Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6145847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:51:26+00:00 2026-05-23T18:51:26+00:00

I have this curry function: (define curry (lambda (f) (lambda (a) (lambda (b) (f

  • 0

I have this curry function:

(define curry
(lambda (f) (lambda (a) (lambda (b) (f a b)))))

I think it’s like (define curry (f a b)).

my assignment is to write a function consElem2All using curry,which should work like

(((consElem2All cons) 'b) '((1) (2 3) (4)))
>((b 1) (b 2 3) (b 4))

I have wrote this function in a regular way:

(define (consElem2All0 x lst) 
  (map (lambda (elem) (cons x elem)) lst))

but still don’t know how to transform it with curry. Can anyone help me?

thanks in advance

bearzk

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:51:26+00:00Added an answer on May 23, 2026 at 6:51 pm

    You should begin by reading about currying. If you don’t understand what curry is about, it may be really hard to use it… In your case, http://www.engr.uconn.edu/~jeffm/Papers/curry.html may be a good start.

    One very common and interesting use of currying is with functions like reduce or map (for themselves or their arguments).

    Let’s define two currying operators!

    (define curry2 (lambda (f) (lambda (arg1) (lambda (arg2) (f arg1 arg2)))))
    (define curry3 (lambda (f) (lambda (arg1) (lambda (arg2) (lambda (arg3) (f arg1 arg2 arg3))))))
    

    Then a few curried mathematical functions:

    (define mult (curry2 *))
    (define double (mult 2))
    
    (define add (curry2 +))
    (define increment (add 1))
    (define decrement (add -1))
    

    And then come the curried reduce/map:

    (define creduce (curry3 reduce))
    (define cmap (curry2 map))
    

    Using them

    First reduce use cases:

    (define sum ((creduce +) 0))
    (sum '(1 2 3 4)) ; => 10
    
    (define product (creduce * 1))
    (product '(1 2 3 4)) ; => 24
    

    And then map use cases:

    (define doubles (cmap double))
    (doubles '(1 2 3 4)) ; => (2 4 6 8)
    
    (define bump (cmap increment))
    (bump '(1 2 3 4)) ; => (2 3 4 5)
    

    I hope that helps you grasp the usefulness of currying…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a partial-application function which looks like this: Function.prototype.curry = function() {
I have implemented a curry function this way: function curry (fn) { var slice
I have a class which looks something like this: class MyClass { public: //
I want a 'curry' like function - this kind of thing function invoker (fn)
I have this string 'john smith~123 Street~Apt 4~New York~NY~12345' Using JavaScript, what is the
I have a bunch of name/email fields in my form like this: data[Friend][0][name] data[Friend][1][name]
I have a validation class which I would like to use to check all
I have a function mainFunc which needs to call a several times another function
I have an error with an assignment, of which I get a seg fault,
I have a string in my function defined like .. char *key=anyvalue; Now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.