Skip to content

halcat0x15a/cont

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cont

A delimited continuations library for Clojure.

Build Status

Clojars Project

Usage

Non-determinism

(require '[cont.core :refer [shift reset]])

(defn amb [& xs]
  (shift k (mapcat k xs)))

(reset
  (let [x (amb 1 2 3)
        y (amb 2 4 6)]
    (if (zero? (mod (+ x y) 3))
      [[x y]])))
;=> ([1 2] [2 4] [3 6])

Generator

(defn yield [x]
  (shift k (cons x (k nil))))

(reset
  (yield 1)
  (yield 2)
  (yield 3))
;=> (1 2 3)

License

Copyright © 2014 Sanshiro Yoshida.

Distributed under the Eclipse Public License.

About

Delimited continuations library

Resources

Stars

Watchers

Forks

Packages

No packages published