<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, procedures within a list</title>
    <link>http://www.mapleprimes.com/questions/127026-Procedures-Within-A-List</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Wed, 10 Jun 2026 21:33:53 GMT</lastBuildDate>
    <pubDate>Wed, 10 Jun 2026 21:33:53 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, procedures within a list</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, procedures within a list</title>
      <link>http://www.mapleprimes.com/questions/127026-Procedures-Within-A-List</link>
    </image>
    <item>
      <title>Global and piecewise</title>
      <link>http://www.mapleprimes.com/questions/127026-Procedures-Within-A-List?ref=Feed:MaplePrimes:procedures within a list:Comments#answer127034</link>
      <itunes:summary>&lt;p&gt;The following works, but does it serve your needs?&lt;/p&gt;
&lt;pre&gt;Parameters2 := [ s = 1 ];&lt;br&gt;Functions2 := [ U = 'proc(c) global s; piecewise(s=1,log(c),(c^(1-s)-1)/(1-s)) end proc' ];&lt;br&gt;eval(eval(U(c), Functions2), Parameters2);&lt;/pre&gt;</itunes:summary>
      <description>&lt;p&gt;The following works, but does it serve your needs?&lt;/p&gt;
&lt;pre&gt;Parameters2 := [ s = 1 ];&lt;br&gt;Functions2 := [ U = 'proc(c) global s; piecewise(s=1,log(c),(c^(1-s)-1)/(1-s)) end proc' ];&lt;br&gt;eval(eval(U(c), Functions2), Parameters2);&lt;/pre&gt;</description>
      <guid>127034</guid>
      <pubDate>Mon, 24 Oct 2011 18:25:59 Z</pubDate>
      <itunes:author>Preben Alsholm</itunes:author>
      <author>Preben Alsholm</author>
    </item>
    <item>
      <title>alternative</title>
      <link>http://www.mapleprimes.com/questions/127026-Procedures-Within-A-List?ref=Feed:MaplePrimes:procedures within a list:Comments#answer127035</link>
      <itunes:summary>&lt;p&gt;Rather then assigning Functions2, I'd consider doing&lt;/p&gt;
&lt;pre&gt;U := proc(c)&lt;br&gt;global s;&lt;br&gt;&amp;nbsp; if not [args]::list(numeric) then return 'procname'(args) end if;&lt;br&gt;&amp;nbsp; if s = 1 then &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return log(c);&lt;br&gt;&amp;nbsp; else&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (c^(1-s)-1)/(1-s);&lt;br&gt;&amp;nbsp; end if;&lt;br&gt;end proc:&lt;/pre&gt;
&lt;p&gt;Then&lt;/p&gt;
&lt;pre&gt;eval(U(c),Parameters2);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/pre&gt;</itunes:summary>
      <description>&lt;p&gt;Rather then assigning Functions2, I'd consider doing&lt;/p&gt;
&lt;pre&gt;U := proc(c)&lt;br&gt;global s;&lt;br&gt;&amp;nbsp; if not [args]::list(numeric) then return 'procname'(args) end if;&lt;br&gt;&amp;nbsp; if s = 1 then &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return log(c);&lt;br&gt;&amp;nbsp; else&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (c^(1-s)-1)/(1-s);&lt;br&gt;&amp;nbsp; end if;&lt;br&gt;end proc:&lt;/pre&gt;
&lt;p&gt;Then&lt;/p&gt;
&lt;pre&gt;eval(U(c),Parameters2);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/pre&gt;</description>
      <guid>127035</guid>
      <pubDate>Mon, 24 Oct 2011 18:59:14 Z</pubDate>
      <itunes:author>Joe Riel</itunes:author>
      <author>Joe Riel</author>
    </item>
    <item>
      <title>variables and evaluation</title>
      <link>http://www.mapleprimes.com/questions/127026-Procedures-Within-A-List?ref=Feed:MaplePrimes:procedures within a list:Comments#answer127041</link>
      <itunes:summary>&lt;p&gt;You declared s as a local variable of U, while Parameters2 refers to the global variable s.&amp;nbsp; These are not the same, and you shouldn't expect them to be the same.&amp;nbsp;&amp;nbsp; So evaluating U(c) with the global s=1 will not affect the result.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;On the other hand, if you made s a global variable the situation becomes more subtle, and the sequence in which evaluation takes place becomes important.&amp;nbsp; In this case what actually happens is that the procedure U is called first, and then the result of that is evaluated with s=1.&lt;/p&gt;
&lt;p&gt;One way that almost works is to substitute into the function definition rather than the result of the function call.&lt;/p&gt;
&lt;p&gt;&amp;gt; Parameters2 := [ s = 1 ];&lt;br&gt;&amp;nbsp;&amp;nbsp; Functions2 := [ U = proc(c) if s = 1 then log(c) else&amp;nbsp; (c^(1-s)-1)/(1-s)&amp;nbsp; end if end proc ];&lt;br&gt;&amp;nbsp; eval(U(c),subs(Parameters2,Functions2));&lt;/p&gt;
&lt;p&gt;Error, numeric exception: division by zero&lt;/p&gt;
&lt;p&gt;The problem here is that when s=1 the (c^(1-s)-1)/(1-s) contains a division by 0 (even though that branch is not going to be taken, this causes a problem in trying to define the substituted procedure).&amp;nbsp; A work-around is to rewrite it so that we don't have an "immediate" division by 0.&lt;/p&gt;
&lt;p&gt;&amp;gt; Parameters2 := [ s = 1 ];&lt;br&gt;&amp;nbsp;&amp;nbsp; Functions2 := [ U = proc(c) local one;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if s = 1 then log(c) else one:= 1; (c^(1-s)-1)/(one-s)&amp;nbsp; end if end proc ];&lt;br&gt;&amp;nbsp;&amp;nbsp; eval(U(c),subs(Parameters2,Functions2));&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;You declared s as a local variable of U, while Parameters2 refers to the global variable s.&amp;nbsp; These are not the same, and you shouldn't expect them to be the same.&amp;nbsp;&amp;nbsp; So evaluating U(c) with the global s=1 will not affect the result.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;On the other hand, if you made s a global variable the situation becomes more subtle, and the sequence in which evaluation takes place becomes important.&amp;nbsp; In this case what actually happens is that the procedure U is called first, and then the result of that is evaluated with s=1.&lt;/p&gt;
&lt;p&gt;One way that almost works is to substitute into the function definition rather than the result of the function call.&lt;/p&gt;
&lt;p&gt;&amp;gt; Parameters2 := [ s = 1 ];&lt;br&gt;&amp;nbsp;&amp;nbsp; Functions2 := [ U = proc(c) if s = 1 then log(c) else&amp;nbsp; (c^(1-s)-1)/(1-s)&amp;nbsp; end if end proc ];&lt;br&gt;&amp;nbsp; eval(U(c),subs(Parameters2,Functions2));&lt;/p&gt;
&lt;p&gt;Error, numeric exception: division by zero&lt;/p&gt;
&lt;p&gt;The problem here is that when s=1 the (c^(1-s)-1)/(1-s) contains a division by 0 (even though that branch is not going to be taken, this causes a problem in trying to define the substituted procedure).&amp;nbsp; A work-around is to rewrite it so that we don't have an "immediate" division by 0.&lt;/p&gt;
&lt;p&gt;&amp;gt; Parameters2 := [ s = 1 ];&lt;br&gt;&amp;nbsp;&amp;nbsp; Functions2 := [ U = proc(c) local one;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if s = 1 then log(c) else one:= 1; (c^(1-s)-1)/(one-s)&amp;nbsp; end if end proc ];&lt;br&gt;&amp;nbsp;&amp;nbsp; eval(U(c),subs(Parameters2,Functions2));&lt;/p&gt;</description>
      <guid>127041</guid>
      <pubDate>Tue, 25 Oct 2011 06:01:54 Z</pubDate>
      <itunes:author>Robert Israel</itunes:author>
      <author>Robert Israel</author>
    </item>
    <item>
      <title>parameters vs arguments</title>
      <link>http://www.mapleprimes.com/questions/127026-Procedures-Within-A-List?ref=Feed:MaplePrimes:procedures within a list:Comments#answer127042</link>
      <itunes:summary>&lt;p&gt;I feel that (in Maple, at least) the significant difference between parameters (inside a proc) and arguments (to that proc) lies more in how you expect to use them than it does in some special coding practice. There are always exceptions, of course, but my preference is to manage parameters as formal arguments.&lt;/p&gt;
