Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
santinic authored Dec 15, 2018
1 parent 252d3d0 commit d13ef4d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ lisp([reduce, plus, [1, 2, 3]]); // => 6
## You can match so many things!
```javascript
let {match, _, NUMBER, STRING} = require("pampy");
let {match, _} = require("pampy");

match(x,
3, "this matches the number 3",

NUMBER, "matches any javascript number",
Number, "matches any javascript number",

[STRING, NUMBER], (a, b) => "a typed list [a, b] that you can use in a function",
[String, Number], (a, b) => "a typed list [a, b] that you can use in a function",

[1, 2, _], "any list of 3 elements that begins with [1, 2]",

Expand Down Expand Up @@ -119,15 +119,15 @@ Admittedly using `_` as key is a bit of a trick, but it works for most situation
| Pattern Example | What it means | Matched Example | Arguments Passed to function | NOT Matched Example |
| --------------- | --------------| --------------- | ----------------------------- | ------------------ |
| `"hello"` | only the string `"hello"` matches | `"hello"` | nothing | any other value |
| `NUMBER` | Any javascript number | `2.35` | `2.35` | any other value |
| `STRING` | Any javascript string | `"hello"` | `"hello"` | any other value |
| `Number` | Any javascript number | `2.35` | `2.35` | any other value |
| `String` | Any javascript string | `"hello"` | `"hello"` | any other value |
| `Array` | Any array object | `[1, 2]` | `[1, 2]` | any other value |
| `_` | Any object | | that value | |
| `ANY` | The same as `_` | | that value | |
| `[1, 2, _]` | A list that starts with 1, 2 and ends with any value | `[1, 2, 3]` | `3` | `[1, 2, 3, 4]` |
| `[1, 2, TAIL]` | A list that start with 1, 2 and ends with any sequence | `[1, 2, 3, 4]`| `[3, 4]` | `[1, 7, 7, 7]` |
| `{type:'dog', age: _ }` | Any dict with `type: "dog"` and with an age | `{type:"dog", age: 3}` | `3` | `{type:"cat", age:2}` |
| `{type:'dog', age: NUMBER }` | Any dict with `type: "dog"` and with an numeric age | `{type:"dog", age: 3}` | `3` | `{type:"dog", age:2.3}` |
| `{type:'dog', age: Number }` | Any dict with `type: "dog"` and with an numeric age | `{type:"dog", age: 3}` | `3` | `{type:"dog", age:2.3}` |
| `null` | only `null` | `null` | nothing | any other value |
| `undefined` | only `undefined` | `undefined` | nothing | any other value |
Expand Down

0 comments on commit d13ef4d

Please sign in to comment.