<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;"><div class="Ih2E3d">On Fri, Jan 30, 2009 at 3:44 PM, James Coglan <<a href="mailto:jcoglan@googlemail.com">jcoglan@googlemail.com</a>> wrote:<br>
> I just started learning Scheme and am also trying to implement it,<br>
<br>
</div>In what language are you implementing it?</blockquote><div><br>Ruby, code here: <a href="http://github.com/jcoglan/heist">http://github.com/jcoglan/heist</a><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;">
I took the implict contract here to be the fn will always be a<br>
multiple-arity function; so you can leverage apply and it saves you<br>
one rule.</blockquote><div><br>Taking this with Eli's examples:<br><br> (let ([x 4])<br>
(! x (compose square add1))<br>
(list 'x= x))<br>
<br>
vs<br>
<br>
(let ([x 4])<br>
(define foo (compose square add1))<br>
(! x foo)<br>
(list 'x= x))<br><br>I can see how this would be dangerous (like I said, I'm playing with features rather than building rock-solid code right now). Maybe a better idea is:<br><br>(define-syntax ! (syntax-rules ()<br>
[(! x fn arg ...)<br> (set! x (fn x arg ...))]))<br><br>Then you wouldn't get into trouble trying to do this:<br><br>(! x (compose square add1))<br></div></div>