lisp - Cond definition in scheme -


this easy question guess need it.i making simulator game in scheme(dr racket)and want change how cond works.but change thing cond need know definition of cond , not find in dr racket.can give definition of cond in scheme?

the racket definition of cond in collects/racket/private/cond.rkt. it's written using low-level syntax object operations, not using either syntax-rules nor syntax-case, unless know syntax objects well, won't readable you.

as alternative starting place customised cond, 1 definition of cond reference implementation given in srfi 61. succinct , 1 of best implementations of cond i've seen:

(define-syntax cond   (syntax-rules (=> else)      ((cond (else else1 else2 ...))      ;; (if #t (begin ...)) wrapper ensures there may no      ;; internal definitions in body of clause.  r5rs mandates      ;; in text (by referring each subform of clauses      ;; <expression>) not in reference implementation of cond,      ;; expands (begin ...) no (if #t ...) wrapper.      (if #t (begin else1 else2 ...)))      ((cond (test => receiver) more-clause ...)      (let ((t test))        (cond/maybe-more t                         (receiver t)                         more-clause ...)))      ((cond (generator guard => receiver) more-clause ...)      (call-with-values (lambda () generator)        (lambda t          (cond/maybe-more (apply guard    t)                           (apply receiver t)                           more-clause ...))))      ((cond (test) more-clause ...)      (let ((t test))        (cond/maybe-more t t more-clause ...)))      ((cond (test body1 body2 ...) more-clause ...)      (cond/maybe-more test                       (begin body1 body2 ...)                       more-clause ...))))  (define-syntax cond/maybe-more   (syntax-rules ()     ((cond/maybe-more test consequent)      (if test          consequent))     ((cond/maybe-more test consequent clause ...)      (if test          consequent          (cond clause ...))))) 

(as molbdnilo says, though, please call version other cond avoid confusion.)


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -