google / lisp-koans

Common Lisp Koans is a language learning exercise in the same vein as the ruby koans, python koans and others. It is a port of the prior koans with some modifications to highlight lisp-specific features. Structured as ordered groups of broken unit tests, the project guides the learner progressively through many Common Lisp language features.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DEFUN SIGN-OF is beyond repair

phoe opened this issue · comments

; returns sign x
(defun sign-of (x)
  (if (< x 0) (return-from sign-of -1))
  (if (eq x 0) (return-from sign-of 0))
  1)
  1. (sign-of 0.0) ;=> 1, not 0
  2. it uses eq on a number, which has undefined result
  3. it uses multiple return-froms instead of a cond or a typecase
  4. cl:signum exists

Will fix this in my fork and submit a PR along with all other koan fixes.