Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* src/main/clojure/clojure/core/match.clj: add group-patterns - still…

… not quite right
  • Loading branch information...
commit 402149629ea69154026610ddc166d19dd3e3564c 1 parent f005551
@swannodette swannodette authored
View
5 src/main/clojure/clojure/core/match.clj
@@ -542,6 +542,11 @@
(trace-dag "Add fail-node as default matrix for next node (specialized matrix empty)")
(fail-node)))))
+ (group-patterns [[p & prs :as ps]]
+ (if (seq ps)
+ (let [[fs rs] ((juxt filter remove) #(= (type p) (type %)) prs)]
+ (concat (cons p fs) (group-patterns rs)))))
+
;; analyze vector patterns, if a vector-pattern containing a rest pattern
;; occurs, drop all previous vector patterns that it subsumes. note this
;; is a bit hard coding that should be removed when get a better sense
View
10 src/test/clojure/clojure/core/match/test/core.clj
@@ -561,3 +561,13 @@
[["baz" a b]] :a3
:else :a4)
:a0)))
+
+;; FIXME
+(deftest match-group-type-1
+ (is (= (match [[2]]
+ [[1]] :a0
+ [1] :a1
+ [[2]] :a2
+ [2] :a3
+ :else :a4)
+ :a0)))
Please sign in to comment.
Something went wrong with that request. Please try again.