If you have a boolean-or expression:
a || b
will "a" be evaluated before "b" in Haskell as it is in other languages?
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists/?e
___
Hi
(take 4 . map (>0)) (f s t)
where
s = 2 : t
t = 3 : s
f = zipWith (-)
What would be the order of evaluation for the above code? How would I
illustrate the evaluation step-by-step?
I'm guessing that the code necessitates lazy evaluation and as such
it starts with take then
On Thu, 2007-07-26 at 12:04 -0500, Spencer Janssen wrote:
> On Thursday 26 July 2007 11:02:00 Jon Harrop wrote:
> > On Thursday 26 July 2007 17:03:31 C.M.Brown wrote:
> > > Hi Jon,
> > >
> > > On Thu, 26 Jul 2007, Jon Harrop wrote:
> > > > If you have a boolean-or expression:
> > > >
> > > > a ||
On Thursday 26 July 2007 11:02:00 Jon Harrop wrote:
> On Thursday 26 July 2007 17:03:31 C.M.Brown wrote:
> > Hi Jon,
> >
> > On Thu, 26 Jul 2007, Jon Harrop wrote:
> > > If you have a boolean-or expression:
> > >
> > > a || b
> > >
> > > will "a" be evaluated before "b" in Haskell as it is in oth
On Thursday 26 July 2007 17:03:31 C.M.Brown wrote:
> Hi Jon,
>
> On Thu, 26 Jul 2007, Jon Harrop wrote:
> > If you have a boolean-or expression:
> >
> > a || b
> >
> > will "a" be evaluated before "b" in Haskell as it is in other languages?
>
> Yes, I believe it is defined thus:
>
> True || _
Hi Jon,
On Thu, 26 Jul 2007, Jon Harrop wrote:
>
> If you have a boolean-or expression:
>
> a || b
>
> will "a" be evaluated before "b" in Haskell as it is in other languages?
>
Yes, I believe it is defined thus:
True || _= True
_|| True = True
_|| _= False
Therefore it is st
On Thursday 26 July 2007, Jon Harrop wrote:
> If you have a boolean-or expression:
>
> a || b
>
> will "a" be evaluated before "b" in Haskell as it is in other languages?
Yes.
The definition of (||) is roughly
True || b = True
False || b = b
Which de-sugars to
(||) = \ a b -> case a of
Tru
On 9 May 2008, at 21:52, PR Stanley wrote:
Hi
(take 4 . map (>0)) (f s t)
where
s = 2 : t
t = 3 : s
f = zipWith (-)
What would be the order of evaluation for the above code? How would
I illustrate the evaluation step-by-step?
What do you need it for, really? Pure functional
Hello,
I'm quite new to Haskell, but this is my understanding... Please correct me
if I am wrong, as there is a good chance I am. ;)
### Begin Code ###
module Main where
main =
putStrLn (show( (take 4 . map (> 0)) (f s t) ))
where
s = 2 : t
t = 3 : s
f = zipWith (-)
{-
- Output
PR Stanley wrote:
(take 4 . map (>0)) (f s t)
where
s = 2 : t
t = 3 : s
f = zipWith (-)
What would be the order of evaluation for the above code?
As I understand it Haskell does not specify an order of evaluation
and it would therefore be a mistake to write a program which relies
on
As I understand it Haskell does not specify an order of evaluation
and it would therefore be a mistake to write a program which relies
on a particular evaluation order. This is the 'unsafe' aspect of
unsafePerformIO.
Hmm... IMHO unsafePerformIO is 'unsafe' because it can lead to type
errors in
Hi
(take 4 . map (>0)) (f s t)
where
s = 2 : t
t = 3 : s
f = zipWith (-)
What would be the order of evaluation for the above code? How would
I illustrate the evaluation step-by-step?
What do you need it for, really? Pure functional programs are not
about evaluation order, but a
As others have pointed out, there are many allowed evaluation orders of this
expressions.
But not only that, how it gets evaluated depends on how you are going to use
it. Say that you print it, then you need all 4 elements, but say that it's
oly going to be used as an argument to null, then you wi
Lennart Augustsson wrote:
Even so, it's instructive to study how the normal order reduction of
this expression would proceed under the assumption that all 4 elements
will be used.
I think it's useful to try normal order until weak head normal form.
Not all steps are shown. Definitions of take
Hello
You may find this paper useful
http://research.microsoft.com/~simonpj/Papers/spineless-tagless-gmachine.ps.gz
It should give you the general feeling of how things are actually executed.
It's quite old, some things in GHC have changed, but the overall scheme,
I believe, is the same. The
Miguel Mitrofanov wrote:
As I understand it Haskell does not specify an order of evaluation
and it would therefore be a mistake to write a program which relies
on a particular evaluation order. This is the 'unsafe' aspect of
unsafePerformIO.
Hmm... IMHO unsafePerformIO is 'unsafe' because it ca
16 matches
Mail list logo