Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.scheme

Reply
 
Thread Tools Display Modes
  #16 (permalink)  
Old 02-02-2012, 12:05 PM
Jussi Piitulainen
Guest
 
Posts: n/a
Default Re: varaible question

Roelof Wobben writes:

> > Something like this should work:
> >
> > (define (h x) (- (f x) (g (f x))))
> > (define (g x) (* x 0.15))
> > (define (f x) (* x 12))
> >

>
> Oke,
>
> Thanks for the tip.
>
> Just to be sure.
>
> When function h is executed with argument x.
> Then in the calculation area (- f x) (g (f x))
> First function f is executed and after that function g with as
> argument function f .


Let's be pedantic with the parens: (- (f x) (g (f x))).

You got the order of execution right: - is called with two arguments,
the first is the value of (f x), the second the value of (g (f x)). In
the second argument expression, g is called with the value of (f x).

Scheme is said to use call-by-value (eager), as opposed to policies
like call-by-name (old) and call-by-need (lazy) that may not evaluate
argument expressions in this order (or at all).
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #17 (permalink)  
Old 02-02-2012, 12:20 PM
Roelof Wobben
Guest
 
Posts: n/a
Default Re: varaible question

Everyone thanks for the explanation and patience with me.
I begin to understand how scheme works.

Roelof



Op 2-2-2012 14:05, Jussi Piitulainen schreef:
> Roelof Wobben writes:
>
>>> Something like this should work:
>>>
>>> (define (h x) (- (f x) (g (f x))))
>>> (define (g x) (* x 0.15))
>>> (define (f x) (* x 12))
>>>

>>
>> Oke,
>>
>> Thanks for the tip.
>>
>> Just to be sure.
>>
>> When function h is executed with argument x.
>> Then in the calculation area (- f x) (g (f x))
>> First function f is executed and after that function g with as
>> argument function f .

>
> Let's be pedantic with the parens: (- (f x) (g (f x))).
>
> You got the order of execution right: - is called with two arguments,
> the first is the value of (f x), the second the value of (g (f x)). In
> the second argument expression, g is called with the value of (f x).
>
> Scheme is said to use call-by-value (eager), as opposed to policies
> like call-by-name (old) and call-by-need (lazy) that may not evaluate
> argument expressions in this order (or at all).


Reply With Quote
  #18 (permalink)  
Old 02-02-2012, 02:15 PM
Catfish
Guest
 
Posts: n/a
Default Re: varaible question

Jussi Piitulainen <jpiitula@ling.helsinki.fi> writes:

> Roelof Wobben writes:
>
>> > Something like this should work:
>> >
>> > (define (h x) (- (f x) (g (f x))))
>> > (define (g x) (* x 0.15))
>> > (define (f x) (* x 12))
>> >

>>
>> Oke,
>>
>> Thanks for the tip.
>>
>> Just to be sure.
>>
>> When function h is executed with argument x.
>> Then in the calculation area (- f x) (g (f x))
>> First function f is executed and after that function g with as
>> argument function f .

>
> Let's be pedantic with the parens: (- (f x) (g (f x))).
>
> You got the order of execution right: - is called with two arguments,
> the first is the value of (f x), the second the value of (g (f x)). In
> the second argument expression, g is called with the value of (f x).
>
> Scheme is said to use call-by-value (eager), as opposed to policies
> like call-by-name (old) and call-by-need (lazy) that may not evaluate
> argument expressions in this order (or at all).


As this dude says, you're in a REPL, when you put a parens
you call a function, when you have a variable the result gets
printed.

CF
Reply With Quote
  #19 (permalink)  
Old 02-02-2012, 02:34 PM
Catfish
Guest
 
Posts: n/a
Default Re: varaible question

Roelof Wobben <rwobben@hotmail.com> writes:

> Everyone thanks for the explanation and patience with me.
> I begin to understand how scheme works.
>


Dude, happy hacking!
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 10:00 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.