Skip to content

Instantly share code, notes, and snippets.

@freeformz
Created April 2, 2011 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freeformz/899221 to your computer and use it in GitHub Desktop.
Save freeformz/899221 to your computer and use it in GitHub Desktop.
Haskell
largestDivisible :: Integer
largestDivisible = head (filter p [100000,99999..])
where p x = x `mod` 3829 == 0
Solved!
Oh duh. It's a function!
p x = x `mod` 3829 == 0
p takes x and performs
x `mod` 3829 == 0
Other variants
with let:
largestDivisible' :: Integer
largestDivisible' =
let p x = x `mod` 3829 == 0
in head (filter p [100000,99999..])
with a λ
largestDivisible'' :: Integer
largestDivisible'' = head (filter (\x -> x `mod` 3829 == 0) [100000,99999..])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment