2008-07-19から1日間の記事一覧

現実逃避的に書いたので

http://blog.tmorris.net/scala-exercises-for-beginners/ せっかくなので貼っておく。 object Exercise { def succ(n: Int) = n + 1 def pred(n: Int) = n - 1 def add(x:Int, y:Int) : Int = if ( x == 0 ) y else add(pred(x), succ(y)) def sum(xs: List…

久しぶりの Haskell

そして久しぶりの Project Euler。今は単純作業なお仕事ばかりやっているのでパズルで気分転換。 isEquiv [] [] = True isEquiv (x:xs) ys | elem x ys = isEquiv xs $ filter (/=x) ys | otherwise = False isEquiv _ _ = False isOK x = let (n:ns) = map …