Thanks I got it now :)_______________________________________________On Thu, Sep 24, 2015 at 9:45 PM, Kostiantyn Rybnikov <k-bx@k-bx.com> wrote:Hi.
Your function gets passed numbers one by one in the place of x, and its previous result in the place of acc, and it returns a Bool. Initial value in place of acc parameter ("previous result") is put as False (since you begin with answer "no" to question "is it elem?").
Hope this helps.
24 вер. 2015 19:04 "goforgit ." <teztingit@gmail.com> пише:_______________________________________________How is that evaluated to True by foldl in elem'?ghci>>> elem' 3 [1,2,3]and calling it withBut what about the functionwill be evaluated asI understand that with the function
sum' :: (Num a) => [a] -> a
sum' = foldl (+) 0the callghci>>> sum' [1,2,3]
0 + 1 + 2 + 3 = 6
elem' :: (Eq a) => a -> [a] -> Bool
elem' y ys = foldl (\acc x -> if x == y then True else acc) False ysThanks in advance for any explanation to this!
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners