mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-12 17:27:50 +08:00
Add new util vals.MakeListFromStrings.
This commit is contained in:
parent
c46fd60270
commit
de5f0e0d32
|
@ -186,9 +186,9 @@ type closureFields struct{ c *closure }
|
|||
|
||||
func (closureFields) IsStructMap() {}
|
||||
|
||||
func (cf closureFields) ArgNames() vals.List { return listOfStrings(cf.c.ArgNames) }
|
||||
func (cf closureFields) ArgNames() vals.List { return vals.MakeListFromStrings(cf.c.ArgNames...) }
|
||||
func (cf closureFields) RestArg() string { return strconv.Itoa(cf.c.RestArg) }
|
||||
func (cf closureFields) OptNames() vals.List { return listOfStrings(cf.c.OptNames) }
|
||||
func (cf closureFields) OptNames() vals.List { return vals.MakeListFromStrings(cf.c.OptNames...) }
|
||||
func (cf closureFields) Src() parse.Source { return cf.c.SrcMeta }
|
||||
|
||||
func (cf closureFields) OptDefaults() vals.List {
|
||||
|
@ -203,11 +203,3 @@ func (cf closureFields) Body() string {
|
|||
func (cf closureFields) Def() string {
|
||||
return cf.c.SrcMeta.Code[cf.c.DefRange.From:cf.c.DefRange.To]
|
||||
}
|
||||
|
||||
func listOfStrings(ss []string) vals.List {
|
||||
list := vals.EmptyList
|
||||
for _, s := range ss {
|
||||
list = list.Cons(s)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
|
|
@ -280,7 +280,7 @@ func (ev *Evaler) addNumBgJobs(delta int) {
|
|||
// the given slice. This method must be called before the Evaler is used to
|
||||
// evaluate any code.
|
||||
func (ev *Evaler) SetArgs(args []string) {
|
||||
ev.Args = listOfStrings(args)
|
||||
ev.Args = vals.MakeListFromStrings(args...)
|
||||
}
|
||||
|
||||
// AddBeforeChdir adds a function to run before changing directory. This method
|
||||
|
|
|
@ -25,6 +25,15 @@ func MakeList(vs ...interface{}) vector.Vector {
|
|||
return vec
|
||||
}
|
||||
|
||||
// MakeListFromStrings creates a new List from strings.
|
||||
func MakeListFromStrings(ss ...string) vector.Vector {
|
||||
vec := vector.Empty
|
||||
for _, s := range ss {
|
||||
vec = vec.Cons(s)
|
||||
}
|
||||
return vec
|
||||
}
|
||||
|
||||
// Map is an alias for the underlying type used for maps in Elvish.
|
||||
type Map = hashmap.Map
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user