functors: use SYNTAX: instead of top-level code

modern-harvey2
Doug Coleman 2017-12-28 19:06:10 -08:00
parent a40fef851a
commit 10d59ade55
4 changed files with 5 additions and 5 deletions

View File

@ -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 ;

View File

@ -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 ] >>

View File

@ -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 } } }
[

View File

@ -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 ;