<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Dear Stephen,<div><br></div><div>I am highly appreciative of the implementations you've provided. Are you happy for me to add your name on the credits page?</div><div><br></div><div>Yes, it is a highly artificial problem - chosen specifically so that the advanced students might figure this out and have a bit of a laugh.</div><div><br></div><div>Kind regards,</div><div>Samuel</div><div><br><div><div>On 4/05/2010, at 1:01 AM, Stephen Bloch wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On May 3, 2010, at 8:17 AM, Samuel Williams wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I'm putting together a website aimed at high school students and teachers, and would like to make sure the following page is as good as possible:</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span><a href="http://programming.dojo.net.nz/languages/scheme/index">http://programming.dojo.net.nz/languages/scheme/index</a></div><div><br></div><div><div>In particular, "Why would I learn this language?" section needs to have a few paragraphs. I don't use Scheme so I hoped that you could provide the main reasons why Scheme is a language someone would want to learn about.</div></div></div></blockquote><div><br></div>Take a look at <a href="http://www.adelphi.edu/sbloch/class/tsrj/testimonials/">http://wwwadelphi.edu/sbloch/class/tsrj/testimonials/</a> </div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>It would also be great if someone could rewrite the Scheme source code example so that it is as close as possible to the C implementation:</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        <a href="http://programming.dojo.net.nz/languages/c/index">http://programming.dojo.net.nz/languages/c/index</a></span></div><div><br></div><div>I understand that Scheme is very different from C, and uses different paradigms, so it doesn't have to be identical, however it would be great if it worked in generally the same way. It would be great if you could include comments explaining how it works and what is happening (like the C example).</div></div></div></blockquote><div><br></div>Well, that particular algorithm relies very heavily on mutation, but here's a functional version.</div><div><br></div><div><div>(define (door-open door)</div><div> (doh door 99))</div><div><br></div><div>(define (doh door pass)</div><div> (cond [(zero? pass) true]</div><div> [(= (remainder door (+ pass 1)) pass)</div><div> (not (doh door (- pass 1)))]</div><div> [else</div><div> (doh door (- pass 1))]))</div><div><br></div><div>(define doors (build-list 100 door-open))</div><div><br></div><div><br></div><div><br></div><div>Somewhat shorter but more cryptic:</div><div><div><br></div><div>(define (door-open door)</div><div> (doh door 99))</div><div><br></div><div>(define (doh door pass)</div><div> (or (zero? pass)</div><div> (not (boolean=? (= (remainder door (+ pass 1)) pass)</div><div> (doh door (- pass 1))))))</div><div><br></div><div>(define doors (build-list 100 door-open))</div><div><br></div><div><br></div><div><br></div><div>Even shorter, but takes some math (and illustrates how artificial this problem is :-) :</div><div><br></div><div>(define (door-open door)</div><div> (integer? (sqrt (+ door 1))))</div><div><br></div><div>(define doors (build-list 100 door-open))</div><div><br></div></div></div><br><br><div>
<span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div>Stephen Bloch</div><div><a href="mailto:sbloch@adelphi.edu">sbloch@adelphi.edu</a></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br></div></blockquote></div><br></div></body></html>