Intro
Let's say I have the following sequence:
var ls = new[]{10, 20, 30, 40};
I'd like to apply a function to:
- The entire sequence
- The entire sequence except the first
- The entire sequence except the second
- ...
Implementation
Here's one approach to implementing this:
IEnumerable<U> f_a<T,U>(IEnumerable<T> seq, Func<IEnumerable<T>, U> proc) =>
Enumerable
.Range(0, seq.Count())
.Select(n => seq.Skip(n))
.Select(proc);
Examples
Example: join the subsets:
Example: sum the subsets:
Example: sum the subsets and show the seq:
(Examples generated in dotnet-interactive in vscode.)
Question
Is there already a built-in function that basically performs f_a above?
If not, would you recommend another approach to implementing f_a?
Does the equivalent of f_a exist in libraries from other languages?


