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.
 
 
 
 
 
 

988 B

listpushback

Instructions

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

  • For this you shoud use the function CompStr.

  • Use pointers when 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, 1)
	piscine.ListPushBack(link, "hello")
	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
hello
student@ubuntu:~/piscine/test$