Tags: anybuilt-in, beginner, brief, curry, currying, function, lisp, lookat, programming

Currying in Lisp - Suggestions for a beginner

On Programmer » Lisp

5,136 words with 9 Comments; publish: Sat, 26 Apr 2008 17:28:00 GMT; (20062.50, « »)

Hi,

I've just started using Lisp a few ws ago, and I haven't seen any

built-in function to curry another function. I have had a brief look

at the Hyperspec but I couldn't find anything.

That's obviously possible, so is there any standard function defined

for that purpose in Common Lisp?

Thanks in advance.

All Comments

Leave a comment...

  • 9 Comments
    • arcadiorubiogarcia.lisp.todaysummary.com.gmail.com writes:

      > Hi,

      > I've just started using Lisp a few ws ago, and I haven't seen any

      > built-in function to curry another function. I have had a brief look

      > at the Hyperspec but I couldn't find anything.

      > That's obviously possible, so is there any standard function defined

      > for that purpose in Common Lisp?

      No.

      'as

      #1; Sat, 26 Apr 2008 17:29:00 GMT
    • On 15 mar, 23:06, Alexander Schmolck <a.schmo....lisp.todaysummary.com.gmail.com> wrote:

      > arcadiorubiogar....lisp.todaysummary.com.gmail.com writes:

      >

      >

      > No.

      > 'as

      So do I have to code it by hand?

      #2; Sat, 26 Apr 2008 17:30:00 GMT
    • On Mar 15, 2:08 pm, arcadiorubiogar....lisp.todaysummary.com.gmail.com wrote:

      > So do I have to code it by hand?

      Well, you have to add something into your program so that the computer

      knows about your intent to curry a function. For people with

      disabilities, there exist special input methods for doing that, but by

      most of the programming population, it's done with the hands.

      #3; Sat, 26 Apr 2008 17:31:00 GMT
    • On Mar 15, 1:38 pm, arcadiorubiogar....lisp.todaysummary.com.gmail.com wrote:

      > Hi,

      > I've just started using Lisp a few ws ago, and I haven't seen any

      > built-in function to curry another function.

      The LAMBDA operator creates a lexical closure. If F is a function of

      two arguments, and A is some value that is to be used as the first

      argument, then LAMBDA can be used to curry to a one-argument function

      as follows:

      (lambda (x) (funcall f a x))

      If F is the name of a function rather than an expression that

      evaluates to a function object, drop the funcall.

      #4; Sat, 26 Apr 2008 17:32:00 GMT
    • On 15 Mar 2007 15:08:54 -0700, arcadiorubiogarcia.lisp.todaysummary.com.gmail.com wrote:

      > So do I have to code it by hand?

      You can copy it somewhere. Here for example:

      http://common-lisp.net/project/alex.../functions.lisp

      Not sure if you need your hands for that...

      Lisp is not dead, it just smells funny.

      Real email: (replace (subseq "spamtrap.lisp.todaysummary.com.agharta.de" 5) "edi")

      #6; Sat, 26 Apr 2008 17:34:00 GMT
    • On 15 Mrz., 22:38, arcadiorubiogar....lisp.todaysummary.com.gmail.com wrote:

      > Hi,

      > I've just started using Lisp a few ws ago, and I haven't seen any

      > built-in function to curry another function. I have had a brief look

      > at the Hyperspec but I couldn't find anything.

      > That's obviously possible, so is there any standard function defined

      > for that purpose in Common Lisp?

      > Thanks in advance.

      There is no predefined CURRY in ANSI Common Lisp. Defining your own

      CURRY is quite straightforward though. If you want it to be efficient,

      you can augment it by a compiler macro that curries at compile-time.

      ciao,

      Jochen

      #7; Sat, 26 Apr 2008 17:35:00 GMT
    • On 15 mar, 23:46, "j....lisp.todaysummary.com.codeartist.org" <j....lisp.todaysummary.com.codeartist.org> wrote:

      > On 15 Mrz., 22:38, arcadiorubiogar....lisp.todaysummary.com.gmail.com wrote:

      >

      >

      >

      >

      > There is no predefined CURRY in ANSI Common Lisp. Defining your own

      > CURRY is quite straightforward though. If you want it to be efficient,

      > you can augment it by a compiler macro that curries at compile-time.

      > ciao,

      > Jochen

      Yeah, that was what I was thinking about : coding a macro. However I

      wanted to know if there was a standard solution beforehand.

      Thank you all.

      #8; Sat, 26 Apr 2008 17:37:00 GMT
    • On 15 Mar 2007 15:53:57 -0700, arcadiorubiogarcia.lisp.todaysummary.com.gmail.com wrote:

      > On 15 mar, 23:46, "j....lisp.todaysummary.com.codeartist.org" <j....lisp.todaysummary.com.codeartist.org> wrote:

      >

      > Yeah, that was what I was thinking about : coding a macro.

      No, you don't want a macro, you want a function. A compiler macro is

      not the same as a macro. See for example here:

      http://www.pentaside.org/paper/comp...i

      on.txt

      Lisp is not dead, it just smells funny.

      Real email: (replace (subseq "spamtrap.lisp.todaysummary.com.agharta.de" 5) "edi")

      #9; Sat, 26 Apr 2008 17:37:00 GMT