TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: VovKa on January 14, 2010, 12:45:41 PM
-
inspired by EvgeniyElpanov (http://www.theswamp.org/index.php?topic=31640.msg371814#msg371814)
originally Kelvinator was introduced by someone called Kelvin R. Throop.
trying to avoid copyright problems i named mine VovKaFicator :)
scrambles localized variables and functions
strings and quoted lists remain intact
(defun VovKaFicator (Func UsedVars)
(or GenVarName
(defun GenVarName (VarName UsedVars /)
(if (assoc VarName UsedVars)
UsedVars
(cons (cons VarName (read (substr (vl-filename-mktemp "_" "\\") 2))) UsedVars)
)
)
)
(cond ((null Func) nil)
((= (car Func) 'QUOTE) Func)
((listp (car Func))
(cons (VovKaFicator (car Func) UsedVars) (VovKaFicator (cdr Func) UsedVars))
)
((= (car Func) 'DEFUN)
(cons (car Func)
(cons (cond ((cdr (assoc (cadr Func) UsedVars)))
((cadr Func))
)
(VovKaFicator (cddr Func)
(progn (foreach v (vl-remove '/ (caddr Func))
(setq UsedVars (GenVarName v UsedVars))
)
UsedVars
)
)
)
)
)
((= (car Func) 'LAMBDA)
(foreach v (vl-remove '/ (cadr Func)) (setq UsedVars (GenVarName v UsedVars)))
(cons (car Func) (VovKaFicator (cdr Func) UsedVars))
)
((assoc (car Func) UsedVars)
(cons (cdr (assoc (car Func) UsedVars)) (VovKaFicator (cdr Func) UsedVars))
)
(t (cons (car Func) (VovKaFicator (cdr Func) UsedVars)))
)
)
(setq
testfunc (quote (defun test (arg1 DoNotRename / var1 var2 var3 test *error*)
(defun *error* (msg) (princ msg))
(defun test (arg3) arg3)
(setq var1 (strcat arg1 (setq var2 (strcat DoNotRename "_" arg1))))
(setq
var3 (strcat (vl-princ-to-string
(mapcar (function (lambda (e) (test e))) '(1 var1 3))
)
var1
((lambda (str1 / str2 var1)
(setq str2 (strcat arg1 (setq var1 DoNotRename)))
(strcat str1 str2 var2)
)
var1
)
var2
)
)
)
)
)
(prin1
(VovKaFicator testfunc
'((*ERROR* . *ERROR*) (var3 . guesswhat) (DoNotRename . DoNotRename))
)
)
GenVarName is a subject to change to strengthen the ambiguities :roll:
-
How to use your function?
I have not understood, how it to use...
>> add:
Apologize, has understood, an example in the end...
-
Recursive... much... :evil:
-
Recursive... much... :evil:
sorry, this was the only way i could do it :wink: