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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:45:56+00:00 2026-05-27T15:45:56+00:00

At the Clojure REPL, this expression ( #(for [x %] (+ 100 (second x)))

  • 0

At the Clojure REPL, this expression

( #(for [x %] (+ 100 (second x)))  ['(+ 38) '(+ 48)] )

produces (138 148) as expected

but this

( #(for [x %] ((first x) 100 (second x))) ['(+ 38) '(+ 48)] )

produces (38 48) which seems truly weird.

Both expressions really should be producing the same result!
What am I missing?
Will appreciate any ideas to resolve this mystery.

BTW, I tried to use ‘apply (first x)’ and package the rest of the args into a list but it doesn’t seem to matter. The same unexpected result comes back.

Also, to verify that the + indeed gets resolved from the input, I gave the following to the REPL

( #(for [x %] (resolve (first x) )) '((+ 38) (+ 48)) )

which produced

 (#'clojure.core/+ #'clojure.core/+)   as expected.
  • 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-27T15:45:56+00:00Added an answer on May 27, 2026 at 3:45 pm
    ( #(for [x %] ((first x) 100 (second x))) ['(+ 38) '(+ 48)] )
    

    In this the + is a symbol, not a function, because it has been quoted in the list. However, symbols are defined as doing map lookup when invoked as a function (the same as keywords). So ('+ 100 38) is the same as (get 100 '+ 38). That last argument is the “if you can’t find what I want in the map, return that”. Since 100 is not a map, + uses that argument as the return value.

    To make it do what you want you have two options:

    1. Use vectors instead of quoted lists ensures that + gets resolved appropriately.

      ( #(for [x %] ((first x) 100 (second x))) [[+ 38] [+ 48]] )
      
    2. Resolve it yourself to ensure that you use the + function instead of the + symbol.

      ( #(for [x %] ((resolve (first x)) 100 (second x))) ['(+ 38) '(+ 48)] )
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I typed this into Clojure REPL (using the enclojure Netbeans plugin): user=> hello, world
I'm doing my first steps with Clojure, but for some reason the up/down keys
When I paste this code into a REPL, it works fine: (use 'clojure.contrib.seq-utils) (defn-
I'm very new in learning Clojure. This intended to be my first and very
I'm trying to learn Clojure at the moment, but off to my parents this
I'd like to get a colored REPL for clojure code, similar to what you
When I try to run the following code (from the REPL) in Clojure: (dotimes
I'm trying to embed a swank-clojure repl into my application for the purpose of
I can't seem to find a way to launch the Clojure REPL with the
For some reason I can't get clojure REPL working with jline, what i did

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.