Giter Site home page Giter Site logo

Comments (10)

ChristianGruen avatar ChristianGruen commented on July 18, 2024 1

Related: https://docs.basex.org/wiki/Higher-Order_Functions_Module#hof:scan-left

from qtspecs.

ChristianGruen avatar ChristianGruen commented on July 18, 2024 1

PRs are always helpful.

from qtspecs.

liamquin avatar liamquin commented on July 18, 2024

Looks like these could be defined in terms of the existing fold functions?

from qtspecs.

ChristianGruen avatar ChristianGruen commented on July 18, 2024

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.

liamquin avatar liamquin commented on July 18, 2024

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.

ChristianGruen avatar ChristianGruen commented on July 18, 2024

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.

michaelhkay avatar michaelhkay commented on July 18, 2024

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.

dnovatchev avatar dnovatchev commented on July 18, 2024

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.

dnovatchev avatar dnovatchev commented on July 18, 2024

As there seem to be no more comments, I will proceed to creating a PR.

Any objections?

from qtspecs.

dnovatchev avatar dnovatchev commented on July 18, 2024

Submitted the PR, can be viewed here now: #957

from qtspecs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.