A Look At Folding

Currently I’m sitting the FP101x from edX. A portion of the homework was on foldr and foldl (i.e. right fold and left fold). This got me thinking how I might think about these ideas. Lets firstly compare the two. Prelude > foldr (-) 0 [1..4] -2 Prelude > foldl (-) 0 [1..4] -10 Why are they different? How do they work? foldl is probably the intuitive one. It simply “inserts” the function between the elements. [Read More]

Using J To Solve Euler Project

Today I thought I’ll have a quick look at J and how to use J to solve some Euler project problems. This post will go through one possible way to solve the first Euler project problem. If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. [Read More]