Lisp

Lisp

Anonymous
Not applicable
820 Views
5 Replies
Message 1 of 6

Lisp

Anonymous
Not applicable

Dear all 

 

If

(setq a (the auto cad forum))

(setq b (lisp))

 

so now i need to interchange the value of b  to a....

 

If anyone knows this function please help me..

 

Regards 

DMC

0 Likes
821 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

Whatever you have in two variables, you can swap their contents this way:

(setq

  temp a

  a b

  b temp

)

Kent Cooper, AIA
Message 3 of 6

martti.halminen
Collaborator
Collaborator

@di****hmc wrote:

Dear all 

 

If

(setq a (the auto cad forum))

(setq b (lisp))

 

so now i need to interchange the value of b  to a....

 

If anyone knows this function please help me..

 

Regards 

DMC


Actually trying your example in the  VLIDE console window produces this:

 

_$ (setq a (the auto cad forum))
; error: no function definition: THE
_1$ a
nil
_1$ (setq b (lisp))
_$ b
nil
_$ (setq b (lisp))
; error: no function definition: LISP
_1$

 

So, start taking those quote marks seriously, they are not optional!

 

(the previous answer already handled the question)

 

-- 

0 Likes
Message 4 of 6

john.uhden
Mentor
Mentor

I apologize for Marrti's somewhat cynical reply.  Cynicism is usually my brand.  What Kent responded is the best answer you can get.  I use his approach very often.

 

John F. Uhden

0 Likes
Message 5 of 6

_gile
Consultant
Consultant

Hi,

 

Just for fun:

 

(mapcar 'set '(a b) (list b a))


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 6

john.uhden
Mentor
Mentor

@_gile WROTE:

 

Just for fun:

 

(mapcar 'set '(a b) (list b a))

THAT IS FUN!  THANKS!

John F. Uhden

0 Likes