Skip to content

Instantly share code, notes, and snippets.

@rafaelcaricio
Created July 17, 2011 23:47
Show Gist options
  • Save rafaelcaricio/1088256 to your computer and use it in GitHub Desktop.
Save rafaelcaricio/1088256 to your computer and use it in GitHub Desktop.
Blog post - Implementando uma Toy Programming Language
filter = { _array, _func:
map( map(_array, _func), { _item:
if ( _item, {
_item
});
});
};
for = { number, block:
_i = 0;
while { i < number:
_i++;
block(_i - 1)
}
}
a = [];
for(10, { i :
*a[i] = i
});
if = { _op, _true, _false:
_op && _true() || _false()
};
k = 0;
if ( x == 2, {
*k = 2
}, {
*k = 3
});
map = { _array, func:
_x = len(_array);
while { _x > 0:
_x--;
_func(_array[_x - 1])
}
};
Pessoa = Class({
nome = "";
falar = { texto:
print(texto);
};
});
p = Pessoa("Rafael Caricio");
print( p("nome") );
p("falar")("Hello world!");
i = 10;
while { i > 0:
print( i );
*i--
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment