This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro while (cond &body body) | |
(with-gensyms (cond-var) | |
`(do ((,cond-var ,cond ,cond)) | |
((not ,cond-var)) | |
,@body))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define digits12 "0123456789AB") | |
(define digits12-list (string->list digits12)) | |
(define (digit12->int digit) | |
(let loop ((digits digits12-list) | |
(result 0)) | |
(if (char=? digit (first digits)) | |
result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ql:quickload "hunchentoot") | |
(use-package :hunchentoot) | |
(start (make-instance 'acceptor :port 8080)) | |
(define-easy-handler (greet :uri "/hello") (name) | |
(format nil "<html><body><h1>Hello ~a!</h1></body></html>" name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; the most straightforward imperative implementation of the while | |
; control structure | |
(defmacro while1 (cond &body body) | |
(with-gensyms (cond-var) | |
`(do ((,cond-var ,cond ,cond)) | |
((not ,cond-var)) | |
,@body))) | |
; a functional implementation relying on TCO | |
(defmacro while2 (cond &body body) |
NewerOlder