From: ·········@hotmail.com
Subject: Higher order programming
Date: 
Message-ID: <1154724651.395306.141550@p79g2000cwp.googlegroups.com>
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

From: Pascal Costanza
Subject: Re: Higher order programming
Date: 
Message-ID: <4jhqg9F841teU1@individual.net>
·········@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/
From: Frank Buss
Subject: Re: Higher order programming
Date: 
Message-ID: <17cbpo2jq9k59$.162hcvs6wdmfv$.dlg@40tude.net>
·········@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
From: Duncan Rose
Subject: Re: Higher order programming
Date: 
Message-ID: <1154728638.750882.87280@s13g2000cwa.googlegroups.com>
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