Skip to content

NoahStoryM/amb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amb: Ambiguous Operator

Table of Contents

About

“amb” provides John McCarthy’s ambiguous operator for Racket. It introduces amb along with helpers such as for/amb and in-amb for exploring nondeterministic computations. A typed version is available in the typed-amb package.

Installation

  • raco pkg install amb
(require amb)
raco pkg install amb
  • raco pkg install typed-amb
(require typed/amb)
raco pkg install typed-amb

Usage

The forms allow exploring multiple execution paths. The snippet below collects all pairs (x y) such that x < y:

(require amb)

(for/list ([p (in-amb
               (let ([x (amb 1 2 3)]
                     [y (amb 3 4 5)])
                 (when (>= x y) (amb))
                 (list x y)))])
  p)

This evaluates to

'((1 3) (1 4) (1 5) (2 3) (2 4) (2 5))

Typed Interface

Using typed/amb offers the same API for Typed Racket programs.

(require typed/amb)
;; Typed usage mirrors the untyped API

About

Ambiguous Operator

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages