mirror of https://github.com/01-edu/public.git
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.
24 lines
304 B
24 lines
304 B
4 years ago
|
package correct
|
||
5 years ago
|
|
||
4 years ago
|
// returs the node in a given position
|
||
5 years ago
|
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
|
||
|
}
|