Skip to content

Commit

Permalink
Merge pull request google#84 from emdeesee/autocontemplate
Browse files Browse the repository at this point in the history
Autocontemplate.
  • Loading branch information
bileschi authored Jun 14, 2017
2 parents a451d32 + 0b8fef4 commit 36151b5
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ignore some editor temp files
*~
.#*
.*.sw?
.*.sw?
\#*#
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Getting Started
---------------
# Lisp Koans

## Getting Started

### One-time Method

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

Expand All @@ -9,6 +12,18 @@ From a terminal, execute your lisp interpreter on the file 'contemplate.lsp' e.g
ecl -norc -load contemplate.lsp -eval '(quit)'
sbcl --script contemplate.lsp

### Watching the Koans

On Linux systems, the shell script `meditate.sh` can be used to
automatically evaluate 'contemplate.lsp' whenever the koan files are
modified, providing immediate feedback on changes to the koans. From a
terminal:

$ cd lisp-koans
$ sh meditate.sh

## Results of Contemplation

Running on a fresh version should output the following:

```
Expand Down Expand Up @@ -41,8 +56,7 @@ 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.

Quoting the Ruby Koans instructions::
-------------------------------------
## 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),
Expand All @@ -52,8 +66,7 @@ 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
-------
## 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
Expand Down
44 changes: 44 additions & 0 deletions meditate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

if [ $# != 1 ]; then
echo "usage: sh meditate.sh <lisp implementation>"
echo " lisp implementation: one of abcl, ccl, clisp, ecl, or sbcl"
exit
fi

choose_command_line() {
case "$1" in
'abcl' )
echo "abcl --noinform --noinit --load contemplate.lsp --eval '(quit)'"
;;
'ccl' )
echo "ccl -n -l contemplate.lsp -e '(quit)'"
;;
'clisp' )
echo "clisp -q -norc -ansi contemplate.lsp"
;;
'ecl' )
echo "ecl -norc -load contemplate.lsp -eval '(quit)'"
;;
'sbcl' )
echo "sbcl --script contemplate.lsp"
;;
* )
echo ""
exit
;;
esac
}

CONTEMPLATE=$(choose_command_line $1)
if [ "$CONTEMPLATE" = "" ]; then
echo "Unknown Lisp implementation."
exit
else
echo $CONTEMPLATE
fi

$CONTEMPLATE
while inotifywait -e modify --exclude "\#.*\#" -q -r koans; do
$CONTEMPLATE
done

0 comments on commit 36151b5

Please sign in to comment.