Skip to content

Instantly share code, notes, and snippets.

@ichimal
Created November 30, 2012 05:39
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 ichimal/4173951 to your computer and use it in GitHub Desktop.
Save ichimal/4173951 to your computer and use it in GitHub Desktop.
builder of "make-N-tuple" function
(ql:quickload :cl-case-control)
(defmacro build-make-n-tuple-of (args)
(let ((expanded (eval args)))
`(progn
,@(loop for elm in `(,@expanded)
collect (list 'build-make-n-tuple elm))
nil )))
(defmacro build-make-n-tuple (n)
(declare (type (integer 0 *) n))
(check-type n (integer 0 *) "integer >=0")
(let ((fsym (intern (casectl:adj-case (format nil "make-~d-tuple" n))))
(args (loop for i from 1 to n collect (gensym))) )
`(defun ,fsym (,@args) (list ,@args)) ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment