qi
qi copied to clipboard
Review `loop2` and other looping forms
loop2
seems odd. It appears to expect specifically two inputs, and produces specifically one output:
- the first input is a list of inputs
- the second input is the in-progress result
- the output is a single value
Should it instead support the inputs being any number of values? Should the output be any number of values? We probably can't do both here since there would be no way to differentiate inputs to be processed from in-progress outputs. Most likely, the output should be a single value (including a list), while the input should be any number of values (and the in-progress result can be fed forward as the first input).
More generally, when are loop
and loop2
useful? Most existing usecases appear to be covered by amp
and the folds, <<
and >>
. Finally, feedback
seems to cover remaining cases. When do we need loop
and loop2
? Is it perhaps that these could be considered lower-level forms with which to implement amp
and >>
/ <<
?