[solved] What is wrong here


hi need some feedback on what am I doing wrong here

Please post an error, a failed test or a specific question; college assignments are not allowed here.

ok did not know that, thanks for the info though. In the meantime figured it out by myself

If the Haskell forum could be divided into two separate subforums, one for users of Haskell, another one for the developers and researchers of Haskell/GHC, like rust’s https://users.rust-lang.org/ and https://internals.rust-lang.org/?

I don’t know exactly what @f-a means because his response is very brief. But I would say it does not have anything to do with Haskell users or GHC developers. It is just that asking for answers to homework questions violates academic integrity.

In this case a question has been posted and a possibly faulty answer, but there is not really a way for us to help without first figuring out the answer to the question for ourselves. If @pain89 can ask about a specific error message or ask a more specific question about a part of this assignment, then I think that would be fine here on this forum.

In this case I think I see the problem, which is the bla (x:xs) in the pattern match on the third line. In Haskell pattern matching only works on data constructors, so you can’t use normal functions like bla in a pattern match. There are several ways around this, but the simplest is just to make a second wrapper function:

digit2List :: String -> [Int]
digit2List xs = digit2ListHelper (bla xs)
  where
    digits2ListHelper :: [Int] → [Int]
    digits2ListHelper [] = []
    digits2ListHelper (x:xs)
      | x >= 48 && x <= 57 = (x - 48) : digits2ListHelper xs
      | x >= 65 && x <= 70 = (x - 55) : digits2ListHelper xs

I would also like to note that the pattern match in the bla function is superfluous and even harmful, instead you should write:

bla::String → [Int]
bla xs = map ord xs
1 Like