Skip to content

Commit

Permalink
Add a count example for arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
bas080 committed Nov 18, 2021
1 parent 514d3ab commit 7c97d89
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,20 @@ patroon(
Index 6 has value 7
```

A function that returns the lenght of an array:

```js ./tape-test
const count = patroon(
[_], ([, ...xs]) => 1 + count(xs),
[], 0
)

count([0,1,2,3])
```
```
4
```

A function that looks for a certain pattern in an array:

```js ./tape-test
Expand Down Expand Up @@ -531,7 +545,7 @@ npx nyc npm t | npx tap-nyc
npx nyc check-coverage
```
```
> patroon@0.4.1 test
> patroon@0.4.2 test
> tape ./src/index.test.js
-------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
Expand All @@ -545,7 +559,7 @@ npx nyc check-coverage
total: 15
passing: 15
duration: 703ms
duration: 722ms
```

Expand Down
11 changes: 11 additions & 0 deletions README.mz
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ patroon(
)([1, 2, 3, 4, 5, 6, 7])
```

A function that returns the lenght of an array:

```js ./tape-test
const count = patroon(
[_], ([, ...xs]) => 1 + count(xs),
[], 0
)

count([0,1,2,3])
```

A function that looks for a certain pattern in an array:

```js ./tape-test
Expand Down

0 comments on commit 7c97d89

Please sign in to comment.