2024-10-09 10:26:28 -07:00
|
|
|
func ping(x:Int->[Text]):
|
2024-04-28 11:58:55 -07:00
|
|
|
if x > 0:
|
2024-08-18 11:44:15 -07:00
|
|
|
return ["ping: $x"] ++ pong(x-1)
|
2024-04-28 11:58:55 -07:00
|
|
|
else:
|
2024-08-18 11:44:15 -07:00
|
|
|
return ["ping: $x"]
|
2024-04-10 08:53:18 -07:00
|
|
|
|
2024-10-09 10:26:28 -07:00
|
|
|
func pong(x:Int->[Text]):
|
2024-04-28 11:58:55 -07:00
|
|
|
if x > 0:
|
2024-08-18 11:44:15 -07:00
|
|
|
return ["pong: $x"] ++ ping(x-1)
|
2024-04-28 11:58:55 -07:00
|
|
|
else:
|
2024-08-18 11:44:15 -07:00
|
|
|
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"]
|