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

The Archive Base Latest Questions

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

I’m not clear on the difference between -> and ->> in Clojure: from the

  • 0

I’m not clear on the difference between -> and ->> in Clojure: from the API reference, it seems like the latter would be the correct way to apply several functions in sequence, i.e. (->> x h g f) would result in f(g(h(x))).

This is related to how Lisp-like language differentiate f(x, y) and (f(x))(y), whereas Haskell does not, correct? (Using math notation; commas intended to imply n-ary functions, not tupling).

Thanks in advance!

Edit

I’m wrong, neither work except on simple functions like (def inc #(+ 1 %)), where they both work.

Here’s an example of a function that doesn’t work with -> or ->>,

(defn mkinc­ [amnt­] (fn [x] (+ x amnt)­))
(-> 3 (mkin­c 2))
; ERROR -- Wrong number of args (2) passed to: sandbox58780$fn--58797$mkinc
((mkinc 2) 3)
; 5
  • 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-23T03:42:52+00:00Added an answer on May 23, 2026 at 3:42 am

    -> and ->> are equivalent if all the functions take only one argument. Otherwise, -> passes the value being threaded as the first argument to the function where as ->> passes it as the last argument. The following example should make this clear:

    (-> x
        (f 1 2)
        (g 3 4)
        (h 5 6))
    

    becomes

    (h (g (f x
             1 2)
          3 4)
       5 6)
    

    or h(g(f(x, 1, 2), 3, 4), 5, 6)

    (->> x
         (f 1 2)
         (g 3 4)
         (h 5 6))
    

    becomes

    (h 5 6
       (g 3 4
          (f 1 2 x)))
    

    or h(5, 6, g(3, 4, f(1, 2, x)))

    Edit: (Responding to the Edit in the question, copying this from the comments).

    The example doesn’t work because the -> macro inserts the 3 as the first arg of mkinc.
    See (macroexpand-1 '(-> 3 (mkinc 2))) to understand this better.

    This does work: (-> 3 ((mkinc 2))).
    See (macroexpand-1 '(-> 3 ((mkinc 2)))) to understand why.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I am currently running into a problem where an element is coming back from
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Basically, what I'm trying to create is a page of div tags, each has

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.