19 lines
504 B
Factor
19 lines
504 B
Factor
|
|
||
|
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 ;
|