mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 10:36:43 +00:00
Created a Tuple struct as some of the new functions require you to return a new slice with two fields which is the result of the new functions Created the Join, JoinProjection, Range, SumMap, Zip functions, ecah fuction is documented with how it works and had a unit test or maybe more
16 lines
351 B
Go
16 lines
351 B
Go
package underscore
|
|
|
|
// Creates a sequence of numbers, i.e. u.Range(0, 3) = [0 1 2 3], while u.Range(3, 0) = [3 2 1 0]
|
|
func Range(start int, end int) (result []int) {
|
|
if start < end {
|
|
for i := start; i <= end; i++ {
|
|
result = append(result, i)
|
|
}
|
|
} else {
|
|
for i := start; i >= end; i-- {
|
|
result = append(result, i)
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|