This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Char | |
import System.IO | |
import System.Environment | |
main = do | |
(command:argList) <- getArgs | |
dispatch command argList | |
dispatch :: String -> [String] -> IO () | |
dispatch "add" = calc (+) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List (foldl') | |
isPalindrome :: Integer -> Bool | |
isPalindrome x = show x == reverse (show x) | |
main = do | |
print $ foldl' max 0 [ a*b | a<-[100..999], b<-[100..999], isPalindrome (a*b) ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--http://projecteuler.net/problem=1 | |
--If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
--Find the sum of all the multiples of 3 or 5 below 1000. | |
main = do | |
print $ sum [ x | x<-init[1..1000], x`mod`==0 || x`mod`5==0 ] |
NewerOlder