Commit e1ec5446 authored by Fernando Basso's avatar Fernando Basso
Browse files

haskell(hffp,ch09: Add myRev stdfn

parent e69a4b13
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -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"
--
```