Created
November 5, 2010 22:24
-
-
Save dumbs/664976 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-optional (params env position num-env) | |
(cond ((endp params) | |
env) | |
((consp (car params)) | |
(print params) | |
`((,(caar params) ,num-env ,position) | |
(,(intern (format nil "~a-P" (caar params))) ,num-env ,(+ 1 position)) | |
. ,(make-stat-env-optional (cdr 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-optional (cdr params) env (+ 1 position) num-env))))) | |
(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)) | |
(make-stat-env-optional (cdr params) env 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)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment