Skip to content

Instantly share code, notes, and snippets.

@tirnovar
Created November 1, 2023 20:33
Show Gist options
  • Select an option

  • Save tirnovar/cbe33e8026d81a4d78435309b611605b to your computer and use it in GitHub Desktop.

Select an option

Save tirnovar/cbe33e8026d81a4d78435309b611605b to your computer and use it in GitHub Desktop.
(series as list) =>
[
bfr = List.Buffer(series),
len = List.Count(bfr),
additions = List.Combine(
List.Generate(
() => [
id = 0,
currVal = bfr{id},
others = List.Skip(bfr, id + 1)
],
each _[id] < len,
each [
id = [id] + 1,
currVal = bfr{id},
others = List.Skip(bfr, id + 1)
],
each
[
vl = [currVal],
countr = List.Count([others]),
lst = [others],
iterator = List.Transform(List.Numbers(0, countr), each List.Skip(lst, _)),
accumulator = List.Union(
List.Transform(iterator, each List.Accumulate(_, {vl}, (s, c) => s & {(List.Last(s) & c)}))
)
][accumulator]
)
)
& {List.Last(bfr)}
][additions]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment