determining if a int is a power

Paul Hudak paul.hudak at yale.edu
Sat Nov 8 07:13:06 EST 2003


But note that x `seq` x is equivalent to x, even operationally.  To see 
why denotationally, note that if x evaluates to _|_, so does x `seq` x. 
  And if x evaluates to a value v, so does x `seq` x.  To see why 
operationally, consider the two lists:

   let x = 1+1 in [x `seq` x]
   let x = 1+1 in [x]

Using conventional lazy evaluation in both cases, the term "1+1" is not 
evaluated until the head of the list is taken.  In other words, x `seq` 
x in no way hurries the evaluation of x.

   -Paul


Wolfgang Jeltsch wrote:
> Am Samstag, 8. November 2003, 00:22 schrieb Hamilton Richards:
>>Also note that
>>	if x then True else False
>>is just a verbose way of writing
>>	x
> 
> Actually, it's just a verbose way of writing x `seq` x, but this detail is, of 
> course, not interesting for beginners.
> 
> Wolfgang



More information about the Haskell-Cafe mailing list