Permalink
Browse files

Added chapter 3 exercise

  • Loading branch information...
1 parent 796aa49 commit 29ce1b5ecc83dc785d2858f5960269ae94e1a230 @vpalivela committed Mar 21, 2012
Showing with 32 additions and 4 deletions.
  1. +19 −0 chapter3.lisp
  2. +13 −4 lisp-unit/simple-test.lisp
View
@@ -0,0 +1,19 @@
+;; Loads
+(load "lisp-unit/lisp-unit.lisp")
+(use-package :lisp-unit)
+
+;; steal-emerald: list -> string
+;; Purpose:
+;; As part of being a high tech bandit, by nights
+;; I steal emeralds from moving bullet trains
+;; using my awesome wet suit that gives me
+;; aerodynamic properties to cling to train and avoid hypothermia
+
+(defun steal-emerald (x)
+ (caddr x))
+
+;; its-go-time: I must now steal emerald in the 3rd car between cameras and guards
+(define-test its-go-time
+ (assert-equal 'emerald (steal-emerald '(train-controls cameras emerald guards))))
+
+(run-tests)
@@ -1,10 +1,19 @@
;; this is a simple test to test whether lisp-unit is loaded properly
+;;
+;;
+;; To run this, Open REPL and type the following in one line
+;; (load "simple-test.lisp")(run-tests)
+;; Load list-unit package
(load "lisp-unit.lisp")
-;;(use-package :lisp-unit)
+(use-package :lisp-unit)
-(defun my-sqr (x) (* x x))
-(define-test my-sqr
- (assert-equal 4 (my-sqr 2)))
+;; my-sqr: num -> num
+;; Purpose: To compute a square of a number
+;; Examples: (mysqr 2) => 4
+(defun my-sqr (x) (* x x))
+;; Tests:
+(define-test my-sqr-test
+ (assert-equal 4 (my-sqr 2)))

0 comments on commit 29ce1b5

Please sign in to comment.