Changeset 39046 in project


Ignore:
Timestamp:
09/21/20 06:08:39 (5 weeks ago)
Author:
Kon Lovett
Message:

rm deps, add srfi-1 dep, slim dwelling, required is and

Location:
release/5/amb/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • release/5/amb/trunk/amb-dwelling.scm

    r38990 r39046  
    11;;;; amb-dwelling.scm
    22
    3 (import scheme)
    4 (import (chicken base))
    5 (import amb)
    6 (import amb-extras)
     3(import
     4  scheme
     5  (chicken base)
     6  amb
     7  amb-extras)
    78
    89;; Baker, Cooper, Fletcher, Miller, and Smith live on different
     
    1718
    1819(define (solve-dwelling-puzzle)
    19   ;
     20
    2021  (let ((baker    (amb 1 2 3 4 5))
    2122        (cooper   (amb 1 2 3 4 5))
     
    2324        (miller   (amb 1 2 3 4 5))
    2425        (smith    (amb 1 2 3 4 5)) )
    25     ;
    26     ;; They live on different floors.
    27     (required (distinct? (list baker cooper fletcher miller smith)))
    28     ;
    29     ;; Baker does not live on the top floor.
    30     (required (not (= baker 5)))
    31     ;
    32     ;; Cooper does not live on the bottom floor.
    33     (required (not (= cooper 1)))
    34     ;
    35     ;; Fletcher does not live on either the top or the bottom floor.
    36     (required (not (= fletcher 5)))
    37     (required (not (= fletcher 1)))
    38     ;
    39     ;; Miller lives on a higher floor than does Cooper.
    40     (required (> miller cooper))
    41     ;
    42     ;; Smith does not live on a floor adjacent to Fletcher's.
    43     (required (not (= (abs (- smith fletcher)) 1)))
    44     ;
    45     ;; Fletcher does not live on a floor adjacent to Cooper's.
    46     (required (not (= (abs (- fletcher cooper)) 1)))
    47     ;
     26
     27    (required
     28      ; They live on different floors.
     29      (distinct? (list baker cooper fletcher miller smith))
     30      ; Baker does not live on the top floor.
     31      (not (= baker 5))
     32      ; Cooper does not live on the bottom floor.
     33      (not (= cooper 1))
     34      ; Fletcher does not live on either the top or the bottom floor.
     35      (not (= fletcher 5))
     36      (not (= fletcher 1))
     37      ; Miller lives on a higher floor than does Cooper.
     38      (> miller cooper)
     39      ; Smith does not live on a floor adjacent to Fletcher's.
     40      (not (= (abs (- smith fletcher)) 1))
     41      ; Fletcher does not live on a floor adjacent to Cooper's.
     42      (not (= (abs (- fletcher cooper)) 1)) )
     43
    4844    `((baker    ,baker)
    4945      (cooper   ,cooper)
  • release/5/amb/trunk/amb-extras.scm

    r38990 r39046  
    2424(import (chicken syntax))
    2525(import (chicken type))
     26(import (only (chicken fixnum) fx+))
    2627(import (only (chicken sort) sort!))
    2728(import (only (srfi 1) count every))
     
    7071  (syntax-rules ()
    7172    ((required ?expr)
    72      (amb-assert ?expr) ) ) )
     73     (amb-assert ?expr) )
     74    ((required ?expr ...)
     75     (begin (amb-assert ?expr) ...) ) ) )
    7376
    7477;; Logic Control
  • release/5/amb/trunk/amb.egg

    r38925 r39046  
    33
    44((synopsis "The non-deterministic backtracking ambivalence operator")
    5  (version "3.0.1")
     5 (version "3.0.2")
    66 (category data)
    7  (author "[[thomas chust]]")
    8  (maintainer "[[kon lovett]]")
     7 (author "[[thomas chust]] (for CHICKEN by [[kon lovett]])")
    98 (license "BSD")
    10  (dependencies check-errors condition-utils)
     9 (dependencies srfi-1)
    1110 (test-dependencies test)
    1211 (components
  • release/5/amb/trunk/amb.scm

    r38990 r39046  
    2727(import scheme)
    2828(import (chicken base))
    29 (import(chicken type))
    30 (import (only (chicken bitwise) integer-length))
    3129(import (chicken syntax))
    3230(import (chicken type))
     31(import (only (chicken condition) signal make-property-condition make-composite-condition))
     32(import (only (chicken string) conc))
     33(import (only (chicken bitwise) integer-length))
    3334(import (only (chicken sort) sort!))
    3435(import (only (chicken random) pseudo-random-integer))
    35 (import (only (srfi 1) map!))
    36 (import (srfi 12))
    37 (import (only type-errors warning-argument-type))
    38 (import (only exn-condition make-exn-condition+))
    3936
    4037;;(from miscmacros.scm)
     
    9087
    9188(define make-amb-exhausted-condition
    92   (let ((+cached-amb-exhausted-condition+
    93           (make-exn-condition+ 'amb "expression tree exhausted" '() 'amb)) )
    94     (lambda () +cached-amb-exhausted-condition+) ) )
     89  (let (
     90    (cached-amb-exhausted-condition
     91      (make-composite-condition
     92        (make-property-condition 'exn
     93          'location 'amb 'message "expression tree exhausted" 'arguments '())
     94        (make-property-condition 'amb))) )
     95    (lambda () cached-amb-exhausted-condition) ) )
    9596
    9697;;
     
    109110      x
    110111      (begin
    111         (warning-argument-type 'amb-failure-continuation x 'procedure)
     112        (warning (conc "(amb-failure-continuation) bad argument - not a procedure: " x))
    112113        (amb-failure-continuation) ) ) ) )
    113114
Note: See TracChangeset for help on using the changeset viewer.