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