Trouble searching lists...
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Trouble searching lists...
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization

Author Message
Ray Schiska
Guest





Posted: Sun Dec 04, 2005 9:10 pm    Post subject: Trouble searching lists... Reply with quote

Hello All,

I confess I have been monitoring this and the other NGs plus the
AutoDesk web site forums in my quest to learn Autolisp, VLisp and the
rest for so long I feel I know some of these people, Jason P. Doug B.
and others. :) But this is my first post so please be gentle.
My problem is this: I have some rather large lists (one with over
16,000 lists of 3 elements each) that have the following format - INT
FLOAT FLOAT. This never varies so one would think that manipulating
this list of lists would be easy, but, alas I hit a snag. Finding
individual lists by searching for the first element, the INT, is easy,
but I need to be able to search for the either of the FLOAT values and
return that entire "INT FLOAT FLOAT" list. I apologize if my
terminology is not correct...
I hope I have stated this clearly enough. I feel the solution is
something simple and has just evaded me. Thanks in advance for any
help anyone may provide.

Sincerely,

Ray Schiska

Back to top
CarlB



Joined: 27 Sep 2005
Posts: 121

Posted: Mon Dec 05, 2005 2:07 am    Post subject: re:Trouble searching lists... Reply with quote

Not sure about your terminology, I'm guessing FLOAT is a real nmuber? Are your lists something like:

'((2 34.66 455.555)(322 34.3245 -34.0045)(etc....))

And you can find 3-element sub-lists using the first number (integer)as a 'key' but are having difficulties finding a list keying on the real numbers?

'assoc' is quite useful searching lists but is based on only the first item ina "sublist". You may need to build temporary lists then search those with "member". For example to get a list of just the second elements of 'somelist', use (mapcar 'cadr somelist). If you find the desired number using "member" you'll have the remainder of the list. using 'length' you cn get the position of the target item, then you can get the original INT FLOAT FLOAT sublist using 'nth'.

Hope this gives you some ideas, let me if this isn't quite your situation.
Back to top
View user's profile Send private message
Ray Schiska
Guest





Posted: Mon Dec 05, 2005 9:10 pm    Post subject: Re: Trouble searching lists... Reply with quote

CarlB,

Thanks for responding! I had come to a similar conclusion about the
temp lists though didn't really know where to start. Your message
points me in that direction. Exactly what I needed. Please don't
think me presumptious but can you tell me or point me to something
that will help me to understand what it is that Marcar/Lambda actually
do? I have used them, but all I do is use other sample code that I
have downloaded or gotten off a NGs or ADESK and try to fathom what
they have done, then adapt it to my needs. But I don't have a clear
picture of the mechanics involved. The explanations in ACAD/VLISP
help areas are all but useless to me. Maybe I'm too dumb, but I need
it explained or better yet illustrated in simple terms to be able to
grasp the concepts. Another example (now I AM being presumptious)
would be the workings of the Block Tables and ways to address it/them
for attribute access. That one has got me stonewalled, so I am again
using example code from other routines that does what I need to do.
You've heard the expression "a picture is worth a thousand words",
well, I am canvasing the Net and bookstores for an explanation with
"illustrations" that will help me understand the workings of them. I
am a very visual person and sometimes you have to "draw me a picture"
b4 I will click to it. :-} So if you have any suggestions for
research or reference materials in these two areas (Mapcar/Lambda and
entity/attribute addressing) I would appreciate it.

BTW - yours is another of the names I recognize on sight from your
participation in the NGs, ADESK and other forums. Good to find
someone who is willing to help others!

Thanks again,
Ray...
Back to top
CarlB



Joined: 27 Sep 2005
Posts: 121

Posted: Mon Dec 05, 2005 9:21 pm    Post subject: re:Trouble searching lists... Reply with quote

For information on accessing attributes, see:
Visual LISP: Attribute Magic at http://autodesk.com.tw/adsk/servlet/item?siteID=123112&id=3369513

