with string-append, you can perform a test (string?) beforehand to know if it will crash or not (and avoid the crash).<br>with string->number, the test can "only" (means: this is the simplest way) be done by that same function, so it can be used as either a tester or a transformer, a bit like member for example.<br>
<br><div class="gmail_quote">On Thu, Nov 12, 2009 at 14:38, wooks <span dir="ltr"><<a href="mailto:wookiz@hotmail.com">wookiz@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
<br>
On Nov 12, 1:01 pm, Nadeem Abdul Hamid <<a href="mailto:nad...@acm.org">nad...@acm.org</a>> wrote:<br>
> You could try asking a student to be the function -- tell them you'll <br>
> give them a sequence of digits (or write them on the board) and they <br>
> have to read back to you the number. Try it with some 3 and 4 digit <br>
> numbers; then give them something like "13z5". Hopefully, they'll say <br>
> something like "that's not a number"; Try with a couple more valid <br>
> sequences of digits; then another invalid one. Point out to them, that <br>
> when they are given something not a number, then they are deciding <br>
> somehow what a suitable response is -- "false" is just an easy, <br>
> abbreviated way of indicating the "not a number" case -- because it <br>
> wouldn't make sense to read back some arbitrary number if given <br>
> something like "13z5." I don't think you want to overkill this issue <br>
> at this point -- just make it seem intuitively sensible and move on.<br>
<br>
</div>Hmmm. This will come right after the example of string-append that<br>
crashes when given a numeric argument.....<br>
<br>
I guess it's an early exposure to the need to look up a fucnctions<br>
contract specification - sometimes you can intuit and sometimes you<br>
need to look it up.<br>
<div><div></div><div class="h5">_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
</div></div></blockquote></div><br>