- From: Dimitre Novatchev <dnovatchev@gmail.com>
- Date: Sun, 29 Nov 2020 14:19:38 -0800
- To: Michael Kay <mike@saxonica.com>
- Cc: public-xslt-40@w3.org
- Message-ID: <CAK4KnZedaZjU5bTeZSpwcYdptU9Om5XD_q3Agzg57AVheO6R6g@mail.gmail.com>
> fn:all() - functional equivalent of the "every" expression > > fn:some() - functional equivalent of the "some" expression > > fn:index-where() - like fn:index-of(), but using an arbitrary predicate rather than a simple equality test > > fn:items-before(), items-after(), items-until(), items-from() - enables selection of a subsequence before/after the first item matching a predicate. Provided because this is notoriously hard to to at > the moment, and higher-order functions make it easy. > > fn:highest(), fn:lowest() - unlike min/max, these return the nodes (typically) that contain the min/max values rather than the min/max themselves. Much more efficient than first finding the max and then > finding which element it came from. What is the reason not to provide the same functionality for arrays? Thanks, Dimitre On Fri, Nov 27, 2020 at 11:30 AM Michael Kay <mike@saxonica.com> wrote: > Welcome! > > The current list of new and changed functions I've included in the F&O > proposal is as follows: > > > https://htmlpreview.github.io/?https://github.com/qt4cg/qtspecs/blob/master/specifications/xpath-functions-40/html/Overview-diff.html > > fn:stack-trace() - seems useful and general enough to put in the spec > rather than making it an extension function > > fn:is-NaN() - a simple utiltiy function, included because the standard > ways of doing this ($X ne $X) are so obscure > > fn:format-number() - allow the decimal format name to be supplied as an > xs:QName rather than a string, to remove context dependency > > fn:characters() - split a string into characters; included because the > workaround (string-to-codepoints() ! codepoints-to-string()) is bizarre > > fn:replace-with() - replace but supplying the replacement string as a > function - included because when you've discovered this in Javascript, it > starts to become indispensible (and because we ought to be making more use > of higher-order functions now we have them) > > fn:in-scope-namespaces() - combines fn:in-scope-prefixes() and > fn:namespace-uri-for-prefix() into a single function that returns a map; > included because the current functions are a clumsy workaround and it can > be done so much more elegantly with maps > > fn:identity() - because an identity function is useful with callbacks > > fn:replicate() - handy for string padding in particular > > fn:slice() - allows much more general selective extraction of items from a > sequence. Broadly equivalent to $seq[position() = $integers] but doesn't > suffer from the drawback that the integers are computed in a new context. > > fn:differences() - like deep-equal, but (a) provides options as to how the > comparisons are performed, (b) drops the things deep-equal got wrong (like > stripping comments without combining the resulting adjacent text nodes), > and (c) tells you where the differences were found. Main use case is for > testing (comparison of expected results). > > fn:uniform() - tests if all values in a sequence are the same. Main use > case is for assertions in validation; provided because it's clumsy to write > it by hand, and probably inefficient > > fn:unique() - tests if all values in a sequence are different. Ditto. > > fn:all() - functional equivalent of the "every" expression > > fn:some() - functional equivalent of the "some" expression > > fn:index-where() - like fn:index-of(), but using an arbitrary predicate > rather than a simple equality test > > fn:items-before(), items-after(), items-until(), items-from() - enables > selection of a subsequence before/after the first item matching a > predicate. Provided because this is notoriously hard to to at the moment, > and higher-order functions make it easy. > > fn:highest(), fn:lowest() - unlike min/max, these return the nodes > (typically) that contain the min/max values rather than the min/max > themselves. Much more efficient than first finding the max and then finding > which element it came from. > > map:filter() - selects multiple entries from a map using a predicate. > > map:substitute() - effectively a map operation applied to a map: computes > new values for all the entries by applying a function > > map:index() - constructs a map by indexing a sequence, using a supplied > function to compute the key. (A much more flexible alternative to xsl:key) > > fn:json() - converts any XDM value to a JSON representation. > > I'm also proposing to change eq, distinct-values() etc to do numeric > comparison using the same rules as op:same-key, which makes it transitive. > The only change is when you compare a decimal and a double that are very > close to each other; the double is now converted to a decimal, avoiding > rounding errors, which was the source of the non-transitivity. > > If you have any comments, or suggestions for new functions, open an issue > at https://github.com/qt4cg/qtspecs. I suggest using [FO40] at the start > of the title. > > Michael Kay > Saxonica > > > > -- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence. --------------------------------------- To invent, you need a good imagination and a pile of junk ------------------------------------- Never fight an inanimate object ------------------------------------- To avoid situations in which you might make mistakes may be the biggest mistake of all ------------------------------------ Quality means doing it right when no one is looking. ------------------------------------- You've achieved success in your field when you don't know whether what you're doing is work or play ------------------------------------- To achieve the impossible dream, try going to sleep. ------------------------------------- Facts do not cease to exist because they are ignored. ------------------------------------- Typing monkeys will write all Shakespeare's works in 200yrs.Will they write all patents, too? :) ------------------------------------- Sanity is madness put to good use. ------------------------------------- I finally figured out the only reason to be alive is to enjoy it.
Received on Sunday, 29 November 2020 22:20:02 UTC