RosettaCodeData/Task/Catamorphism/Nim/catamorphism.nim

20 lines
488 B
Nim
Raw Permalink Normal View History

2016-12-05 23:44:36 +01:00
import sequtils
block:
let
numbers = @[5, 9, 11]
addition = foldl(numbers, a + b)
substraction = foldl(numbers, a - b)
multiplication = foldl(numbers, a * b)
2018-08-17 15:15:24 +01:00
words = @["nim", "is", "cool"]
2016-12-05 23:44:36 +01:00
concatenation = foldl(words, a & b)
block:
let
numbers = @[5, 9, 11]
addition = foldr(numbers, a + b)
substraction = foldr(numbers, a - b)
multiplication = foldr(numbers, a * b)
2018-08-17 15:15:24 +01:00
words = @["nim", "is", "cool"]
2016-12-05 23:44:36 +01:00
concatenation = foldr(words, a & b)