Re: [xsl] Use pure XPath to test a sequence for being a valid Fibonacci sequence

Subject: Re: [xsl] Use pure XPath to test a sequence for being a valid Fibonacci sequence
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 31 Jan 2007 20:05:49 +0100
Michael Kay wrote:
Not sure why you are using index-of (or some, for that matter). It looks to
me like

$fib[1] = 0 and $fib[2] = 1 and
every $i in 2 to count($fib) satisfies
$fib[$i] = $fib[$i - 1] + $fib[$i - 2]

Aha! (erlebnis)
Thanks, Michael. It was one of those problems I can look at forever without 'seeing' the inverse-logic algorithm you present me here. Instead of going through the objects and 'satisfying' from each object (hence trying index-of to find near-by objects), I should've used a simple range operator and indices instead.


This definitely clears up my mind for several lock-up problems (and I shouldn't stay up too late ;)

(or some, for that matter)
That was a typo, the example problem only works, of course, with 'every', I have some other cases where 'some' is required.


Cheers! -- Abel

Current Thread