summaryrefslogtreecommitdiff
path: root/lisp/ouat/shell.lisp
diff options
context:
space:
mode:
authorJason Katz-Brown <jason@airbnb.com>2013-08-25 02:17:13 -0700
committerJason Katz-Brown <jason@airbnb.com>2013-08-25 02:17:13 -0700
commit9306cb60c32082c5403931de0823a9fd5daa196c (patch)
treeca1b6eb695fdf3f0c2294e92416b272164bae642 /lisp/ouat/shell.lisp
parent8fb2c681cecc01b46b0f4ba02d5cc177c4747b1c (diff)
Initial git commit.
Diffstat (limited to 'lisp/ouat/shell.lisp')
-rw-r--r--lisp/ouat/shell.lisp49
1 files changed, 49 insertions, 0 deletions
diff --git a/lisp/ouat/shell.lisp b/lisp/ouat/shell.lisp
new file mode 100644
index 0000000..72d1f9a
--- /dev/null
+++ b/lisp/ouat/shell.lisp
@@ -0,0 +1,49 @@
+(in-package :ouat)
+
+#+nil
+(defvar command-list
+ '(("a" . (ana 1 nil))
+ ("d" . (defi 1 nil))
+ ("h" . (help 0 nil))
+ ("l" . (by-length 0 t))
+ ("p" . (seven-prob 1 nil))
+ ("q" . (quit-words 0 nil))))
+
+(defvar *command-list*
+ '(("a" . ana)
+ ("b" . build)
+ ("q" . quit-words)
+ ("w" . woadwage)))
+
+(defun quit-words (arg)
+ (declare (ignore arg))
+ :QUIT)
+
+(defun woadwage (arg)
+ (anagram arg 2))
+
+(defun build (arg)
+ (anagram arg 1 *default-dictionary* '(:WORDS) t t))
+
+(defun build-num (arg)
+ (anagram arg 1 *default-dictionary* '(:NUMBER-OF-ANSWERS) t t))
+
+(defun num-anagrams (arg)
+ (anagram arg 1 *default-dictionary* '(:NUMBER-OF-ANSWERS)))
+
+(defun handle (query)
+ (when (< 1 (length (first query)))
+ (push "a" query))
+ (let ((command (first query))
+ (arg (second query))
+ (subquery (cddr query)))
+ (declare (ignore subquery))
+ (apply (cdr (assoc command *command-list* :test 'equal)) (list arg))))
+
+(defun words ()
+ (loop
+ do
+ (let ((result (handle (string-tokens (read-line)))))
+ (when (eq result :QUIT) (return))
+ (format t "~a~%" result)))
+ (values)) \ No newline at end of file