<?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 2.4</title>
	<atom:link href="http://eli.thegreenplace.net/2007/09/09/sicp-section-24/feed/" rel="self" type="application/rss+xml" />
	<link>http://eli.thegreenplace.net/2007/09/09/sicp-section-24/</link>
	<description>Eli Bendersky's personal website</description>
	<pubDate>Fri, 21 Nov 2008 23:50:31 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: bhrgunatha</title>
		<link>http://eli.thegreenplace.net/2007/09/09/sicp-section-24/#comment-106412</link>
		<dc:creator>bhrgunatha</dc:creator>
		<pubDate>Tue, 05 Feb 2008 06:05:37 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/09/sicp-section-24/#comment-106412</guid>
		<description>Sorry it seems I'm confused about the way the operators and types are being used.
Exercise 2.73  part d is the way I expected thi8ngs to work i.e. that deriv is the type and '+, '* or '** are the operators.</description>
		<content:encoded><![CDATA[<p>Sorry it seems I&#8217;m confused about the way the operators and types are being used.<br />
Exercise 2.73  part d is the way I expected thi8ngs to work i.e. that deriv is the type and &#8216;+, &#8216;* or &#8216;** are the operators.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bhrgunatha</title>
		<link>http://eli.thegreenplace.net/2007/09/09/sicp-section-24/#comment-106406</link>
		<dc:creator>bhrgunatha</dc:creator>
		<pubDate>Tue, 05 Feb 2008 05:44:12 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/09/sicp-section-24/#comment-106406</guid>
		<description>Ex 2.73 - I think there's a minor flaw in your packaging of deriv:
put is given as: 
&lt;code&gt;
(put &lt;op&gt; &lt;type&gt; &lt;item&gt;)
&lt;/code&gt;

and you've used: 
&lt;code&gt;
(put 'deriv '+ deriv-sum)
&lt;/code&gt;

But '+ is the operator and 'deriv is the type.
In your implementation there is clearly no problem as you make the hash table's key a tuple of both &lt;i&gt;and&lt;/i&gt; there is only 1 implementation type - 'deriv..
The definitions of put and get are not clear that actually the type parameter of both are &lt;i&gt;lists&lt;/i&gt; of types.
Only the code in the book makes this explicit though e.g.
&lt;code&gt;
  (put 'real-part '(rectangular) real-part)
  (put 'imag-part '(rectangular) imag-part)
&lt;/code&gt;

especially within the implementation of apply-generic 
&lt;code&gt;
(define (apply-generic op . args)
  (let ((type-tags (map type-tag args)))
    (let ((proc (get op type-tags)))
      (if proc
          (apply proc (map contents args))
          ...
          ...
&lt;/code&gt;

It's a little confusing but it seems get scans the list of types for the first match and only returns false if no match is found against the list.</description>
		<content:encoded><![CDATA[<p>Ex 2.73 - I think there&#8217;s a minor flaw in your packaging of deriv:<br />
put is given as:<br />
<code><br />
(put <op> <type> <item>)<br />
</item></type></op></code></p>
<p>and you&#8217;ve used:<br />
<code><br />
(put 'deriv '+ deriv-sum)<br />
</code></p>
<p>But &#8216;+ is the operator and &#8216;deriv is the type.<br />
In your implementation there is clearly no problem as you make the hash table&#8217;s key a tuple of both <i>and</i> there is only 1 implementation type - &#8216;deriv..<br />
The definitions of put and get are not clear that actually the type parameter of both are <i>lists</i> of types.<br />
Only the code in the book makes this explicit though e.g.<br />
<code><br />
  (put 'real-part '(rectangular) real-part)<br />
  (put 'imag-part '(rectangular) imag-part)<br />
</code></p>
<p>especially within the implementation of apply-generic<br />
<code><br />
(define (apply-generic op . args)<br />
  (let ((type-tags (map type-tag args)))<br />
    (let ((proc (get op type-tags)))<br />
      (if proc<br />
          (apply proc (map contents args))<br />
          ...<br />
          ...<br />
</code></p>
<p>It&#8217;s a little confusing but it seems get scans the list of types for the first match and only returns false if no match is found against the list.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
