-2

how can I print list elements using let keyword in clojure language?

(defn build-headline-keywords-item [es-client conf common-item headline]
  (let [headline headline]
  (println (:headline))
  (es/upsert es-client conf (merge common-item{:source ["headline"]
                                          :type ["headline"]
                                          :keywords headline}))))
shivani thakur
  • 219
  • 1
  • 3
  • 12

2 Answers2

1

If I understand you correctly, it should look more like this:

(defn build-headline-keywords-item 
  [es-client conf common-item headline]
  (println headline)
  ... )

UPDATE:

If you are still having trouble, make a test file and remove bits one-by-one until you get something that works. Then add the bits back in one at a time to build up the whole problem. It will work:

Code:

(defn build-headline [a b c headline]
  (println headline))
(build-headline 1 2 3 "Space Aliens Invade!")

Result:

> lein run
Space Aliens Invade!

Please also see the online book Clojure for the Brave & True for more information.

Alan Thompson
  • 29,276
  • 6
  • 41
  • 48
1

Alan's answer covers the important parts of how to use Clojure to do this.

I'll take a different path and ask about whether this is an issue with your environment. Are you working in a REPL? Or running things in some other way? What is the actual thing you are running or evaluating?

Maybe you are using an editor where the console output is going someplace you're not seeing? For example, in Emacs the console output may go to a buffer that is not visible.

Alex Miller
  • 69,183
  • 25
  • 122
  • 167