Doug F
Doug F

Reputation: 348

What should I call this function composition?

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.

Upvotes: 1

Views: 290

Answers (5)

Michael Sofaer
Michael Sofaer

Reputation: 2947

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.

Upvotes: 1

Federico A. Ramponi
Federico A. Ramponi

Reputation: 47075

 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.

Upvotes: 2

Doug F
Doug F

Reputation: 348

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)

Upvotes: 0

user21037
user21037

Reputation:

The synergy engine.

Upvotes: 0

dfa
dfa

Reputation: 116334

I would call it function compositor or something like that

Upvotes: 1

Related Questions