1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-07-17 01:32:22 +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

@ -32,15 +32,18 @@ func SortedUnique(_ context.Context, args ...core.Value) (core.Value, error) {
return values.NewArray(0), nil
}
sorter, err := collections.NewSorter(func(first core.Value, second core.Value) (int, error) {
return first.Compare(second), nil
sorter, err := collections.NewSorter(func(first collections.DataSet, second collections.DataSet) (int, error) {
return first.Get(collections.DefaultValueVar).Compare(second.Get(collections.DefaultValueVar)), nil
}, collections.SortDirectionAsc)
if err != nil {
return values.None, err
}
uniqIterator, err := collections.NewUniqueIterator(collections.NewArrayIterator(arr))
uniqIterator, err := collections.NewUniqueIterator(
collections.NewDefaultIndexedIterator(arr),
collections.DefaultValueVar,
)
if err != nil {
return values.None, err
@ -55,5 +58,5 @@ func SortedUnique(_ context.Context, args ...core.Value) (core.Value, error) {
return values.None, err
}
return collections.ToArray(iterator)
return toArray(iterator)
}