<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Scheme code capsule: currying</title>
	<atom:link href="http://programming-musings.org/2007/02/03/scheme-code-capsule-currying/feed/" rel="self" type="application/rss+xml" />
	<link>http://programming-musings.org/2007/02/03/scheme-code-capsule-currying/</link>
	<description>random thoughts on programming and programming languages</description>
	<lastBuildDate>Fri, 04 Nov 2011 16:12:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: The Comonad.Reader &#187; Curried Scheme</title>
		<link>http://programming-musings.org/2007/02/03/scheme-code-capsule-currying/#comment-30977</link>
		<dc:creator><![CDATA[The Comonad.Reader &#187; Curried Scheme]]></dc:creator>
		<pubDate>Sat, 29 Aug 2009 15:45:35 +0000</pubDate>
		<guid isPermaLink="false">http://jaortega.wordpress.com/2007/02/03/scheme-code-capsule-currying/#comment-30977</guid>
		<description><![CDATA[[...] found a very elegant macro by Piet Delport that handles partial application, but that doesn&#039;t deal with the partial application of no arguments or that I&#039;d like to also be [...]]]></description>
		<content:encoded><![CDATA[<p>[...] found a very elegant macro by Piet Delport that handles partial application, but that doesn&#39;t deal with the partial application of no arguments or that I&#39;d like to also be [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Comonad.Reader &#187; A Robust Currying Macro for Scheme</title>
		<link>http://programming-musings.org/2007/02/03/scheme-code-capsule-currying/#comment-30976</link>
		<dc:creator><![CDATA[The Comonad.Reader &#187; A Robust Currying Macro for Scheme]]></dc:creator>
		<pubDate>Sat, 29 Aug 2009 15:42:46 +0000</pubDate>
		<guid isPermaLink="false">http://jaortega.wordpress.com/2007/02/03/scheme-code-capsule-currying/#comment-30976</guid>
		<description><![CDATA[[...] found a very elegant macro by Piet Delport that handles partial application, but that doesn&#039;t deal with the partial application of no arguments or that I&#039;d like to also be [...]]]></description>
		<content:encoded><![CDATA[<p>[...] found a very elegant macro by Piet Delport that handles partial application, but that doesn&#39;t deal with the partial application of no arguments or that I&#39;d like to also be [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Auto-Currying vs. Variable-Arity :: I am Richard :: Entries ::</title>
		<link>http://programming-musings.org/2007/02/03/scheme-code-capsule-currying/#comment-30811</link>
		<dc:creator><![CDATA[Auto-Currying vs. Variable-Arity :: I am Richard :: Entries ::]]></dc:creator>
		<pubDate>Wed, 24 Sep 2008 04:44:53 +0000</pubDate>
		<guid isPermaLink="false">http://jaortega.wordpress.com/2007/02/03/scheme-code-capsule-currying/#comment-30811</guid>
		<description><![CDATA[[...] anyway for the toy cases like the + function. If your language has macros, then you can do like some people have done and make macros that allow you to auto-curry individual [...]]]></description>
		<content:encoded><![CDATA[<p>[...] anyway for the toy cases like the + function. If your language has macros, then you can do like some people have done and make macros that allow you to auto-curry individual [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Martin</title>
		<link>http://programming-musings.org/2007/02/03/scheme-code-capsule-currying/#comment-12253</link>
		<dc:creator><![CDATA[Daniel Martin]]></dc:creator>
		<pubDate>Wed, 21 Feb 2007 14:18:02 +0000</pubDate>
		<guid isPermaLink="false">http://jaortega.wordpress.com/2007/02/03/scheme-code-capsule-currying/#comment-12253</guid>
		<description><![CDATA[&lt;blockquote&gt;currying works fine with languages in the ML family because
functions there take a single argument. This “single argument” might, of course, be a tuple. This works transparently to the user because of pattern matching, so that it *looks* like you’re calling a function with multiple arguments.&lt;/blockquote&gt;Not quite.  When you make a call that looks like you&#039;re calling a function with multiple arguments in, e.g., Haskell, what&#039;s going on with the idea that a function should take multiple arguments is that the function returns another function.  That is:

myFunc 3 4

Is equivalent to the scheme code:

((myFunc 3) 4)

And &lt;em&gt;automatic&lt;/em&gt; currying works properly only in the presence of a defined, definite arity.  So currying can&#039;t work automatically with arbitrary scheme functions, but the given define-syntax forms let currying work automatically and reasonably efficiently with function definitions that take a fixed number of parameters.  With the above definitions, I can still run this:
(repeat 100000
  ((foo 3) 1 2)
  ((foo 3 1) 2)
  (((foo 3) 1) 2) )
on a rather slow machine (500Mhz K6) in ~7.1 seconds.  (under &quot;bigloo -i&quot;)

As Phil shows, manual currying can be done quite easily in scheme, without even a need to get into define-syntax.]]></description>
		<content:encoded><![CDATA[<blockquote><p>currying works fine with languages in the ML family because<br />
functions there take a single argument. This “single argument” might, of course, be a tuple. This works transparently to the user because of pattern matching, so that it *looks* like you’re calling a function with multiple arguments.</p></blockquote>
<p>Not quite.  When you make a call that looks like you&#8217;re calling a function with multiple arguments in, e.g., Haskell, what&#8217;s going on with the idea that a function should take multiple arguments is that the function returns another function.  That is:</p>
<p>myFunc 3 4</p>
<p>Is equivalent to the scheme code:</p>
<p>((myFunc 3) 4)</p>
<p>And <em>automatic</em> currying works properly only in the presence of a defined, definite arity.  So currying can&#8217;t work automatically with arbitrary scheme functions, but the given define-syntax forms let currying work automatically and reasonably efficiently with function definitions that take a fixed number of parameters.  With the above definitions, I can still run this:<br />
(repeat 100000<br />
  ((foo 3) 1 2)<br />
  ((foo 3 1) 2)<br />
  (((foo 3) 1) 2) )<br />
on a rather slow machine (500Mhz K6) in ~7.1 seconds.  (under &#8220;bigloo -i&#8221;)</p>
<p>As Phil shows, manual currying can be done quite easily in scheme, without even a need to get into define-syntax.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://programming-musings.org/2007/02/03/scheme-code-capsule-currying/#comment-12204</link>
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Mon, 05 Feb 2007 20:57:08 +0000</pubDate>
		<guid isPermaLink="false">http://jaortega.wordpress.com/2007/02/03/scheme-code-capsule-currying/#comment-12204</guid>
		<description><![CDATA[Thanks a lot for your reply Phil. I&#039;m off to learn something new.]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot for your reply Phil. I&#8217;m off to learn something new.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://programming-musings.org/2007/02/03/scheme-code-capsule-currying/#comment-12203</link>
		<dc:creator><![CDATA[Phil]]></dc:creator>
		<pubDate>Mon, 05 Feb 2007 20:42:23 +0000</pubDate>
		<guid isPermaLink="false">http://jaortega.wordpress.com/2007/02/03/scheme-code-capsule-currying/#comment-12203</guid>
		<description><![CDATA[Follow the trail PLT -&gt; Help -&gt; Software: Manuals -&gt; R5RS -&gt; Contents -&gt; 4.1.4 Procedures for a description of the various forms of lambda.  Briefly, both curry-args and args collect the function arguments in a list.  The curry function takes a function and a list of arguments and returns a new function that saves the original function and the given arguments.  The returned function then takes the additional arguments, appends them to the arguments given to the curried function, and applies the original function to the entire list of arguments.]]></description>
		<content:encoded><![CDATA[<p>Follow the trail PLT -&gt; Help -&gt; Software: Manuals -&gt; R5RS -&gt; Contents -&gt; 4.1.4 Procedures for a description of the various forms of lambda.  Briefly, both curry-args and args collect the function arguments in a list.  The curry function takes a function and a list of arguments and returns a new function that saves the original function and the given arguments.  The returned function then takes the additional arguments, appends them to the arguments given to the curried function, and applies the original function to the entire list of arguments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://programming-musings.org/2007/02/03/scheme-code-capsule-currying/#comment-12202</link>
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Mon, 05 Feb 2007 17:32:58 +0000</pubDate>
		<guid isPermaLink="false">http://jaortega.wordpress.com/2007/02/03/scheme-code-capsule-currying/#comment-12202</guid>
		<description><![CDATA[Phil,
I guess I have been missing something, but your code above strikes me as brilliant. I don&#039;t completely understand it and I very much want to. What is the significance of the dotted pair in the function definition? and lambda&#039;s &quot;arg&quot; not being enclosed in parenthases? Can you point me toward a tutorial or something? I have PLT. Thanks.]]></description>
		<content:encoded><![CDATA[<p>Phil,<br />
I guess I have been missing something, but your code above strikes me as brilliant. I don&#8217;t completely understand it and I very much want to. What is the significance of the dotted pair in the function definition? and lambda&#8217;s &#8220;arg&#8221; not being enclosed in parenthases? Can you point me toward a tutorial or something? I have PLT. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://programming-musings.org/2007/02/03/scheme-code-capsule-currying/#comment-12201</link>
		<dc:creator><![CDATA[Phil]]></dc:creator>
		<pubDate>Mon, 05 Feb 2007 14:17:24 +0000</pubDate>
		<guid isPermaLink="false">http://jaortega.wordpress.com/2007/02/03/scheme-code-capsule-currying/#comment-12201</guid>
		<description><![CDATA[&gt; (define (curry func . curry-args)
  (lambda args
    (apply func (append curry-args args))))
&gt; ((curry + 1) 2)
3
&gt; ((curry + 1 2) 3)
6
&gt; ((curry + 1 2) 3 4)
10]]></description>
		<content:encoded><![CDATA[<p>&gt; (define (curry func . curry-args)<br />
  (lambda args<br />
    (apply func (append curry-args args))))<br />
&gt; ((curry + 1) 2)<br />
3<br />
&gt; ((curry + 1 2) 3)<br />
6<br />
&gt; ((curry + 1 2) 3 4)<br />
10</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eclig</title>
		<link>http://programming-musings.org/2007/02/03/scheme-code-capsule-currying/#comment-12200</link>
		<dc:creator><![CDATA[eclig]]></dc:creator>
		<pubDate>Sun, 04 Feb 2007 11:58:57 +0000</pubDate>
		<guid isPermaLink="false">http://jaortega.wordpress.com/2007/02/03/scheme-code-capsule-currying/#comment-12200</guid>
		<description><![CDATA[currying works fine with languages in the ML family because
functions there take a single argument.  This &quot;single argument&quot; might, of course, be a tuple.  This works transparently to the user because of pattern matching, so that it *looks* like you&#039;re calling a function with multiple arguments.

Scheme, on the other hand, has functions with multiple arguments and multiple arity.  And these don&#039;t match with currying.]]></description>
		<content:encoded><![CDATA[<p>currying works fine with languages in the ML family because<br />
functions there take a single argument.  This &#8220;single argument&#8221; might, of course, be a tuple.  This works transparently to the user because of pattern matching, so that it *looks* like you&#8217;re calling a function with multiple arguments.</p>
<p>Scheme, on the other hand, has functions with multiple arguments and multiple arity.  And these don&#8217;t match with currying.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

