1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-10 07:42:27 +08:00

feat: add RangeWithStep function

This commit is contained in:
dudaodong
2023-03-06 18:05:58 +08:00
parent 28d0428b50
commit 51a6912eb3
3 changed files with 50 additions and 0 deletions

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]
}