cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

2 versions 1 works one does not - why

drgriffin
1-Newbie

2 versions 1 works one does not - why

There is no underlying logic that I can discern as to what will work and what won't
5 REPLIES 5

The for loop in the program is meaningless. You are defining u as a local function with a formal parameter of x. The value of x in the environment of that definition is irrelevant.

Note that u is defined as a function. So in version 1 you have defined displacement as a function (of one variable) and displacement(x) is a number, depending on x.

In version 2 you have defined displacement as a function of one variable that returns a function (u) of one variable. As you do not ever use the value of the formal parameter x in the definition of displacement, it returns the same value (a function) regardless of the passed value of x. Now displacement(x) is a function of one variable and is not a value.

Further note that due to the implicit currying associated with SUC a function of one variable returning a function of one variable is indistinguishable from a function of two variable (returning a normal value). And that is what the error message is showing.
__________________
� � � � Tom Gutman

On 12/6/2009 3:49:02 PM, Tom_Gutman wrote:
>The for loop in the program is
>meaningless. You are defining
>u as a local function with a
>formal parameter of x. The
>value of x in the environment
>of that definition is
>irrelevant.

Note that u is
>defined as a function. So in
>version 1 you have defined
>displacement as a function (of
>one variable) and
>displacement(x) is a number,
>depending on x.

In version 2
>you have defined displacement
>as a function of one variable
>that returns a function (u) of
>one variable. As you do not
>ever use the value of the
>formal parameter x in the
>definition of displacement, it
>returns the same value (a
>function) regardless of the
>passed value of x. Now
>displacement(x) is a function
>of one variable and is not a
>value.

Further note that due
>to the implicit currying
>associated with SUC a function
>of one variable returning a
>function of one variable is
>indistinguishable from a
>function of two variable
>(returning a normal value).
>And that is what the error
>message is
>showing.
__________________

>� � � Tom Gutman



So what I should have done is simply define the displacement function as displacement(x) as one would normally do and use the a range value for x. There was no need for the program.

Yes. It is generally better and easier to define functions and then evaluate the functions at multiple points (as needed) rather than try to define vectors of values.
__________________
� � � � Tom Gutman
PhilipOakley
5-Regular Member
(To:TomGutman)

On 12/7/2009 3:25:56 PM, Tom_Gutman wrote:
>Yes. It is generally better
>and easier to define functions
>and then evaluate the
>functions at multiple points
>(as needed) rather than try to
>define vectors of values.
>__________________
>� � � � Tom Gutman
An aside:
"... generally.. ".
Yes this is generally true, but occasionally the
vector of values can be better, particularly if it
(the vector) is evaluated once and used often. i.e.
An economy of effort consideration.
Thought I'd mention it.. 😉

Philip Oakley
RichardJ
19-Tanzanite
(To:drgriffin)

Same answer as Tom.

The function being requested does not need any loops though, just some if and otherwise statements. What are you trying to do with the loop?

Richard
Top Tags