On 9/20/07, PR Stanley <[EMAIL PROTECTED]> wrote:
> Hi
> \_ n -> 1 + n
> \_ -> (\n -> 1 + n)
> The outcome seems to be identical. is there a substantive difference
> between the two definitions?
You can check this out your self by compiling this program and looking
at the generated core program li
On Thu, 20 Sep 2007, PR Stanley <[EMAIL PROTECTED]> wrote:
> \_ n -> 1 + n
> \_ -> (\n -> 1 + n)
> The outcome seems to be identical. is there a substantive difference
> between the two definitions?
No, since you do not pattern match on the first argument. Otherwise,
due to the way these definiti
G'day all.
Quoting PR Stanley <[EMAIL PROTECTED]>:
Fully lazy? Can you elaborate please?
Sure. that code again:
test1 = \n _ -> 1+n
test2 = \n -> let x = n+1 in \_ -> x
Suppose we have:
f g x = g x + g x
And we try two options:
f (test1 4) 3
f (test2 4) 3
In the fir
test1 n _ = 1 + n
test2 n = \_ -> 1 + n
I don't know if it's still the case, but GHC used to compile different
code for these at high optimisation levels. The first was essentially
compiled to:
test1 = \n _ -> 1+n
And the second to:
test2 = \n -> let x = n+1 in \_ -> x
The
G'day all.
Quoting PR Stanley <[EMAIL PROTECTED]>:
\_ n -> 1 + n
\_ -> (\n -> 1 + n)
The outcome seems to be identical. is there a substantive difference
between the two definitions?
Certainly, GHC compiles these to the same code. But be careful! Consider
the following two defintions:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
PR Stanley wrote:
> I must confess that the use of "\_" had me a little confused at first
> but thinking about it I can see that it makes perfect sense to have an
> argument or a wildcard character for any value.
> Cheers, Paul
FYI
If \_ -> foo confus
On Sep 20, 2007, at 0:16 , PR Stanley wrote:
I must confess that the use of "\_" had me a little confused at
first but thinking about it I can see that it makes perfect sense
to have an argument or a wildcard character for any value.
Sure. Remember, arguments are pattern matches in Haskel
I must confess that the use of "\_" had me a little confused at first
but thinking about it I can see that it makes perfect sense to have
an argument or a wildcard character for any value.
Cheers, Paul
On Sep 20, 2007, at 0:03 , PR Stanley wrote:
\_ n -> 1 + n
\_ -> (\n -> 1 + n)
The outcom
On Sep 20, 2007, at 0:03 , PR Stanley wrote:
\_ n -> 1 + n
\_ -> (\n -> 1 + n)
The outcome seems to be identical. is there a substantive
difference between the two definitions?
The second one seems to be more expressive of the currying principle.
Any thoughts?
I *think* the former is inter
Hi
\_ n -> 1 + n
\_ -> (\n -> 1 + n)
The outcome seems to be identical. is there a substantive difference
between the two definitions?
The second one seems to be more expressive of the currying principle.
Any thoughts?
Thanks, Paul
___
Haskell-Cafe m
10 matches
Mail list logo