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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:21:23+00:00 2026-06-12T09:21:23+00:00

In trying to stay with the functional style, I am having difficulty understanding when

  • 0

In trying to stay with the functional style, I am having difficulty understanding when I should prefer:

(-> [1 2 3] reverse last)

over:

(last (reverse [1 2 3]))

When I come across both styles in a project, I find that it breaks my flow since I have to switch between thinking about function compositions and thinking about intermediate value states.

Which should I use at what times?

  • 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-12T09:21:23+00:00Added an answer on June 12, 2026 at 9:21 am

    I mostly avoid using -> for one-argument functions; it’s a lot more useful when you have multiple-argument functions, because it lets you keep each function next to its “extra args”, without the focus object obscuring it.

    But also, you don’t have to choose one or the other extreme: one of my favorite things about -> is that it allows you to write the functions in any order at all, and you can use this freedom to write the code in whatever way you think is most readable. For example, perhaps you want to emphasize that you’re taking the last of a collection, and in context the fact that it’s reversed first is uninteresting:

    (last (-> [1 2 3] (reverse)))
    

    Or maybe reversing is important, and last is boring:

    (-> (reverse [1 2 3]) (last))
    

    As an aside, note that I wrote (last) and (reverse) here rather than just last and reverse even though the -> macro implicitly inserts parentheses for you if you leave them out. This was on purpose: although it’s not a terribly popular style, I think it’s a good idea to always use parentheses in the forms given to ->. There are several reasons for this:

    • It means you aren’t surprised when (-> (blah) (fn [x] (+ 1 (* x 5)))) expands weirdly, because you are used to thinking that -> takes a form rather than a function.
    • It keeps the link between “here is an open parenthesis” and “a function is being called”. It’s nice to be able to grep for calls to a particular function, and it’s also a nice visual hint. If you omit the parentheses, functions are called without being visually signaled.
    • It looks more regular in a multi-line -> with some unary functions and other multi-argument functions. For example:

      (-> attrs
          (update :sessions inc)
          frobnicate
          save-to-disk
          (get :uuid))
      

      Isn’t it gross to have those two things in the middle offset, looking different from everything else?

    The only argument I have ever seen for omitting the ()s is that it saves two characters of typing, which is not an argument at all.

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

Sidebar

Related Questions

I'm writing my Website right now, trying to stay more conservative, but using newer
I am trying to get a footer that will always stay at the bottom
I was trying to have a specific div fade in (left_panel_fade), and stay visible
Trying to implement LoaderManager + CursorLoader. In onFinish method adapter should swap its cursor
I'm trying to get a dropdown menu to open when I hover over the
I'm trying to stay on the current page from where a form gets submitted.
I'm trying to get an image to stay opaque when clicked on, along with
I am trying to sort one array, but have a second array stay in
I'm trying to make a div div disappear and stay gone even when the
I am writing a PhoneGap app on Android. I am trying to stay pure

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.