Redefinition of function(operator) *
Posted: Wed Nov 04, 2009 6:33 am
I am new to Cl.
I have to define +,-,* and / operators for strings.
so, if the input is :
setf ret (+ 1 2 3 "asd"), I want the output in ret to be "1+2+3+asd". Similarly, for other operators.
I had no issues while redefining +, - and /. But redefining '*' is giving me headaches.
The sample * function:
The package abc uses common-lisp package and I have shadowed and exported opertaors(+, -, *, /).
Except '*' , the rest work fine according to my requirement. I get a name-conflict error for *.
Please suggest a better approach if available.
I have to define +,-,* and / operators for strings.
so, if the input is :
setf ret (+ 1 2 3 "asd"), I want the output in ret to be "1+2+3+asd". Similarly, for other operators.
I had no issues while redefining +, - and /. But redefining '*' is giving me headaches.
The sample * function:
Code: Select all
(defun abc:* (&rest arg)
(if (isAllNum arg)
(setf ret (multiple-value-call #'common-lisp:* (values-list arg)))
;else
(if(= (list-length arg) 1)(setf ret (format nil "~a" arg)) (setf ret (format nil "~{~a~^ * ~}" arg))
)
)
ret
)
Except '*' , the rest work fine according to my requirement. I get a name-conflict error for *.
Please suggest a better approach if available.