Last active
November 27, 2017 14:12
-
-
Save alces/aa41d067d6beaeafbada19b684b5176f to your computer and use it in GitHub Desktop.
Adding Map method to List class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "container/list" | |
type MyList struct { | |
*list.List | |
} | |
func (l *MyList) Map(f func(interface{}) interface{}) *MyList { | |
nl := &MyList {list.New()} | |
for e := l.Front(); e != nil; e = e.Next() { | |
nl.PushBack(f(e.Value)) | |
} | |
return nl | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment