-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Taken from Spectrum.
This is how i first imagined the syntax:
FOR accumulator, variable IN "{" iterator-set [, ...] "}"
REDUCE output-expr ;
Note that this doesn't allow defining arbitrary aggregate functions, but rather executing them, just like FOR.
Example 1
FOR sentence = "", word IN { "hello", "world" }
REDUCE (
SELECT result ++ " " ++ word
)
This would give a result of hello world.
We can also access the current index by using _index and the original set using_source
FOR sentence = "", word IN { "hello", "world" }
REDUCE (
SELECT (
(<str>(SELECT count(_source)) ++ " ") IF _index = 1 ELSE "")
++ result ++ " " ++ word ++ " "
)
Result: 2 hello world
Metadata
Metadata
Assignees
Labels
No labels