Skript icon indicating copy to clipboard operation
Skript copied to clipboard

Add list transformation expression and effect

Open sovdeeth opened this issue 1 year ago • 2 comments

Description

Adds transformation/mapping syntaxes for lists:

(transform|map) %~objects% (using|with) <.+>
%~objects% (transformed|mapped) (using|with) \\[<.+>\\]
%~objects% (transformed|mapped) (using|with) \\(<.+>\\)

The effect only works on variable lists, but allows the indices of the list to be retained (if the expression is singular). The expression works on any list, but naturally cannot retain indices. If the expression is plural, this acts like flatMap, where x,y,z transformed with (a, b) will return a(x), b(x), a(y), b(y), a(z), b(z).

Also allows ExprFilter to use () as grouping markers as well as [].

I'm still not convinced on the syntax wording and would like opinions and alternatives!

(i know i touched ClassInfo but i'm not cleaning all of that up!)


Target Minecraft Versions: any Requirements: none Related Issues: closes #3573

sovdeeth avatar Sep 01 '24 23:09 sovdeeth

I think this needs a much better description and examples because I honestly can't work out what it's actually for even when I'm reading the code for it.

Moderocky avatar Sep 02 '24 08:09 Moderocky

I think this needs a much better description and examples because I honestly can't work out what it's actually for even when I'm reading the code for it.

I would welcome suggestions! I'm not really sure how i should go about improving the descriptions because I don't really know where the fault is. It makes sense to me, which is obvious otherwise i wouldn't have written it this way, but I'm not sure where it's failing for others.

To explain it in java terms, this expression/effect is equivalent to Stream#flatMap() where it takes in a function and applies to to each element in the list.

sovdeeth avatar Sep 04 '24 01:09 sovdeeth