CHAP. 4] SOFTWARE 55
FUNCTIONAL LANGUAGES
Functional languages were invented early in the history of computing. In 1958 John McCarthy at MIT
invented LISP. Functional languages represent computing as solving mathematical functions. A function takes
one or more arguments, and returns a value. For example, an equation for a parabola is:
f = 2x2 + 5 (4.4)
When one supplies a particular value for x, the function returns a particular result:
f (3) = 2(3)2 + 5 = 23 (4.5)
With a functional language, computing proceeds by passing input parameters to a function, which then
returns the result of the function. The return value(s) typically provides the input parameter(s) for another
function(s), and so any level of computational complexity can be programmed.
In any functional language, some basic functions are built in, and they??™re called primitives. In LISP these
include the mathematical functions of addition, subtraction, multiplication and division, for example, as well as
the function car, which returns the first element in a list, and cdr, which returns all but the first element in
a list. (By the way, the function names car and cdr come from acronyms for two registers used by LISP on
the old IBM 704 computer.
Pages:
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161