factor/contrib/sequences.factor

20 lines
563 B
Factor
Raw Normal View History

2006-09-11 06:57:34 -04:00
USING: kernel math sequences ;
2006-09-11 06:49:12 -04:00
IN: sequences-contrib
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: 3nth ( n seq -- slice ) >r dup 3 + r> <slice> ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: map3-i ( seq -- i ) length 2 - ;
: map3-quot ( quot -- quot ) [ swap 3nth ] swap append ;
: map3 ( seq quot -- seq ) over map3-i swap map3-quot map-with ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: last ( seq -- elt ) dup length 1- swap nth ;
2006-09-11 06:57:34 -04:00
PROVIDE: contrib/sequences ;