Fork me on GitHub
quan xing10:07:50

What's means about (map->Interceptor t) , is map->Interceptor a fixed notation?

Alex Miller (Clojure team)11:07:17

No, it's just a function name

Alex Miller (Clojure team)11:07:57

It is a little special in that defrecord creates two constructor functions with well known names, map->TheRecord (takes a map, returns an instance of the record), and ->TheRecord which take record fields positionally and returns an instance of the record

Alex Miller (Clojure team)11:07:25

(doc defrecord) for more detail

quan xing11:07:16

sorry. I got it. I didn't notice that It is a defrecord. It's a function factory. I forgot how to use it. Thanks.

quan xing11:07:43

This code is from pedestal. I want to know how it works. But I I found my skills a little lame. I might be used to reading Java code, but when I read Clojure code, the full contents of a function's parameters are unknown and I have to work my way from the top to the bottom, which is a bit of a struggle to understand


Don't worry about it. That particular part of Clojure isn't very discoverable. I think everyone is confused when they first run into it. It's a bit of an oddity.

quan xing10:07:53

Ok. I need to be patient to learn. Thanks.


I found this book Poetry of Programming It's aimed towards "non-programmers, in particular for Liberal Arts students with some college/high school algebra background," As a novice programmer I found this more gentle than other resources that are commonly listed here. I will continue with the Brave Clojure after completing this.

👍 4
🎉 1
Bart Kleijngeld16:07:42

Looks interesting, thanks for sharing!


How to Design Programs is written from a similar perspective, aiming to be an intro CS text that imagines programming as part of a liberal arts college curriculum: You may find it useful as well.

❤️ 1

How to do assoc in variable of type clojure.lang.PersistentArrayMap ?


field-values=> (assoc (array-map) :a 1)
{:a 1}
field-values=> (type *1)


best not to rely on concrete types


field-values=> (type {:key :value})
field-values=> (assoc {:key :value} :extra :info)
{:key :value, :extra :info}
you’ve been using them this whole time. That’s the beautify of the language


I am trying it with filter , which is not happening


can you show what you are trying?


something like

(println (filter (fn [data]
                   (println "----s--" (type data))
                   (when (= "Actual" (get data "sectionTitle"))
                     (assoc data "Date" (str "P-- " (get data "Date"))))) title)


but it is not updating Date key


right. Because filter doesn’t return the value of the function, it keeps or discards the original based on if the predicate is truthy


field-values=> (map inc [1 2 3])
(2 3 4)
field-values=> (filter inc [1 2 3])
(1 2 3)


there should be no need to wrap your forms in println


just type into your repl


it will print the answers automatically


i am trying in intellj


intellij has a keystroke to evaluate a form and print it in the REPL (I don't know what it is)


there’s also a repl input window so you can just type there at the very least


@U11BV7MTK, I did not get you, does that mean it wont update the map?


field-values=> (doc filter)
([pred] [pred coll])
  Returns a lazy sequence of the items in coll for which
  (pred item) returns logical true. pred must be free of side-effects.
  Returns a transducer when no collection is provided.


it returns the items in the coll for which (pred item) returns logical true. It doesn’t return arbitrary stuff. Its just a way of selecting items from a collection


@U11BV7MTK Got it Thanks 🙂

Chris G19:07:29

if im understanding correctly assoc will do what your asking

Chris G19:07:38

cljs.user=> (assoc {} :a {:something "else"})
{:a {:something "else"}}


Hi folks. Can someone direct me to a good starting place for learning about modern string timestamp conversion? I need to convert strings like "2022-07-11T10:42:30.707+02:00" and "2022-07-11T08:43:28.6901659Z" to timestamps which postgresql jdbc will accept for timestampz or timestamp with time zone columns. I'm not actually sure which I should be using, but anything that works is a start at this point 🙂. (I'm consuming an API which unfortunately has a mix of timestamp representations, but the time part is not especially critical to my needs anyway.)


As a first step, you can use one of these parsers (java.time.ZonedDateTime/parse "2022-07-11T08:43:28.6901659Z") (java.time.Instant/parse "2022-07-11T08:43:28.6901659Z") (clojure.instant/read-instant-date "2022-07-11T08:43:28.6901659Z") It will give to you an ZonedDateTime, an Instant or an java.util.Date Once you have these date objects, you can take a look at


Awesome, thank you very much


@U9RGZJC4C That section of the docs has recently been updated on GH (but not yet published) to provide advice from a PostgreSQL user who says to avoid the timezone column stuff in PG and use plain timestamp and try to do everything in UTC and only convert TZs at the edges (on input and for display).

👌 1

Yeah, that blog post comes up every time UTC is discussed for databases...


As that article says, there are some situations where you need additional information but for most situations, "UTC everywhere" is simple and workable.


We store member TZ as well as "everything in UTC", for example.