Giter Site home page Giter Site logo

Comments (6)

michaelhkay avatar michaelhkay commented on July 18, 2024

I think that users who are sophisticated enough to be using fold/reduce functions have sufficient brain power to implement this for themselves.

from qtspecs.

MarkNicholls avatar MarkNicholls commented on July 18, 2024

I'm too unsophisticated to completely understand the issue.

I'm too lazy to implement it myself, and too incompetent to get it right first time or possibly second time.

I prefer an explicit named fold and reduce...I tend not to like overloaded functions, because typos type check and its a nightmare to find the error.

this would be a particularly wrinkly overload in my opinion.

What happens if the sequence over which you reduce is empty is the other issue?

I DONT use folds in xslt...I find them ugly and incomprehensible to most other developers, where other (xslt) constructs feel less scary.

in fp languages I nowadays prefer direct recursion, because syntactically it just seems clearer whats going on, so in xslt I would prefer iterate, which i suppose is just fold gone "smart casual" (that probably wont translate even to an english speaker).

from qtspecs.

ChristianGruen avatar ChristianGruen commented on July 18, 2024

I think that users who are sophisticated enough to be using fold/reduce functions have sufficient brain power to implement this for themselves.

@michaelhkay I’m not so sure about this. I would rather assume that it’s more obvious how to rewrite reduce to fold. reduce allows you to get rid of special-casing around the initial action (providing an empty sequence, or the identity element – 0 for additions, 1 for multiplications – is not always sufficient). I’m just not sure if it’s a good idea to bloat the spec with 4 new functions for every higher-order feature we add, which can possibly be processed from left-to-right and right-to-left, and run for sequences or arrays.

I prefer an explicit named fold and reduce...I tend not to like overloaded functions, because typos type check and its a nightmare to find the error.

What happens if the sequence over which you reduce is empty is the other issue?

@MarkNicholls Out of interest, as you’re most probably the one among us who’s most proficient in F#, are the following versions for F# correct, or would you write them differently?

List.fold   (fun acc x -> acc * x) 1 [1..5]
List.reduce (fun acc x -> acc * x) [1..5]

In Kotlin, I assume the syntax would be similar:

(1..5).fold(1) { acc, x -> acc * x }
(1..5).reduce { acc, x -> acc * x }

In our language, it would be:

fold-left(1 to 5, 1, fn($acc, $x) { $acc * $x })
reduce(1 to 5, fn($acc, $x) { $acc * $x })

For those trivial cases, though, it would obviously a waste of energy to add reduce.

from qtspecs.

MarkNicholls avatar MarkNicholls commented on July 18, 2024

@ChristianGruen

yes....you would write

List.fold (*) 1 [1..5]
just be be fancy and show off to your C# mates

my kotlins too rusty to comment,

(and to be fair, reduce is pretty obvious to derive from fold...so maybe its gold plating)

from qtspecs.

ChristianGruen avatar ChristianGruen commented on July 18, 2024

List.fold (*) 1 [1..5] just be be fancy and show off to your C# mates

;-) Thanks. In XPath, we now also have:

fold-left(1 to 5, 1, op('*'))

from qtspecs.

ndw avatar ndw commented on July 18, 2024

The CG agreed to close this issue without further action at meeting 072

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.