Comment by ux266478

Comment by ux266478 a day ago

0 replies

FP is principally about function composition, folds and zippers. I still find myself thinking in terms of iteration, it's just not expressed as a for-loop. Instead, the iteration conditions are expressed by the composed function which builds a list, and the body of the for-loop is expressed by the composed function applied to the members of the list.

  for(int i = 0; i < N; ++i) { ... }
becomes

  foldl (fn (i, acc) => ...) 0 (range N)
It's technically recursion, but I don't really see any of it, and I don't really think about it that way.