【电子书】直击AUTOLISP (20个精彩的范例)
This is a review of several valuable examples of AutoLISP and Visual LISP taken from the AUGI
LISP guild over the last couple of years. Since this is called The LISP Guilds Greatest Hits I
would like to present the programs and tips like the “Top Twenty” countdown, starting at #20.
#20 What is mapcar lambda and how
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)
**** Hidden Message *****
好文章,谢谢分享 谢谢分享!20个好多
向大师学习,谢谢分享!!! kkkkkkkkkkkkkkkkkkk
感谢分享程序!!! 感谢大师分享 回复学习,谢谢分享
reading~~~ 回复学习学习{:1_12:} 英文版的吗? 看看有什么 支持一下,谢谢分享。。。。。。
看着是英文,尝试看看
谢谢分享。