SequenceUsing for all types
zhiburt opened this issue · 1 comments
zhiburt commented
Generates sequence like in #70 for all types:
It seems to me, It'd be fine for many reasons such as testing and convenience.
I present some examples.
For Structure.
Cars{}.SequenceWith(3, func(i int) Car {
return Car{Number: i}
})
// Cars{Car{0}, Car{1}, Car{2}}
For strings.
pie.Strings{}.SequenceWith(3, func(i int) string {
prefix := "id_"
return prefix + i
})
// pie.Strings{"id_0", "id_1", "id_2"}
It can be important to make a special sequence of numbers, and it could help.
pie.Ints{}.SequenceWith(3, func(i int) int {
return i * 4
})
// pie.Ints{0, 4, 8}
elliotchance commented
This makes sense. I’d prefer the function to be called SequenceUsing, so it’s consistent with other function naming.