Very simple lisp, help
Posted: Wed Dec 16, 2009 11:05 am
I have a very simple code problem I trying to find the LCM of few numbers I first created this code which compiles and works..
(defun lcm (&key a b c d e) (lcm a b c d e ))
(lcm :a 3 :b 2 :c 4 :d 7 :e 11)
My instructor informed me that I needed to use &rest. Every time I tried to use the &rest function it has not worked, I am not sure if my syntax is wrong or not. Bellow are the 2 ways I think the code should work but is not working. ANy help or suggestions Thanks much... I
(defun my-lcm (&rest a b c d e) (lcm a b c d e ))
(my-lcm :a 3 :b 2 :c 4 :d 7 :e 11)
Or
(defun my-lcm (&rest 1 2 3 4 5))
(defun lcm (&key a b c d e) (lcm a b c d e ))
(lcm :a 3 :b 2 :c 4 :d 7 :e 11)
My instructor informed me that I needed to use &rest. Every time I tried to use the &rest function it has not worked, I am not sure if my syntax is wrong or not. Bellow are the 2 ways I think the code should work but is not working. ANy help or suggestions Thanks much... I
(defun my-lcm (&rest a b c d e) (lcm a b c d e ))
(my-lcm :a 3 :b 2 :c 4 :d 7 :e 11)
Or
(defun my-lcm (&rest 1 2 3 4 5))