Created
December 17, 2016 15:00
-
-
Save blippy/0c21c606e7b72d539f413339f372e395 to your computer and use it in GitHub Desktop.
APL in Perl 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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