Skip to content

Instantly share code, notes, and snippets.

View kephas's full-sized avatar

Pierre Thierry kephas

  • AUTOGRIFF
  • Strasbourg, France
  • X @kephasp
View GitHub Profile
@kephas
kephas / while.lisp
Created March 18, 2015 21:42
While implementation in Common Lisp
(defmacro while (cond &body body)
(with-gensyms (cond-var)
`(do ((,cond-var ,cond ,cond))
((not ,cond-var))
,@body)))
@kephas
kephas / base.scm
Created December 12, 2012 00:16
Base 12
#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
@kephas
kephas / hunchentoot-hello.lisp
Created November 29, 2011 23:08
Hello World for Hunchentoot
(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))
@kephas
kephas / while.lisp
Created August 5, 2011 02:12
Implementation of while in Common Lisp
; 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)