xsl-list
[Top] [All Lists]

RE: [xsl] [XSL] Accessing part of the result tree illustrated with "The Sudoku solver" example.

2007-09-05 00:43:14
But experts as you are, you would have noticed that there is a major 
BUG: even when we have found the solution, the recursion continues!..
So you can get "lucky" and find a solution in the first seconds, then 
run for many minutes uselessly just terminating the recursion.

A Sudoku puzzle can in general have more than one solution, and I think,
without studying it in detail, that your code is written to find all the
solutions. If you only want the first solution, the answer is to do:

<xsl:variable name="all-solutions" as="...">
  ... your algorithm here ...
</xsl:variable>
<xsl:sequence select="$all-solutions[1]"/>

An intelligent pipelined XSLT processor will evaluate $all-solutions lazily,
and will recognize the "[1]" as indicating that after finding the first
element in $all-solutions, no further processing is needed.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
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>
--~--