xsl-list
[Top] [All Lists]

Re: Sudoku - A solution in XSLT 2

2006-02-16 05:40:43

Ah finally xsl being put to something useful!!

(Doesn't seem to use templates really so probably could be converted to
keep the xquery folks happy as well)

I think that you can replace

some $x in position() satisfies $x =

by 

position()

in all cases

although if I read it right 

        <xsl:param name="index" as="xs:integer+"/>
can be

        <xsl:param name="index" as="xs:integer"/>

in several places, I think it's just a single number isn't it?

which means that fn:getGroup can be simplified to

<xsl:function name="fn:getGroup" as="xs:integer+">
        <xsl:param name="board" as="xs:integer+"/>
        <xsl:param name="index" as="xs:integer"/>
        <xsl:variable name="group" select="$groups[$index]"/>
        <xsl:sequence select="$board[for $x in position()  return $groups[$x]= 
$group]"/>
</xsl:function>


where $groups is a global variable

<xsl:variable name="groups" select="(
1,1,1,  2,2,2,  3,3,3,
1,1,1,  2,2,2,  3,3,3,
1,1,1,  2,2,2,  3,3,3,

4,4,4,  5,5,5,  6,6,6,
4,4,4,  5,5,5,  6,6,6,
4,4,4,  5,5,5,  6,6,6,

7,7,7,  8,8,8,  9,9,9,
7,7,7,  8,8,8,  9,9,9,
7,7,7,  8,8,8,  9,9,9
)" as="xs:integer+"/>



David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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