;Deftests for chapter 4 (deftest justinChap4 () (check ;open check (string-equal "Justin" (let ((str (copy-seq (concatenate 'string "dus" "tin")))) (setf (char str 0) #\j) str)) ; check for section 4.3 (equal '("first" "2nd" "Last") (tokens "first 2nd Last" #'constituent 0)) ;check for figure 4.2 ); close check ) ;close deftest ;;Functions Taken from Lisp book, fig 4.2 (defun tokens (str test start) (let ((p1 (position-if test str :start start))) (if p1 (let ((p2 (position-if #'(lambda (c) (not (funcall test c))) str :start p1))) (cons (subseq str p1 p2) (if p2 (tokens str test p2) nil))) nil))) (defun constituent (c) (and (graphic-char-p c) (not (char= c #\ )))) ;End functions for fig 4.2