cursors: -find iterator
parent
e0435f6261
commit
dbebe044c9
|
@ -8,6 +8,10 @@ IN: cursors.tests
|
||||||
{ } make
|
{ } make
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
[ T{ linear-cursor f 3 1 } ] [
|
||||||
|
T{ linear-cursor f 1 1 } T{ linear-cursor f 5 1 } [ value>> 3 mod zero? ] -find
|
||||||
|
] unit-test
|
||||||
|
|
||||||
[ { 1 3 } ] [
|
[ { 1 3 } ] [
|
||||||
[ T{ linear-cursor f 1 2 } T{ linear-cursor f 5 2 } [ value>> , ] -each ]
|
[ T{ linear-cursor f 1 2 } T{ linear-cursor f 5 2 } [ value>> , ] -each ]
|
||||||
{ } make
|
{ } make
|
||||||
|
|
|
@ -125,6 +125,9 @@ M: end-of-stream cursor-stream-ended? drop t ; inline
|
||||||
[ '[ dup _ cursor>= ] ]
|
[ '[ dup _ cursor>= ] ]
|
||||||
[ '[ _ keep inc-cursor ] ] bi* until drop ; inline
|
[ '[ _ keep inc-cursor ] ] bi* until drop ; inline
|
||||||
|
|
||||||
|
: -find ( ... begin end quot: ( ... cursor -- ... ? ) -- ... cursor )
|
||||||
|
'[ dup _ cursor>= [ t ] [ dup @ ] if ] [ inc-cursor ] until ; inline
|
||||||
|
|
||||||
: -in- ( quot -- quot' )
|
: -in- ( quot -- quot' )
|
||||||
'[ cursor-value-unsafe @ ] ; inline
|
'[ cursor-value-unsafe @ ] ; inline
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue