<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Tidying up a messy set of Proc and loops. (Recurrece relations)</title>
    <link>http://www.mapleprimes.com/questions/129422-Tidying-Up-A-Messy-Set-Of-Proc-And-Loops-Recurrece-Relations</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Tue, 09 Jun 2026 15:04:37 GMT</lastBuildDate>
    <pubDate>Tue, 09 Jun 2026 15:04:37 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Tidying up a messy set of Proc and loops. (Recurrece relations)</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Tidying up a messy set of Proc and loops. (Recurrece relations)</title>
      <link>http://www.mapleprimes.com/questions/129422-Tidying-Up-A-Messy-Set-Of-Proc-And-Loops-Recurrece-Relations</link>
    </image>
    <item>
      <title>for example</title>
      <link>http://www.mapleprimes.com/questions/129422-Tidying-Up-A-Messy-Set-Of-Proc-And-Loops-Recurrece-Relations?ref=Feed:MaplePrimes:Tidying up a messy set of Proc and loops. (Recurrece relations):Comments#answer129431</link>
      <itunes:summary>&lt;pre&gt;L:=[seq(x(i), i=0 .. 20)]:&lt;br&gt;map('t -&amp;gt; type(t, integer)', L);&lt;br&gt;convert(%, set); # to see, which values occure&lt;br&gt;&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; {true}&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/pre&gt;</itunes:summary>
      <description>&lt;pre&gt;L:=[seq(x(i), i=0 .. 20)]:&lt;br&gt;map('t -&amp;gt; type(t, integer)', L);&lt;br&gt;convert(%, set); # to see, which values occure&lt;br&gt;&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; {true}&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/pre&gt;</description>
      <guid>129431</guid>
      <pubDate>Sat, 07 Jan 2012 18:53:42 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>Early termination</title>
      <link>http://www.mapleprimes.com/questions/129422-Tidying-Up-A-Messy-Set-Of-Proc-And-Loops-Recurrece-Relations?ref=Feed:MaplePrimes:Tidying up a messy set of Proc and loops. (Recurrece relations):Comments#answer129498</link>
      <itunes:summary>&lt;p&gt;Hi Pete3431,&lt;/p&gt;
&lt;p&gt;I'd like to try to set things up in such a way that once a non-integer value is produced, it doesn't need to continue searching and stops immediately. If you prefer the method of defining a procedure with remember table, then we can keep the definition of &lt;em&gt;x&lt;/em&gt; as is (including assigning to &lt;em&gt;x&lt;/em&gt;(0), &lt;em&gt;x&lt;/em&gt;(1), &lt;em&gt;x&lt;/em&gt;(2)). After that, I would do:&lt;/p&gt;
&lt;p&gt;testIntegers := proc(seqname :: appliable,&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; {rng :: range(integer) := 0 .. 20},&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; $)&lt;br&gt;local i;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for i from lhs(rng) to rhs(rng) do&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not type(seqname(i), 'integer') then&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; return false;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end if;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end do;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;br&gt;end proc;&lt;/p&gt;
&lt;p&gt;Then you can ask for &lt;em&gt;testIntegers&lt;/em&gt;(&lt;em&gt;x&lt;/em&gt;), or if the first 21 numbers are maybe not enough, &lt;em&gt;testIntegers&lt;/em&gt;(&lt;em&gt;x&lt;/em&gt;, '&lt;em&gt;rng&lt;/em&gt;' = 0 .. 30) to test the first 31 numbers. It will return &lt;em&gt;true&lt;/em&gt; in both cases, because these entries are all integers. Both of these are relatively quick. More importantly, if we run &lt;em&gt;forget&lt;/em&gt;(&lt;em&gt;x&lt;/em&gt;) in order to clear the set values of &lt;em&gt;x&lt;/em&gt; and use new initial conditions 1, 2, 3, then computation of &lt;em&gt;x&lt;/em&gt;(5) will already trigger stopping the loop.&lt;/p&gt;
&lt;p&gt;In this way you get the best of both worlds: it's reasonably fast if indeed the sequence consists of only integers (because the in-memory size of the integers involved is a lot smaller than the size of fractions), and typically even faster if there are non-integer values.&lt;/p&gt;
&lt;p&gt;If you'd be OK with tracking integer or non-integer status only until the values get too large to fit into an 8-byte signed integer (about 10^18), we could look at optimizing the code further to be able to use the Compiler.&lt;/p&gt;
&lt;p&gt;Hope this helps,&lt;/p&gt;
&lt;p&gt;Erik Postma&lt;br&gt;Maplesoft.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Hi Pete3431,&lt;/p&gt;
&lt;p&gt;I'd like to try to set things up in such a way that once a non-integer value is produced, it doesn't need to continue searching and stops immediately. If you prefer the method of defining a procedure with remember table, then we can keep the definition of &lt;em&gt;x&lt;/em&gt; as is (including assigning to &lt;em&gt;x&lt;/em&gt;(0), &lt;em&gt;x&lt;/em&gt;(1), &lt;em&gt;x&lt;/em&gt;(2)). After that, I would do:&lt;/p&gt;
&lt;p&gt;testIntegers := proc(seqname :: appliable,&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; {rng :: range(integer) := 0 .. 20},&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; $)&lt;br&gt;local i;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for i from lhs(rng) to rhs(rng) do&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not type(seqname(i), 'integer') then&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; return false;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end if;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end do;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;br&gt;end proc;&lt;/p&gt;
&lt;p&gt;Then you can ask for &lt;em&gt;testIntegers&lt;/em&gt;(&lt;em&gt;x&lt;/em&gt;), or if the first 21 numbers are maybe not enough, &lt;em&gt;testIntegers&lt;/em&gt;(&lt;em&gt;x&lt;/em&gt;, '&lt;em&gt;rng&lt;/em&gt;' = 0 .. 30) to test the first 31 numbers. It will return &lt;em&gt;true&lt;/em&gt; in both cases, because these entries are all integers. Both of these are relatively quick. More importantly, if we run &lt;em&gt;forget&lt;/em&gt;(&lt;em&gt;x&lt;/em&gt;) in order to clear the set values of &lt;em&gt;x&lt;/em&gt; and use new initial conditions 1, 2, 3, then computation of &lt;em&gt;x&lt;/em&gt;(5) will already trigger stopping the loop.&lt;/p&gt;
&lt;p&gt;In this way you get the best of both worlds: it's reasonably fast if indeed the sequence consists of only integers (because the in-memory size of the integers involved is a lot smaller than the size of fractions), and typically even faster if there are non-integer values.&lt;/p&gt;
&lt;p&gt;If you'd be OK with tracking integer or non-integer status only until the values get too large to fit into an 8-byte signed integer (about 10^18), we could look at optimizing the code further to be able to use the Compiler.&lt;/p&gt;
&lt;p&gt;Hope this helps,&lt;/p&gt;
&lt;p&gt;Erik Postma&lt;br&gt;Maplesoft.&lt;/p&gt;</description>
      <guid>129498</guid>
      <pubDate>Tue, 10 Jan 2012 02:45:16 Z</pubDate>
      <itunes:author>epostma</itunes:author>
      <author>epostma</author>
    </item>
  </channel>
</rss>