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.
 
 
 
 
 
 

1003 B

listpushback

Instructions

Write a function ListFind that returns the address of the first link that the function in the arguments its equal.

  • For this you shoud use the function CompStr.

  • Use pointers wen ever you can.

Expected function and structure

type node struct {
	data interface{}
	next *node
}

type list struct {
	head *node
	tail *node
}

func CompStr(l *list) bool {

}

func ListFind(l *list, comp func(l *list) bool) *interface{} {

}

Usage

Here is a possible program to test your function :

package main

import (
	"fmt"
	piscine ".."
)

func main() {
	link := &list{}

	piscine.ListPushBack(link, "hello")
	piscine.ListPushBack(link, "hello1")
	piscine.ListPushBack(link, "hello2")
	piscine.ListPushBack(link, "hello3")

	fmt.Println(piscine.ListFind(link, compStr))
}

And its output :

student@ubuntu:~/piscine/test$ go build
student@ubuntu:~/piscine/test$ ./test
0xc42000a0a0
student@ubuntu:~/piscine/test$