Loading docs/haskell/hffp/ch09-exercises-lists.md +16 −2 Original line number Diff line number Diff line Loading @@ -1247,3 +1247,17 @@ myElem e = myAny (e ==) Point-free on the list element (we don't do `myElem e xs`, but `myElem e`). And we do _sectioning_ and _partial application_ of `==` to `e`. #### myReverse Get `x` from the head of the list, and concatenate it to the end :) We put it (the `x`) inside brackets to make a list out of it, as `++` concatenates lists (both operands must be lists). ```haskell myRev :: [a] -> [a] myRev [] = [] myRev (x : xs) = myRev xs ++ [x] -- -- λ> myRev "xyz" -- "zyx" -- ``` Loading
docs/haskell/hffp/ch09-exercises-lists.md +16 −2 Original line number Diff line number Diff line Loading @@ -1247,3 +1247,17 @@ myElem e = myAny (e ==) Point-free on the list element (we don't do `myElem e xs`, but `myElem e`). And we do _sectioning_ and _partial application_ of `==` to `e`. #### myReverse Get `x` from the head of the list, and concatenate it to the end :) We put it (the `x`) inside brackets to make a list out of it, as `++` concatenates lists (both operands must be lists). ```haskell myRev :: [a] -> [a] myRev [] = [] myRev (x : xs) = myRev xs ++ [x] -- -- λ> myRev "xyz" -- "zyx" -- ```