Hi,
Is lisp the only programming language with higher order functions?
Higher order functions are truely great for abstraction and code reuse
and should be applied more in modern programming. Wouldn't you agree?
Best regards,
John
·········@hotmail.com wrote:
> Hi,
>
> Is lisp the only programming language with higher order functions?
No, see for example http://en.wikipedia.org/wiki/Functional_programming
> Higher order functions are truely great for abstraction and code reuse
> and should be applied more in modern programming. Wouldn't you agree?
Yes.
Pascal
--
My website: http://p-cos.net
Closer to MOP & ContextL:
http://common-lisp.net/project/closer/
·········@hotmail.com wrote:
> Is lisp the only programming language with higher order functions?
You can use higher order functions in C++, too:
stl::vector<int> v;
v.push_back(1);
v.push_back(11);
cout << count(v.begin(), v.end(), bind2nd(less(), 10));
But don't ask how the "bind2nd" and "less" constructs looks like :-)
In Common Lisp it looks like this:
(count-if (lambda (x) (< x 10)) '(1 11))
But the bind2nd function is useful, too, in Lisp (is there such a function
already defined in the CLHS? )
(defun bind2nd (fun arg2)
(lambda (arg1)
(funcall fun arg1 arg2)))
Then you can write it like in C++:
(count-if (bind2nd #'< 10) '(1 11))
> Higher order functions are truely great for abstraction and code reuse
> and should be applied more in modern programming. Wouldn't you agree?
Yes.
--
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Frank Buss wrote:
> ·········@hotmail.com wrote:
>
> > Is lisp the only programming language with higher order functions?
>
> You can use higher order functions in C++, too:
>
> stl::vector<int> v;
> v.push_back(1);
> v.push_back(11);
> cout << count(v.begin(), v.end(), bind2nd(less(), 10));
>
> But don't ask how the "bind2nd" and "less" constructs looks like :-)
>
> In Common Lisp it looks like this:
>
> (count-if (lambda (x) (< x 10)) '(1 11))
>
> But the bind2nd function is useful, too, in Lisp (is there such a function
> already defined in the CLHS? )
This is I think generally called a 'right-curry'. See for example
http://common-lisp.net/project/bese/docs/arnesi/html/api/function_005FIT.BESE.ARNESI_003A_003ARCURRY.html
>
> (defun bind2nd (fun arg2)
> (lambda (arg1)
> (funcall fun arg1 arg2)))
>
> Then you can write it like in C++:
>
> (count-if (bind2nd #'< 10) '(1 11))
>
> > Higher order functions are truely great for abstraction and code reuse
> > and should be applied more in modern programming. Wouldn't you agree?
>
> Yes.
>
> --
> Frank Buss, ··@frank-buss.de
> http://www.frank-buss.de, http://www.it4-systems.de