Calculate the sum of numbers 1 to 4:

seq:fold(util:function("f:plus", 2), 1 to 4, 0)

Result:

10

Calculate the product of numbers 1 to 4:

seq:fold(util:function("f:product", 2), 1 to 4, 1)

Result:

24

Adding the elements of sequences (4, 7, 6) and (10, 15, 8) element-wise:

seq:map(util:function("f:plus", 2), (4, 7, 6), (10, 15, 8))

Result:

14 22 14

Generating a table from the elements of sequences: (1, 2, 3) and ("Franz", "Klaus", "Erwin"):

seq:map(util:function("f:table-row", 2), 1 to 3, ("Franz", "Klaus", "Erwin"))

Result:

1 Franz
2 Klaus
3 Erwin

Filter out all items greater than 10:

seq:filter(util:function("f:remove", 1), (8, 15, 7, 19, 22, 5))

Result:

15 19 22


View source code