Skip to content

Commit

Permalink
Merge pull request #50 from Lyrkan/fix-compress-example
Browse files Browse the repository at this point in the history
Fix compress example
  • Loading branch information
leonardiwagner authored Nov 5, 2018
2 parents b303f33 + 6f45925 commit 0dc811a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,14 @@ const compress = (numbers) => {
(x, y, xs) => x === y
? compress([x].concat(xs))
: [x].concat(compress([y].concat(xs))),
(x, xs) => x // stopping condition
(x, [y]) => x === y // stopping condition
? [x]
: [x, y],
x => x
)
}

compress([1, 1, 2, 3, 4, 4, 4]) //output: [1, 2, 3]
compress([1, 1, 2, 3, 4, 4, 4]) //output: [1, 2, 3, 4]
```

### License
Expand Down

0 comments on commit 0dc811a

Please sign in to comment.