-
-
Save SuzanneSoy/664610 to your computer and use it in GitHub Desktop.
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 make-stat-env (params &optional env (position 1) num-env) | |
(unless num-env (setq num-env (+ (or (second (first env)) -1) 1))) | |
(cond ((endp params) | |
env) | |
((eq '&optional (car params)) | |
`((,(cadr params) ,num-env ,position) | |
(,(intern (format nil "~a-P" (cadr params))) ,num-env ,(+ 1 position)) | |
. ,(make-stat-env (cddr params) env (+ 2 position) num-env))) | |
((eq '&rest (car params)) | |
(make-stat-env (cdr params) env position num-env)) | |
(t | |
`((,(car params) ,num-env ,position) | |
. ,(make-stat-env (cdr params) env (+ 1 position)))))) | |
(make-stat-env '(a b &optional c)) | |
=> ((A 0 1) (B 0 2) (&OPTIONAL 0 3) (C 0 4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment