views:

190

answers:

5

What should 'foo' be called, given the following?

x.items is a set, y.values is a set.

function a(key) returns an ordered list of x.items

function b(x.item) returns a single y.value

Define foo(a, b), which returns a function, d, such that d(key) returns a list of y.values defined by: map(b, a(key)).

This feels like a fairly common and generic function composition but I don't know what to call it.

+1  A: 

I would call it function compositor or something like that

dfa
A: 

The synergy engine.

Dan
Ok then, how about "Bob"?
Dan
Gussey it up however you want Trebek. What matters is, does it work?
Totty
A: 

Here's are example names for a, b, and foo that might help (I don't like these, but they're sort of like what I'm getting at):

items_by_key(key)

value_by_item(item)

values_by_key(items_by_key, value_by_item)
Goladus
Your should edit your question and put this in there instead of putting it in an answer.
musicfreak
+2  A: 
 function a(key) returns an ordered list of x.items
 function b(x.item) returns a single y.value

Except for the ordering, a() is in practice a filter, i.e. it "filters" or "selects" items from x.items according to a key. b() is a normal map, or function. Thus, I would choose for 'foo' the name "composeFilterWithMap", or "composeSelectorWithMap" or a similar name.

Federico Ramponi
+1  A: 

I would call that function permuted_values

What you are doing is equivalent to iterating over a hash map using a permutation based on your key.

Michael Sofaer