completed 1.29 in Scheme, Haskell and JavaScript