Skip to content

Instantly share code, notes, and snippets.

View chiku-samugari's full-sized avatar

Takehiko Nawata chiku-samugari

View GitHub Profile
@chiku-samugari
chiku-samugari / meetup11.lisp
Created December 3, 2013 00:54
Live coding session at Lisp Meet Up #11. Make a frequency table and a histogram for a given list of floating point numbers.
;;; Utility
(defun iota (num &key (start 0) (step 1))
(do ((i start (+ i step))
(acc '() (cons i acc))
(c 0 (1+ c)))
((= c num) (nreverse acc))))
(defparameter *floats*
(mapcar (lambda (x)
(declare (ignore x))
@chiku-samugari
chiku-samugari / meetup9.lisp
Created September 28, 2013 12:11
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)
@chiku-samugari
chiku-samugari / meetup8.lisp
Created August 28, 2013 08:15
Live coding session at Lisp Meet Up #8 Devide the resulst of ``ls -l'' command into 2 sets by modulo 2 of the 2nd column (hard link count field) and sum up the 5th field (byte size field) of each set. Following code is available only for SBCL because PAPPLY macro depends on SB-C package.
(defparameter *sample*
(butlast (cdr (maplist (lambda (lst)
(when (cadr lst)
(subseq (str<-textfile "sample")
(1+ (car lst))
(cadr lst))))
(cons -1 (position-list #\Newline (str<-textfile "sample")))))))
(ql:quickload :split-sequence)