Skip to content

Instantly share code, notes, and snippets.

View aomoriringo's full-sized avatar
🏠
Working from home

aomoriringo aomoriringo

🏠
Working from home
View GitHub Profile
import Data.Char
import System.IO
import System.Environment
main = do
(command:argList) <- getArgs
dispatch command argList
dispatch :: String -> [String] -> IO ()
dispatch "add" = calc (+)
@aomoriringo
aomoriringo / gist:3299467
Created August 8, 2012 22:37
Project Euler Problem 4 with Haskell
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) ]
@aomoriringo
aomoriringo / pe001.hs
Created August 8, 2012 03:57
Project Euler Problem 0001 with Haskell
--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 ]