[
Lists Home |
Date Index |
Thread Index
]
Assignment in your case is a special case of an "update" operation, which
takes an object and returns a new object, some properties of which have new
values.
From the book of Simon J. Thomson ""Haskell: The Craft of Functional
Programming":
update (Sto sto) v n
= Sto (\w -> if v == w then n else sto w)
This is the definition of an update function of a calculator store, which
keeps track of user-defined variables names and values using a lookup
function sto.
This creates a new store (Sto is the constructor, which takes a lookup
function) with a new lookup function, which is identical to the lookup
function of the store that is being updated with the only exception of the
variable name "v", for which it will return the newly specified value "n".
To be clear, here's the definition (in Haskell) of all the functions
implementing this data type:
newtype Store = Sto (Var -> Int)
initial :: Store
initial = Sto (\v -> 0)
value :: Store -> Var -> Int
value (Sto sto) v = sto v
update :: Store -> Var -> Int -> Store
update (Sto sto) v n
= Sto (\w -> if v == w then n else sto w)=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Roger L. Costello" <costello@mitre.org> wrote in message
3F1593E6.A57FC302@mitre.org">news:3F1593E6.A57FC302@mitre.org...
> Hi Folks,
>
> 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?"
>
> The particular technology that I am looking at (MathML) interprets the
> equal symbol the later way (as a relational operator).
>
> I would like to devise an expression that would be interpreted along the
>
> lines of the first way (that is, I'd like the expression to be a
> statement of a
> "formula" that I can plug in a value for miles to compute the
> kilometer's value).
>
> MathML has the ability to express "functions". From a mathematician's
> point-of-view is this interpretation:
>
> "kilometers is assigned the result of multiplying the
> value of miles times 1.62."
>
> considered a statement of a function? For example,
>
> kilometers = f(miles)
>
> where the function, f, multiplies miles times 1.62?
>
> 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? 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.
>
> /Roger
>
>
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
>
>
|