Created
September 24, 2020 22:35
-
-
Save ryanc414/6b9bd2210c6813efe36738f78bce5e98 to your computer and use it in GitHub Desktop.
linked lists in Go
This file contains hidden or 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 ( | |
"fmt" | |
"container/list" | |
) | |
func main() { | |
l := list.New() | |
l.PushBack(2) | |
l.PushBack(3) | |
l.PushBack(5) | |
l.PushBack(7) | |
l.PushBack(11) | |
var processed []int | |
for e := l.Front(); e != nil; e = e.Next() { | |
val := e.Value.(int) * 3 | |
processed = append(processed, val) | |
} | |
fmt.Println(processed) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment