Generating Large Trees to Play In.
18 Oct 2014
I have been working at understanding Huet’s Zippers. To do some proper
testing of the code I have written, I need some large trees to play in.
This post is about generating these trees with
It has been a while since I used test.check, so I’ll be following the guide. Here on first scan I see that was a good idea anyway since: “NOTE: Writing recursive generators was significantly simplified in version 0.5.9.” When really trying to use it, it turned out that I had forgotten too much to make an easy start. However, once I got to understand the new recursive generator, it was easy.
Here it is:
Using this we can generate a tree as intended (and by chaning the value 10 to a large value we can get large trees indeed)
which gives us
Using this here is a property for zippers (if you have a nonempty tree, make it into a zipper, go down the first key, then back up; after all that, the current value is the original tree) and its test