functors: use SYNTAX: instead of top-level code
parent
a40fef851a
commit
10d59ade55
|
@ -132,7 +132,7 @@ TUPLE: sequence-parser sequence n ;
|
|||
sequence-parser [ n + ] change-n drop
|
||||
] if ;
|
||||
|
||||
<< "length" [ length ] define-sorting >>
|
||||
<< SORTING: length [ length ] >>
|
||||
|
||||
: sort-tokens ( seq -- seq' )
|
||||
{ length>=< <=> } sort-by ;
|
||||
|
|
|
@ -42,5 +42,5 @@ M: alphanum <=>
|
|||
<=>
|
||||
] if ;
|
||||
|
||||
<< "human" [ find-numbers [ <alphanum> ] map ] define-sorting >>
|
||||
<< "humani" [ find-numbers [ <alphanum-insensitive> ] map ] define-sorting >>
|
||||
<< SORTING: human [ find-numbers [ <alphanum> ] map ] >>
|
||||
<< SORTING: humani [ find-numbers [ <alphanum-insensitive> ] map ] >>
|
||||
|
|
|
@ -74,7 +74,7 @@ TUPLE: tuple2 d ;
|
|||
{ { "a" "b" "c" } } [ { "b" "c" "a" } { <=> <=> } sort-by ] unit-test
|
||||
{ { "b" "c" "a" } } [ { "b" "c" "a" } { } sort-by ] unit-test
|
||||
|
||||
<< "length-test" [ length ] define-sorting >>
|
||||
<< SORTING: length-test [ length ] >>
|
||||
|
||||
{ { { 1 } { 1 2 3 } { 1 3 2 } { 3 2 1 } } }
|
||||
[
|
||||
|
|
|
@ -92,7 +92,7 @@ IN: c.lexer
|
|||
: take-c-identifier ( sequence-parser -- string/f )
|
||||
[ (take-c-identifier) ] with-sequence-parser ;
|
||||
|
||||
<< "length" [ length ] define-sorting >>
|
||||
<< SORTING: length [ length ] >>
|
||||
|
||||
: sort-tokens ( seq -- seq' )
|
||||
{ length>=< <=> } sort-by ;
|
||||
|
|
Loading…
Reference in New Issue