[Haskell-cafe] Where's the error in this snippet of code?

Stefan Holdermans sholderm at students.cs.uu.nl
Wed Mar 24 21:04:14 EST 2004


  AG> Ignore the layout
  AG> I can't find the error, running it gives parse error during 
  AG> compile on pStack, it is not very descriptive and I don't 
  AG> what is wrong.

Well, ignoring the layout is not a good thing here, since that's the one of
the causes for your program to not compile. Besides that, the recursive call
to pStack needs a second argument.

> digStack      :: Integer->Integer->[Integer]
> digStack a b
>   | a == 0    =  []
>   | otherwise =  (mod a b):(digStack (div a b) b)

> pStack          :: [Integer] -> Integer -> [Integer]
> pStack [] _     =  []
> pStack (x:xs) a =  digStack x a ++ pStack xs {- ADDED: -} a



More information about the Haskell-Cafe mailing list