Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why the numbers are not summed?

3 REPLIES 3
Reply
Message 1 of 4
crixtiano
274 Views, 3 Replies

Why the numbers are not summed?

Please, I need help understanding something:
 
=================================================
Command: (setq pt (list 1.0 2.0 3.0))
(1.0 2.0 3.0)
 
Command: (cddr pt)
(3.0)
 
 Command: (+ (cddr pt) 100)
; error: bad argument type: numberp: (3.0)
 
Command: (+ (cddr pt) 100.0)
; error: bad argument type: numberp: (3.0)
=================================================
 
Why the above code generates an error?
 
Why the numbers are not summed?
 
Thank you!
 
Cristiano
 
 
 
3 REPLIES 3
Message 2 of 4
crixtiano
in reply to: crixtiano

Because cdr returns a list and not a number. LOL

😉
Message 3 of 4
hmsilva
in reply to: crixtiano

Hi Cristiano,

 

cddr will return a list,

change to

(+ (caddr pt) 100.0)

 

EDIT: too slow...

 

HTH

Henrique

 

EESignature

Message 4 of 4
devitg
in reply to: crixtiano

3 options  

 

 

 (setq pt (list 1.0 2.0 3.0))
;;;(1.0 2.0 3.0)


(setq pt+100z ( mapcar '+ pt (list 0 0 100)))

(setq z+100 ( + (last pt) 100))

(setq z++100 ( + (car(cddr pt))))

 

 

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost