fork download
  1. -- import Text.Parsec
  2. -- import Text.Regex.Posix
  3.  
  4. oddEx :: Integer -> Bool
  5. oddEx n = case quotRem n 10 of
  6. (0,0) -> False
  7. (0,r) -> odd r
  8. (q,r) -> odd r && oddEx q
  9.  
  10. oddEx' :: Integer -> Bool
  11. oddEx' = all (flip notElem "02468") . show
  12.  
  13. -- oddEx'' :: Integer -> Bool
  14. -- oddEx'' = (== "") . (=~ "[02468]") . show
  15.  
  16. -- oddEx''' :: Integer -> Bool
  17. -- oddEx''' = either (const False) (const True) . parse (many1 (noneOf "02468") >> eof) "" . show
  18.  
  19. main :: IO ()
  20. main = do
  21. let xs = [0..1000]
  22. a = filter oddEx xs
  23. print $ a
  24. print $ all ((a ==) . flip filter xs) [oddEx' -- ,oddEx'' ,oddEx'''
  25. ]
  26.  
Success #stdin #stdout 0s 6272KB
stdin
Standard input is empty
stdout
[1,3,5,7,9,11,13,15,17,19,31,33,35,37,39,51,53,55,57,59,71,73,75,77,79,91,93,95,97,99,111,113,115,117,119,131,133,135,137,139,151,153,155,157,159,171,173,175,177,179,191,193,195,197,199,311,313,315,317,319,331,333,335,337,339,351,353,355,357,359,371,373,375,377,379,391,393,395,397,399,511,513,515,517,519,531,533,535,537,539,551,553,555,557,559,571,573,575,577,579,591,593,595,597,599,711,713,715,717,719,731,733,735,737,739,751,753,755,757,759,771,773,775,777,779,791,793,795,797,799,911,913,915,917,919,931,933,935,937,939,951,953,955,957,959,971,973,975,977,979,991,993,995,997,999]
True