On Mon, Jun 15, 2009 at 3:03 AM, Luke Palmer <span dir="ltr"><<a href="mailto:lrpalmer@gmail.com">lrpalmer@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><div class="gmail_quote"><div>The last thing: we made startsWithUpper less general in the process; it is undefined for empty strings. We need to verify that words never returns any empty strings. I did this using SmallCheck:<br>
<br>ghci> import Test.SmallCheck<br>ghci> smallCheck 10 $ \string -> all (not . null) (words string)</div></div></blockquote><div><br>'Course, it turns out that SmallCheck never generates any spaces... ever. Some verifier that is.<br>
<br>By careful inspection of the definition of words, I can see that it never returns an empty string. I couldn't find a better way to convince myself of this (I like to avoid looking at definitions when possible).<br>
<br>Luke<br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote"><div><br>Depth 0:<br> Completed 1 test(s) without failure.<br>
Depth 1:<br> Completed 2 test(s) without failure.<br>
Depth 2:<br> Completed 5 test(s) without failure.<br>Depth 3:<br> Completed 16 test(s) without failure.<br>Depth 4:<br> Completed 65 test(s) without failure.<br>Depth 5:<br> Completed 326 test(s) without failure.<br>
Depth 6:<br>
Completed 1957 test(s) without failure.<br>Depth 7:<br> Completed 13700 test(s) without failure.<br>Depth 8:<br> Completed 109601 test(s) without failure.<br>Depth 9:<br> Completed 986410 test(s) without failure.<br>
Depth 10:<br> Completed 9864101 test(s) without failure.<br><br>So I am reasonably confident that words never gives me any empty strings.<br><br>Tada! Your solution is almost exactly the same as the one-liners! :-)<br>
<br>
Luke<br></div></div><br>
</blockquote></div><br>