feat: add RangeWithStep function

This commit is contained in:
dudaodong committed 2023-03-06 18:05:58 +08:00
1 parent 28d0428b50
commit 51a6912eb3
3 files changed
+50

No files matched your search

+18
View File
@@ -203,3 +203,21 @@ func ExampleRange() {
// [-4 -3 -2 -1]
// [1 2 3 4]
}
func ExampleRangeWithStep() {
result1 := RangeWithStep(1, 4, 1)
result2 := RangeWithStep(1, -1, 0)
result3 := RangeWithStep(-4, 1, 2)
result4 := RangeWithStep(1.0, 4.0, 1.1)
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
// Output:
// [1 2 3]
// []
// [-4 -2 0]
// [1 2.1 3.2]
}