2008-08-06 02:06:14 -04:00
|
|
|
! Copyright (C) 2008 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: sequences kernel ;
|
|
|
|
IN: persistent.sequences
|
|
|
|
|
|
|
|
GENERIC: ppush ( val seq -- seq' )
|
|
|
|
|
|
|
|
M: sequence ppush swap suffix ;
|
|
|
|
|
|
|
|
GENERIC: ppop ( seq -- seq' )
|
|
|
|
|
|
|
|
M: sequence ppop 1 head* ;
|
|
|
|
|
|
|
|
GENERIC: new-nth ( val i seq -- seq' )
|
|
|
|
|
|
|
|
M: sequence new-nth clone [ set-nth ] keep ;
|
2008-11-13 01:10:55 -05:00
|
|
|
|
|
|
|
: changed-nth ( i seq quot -- seq' )
|
|
|
|
[ [ nth ] dip call ] [ drop new-nth ] 3bi ; inline
|