Skip to content

Commit

Permalink
Added description of match-1 in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
frenchy64 committed Aug 19, 2011
1 parent 5b75ae3 commit a4aa7d1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,35 @@ For example, this syntax is illegal:
([1] :as w) :a0) ;; Illegal! [1] is a pattern row, not a pattern.
```

Matching single variables
---

`match.core/match-1` is sugar over `match` that allows pattern matching over a single variable, without
an "extra" pair of `[]` around the occurances and each pattern row.

```clojure
(let [x 3]
(match-1 x
1 :a0
2 :a1
:else :a2))
;=> :a2
```

This is equivalent to the following `match`.

```clojure
(let [x 3]
(match [x]
[1] :a0
[2] :a1
:else :a2))
;=> :a2
```

As shown, :else clauses are special, in that they are not implicitely wrapped in `[]`.


Road Map
----

Expand Down

0 comments on commit a4aa7d1

Please sign in to comment.