From: 324
Subject: Acad + LISP
Date: 
Message-ID: <348c9ac4.0@news.esc.net.au>
Howdy all,
        I am trying to do some lisp programming within Acad r13. What I need
to now is if lisp can do assosiative arrays (like in Perl) ie

variable( "first", "when" "second", "does" "thd", "it work")

so that if I call $variable (first) gives when
                    $variable(second) gives does
                    $variable(thd) gives work

I can "sort of" do it like so

(setq a 10 b 20 c 30)
then do a !a which gives 10
                !b gives 20
                !c gives 30

but I can't assign this:

(setq 104 "text-string"  202 "another-one")

etc etc

Your help would be greatly appreciated.

PS: can you please  email me the answer- or clues- as well as posting to the
news group.


Thanks
Stavros...

From: Martti Halminen
Subject: Re: Acad + LISP
Date: 
Message-ID: <348D0E3B.5FBB@dpe.fi>
324 wrote:
> 
> Howdy all,
>         I am trying to do some lisp programming within Acad r13. What I need
> to now is if lisp can do assosiative arrays (like in Perl) ie
> 
> variable( "first", "when" "second", "does" "thd", "it work")
> 
> so that if I call $variable (first) gives when
>                     $variable(second) gives does
>                     $variable(thd) gives work
> 
> I can "sort of" do it like so
> 
> (setq a 10 b 20 c 30)
> then do a !a which gives 10
>                 !b gives 20
>                 !c gives 30
> 
> but I can't assign this:
> 
> (setq 104 "text-string"  202 "another-one")

- First, you would probably have better luck asking in comp.cad.acad
instead of comp.lang.lisp. This newsgroup is mostly populated with
people concerned with programming in Common Lisp and other "stand-alone"
lisp versions.

- Offhand the only system for this I remember in AutoLisp (4 years since
I did any serious programming with it...) would be the association list.
Usage would be something like:

(setq variable '((first . when)(second . does)(thd . "it work")))

(assoc 'second variable)


see the AutoLisp Programmers Reference for details

- In full-size Common Lisp I would use hash tables for this, but
AutoLisp doesn't have those (as well as most other interesting parts of
Lisp).
-- 
________________________________________________________________
    ^.          Martti Halminen
   / \`.        Design Power Europe Oy
  /   \ `.      Tekniikantie 12, FIN-02150 Espoo, Finland
 /\`.  \ |      Tel:+358 9 4354 2306, Fax:+358 9 455 8575
/__\|___\|      ······················@dpe.fi   http://www.dpe.fi
From: Kent M Pitman
Subject: Re: Acad + LISP
Date: 
Message-ID: <sfwd8j6r55q.fsf@world.std.com>
As a total aside to this remark by Martti Halminen <···@dpe.fi>:

> - In full-size Common Lisp I would use hash tables for this, but
> AutoLisp doesn't have those (as well as most other interesting 
> parts of Lisp).

Hmm. I'm surprised to find CL offers something useful that the
easy-to-use AutoLisp debugger doesn't compensate for.

          "Hash tables not available; using alists. Sorry."

;-)