factor/extra/partial-continuations/partial-continuations.factor

23 lines
582 B
Factor
Raw Normal View History

2007-09-20 18:09:08 -04:00
! Copyright (C) 2006 Chris Double.
! See http://factorcode.org/license.txt for BSD license.
IN: partial-continuations
USING: kernel continuations arrays sequences quotations ;
: breset ( quot -- )
2009-04-15 20:03:44 -04:00
[ 1array swap keep first continue-with ] callcc1 nip ; inline
2007-09-20 18:09:08 -04:00
2008-02-06 20:23:39 -05:00
: (bshift) ( v r k -- obj )
2008-12-18 01:42:12 -05:00
[ dup first -rot ] dip
2007-09-20 18:09:08 -04:00
[
rot set-first
continue-with
] callcc1
2008-12-18 01:42:12 -05:00
[ drop nip set-first ] dip ;
2007-09-20 18:09:08 -04:00
: bshift ( r quot -- )
swap [ ! quot r k
2008-12-18 01:42:12 -05:00
over [
[ (bshift) ] 2curry swap call
] dip first continue-with
2008-02-06 20:23:39 -05:00
] callcc1 2nip ; inline