I'll get back on mapcar lambda, gotta run....
Back to top
View user's profile Send private message
CarlB



Joined: 27 Sep 2005
Posts: 121

Posted: Mon Dec 05, 2005 11:42 pm    Post subject: re:Trouble searching lists... Reply with quote

Below is something on mapcar lambda from an AutoCAD Universuity doc:
http://www.onlinecad.net/AU%20Course%20Docs/AU%202002/AUGI%20LISP%20Greatest%20Hits.pdf

See also http://www.afralisp.co.za/lispa/lisp9.htm

#20 What is mapcar lambda and how does it work?
I decided to seek out the recognized leading expert in the world on AutoLISP for this informative explanation of the origins of Mapcar Lambda to add to add to my presentation.
According to Bill Kramer:

MAPCAR = Multiple APplications of the CAR command.
CAR = Contents of the Address Register - an IBM 504 Assembler mnemonic. When a list was called into the processor component of the computer, there were two registers or places to store numbers for manipulation. One was called the "A" register, the other was the "D" register. The creators of LISP decided to store the pointer to the data in the A register and the pointer to the next set of pointers in the D register. Thing to remember is that the 504 had only 504 bytes of
RAM.... wow!
Now, how about LAMBDA? Ever heard the term "it's Greek to me"? In mathematical language the Greek letters are often employed to represent unknowns or derived values. The use of Lambda, a Greek letter, signifies an unknown. It is not the origins of the Lambda-Lambda-Lambda house in
the Revenge of the Nerds movies <grin>!
End quote.

Mapcar is a function that will perform a specific function to every member of a list. So,
(mapcar ‘strcase (list “a” “b” “c”))
would return ‘(“A” “B” “C”). Lambda is an anonymous function very similar to the defun statement
except it doesn’t have a function name. Like,
(lambda (X)(strcase X)) is similar to (defun MYFUNCT (X)(strcase X))
So using the lambda function instead of the ‘strcase shown above with X being the argument being passed to the function. So,
(mapcar ‘(lambda (X)(strcase X)) (list “a” “b” “c”))
would return the list ‘(“A” “B” “C”) also.
Or
(mapcar ‘(lambda (X)(+ X Y)) (list 1 2 3)(list 0.5 0.5 0.5))
would return the list ‘(1.5 2.5 3.5)
Back to top
View user's profile Send private message
Ray Schiska
Guest





Posted: Thu Dec 08, 2005 5:10 pm    Post subject: Re: Trouble searching lists... Reply with quote

CarlB,

Thanks again for taking the time to research questions from a newbie
(to this NG and to A/VLisp. As busy as we all are these days I find
that admirable... I hope you don't mind if I use you as my "Go To"
guy in my future Lisp programming endeavors. I will not abuse that
privilege. l8tr...

Ray...
Back to top
Ray Schiska
Guest





Posted: Sat Dec 10, 2005 9:10 pm    Post subject: Re: Trouble searching lists... Reply with quote

Quote:
For information on accessing attributes, see:
Visual LISP: Attribute Magic at
http://autodesk.com.tw/adsk/servlet/item?siteID=123112&id=3369513

I'll get back on mapcar lambda, gotta run....

CarlB,

A quick question... Do you know of a utility (preferebly free :-)
that will inspect the code and generate a flow chart of some kind. It
may seem like cheating, but it seems to me a good way to learn to flow
chart. Having said that, do you have ANY tips along those lines?
TIA...

Ray...
Back to top
CarlB



Joined: 27 Sep 2005
Posts: 121

Posted: Sat Dec 10, 2005 10:18 pm    Post subject: re:Trouble searching lists... Reply with quote

I haven't heard of a "flow charting" program. My flow problems are in figuring them out then converting to code.

You might look into ALLY30 at http://www.cadinfo.net/scripts/lisplib-software.cfm?areano=45
Back to top
View user's profile Send private message
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Access Forum - Microsoft Office Forum - Electronics

Contact Us Powered by phpBB