Skip to content

Instantly share code, notes, and snippets.

@gfldex
Last active Jul 16, 2016
Embed
What would you like to do?
use v6;
# multi sub infix:<∘> (&f, &g --> Block) { (&f).count > 1 ?? -> |args { f |g |args } !! -> |args { f g |args } }
multi sub infix:<oo> (&f, &g --> Block) {
do if (&f).count > 1 {
do if (&g).count == 1 {
-> |args { f |(args>>.&g) }
}else{
-> |args { f |g |args }
}
}else{
-> |args { f g |args }
}
}
my &ieq = &infix:<eq> oo &lc;
say [ "abc" [&ieq] "abc", "Abc" [&ieq] "abc", "abc" [&ieq] "bbc", ];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment