Fork me on GitHub
#beginners
<
2020-06-14
>
sova-soars-the-sora14:06:37

Hi, I want to turn the entries of a set into maps. It's the result of a datomic-esque query using datahike..

; ;; successfully returns all chats from room
(println  "haxorrr : "
  (d/q '[:find  ?authorid ?content ?timestamp ?messageid
       :in $ ?kind ?roomname
       :where
       [?m :message/kind ?kind]
       [?m :message/roomname ?roomname]
       [?m :message/authorid ?authorid]
       [?m :message/content ?content]
       [?m :message/timestamp ?timestamp]
       [?m :message/messageid ?messageid]]
  @conn "chat" "Beginners"))
returns
haxorrr :  #{[a.tester Welcome to the beginner's channel. Please post any questions you have here.  Feel free to discuss! 1592143964 aed7504f-b1a7] [c.tester Quite a hypothetical, indeed. 1592143964 cf91e354-abab] [b.tester That is a hypothetical. 1592143964 7c96b2a2-ef2b] [a.tester Say I had a question, you'd want to help me figure it out. 1592143964 7c22e8fd-6391] [a.tester Real mature, gems. 1592143964 ad536ace-5a3f]}
So I'd like a vector of maps instead, that way I can sort it by timestamp and generate a page from it. Is there a better way to sort by timestamp ? open to suggestions.

dpsutton15:06:45

does datahike support the pull syntax?

sova-soars-the-sora15:06:11

Neat. I have not used pull before... I recall it being a formative part of om.next but I still don't really get it

sova-soars-the-sora18:06:05

woots. makin' some progress aw yeah B-) thanks y'all

Lukas19:06:11

👋 Hi, I'm trying to spec a tuple where I only care about the first value. The second can be every arbitrary type how can I achieve that?

Lukas19:06:36

Okay nvm I guess any? will work for me 😇

William Skinner20:06:25

it looks like it's spending a good deal of time in processResults which I don't really care about

seancorfield21:06:27

@skinner89 I know you're using clojure.java.jdbc there, rather than next.jdbc but read this section of the latter's docs that talks about a possible issue there https://cljdoc.org/d/seancorfield/next.jdbc/1.0.462/doc/getting-started/prepared-statements#caveats

mister_m21:06:45

I find myself wanting to change the value of something I've defined in an outer let binding form when I encounter some condition inside of an inner letfn . Realizing that what I introduce in a let binding form cannot be changed, is there something analagous to let that would actually let me change the value of a binding?

andy.fingerhut21:06:24

You can 'shadow' the value of an earlier binding, even within the same let , but also within an inner let . That isn't mutating an existing value, just giving the same name to a new value.

seancorfield21:06:39

(let [a 1
      a (+ a 2)]
  a) ; 3

raspasov22:06:09

@radicalmatt any time you find yourself wanting to change something try thinking “well I can just make a NEW thing” 🙂

(let [a 1
      a' (+ a 2)]
  a') ; 3
I personally like the “a prime” approach where I don’t shadow bindings; instead I give them similar but different names