Skip to content

Instantly share code, notes, and snippets.

@alces
Last active November 27, 2017 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alces/aa41d067d6beaeafbada19b684b5176f to your computer and use it in GitHub Desktop.
Save alces/aa41d067d6beaeafbada19b684b5176f to your computer and use it in GitHub Desktop.
Adding Map method to List class
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