def op(acc x) if mod(x 2) +(acc x) else acc end end # generate a list 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 1001 def main() display(fold(0 op range(1001))) end