On Mon, Jul 12, 1999 at 07:48:30AM -0700, Simon Peyton-Jones wrote:
> Who owns the copyright?
Technically, everybody who has contributed nontrivial amounts of text (not
ideas, but text).
> but given very free-wheeling permission to reproduce the report.
I have one request. Language definitio
Stefan Kahrs <[EMAIL PROTECTED]> writes:
> I liked Mark's version, but let me add a related challenge.
>
> I defined a translation of //-list comprehensions
> that is analogous to the foldr-translation of list comprehensions
> (which optimises the map-concat approach) but works in the infin
Tom Pledger writes:
| > diag = foldr (diag2 []) [[]] where
| > diag2 zs (x:xs) ys = (zipWith (:) (x:zs) ys) ++ diag2 (x:zs) xs ys
| > diag2 zs [] (_:ys) = (zipWith (:) zs ys) ++ diag2 zs [] ys
| > diag2 _ _ _ = []
... which hangs when given a mixture of empty and
Wolfram Kahl writes:
| 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.
IIRC a (Cantor?) diagonal
In the meantime I have discovered a flaw in my original
diagonalisation in that it looped in finite cases.
This can easily be mended:
DiagWK1:
> diag :: [[a]] -> [a]
> diag = f id where
> f :: ([[a]] -> [[a]]) -> [[a]] -> [a]
> f a [] = split id (a []) []
> f a (l:ls) = split id (a [l]) ls
I liked Mark's version, but let me add a related challenge.
I defined a translation of //-list comprehensions
that is analogous to the foldr-translation of list comprehensions
(which optimises the map-concat approach) but works in the infinite case
as well.
This requires an operator foldrinf, o
Another alternative to diag [[f x y | x < - xs] | y <- ys] is
to write it as diagWith f xs ys where:
diagWith f [] ys = []
diagWith f xs [] = []
diagWith f (x:xs) ys = d [x] xs ys
where
d xs' xs ys = zipWith f xs' ys ++ d' xs ys
where
d' [] [] = []
d' [] (y:ys)
> > > Miranda has something called diagonalizing list
> > comprehensions if I recall
> > > correctly. I think you would write:
> > >
> > > [(a,b) // a <- [1..], b <-[1..]]
> > >
> > > and the resulting list would be
> > >
> > > [(1,1), (1,2), (2,1) ...]
> >
> > Haskell has this too. :) The s
Mark P Jones <[EMAIL PROTECTED]> writes:
>
> Here's my definition of an integer free diagonalization function.
> [..] As written, I think
> it is a nice example of programming with higher-order functions,
> and, in particular, using function composition to construct a
> pipelined program:
> DiagMPJ 0:00.16 0:02.32 0:37.55
> DiagMPJ1 0:00.12 0:01.50 0:23.83
> DiagWK1 0:00.12 0:01.34 0:19.02
> DiagWK2 0:00.12 0:01.35 0:19.09
> DiagWK3 0:00.12 0:01.34 0:18.82
>
>
> The only thing that surprises me is
> that the compiler does not do the optimization from DiagWK2
Folks,
For a long time an item on my to-do list has been to update
the Haskell 98 bugs page.
http://research.microsoft.com/~simonpj/haskell/haskell98-bugs.html
I have now done so, adding a dozen or so bug fixes and clarifications
that have arisen over the last few months.
I believe t
11 matches
Mail list logo