sequences.extras: adding each-from and reduce-from.

db4
John Benediktsson 2012-05-14 16:43:42 -07:00
parent e90732f5e7
commit d035d1abfc
1 changed files with 6 additions and 0 deletions

View File

@ -27,6 +27,12 @@ IN: sequences.extras
: insert-sorted ( elt seq -- seq )
2dup [ < ] with find drop over length or swap insert-nth ;
: each-from ( ... seq quot: ( ... x -- ... ) i -- ... )
-rot (each) (each-integer) ; inline
: reduce-from ( ... seq identity quot: ( ... prev elt -- ... next ) i -- ... result )
[ swap ] 2dip each-from ; inline
: max-by ( obj1 obj2 quot: ( obj -- n ) -- obj1/obj2 )
[ bi@ dupd max = ] curry most ; inline