Tagged Questions
163
votes
4answers
14k views
What is the difference between a 'closure' and a 'lambda'?
Could someone explain? I understand the basic concepts behind them but I often see them used interchangeably and I get confused.
And now that we're here, how do they differ from a regular function?
19
votes
4answers
2k views
Haskell: How to compose `not` with a function of arbitrary arity?
When I have some function of type like
f :: (Ord a) => a -> a -> Bool
f a b = a > b
I should like make function which wrap this function with not.
e.g. make function like this
g :: ...
25
votes
8answers
3k views
14
votes
4answers
608 views
In C, what is the difference between `&function` and `function` when passed as arguments?
For example:
#include <stdio.h>
typedef void (* proto_1)();
typedef void proto_2();
void my_function(int j){
printf("hello from function. I got %d.\n",j);
}
void call_arg_1(proto_1 arg){
...
10
votes
6answers
3k views
Haskell function composition
I am reading this tutorial on Haskell. They define function composition as the following:
(.) :: (b->c) -> (a->b) -> (a->c)
f . g = \ x -> f (g ...
9
votes
1answer
2k views
compose function and functional module
Python 3.2 documentation refers to Collin Winter's functional module which contains function compose:
The compose() function implements function composition. In other
words, it returns a wrapper ...
3
votes
2answers
412 views
Point-free style with objects/records in F#
I'm getting stymied by the way "dot notation" works with objects and records when trying to program in a point-free functional style (which I think is a great, concise way to use a functional language ...
2
votes
2answers
656 views
posmax: like argmax but gives the position(s) of the element x for which f[x] is maximal
Mathematica has a built-in function ArgMax for functions over infinite domains, based on the standard mathematical definition.
The analog for finite domains is a handy utility function.
Given a ...
4
votes
4answers
167 views
What object javascript function is bound to (what is its “this”)?
I know that inside the function it is this.
var func = function {
return this.f === arguments.callee;
// => true, if bound to some object
// => false, if is bound to null, because ...
2
votes
4answers
148 views
Is it possible to do functional programming in a language without functions?
In this comment, it was stated that Ruby doesn't have functions, only methods. If Ruby doesn't have functions, is it not possible to do functional programming in it? Or am I confused about the term ...
0
votes
1answer
81 views
What is a function composition algorithm that will work for multiple arguments, such as h(x,y) . f(x) . g(x) = h(f(x),g(x))?
For example, suppose we had the functions double(x)=2*x, square(x)=x^2 and sum(x,y)=x+y. What is a function compose such as compose(compose(sum,square),double) = x^2 + 2*x? Notice that I'm asking a ...
0
votes
2answers
427 views
Scheme - define variable as the result of a function?
The beginning of one of my programs results in an error. This is the problem area. I am trying to define a variable as the result of a recursive function.
(define (test n)
(define (a1func i)
...