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 4059534
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:13:17+00:00 2026-05-20T15:13:17+00:00

Clojure is awesome, we all know this, but that’s not the point. I’m wondering

  • 0

Clojure is awesome, we all know this, but that’s not the point. I’m wondering what the idiomatic way of creating and managing higher-order functions in a Haskell-like way is. In Clojure I can do the following:

(defn sum [a b] (+ a b))

But (sum 1) doesn’t return a function: it causes an error. Of course, you can do something like this:

(defn sum
  ([a] (partial + a)) 
  ([a b] (+ a b)))

In this case:

user=> (sum 1)
#<core$partial$fn__3678 clojure.core$partial$fn__3678@1acaf0ed>
user=> ((sum 1) 2)
3

But it doesn’t seem like the right way to proceed. Any ideas?
I’m not talking about implementing the sum function, I’m talking at a higher level of abstraction. Are there any idiomatic patterns to follow? Some macro? Is the best way defining a macro or are there alternative solutions?

  • 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-20T15:13:17+00:00Added an answer on May 20, 2026 at 3:13 pm

    Someone has already implememented this on the Clojure group. You can specify how many args a function has, and it will curry itself for you until it gets that many.

    The reason this doesn’t happen by default in Clojure is that we prefer variadic functions to auto-curried functions, I suppose.

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

Sidebar

Related Questions

Clojure is a functional lisp, reportedly not at all object-oriented, even though it runs
The clojure.contrib.sql library returns BigDecimals for all numeric fields. What's a good way to
I have the following Clojure code and I'm not sure why it's not working:
Is there anything in Clojure that is equivalent to Common Lisp's symbol-name function?
I was reading about Clojure and found a discussion about Java not supporting tail
I want to use JOGL (for Clojure, not Java). There seems to be quite
What methods to use a database from Clojure are there? I know from Clojure
I'm trying to get console input in my Clojure program, but when it gives
Clojure has introduced me to the concept of Lisp syntax, and I'm interested, but
Clojure comes with some basic ui apps that let you inspect objects. The generic

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.