ngs
ngs copied to clipboard
Implement '.'(Iter, Str)
... allowing Iter(something).my_field
Currently this works: [{"x": 1}, {"x": 2}].x == [1, 2]
. That's because of definition: F .(a:Arr, field:Str) a.map(X.(field))
in stdlib.ngs
.
Same .my_field
operation should work on Iter
objects: my_iter.x
but it should return an Iter
object, not an array. That's in order to be able to have a chain of Iter
s, for processing potentially endless stream. At no point of Iter
chain.
See
-
Iter.ngs
, particularlyMapIter
. It should be pretty close to what needs to be implemented here. -
F .(a:Arr, field:Str)
instdlib.ngs
which fields can an Iterator have? what is the really purpose of implementing this?
This is supposed to be the equivalent of F .(Arr, Str)
which is defined as F .(a:Arr, field:Str) a.map(X.(field))
but for Iter
s.
The .
operation should be applied to items that the Iter
returns (when next()
is called).
Unfortunately, there is a design issue here. Arr
objects don't have any fields so my_arr.my_field
can be used to reference the fields of the elements. Iter
has fields so my_iter.my_field
can not be freely repurposed. One possible solution would be to move all the fields of Iter
into meta()
like ArrLike
does. Open to hear other suggestions.