1. Is there any difference between
\a b -> (a, b)
and
let f a b = (a, b) in f
?
2. Is there any difference between
case x of (a, b) -> (b, a)
and
let (a, b) = x in (b, a)
?
--
__("
Marcin 'Qrczak' Kowalczyk wrote:
> 1. Is there any difference between
> \a b -> (a, b)
> and
> let f a b = (a, b) in f
> ?
No
>
>
> 2. Is there any difference between
> case x of (a, b) -> (b, a)
> and
> let (a, b) = x in (b, a)
> ?
Yes, if x is bottom.
-- Lennart
Koen Claessen <[EMAIL PROTECTED]>
proposes the following diagonalisation function:
>
> [ (a,b) | (a,b) <- [1..] // [1..] ]
>
> For a suitable definition of (//), for example:
>
> (//) :: [a] -> [b] -> [(a,b)]
> xs // ys = diagonalize 1 [[(x,y) | x <- xs] | y <- ys]
>where
>
Fergus Henderson wrote:
| Yes, the correct Haskell syntax for this is somewhat different.
| You can use
|
| [(a, b-a) | b <- [1..], a <- [1..b-1]]
Or:
[ (a,b) | (a,b) <- [1..] // [1..] ]
For a suitable definition of (//), for example:
(//) :: [a] -> [b] -> [(a,b)]
xs // ys =
| To me, it seems unsatisfactory to have a solution to this pure
| list problem with auxiliary functions relying on integers.
| It turns out to be a nice exercise to implement
|
| > diagonalise :: [[a]] -> [a]
|
| without any reference to numbers.
Here's my definition of an integer free diagon