cursors: -find iterator

release
Joe Groff 2010-03-26 20:08:29 -07:00
parent e0435f6261
commit dbebe044c9
2 changed files with 7 additions and 0 deletions

View File

@ -8,6 +8,10 @@ IN: cursors.tests
{ } make
] 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 } ] [
[ T{ linear-cursor f 1 2 } T{ linear-cursor f 5 2 } [ value>> , ] -each ]
{ } make

View File

@ -125,6 +125,9 @@ M: end-of-stream cursor-stream-ended? drop t ; inline
[ '[ dup _ cursor>= ] ]
[ '[ _ 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' )
'[ cursor-value-unsafe @ ] ; inline