[MATCH-21] Head-Tail Pattern Matching Fails for Lists Created: 30/Sep/11 Updated: 02/Oct/11 Resolved: 02/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Ambrose Bonnaire-Sergeant | Assignee: | David Nolen |
| Resolution: | Declined | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Head-tail pattern matching only seems to work with vectors. Commit: https://github.com/clojure/core.match/commit/9f4919d855be09a1b32f9e5563ac1c3f5bace642 The following code falls through. (macroexpand appended) (let [x '(1 2 3)]
(match [x]
[[a & as]] :a))
(try (clojure.core/cond (clojure.core/instance? clojure.lang.IPersistentVector x) (try (clojure.core/let [x_left__3201 (clojure.core/subvec x 0 1)] (clojure.core/cond (clojure.core/and (clojure.core/instance? clojure.lang.IPersistentVector x_left__3201) (clojure.core/= (clojure.core/count x_left__3201) 1)) (clojure.core/let [a (clojure.core/nth x_left__3201 0) as (clojure.core/subvec x 1)] :a) :else (throw clojure.core.match.core/backtrack))) (catch java.lang.Exception e__2436__auto__ (throw clojure.core.match.core/backtrack))) :else (throw clojure.core.match.core/backtrack)) (catch java.lang.Exception e__2437__auto__ (throw clojure.core.match.core/backtrack))) |
| Comments |
| Comment by David Nolen [ 02/Oct/11 11:35 AM ] |
|
This is the expected behavior. If you want to match seqs you have to use the seq pattern syntax. |