Last active
March 4, 2019 13:47
-
-
Save anupkalburgi/af7791515adc7232ea255d6eb243213b to your computer and use it in GitHub Desktop.
ch7.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snoc :: a -> [a] -> [a] | |
snoc x xs = xs ++ [x] | |
rr :: [a] -> [a] | |
rr = foldr (snoc) [] | |
rre :: [a] -> [a] | |
rre = foldr ( \ x xs -> xs ++ [x] ) [] -- why is this wrong | |
{- | | |
ch7.hs:18:15: error: | |
313 • Couldn't match expected type ‘[a]’ | |
314 with actual type ‘[[a]] -> [[a]]’ | |
315 • In the first argument of ‘foldr’, namely | |
316 ‘(\ _ x xs -> xs ++ [x])’ | |
317 In the expression: foldr (\ _ x xs -> xs ++ [x]) [] | |
318 In an equation for ‘rre’: rre = foldr (\ _ x xs -> xs ++ [x]) [] | |
319 • Relevant bindings include | |
320 rre :: [a] -> [a] (bound at ch7.hs:18:1) | |
321 | | |
32218 | rre = foldr ( \_ x xs -> xs ++ [x] ) [] | |
323 | ^^^^^^^^^^^^^^^^^^^^ | |
324Failed, no modules loaded. | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment