<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<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>
	<lastBuildDate>Wed, 28 Jul 2010 12:22:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: José Hérnandez</title>
		<link>http://eli.thegreenplace.net/2007/11/10/sicp-section-353/comment-page-1/#comment-173287</link>
		<dc:creator>José Hérnandez</dc:creator>
		<pubDate>Fri, 29 May 2009 16:24:02 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/11/10/sicp-section-353/#comment-173287</guid>
		<description>In exercise 3.76, it might be more correct to write the smooth function as follows:

(define (smooth-stream stream)
  (define (avg a b) (/ (+ a b) 2.0))
  (stream-map2 avg stream (stream-cdr stream)))

This approach doesn&#039;t require introducing a zero at the beginning of the stream, since technically smoothing shouldn&#039;t do so. It&#039;s only in zero-crossings that prepending a zero is needed.</description>
		<content:encoded><![CDATA[<p>In exercise 3.76, it might be more correct to write the smooth function as follows:</p>
<p>(define (smooth-stream stream)<br />
  (define (avg a b) (/ (+ a b) 2.0))<br />
  (stream-map2 avg stream (stream-cdr stream)))</p>
<p>This approach doesn&#8217;t require introducing a zero at the beginning of the stream, since technically smoothing shouldn&#8217;t do so. It&#8217;s only in zero-crossings that prepending a zero is needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ray Bai</title>
		<link>http://eli.thegreenplace.net/2007/11/10/sicp-section-353/comment-page-1/#comment-162052</link>
		<dc:creator>Ray Bai</dc:creator>
		<pubDate>Wed, 18 Mar 2009 14:17:40 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/11/10/sicp-section-353/#comment-162052</guid>
		<description>Sorry I made a mistake. It shouldn&#039;t work.</description>
		<content:encoded><![CDATA[<p>Sorry I made a mistake. It shouldn&#8217;t work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ray Bai</title>
		<link>http://eli.thegreenplace.net/2007/11/10/sicp-section-353/comment-page-1/#comment-162044</link>
		<dc:creator>Ray Bai</dc:creator>
		<pubDate>Wed, 18 Mar 2009 13:41:49 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/11/10/sicp-section-353/#comment-162044</guid>
		<description>The code in exercise 3.68 actually works.

Although interleave isn&#039;t called withn cons-stream, it contains cons-stream itself.</description>
		<content:encoded><![CDATA[<p>The code in exercise 3.68 actually works.</p>
<p>Although interleave isn&#8217;t called withn cons-stream, it contains cons-stream itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eliben</title>
		<link>http://eli.thegreenplace.net/2007/11/10/sicp-section-353/comment-page-1/#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&#039;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-page-1/#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&#039;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 &#039;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&#039;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>
