Fork me on GitHub
#clojure
<
2017-03-04
>
ag05:03:26

what’s the proper way of validating ISO datetime string e.g. "1999-12-31T08:00:00-08:00"? Besides regexp. upd: ended up doing this: (not (nil? (clj-time.coerce/to-date “1999-12-31T08:00:00-08:00”)))

qqq05:03:02

Would reading it with the Java class, and catchin gcorresponding exceptions work?

qqq05:03:22

'iso spec' seems to imply 'complicated thing I don't want to implement myself'

qqq07:03:25

woot! I finally found a use for juxt on my own: I have objects of the form {:tag :vec2 ...} I want to add them with o+

(defmulti o+ (juxt :tag :tag))

qqq08:03:12

doh, just figured out what I really need is (fn [lhs rhs] [(:tag lhs) (:tag rhs)]) -- which, unfortunately, is not (juxt :tag :tag)

rauh09:03:26

@qqq #(mapv :tag %&)

Ethan Miller09:03:36

if i have a vector of items [[1] [2] [3]] that i want to add into another like so [:thing [1] [2] [3]] how would i do that?

val_waeselynck09:03:27

@ezmiller77 (into [:thing] [[1] [2] [3]])

pesterhazy12:03:14

the first law of clojure: the answer is reduce (or into)

mihaelkonjevic12:03:38

Hi, I don’t know if this is the right channel, but transit channel doesn’t exist, so I’ll ask here. Is there a way to have transit write handlers based on the protocol? If I have a bunch of records that all implement the same protocol, I’d like to serialize them in the same way

jaymartin13:03:03

How can we build better "first contact" experiences for new programmers and Clojurians? Our open source learning group is hosting the free online webinar Essential Klipse TODAY at 7 pm UTC (2 pm Eastern) to address that question. Everyone is welcome! http://discuss.thevalueoflearning.org/t/webinar-discussion-2-essential-klipse/39?u=jay

mruzekw18:03:05

I have this problem where my *.cljc files won’t reload on the server side. In other words, I have to restart my server to see the changes. The correct directories are in my build path, so I don’t know what’s up. Anyone have any idea?

mruzekw18:03:36

I’m using the wrap-reload middleware for ring, and the luminus template. If that helps at all

emccue19:03:26

How are comparisons done between clojure's immutable data structures?

emccue19:03:52

I ask because I'm trying to implement some of them in Python, along with an Atom implementation to do asynchronous stuff

emccue19:03:02

But even at the basic linked list I run into comparisons of O(n) and I am at a lost with vectors and maps

pesterhazy19:03:20

comparisons are going to be O(n)

istvan19:03:23

emccue there is a video about these and the time complexity of the operations

pesterhazy19:03:38

unless there is pointer equality

richiardiandrea19:03:11

Yeah the point is that you should do pointer equality

istvan19:03:27

Several operations on Clojure's persistent data structures are described as "essentially constant time". In all cases these are O(log32 n)

richiardiandrea19:03:38

But two equal objects should be then allocated only once on the heap

pesterhazy19:03:29

(= (map identity xs) (map identity xs)) is going to be O(n) by necessity

pesterhazy19:03:52

there's no way around checkin each element 🙂

joshjones19:03:58

@emccue You seem to be confusing data structure O() complexities with how clojure data is stored

richiardiandrea19:03:16

Unless you have an object pool yes @pesterhazy no?

pesterhazy19:03:52

@istvan, that blog post is talking about the nth operation, not =

pesterhazy19:03:26

@richiardiandrea, true, with String interning you might actually get identical?, not just =

istvan19:03:30

pesterhazy yep, comparisons are all O(n)

richiardiandrea19:03:46

Of course it adds some overhead

richiardiandrea19:03:58

So trade-offs 😀

pesterhazy19:03:09

not by default though...

pesterhazy19:03:14

user=> (= (str "a" "b") (str "a" "b"))
true
user=> (identical? (str "a" "b") (str "a" "b"))
false

istvan19:03:09

is this relevant?

emccue19:03:09

Oh okay so to do efficient comparisons I would need some sort of global object pool

joshjones19:03:25

@emccue this is a great series on how clojure's persistent data structures are implemented: (sorry, was linked above already i see) ... but, then once those structures are composed, then the algorithmic complexity of those data structures still applies...

pesterhazy19:03:29

but,

user=> (identical? "a" "a")
true

richiardiandrea19:03:33

@pesterhazy iirc Java does not intern all strings

richiardiandrea19:03:38

I actually always need to check these caching things on the JVM, there is a funny interview question on Integer too on this

richiardiandrea19:03:38

Yeah exactly the above thanks 😀😀 ^

pesterhazy19:03:15

haha what? Explain this please @rauh!

pesterhazy19:03:11

I guess these are boxed integers and they're only interned up to 2^7

pesterhazy19:03:56

that could generate funny bugs

emccue19:03:58

That Amazon book doesn't actually seem to cover how to implement any of those in an imperative way (for the purpose of being used in a functional way)

joshjones19:03:45

@pesterhazy it could, but no one should be doing == or identical? comparisons anyway without thinking of 'instances' instead of actual equality anyway, right?

gfredericks20:03:51

@joshjones == is not about instances

gfredericks20:03:06

unless you meant java's ==

gfredericks20:03:22

clojure.core/== is not about instances

joshjones20:03:24

yes, that's what I meant

gfredericks20:03:30

okay nevermind then 🙂

joshjones20:03:11

i suppose i was unclear, sorry 😉 i'm not sure i've ever used == in clojure, actually -- thanks for introducing it to me 🙂

gfredericks20:03:02

neither have I! 😄

gfredericks20:03:45

but I'm allergic to using the wrong numeric type for something

joshjones20:03:10

yes, numbers are quite complex (no pun), to be so simple 😉

joshjones20:03:43

now that I look at c.c/==, I'm not sure how I haven't used it before, but I'm glad to know it's there