Thomas Hartman wrote:
> could someone explain sharing?

A good tool for visualising the difference between shared and non-shared
results would be vacuum, using one of its front ends, vacuum-cairo or
vacuum-ubigraph.

http://hackage.haskell.org/package/vacuum
http://hackage.haskell.org/package/vacuum-cairo
http://hackage.haskell.org/package/vacuum-ubigraph

To see sharing, you will need to view a set of outputs (not just one
string). To keep the graph to a manageable size, use a smaller alphabet:

digits = "01"

-- All words of length n, with shared substrings
shared :: Int -> [String]
shared n = sss !! n where
  sss = [""] : [ [ c:s | c <- digits, s <- ss ] | ss <- sss ]

-- All words of length n, with unshared substrings
unshared :: Int -> [String]
unshared 0 = [""]
unshared n = [ c:s | c <- digits, s <- unshared (n-1) ]

And then in GHCi:

Vacuum.Cairo> shared 3 == unshared 3
True
Vacuum.Cairo> view $ shared 3
Vacuum.Cairo> view $ unshared 3

I'd send some PNGs, except my vacuum installation is currently broken.
Perhaps someone else can?

Regards,
Matthew


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to