<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>xacc.ide</title>
	<atom:link href="http://xacc.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xacc.wordpress.com</link>
	<description>A small, super fast, opensource and 100% C# IDE targetting .NET-based languages</description>
	<pubDate>Mon, 19 May 2008 09:48:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language>en</language>
			<item>
		<title>LINQ for R6RS Scheme - final</title>
		<link>http://xacc.wordpress.com/2008/05/19/linq-for-r6rs-scheme-final/</link>
		<comments>http://xacc.wordpress.com/2008/05/19/linq-for-r6rs-scheme-final/#comments</comments>
		<pubDate>Mon, 19 May 2008 09:48:01 +0000</pubDate>
		<dc:creator>leppie</dc:creator>
		
		<category><![CDATA[Default]]></category>

		<category><![CDATA[IronScheme]]></category>

		<guid isPermaLink="false">http://xacc.wordpress.com/?p=115</guid>
		<description><![CDATA[I kinda forgot that I completed the entire library.
It now supports syntactically and semantically LINQ as defined for C#. See the top of the file for getting it working on your preferred R6RS Scheme. See bottom for examples/test.
The source can be viewed here.
       ]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I kinda forgot that I completed the entire library.</p>
<p>It now supports syntactically and semantically LINQ as defined for C#. See the top of the file for getting it working on your preferred R6RS Scheme. See bottom for examples/test.</p>
<p>The source can be viewed <a href="https://code.launchpad.net/~leppie/ikarus-libraries/ironscheme">here</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xacc.wordpress.com/115/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xacc.wordpress.com/115/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xacc.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xacc.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xacc.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xacc.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xacc.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xacc.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xacc.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xacc.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xacc.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xacc.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xacc.wordpress.com&blog=1242361&post=115&subd=xacc&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xacc.wordpress.com/2008/05/19/linq-for-r6rs-scheme-final/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/xacc-128.jpg" medium="image">
			<media:title type="html">leppie</media:title>
		</media:content>
	</item>
		<item>
		<title>Catastrophic hard disk failure</title>
		<link>http://xacc.wordpress.com/2008/05/19/catastrophic-hard-disk-failure/</link>
		<comments>http://xacc.wordpress.com/2008/05/19/catastrophic-hard-disk-failure/#comments</comments>
		<pubDate>Mon, 19 May 2008 09:42:36 +0000</pubDate>
		<dc:creator>leppie</dc:creator>
		
		<category><![CDATA[Default]]></category>

		<category><![CDATA[IronScheme]]></category>

		<category><![CDATA[xacc.ide]]></category>

		<guid isPermaLink="false">http://xacc.wordpress.com/?p=114</guid>
		<description><![CDATA[Exactly a week ago, my 150GB WD Raptor died, it seems like something mechanical or just physical, as Vista reports bad blocks on the drive when inserted via USB (I cant even boot with the drive plugged in). This was my system drive, so I needed to reinstall Vista, VS and all the SP&#8217;s (sigh).
Anyways, [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Exactly a week ago, my 150GB WD Raptor died, it seems like something mechanical or just physical, as Vista reports bad blocks on the drive when inserted via USB (I cant even boot with the drive plugged in). This was my system drive, so I needed to reinstall Vista, VS and all the SP&#8217;s (sigh).</p>
<p>Anyways, lucky I did a checkin to IronScheme the night before, and I managed to recover all the data I needed from the drive via a Linux Recovery DC (trinity recovery kit).</p>
<p>So development will continue as normal, just taking a bit of time to get back into it.</p>
<p>Cheers <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xacc.wordpress.com/114/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xacc.wordpress.com/114/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xacc.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xacc.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xacc.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xacc.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xacc.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xacc.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xacc.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xacc.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xacc.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xacc.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xacc.wordpress.com&blog=1242361&post=114&subd=xacc&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xacc.wordpress.com/2008/05/19/catastrophic-hard-disk-failure/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/xacc-128.jpg" medium="image">
			<media:title type="html">leppie</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ for R6RS Scheme take 9</title>
		<link>http://xacc.wordpress.com/2008/04/20/linq-for-r6rs-scheme-take-9/</link>
		<comments>http://xacc.wordpress.com/2008/04/20/linq-for-r6rs-scheme-take-9/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 00:00:33 +0000</pubDate>
		<dc:creator>leppie</dc:creator>
		
		<category><![CDATA[Default]]></category>

		<category><![CDATA[IronScheme]]></category>

		<guid isPermaLink="false">http://xacc.wordpress.com/?p=113</guid>
		<description><![CDATA[Now completely rewritten. Supports all the non-grouping constructs for now. From what I can see, this is quite similar to the LISP FOR construct.
Tested on IronScheme, Ikarus and Petite Chez.
(import (rnrs))

(define (compare asc? a b)
  (cond
    [(and (number? a) (number? b))
      ((if asc? &#60; &#62;) a [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Now completely rewritten. Supports all the non-grouping constructs for now. From what I can see, this is quite similar to the LISP FOR construct.</p>
<p>Tested on IronScheme, Ikarus and Petite Chez.</p>
<pre><FONT color="DarkBlue">(</FONT><FONT color="Blue">import</FONT> <FONT color="DarkBlue">(</FONT>rnrs<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>compare asc? a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">cond</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">&lt;</FONT> <FONT color="Teal">&gt;</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">char&lt;?</FONT> <FONT color="Teal">char&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>a <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> a<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>b <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
           <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DeepPink">else</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Teal">assertion-violation</FONT> <FONT color="DarkBlue">'</FONT>compare <FONT color="Maroon">"not supported"</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>sort asc? l a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">list-sort</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>a* b*<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT>compare asc? <FONT color="DarkBlue">(</FONT>a a*<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>b b*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>flatten lst<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT> <FONT color="Teal">append</FONT> lst<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define-syntax</FONT> bind
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-rules</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>bind var body<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>var<FONT color="DarkBlue">)</FONT> body<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>bind vars <FONT color="DeepPink">...</FONT> body<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>K<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>vars <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT> body<FONT color="DarkBlue">)</FONT>
          K<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define-syntax</FONT> from
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>x<FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> valid-id?
      <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e vars<FONT color="DarkBlue">)</FONT>
         <FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> e<FONT color="DarkBlue">)</FONT>
           <FONT color="DarkBlue">(</FONT><FONT color="Teal">not</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">memp</FONT>
                  <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>x<FONT color="DarkBlue">)</FONT>
                    <FONT color="DarkBlue">(</FONT><FONT color="Teal">bound-identifier=?</FONT> e x<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                  vars<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> id=?
      <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e o<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Teal">eq?</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> e<FONT color="DarkBlue">)</FONT> o<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> x <FONT color="DarkBlue">(</FONT>in<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="DeepPink">_</FONT> e in l rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> recur <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>vars <FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                    <FONT color="DarkBlue">(</FONT>l <FONT color="DarkBlue">#'</FONT>l<FONT color="DarkBlue">)</FONT>
                    <FONT color="DarkBlue">(</FONT>x* <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> x* <FONT color="DarkBlue">(</FONT>where <FONT color="Blue">let</FONT> <FONT color="Teal">=</FONT> in select from orderby join equals on<FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-violation</FONT> <FONT color="DarkBlue">'</FONT>from <FONT color="Maroon">"missing select"</FONT> x<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
            <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>select s<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT> <FONT color="DarkBlue">(</FONT>bind <FONT color="DarkBlue">#,@</FONT>vars s<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">#,</FONT>l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
            <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>where p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>recur vars
                <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">filter</FONT> <FONT color="DarkBlue">(</FONT>bind <FONT color="DarkBlue">#,@</FONT>vars p<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">#,</FONT>l<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
            <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e* in l* rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> <FONT color="DarkBlue">(</FONT>valid-id? <FONT color="DarkBlue">#'</FONT>e* vars<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT>recur <FONT color="DarkBlue">(</FONT><FONT color="Teal">cons</FONT> <FONT color="DarkBlue">#'</FONT>e* vars<FONT color="DarkBlue">)</FONT>
                  <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>flatten
                      <FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT>
                        <FONT color="DarkBlue">(</FONT>bind <FONT color="DarkBlue">#,@</FONT>vars
                          <FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT>
                            <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>K*<FONT color="DarkBlue">)</FONT>
                              <FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> K* <FONT color="DarkBlue">#,@</FONT>vars<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                            l*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">#,</FONT>l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                   <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-violation</FONT> <FONT color="DarkBlue">'</FONT>from <FONT color="Maroon">"not a unique identifier"</FONT> <FONT color="DarkBlue">#'</FONT>e* x*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
            <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> a <FONT color="Teal">=</FONT> b rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> <FONT color="DarkBlue">(</FONT>valid-id? <FONT color="DarkBlue">#'</FONT>a vars<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT>recur <FONT color="DarkBlue">(</FONT><FONT color="Teal">cons</FONT> <FONT color="DarkBlue">#'</FONT>a vars<FONT color="DarkBlue">)</FONT>
                  <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT> <FONT color="DarkBlue">(</FONT>bind <FONT color="DarkBlue">#,@</FONT>vars <FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> b <FONT color="DarkBlue">#,@</FONT>vars<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">#,</FONT>l<FONT color="DarkBlue">)</FONT>
                  <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-violation</FONT> <FONT color="DarkBlue">'</FONT>from <FONT color="Maroon">"not a unique identifier"</FONT> <FONT color="DarkBlue">#'</FONT>a x*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
            <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p dir rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT><FONT color="Blue">or</FONT> <FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>asc<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>desc<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>recur vars
                <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">let*</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>p*
                    <FONT color="DarkBlue">(</FONT>bind <FONT color="DarkBlue">#,@</FONT>vars p<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                    <FONT color="DarkBlue">(</FONT>sort <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>asc<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">#,</FONT>l p* p*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
            <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>recur vars l <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>orderby p asc rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
            <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>join e* in l* on a equals b rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>recur vars l
                <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e* in l* where <FONT color="DarkBlue">(</FONT><FONT color="Teal">eqv?</FONT> a b<FONT color="DarkBlue">)</FONT> rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
            <FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT></pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xacc.wordpress.com/113/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xacc.wordpress.com/113/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xacc.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xacc.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xacc.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xacc.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xacc.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xacc.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xacc.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xacc.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xacc.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xacc.wordpress.com/113/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xacc.wordpress.com&blog=1242361&post=113&subd=xacc&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xacc.wordpress.com/2008/04/20/linq-for-r6rs-scheme-take-9/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/xacc-128.jpg" medium="image">
			<media:title type="html">leppie</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ for R6RS Scheme take 8</title>
		<link>http://xacc.wordpress.com/2008/04/17/linq-for-r6rs-scheme-take-8/</link>
		<comments>http://xacc.wordpress.com/2008/04/17/linq-for-r6rs-scheme-take-8/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 17:28:08 +0000</pubDate>
		<dc:creator>leppie</dc:creator>
		
		<category><![CDATA[Default]]></category>

		<category><![CDATA[IronScheme]]></category>

		<guid isPermaLink="false">http://xacc.wordpress.com/?p=112</guid>
		<description><![CDATA[Fixed the nested &#8216;from x in y&#8217; problem  
Thanks to Jos, Aziz and Andre for tips on comp.lang.scheme.
(import (rnrs))

(define (compare asc? a b)
  (cond
    [(and (number? a) (number? b))
      ((if asc? &#60; &#62;) a b)]
    [(and (char? a) (char? b))
   [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Fixed the nested &#8216;from x in y&#8217; problem <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thanks to Jos, Aziz and Andre for tips on comp.lang.scheme.</p>
<pre><FONT color="DarkBlue">(</FONT><FONT color="Blue">import</FONT> <FONT color="DarkBlue">(</FONT>rnrs<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>compare asc? a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">cond</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">&lt;</FONT> <FONT color="Teal">&gt;</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">char&lt;?</FONT> <FONT color="Teal">char&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>a <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> a<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>b <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
           <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DeepPink">else</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Teal">assertion-violation</FONT> <FONT color="DarkBlue">'</FONT>compare <FONT color="Maroon">"not supported"</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>sort asc? l a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">list-sort</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>a* b*<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT>compare asc? <FONT color="DarkBlue">(</FONT>a a*<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>b b*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>flatten lists<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT> <FONT color="Teal">append</FONT> lists<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define-syntax</FONT> from
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>x<FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">letrec</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>vars <FONT color="DarkBlue">&#8216;</FONT><FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
       <FONT color="DarkBlue">(</FONT>id=?
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e o<FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Teal">eq?</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> e<FONT color="DarkBlue">)</FONT> o<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
       <FONT color="DarkBlue">(</FONT>arg
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">=</FONT> <FONT color="Red">1</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">length</FONT> vars<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT><FONT color="Teal">datum-&gt;syntax</FONT> e <FONT color="DarkBlue">`</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> <FONT color="DarkBlue">,</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
       <FONT color="DarkBlue">(</FONT>init
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Blue">when</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">null?</FONT> vars<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT><FONT color="Blue">set!</FONT> vars <FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
       <FONT color="DarkBlue">(</FONT>valid-id?
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> e<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT><FONT color="Teal">not</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">memp</FONT>
                     <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>x<FONT color="DarkBlue">)</FONT>
                       <FONT color="DarkBlue">(</FONT><FONT color="Teal">bound-identifier=?</FONT> e x<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                     vars<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
       <FONT color="DarkBlue">(</FONT>from*
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>x<FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> x <FONT color="DarkBlue">(</FONT>in select<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>e in l select s<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Blue">begin</FONT>
                  <FONT color="DarkBlue">(</FONT>init <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">; bind</FONT>
                   <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT>
                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>K<FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">#,@</FONT>vars<FONT color="DarkBlue">)</FONT> s<FONT color="DarkBlue">)</FONT>
                          <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>K<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                      l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
              <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>e in l c <FONT color="DeepPink">...</FONT> select s<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Blue">begin</FONT>
                  <FONT color="DarkBlue">(</FONT>init <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">; bind</FONT>
                  <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>c <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>where <FONT color="Blue">let</FONT> <FONT color="Teal">=</FONT> in orderby<FONT color="DarkBlue">)</FONT>
                    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>where p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>e in
                          <FONT color="DarkBlue">(</FONT><FONT color="Teal">filter</FONT>
                            <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>K<FONT color="DarkBlue">)</FONT>
                              <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                                <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">#,@</FONT>vars<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT>
                                <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>K<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                            l<FONT color="DarkBlue">)</FONT>
                         rest <FONT color="DeepPink">...</FONT>
                         select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
                    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> y <FONT color="Teal">=</FONT> y* rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT>valid-id? <FONT color="DarkBlue">#'</FONT>y<FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>v* vars<FONT color="DarkBlue">)</FONT>
                            <FONT color="DarkBlue">(</FONT>a* <FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>K<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">(</FONT><FONT color="Blue">set!</FONT> vars <FONT color="DarkBlue">(</FONT><FONT color="Teal">cons</FONT> <FONT color="DarkBlue">#'</FONT>y vars<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>e in
                            <FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT>
                              <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>K<FONT color="DarkBlue">)</FONT>
                                <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                                  <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">#,@</FONT>v*<FONT color="DarkBlue">)</FONT>
                                    <FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> y* <FONT color="DarkBlue">#,@</FONT>v*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                                  <FONT color="DarkBlue">#,</FONT>a*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                              l<FONT color="DarkBlue">)</FONT>
                           rest <FONT color="DeepPink">...</FONT>
                           select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
                    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e* in l* rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT>valid-id? <FONT color="DarkBlue">#'</FONT>e*<FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>v* vars<FONT color="DarkBlue">)</FONT>
                            <FONT color="DarkBlue">(</FONT>a* <FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>K<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">(</FONT><FONT color="Blue">set!</FONT> vars <FONT color="DarkBlue">(</FONT><FONT color="Teal">cons</FONT> <FONT color="DarkBlue">#'</FONT>e* vars<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>e in
                              <FONT color="DarkBlue">(</FONT>flatten
                                <FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT>
                                  <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>K<FONT color="DarkBlue">)</FONT>
                                    <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">#,@</FONT>v*<FONT color="DarkBlue">)</FONT>
                                        <FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT>
                                          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>K*<FONT color="DarkBlue">)</FONT>
                                            <FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> K* <FONT color="DarkBlue">#,@</FONT>v*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                                        l*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                                      <FONT color="DarkBlue">#,</FONT>a*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                                  l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                           rest <FONT color="DeepPink">...</FONT>
                           select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
                    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p dir rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">or</FONT> <FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>asc<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>desc<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>e in
                          <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>p*
                            <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>K<FONT color="DarkBlue">)</FONT>
                              <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                                <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">#,@</FONT>vars<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT>
                                <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>K<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                            <FONT color="DarkBlue">(</FONT>sort <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>asc<FONT color="DarkBlue">)</FONT> l p* p*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                         rest <FONT color="DeepPink">...</FONT>
                         select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
                    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>e in l
                         orderby p asc
                         rest <FONT color="DeepPink">...</FONT>
                         select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
                <FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
         <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> x <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from <FONT color="DarkBlue">.</FONT> rest<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#'</FONT>rest<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT></pre>
<p>Example:</p>
<pre><FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> args <FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string-&gt;list</FONT> <FONT color="Maroon">&#8220;hello&#8221;</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string-&gt;list</FONT> <FONT color="Maroon">&#8220;world&#8221;</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Teal">display</FONT>
  <FONT color="DarkBlue">[</FONT>
    from K in args
    from K* in K
    where <FONT color="DarkBlue">(</FONT><FONT color="Teal">not</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char=?</FONT> <FONT color="Red">#\l</FONT> K*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    orderby K*
    select K*
  <FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT>
<FONT color="DarkBlue">(</FONT><FONT color="Teal">newline</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">;=&gt; (d e h o o r w)</FONT></pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xacc.wordpress.com/112/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xacc.wordpress.com/112/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xacc.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xacc.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xacc.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xacc.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xacc.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xacc.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xacc.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xacc.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xacc.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xacc.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xacc.wordpress.com&blog=1242361&post=112&subd=xacc&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xacc.wordpress.com/2008/04/17/linq-for-r6rs-scheme-take-8/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/xacc-128.jpg" medium="image">
			<media:title type="html">leppie</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ for R6RS Scheme take 7</title>
		<link>http://xacc.wordpress.com/2008/04/16/linq-for-r6rs-scheme-take-7/</link>
		<comments>http://xacc.wordpress.com/2008/04/16/linq-for-r6rs-scheme-take-7/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 11:56:07 +0000</pubDate>
		<dc:creator>leppie</dc:creator>
		
		<category><![CDATA[Default]]></category>

		<category><![CDATA[IronScheme]]></category>

		<guid isPermaLink="false">http://xacc.wordpress.com/?p=111</guid>
		<description><![CDATA[Thanks to Jos Koot from comp.lang.scheme, I have managed to make the macro multithread friendly, it does however &#8216;uglify&#8217; the macro quite a bit.
Also optimized the sort proc generation and fixed a small bug that prevented it from running on other R6RS Schemes  
UPDATE: removed unnecessary syntax to/from datum conversion (thanks Aziz).
UPDATE 2: There [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Thanks to Jos Koot from comp.lang.scheme, I have managed to make the macro multithread friendly, it does however &#8216;uglify&#8217; the macro quite a bit.</p>
<p>Also optimized the sort proc generation and fixed a small bug that prevented it from running on other R6RS Schemes <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>UPDATE: removed unnecessary syntax to/from datum conversion (thanks Aziz).</p>
<p>UPDATE 2: There is a problem with the nested &#8216;from x in y&#8217;.</p>
<pre><FONT color="DarkBlue">(</FONT><FONT color="Blue">import</FONT> <FONT color="DarkBlue">(</FONT>rnrs<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>compare asc? a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">cond</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">&lt;</FONT> <FONT color="Teal">&gt;</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">char&lt;?</FONT> <FONT color="Teal">char&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>a <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> a<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>b <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
           <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DeepPink">else</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Teal">assertion-violation</FONT> <FONT color="DarkBlue">'</FONT>compare <FONT color="Maroon">"not supported"</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>sort asc? l a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">list-sort</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>a* b*<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT>compare asc? <FONT color="DarkBlue">(</FONT>a a*<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>b b*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>flatten lists<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT> <FONT color="Teal">append</FONT> lists<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define-syntax</FONT> from
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>x<FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">letrec</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>v <FONT color="DarkBlue">&#8216;</FONT><FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
       <FONT color="DarkBlue">(</FONT>id=?
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e o<FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Teal">eq?</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> e<FONT color="DarkBlue">)</FONT> o<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
       <FONT color="DarkBlue">(</FONT>arg
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">=</FONT> <FONT color="Red">1</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">length</FONT> v<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT><FONT color="Teal">datum-&gt;syntax</FONT> e <FONT color="DarkBlue">`</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> <FONT color="DarkBlue">,</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
       <FONT color="DarkBlue">(</FONT>init
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Blue">when</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">=</FONT> <FONT color="Red">0</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">length</FONT> v<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT><FONT color="Blue">set!</FONT> v <FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
       <FONT color="DarkBlue">(</FONT>from*
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>x<FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> x <FONT color="DarkBlue">(</FONT>in select<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>e in l select s<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Blue">begin</FONT>
                  <FONT color="DarkBlue">(</FONT>init <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">; bind</FONT>
                   <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT>
                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">#,@</FONT>v<FONT color="DarkBlue">)</FONT> s<FONT color="DarkBlue">)</FONT>
                          <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                      l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
              <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>e in l c <FONT color="DeepPink">...</FONT> select s<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Blue">begin</FONT>
                  <FONT color="DarkBlue">(</FONT>init <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">; bind</FONT>
                  <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>c <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>where <FONT color="Blue">let</FONT> <FONT color="Teal">=</FONT> in orderby<FONT color="DarkBlue">)</FONT>
                    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>where p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>e in
                          <FONT color="DarkBlue">(</FONT><FONT color="Teal">filter</FONT>
                            <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
                              <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                                <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">#,@</FONT>v<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT>
                                <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                            l<FONT color="DarkBlue">)</FONT>
                         rest <FONT color="DeepPink">...</FONT>
                         select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
                    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> y <FONT color="Teal">=</FONT> y* rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>y<FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>v* v<FONT color="DarkBlue">)</FONT>
                            <FONT color="DarkBlue">(</FONT>a* <FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">(</FONT><FONT color="Blue">set!</FONT> v <FONT color="DarkBlue">(</FONT><FONT color="Teal">cons</FONT> <FONT color="DarkBlue">#'</FONT>y v<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>e in
                            <FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT>
                              <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
                                <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                                  <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">#,@</FONT>v*<FONT color="DarkBlue">)</FONT>
                                    <FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> y* <FONT color="DarkBlue">#,@</FONT>v*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                                  <FONT color="DarkBlue">#,</FONT>a*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                              l<FONT color="DarkBlue">)</FONT>
                           rest <FONT color="DeepPink">...</FONT>
                           select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
                    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e* in l* rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>flatten
                          <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>e in l
                             select
                              <FONT color="DarkBlue">(</FONT>from e* in l*
                               rest <FONT color="DeepPink">...</FONT>
                               select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
                    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p dir rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">or</FONT> <FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>asc<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>desc<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>e in
                          <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>p*
                            <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
                              <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                                <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">#,@</FONT>v<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT>
                                <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                            <FONT color="DarkBlue">(</FONT>sort <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>asc<FONT color="DarkBlue">)</FONT> l p* p*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                         rest <FONT color="DeepPink">...</FONT>
                         select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
                    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>e in l
                         orderby p asc
                         rest <FONT color="DeepPink">...</FONT>
                         select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
                <FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
         <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> x <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from <FONT color="DarkBlue">.</FONT> rest<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>from* <FONT color="DarkBlue">#'</FONT>rest<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT></pre>
<pre><FONT color="DarkGreen">; sample usage</FONT>
<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> al <FONT color="DarkBlue">&#8216;</FONT><FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>a <FONT color="Red">4</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>d <FONT color="Red">3</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>a <FONT color="Red">2</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>c <FONT color="Red">9</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>a <FONT color="Red">11</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Teal">write</FONT>
  <FONT color="DarkBlue">[</FONT>
  from y in al
  <FONT color="Blue">let</FONT> a <FONT color="Teal">=</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">car</FONT> y<FONT color="DarkBlue">)</FONT>  <FONT color="DarkGreen">; the symbol</FONT>
  <FONT color="Blue">let</FONT> b <FONT color="Teal">=</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">cadr</FONT> y<FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">; the number</FONT>
  <FONT color="Blue">let</FONT> c <FONT color="Teal">=</FONT> y        <FONT color="DarkGreen">; alias</FONT>
  orderby b
  where <FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">eq?</FONT> a <FONT color="DarkBlue">'</FONT>a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">even?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
  from x in c
  <FONT color="Blue">let</FONT> d <FONT color="Teal">=</FONT> x
  select d
  <FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT>
<FONT color="DarkBlue">(</FONT><FONT color="Teal">newline</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">;=&gt; (a 2 a 4)</FONT></pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xacc.wordpress.com/111/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xacc.wordpress.com/111/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xacc.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xacc.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xacc.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xacc.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xacc.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xacc.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xacc.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xacc.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xacc.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xacc.wordpress.com/111/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xacc.wordpress.com&blog=1242361&post=111&subd=xacc&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xacc.wordpress.com/2008/04/16/linq-for-r6rs-scheme-take-7/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/xacc-128.jpg" medium="image">
			<media:title type="html">leppie</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ for R6RS Scheme take 6</title>
		<link>http://xacc.wordpress.com/2008/04/15/linq-for-r6rs-scheme-take-6/</link>
		<comments>http://xacc.wordpress.com/2008/04/15/linq-for-r6rs-scheme-take-6/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 11:39:49 +0000</pubDate>
		<dc:creator>leppie</dc:creator>
		
		<category><![CDATA[Default]]></category>

		<category><![CDATA[IronScheme]]></category>

		<guid isPermaLink="false">http://xacc.wordpress.com/?p=110</guid>
		<description><![CDATA[Added the &#8216;let x = y&#8217; construct  
This required some substantial reworking, but it works much easier now.
Next I will look at joins and groupby&#8217;s as well as constructing &#8216;delayed&#8217; queries as in C#.
(import (rnrs))

(define (compare asc? a b)
  (cond
    [(and (number? a) (number? b))
      [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Added the &#8216;let x = y&#8217; construct <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This required some substantial reworking, but it works much easier now.</p>
<p>Next I will look at joins and groupby&#8217;s as well as constructing &#8216;delayed&#8217; queries as in C#.</p>
<pre><FONT color="DarkBlue">(</FONT><FONT color="Blue">import</FONT> <FONT color="DarkBlue">(</FONT>rnrs<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>compare asc? a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">cond</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">&lt;</FONT> <FONT color="Teal">&gt;</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">char&lt;?</FONT> <FONT color="Teal">char&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>a <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> a<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>b <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
           <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DeepPink">else</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Teal">assertion-violation</FONT> <FONT color="DarkBlue">'</FONT>compare <FONT color="Maroon">"not supported"</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>sort asc? l a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">list-sort</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>a* b*<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT>compare asc? <FONT color="DarkBlue">(</FONT>a a*<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>b b*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>flatten lists<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT> <FONT color="Teal">append</FONT> lists<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define-syntax</FONT> from
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>v <FONT color="DarkBlue">&#8216;</FONT><FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>x<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>id=? e o<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Teal">eq?</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> e<FONT color="DarkBlue">)</FONT> o<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>vars e<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Teal">datum-&gt;syntax</FONT> e v<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>arg e<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">=</FONT> <FONT color="Red">1</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">length</FONT> v<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
          <FONT color="DarkBlue">(</FONT><FONT color="Teal">datum-&gt;syntax</FONT> e <FONT color="DarkBlue">`</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> <FONT color="DarkBlue">,</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
          e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>init e<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">when</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">=</FONT> <FONT color="Red">0</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">length</FONT> v<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">set!</FONT> v <FONT color="DarkBlue">(</FONT><FONT color="Teal">cons</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> x <FONT color="DarkBlue">(</FONT>in select<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e in l select s<FONT color="DarkBlue">)</FONT>
          <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT>
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">begin</FONT>
            <FONT color="DarkBlue">(</FONT>init <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">; bind</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>r
               <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT>
                  <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
                    <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>vars <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT> s<FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                  l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Blue">set!</FONT> v <FONT color="DarkBlue">'</FONT><FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">; reset v <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </FONT>
                r<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
        <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e in l c <FONT color="DeepPink">...</FONT> select s<FONT color="DarkBlue">)</FONT>
          <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT>
          <FONT color="DarkBlue">(</FONT><FONT color="Blue">begin</FONT>
            <FONT color="DarkBlue">(</FONT>init <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">; bind</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>c <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>where <FONT color="Blue">let</FONT> <FONT color="Teal">=</FONT> in orderby<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>where p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>from e in
                    <FONT color="DarkBlue">(</FONT><FONT color="Teal">filter</FONT>
                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>vars <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT>
                          <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                      l<FONT color="DarkBlue">)</FONT>
                   rest <FONT color="DeepPink">...</FONT>
                   select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
              <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> y <FONT color="Teal">=</FONT> y* rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>y<FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>v* <FONT color="DarkBlue">(</FONT>vars <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT>a* <FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                  <FONT color="DarkBlue">(</FONT><FONT color="Blue">set!</FONT> v <FONT color="DarkBlue">(</FONT><FONT color="Teal">cons</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> <FONT color="DarkBlue">#'</FONT>y<FONT color="DarkBlue">)</FONT> v<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                  <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>from e in
                      <FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT>
                        <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
                          <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                            <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">#,</FONT>v*
                              <FONT color="DarkBlue">(</FONT><FONT color="Teal">list</FONT> y* <FONT color="DarkBlue">#,@</FONT>v*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                            <FONT color="DarkBlue">#,</FONT>a*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                        l<FONT color="DarkBlue">)</FONT>
                     rest <FONT color="DeepPink">...</FONT>
                     select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
              <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e* in l* rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>flatten
                    <FONT color="DarkBlue">(</FONT>from e in l
                     select
                      <FONT color="DarkBlue">(</FONT>from e* in l*
                       rest <FONT color="DeepPink">...</FONT>
                       select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
              <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p dir rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">(</FONT><FONT color="Blue">or</FONT> <FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>asc<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>desc<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">#`</FONT><FONT color="DarkBlue">(</FONT>from e in
                    <FONT color="DarkBlue">(</FONT>sort <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>id=? <FONT color="DarkBlue">#'</FONT>dir <FONT color="DarkBlue">'</FONT>asc<FONT color="DarkBlue">)</FONT> l
                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>vars <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT>
                          <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                      <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT>
                        <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT>
                          <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>vars <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT>
                          <FONT color="DarkBlue">#,</FONT><FONT color="DarkBlue">(</FONT>arg <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
                   rest <FONT color="DeepPink">...</FONT>
                   select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
              <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
                <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e in l
                   orderby p asc
                   rest <FONT color="DeepPink">...</FONT>
                   select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
          <FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
</pre>
<p>Usage:</p>
<pre><FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> al <FONT color="DarkBlue">&#8216;</FONT><FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>a <FONT color="Red">4</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>d <FONT color="Red">3</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>a <FONT color="Red">2</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>c <FONT color="Red">9</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>a <FONT color="Red">11</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Teal">write</FONT>
  <FONT color="DarkBlue">[</FONT>
  from y in al
  <FONT color="Blue">let</FONT> a <FONT color="Teal">=</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">car</FONT> y<FONT color="DarkBlue">)</FONT>  <FONT color="DarkGreen">; the symbol</FONT>
  <FONT color="Blue">let</FONT> b <FONT color="Teal">=</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">cadr</FONT> y<FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">; the number</FONT>
  <FONT color="Blue">let</FONT> c <FONT color="Teal">=</FONT> y        <FONT color="DarkGreen">; alias</FONT>
  orderby b asc
  where <FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">eq?</FONT> a <FONT color="DarkBlue">'</FONT>a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">even?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
  from x in c
  <FONT color="Blue">let</FONT> d <FONT color="Teal">=</FONT> x
  select d
  <FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT>
<FONT color="DarkBlue">(</FONT><FONT color="Teal">newline</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">;=&gt; (a 2 a 4)</FONT></pre>
<p>Rules:<br />
- No duplicate identifiers<br />
- from and let requires an unique identifier<br />
- you can use normal expressions in the latter parts of from and let, as well as select, where and orderby</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xacc.wordpress.com/110/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xacc.wordpress.com/110/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xacc.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xacc.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xacc.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xacc.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xacc.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xacc.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xacc.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xacc.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xacc.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xacc.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xacc.wordpress.com&blog=1242361&post=110&subd=xacc&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xacc.wordpress.com/2008/04/15/linq-for-r6rs-scheme-take-6/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/xacc-128.jpg" medium="image">
			<media:title type="html">leppie</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ for R6RS Scheme take 5</title>
		<link>http://xacc.wordpress.com/2008/04/13/linq-for-r6rs-scheme-take-5/</link>
		<comments>http://xacc.wordpress.com/2008/04/13/linq-for-r6rs-scheme-take-5/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 19:15:47 +0000</pubDate>
		<dc:creator>leppie</dc:creator>
		
		<category><![CDATA[Default]]></category>

		<category><![CDATA[IronScheme]]></category>

		<guid isPermaLink="false">http://xacc.wordpress.com/?p=109</guid>
		<description><![CDATA[I have managed to get the lexical scoping working  
This works on the following:
- IronScheme
- Ikarus
- Larceny
- Petite Chez Scheme (remove the import clause)
Implementation:
(import (rnrs))

(define (compare asc? a b)
  (cond
    [(and (number? a) (number? b))
      ((if asc? &#60; &#62;) a b)]
    [(and [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have managed to get the lexical scoping working <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This works on the following:<br />
- IronScheme<br />
- Ikarus<br />
- Larceny<br />
- Petite Chez Scheme (remove the import clause)</p>
<p>Implementation:</p>
<pre><FONT color="DarkBlue">(</FONT><FONT color="Blue">import</FONT> <FONT color="DarkBlue">(</FONT>rnrs<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>compare asc? a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">cond</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">&lt;</FONT> <FONT color="Teal">&gt;</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">char&lt;?</FONT> <FONT color="Teal">char&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>a <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> a<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>b <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
           <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DeepPink">else</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Teal">assertion-violation</FONT> <FONT color="DarkBlue">'</FONT>compare <FONT color="Maroon">"not supported"</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>sort asc? l a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">list-sort</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>a* b*<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT>compare asc? <FONT color="DarkBlue">(</FONT>a a*<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>b b*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>flatten lists<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT> <FONT color="Teal">append</FONT> lists<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define-syntax</FONT> from
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>x<FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>e? e o<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Teal">eq?</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> e<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> o<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> x <FONT color="DarkBlue">(</FONT>in select<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e in l select s<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> <FONT color="DarkBlue">(</FONT>e? <FONT color="DarkBlue">#'</FONT>e <FONT color="DarkBlue">#'</FONT>s<FONT color="DarkBlue">)</FONT>
          <FONT color="DarkBlue">#'</FONT>l
          <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> s<FONT color="DarkBlue">)</FONT> l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e in l c <FONT color="DeepPink">...</FONT> select s<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>c <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>where orderby asc desc in<FONT color="DarkBlue">)</FONT>
          <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>where p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> <FONT color="DarkBlue">(</FONT>e? <FONT color="DarkBlue">#'</FONT>e <FONT color="DarkBlue">#'</FONT>p<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e in l
                 rest <FONT color="DeepPink">...</FONT>
                 select s<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e in <FONT color="DarkBlue">(</FONT><FONT color="Teal">filter</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT> l<FONT color="DarkBlue">)</FONT>
                 rest <FONT color="DeepPink">...</FONT>
                 select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
          <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e* in l* rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>flatten
                <FONT color="DarkBlue">(</FONT>from e in l
                 select
                  <FONT color="DarkBlue">(</FONT>from e* in l*
                   rest <FONT color="DeepPink">...</FONT>
                   select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
          <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p asc rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e in
                 <FONT color="DarkBlue">(</FONT>sort <FONT color="Red">#t</FONT> l <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
               rest <FONT color="DeepPink">...</FONT>
               select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
          <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p desc rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e in
                 <FONT color="DarkBlue">(</FONT>sort <FONT color="Red">#f</FONT> l <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
               rest <FONT color="DeepPink">...</FONT>
               select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
          <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e in l
               orderby p asc
               rest <FONT color="DeepPink">...</FONT>
               select s<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
      <FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT></pre>
<p>Usage (shows nested &#8216;from x in y&#8217; equivalence):</p>
<pre><FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> al <FONT color="DarkBlue">&#8216;</FONT><FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>a <FONT color="Red">4</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>d <FONT color="Red">3</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>a <FONT color="Red">2</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>c <FONT color="Red">9</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>a <FONT color="Red">10</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Teal">write</FONT>
  <FONT color="DarkBlue">(</FONT>
  from e in al
  orderby <FONT color="DarkBlue">(</FONT><FONT color="Teal">cadr</FONT> e<FONT color="DarkBlue">)</FONT>
  from x in e
  where <FONT color="DarkBlue">(</FONT><FONT color="Teal">eq?</FONT> x <FONT color="DarkBlue">&#8216;</FONT>a<FONT color="DarkBlue">)</FONT>
  select e
  <FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
<FONT color="DarkBlue">(</FONT><FONT color="Teal">newline</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">;=&gt; ((a 2) (a 4) (a 10))</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Teal">write</FONT>
  <FONT color="DarkBlue">(</FONT>flatten
  <FONT color="DarkBlue">(</FONT>
  from e in al
  orderby <FONT color="DarkBlue">(</FONT><FONT color="Teal">cadr</FONT> e<FONT color="DarkBlue">)</FONT>
  select
    <FONT color="DarkBlue">(</FONT>from x in e
     where <FONT color="DarkBlue">(</FONT><FONT color="Teal">eq?</FONT> x <FONT color="DarkBlue">&#8216;</FONT>a<FONT color="DarkBlue">)</FONT>
     select e<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
<FONT color="DarkBlue">(</FONT><FONT color="Teal">newline</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">;=&gt; ((a 2) (a 4) (a 10))</FONT></pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xacc.wordpress.com/109/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xacc.wordpress.com/109/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xacc.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xacc.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xacc.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xacc.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xacc.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xacc.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xacc.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xacc.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xacc.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xacc.wordpress.com/109/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xacc.wordpress.com&blog=1242361&post=109&subd=xacc&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xacc.wordpress.com/2008/04/13/linq-for-r6rs-scheme-take-5/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/xacc-128.jpg" medium="image">
			<media:title type="html">leppie</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ for R6RS Scheme take 4</title>
		<link>http://xacc.wordpress.com/2008/04/12/linq-for-r6rs-scheme-take-4/</link>
		<comments>http://xacc.wordpress.com/2008/04/12/linq-for-r6rs-scheme-take-4/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 17:48:49 +0000</pubDate>
		<dc:creator>leppie</dc:creator>
		
		<category><![CDATA[Default]]></category>

		<category><![CDATA[IronScheme]]></category>

		<guid isPermaLink="false">http://xacc.wordpress.com/?p=108</guid>
		<description><![CDATA[Added the nested &#8216;from x in y&#8217; construct. Added symbol comparison.
(import (rnrs))

(define (compare asc? a b)
  (cond
    [(and (number? a) (number? b))
      ((if asc? &#60; &#62;) a b)]
    [(and (char? a) (char? b))
      ((if asc? char&#60;? char&#62;?) a [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Added the nested &#8216;from x in y&#8217; construct. Added symbol comparison.</p>
<pre><FONT color="DarkBlue">(</FONT><FONT color="Blue">import</FONT> <FONT color="DarkBlue">(</FONT>rnrs<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>compare asc? a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">cond</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">&lt;</FONT> <FONT color="Teal">&gt;</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">char&lt;?</FONT> <FONT color="Teal">char&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">let</FONT> <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>a <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> a<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">(</FONT>b <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol-&gt;string</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
           <FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc? <FONT color="Teal">string&lt;?</FONT> <FONT color="Teal">string&gt;?</FONT><FONT color="DarkBlue">)</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
    <FONT color="DarkBlue">[</FONT><FONT color="DeepPink">else</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Teal">assertion-violation</FONT> <FONT color="DarkBlue">'</FONT>compare <FONT color="Maroon">"not supported"</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>sort asc? l a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">list-sort</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>a* b*<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT>compare asc? <FONT color="DarkBlue">(</FONT>a a*<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>b b*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>flatten lists<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Teal">apply</FONT> <FONT color="Teal">append</FONT> lists<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define-syntax</FONT> from
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>x<FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>e? e o<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">(</FONT><FONT color="Teal">eq?</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> e<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">syntax-&gt;datum</FONT> o<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> x <FONT color="DarkBlue">(</FONT>in select<FONT color="DarkBlue">)</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e in l select sel<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> <FONT color="DarkBlue">(</FONT>e? <FONT color="DarkBlue">#'</FONT>e <FONT color="DarkBlue">#'</FONT>sel<FONT color="DarkBlue">)</FONT>
          <FONT color="DarkBlue">#'</FONT>l
          <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT><FONT color="Teal">map</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> sel<FONT color="DarkBlue">)</FONT> l<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e in l c <FONT color="DeepPink">...</FONT> select sel<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Teal">identifier?</FONT> <FONT color="DarkBlue">#'</FONT>e<FONT color="DarkBlue">)</FONT>
        <FONT color="DarkBlue">(</FONT><FONT color="Blue">syntax-case</FONT> <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>c <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>where orderby asc desc<FONT color="DarkBlue">)</FONT>
          <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>where p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> <FONT color="DarkBlue">(</FONT>e? <FONT color="DarkBlue">#'</FONT>e <FONT color="DarkBlue">#'</FONT>p<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e in l
                 rest <FONT color="DeepPink">...</FONT>
                 select sel<FONT color="DarkBlue">)</FONT>
              <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e in <FONT color="DarkBlue">(</FONT><FONT color="Teal">filter</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT> l<FONT color="DarkBlue">)</FONT>
                 rest <FONT color="DeepPink">...</FONT>
                 select sel<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
          <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>from e* in l* rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e* in
                 <FONT color="DarkBlue">(</FONT>flatten <FONT color="DarkBlue">(</FONT>from e in l select l*<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
               rest <FONT color="DeepPink">...</FONT>
               select sel<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
          <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p asc rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e in
                 <FONT color="DarkBlue">(</FONT>sort <FONT color="Red">#t</FONT> l <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
               rest <FONT color="DeepPink">...</FONT>
               select sel<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
          <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p desc rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e in
                 <FONT color="DarkBlue">(</FONT>sort <FONT color="Red">#f</FONT> l <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Blue">lambda</FONT> <FONT color="DarkBlue">(</FONT>e<FONT color="DarkBlue">)</FONT> p<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
               rest <FONT color="DeepPink">...</FONT>
               select sel<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
          <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT>orderby p rest <FONT color="DeepPink">...</FONT><FONT color="DarkBlue">)</FONT>
            <FONT color="DarkBlue">#'</FONT><FONT color="DarkBlue">(</FONT>from e in l
               orderby p asc
               rest <FONT color="DeepPink">...</FONT>
               select sel<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
      <FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT></pre>
<p>Usage for nested &#8216;from x in y&#8217;:</p>
<pre><FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> al <FONT color="DarkBlue">&#8216;</FONT><FONT color="DarkBlue">(</FONT><FONT color="DarkBlue">(</FONT>a <FONT color="Red">2</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>b <FONT color="Red">3</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>d <FONT color="Red">4</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT>c <FONT color="Red">1</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Teal">write</FONT>
  <FONT color="DarkBlue">(</FONT>
  from e in al
  from x in e
  where <FONT color="DarkBlue">(</FONT><FONT color="Teal">symbol?</FONT> x<FONT color="DarkBlue">)</FONT>
  orderby x desc
  select x
  <FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>
<FONT color="DarkBlue">(</FONT><FONT color="Teal">newline</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkGreen">;=&gt; (d c b a)</FONT></pre>
<p>UPDATE:<br />
The above version has a problem/limitation with the nested &#8216;from x in y&#8217; as the &#8216;e&#8217; variable goes out of scope, and cannot be used further on. I will try to address that next.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/xacc.wordpress.com/108/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/xacc.wordpress.com/108/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xacc.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xacc.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xacc.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xacc.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xacc.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xacc.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xacc.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xacc.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xacc.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xacc.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xacc.wordpress.com&blog=1242361&post=108&subd=xacc&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://xacc.wordpress.com/2008/04/12/linq-for-r6rs-scheme-take-4/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/xacc-128.jpg" medium="image">
			<media:title type="html">leppie</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ for R6RS Scheme take 3</title>
		<link>http://xacc.wordpress.com/2008/04/12/linq-for-r6rs-scheme-take-3/</link>
		<comments>http://xacc.wordpress.com/2008/04/12/linq-for-r6rs-scheme-take-3/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 11:13:11 +0000</pubDate>
		<dc:creator>leppie</dc:creator>
		
		<category><![CDATA[Default]]></category>

		<category><![CDATA[IronScheme]]></category>

		<guid isPermaLink="false">http://xacc.wordpress.com/?p=107</guid>
		<description><![CDATA[Well this is proving to be an interesting exercise  I think most would agree the new solution provides much better extensibility.
(import (rnrs))

(define (compare asc? a b)
  (if asc?
    (cond
      [(and (number? a) (number? b)) (&#60; a b)]
      [(and (char? a) [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Well this is proving to be an interesting exercise <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> I think most would agree the new solution provides much better extensibility.</p>
<pre><FONT color="DarkBlue">(</FONT><FONT color="Blue">import</FONT> <FONT color="DarkBlue">(</FONT>rnrs<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT><FONT color="Blue">define</FONT> <FONT color="DarkBlue">(</FONT>compare asc? a b<FONT color="DarkBlue">)</FONT>
  <FONT color="DarkBlue">(</FONT><FONT color="Blue">if</FONT> asc?
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">cond</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">&lt;</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char&lt;?</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string&lt;?</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DeepPink">else</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">error</FONT> <FONT color="DarkBlue">'</FONT>compare <FONT color="Maroon">"not supported"</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT>
    <FONT color="DarkBlue">(</FONT><FONT color="Blue">cond</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">number?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">&gt;</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">char&gt;?</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DarkBlue">(</FONT><FONT color="Blue">and</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> a<FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string?</FONT> b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">string&gt;?</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT>
      <FONT color="DarkBlue">[</FONT><FONT color="DeepPink">else</FONT> <FONT color="DarkBlue">(</FONT><FONT color="Teal">error</FONT> <FONT color="DarkBlue">'</FONT>compare <FONT color="Maroon">"not supported"</FONT> a b<FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">]</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT><FONT color="DarkBlue">)</FONT>

<FONT color="DarkBlue">(</FONT