tomo/test/corecursive_func.tm

16 lines
277 B
Plaintext
Raw Normal View History

func ping(x:Int->[Text]):
2024-04-28 11:58:55 -07:00
if x > 0:
return ["ping: $x"] ++ pong(x-1)
2024-04-28 11:58:55 -07:00
else:
return ["ping: $x"]
2024-04-10 08:53:18 -07:00
func pong(x:Int->[Text]):
2024-04-28 11:58:55 -07:00
if x > 0:
return ["pong: $x"] ++ ping(x-1)
2024-04-28 11:58:55 -07:00
else:
return ["pong: $x"]
2024-04-10 08:53:18 -07:00
2024-04-28 11:58:55 -07:00
func main():
2024-04-12 10:09:31 -07:00
>> ping(3)
= ["ping: 3", "pong: 2", "ping: 1", "pong: 0"]