<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: SICP section 3.5.3</title>
	<atom:link href="http://eli.thegreenplace.net/2007/11/10/sicp-section-353/feed/" rel="self" type="application/rss+xml" />
	<link>http://eli.thegreenplace.net/2007/11/10/sicp-section-353/</link>
	<description>Eli Bendersky's personal website</description>
	<pubDate>Fri, 21 Nov 2008 22:50:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: eliben</title>
		<link>http://eli.thegreenplace.net/2007/11/10/sicp-section-353/#comment-123876</link>
		<dc:creator>eliben</dc:creator>
		<pubDate>Sun, 13 Jul 2008 16:06:22 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/11/10/sicp-section-353/#comment-123876</guid>
		<description>Sigrid,
Stream operations are memoized with memo-proc, but simple recursive function calls are not. The new implementation in exercise 3.63 involves a recursive call which isn't being optimized by memo-proc.</description>
		<content:encoded><![CDATA[<p>Sigrid,<br />
Stream operations are memoized with memo-proc, but simple recursive function calls are not. The new implementation in exercise 3.63 involves a recursive call which isn&#8217;t being optimized by memo-proc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sigrid</title>
		<link>http://eli.thegreenplace.net/2007/11/10/sicp-section-353/#comment-123740</link>
		<dc:creator>Sigrid</dc:creator>
		<pubDate>Fri, 11 Jul 2008 06:12:19 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/11/10/sicp-section-353/#comment-123740</guid>
		<description>Hi Eli,

first of all, thanks so much for posting the SICP solutions on the web!  They are extremely valuable for me, reading SICP as a complete autodidact who made her way into (Java) software development completely on her own without attending any informatics curriculum (unfortunately!).

If you like, could you explain the solution for 3.63 a little more? I think a got a basic grep on memoization by drawing the environment diagram in ex. 3.27, but in the context of streams I'm not really sure about what exactly is being memoized and how this works (I did not really manage to draw the environment diagram for this...)

Also, I added a logging message to memo-proc, like this:

(define memo-proc
  (lambda (p)
    (let ((already-run? #f) (result #f))
      (lambda ()
        (if (not already-run?)
            (begin (set! result (p))
                   (set! already-run? #t)
                   result)
            (begin (display-line (list 'already-computed: result))
                   result))))))

... and  I get the same output for both versions:

1.0
1.5
(already-computed: (1.5 . #))
1.4166666666666665
(already-computed: (1.4166666666666665 . #))
1.4142156862745097....

Just in case it matters, that's how I defined delay:

(define-syntax delay 
  (syntax-rules ()
    ((_ expr)
     (memo-proc (lambda () expr)))))

best greetings,
Sigrid</description>
		<content:encoded><![CDATA[<p>Hi Eli,</p>
<p>first of all, thanks so much for posting the SICP solutions on the web!  They are extremely valuable for me, reading SICP as a complete autodidact who made her way into (Java) software development completely on her own without attending any informatics curriculum (unfortunately!).</p>
<p>If you like, could you explain the solution for 3.63 a little more? I think a got a basic grep on memoization by drawing the environment diagram in ex. 3.27, but in the context of streams I&#8217;m not really sure about what exactly is being memoized and how this works (I did not really manage to draw the environment diagram for this&#8230;)</p>
<p>Also, I added a logging message to memo-proc, like this:</p>
<p>(define memo-proc<br />
  (lambda (p)<br />
    (let ((already-run? #f) (result #f))<br />
      (lambda ()<br />
        (if (not already-run?)<br />
            (begin (set! result (p))<br />
                   (set! already-run? #t)<br />
                   result)<br />
            (begin (display-line (list &#8216;already-computed: result))<br />
                   result))))))</p>
<p>&#8230; and  I get the same output for both versions:</p>
<p>1.0<br />
1.5<br />
(already-computed: (1.5 . #))<br />
1.4166666666666665<br />
(already-computed: (1.4166666666666665 . #))<br />
1.4142156862745097&#8230;.</p>
<p>Just in case it matters, that&#8217;s how I defined delay:</p>
<p>(define-syntax delay<br />
  (syntax-rules ()<br />
    ((_ expr)<br />
     (memo-proc (lambda () expr)))))</p>
<p>best greetings,<br />
Sigrid</p>
]]></content:encoded>
	</item>
</channel>
</rss>
