I am late to the party but you might find 
https://blog.jakubholy.net/clojure-common-beginner-mistakes/ useful. It 
also links to a few very valuable resources.

On Thursday, December 17, 2020 at 12:42:41 AM UTC+1 Derek Troy-West wrote:

> Hello James,
>
>  Aditya links to one of Stuart Sierra's Do's and Don't posts.
>
> That series of posts really influenced my basic Clojure style and I'd 
> suggest reading them all: https://stuartsierra.com/tag/dos-and-donts, 
> they're (mostly!) great and simple advice.
>
> Best,
>  Derek
>
> On Tuesday, December 15, 2020 at 2:18:49 AM UTC+11 jamesl...@gmail.com 
> wrote:
>
>> Hello all,
>> This is my first Clojure program and I was hoping to get some advice on 
>> it since I don't know any experienced Clojure devs. I'm using it locally to 
>> print the latest build numbers for a list of projects.
>>
>> ```
>> (ns jlorenzen.core
>>   (:gen-class)
>>   (:require [clj-http.client :as client])
>>   (:require [cheshire.core :refer :all]))
>>
>> (defn fetch-pipeline
>> [pipeline]
>> (client/get (str "https://example.com/go/api/pipelines/"; pipeline 
>> "/history")
>> {:basic-auth "username:password"}))
>>
>> (defn get-latest-build
>> [pipeline]
>> (let [response (fetch-pipeline pipeline)
>> json (parse-string (:body response) true)]
>> (let [[pipeline] (:pipelines json)]
>> (:counter pipeline))))
>>
>> (def core-projects #{"projectA"
>> "projectB"
>> "projectC"
>> "projectD"})
>>
>> (defn print-builds
>> ([]
>> (print-builds core-projects))
>> ([projects]
>> (let [builds (pmap #(str % " " (get-latest-build %)) projects)]
>> (map #(println %) (sort builds)))))
>> ```
>>
>> This will output the following:
>> ```
>> projectA 156
>> projectB 205
>> projectC 29
>> projectD 123
>> (nil nil nil nil)
>> ```
>>
>> A few questions:
>>
>>    - How can this program be improved?
>>    - How idiomatic is it?
>>    - How can I prevent it from returning the nils at the end? I know 
>>    this is returning nil for each map'd item; I just don't know the best way 
>>    to prevent that.
>>
>> Thanks,
>> James Lorenzen
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/c8a1809f-50ba-4dab-ac3d-377a91b61dcen%40googlegroups.com.

Reply via email to