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

asserts.lsp 1.5KB

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. ; Concept: What do you do to go through the lisp koans? You fill in
  15. ; the blanks, or otherwise fix the lisp code so that the
  16. ; code within the 'define-test' blocks passes.
  17. ; In common lisp, "True" and "False" are represented by "t" and "nil".
  18. ; More in a future lesson, but for now, consider t to be true,
  19. ; and nil to be false.
  20. (define-test assert-true
  21. "t is true. Replace the blank with a t"
  22. (assert-true t))
  23. (define-test assert-false
  24. "nil is false"
  25. (assert-false nil))
  26. (define-test fill-in-the-blank
  27. "sometimes you will need to fill the blank to complete"
  28. (assert-equal 2 2))
  29. (define-test fill-in-the-blank-string
  30. (assert-equal "hello world" "hello world"))
  31. (define-test test-true-or-false
  32. "sometimes you will be asked to evaluate whether statements
  33. are true (t) or false (nil)"
  34. (true-or-false? t (equal 34 34))
  35. (true-or-false? nil (equal 19 78)))