On August 15, 2017 6:51:00 PM GMT+02:00, Jonathan Bluett-Duncan <jbluettdun...@gmail.com> wrote: >Hi Krunoslav, > >I think the reason the method was named `map` rather than `replaceWith` >or >an equivalent name, is because `map` is a well-known name for this >sort of *higher-order >function*. The name itself has been around in functional programming >languages like Haskell and Scala and programming models like MapReduce >for >decades. > >Thus it would make sense to me that the writers of `java.util.stream` >named >it `map` to follow the Principle of least astonishment ><https://en.wikipedia.org/wiki/Principle_of_least_astonishment>. > >(Why was it named that way? I admit I do not know, but someone else may >be >able to explain.)
the name comes from Lisp https://en.m.wikipedia.org/wiki/Map_(higher-order_function) > >Hope this helps. > >Best regards, >Jonathan Remi > >On 12 August 2017 at 03:36, Krunoslav Magazin <magaz...@gmail.com> >wrote: > >> Hi. When using java.util.stream 'map' method my opinion is that >> 'replaceWith' as method name would better describe what method do. >> 'map' method is applied on input stream, returns output stream but >> returned stream elements are return values from 'map' method Function >> argument. We continue our work with output stream so mapping with >> input stream have no meaning. Input stream is replaced with output >> stream which elements are outputs of Function. After that point we >can >> forgot about input stream. >> >> Example of usage: >> now - stream.map(e -> e+2).. // read: map input stream with >> output stream containing elements resulting from function (e -> e+2) >> proposed - stream.replaceWith(e -> e+2).. // read: replace input >> stream with output stream containing elements resulting from function >> (e -> e+2) >> >> With 'map' method number of elements is the same but we do not make >> assumptions what passed Function will do (specialization) until the >> moment we pass Function implementation as method argument.. >> >> I will appreciate any comments. >> Best regards, >> Krunoslav Magazin >> -- Sent from my Android device with K-9 Mail. Please excuse my brevity.