Add reduce/fold Expression #8353
Conversation
…ist elements into a single result, and add reduced value to access the value within reduce expressions
sovdeeth
left a comment
There was a problem hiding this comment.
looking great
just some minor stuff
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
sovdeeth
left a comment
There was a problem hiding this comment.
some minor tweaks, otherwise looks great!
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
sovdeeth
left a comment
There was a problem hiding this comment.
looks great
i'll handle the registration api stuff in a later pr that updates all the stream-like syntax (filter/map/sort)
APickledWalrus
left a comment
There was a problem hiding this comment.
Great work so far, I love this idea!
…to feature/reduce
Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com> Co-authored-by: Patrick Miller <apickledwalrus@icloud.com>
…to feature/reduce
Absolutionism
left a comment
There was a problem hiding this comment.
Should be moved to the org.skriptlang.skript.bukkit.misc package.
Should also be using SyntaxRegistry as Skript.registerExpression is deprecated
See
(It also isn't a bukkit syntax) |
|
I apologize, I suffer from “I didn’t see that and I’m dumb” syndrome |
APickledWalrus
left a comment
There was a problem hiding this comment.
Just about ready. Great work so far!
Co-authored-by: Patrick Miller <apickledwalrus@icloud.com>
7da4411
into
SkriptLang:dev/feature
* Add Origin-applying SyntaxRegistry (#8376) * Add reduce/fold Expression (#8353) * Location with Yaw/Pitch (#8351) * Test framework: support directory resources (#8377) * Test framework: support directory resources * use walkFileTree * oops forgot imports * Pattern Stringification Customization (#8391) * Implement StringificationProperties * Package cleanup * Fix missing call in GroupPatternElement stringification (#8449) Fix GroupPatternElement stringification * Stabilise damage source experiment (#8414) * Stabilise damage source experiment * Replace STABLE with MAINSTREAM * Remove experiment from damage source test * Remove unstable API usage supression --------- Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> * Add vector(n) (#8412) * Init commit * Fix not registering overloading for old namespaces * Standardize Module usage + add child modules (#8346) * child module support * Create child modules and move over existing Bukkit addon modules. * Update newer modules * Clean up * Requested changes and additional conversions Just tags left! * convert last module * standardize package hierarchies * remove bad imports * fix bad examples * Replace ChildAddonModule with HierarchicalAddonModule, move display/interaction modules into entity module, few other requested changes * requested changes * varargs registrar (thanks blue!) * Use addonmodule javadocs to point to other useful tools * Requested Changes * Requested Changes * Added option to compress file backups (#8396) * Add fast path for integer strings in variable name comparator (#8483) * Initial conversion * Some more conversion * fixes * Update StructCommand.java * no tests --------- Co-authored-by: Patrick Miller <apickledwalrus@icloud.com> Co-authored-by: mibers <midaswoah2@gmail.com> Co-authored-by: _tud <98935832+UnderscoreTud@users.noreply.github.com> Co-authored-by: devdinc <234956748+devdinc@users.noreply.github.com> Co-authored-by: Tiberiu Sabău <96194994+tibisabau@users.noreply.github.com> Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com> Co-authored-by: Pesek <42549665+Pesekjak@users.noreply.github.com>
Problem
This adds the first class function 'reduce/fold' as an expression applies an operation to accumulate list elements into a single result, and add reduced value to access the value within reduce expressions
Solution
ExprReducewas made similarly toExprFilterandExprTransform, except I did not use any of the smart flatMap and Stream usage because I wouldn't know how to do that.ExprReducedValuewas made similarly toExprInputwithout type support I guess. I mainly went off of intuitionTesting Completed
src/test/skript/tests/syntaxes/expressions/ExprReduce.sk
Supporting Information
none
Completes: none
Related: none
AI assistance: Google search AI overview once or twice (?) I also previously used AI when I was younger to learn Java.