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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:09:08+00:00 2026-06-17T21:09:08+00:00

In clojure, I would like to push a thrush value through a list of

  • 0

In clojure, I would like to push a thrush value through a list of functions, but I’m not sure how to do so in an idiomatic way. The idea is that I will have a list containing an unknown number of functions, and I’d like to take advantage of the variadic nature of thrush.

So, something like this…

(->> 1 inc inc inc)
; 4

(->> 1 '(inc inc inc))
; does not work, of course
  • 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-17T21:09:10+00:00Added an answer on June 17, 2026 at 9:09 pm

    I think comp is the most idiomatic option here, though it will have prefix syntax instead. This is also more in keeping with normal Clojure (fn args) notation.

    => ((comp inc inc inc) 1)
    4
    

    Combine it with the idiomatic apply if a function normally takes variadic arguments, but you want to feed it a collection.

    => ((apply comp (repeat 3 inc)) 1)
    4
    

    Be aware though it threads from right to left

    => ((comp str inc inc inc) 1)
    "4"
    => ((comp inc inc inc str ) 1)
    ClassCastException java.lang.String cannot be cast to java.lang.Number
    

    This also complies more with Clojure/Lisp s-expressions.

    If you want more ‘easy’ human readable notation, Arthur Ulfeldt’s answer is perfecly acceptable, and a nice example of reduce and functional programming. Using it ‘as is’ might get in the way of getting acquainted with the ‘simplicity’ of s-expressions though..

    Be careful with macro’s !

    The reason why -> and ->> are macro’s is that they actively rewrite forms, so you can use normally incomplete argument notation like (filter odd?) in their scope without having to resort to overuse of partial. This can’t be done with normal function compostition.

    Best learn to make the most of normal function composition before turning to macro’s. There’s a lot of pitfalls in them for the unaccustomed, and should be used sparingly.

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

Sidebar

Related Questions

I would like to know how to list all functions of a Clojure namespace.
I would like to set the fill-column in Emacs to 120 for Clojure-mode, but
I'm learning Clojure and would like some advice on idiomatic usage. As part of
I would like to learn Clojure, but rather than opening up a full-on IDE
I would like to be able to call clojure functions using keyword arguments like
I would like to install slime-js but I already have Clojure installed and it
I'm not very familiar with Clojure/Lisp macros. I would like to write apply-recur macro
I would like to move data back and fourth between clojure applications. Application settings
I would like to know , considering that Clojure uses 32-bit hash for its
What I would like to do (in Clojure): For example, I have a vector

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.