<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Sumimus's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 22:43:02 GMT</pubDate>
    <description>DZone Snippets: Sumimus's Code Snippets</description>
    <item>
      <title>mapi: similar to standard map in Scheme, but function has index of elements as second parameter.</title>
      <link>http://snippets.dzone.com/posts/show/5368</link>
      <description>&lt;br /&gt;&lt;code&gt;&lt;br /&gt;;;;  mapi: similar to standard map in Scheme, but function has index of elements as parameter.&lt;br /&gt;;;;&lt;br /&gt;(define (mapi p l)&lt;br /&gt;  (let loop ((l l) (i 0) (r '()))&lt;br /&gt;    (if (pair? l)&lt;br /&gt;	(loop (cdr l) (+ i 1) (cons (p (car l) i) r))&lt;br /&gt;	(reverse r))))&lt;br /&gt;&lt;br /&gt;;; Example: converting a binary number given as a list of binary digits. &lt;br /&gt;;; (apply + (mapi (lambda (x i) (* x (expt 2 i))) '(0 1 1)))&lt;br /&gt;;; =&gt; 6&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 16 Apr 2008 22:03:41 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5368</guid>
      <author>sumimus (Sumimus L)</author>
    </item>
  </channel>
</rss>
