Add ?first .. ?fourth to sequences.lib
parent
caa2a606c2
commit
c6ce216e03
|
@ -46,3 +46,10 @@ math.functions tools.test strings ;
|
|||
[ { { 0 0 } { 1 0 } { 0 1 } { 1 1 } } ] [ 2 2 exact-strings ] unit-test
|
||||
[ t ] [ "ab" 4 strings [ >string ] map "abab" swap member? ] unit-test
|
||||
[ { { } { 1 } { 2 } { 1 2 } } ] [ { 1 2 } power-set ] unit-test
|
||||
|
||||
[ f ] [ { } ?first ] unit-test
|
||||
[ f ] [ { } ?fourth ] unit-test
|
||||
[ 1 ] [ { 1 2 3 } ?first ] unit-test
|
||||
[ 2 ] [ { 1 2 3 } ?second ] unit-test
|
||||
[ 3 ] [ { 1 2 3 } ?third ] unit-test
|
||||
[ f ] [ { 1 2 3 } ?fourth ] unit-test
|
||||
|
|
|
@ -126,3 +126,8 @@ PRIVATE>
|
|||
: human-sort ( seq -- newseq )
|
||||
[ dup [ digit? ] [ string>number ] cut-all ] { } map>assoc
|
||||
sort-values keys ;
|
||||
|
||||
: ?first ( seq -- first/f ) 0 swap ?nth ; inline
|
||||
: ?second ( seq -- second/f ) 1 swap ?nth ; inline
|
||||
: ?third ( seq -- third/f ) 2 swap ?nth ; inline
|
||||
: ?fourth ( seq -- fourth/f ) 3 swap ?nth ; inline
|
||||
|
|
Loading…
Reference in New Issue