lang: types, lang: core: strings: Add a new join_nonempty function

Along with a helper function for when we need a []string from a Value.
This commit is contained in:
James Shubin
2025-01-24 00:07:23 -05:00
parent f92afe9ae4
commit ca6e7ad432
2 changed files with 82 additions and 0 deletions

View File

@@ -229,3 +229,15 @@ func ListStrToValue(input []string) Value {
}
return l
}
// ValueToListStr is a simple helper function to convert from a list of strings
// in our type system to the equivalent in golang. This panics if the input is
// not of the correct type.
func ValueToListStr(input Value) []string {
l := []string{}
for _, x := range input.List() {
s := x.Str()
l = append(l, s)
}
return l
}