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 ### 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` - 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
hello how are
<nil> <nil>
student@ubuntu:~/piscine/test$ student@ubuntu:~/piscine/test$
``` ```
Loading…
Cancel
Save