[
Lists Home 
Date Index 
Thread Index
]
Roger L. Costello wrote:
> Consider this formula:
> kilometers = miles * 1.62
> A programmer might interpret it like this:
> "kilometers is assigned the result of multiplying the
> value of miles times 1.62."
> That is, the equals symbol is treated as an "assignment operator".
>
> An alternate way of interpreting it is to treat the equals symbol as a
> "relational operator". Thus, the above formula would be interpreted as:
> "Does the value of kilometers equal the value of miles
> times 1.62?"
> [...]
> I would like to devise an expression that would be interpreted along the
> lines of the first way [...]
> If it is true that this interpretation:
>
> "kilometers is assigned the result of multiplying the
> value of miles times 1.62."
>
> is a statement of a function then what kind of function is it?
The usual way of dealing with assignment in a functional
setting is to introduce the concept of an "environment"
or a "store". An environment is a finite map (think
"associative array") that maps identifiers to values.
Assignment statements are then functions that take an
environment as input and return a new environment as
output.
So the denotation of a statement like:
kilometers = miles * 1.62
might be something like (in pseudocode):
function f(env) = store(env, "kilometers", lookup(env,"miles") * 1.62);
where 'lookup :: (environment, identifier) > value'
looks up the value of an identifier in an environment and
'store :: (enviroment, identifier, value) > environment'
returns a new, modified environment.
> Is it a
> lamda function? I am not exactly certain what a "lamda function" is,
> but from the description in the MathML book it seems that lamda function
> is appropriate.
ITYM "lambda". A lambda expression is a way of writing
functions without having to give them a name. For example,
in Scheme:
(define (addone x) (+ x 1))
is essentially the same as:
(define addone (lambda (x) (+ x 1)))
so:
(addone 3)
=== ((lambda (x) (+ x 1)) 3)
=== (+ 3 1)
=== 4
Google for "lambda calculus introduction" for more information.
Joe English
jenglish@flightlab.com
