Fork of https://github.com/google/lisp-koans so that I could go through them. THIS CONTAINS ANSWERS.

triangle-project.lsp 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ;; Copyright 2013 Google Inc.
  2. ;;
  3. ;; Licensed under the Apache License, Version 2.0 (the "License");
  4. ;; you may not use this file except in compliance with the License.
  5. ;; You may obtain a copy of the License at
  6. ;;
  7. ;; http://www.apache.org/licenses/LICENSE-2.0
  8. ;;
  9. ;; Unless required by applicable law or agreed to in writing, software
  10. ;; distributed under the License is distributed on an "AS IS" BASIS,
  11. ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. ;; See the License for the specific language governing permissions and
  13. ;; limitations under the License.
  14. "you need to write the triangle method"
  15. (define-condition triangle-error (error) ())
  16. (defun triangle (a b c)
  17. :write-me)
  18. (define-test test-equilateral-triangles-have-equal-sides
  19. (assert-equal :equilateral (triangle 2 2 2))
  20. (assert-equal :equilateral (triangle 10 10 10)))
  21. (define-test test-isosceles-triangles-have-two-equal-sides
  22. (assert-equal :isosceles (triangle 3 4 4))
  23. (assert-equal :isosceles (triangle 4 3 4))
  24. (assert-equal :isosceles (triangle 4 4 3))
  25. (assert-equal :isosceles (triangle 10 10 2)))
  26. (define-test test-scalene-triangles-have-no-equal-sides
  27. (assert-equal :scalene (triangle 3 4 5))
  28. (assert-equal :scalene (triangle 10 11 12))
  29. (assert-equal :scalene (triangle 5 4 2)))
  30. (define-test test-illegal-triangles-throw-exceptions
  31. (assert-error 'triangle-error (triangle 0 0 0))
  32. (assert-error 'triangle-error (triangle 3 4 -5))
  33. (assert-error 'triangle-error (triangle 1 1 3))
  34. (assert-error 'triangle-error (triangle 2 4 2)))