[Haskell-cafe] Fast code question

Ketil Malde ketil at malde.org
Fri Jun 5 04:32:48 EDT 2009


Bartosz Wójcik <bartek at sudety.it> writes:

> myConcat' :: (Integral a) => Integer -> [a] -> [Integer] 
                  :
> myConcat' acc (x:xs) = case x `mod` 16 of 
                  :
>                 10 -> fail $ show acc
>                 11 -> fail $ show acc
>                 14 -> fail $ show acc
                        ^^^^^^^^^^^^^^^
Since you're in the list monad, this just returns [].  Perhaps you
mean error rather than fail?  (And isn't it more useful to print x
than acc?)

>                  v  -> myConcat' (100*acc + (numberOf . fromIntegral) x) xs 
>          where restOf n = (n - 12) `div` 16 
>                numberOf n = n - 6 * (n `div` 16) 

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list