Created
July 17, 2011 23:47
-
-
Save rafaelcaricio/1088256 to your computer and use it in GitHub Desktop.
Blog post - Implementando uma Toy Programming Language
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
filter = { _array, _func: | |
map( map(_array, _func), { _item: | |
if ( _item, { | |
_item | |
}); | |
}); | |
}; |
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
for = { number, block: | |
_i = 0; | |
while { i < number: | |
_i++; | |
block(_i - 1) | |
} | |
} |
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
a = []; | |
for(10, { i : | |
*a[i] = i | |
}); |
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
if = { _op, _true, _false: | |
_op && _true() || _false() | |
}; |
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
k = 0; | |
if ( x == 2, { | |
*k = 2 | |
}, { | |
*k = 3 | |
}); |
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
map = { _array, func: | |
_x = len(_array); | |
while { _x > 0: | |
_x--; | |
_func(_array[_x - 1]) | |
} | |
}; |
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
Pessoa = Class({ | |
nome = ""; | |
falar = { texto: | |
print(texto); | |
}; | |
}); | |
p = Pessoa("Rafael Caricio"); | |
print( p("nome") ); | |
p("falar")("Hello world!"); |
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
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