User loginNavigation |
Is there an existing name for my higher-order function?I have groups of functions that get called with the exact same arguments:
a = func_a(arg1, arg2, arg3, arg4, arg5);
b = func_b(arg1, arg2, arg3, arg4, arg5);
c = func_c(arg1, arg2, arg3, arg4, arg5);
To reduce duplication, I have a helper function that accepts any number of arguments and returns a second helper function. When called, this second function applies the arguments it was constructed with to other functions:
bar = foo(arg1, arg2, arg3, arg4, arg5);
a = bar(func_a);
b = bar(func_b);
c = bar(func_c);
My question is, what's the best name for "foo" in this second example? I've looked for higher-order functions in various languages but I'm having trouble finding examples of my specific usage--there are similar functions but nothing exactly the same. I'm hoping to find a canonical name for what I'm doing (if one exists). Like partial, foo() fixes the given arguments but it doesn't bind them to a specific function. The best name I can come up with is enclose() or callwith(). If anyone know of an already-existing name for this, I'd like to hear what it is. By shawnbrown at 2016-08-02 21:59 | LtU Forum | previous forum topic | next forum topic | other blogs | 7605 reads
|
Browse archives
Active forum topics |
Recent comments
4 days 15 hours ago
4 days 15 hours ago
4 days 15 hours ago
3 weeks 5 days ago
4 weeks 3 days ago
4 weeks 3 days ago
4 weeks 5 days ago
4 weeks 5 days ago
4 weeks 5 days ago
5 weeks 1 day ago