<?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: Linear Interpolation and sorted-map</title>
	<atom:link href="http://clj-me.cgrand.net/2009/06/08/linear-interpolation-and-sorted-map/feed/" rel="self" type="application/rss+xml" />
	<link>http://clj-me.cgrand.net/2009/06/08/linear-interpolation-and-sorted-map/</link>
	<description>When the pupil is ready to learn, a teacher will appear.</description>
	<lastBuildDate>Tue, 07 Sep 2010 05:36:26 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Christophe Grand</title>
		<link>http://clj-me.cgrand.net/2009/06/08/linear-interpolation-and-sorted-map/comment-page-1/#comment-38</link>
		<dc:creator>Christophe Grand</dc:creator>
		<pubDate>Sun, 20 Sep 2009 09:48:56 +0000</pubDate>
		<guid isPermaLink="false">http://clj-me.cgrand.net/2009/06/08/linear-interpolation-and-sorted-map/#comment-38</guid>
		<description>@john, true, here is an amended version:&lt;br /&gt;(defn interpolator &lt;br /&gt; &quot;Takes a coll of 2D points (vectors) and returns &lt;br /&gt;  their linear interpolation function.&quot;&lt;br /&gt; [points]&lt;br /&gt;  (let [m (into (sorted-map) points)]&lt;br /&gt;    (fn [x]&lt;br /&gt;      (let [[[x1 y1]] (rsubseq m &lt;= x)&lt;br /&gt;            [[x2 y2]] (subseq m &gt; x)]&lt;br /&gt;        (cond&lt;br /&gt;          (not x2) y1&lt;br /&gt;          (not x1) y2&lt;br /&gt;          :else (+ y1 (* (- x x1) (/ (- y2 y1) (- x2 x1)))))))))&lt;br /&gt;&lt;br /&gt;;; =&gt; (map (interpolator [[0 0] [1 1] [3 2] [4 3]]) (range -1 11/2 1/2))&lt;br /&gt;;; (0 0 0 1/2 1 5/4 3/2 7/4 2 5/2 3 3 3)</description>
		<content:encoded><![CDATA[<p>@john, true, here is an amended version:<br />(defn interpolator <br /> &quot;Takes a coll of 2D points (vectors) and returns <br />  their linear interpolation function.&quot;<br /> [points]<br />  (let [m (into (sorted-map) points)]<br />    (fn [x]<br />      (let [[[x1 y1]] (rsubseq m &lt;= x)<br />            [[x2 y2]] (subseq m &gt; x)]<br />        (cond<br />          (not x2) y1<br />          (not x1) y2<br />          :else (+ y1 (* (- x x1) (/ (- y2 y1) (- x2 x1)))))))))</p>
<p>;; =&gt; (map (interpolator [[0 0] [1 1] [3 2] [4 3]]) (range -1 11/2 1/2))<br />;; (0 0 0 1/2 1 5/4 3/2 7/4 2 5/2 3 3 3)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://clj-me.cgrand.net/2009/06/08/linear-interpolation-and-sorted-map/comment-page-1/#comment-37</link>
		<dc:creator>John</dc:creator>
		<pubDate>Sat, 19 Sep 2009 12:35:47 +0000</pubDate>
		<guid isPermaLink="false">http://clj-me.cgrand.net/2009/06/08/linear-interpolation-and-sorted-map/#comment-37</guid>
		<description>Nice.&lt;br /&gt;The function does something sensible for inputs that outside the range of points.&lt;br /&gt;(map (interpolator points) (range 0 19/2 1/2))&lt;br /&gt;; (0 1/2 1 5/4 3/2 7/4 2 5/2 3 3 3 3 3 3 3 3 3 3 3)&lt;br /&gt;&lt;br /&gt;But only on one side&lt;br /&gt;(map (interpolator points) (range -1 19/2 1/2)) ; java.lang.NullPointerException</description>
		<content:encoded><![CDATA[<p>Nice.<br />The function does something sensible for inputs that outside the range of points.<br />(map (interpolator points) (range 0 19/2 1/2))<br />; (0 1/2 1 5/4 3/2 7/4 2 5/2 3 3 3 3 3 3 3 3 3 3 3)</p>
<p>But only on one side<br />(map (interpolator points) (range -1 19/2 1/2)) ; java.lang.NullPointerException</p>
]]></content:encoded>
	</item>
</channel>
</rss>
