interspace<R extends T> method

Iterable<T> interspace<R extends T>(
  1. R r
)

insert value between each element

example

[1,2,3,4,5].interspace(-1) // [1,-1,2,-1,3,-1,4,-1,5]

Implementation

Iterable<T> interspace<R extends T>(R r) => List.generate(
    length + length - 1, (i) => i % 2 == 0 ? elementAt(i ~/ 2) : r);