Comments (10)
Related: https://docs.basex.org/wiki/Higher-Order_Functions_Module#hof:scan-left
from qtspecs.
PRs are always helpful.
from qtspecs.
Looks like these could be defined in terms of the existing fold functions?
from qtspecs.
Looks like these could be defined in terms of the existing fold functions?
With a scan, the intermediate results are returned as well. While it’s possible to generate a sequence with the intermediate results with fold, it’s more convenient to have a custom function for it.
I know that Dimitre will disagree, but as hardly anyone uses fold-right
in practice, a single scan
function should suffice (e.g., as Kotlin has done it).
from qtspecs.
Thanks for replying. Agree about fold-right! And in the XSLT 3 course i run, some people have said they'd struggled for ages with fold-left() before having an example and working through it. But i am not sure that they would find scan() any easier, and having two functions to learn instead of one is a burden sometimes. I’d vote for less-is-more on this one.
from qtspecs.
Thanks for replying. Agree about fold-right! And in the XSLT 3 course i run, some people have said they'd struggled for ages with fold-left() before having an example and working through it. But i am not sure that they would find scan() any easier, and having two functions to learn instead of one is a burden sometimes. I’d vote for less-is-more on this one.
Yes, learning folds may take a while. Until today, I don’t understand how our spec tries to explain how they work (and I wish we would revise the text; related: #864 (comment)). Instead, I learned folding by looking at other languages (or books ;).
My feeling is that once you’ve understood folds, scans are easy. Maybe we can find a better name, though.
from qtspecs.
I have certainly found the need for something equivalent to scan-left. I agree that it's very difficult to explain these functions to users (and that's especially true for fold-right, which I still struggle with myself) and we should certainly try to do a better job on explanation (especially by example), but I don't think that's an absolute reason for leaving them out.
from qtspecs.
Here is more about the use-cases for the scan functions: https://www.reddit.com/r/haskell/comments/s737lq/scan/
And especially here: https://www.cs.cmu.edu/~guyb/papers/Ble93.pdf
from qtspecs.
As there seem to be no more comments, I will proceed to creating a PR.
Any objections?
from qtspecs.
Submitted the PR, can be viewed here now: #957
from qtspecs.
Related Issues (20)
- XQFO Code in the Rules sections HOT 7
- fn:subsequence-where: equivalent `fn:slice` expression HOT 2
- Simulating Objects: Performance HOT 64
- Errors in forming function items (continued) HOT 4
- fn:has-attributes HOT 5
- Rewrite spec of deep lookup operator: edits
- XPath Appendix I: Comparisons
- XQFO: Context item → value
- fn:parse-json, fn:json-to-xml: `number-parser`, `fallback`
- Rules for context-dependent function references in XSLT (e.g. regex-group#1) HOT 1
- Identify optional arguments in callback functions HOT 41
- Add position argument to scan-left and scan-right HOT 3
- fn:reduce (or fn:fold without initial value) HOT 5
- Numeric Comparisons HOT 5
- character sequence constructor 'a' to 'z' HOT 21
- Transitive closure on non-nodes HOT 2
- Invisible-xml - missing details HOT 1
- Invoking maps & arrays: allow sequences? HOT 5
- regular expression addition - lookbehind assertions and lookahead assertions HOT 2
- regular expression addition - comments HOT 4
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.