]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/match/match.factor
factor: trim using lists
[factor.git] / basis / match / match.factor
index b5735b834f885f607815375d48fa4843cae9acae..855672fdc4a05a55f21894e0b1fc84f200d11dd3 100644 (file)
@@ -3,8 +3,7 @@
 !
 ! Based on pattern matching code from Paul Graham's book 'On Lisp'.
 USING: assocs classes classes.tuple combinators kernel lexer
-macros make namespaces parser quotations sequences summary words
-;
+make namespaces parser quotations sequences summary words ;
 IN: match
 
 SYMBOL: _
@@ -39,7 +38,7 @@ PREDICATE: match-var < word "match-var" word-prop ;
             2dup [ class-of ] same? [
                 [ tuple-slots ] bi@ [ (match) ] 2all?
             ] [ 2drop f ] if ] }
-        { [ t ] [ 2drop f ] }
+        [ 2drop f ]
     } cond ;
 
 : match ( value1 value2 -- bindings )
@@ -51,7 +50,7 @@ M: no-match-cond summary drop "Fall-through in match-cond" ;
 
 MACRO: match-cond ( assoc -- quot )
     <reversed>
-    dup ?first callable? [ unclip ] [ [ throw-no-match-cond ] ] if
+    dup ?first callable? [ unclip ] [ [ no-match-cond ] ] if
     [
         first2
         [ [ dupd match ] curry ] dip
@@ -84,7 +83,7 @@ M: tuple replace-patterns tuple>array replace-patterns >tuple ;
     (match-first) drop ;
 
 : (match-all) ( seq pattern-seq -- )
-    [ nip ] [ (match-first) swap ] 2bi
+    [ (match-first) ] keep
     [ , [ swap (match-all) ] [ drop ] if* ] [ 2drop ] if* ;
 
 : match-all ( seq pattern-seq -- bindings-seq )