Comments (6)
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.
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.
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.
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.
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.
The CG agreed to close this issue without further action at meeting 072
from qtspecs.
Related Issues (20)
- Almost all functions in FO that must process multiple string items, can have as a parameter only a single collation HOT 21
- For symmetry, add functions array:scan-left and array:scan-right HOT 1
- fn:apply argument names
- Dangling else syntax ambiguity HOT 9
- add fn:match-groups() function HOT 7
- Tokenization and element constructors HOT 6
- Productions missing ws:explicit
- Ambiguity in XPath EBNF - Lookup with TypeQualifier vs DynamicFunctionCall HOT 9
- 12 div-3 HOT 5
- XPath: type declarations in quantified expressions
- Record Test Subtype Relationship HOT 3
- Function Coercion: Drop Record Tests? HOT 3
- Specification Documents: Editors and Contributors
- fn:parse-uri: Observations HOT 1
- Leading lone slash
- fn:collation-available (editorial)
- Function parameters names: $uri vs. $href HOT 6
- Executable specifications HOT 1
- Variadic System Functions: Principles? HOT 3
- Misleading summary for concat() - "string value"
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.