Re: [xsl] Re: Seeking an elegant XSLT function to check that a pair of numeric ranges are consecutive

Subject: Re: [xsl] Re: Seeking an elegant XSLT function to check that a pair of numeric ranges are consecutive
From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 25 May 2024 17:37:19 -0000
Oops, I got them backwards, of course.

Copy/paste error. That's what unit tests are for.

Enough! Wendell

On Sat, May 25, 2024 at 1:21b/PM Wendell Piez wapiez@xxxxxxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

>     <xsl:function name="r:do-ranges-connect" as="xs:boolean" xmlns:r="
> roger.org">
>         <xsl:param name="previous-range"/>
>         <xsl:param name="current-range"/>
>         <xsl:sequence select="
>                 tokenize($current-range, '-')[last()] ! number() =
>                 (tokenize($previous-range, '-')[1] ! number() + 1)"/>
>     </xsl:function>
>
> NB this returns true from '1-2','3-4-5'.
>
> Enjoy, Wendell
>
>
> On Sat, May 25, 2024 at 1:05b/PM Roger L Costello costello@xxxxxxxxx <
> xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>> Wow! Below is David Carlisle's solution. He solved the problem in a
>> single statement. Totally mind-blowing! Pure elegance!
>>
>> <xsl:function name="f:do-ranges-connect" as="xs:boolean">
>>     <xsl:param name="previous-range"/>
>>     <xsl:param name="current-range"/>
>>
>>     <xsl:sequence select="xs:int(replace($previous-range,'.*-',''))+1=
>>
>> xs:int(replace($current-range,'-.*',''))"/>
>> </xsl:function>
>>
>>
>>
>
> --
> ...Wendell Piez... ...wendell -at- nist -dot- gov...
> ...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org...
> ...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/174322> (by
> email <>)
>


--
...Wendell Piez... ...wendell -at- nist -dot- gov...
...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org...
...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...

Current Thread