Skip to content

Instantly share code, notes, and snippets.

View marcoonroad's full-sized avatar
🦋
the Future() has been CANCELLED and we .Restart() the DEAD Event[] from the past

Marco Aurélio da Silva marcoonroad

🦋
the Future() has been CANCELLED and we .Restart() the DEAD Event[] from the past
View GitHub Profile
function defmulti(keyfn)
if not keyfn then
keyfn = function(...) return ... end
end
local multi = {
_keyfn = keyfn,
_methods = {}
}
setmetatable(multi, {
__call = function(self, ...)
@marcoonroad
marcoonroad / INSTALL.md
Last active August 29, 2015 14:08 — forked from namuol/INSTALL.md

rage-quit support for bash

HOW TO INSTALL

Put flip somewhere in your $PATH and chmod a+x it.

Copy fuck into ~/.bashrc.

@marcoonroad
marcoonroad / oopt.bsh.java
Last active August 29, 2015 14:09
Small test of OOP Prototype-based in BeanShell as example...
// oop prototype-based beanshell test
Point(A, B) {
x = A;
y = B;
a = A;
b = B;
move(X, Y) {
@marcoonroad
marcoonroad / SimpleIter.pm
Created November 22, 2014 03:45
A simple iterator test at Perl 5...
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:
@marcoonroad
marcoonroad / anonrec.pl6
Created November 23, 2014 23:47
Anonymous recursion using some Y combinator function at Perl 6...
#!/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 {
@marcoonroad
marcoonroad / feed-test.pl6
Created November 26, 2014 04:16
Just a feed operator ('==>') test on Perl6...
#!/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..." }
}
@marcoonroad
marcoonroad / funct.bsh.java
Created November 30, 2014 01:51
A simple 'functional'-like test at BeanShell...
// 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;
}
@marcoonroad
marcoonroad / transfer.t
Created December 1, 2014 16:29
"Transfer" function test in Perl6 using Coro::Simple...
#!/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
@marcoonroad
marcoonroad / callcc.js
Last active August 29, 2015 14:11
A test with call-with-current-continuation (Scheme inspired) in JS...
// 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
}