@ -> ^, functional example
This commit is contained in:
11
examples/functional.zr
Normal file
11
examples/functional.zr
Normal file
@@ -0,0 +1,11 @@
|
||||
func square[x: i64] : i64
|
||||
return x * x
|
||||
|
||||
func sum[a: i64, b: i64] : i64
|
||||
return a + b
|
||||
|
||||
func main[] : i64
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
|
||||
|> alg.map(^square)
|
||||
|> alg.reduce(^sum, 0)
|
||||
|> io.println_i64()
|
||||
Reference in New Issue
Block a user