Skip to content

Instantly share code, notes, and snippets.

@chiku-samugari
Created September 28, 2013 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiku-samugari/6741448 to your computer and use it in GitHub Desktop.
Save chiku-samugari/6741448 to your computer and use it in GitHub Desktop.
Live coding session at Lisp Meet Up #9. Case insensitive word count.
(defparameter *test-data*
"PAPPLY is a macro family that offers a shorthand form to write the partial
application of fucntions.
PAPPLY macro generates a function object by partial applying the fucntion
specified as the first argument to the rest arguments. A special symbol `_`
is utilized as a place holder that denotes not-yet-fixed arguments.
(papply (list (1+ _) (string _)))
;=> #'(LAMBDA (#:P0 #:P1 &REST #:REST0)
(APPLY #'LIST (1+ #:P0) (STRING #:P1) #:REST0))
APAPPLY macro introduces anaphoras and made possible to utilize one parameter
multiple times. A symbol `An` (n is a number) appears in APAPPLY form is
recognized as the nth parameter of generated function object.")
(ql:quickload :cl-ppcre)
(use-package :cl-ppcre)
(show-hash-table
(let ((table (make-hash-table :test #'equalp)))
(dolist (word (split "\\s+" *test-data*) table)
(incf (gethash word table 0)))))
(defun show-hash-table (ht &optional (stream t))
(format stream "~% key -> value ~%")
(format stream "--------------~%")
(maphash
(lambda (k v)
(format stream "~a -> ~a~%" k v))
ht))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment