You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
package correct |
|
|
|
// returs the node in a given position |
|
func ListAt(l *NodeL, nbr int) *NodeL { |
|
index := 0 |
|
count := 0 |
|
head := l |
|
|
|
for head != nil { |
|
index++ |
|
head = head.Next |
|
} |
|
if nbr <= index { |
|
for l != nil { |
|
if count == nbr { |
|
return l |
|
} |
|
count++ |
|
l = l.Next |
|
} |
|
} |
|
return nil |
|
}
|
|
|