Created
May 9, 2014 00:06
-
-
Save aiya000/e360d514464391b8a570 to your computer and use it in GitHub Desktop.
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
loseNumber = filter (/=5) [0..9] | |
f :: [Int] -> [Int] | |
f [] = [] | |
f [_] = [] | |
f (a:b:xs) = if (a - b /= -1) then a : f (b:xs) else a : g (b:xs) | |
where g ys = map (-1) ys | |
main = putStrLn $ show $ f loseNumber |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(-)は単項演算子として定義されているので、mapが適用させる関数として渡す事ができません。
x-1=yをやりたいのであれば、(-1)の代わりにsubtract 1を使うとよいでしょう。
後、この関数は無事に動いても抜けている数を見つけ出せないようです。
修正案をideoneに置いときますね
http://ideone.com/WhJ8pt