Put flip
somewhere in your $PATH
and chmod a+x
it.
Copy fuck
into ~/.bashrc
.
function defmulti(keyfn) | |
if not keyfn then | |
keyfn = function(...) return ... end | |
end | |
local multi = { | |
_keyfn = keyfn, | |
_methods = {} | |
} | |
setmetatable(multi, { | |
__call = function(self, ...) |
// oop prototype-based beanshell test | |
Point(A, B) { | |
x = A; | |
y = B; | |
a = A; | |
b = B; | |
move(X, Y) { |
package SimpleIter; | |
use feature qw| state |; | |
use base Exporter; | |
@EXPORT_OK = qw| iter |; | |
sub iter { | |
my $array = shift; | |
return sub { | |
# this is why the 'state' variables are nice: |
#!/usr/bin/perl6 | |
use v6; | |
sub ycomb ($f) { -> $x { $f(ycomb $f)($x) } } | |
# show the first 16 numbers from fibonacci sequence | |
0 ... 15 ==> map ycomb -> $lambda { | |
# using anonymous recursion | |
-> $n { |
#!/usr/bin/perl6 | |
my &echo = &say; | |
my &whether = -> &block, $flag { $flag ?? block( ) !! False } | |
my &otherwise = -> &block, $flag { !$flag ?? block( ) !! $flag } | |
my &test = -> $flag { | |
$flag ==> whether { "Is true!" } ==> otherwise { "Is false..." } | |
} |
// functional-programming-like test at beanshell | |
// prototype | |
list (xs) { | |
// transform a list | |
map (f) { | |
ys = new ArrayList ( ); | |
for (x: xs) ys.add (f.core (x)); | |
return ys; | |
} |
#!/usr/bin/perl6 | |
use v6; | |
# a transfer function test | |
use Test; | |
use Coro::Simple; | |
# transfer definition: |
-- junctions perl6-like at lua -- | |
local coro = coroutine.wrap | |
local yield = coroutine.yield | |
function iter (xs) | |
return coro (function ( ) | |
for _, x in ipairs (xs) do yield (x) end | |
end) | |
end |
// nice continuations :) | |
// method for pass current function like a continuation | |
Function.prototype.callcc = function (expr) { | |
let cont = this; | |
let rest = expr(cont); | |
if (rest.aborted) | |
return rest.value; | |
return cont(rest.value); // else | |
} |