This is a wrapper over find, to do something like this

for elem in seq:
  if(   ! fn ( elem ) ) break
  else newseq.append(elem)

: collect-until ( seq quot -- seq )
    ! calls quot on each element, if it returns false, stops
    ! and returns sequence from beginning to that point ( exclusive )

    [ not ] compose ! this is because find is weird ( according to me )
    dupd find drop dup [ head ] [ 2drop f ] if ;

I'm using 0.91 stable so something like this might already be in the git
repository.
If its not, and if everyone is satisfied with it, maybe it could be put
in...

Cheers,
Nikhil

-- 
------------------------------------------------------------------------
http://22bits.exofire.net/
------------------------------------------------------------------------
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to