Skip to content

Instantly share code, notes, and snippets.

@aiya000
Created May 9, 2014 00:06
Show Gist options
  • Save aiya000/e360d514464391b8a570 to your computer and use it in GitHub Desktop.
Save aiya000/e360d514464391b8a570 to your computer and use it in GitHub Desktop.
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
@func-hs
Copy link

func-hs commented May 9, 2014

(-)は単項演算子として定義されているので、mapが適用させる関数として渡す事ができません。
x-1=yをやりたいのであれば、(-1)の代わりにsubtract 1を使うとよいでしょう。
後、この関数は無事に動いても抜けている数を見つけ出せないようです。
修正案をideoneに置いときますね
http://ideone.com/WhJ8pt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment