]> gitweb.factorcode.org Git - factor.git/blob - basis/sorting/human/human.factor
Resolved merge.
[factor.git] / basis / sorting / human / human.factor
1 ! Copyright (C) 2008 Doug Coleman, Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel math math.order math.parser peg.ebnf
4 sequences sorting.functor ;
5 IN: sorting.human
6
7 : find-numbers ( string -- seq )
8     [EBNF Result = ([0-9]+ => [[ string>number ]] | (!([0-9]) .)+)* EBNF] ;
9
10 ! For comparing integers or sequences
11 TUPLE: hybrid obj ;
12
13 M: hybrid <=>
14     [ obj>> ] bi@
15     2dup [ integer? ] bi@ xor [
16         drop integer? [ +lt+ ] [ +gt+ ] if
17     ] [
18         <=>
19     ] if ;
20
21 << "human" [ find-numbers [ hybrid boa ] map ] define-sorting >>