Created
September 28, 2013 12:11
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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