Skip to content

Instantly share code, notes, and snippets.

@blippy
Created December 17, 2016 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blippy/0c21c606e7b72d539f413339f372e395 to your computer and use it in GitHub Desktop.
Save blippy/0c21c606e7b72d539f413339f372e395 to your computer and use it in GitHub Desktop.
APL in Perl 6
# Blogged about here:
# https://mcturra2000.wordpress.com/2016/12/14/perl6-needs-more-sigils/#comment-1702
my @a1 := 4, 5 ,6;
say @a1;
#say(@a1.rotate(1));
# or equivalently
#
# Φ in vim is C-k F* (Unicode U+03A6)
sub infix:<Φ> ($n, @arr) { @arr.rotate($n); }
say (-1 Φ @a1) ;
# UNICODE 'DIVISION SIGN' (U+00F7), vim C-k -:
sub _div(@pair) { @pair[0] / @pair[1]};
sub infix:<÷> (@num, @denom) { map &_div , zip(@num, @denom) };
say @a1 ÷ (-1 Φ @a1);
#say 1 [&Φ] @a1 ;
#say @a1 / ( 1 [&Φ] @a1);
#sub Φ1(@arr) { Φ(1, @arr); };
#say (Φ1 @a1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment