07.26.07

Exercise 5.3

Posted in Uncategorized at 10:33 pm by admin

Note: Anonymous functions are not introduced until chapter 9! But they are an easy way to solve problems like this.

mylength :: [a] -> Int
mylength xs = foldl (\x _ -> x + 1) 0 xs

1 Comment »

  1. Minime said,

    May 3, 2009 at 12:17 am

    same one without anonymous function
    length1 x = foldl count 0 x where count x y = x + 1

Leave a Comment