match: _ -> __ for fun

modern-harvey3
Doug Coleman 2018-12-30 20:20:35 -06:00
parent bedbfe512a
commit 9cff14ca01
2 changed files with 4 additions and 4 deletions

View File

@ -39,7 +39,7 @@ MATCH-VARS: ?a ?b ;
{ {
{ { 1 2 } [ t ] } { { 1 2 } [ t ] }
{ { 1 3 } [ t ] } { { 1 3 } [ t ] }
{ _ [ f ] } { __ [ f ] }
} match-cond } match-cond
] unit-test ] unit-test
@ -89,7 +89,7 @@ C: <foo> foo
] unit-test ] unit-test
{ { 2 1 } } [ { { 2 1 } } [
{ "a" 1 2 "b" } { _ ?a ?b _ } { ?b ?a } match-replace { "a" 1 2 "b" } { __ ?a ?b __ } { ?b ?a } match-replace
] unit-test ] unit-test
TUPLE: match-replace-test a b ; TUPLE: match-replace-test a b ;

View File

@ -6,7 +6,7 @@ USING: assocs classes classes.tuple combinators kernel lexer
macros make namespaces parser quotations sequences summary words ; macros make namespaces parser quotations sequences summary words ;
IN: match IN: match
SYMBOL: _ SYMBOL: __
: define-match-var ( name -- ) : define-match-var ( name -- )
create-word-in create-word-in
@ -29,7 +29,7 @@ PREDICATE: match-var < word "match-var" word-prop ;
{ [ dup match-var? ] [ set-match-var ] } { [ dup match-var? ] [ set-match-var ] }
{ [ over match-var? ] [ swap set-match-var ] } { [ over match-var? ] [ swap set-match-var ] }
{ [ 2dup = ] [ 2drop t ] } { [ 2dup = ] [ 2drop t ] }
{ [ 2dup [ _ eq? ] either? ] [ 2drop t ] } { [ 2dup [ __ eq? ] either? ] [ 2drop t ] }
{ [ 2dup [ sequence? ] both? ] [ { [ 2dup [ sequence? ] both? ] [
2dup [ length ] same? [ 2dup [ length ] same? [
[ (match) ] 2all? [ (match) ] 2all?