Skip to content

Instantly share code, notes, and snippets.

@ahalbert
Created August 12, 2016 14:48
Show Gist options
  • Save ahalbert/f4536b2c4d03ab7cb7fadf95298a04c0 to your computer and use it in GitHub Desktop.
Save ahalbert/f4536b2c4d03ab7cb7fadf95298a04c0 to your computer and use it in GitHub Desktop.
#CORRECT:
say ("SSdtIGtpb".comb #Removes first element and last element, which are empty
==> map ( { @base64Table.grep($_, :k).Str.Int.base(2).Str }) #Maps each hex item to the corresponding binary string. grep returns Seq, so I have to convert it into a string to get the value.
==> map { binaryLeftPad($_, 6) } #Pads the binary elements
).join; #Turns @r into a single string
#Incorrect:
say ("SSdtIGtpb".comb #Removes first element and last element, which are empty
==> map { @base64Table.grep($_, :k).Str.Int.base(2).Str } #Maps each hex item to the corresponding binary string. grep returns Seq, so I have to convert it into a string to get the value.
==> map { binaryLeftPad($_, 6) } #Pads the binary elements
).join; #Turns @r into a single string
===SORRY!=== Error while compiling /Users/ahalbert/workspace/crypto/test.p6
Bogus statement
at /Users/ahalbert/workspace/crypto/test.p6:19
------> Table.grep($_, :k).Str.Int.base(2).Str }⏏ #Maps each hex item to the correspondin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment