Skip to content

swannodette/delimc

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

delimc

A delimited continuations library for Clojure 1.4.0 (and 1.3.0). Portions based on cl-cont by Slava Akhmechet (http://defmacro.org).

(def cont1 (atom nil))
(def cont2 (atom nil))
(def cont3 (atom nil))
(def cont4 (atom nil))

(reset (+ 1 (apply (fn [a b c]
                     (+ (shift k
                          (reset! cont1 k)
                            (k 1))
                         a b c))
                    3 4 (list 5)))) ;; 14

(@cont1 2) ;; 15

(reset
  (+ 1 (reset (shift k
                (reset! cont2 k)
                (k 2)))
       (reset (shift k
                (reset! cont3 k)
                (k 3))))) ;; 6

(@cont2 4) ;; 8
(@cont3 10) ;; 15

(reset (str "Hello" (shift k
                      (reset! cont4 k)
                        (k ", today is "))
            "a nice day!")) ; "Hello, today is a nice day"

(@cont4 ", yesterday was ") ; "Hello, yesterday was a nice day"

References

About

Delimited continuations for Clojure

Resources

Stars

Watchers

Forks

Packages

No packages published