Set puzzle: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
Thundergnat (talk | contribs) m (Fix Perl6 -> Raku links and comments) |
||
Line 263: | Line 263: | ||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
<lang autohotkey>; Generate deck; card encoding from |
<lang autohotkey>; Generate deck; card encoding from Raku |
||
Loop, 81 |
Loop, 81 |
||
deck .= ToBase(A_Index-1, 3)+1111 "," |
deck .= ToBase(A_Index-1, 3)+1111 "," |
||
Line 2,792: | Line 2,792: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
{{trans| |
{{trans|Raku}} |
||
It's actually slightly simplified, since generating Enum classes |
It's actually slightly simplified, since generating Enum classes |
||
and objects would be overkill for this particular task. |
and objects would be overkill for this particular task. |
||
Line 2,799: | Line 2,799: | ||
use warnings; |
use warnings; |
||
# This code was adapted from the |
# This code was adapted from the Raku solution for this task. |
||
# Each element of the deck is an integer, which, when written |
# Each element of the deck is an integer, which, when written |
||
Line 3,294: | Line 3,294: | ||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
(formerly Perl 6) |
(formerly Perl 6) |
||
The trick here is to allocate three different bits for each enum, with the result that the cards of a matching set OR together to produce a 4-digit octal number that contains only the digits 1, 2, 4, or 7. This OR is done by funny looking <tt>[+|]</tt>, which is the reduction form of <tt>+|</tt>, which is the numeric bitwise OR. (Because |
The trick here is to allocate three different bits for each enum, with the result that the cards of a matching set OR together to produce a 4-digit octal number that contains only the digits 1, 2, 4, or 7. This OR is done by funny looking <tt>[+|]</tt>, which is the reduction form of <tt>+|</tt>, which is the numeric bitwise OR. (Because Raku stole the bare <tt>|</tt> operator for composing junctions instead.) |
||
<lang perl6>enum Color (red => 0o1000, green => 0o2000, purple => 0o4000); |
<lang perl6>enum Color (red => 0o1000, green => 0o2000, purple => 0o4000); |
||
enum Count (one => 0o100, two => 0o200, three => 0o400); |
enum Count (one => 0o100, two => 0o200, three => 0o400); |