parent
b4adebb691
commit
23768dd482
|
@ -22,7 +22,7 @@ PRIVATE>
|
|||
: p= ( p p -- ? ) pextend = ;
|
||||
|
||||
: ptrim ( p -- p )
|
||||
dup singleton? [ [ zero? ] right-trim ] unless ;
|
||||
dup length 1 = [ [ zero? ] right-trim ] unless ;
|
||||
|
||||
: 2ptrim ( p p -- p p ) [ ptrim ] bi@ ;
|
||||
: p+ ( p p -- p ) pextend v+ ;
|
||||
|
|
|
@ -79,7 +79,7 @@ SYMBOL: and-needed?
|
|||
] if ;
|
||||
|
||||
: recombine ( seq -- str )
|
||||
dup singleton? [
|
||||
dup length 1 = [
|
||||
first 3digits>text
|
||||
] [
|
||||
dup set-conjunction "" swap
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
USING: alien.c-types io io.files io.nonblocking kernel
|
||||
namespaces random io.encodings.binary singleton init
|
||||
namespaces random io.encodings.binary init
|
||||
accessors system ;
|
||||
IN: random.unix
|
||||
|
||||
|
|
|
@ -46,9 +46,6 @@ IN: sequences.lib.tests
|
|||
[ { 1 -1 5 2 4 } [ < ] monotonic-split [ >array ] map ] unit-test
|
||||
[ { { 1 1 1 1 } { 2 2 } { 3 } { 4 } { 5 } { 6 6 6 } } ]
|
||||
[ { 1 1 1 1 2 2 3 4 5 6 6 6 } [ = ] monotonic-split [ >array ] map ] unit-test
|
||||
[ f ] [ { } singleton? ] unit-test
|
||||
[ t ] [ { "asdf" } singleton? ] unit-test
|
||||
[ f ] [ { "asdf" "bsdf" } singleton? ] unit-test
|
||||
|
||||
[ 2 ] [ V{ 10 20 30 } [ delete-random drop ] keep length ] unit-test
|
||||
[ V{ } [ delete-random drop ] keep length ] must-fail
|
||||
|
|
|
@ -98,9 +98,6 @@ MACRO: firstn ( n -- )
|
|||
v, [ pick ,, call [ v, ] unless ] curry 2each ,v
|
||||
] { } make ;
|
||||
|
||||
: singleton? ( seq -- ? )
|
||||
length 1 = ;
|
||||
|
||||
: delete-random ( seq -- value )
|
||||
[ length random ] keep [ nth ] 2keep delete-nth ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue