tpy
parent
5d75fe54a9
commit
0c373f56be
@ -0,0 +1,29 @@
|
||||
#lang br/quicklang
|
||||
(require csp racket/stxparam racket/splicing)
|
||||
(provide (all-defined-out)
|
||||
(except-out (all-from-out br/quicklang) #%module-begin)
|
||||
(rename-out [mb #%module-begin]))
|
||||
|
||||
(define-syntax-parameter PROB (λ (stx) (error 'not-parameterized)))
|
||||
(define-syntax-parameter SOLVE (make-rename-transformer #'solve))
|
||||
|
||||
(define-macro (mb EXPR0 ... #:output ID EXPR ...)
|
||||
(with-syntax ([prob #'ID])
|
||||
#'(#%module-begin
|
||||
(require csp)
|
||||
(provide prob SOLVE)
|
||||
(define prob (make-csp))
|
||||
(println prob)
|
||||
(splicing-syntax-parameterize ([PROB (make-rename-transformer #'ID)])
|
||||
EXPR0 ...
|
||||
EXPR ...))))
|
||||
|
||||
(define-macro (define-variable VID DOMAIN)
|
||||
#'(begin
|
||||
(define VID DOMAIN)
|
||||
(add-var! PROB 'VID DOMAIN)))
|
||||
|
||||
(define-macro (define-constraint CID FUNC VARSYMS)
|
||||
#'(begin
|
||||
(define CID (constraint FUNC VARSYMS))
|
||||
(add-constraint! PROB FUNC VARSYMS)))
|
@ -1,4 +1,8 @@
|
||||
#lang racket/base
|
||||
(require "hacs.rkt")
|
||||
|
||||
(module reader syntax/module-reader
|
||||
csp/expander)
|
||||
|
||||
(provide (all-from-out "hacs.rkt"))
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
#lang csp
|
||||
(require csp racket/list)
|
||||
|
||||
#:output foo
|
||||
|
||||
(define-variable q (range 33))
|
||||
|
||||
foo
|
||||
|
||||
(define-variable n (range 33))
|
||||
|
||||
(define-constraint c (λ (q n) (= (+ q n) 33)) '(q n))
|
||||
|
||||
(solve foo)
|
Loading…
Reference in New Issue