Skip to content

Instantly share code, notes, and snippets.

View lgaff's full-sized avatar
💭
Perpetual Procrastination

Lindsay Gaff lgaff

💭
Perpetual Procrastination
  • Sydney, Australia
View GitHub Profile
@lgaff
lgaff / loop expansion.lisp
Created April 30, 2012 03:47
An argument for DSL's
;; The following two functions are equivalent:
(loop repeat 10 for x = 0 then y and y = 1 then (+ x y) collect y) ; ===> (1 1 2 3 5 8 13 21 34 55)
(BLOCK NIL
(LET ((#:LOOP-REPEAT-876 (CEILING 10)) (X NIL) (Y NIL))
(DECLARE (TYPE INTEGER #:LOOP-REPEAT-876))
(SB-LOOP::WITH-LOOP-LIST-COLLECTION-HEAD (#:LOOP-LIST-HEAD-877
#:LOOP-LIST-TAIL-878)
(SB-LOOP::LOOP-BODY NIL
@lgaff
lgaff / starstuff.lisp
Created March 20, 2012 01:53
Common lisp recursion vs. Ruby
;;; The idea here is to be able to determine velocity and distance
;;; attained as a function of time.
;; some physical constants/definitions.
(defconstant +g+ 9.81)
(defconstant +C+ 2.998e8)
;; Helper to determine if we've hit C (we'll use 99.9% as the cutoff)
(defun velocity-cap (velocity accel)
(if (<= (+ velocity accel) (* +C+ 0.999))