match: _ -> __ for fun
parent
bedbfe512a
commit
9cff14ca01
|
@ -39,7 +39,7 @@ MATCH-VARS: ?a ?b ;
|
|||
{
|
||||
{ { 1 2 } [ t ] }
|
||||
{ { 1 3 } [ t ] }
|
||||
{ _ [ f ] }
|
||||
{ __ [ f ] }
|
||||
} match-cond
|
||||
] unit-test
|
||||
|
||||
|
@ -89,7 +89,7 @@ C: <foo> foo
|
|||
] unit-test
|
||||
|
||||
{ { 2 1 } } [
|
||||
{ "a" 1 2 "b" } { _ ?a ?b _ } { ?b ?a } match-replace
|
||||
{ "a" 1 2 "b" } { __ ?a ?b __ } { ?b ?a } match-replace
|
||||
] unit-test
|
||||
|
||||
TUPLE: match-replace-test a b ;
|
||||
|
|
|
@ -6,7 +6,7 @@ USING: assocs classes classes.tuple combinators kernel lexer
|
|||
macros make namespaces parser quotations sequences summary words ;
|
||||
IN: match
|
||||
|
||||
SYMBOL: _
|
||||
SYMBOL: __
|
||||
|
||||
: define-match-var ( name -- )
|
||||
create-word-in
|
||||
|
@ -29,7 +29,7 @@ PREDICATE: match-var < word "match-var" word-prop ;
|
|||
{ [ dup match-var? ] [ set-match-var ] }
|
||||
{ [ over match-var? ] [ swap set-match-var ] }
|
||||
{ [ 2dup = ] [ 2drop t ] }
|
||||
{ [ 2dup [ _ eq? ] either? ] [ 2drop t ] }
|
||||
{ [ 2dup [ __ eq? ] either? ] [ 2drop t ] }
|
||||
{ [ 2dup [ sequence? ] both? ] [
|
||||
2dup [ length ] same? [
|
||||
[ (match) ] 2all?
|
||||
|
|
Loading…
Reference in New Issue