Skip to content

Instantly share code, notes, and snippets.

@damncabbage
Created June 17, 2014 08:56
Show Gist options
  • Save damncabbage/72d9a3b7859445576ac2 to your computer and use it in GitHub Desktop.
Save damncabbage/72d9a3b7859445576ac2 to your computer and use it in GitHub Desktop.
NICTA course exercises.
headOr :: a -> List a -> a
headOr d l = foldRight (\x y -> x) d l -- This anonymous function here is dumb.
product :: List Int -> Int
product l = foldRight (\x y -> x * y) 1 l
-- Alternative:
-- product l = foldRight (*) 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment