Add enumerate
This commit is contained in:
parent
9447daed1d
commit
d42862a485
@ -75,3 +75,12 @@ func Range(args...int) ([]int) {
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
func Enumerate(iter interface{}) interface{} {
|
||||
viter := reflect.ValueOf(iter)
|
||||
enum := make([][]interface{}, viter.Len())
|
||||
for i:=0; i < viter.Len(); i++ {
|
||||
enum[i] = []interface{}{i, viter.Index(i).Interface()}
|
||||
}
|
||||
return enum
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user