xsl-list
[Top] [All Lists]

Re: [xsl] Show all permutations of N coins ... without using recursion?

2013-09-01 05:41:59
On 31/08/2013 17:18, Costello, Roger L. wrote:
Jacob Malý wrote:

  You just iterate from 1 to 2^N, each step gives
you one output sequence, you just have to convert
it to the desired format.

Thank you very much!

I did as you suggested and it works great.

The below stylesheet shows the permutations of N coins, implemented in two 
ways: (1) using recursion, and (2) using iteration.

By the way, I recently learned about the xsl:iterate instruction. Wow! Such a 
useful instruction. How have I lived without it all these years.

Of course you're really using a different _syntax_ for a recursive function rather than not using recursion. As noted on the spec xsl:iterate is essentially a syntactic wrapper around a tail recursive function. It may not be implemented that way, but functions that you write as tail recursive may not be implemented via recursion either.

David


--
google plus: https:/profiles.google.com/d.p.carlisle

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>