]> gitweb.factorcode.org Git - factor.git/blob - extra/partial-continuations/partial-continuations.factor
Factor source files should not be executable
[factor.git] / extra / partial-continuations / partial-continuations.factor
1 ! Copyright (C) 2006 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3 IN: partial-continuations
4 USING: kernel continuations arrays sequences quotations ;
5
6 : breset ( quot -- )
7     [ 1array swap keep first continue-with ] callcc1 nip ; inline
8
9 : (bshift) ( v r k -- obj )
10     [ dup first -rot ] dip
11     [
12         rot set-first
13         continue-with
14     ] callcc1
15     [ drop nip set-first ] dip ;
16
17 : bshift ( r quot -- )
18     swap [ ! quot r k
19         over [
20             [ (bshift) ] 2curry swap call
21         ] dip first continue-with
22     ] callcc1 2nip ; inline