2 ms·
If you instantiate it with concrete types, does "(b IntBox) Map(f func(int) string) StringBox" make more sense? You have a collection (in this case Box) contai
by pkal 2mo ago
If you instantiate it with concrete types, does "(b IntBox) Map(f func(int) string) StringBox" make more sense? You have a collection (in this case Box) containing values of type T, a function that maps values of type T to type U, and if you apply that function to all elements in that collection you get a collection of type U.
- geoka9 2mo agoOnly they are not using a collection and therefore "Map" was a confusing choice for the method name (maybe "To" would have been a better name?).
- pkal 2mo agoIs that really the confusing part? If you had a general collection interface, say Mapper, a Box (i.e. a singleton set) could implement it just as well as a List or a Tree.
- geoka9 2mo agoI realize that mathematically speaking a singleton set is still a set, but as a programmer who is used to map operations in other mainstream languages, I was expecting some kind of loop in the implementation. It took a few page faults in my brain to realize what's going on.
- kccqzy 2mo agoYour understanding is quite incomplete. Wait till you think about the mapping operation for functions. Then there’s no loop, just function composition.
- debugnik 2mo agoA one item collection is admittedly a lame one, but it is a collection. Pointers are collections of zero or one items in a sense. Now, the verb "map" is the traditional name for this operator, but I agree it sounds confusing when the noun "map" is also a collection type. C# and SQL call this Select, if that helps.