RSSAmplifier

Blog

XSLT: Riding the challenge

To iterate is human, To recurse is divine. Discover another world . . .

dnovatchev.wordpress.comRSS feed ↗10 posts

Latest posts

Mutual Recursion with Anonymous (Inline) Functions in XPath 3

If history repeats itself, and the unexpected always happens, how incapable must Man be of learning from experience. Continue reading

Generators in XPath (Proposal for XPath 4)

What is a generator? Generators are well known and provided out of the box in many programming languages. Per Wikipedia: “In computer science , a generator is a routine that can be used to control the iteration behaviour of a loop . All generators are also iterators . [1] A generator is very similar to a function that returns an array, in that a generator has parameters, can be called, and…

The trouble with XPath‘s fn:fold-right. Laziness in XPath.

The trouble with XPath‘s fn:fold-right.Laziness in XPath. This article discusses the standard XPath 3.1 function fn:fold-right, its definition in the official Spec, its lack of apparent use-cases and its utter failure to reproduce the (lazy) behavior of Haskell’s foldr , Continue reading

[XPath 4.0] Proposal: Short-circuiting functions, function-arity guards and lazy hints

As originally posted on Jan. 2nd 2023 at: the QT site: I. Shortcutting and lazy hints Let us have this expression: let $f := function($arg1 as item()*, $arg2 as item()*) as function(item()*) as item()* { (: Some code here :) } return $f($x) ($y) Evaluating $f($x) produces a function. The actual arity of this resulting function can be any number N >= 0 : If N > 1 there would be arity mismatch…

XPath Gems: Construct the PowerSet of a given set

XPath has become a really powerful functional language. Here is a recent proof of this. Let us see how one can construct with XPath 3.1 the PowerSet of a set. Continue reading

[XPath 4.0] Proposal: Decorators support

A **Decorator** is a tool to wrap (extend/change/modify) the behavior of one or more existing functions without modifying their code. There are many cases when _**we want to handle a call to a specific function `f()` Continue reading

[XPath 4.0]Proposal: Maps with Infinite Number of Keys: Total Maps and Decorated maps

Maps have become one of the most useful tools for creating readable, short and efficient XPath code. However, a significant limitation of this datatype is that a `map` can have only a finite number of keys. In many cases we might want to implement a map that can have more than a fixed, finite number of arguments. Continue reading

Recursion with anonymous (inline) functions in XPath 3.0 — Part II

In my first post about implementing recursion with anonymous functions I provided the following example: let $f := function($n as xs:integer, $f1 as function(xs:integer, function()) as xs:integer ) as xs:integer {if($n eq 0) then 1 else $n * $f1($n -1, Continue reading

Word Ladders, or How to go from “angry” to “happy” in 20 steps

Acknowledgement: To Brandon, the person who attracted my attention to this problem. From Wikipedia, the free encyclopedia: A word ladder (also known as a doublets, word-links, or Word golf) is a word game invented by Lewis Carroll. A word ladder Continue reading

Recursion with anonymous (inline) functions in XPath 3.0

A few days ago Roger Costello asked at the xsl-list forum: Hi Folks Is it possible to do recursion in an anonymous function? Example: I would like to implement an "until" function. It has three arguments: 1. p is a Continue reading