Giter VIP home page Giter VIP logo

liyechen / lisp-koans Goto Github PK

View Code? Open in Web Editor NEW

This project forked from google/lisp-koans

0.0 2.0 0.0 322 KB

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.

License: Apache License 2.0

Common Lisp 99.28% Shell 0.67% Starlark 0.05%

lisp-koans's Introduction

Lisp Koans

Getting Started

One-time Method

From a terminal, execute your lisp interpreter on the file 'contemplate.lisp' e.g.

abcl --noinform --noinit --load contemplate.lisp --eval '(quit)'
ccl -n -l contemplate.lisp -e '(quit)'
clisp -q -norc -ansi contemplate.lisp
ecl -norc -load contemplate.lisp -eval '(quit)'
sbcl --script contemplate.lisp

Watching the Koans

On Linux and MacOS systems, the shell scripts meditate-linux.sh and meditate-macos.sh can be used to automatically evaluate 'contemplate.lisp' whenever the koan files are modified, providing immediate feedback on changes to the koans. To run the MacOS version you need to have fswatch installed. From a terminal:

$ cd lisp-koans
$ sh meditate-linux.sh # on Linux
$ sh meditate-macos.sh # on MacOS

Results of Contemplation

Running on a fresh version should output the following:

Thinking about ASSERTS
    FILL-IN-THE-BLANKS requires more meditation.

You have not yet reached enlightenment.
    A koan is incomplete.
Please meditate on the following code:
    File "koans/asserts.lisp"
    Koan "FILL-IN-THE-BLANKS"
    Current koan assert status is "(INCOMPLETE INCOMPLETE INCOMPLETE)"

You are now 0/198 koans and 0/31 lessons closer to reaching enlightenment.

This indicates that the script has completed, and that the learner should look to asserts.lisp to locate and fix the problem. The problem will be within a define-test expression such as

;;; In order to progress, fill in the blanks, denoted via ____ in source code.
;;; Sometimes, you will be asked to provide values that are equal to something.

(define-test fill-in-the-blanks
  (assert-equal ____ 2)
  (assert-equal ____ 3.14)
  (assert-equal ____ "Hello World"))

;;; Sometimes, you will be asked to say whether something is true or false,
;;; In Common Lisp, the canonical values for truth and falsehood are T and NIL.

(define-test assert-true
  (assert-true ____))

(define-test assert-false
  (assert-false ____))

In this case, the test is incomplete, and the student should fill in the blank (____) with appropriate lisp code to make the assert pass.

In order to test code, or evaluate tests interactively, students may copy and paste code into the lisp command line REPL.

Testing

To test the koans, execute your lisp interpreter on the file 'contemplate.lisp' e.g.

abcl --noinform --noinit --load test.lisp --eval '(quit)'
ccl -n -l test.lisp -e '(quit)'
clisp -q -norc -ansi test.lisp
ecl -norc -load test.lisp -eval '(quit)'
sbcl --script test.lisp

Quoting the Ruby Koans instructions

"In test-driven development the mantra has always been, red, green, refactor. Write a failing test and run it (red), make the test pass (green), then refactor it (that is look at the code and see if you can make it any better). In this case you will need to run the koan and see it fail (red), make the test pass (green), then take a moment and reflect upon the test to see what it is teaching you and improve the code to better communicate its intent (refactor)."

Content

The Common Lisp koans are based on the Python koans and Ruby koans projects. Additionally, many of the tests are based on new material that is special to Common Lisp.

Note that the unit on threads uses bordeaux-threads and bt-semaphore. The user must have Quicklisp installed and loaded or a reader macro will remove the instructions to run :threads. For information and instructions on installing Quicklisp please see: https://www.quicklisp.org/beta/ The user can either remove #+quicklisp and uncomment (load "~/.quicklisp/setup.lisp") in threads.lisp, or if they know quicklisp will be loaded while running contemplate.lisp do nothing.

lisp-koans's People

Contributors

0mp avatar alexander-lazarov avatar astronaut-wannabe avatar bileschi avatar calancha avatar cebolan avatar duedl0r avatar emdeesee avatar gibheer avatar informatimago avatar jamil avatar janebert avatar jasperpilgrim avatar jondeandres avatar juanitofatas avatar kaijchen avatar kjgorman avatar liyechen avatar matthewschallenkamp avatar phoe avatar pkulev avatar rjsamson avatar rodnaph avatar rowanthorpe avatar slids avatar spainisnotequal avatar tanner avatar thejnich avatar v-a-1 avatar wlbr avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.