1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-07-15 01:25:00 +02:00

Feature/#5 collect keyword alt (#141)

Implemented COLLECT key word
This commit is contained in:
Tim Voronov
2018-10-24 21:30:05 -04:00
committed by GitHub
parent b02c554214
commit 549b4abd3b
67 changed files with 4913 additions and 2811 deletions

View File

@ -1,6 +1,10 @@
package arrays
import "github.com/MontFerret/ferret/pkg/runtime/core"
import (
"github.com/MontFerret/ferret/pkg/runtime/collections"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
func NewLib() map[string]core.Function {
return map[string]core.Function{
@ -29,3 +33,19 @@ func NewLib() map[string]core.Function {
"UNSHIFT": Unshift,
}
}
func toArray(iterator collections.Iterator) (core.Value, error) {
arr := values.NewArray(10)
for iterator.HasNext() {
ds, err := iterator.Next()
if err != nil {
return values.None, err
}
arr.Push(ds.Get(collections.DefaultValueVar))
}
return arr, nil
}