// Package list implements persistent list.
package list // List is a persistent list. type List interface { // Len returns the number of values in the list. Len() int // Cons returns a new list with an additional value in the front. Cons(interface{}) List // First returns the first value in the list. First() interface{} // Rest returns the list after the first value. Rest() List } // Empty is an empty list. var Empty List = &list{} type list struct { first interface{} rest *list count int } func ( *list) () int { return .count } func ( *list) ( interface{}) List { return &list{, , .count + 1} } func ( *list) () interface{} { return .first } func ( *list) () List { return .rest }