mirror of
https://github.com/swarm-game/swarm.git
synced 2024-09-11 14:46:33 +03:00
14 lines
251 B
Plaintext
14 lines
251 B
Plaintext
// Defining simple recursive functions.
|
|
|
|
def repeat : int -> cmd unit -> cmd unit = \n.\c.
|
|
if (n == 0) {} {c ; repeat (n-1) c}
|
|
end
|
|
|
|
def fact : int -> int = \n:int.
|
|
if (n == 0)
|
|
{1}
|
|
{n * fact (n-1)}
|
|
end
|
|
|
|
def gofar = repeat (fact 4) move end
|