Skip to content

Commit

Permalink
chicken and guile wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelballantyne committed Jan 15, 2015
1 parent 5e544d0 commit 2fbdae6
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 9 deletions.
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,36 @@ For example, `(run (q r s) (== (cons r q) s))`.

## Running

In Chez or Vicare, `(load "mk.scm")`. In Racket, `(require "mk.rkt")`.
### Chez and Vicare

## Running Tests
```
(load "mk.scm")
```

To run the tests, load `test-all.scm`
### Racket

In Chez or Vicare:
```
(require "mk.rkt")
```

### Guile

```
(load "mk.scm")
(load "test-all.scm")
(load "mk-guile.scm")
```

In Racket:
### Chicken

```
(load "mk-chicken.scm")
```

## Running Tests

After loading miniKanren as above,

```
(require "mk.rkt")
(load "test-all.scm")
```

regardless of scheme implementation.
39 changes: 39 additions & 0 deletions mk-chicken.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
(define (list-sort x y) (sort y x))

(define (exists p l)
(if (null? l)
#f
(let ((res (p (car l))))
(if (null? (cdr l))
res
(if res
res
(exists p (cdr l)))))))

(define (find p l)
(if (null? l)
#f
(if (p (car l))
(car l)
(find p (cdr l)))))

(define (remp p l)
(if (null? l)
'()
(if (p (car l))
(remp p (cdr l))
(cons (car l) (remp p (cdr l))))))

(define (for-all p l)
(if (null? l)
#t
(let ((res (p (car l))))
(if (null? (cdr l))
res
(if res
(for-all p (cdr l))
#f)))))

(define call-with-string-output-port call-with-output-string)

(load "mk.scm")
12 changes: 12 additions & 0 deletions mk-guile.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(import (rnrs sorting (6))
(rnrs lists (6)))

(define (sub1 n)
(- n 1))

(define call-with-string-output-port call-with-output-string)

(define (printf format-string . args)
(display (apply format #f format-string args)))

(load "mk.scm")
2 changes: 1 addition & 1 deletion numbers.scm
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
(== `(,b . ,n^) h)
(== '() l)))
((fresh (n^)
(==  `(1 . ,n^) n)
(== `(1 . ,n^) n)
(== '() r)
(== n^ h)
(== '(1) l)))
Expand Down

0 comments on commit 2fbdae6

Please sign in to comment.