Tuesday 1 May 2012

Print Triangle using XQUERY


Pass the number of rows as the local:star function argument $num

declare function local:star($num as xs:integer)
{
for $a in 1 to $num
return ((for $space in 1 to ($num - $a)
          return ''),for $star in 1 to $a
        return ('*'),'
')
};
local:star(5)

No comments: