- From: Dimitre Novatchev <dnovatchev@gmail.com>
- Date: Mon, 30 Nov 2020 07:28:23 -0800
- To: Dave Pawson <dave.pawson@gmail.com>, public-xslt-40@w3.org
- Cc: Martin Honnen <martin.honnen@gmx.de>, Dimitre Novatchev <dnovatchev@gmail.com>
- Message-ID: <CAK4KnZeuCWS3VBkjjU=HE7-Sf=8NcfXqbZEOHUBCq0vz02w5GA@mail.gmail.com>
> I'm with Martin here. > Dimitre, are you going overboard with your higher order functions? > Is it *widely* needed in xSLT/XPATH? @Dave Pawson <dave.pawson@gmail.com> , Martin's comment was about the syntax of the function definition (which is now corrected), not about the usability and need of it. In fact, I provided one use-case (the for efficient partitioning in the implementation of the quick-sort algorithm). Such functions are defined in other languages and not for glossing them... For a few good examples of the partition function in Haskell, see: http://zvon.org/other/haskell/Outputlist/partition_f.html > This isn't Lisp. In the past we used to say: "This isn't Javascript", but the implementors of Saxon.JS have been learning a lot from Javascript. In fact, in order to become a good, first-class citizen of the family of modern programming languages, XPath has a lot to learn from them. Thanks, Dimitre On Mon, Nov 30, 2020 at 1:51 AM Dave Pawson <dave.pawson@gmail.com> wrote: > I'm with Martin here. > Dimitre, are you going overboard with your higher order functions? > Is it *widely* needed in xSLT/XPATH? > This isn't Lisp. > > regards > > On Mon, 30 Nov 2020 at 09:36, Martin Honnen <martin.honnen@gmx.de> wrote: > > > > Am 29.11.2020 um 23:53 schrieb Dimitre Novatchev: > > > Now that we have thetuple/ record type, we can have some very useful > > > functions on collections (both sequences and arrays) that return more > > > than one result, > > > or to say it in other words, return a tuple of Nthings, whereN > 1. > > > > > > fn:partition-at($seq as item()*, > > > > > > $n as xs:integer) > > > > > > as tuple(item()*, item()*) > > > > I am having a hard time following the different suggestions and merging > > them mentally, aren't tuples supposed to have a field name in any case > > as they are just specialized maps? > > https://www.saxonica.com/qt4specs/XP/xpath-40-diff.html#id-tuple-test > > > > That tuple of N things looks just like an array of (N) things to me. > > > > > > > > , returns a tuple of two sequences, the first of which is > > > > > > subsequence($seq, 1, $n), and the second is: > > > > > > subsequence($seq, $n +1) > > > > > > > Or how would one access a the first and second field in the result of > > fn:partition-at($seq, $n)? > > > > > > > > > > > > > -- > Dave Pawson > XSLT XSL-FO FAQ. > Docbook FAQ. > > -- 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 Monday, 30 November 2020 15:28:48 UTC