Comments (9)
fn:intersperse($div/span, ',')
Is that really better than tail($div/span!(',', .))
?
from qtspecs.
In the past, our users were asking for a function that works similar to fn:string-join
, but can be applied to sequences. Similar to other sequence functions (including fn:head
, fn:tail
, fn:subsequence
, fn:remove
, and others that can be realized with filter expressions), the new function could make common tasks more convenient and accessible by a single function (i.e., a function in which you have to supply the input sequence only once).
An equivalent expression for the proposed function would be:
head($sequence), tail($sequence) ! ($separator, .)
from qtspecs.
The separator
attribute on xsl:value-of
has certainly been a great invention, and I've proposed adding a separator
attribute to xsl:for-each
, so the use case certainly exists.
The typical user today writes something like $sequence ! (., (if (position() != last()) then $separator else ()))
which is very ugly, and very expensive unless optimized, and makes streamed execution difficult.
So I agree this function would be useful.
from qtspecs.
Alternative names: fn:item-join
, fn:sequence-join
.
What are your favorites?
from qtspecs.
I like "intersperse". "Join" is wrong, nothing is being joined. "Inject" would also work.
from qtspecs.
+1 to "intersperse" - as it suggests that something is being inserted between the items. Possibly, "interpose" or "delimit"?
from qtspecs.
In the meeting, we discussed an inverse function for fn:intersperse
. Maybe https://qt4cg.org/specifications/xpath-functions-40/Overview-diff.html#func-array-partition already fills the gap?
It works slightly different at the moment, as it includes the separating item in the result, but that behavior could possibly be controlled with an additional option.
from qtspecs.
I found the discussion rather confusing.
If the separators are single items, the problem is trivial, just remove all the items at even-numbered positions.
Otherwise, the problem is only soluble if the separator sequence can be distinguished from the other items; you're then looking to remove all subsequences that "match" some supplied sequence. Which I guess gets us back to functions for comparing sequences (for which one approach might be a generalised deep-equal).
But could someone tell me the use case?
from qtspecs.
The change has been accepted and implemented. Therefore closing the issue.
from qtspecs.
Related Issues (20)
- XQFO: Rendering of new/updated functions HOT 2
- CSV parsing: in call of get($R, $Z), what if $R is out of range
- Array filter: Positional access HOT 2
- Reserved Function Names: item, empty-sequence
- An edge case with coercion in 1.0 compatibility mode HOT 2
- fn:hash, CRC-32: Describe output HOT 7
- Detailed comments on math:e, sinh(), cosh(), tanh() HOT 3
- Residual references to union(A, B)
- new function - fn:tail-recurse a function to allow users to hand roll their recursion and guarentee tail recursion. HOT 11
- Attribute priority for xsl:accumulator-rule HOT 1
- Generalization of Deep Updates HOT 2
- Rendition of RFC2119 terms HOT 1
- Seralization Parameters: Indentation, Whitespace, Newlines HOT 2
- Function Identity: Treating function items with identical bodies HOT 12
- QT4CG-078-01 fn:unparsed-text-lines, normalize newlines HOT 4
- XSLT on-no-match="shallow-copy-all" - revised rules HOT 3
- XSLT xsl:next-match with select attribute HOT 1
- $sequence-of-maps ? info() HOT 4
- Node constructor vs. otherwise/map constructor HOT 3
- XSLT: system-property('xsl:xpath-version')
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qtspecs.