Skip to content

Instantly share code, notes, and snippets.

@freeformz
Created April 2, 2011 04:03
Embed
What would you like to do?
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