TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: curmudgeon on March 31, 2009, 02:26:10 PM
-
I have
(setq lst (vl-sort lst (function (lambda (a b) (< (car a) (car b))))))
which sorts a list for me, the list is of a form
(("101" "3E16F") ("102" "3E0C3") ("103" "3DFFB") ("104" "3DFD9") ("105" "3DFA8") ("106" "3DFCA")....)
text content, entity handle. I guess I should call this an association list because the text is the (1 . "text") from one entity, and the other is the (5. "handle") from a lwpolyline, which might imply that I am learning something.
I look into the help files, and searched the board(s). I look for references to lambda, and cross referenced function, ' and list, mapcar and apply. Lambda is defining an anonymous function (< (car a) (car b)), and passing the result through function, which is the same as ', but allows for optimization, which passes that result to vl-sort to use on the list lst.
I typed it myself, and it still is at least 50% gibberish to me.
Would someone explain in their own words what is happening here, please? I am wanting, at this point in the program, to change the nature of the list sorted to include a points list for the polyline, because this would be the easiest time to get it, rather than grabbing the handle and (entget (handent)).
I am guessing there is a way. Maybe
(("101" "3E16F" ((x y)(x y) (x y)....)("102" "3E0C3")((x1 y1)(x2 y2]) (x3 y3)....)... )
or
(("101" ("3E16F" (x y)(x y) (x y)....)("102" "3E0C3")((x1 y1)(x2 y2) (x3 y3)....)... )
or even
(("101" '("3E16F" (x y)(x y) (x y)....)("102" "3E0C3")((x1 y1)(x2 y2) (x3 y3)....)... )
Understanding is what I am after.
thanks,
roy
-
Before going on a superfluous winded discussion ... does this clarify?
(defun foo ( a b ) (< (car a) (car b)))
(vl-sort lst 'foo)
-
Perhaps this will help (http://www.theswamp.org/index.php?topic=2953.msg37000#msg37000).
-
that helped very much.
I'll try to keep the winds down.
-
Glad it helped curmudgeon, let us know if you need clarity on anything :).
PS: The wind reference was about me: I can go off on long winded explanations only to find out I went down some road no one cares about; just trying to avoid the resulting (http://www.theswamp.org/screens/mp/facepalm.gif).
-
I believe Stig Madsen did an explanation on mapcar/lambda as well but I can't seem to find. :(
-
I believe Stig Madsen did an explanation on mapcar/lambda as well but I can't seem to find. :(
I recall one by Vladimir Nesterovsky - it must be on the web (still)....from many moons ago
-
I believe Stig Madsen did an explanation on mapcar/lambda as well but I can't seem to find. :(
Maybe this?
http://www.theswamp.org/index.php?topic=340.0
PS Brings back happy memories. Those were my early days just learning the language. :-)
-
I believe Stig Madsen did an explanation on mapcar/lambda as well but I can't seem to find. :(
I recall one by Vladimir Nesterovsky - it must be on the web (still)....from many moons ago
Vladimir's page is still up. [ http://vnestr.tripod.com/ ]
His explanation.
[ http://members.tripod.com/~vnestr/mapcar.txt ]
-
I miss Vladimir, he was like Tony Lite: all the intellect, none of the attitude.
-
I learned a lot from his web pages. Of course i learn a lot from everyone everywhere too.
I talked to him via email a couple of times and i tried to get him to take part in the challenges here (back when we were having them on a regular basis) but he never did show up. Last i heard he was big on Haskell.
-
I miss Vladimir, he was like Tony Lite: all the intellect, none of the attitude.
:-D
-
Perhaps this will help (http://www.theswamp.org/index.php?topic=2953.msg37000#msg37000).
Only comment:
might want to use (function (lambda <yada yada>)) instead of quote
Thx to LE for pointing this out many moons ago
-
Perhaps this will help (http://www.theswamp.org/index.php?topic=2953.msg37000#msg37000).
Only comment:
might want to use (function (lambda <yada yada>)) instead of quote
Thx to LE for pointing this out many moons ago
Are you Herman?.... from the old happy days at the autolisp customization ng from adesk, if so I'm glad to see you around here!!!!!! (I mean read you) - have been a long time, Sir. :)
Luis Esquivel.
-
Are you Herman?.... from the old happy days at the autolisp customization ng from adesk?
My guess is ... Herman Mayfarth. :)
-
Are you Herman?.... from the old happy days at the autolisp customization ng from adesk?
My guess is ... Herman Mayfarth. :)
My guess :-P
-
Are you Herman?.... from the old happy days at the autolisp customization ng from adesk?
My guess is ... Herman Mayfarth. :)
My guess :-P
Abit off topic, but.
I did a job for his wife many moons ago (Deb Gwynne) shortly after his passing (They lived in Taneytown, MD)
She looks very similar to the picture of his portrayed character...Herman. :whistle: Scary!!
-
I did a job for his wife many moons ago (Deb Gwynne) shortly after his passing (They lived in Taneytown, MD)
Mr. Mayfarth passed? I'm sorry to hear that; I did not know; apologies
-
</cloak>
And a big "howdy" to MP, LE , et. al., from Corona, Calif.
Herman Mayfarth
www.tktn.com
:)
...return with us now, to those thrilling days of yesteryear, to the exploits of GO ACAD & cca
yeah, I miss Vlad's voice, too. very bright guy, & interesting to type to (what MP said)
Later,
hm
:)
-
My guess is ... Herman Mayfarth. :)
I did a job for his wife many moons ago (Deb Gwynne) shortly after his passing (They lived in Taneytown, MD)
And a big "howdy" to MP, LE , et. al., from Corona, Calif.
Herman Mayfarth
wut
-
Referring to "Herman Munster" (as pictured above) aka Fred Gwynne.... the actor
not referring to Herman Mayfarth aka AutoCAD aficionado....
BTW... good to see/read you again Herman, will you be around?
-
Referring to "Herman Munster" (as pictured above) aka Fred Gwynne.... the actor
*dagnabbit* I swear that picture wasn't there before. (http://www.theswamp.org/screens/mp/facepalm.gif)
Anyway, good to see Herman's mug around here. :)
<MP=Michael Puckett>