<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Programmatically create functions</title>
    <link>http://www.mapleprimes.com/questions/123105-Programmatically-Create-Functions</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Fri, 12 Jun 2026 11:15:17 GMT</lastBuildDate>
    <pubDate>Fri, 12 Jun 2026 11:15:17 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Programmatically create functions</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Programmatically create functions</title>
      <link>http://www.mapleprimes.com/questions/123105-Programmatically-Create-Functions</link>
    </image>
    <item>
      <title>Converting into functions</title>
      <link>http://www.mapleprimes.com/questions/123105-Programmatically-Create-Functions?ref=Feed:MaplePrimes:Programmatically create functions:Comments#answer123109</link>
      <itunes:summary>&lt;p&gt;You don't give an example of the result set, but assuming the results have the form given below, then they can be programmatically converted into functions.&lt;/p&gt;
&lt;pre&gt;resultset := {f=x^2+1, g=x^2*y+2};&lt;br&gt;                         /     2           2      \ &lt;br&gt;                        { f = x  + 1, g = x  y + 2 }&lt;br&gt;                         \                        / &lt;br&gt;for p in resultset do
  expr := rhs(p);
  funcname := lhs(p);
  varnames := op( indets(expr, name) ); 
  assign( funcname=unapply(expr, varnames) );
od:&lt;br&gt;print(f);&lt;br&gt;      2    &lt;br&gt;x -&amp;gt; x  + 1&lt;br&gt;print(g);&lt;br&gt;           2      &lt;br&gt;(x, y) -&amp;gt; x  y + 2&lt;br&gt;f(5);&lt;br&gt;                                     26&lt;br&gt;g(3,2);&lt;br&gt;                                     20&lt;/pre&gt;
&lt;!--break--&gt;
&lt;p&gt;---&lt;/p&gt;
&lt;p&gt;Duncan&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;You don't give an example of the result set, but assuming the results have the form given below, then they can be programmatically converted into functions.&lt;/p&gt;
&lt;pre&gt;resultset := {f=x^2+1, g=x^2*y+2};&lt;br&gt;                         /     2           2      \ &lt;br&gt;                        { f = x  + 1, g = x  y + 2 }&lt;br&gt;                         \                        / &lt;br&gt;for p in resultset do
  expr := rhs(p);
  funcname := lhs(p);
  varnames := op( indets(expr, name) ); 
  assign( funcname=unapply(expr, varnames) );
od:&lt;br&gt;print(f);&lt;br&gt;      2    &lt;br&gt;x -&amp;gt; x  + 1&lt;br&gt;print(g);&lt;br&gt;           2      &lt;br&gt;(x, y) -&amp;gt; x  y + 2&lt;br&gt;f(5);&lt;br&gt;                                     26&lt;br&gt;g(3,2);&lt;br&gt;                                     20&lt;/pre&gt;
&lt;!--break--&gt;
&lt;p&gt;---&lt;/p&gt;
&lt;p&gt;Duncan&lt;/p&gt;</description>
      <guid>123109</guid>
      <pubDate>Wed, 22 Jun 2011 19:06:14 Z</pubDate>
      <itunes:author>DuncanA</itunes:author>
      <author>DuncanA</author>
    </item>
    <item>
      <title>In one line</title>
      <link>http://www.mapleprimes.com/questions/123105-Programmatically-Create-Functions?ref=Feed:MaplePrimes:Programmatically create functions:Comments#answer123126</link>
      <itunes:summary>&lt;pre&gt;assign((eq-&amp;gt;lhs(eq)=unapply(rhs(eq),indets(rhs(eq))[]))~(resultset));&lt;/pre&gt;
&lt;p&gt;Alec&lt;/p&gt;</itunes:summary>
      <description>&lt;pre&gt;assign((eq-&amp;gt;lhs(eq)=unapply(rhs(eq),indets(rhs(eq))[]))~(resultset));&lt;/pre&gt;
&lt;p&gt;Alec&lt;/p&gt;</description>
      <guid>123126</guid>
      <pubDate>Thu, 23 Jun 2011 01:35:38 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
    <item>
      <title>that worked!</title>
      <link>http://www.mapleprimes.com/questions/123105-Programmatically-Create-Functions?ref=Feed:MaplePrimes:Programmatically create functions:Comments#answer123148</link>
      <itunes:summary>&lt;p&gt;Thanks guys!&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Thanks guys!&lt;/p&gt;</description>
      <guid>123148</guid>
      <pubDate>Thu, 23 Jun 2011 15:34:19 Z</pubDate>
      <itunes:author>Djinh</itunes:author>
      <author>Djinh</author>
    </item>
  </channel>
</rss>