From 6f36533a119bb62b4d3a1d702a058c25f75d978b Mon Sep 17 00:00:00 2001 From: Augusto Date: Wed, 26 Jun 2019 16:56:41 +0100 Subject: [PATCH] fix change listfind function --- subjects/listfind.en.md | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/subjects/listfind.en.md b/subjects/listfind.en.md index 4979b8466..c84208e79 100644 --- a/subjects/listfind.en.md +++ b/subjects/listfind.en.md @@ -1,31 +1,29 @@ -## listpushback +## listfind ### Instructions -Write a function `ListFind` that returns the address of the first link that the function in the arguments its equal. +Write a function `ListFind` that returns the address of the first node in the list that is determined to be equal to `ref` by the functions `CompStr`. - For this you shoud use the function `CompStr`. -- Use pointers wen ever you can. - ### Expected function and structure ```go -type node struct { - data interface{} - next *node +type NodeL struct { + Data interface{} + Next *NodeL } -type list struct { - head *node - tail *node +type List struct { + Head *NodeL + Tail *NodeL } -func CompStr(l *list) bool { - +func CompStr(a, b interface{}) bool { + return a == b } -func ListFind(l *list, comp func(l *list) bool) *interface{} { +func ListFind(l *List, ref interface{}, comp func(a, b interface{}) bool) *interface{} { } ``` @@ -43,14 +41,14 @@ import ( ) func main() { - link := &list{} + link := &piscine.List{} piscine.ListPushBack(link, "hello") piscine.ListPushBack(link, "hello1") piscine.ListPushBack(link, "hello2") piscine.ListPushBack(link, "hello3") - fmt.Println(piscine.ListFind(link, compStr)) + fmt.Println(piscine.ListFind(link, interface{}("hello2"), piscine.CompStr)) } ``` @@ -62,3 +60,6 @@ student@ubuntu:~/piscine/test$ ./test 0xc42000a0a0 student@ubuntu:~/piscine/test$ ``` +### Note + +- The address may be different in each execution of the program. \ No newline at end of file