- UID
- 3388
- 积分
- 3322
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-3-28
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
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)
|
评分
-
查看全部评分
|