@ -2,20 +2,20 @@
### Instructions
### Instructions
Write a function `ListAt` that hav es one pointer to the list, `l` , and an `int` as parameters. This function should print a `Node` of the linked list, depending on the number, `nbr` .
Write a function `ListAt` that tak es one pointer to the list, `l` , and an `int` as parameters. This function should print a `NodeL` in the position `pos` in the linked list .
- In case of error it should print `nil`
- In case of error it should print `nil`
### Expected function and structure
### Expected function and structure
```go
```go
type Node struct {
type NodeL struct {
Data interface{}
Data interface{}
Next *Node
Next *NodeL
}
}
func ListAt(l *Node, nbr int) *Node {
func ListAt(l *NodeL, pos int) *NodeL {
}
}
```
```
@ -33,18 +33,16 @@ import (
)
)
func main() {
func main() {
link := & Node {}
link := & piscine.List {}
ListPushBack(link, "hello")
piscine. ListPushBack(link, "hello")
ListPushBack(link, "how are")
piscine. ListPushBack(link, "how are")
ListPushBack(link, "you")
piscine. ListPushBack(link, "you")
ListPushBack(link, 1)
piscine. ListPushBack(link, 1)
fmt.Println()
fmt.Println(piscine.ListAt(link.Head, 3).Data)
fmt.Println(piscine.ListAt(link.Head, 1).Data)
fmt.Println(ListAt(link, 3).Data)
fmt.Println(piscine.ListAt(link.Head, 7))
fmt.Println(ListAt(link, 1).Data)
fmt.Println(ListAt(link, 7))
}
}
```
```
@ -54,8 +52,8 @@ And its output :
```console
```console
student@ubuntu:~/piscine/test$ go build
student@ubuntu:~/piscine/test$ go build
student@ubuntu:~/piscine/test$ ./test
student@ubuntu:~/piscine/test$ ./test
you
1
hell o
how are
< nil >
< nil >
student@ubuntu:~/piscine/test$
student@ubuntu:~/piscine/test$
```
```