Created
January 14, 2013 19:34
-
-
Save JakubOboza/4532654 to your computer and use it in GitHub Desktop.
This is first set of examples of JO programming language designed by me.
This file contains hidden or 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
add x y = x + y | |
add 5 6 # -> 11 | |
(add 5 6) # -> 11 | |
map (\x -> x + 1) [2,3,4,5] # -> [3,4,5,6] | |
loop x = | |
puts x | |
(loop x + 1) | |
loop2 x = | |
puts x | |
loop x + 1 | |
loop 0 # prints 1\n2\n3\n.... like int x = 0; while(1){printf("%d\n", x++)} /lol | |
countdown x = | |
puts x | |
if x < 1 | |
x | |
else | |
(countdown x - 1) | |
[x*x | x <- [1,2,3,4,5], x < 5] # -> [1,4,9,16] | |
Process.spawn # primitive to spawn light process with its own GC. Light process autonomic. | |
loop _ = | |
receive | |
Int i -> puts "Yay a number" | |
- -> puts "Other stuffz" | |
loop 0 | |
pid = Process.spawn loop | |
pid <- 1 # prints Yay a number\n in pid process | |
pid <- "Lolz" # prints Other stuffz\n in pid process |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment