[Haskell-cafe] Fair diagonals
Twan van Laarhoven
twanvl at gmail.com
Wed Nov 4 09:21:46 EST 2009
Sjoerd Visscher wrote:
> I believe this does what you want:
>
> <code>
The attached code should be more efficient, since it doesn't use integer indices.
Note that this is just a 'level' monad: the list is stratified into levels, when
combining two levels, the level of the result is the sum of the levels of the
inputs.
map (map sum) . runDiags . traverse each $ [[1..], [1..], [1..]]
[[3],[4,4,4],[5,5,5,5,5,5],[6,6,6,6,6,6,6,6,6,6],[7,7,7,7,7,7,7,7,7,7,7,...
I looked on hackage but I was surprised that I couldn't find this simple monad.
The package level-monad does look very similar, only it uses a different list
type for the representation.
By the way, it seems Omega intentionally doesn't use this design. To quote the
documentation "... a breadth-first search of a data structure can fall short if
it has an infinitely branching node. Omega addresses this problem ..."
Twan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MonadDiag.hs
Type: text/x-haskell
Size: 1226 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/b0a07eb0/MonadDiag.bin
More information about the Haskell-Cafe
mailing list