&lt;p&gt;There are a few minor sins which I think this helps avoid. (The severity of the sin varies with circumstance and context, of course.)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;One of those is declaing globals in a proc, when it's not necessary.&lt;br&gt;[We've seen the worksheets here, that have procs each with 2 formal parameters and a dozen declared globals. And at worst the results are confusion as to which `x` is which, debugging nightmares, slow code, and certainly no evalhf'ability.]&lt;/li&gt;
&lt;li&gt;Using a procedure without knowing why.&lt;br&gt;[We've seen this too on mapleprimes: it starts off simple, and then somehow quotes get added because they seem to help, and then before you know it you're creating a procedure which you only ever call once. At this point, the central threads of purpose may have been lost. NB. This case in point is not even close to the extreme, which is something like,
&lt;pre&gt;fexpr:=unapply(expr,x);&lt;br&gt;plot(fexpr(x),x=a..b);&amp;nbsp; # and fexpr is never again used&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Having to do a full restart,or even just have Maple do more "work", just to make changes to an example. Or put another way: the less re-calculation required in order to re-run with different parameter values, the better. And re-creating a new instance of the whole procedure, just to use different parameter values, is certainly more re-calculation. (Yes, I realize that there may be other quite different memory management reasons why one has to do a full restart. But it still be be decent practice to not force the requirement...)&lt;/li&gt;
&lt;/ul&gt;
&lt;!--break--&gt;
&lt;p&gt;So I might try something like this:&lt;/p&gt;
&lt;pre&gt;restart:

U := proc(c, s) if s=1 then log(c); else (c^(1-s)-1)/(1-s); end if; end proc:

Parameters1 := [ s = 2 ]:
U(c, subs(Parameters1,s));

                              1    
                            - - + 1
                              c    

# And now, without having to re-create any procedure,

Parameters1 := [ s = 1 ]:
U(c, subs(Parameters1,s));

                             ln(c)
&lt;/pre&gt;
&lt;p&gt;As a very minor quibble -- if I may offer more opinion on coding style -- I suggest trying to use different names for formal parameters than are expected to be used as supplied arguments. Fr example, to help keep thing straight in our heads,&lt;/p&gt;
&lt;pre&gt;restart:

U := proc(C, S) if S=1 then log(C); else (C^(1-S)-1)/(1-S); end if; end proc:

Parameters1 := [ s = 2 ]:
U(c, subs(Parameters1,s));
                              1    
                            - - + 1
                              c    
Parameters1 := [ s = 1 ]:
U(c, subs(Parameters1,s));
                             ln(c)
&lt;/pre&gt;
&lt;p&gt;The formal parameters of procedure U are now named differently, and may help avoids some confusion, but the way that U gets called and the final form results are the same.&lt;/p&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;I feel that (in Maple, at least) the significant difference between parameters (inside a proc) and arguments (to that proc) lies more in how you expect to use them than it does in some special coding practice. There are always exceptions, of course, but my preference is to manage parameters as formal arguments.&lt;/p&gt;
&lt;p&gt;There are a few minor sins which I think this helps avoid. (The severity of the sin varies with circumstance and context, of course.)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;One of those is declaing globals in a proc, when it's not necessary.&lt;br&gt;[We've seen the worksheets here, that have procs each with 2 formal parameters and a dozen declared globals. And at worst the results are confusion as to which `x` is which, debugging nightmares, slow code, and certainly no evalhf'ability.]&lt;/li&gt;
&lt;li&gt;Using a procedure without knowing why.&lt;br&gt;[We've seen this too on mapleprimes: it starts off simple, and then somehow quotes get added because they seem to help, and then before you know it you're creating a procedure which you only ever call once. At this point, the central threads of purpose may have been lost. NB. This case in point is not even close to the extreme, which is something like,
&lt;pre&gt;fexpr:=unapply(expr,x);&lt;br&gt;plot(fexpr(x),x=a..b);&amp;nbsp; # and fexpr is never again used&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Having to do a full restart,or even just have Maple do more "work", just to make changes to an example. Or put another way: the less re-calculation required in order to re-run with different parameter values, the better. And re-creating a new instance of the whole procedure, just to use different parameter values, is certainly more re-calculation. (Yes, I realize that there may be other quite different memory management reasons why one has to do a full restart. But it still be be decent practice to not force the requirement...)&lt;/li&gt;
&lt;/ul&gt;
&lt;!--break--&gt;
&lt;p&gt;So I might try something like this:&lt;/p&gt;
&lt;pre&gt;restart:

U := proc(c, s) if s=1 then log(c); else (c^(1-s)-1)/(1-s); end if; end proc:

Parameters1 := [ s = 2 ]:
U(c, subs(Parameters1,s));

                              1    
                            - - + 1
                              c    

# And now, without having to re-create any procedure,

Parameters1 := [ s = 1 ]:
U(c, subs(Parameters1,s));

                             ln(c)
&lt;/pre&gt;
&lt;p&gt;As a very minor quibble -- if I may offer more opinion on coding style -- I suggest trying to use different names for formal parameters than are expected to be used as supplied arguments. Fr example, to help keep thing straight in our heads,&lt;/p&gt;
&lt;pre&gt;restart:

U := proc(C, S) if S=1 then log(C); else (C^(1-S)-1)/(1-S); end if; end proc:

Parameters1 := [ s = 2 ]:
U(c, subs(Parameters1,s));
                              1    
                            - - + 1
                              c    
Parameters1 := [ s = 1 ]:
U(c, subs(Parameters1,s));
                             ln(c)
&lt;/pre&gt;
&lt;p&gt;The formal parameters of procedure U are now named differently, and may help avoids some confusion, but the way that U gets called and the final form results are the same.&lt;/p&gt;
&lt;p&gt;acer&lt;/p&gt;</description>
      <guid>127042</guid>
      <pubDate>Tue, 25 Oct 2011 09:03:14 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>%name and value</title>
      <link>http://www.mapleprimes.com/questions/127026-Procedures-Within-A-List?ref=Feed:MaplePrimes:procedures within a list:Comments#answer127043</link>
      <itunes:summary>&lt;p&gt;If the goal is to be able to manipulate an inert function call and various symbolic parameters, then later evaluate them, you could use the following technique.&lt;/p&gt;
&lt;pre&gt;s := 1;&lt;br&gt;U := proc(c) if s = 1 then log(c) else 1/(s-1) end if; end proc: # or whatever ...&lt;br&gt;y := %U(c)^2 + %s;&amp;nbsp;&amp;nbsp; # use %U and %s rather than U and s&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y := %U(c)&amp;nbsp; + %s&lt;br&gt;value(y);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ln(c)&amp;nbsp; + 1&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/pre&gt;</itunes:summary>
      <description>&lt;p&gt;If the goal is to be able to manipulate an inert function call and various symbolic parameters, then later evaluate them, you could use the following technique.&lt;/p&gt;
&lt;pre&gt;s := 1;&lt;br&gt;U := proc(c) if s = 1 then log(c) else 1/(s-1) end if; end proc: # or whatever ...&lt;br&gt;y := %U(c)^2 + %s;&amp;nbsp;&amp;nbsp; # use %U and %s rather than U and s&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y := %U(c)&amp;nbsp; + %s&lt;br&gt;value(y);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ln(c)&amp;nbsp; + 1&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/pre&gt;</description>
      <guid>127043</guid>
      <pubDate>Tue, 25 Oct 2011 10:16:47 Z</pubDate>
      <itunes:author>Joe Riel</itunes:author>
      <author>Joe Riel</author>
    </item>
    <item>
      <title>thanks</title>
      <link>http://www.mapleprimes.com/questions/127026-Procedures-Within-A-List?ref=Feed:MaplePrimes:procedures within a list:Comments#comment127087</link>
      <itunes:summary>&lt;p&gt;&lt;br&gt;Preben, Joe, Robert, acer, thank you so much for your suggestions. This has been a very useful exchange, I have learned several things. I am particularly grateful for the pains you took to explaining the details of what was going on. &lt;br&gt;&lt;br&gt;Preben, very interesting use of piecewise, your code is the shortest too, it does achieve what I was after. &lt;br&gt;&lt;br&gt;Robert, I like that your method makes clear the order of evaluation, and it's nice to learn how to get around the division by zero, this trick will be potentially useful elsewhere. &lt;br&gt;&lt;br&gt;Using subs I can also simplify the code in places where I intend to use both the functional forms and the parameter values at once, e.g.&lt;/p&gt;
&lt;pre&gt;&lt;br&gt;model := subs(Parameters1,Functions);&lt;br&gt;eval(U(c), model); # clearer than eval(eval(...&lt;br&gt;&lt;br&gt;&amp;nbsp; model := [U = proc (c) local one; if 2 = 1 then log(c) else one := 1; (1/c-1)/(one-2) end if end proc]&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;it helped me understand what was going on to actually see the statement if 2=1.&lt;br&gt;&lt;br&gt;Joe, thanks, working out the meaning of the following line was well worth the effort, code that may prove useful in the future too,&lt;br&gt;&lt;br&gt;&amp;nbsp; if not [args]::list(numeric) then return 'procname'(args) end if;&lt;br&gt;&lt;br&gt;acer, yes I fully agree with the practice of using different symbols in the definition of the proc and in its evaluation, I'll try to be consistent with that in the future. Thanks for your guidance.&lt;br&gt;&lt;br&gt;Joe, I'm curious about the use of the percentage sign in front of a symbol, as in %s, I couldn't find documentation about this particular use of % ... Oh, wait! I do find information about it as I write, by searching &lt;a href='http://www.maplesoft.com/support/help/search.aspx?term=value' target='_new'&gt;?value&lt;/a&gt;. Here: &lt;br&gt;&amp;lt;quote&amp;gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;br&gt;any function whose name starts with the % character, as in %F, is an inert representation for the function F. This feature provides inert representations for any Maple or user-defined function. [...] During computations, inert functions remain unevaluated (the operations they represent remain unperformed). The value command maps these inert functions [...] into the corresponding active functions.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&amp;lt;\quote&amp;gt; &lt;/p&gt;
&lt;p&gt;Example: %Pi; value(%Pi);&lt;br&gt;&lt;br&gt;A search for % returns "The Ditto Operators" section Maple's help pages. I don't see there a link to "value."&amp;nbsp; This is, I think, a shortcoming of the ditto help page.&lt;br&gt;&lt;br&gt;That's quite a few tricks to add to my bag. Thanks so much to all of you for your help. &lt;br&gt;&lt;br&gt;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;&lt;br&gt;Preben, Joe, Robert, acer, thank you so much for your suggestions. This has been a very useful exchange, I have learned several things. I am particularly grateful for the pains you took to explaining the details of what was going on. &lt;br&gt;&lt;br&gt;Preben, very interesting use of piecewise, your code is the shortest too, it does achieve what I was after. &lt;br&gt;&lt;br&gt;Robert, I like that your method makes clear the order of evaluation, and it's nice to learn how to get around the division by zero, this trick will be potentially useful elsewhere. &lt;br&gt;&lt;br&gt;Using subs I can also simplify the code in places where I intend to use both the functional forms and the parameter values at once, e.g.&lt;/p&gt;
&lt;pre&gt;&lt;br&gt;model := subs(Parameters1,Functions);&lt;br&gt;eval(U(c), model); # clearer than eval(eval(...&lt;br&gt;&lt;br&gt;&amp;nbsp; model := [U = proc (c) local one; if 2 = 1 then log(c) else one := 1; (1/c-1)/(one-2) end if end proc]&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;it helped me understand what was going on to actually see the statement if 2=1.&lt;br&gt;&lt;br&gt;Joe, thanks, working out the meaning of the following line was well worth the effort, code that may prove useful in the future too,&lt;br&gt;&lt;br&gt;&amp;nbsp; if not [args]::list(numeric) then return 'procname'(args) end if;&lt;br&gt;&lt;br&gt;acer, yes I fully agree with the practice of using different symbols in the definition of the proc and in its evaluation, I'll try to be consistent with that in the future. Thanks for your guidance.&lt;br&gt;&lt;br&gt;Joe, I'm curious about the use of the percentage sign in front of a symbol, as in %s, I couldn't find documentation about this particular use of % ... Oh, wait! I do find information about it as I write, by searching &lt;a href='http://www.maplesoft.com/support/help/search.aspx?term=value' target='_new'&gt;?value&lt;/a&gt;. Here: &lt;br&gt;&amp;lt;quote&amp;gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;br&gt;any function whose name starts with the % character, as in %F, is an inert representation for the function F. This feature provides inert representations for any Maple or user-defined function. [...] During computations, inert functions remain unevaluated (the operations they represent remain unperformed). The value command maps these inert functions [...] into the corresponding active functions.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&amp;lt;\quote&amp;gt; &lt;/p&gt;
&lt;p&gt;Example: %Pi; value(%Pi);&lt;br&gt;&lt;br&gt;A search for % returns "The Ditto Operators" section Maple's help pages. I don't see there a link to "value."&amp;nbsp; This is, I think, a shortcoming of the ditto help page.&lt;br&gt;&lt;br&gt;That's quite a few tricks to add to my bag. Thanks so much to all of you for your help. &lt;br&gt;&lt;br&gt;&lt;/p&gt;</description>
      <guid>127087</guid>
      <pubDate>Thu, 27 Oct 2011 03:45:20 Z</pubDate>
      <itunes:author>PatrickT</itunes:author>
      <author>PatrickT</author>
    </item>
  </channel>
</rss>