http://qs321.pair.com?node_id=1066854


in reply to Re: Want for a name? (Final thoughts; strong feelings; votes?)
in thread Want for a name?

One reasonable metric for rating them might be: Imagine you're seeing the function name for the first time, together with a definition of its signature (parameter/return types). Would you have guessed its correct meaning? How sure would you have been?

Of course that's still subjective, so let me present my intuitive reactions so that you can compare them to your own:

Simple version of the function: Map a list to all its subsequences of 2 adjacent items

For the "pairwise" version, the function would only take a code block and a list. Given that function signature, I think the only ones for which I would have guessed the correct meaning and would have been reasonably sure about it, are:

RESULT_LIST = map_adjacent { CODE } LIST
RESULT_LIST = neighbors { CODE } LIST

A few comments on some of the others:

Generalized version of the function: Map a list to all its subsequences of n adjacent items

In this case, the function would likely take a code block, a number, and a list. Unfortunately, I don't think I would be very sure about any of my guesses in this scenario, for any of the suggested names. One that hasn't been suggested yet (probably because it's too long), but would be pretty self-explanatory for me, is:

RESULT_LIST = natatime_sliding { CODE } NUMBER, LIST

Those where there's at least a decent chance that I would have guessed the correct meaning, are, in descending order:

RESULT_LIST = map_adjacent { CODE } NUMBER, LIST
RESULT_LIST = moving { CODE } NUMBER, LIST
RESULT_LIST = slide { CODE } NUMBER, LIST

moving is nice because it's effectively a generalization of "moving average" to "moving <custom calculation>"...

@moving_averages = moving { sum(@_)/@_ } $n, @data

...but of course if the context in which you're using it has nothing to do with statistics, that recognition value will be lost.

between and map_right_neighbour wouldn't work at all anymore for n > 2.
adjoin, overlaps, mapAdj and pipeline would still have the same problems as above.

Replies are listed 'Best First'.
Re^3: Want for a name? (Final thoughts; strong feelings; votes?)
by BrowserUk (Patriarch) on Dec 12, 2013 at 15:35 UTC

    Thanks for your thoughtful review.

    natatime_sliding

    Sounds like OAPs complaining that their tea'n'chat session are getting later and later .... :) But yes, it's too long.

    mapAdj

    Map adjacent; map adjoining; map adjunct; all of those work.

    Since salva pointed out the scala version, I keep looking again at slide/sliding; but they make me think of sliding scales & sliding checksum, neither of which are appropriate here.

    As I said elsewhere, many function names (and keywords) do not mean much unless you know what they mean in the context of a computer program.

    Take reduce or join or grep or splice. Write the functionality of any of those out in full:

    take_a_list_of_values_convert_them_to_their_string_representations_if_ +necessary_intersperse_them_with_this_other_string_and_return_a_single +_string_formed_from_them_all( "\t", @nums);

    And it would be ridiculous.

    You only know what grep does, because you learnt it, not from the name, so the key things are to be vaguely mnemonic and memorable, and preferably short.

    I'm more and more persuaded by overlap & overmap.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      why no map_slice or map_splice? cause like slice/splice it returns a list ... and you're slicing the list you're iterating over

        Mostly, because splice (and slice syntax) allow complete control over where to start and how many.

        And library routine use those terms combined with map is going to have to be -- or at least feel the pressure to be -- equally flexible.

        And a) that flexibility would have a disastrous affect on both usability & efficiency for the simple case; b) I've never encountered a need for that flexibility; where the simple case can (and has for me in recent months), crop up very frequently.

        Also, splice modifies array, this just provides snapshots.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.