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

  • SEARCH
  • Home
  • 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 8183787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:16:32+00:00 2026-06-07T01:16:32+00:00

the c++ boost bind library and clojure’s partial function are very similar. For example:

  • 0

the c++ boost bind library and clojure’s partial function are very similar. For example:

int x = 8;
bind(std::less<int>(), _1, 9)(x);   // x < 9

This is similar to clojure’s partial function:

((partial > 9) 8)

The difference is that partial only allows the first n parameters to be bound, whereas boost::bind allows placeholders indicating which parameters are bound and which are unbound. So boost::bind is actually much more general and useful:

bind(f, _2, _1)(x, y);                 // f(y, x)

bind(g, _1, 9, _1)(x);                 // g(x, 9, x) 

I’m wondering if there is something similar to boost::bind in clojure (or clojure-contrib)? And why partial was not written to be more general (and useful) as boost::bind is?

  • 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-06-07T01:16:33+00:00Added an answer on June 7, 2026 at 1:16 am

    This is a fairly frequently asked question of Clojure, more often couched in terms of the threading macros -> and ->> as to why they also don’t allow arbitrary placeholders.

    The reason given for those also applies here in my opinion: idiomatic Clojure functions generally breakdown into ones that lend themselves to having either their first or their last arguments supplied separately, not a mixture.

    In other words, developers generally try to code functions so that they are amenable to ->, ->> and/or partial.

    Given the reader macro for anonymous functions, it’s fairly easy to create the placeholder versions when they’re needed, for less idiomatic situations:

    #(f %2 %1) ;; bind(f, _2, _1)
    #(g % 9 %) ;; bind(g, _1, 9, _1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My confuse is like this code: #include stdafx.h #include <boost/bind.hpp> using namespace std; void
I am trying to use boost::bind with a boost::function using this. It seems a
I have a situation where a boost::function and boost::bind (actually a std::tr1::function and bind)
I'm trying to use boost::bind with the std::sort function. I want to bind sort
I had this code building and running perfectly: boost::function<void(string)> bar = boost::bind(&Bar::BarHandler, this, _1);
boost::bind overloads several operators for its placeholders: For convenience, the function objects produced by
I have some C++ code #include <cstdio> #include <boost/bind.hpp> #include <boost/function.hpp> class A {
#include <iostream> #include <algorithm> #include <vector> #include <boost/array.hpp> #include <boost/bind.hpp> int main() { boost::array<int,
Other than boost (Bind & Function), how can I dynamically call a function in
want to pass boost::bind to a method expecting a plain function pointer (same signature).

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.