If x.find returns a value, why then x.findAll returns a map instead of a list of values? For me, that would be the logic and preferred way. Or take it contrary, if x.findAll returns a map, why isn't so with x.find, i.e. why doesn't it return a map with one map entry but a single value? It looks for me like inconsistency in map design. What do you think about it?
brianFri 5 Sep 2014
All the collection methods b/w List and Map parallel each other. So in both cases find returns one value, and findAll returns a new collection of the source type. If you want a list then just pipe to a list:
Besides, I've already just checked docs for the sys::Map and got a little confused with the description of the addList slot. It says:
Add the specified list to this map where the values are the list items and the keys are derived by calling the specified function on each item.
and in the attached example we have:
m := [0:"0"]
m.addList(["1","2"]) |Str s->Int| { return s.toInt }
m => [0:0, 1:1, 2:2]
According to slot description, the right result should be m => [0:"0", 1:"1", 2:"2"] but it's not? Whether it is a good description of this slot?
brianFri 5 Sep 2014
Sorry, its vals, not list
rasaFri 5 Sep 2014
OK, that works. Thanks. I've just updated my previous post, so take a look.
rasaSun 7 Sep 2014
Besides, I've already just checked docs for the sys::Map and got a little confused with the description of the addList slot. It says:
Add the specified list to this map where the values are the list items and the keys are derived by calling the specified function on each item.
and in the attached example we have:
m := [0:"0"]
m.addList(["1","2"]) |Str s->Int| { return s.toInt }
m => [0:0, 1:1, 2:2]
According to slot description, the right result should be m => [0:"0", 1:"1", 2:"2"] but it is [0:0, 1:1, 2:2]? Whether it is a wrong description of this slot or its implementation?
brianSun 7 Sep 2014
Whether it is a wrong description of this slot or its implementation?
Those docs were copied from fansh which didn't include the quotes to illustrate the values are strings. I fixed the documentation so its clearer
rasa Fri 5 Sep 2014
Take a look at this method in Fantom Examples (file sys.maps.fan):
If x.find returns a value, why then x.findAll returns a map instead of a list of values? For me, that would be the logic and preferred way. Or take it contrary, if x.findAll returns a map, why isn't so with x.find, i.e. why doesn't it return a map with one map entry but a single value? It looks for me like inconsistency in map design. What do you think about it?
brian Fri 5 Sep 2014
All the collection methods b/w List and Map parallel each other. So in both cases find returns one value, and findAll returns a new collection of the source type. If you want a list then just pipe to a list:
rasa Fri 5 Sep 2014
I've just tried it in fansh and it doesn't work.
This works:
and this doesn't work:
Besides, I've already just checked docs for the sys::Map and got a little confused with the description of the addList slot. It says:
and in the attached example we have:
According to slot description, the right result should be m => [0:"0", 1:"1", 2:"2"] but it's not? Whether it is a good description of this slot?
brian Fri 5 Sep 2014
Sorry, its
vals
, notlist
rasa Fri 5 Sep 2014
OK, that works. Thanks. I've just updated my previous post, so take a look.
rasa Sun 7 Sep 2014
Besides, I've already just checked docs for the sys::Map and got a little confused with the description of the addList slot. It says:
and in the attached example we have:
According to slot description, the right result should be m => [0:"0", 1:"1", 2:"2"] but it is [0:0, 1:1, 2:2]? Whether it is a wrong description of this slot or its implementation?
brian Sun 7 Sep 2014
Those docs were copied from fansh which didn't include the quotes to illustrate the values are strings. I fixed the documentation so its clearer
rasa Sun 7 Sep 2014
You should update docs at this place also.