Browse Source

fix some sintax erros in listat readme

content-update
Augusto 5 years ago
parent
commit
066769728b
  1. 32
      subjects/listat.en.md

32
subjects/listat.en.md

@ -2,20 +2,20 @@
### Instructions
Write a function `ListAt` that haves 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 takes 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`
### Expected function and structure
```go
type Node struct {
type NodeL struct {
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() {
link := &Node{}
link := &piscine.List{}
ListPushBack(link, "hello")
ListPushBack(link, "how are")
ListPushBack(link, "you")
ListPushBack(link, 1)
piscine.ListPushBack(link, "hello")
piscine.ListPushBack(link, "how are")
piscine.ListPushBack(link, "you")
piscine.ListPushBack(link, 1)
fmt.Println()
fmt.Println(ListAt(link, 3).Data)
fmt.Println(ListAt(link, 1).Data)
fmt.Println(ListAt(link, 7))
fmt.Println(piscine.ListAt(link.Head, 3).Data)
fmt.Println(piscine.ListAt(link.Head, 1).Data)
fmt.Println(piscine.ListAt(link.Head, 7))
}
```
@ -54,8 +52,8 @@ And its output :
```console
student@ubuntu:~/piscine/test$ go build
student@ubuntu:~/piscine/test$ ./test
you
hello
1
how are
<nil>
student@ubuntu:~/piscine/test$
```
```
Loading…
Cancel
Save