Gracjan Polak wrote:
Data.List.foldr (Data.Set.delete) s [1,3,5]
or
Data.List.foldl' (flip Data.Set.delete) s [1,3,5]

There will be a day when I finally grasp foldr/foldl :)

Maybe

  http://en.wikibooks.org/wiki/Haskell/Performance_Introduction
  http://www.haskell.org/haskellwiki/Stack_overflow

helps to make that day dawn earlier :)


Note that in your original approach of fold (.) id , it doesn't really matter whether you use foldr or foldl' (except for argument order!) because the latter would only evaluate to a function Data.Set -> Data.Set which is not very useful. In contrast, Duncan's code evaluates to Data.Set , that's what you want to be strict in.


Regards,
apfelmus


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to