def op(acc x) if mod(x 2) +(acc x) else acc end end # generate a list with integers from 1 to n def range(n) def genrec(l limit n) if <(n limit) @genrec(+(l list(n)) limit +(n 1)) else l end end genrec(list() n 0) end # add odd numbers from 0 to 1000 def main() display(fold(0 op range(1001))) end