Haskellãçãæ¸ãã¦ã¹ãããªä»¶ã«ã¤ãã¦
ï¼ä¸»ã«ç§ã®ã¾ããã§ï¼æµè¡ã£ã¦ããããã¨ãããã¼ãã¼ãªçç±ã§Haskellãåå¼·ä¸ã§ãã
åç´ã«çãæ¸ãã¦ããããªã¨æãã¾ãã
ä¾ãã°ããªã¹ããå¼æ°ã«æ¸¡ãã¦ãå¶æ°ã®è¦ç´ ã ãè¿ãé¢æ°ãªããããã ãã§ãï½ã
evenList :: [Int] -> [Int] evenList [] = [] evenList (x:xs)| even x = x : evenList xs | otherwise = evenList xs
ãªã¹ãå å 表è¨ã使ãã¨ãã£ã¨çãã
evenList :: [Int] -> [Int] evenList xs = [ n | n <- xs, even n]
ãªã¹ãå å 表è¨ã¯ããã°ã©ãå¨äºç å¿ã«ãã³ãã·ã£ã ã£ãã®ã ãã©ãè¤éãªå¦çã®å ´åããããããè¦ãç®ã«ãªãããã§ãæ°ãã¤ãããã¨æã£ãã
ã¡ãªã¿ã«éè¤ãåãé¤ããªãã¦ä»æ§å¤æ´ããã£ã¦ãã¸ã£ã¡ããã§ãã
evenList3 xs = nub $ evenList xs