github.com/elves/elvish@v0.15.0/pkg/eval/vals/aliased_types.go (about) 1 package vals 2 3 import ( 4 "os" 5 6 "github.com/xiaq/persistent/hashmap" 7 "github.com/xiaq/persistent/vector" 8 ) 9 10 // File is an alias for *os.File. 11 type File = *os.File 12 13 // List is an alias for the underlying type used for lists in Elvish. 14 type List = vector.Vector 15 16 // EmptyList is an empty list. 17 var EmptyList = vector.Empty 18 19 // MakeList creates a new List from values. 20 func MakeList(vs ...interface{}) vector.Vector { 21 vec := vector.Empty 22 for _, v := range vs { 23 vec = vec.Cons(v) 24 } 25 return vec 26 } 27 28 // Map is an alias for the underlying type used for maps in Elvish. 29 type Map = hashmap.Map 30 31 // EmptyMap is an empty map. 32 var EmptyMap = hashmap.New(Equal, Hash) 33 34 // MakeMap creates a map from arguments that are alternately keys and values. It 35 // panics if the number of arguments is odd. 36 func MakeMap(a ...interface{}) hashmap.Map { 37 if len(a)%2 == 1 { 38 panic("Odd number of arguments to MakeMap") 39 } 40 m := EmptyMap 41 for i := 0; i < len(a); i += 2 { 42 m = m.Assoc(a[i], a[i+1]) 43 } 44 return m 45 }