2014-12-25
| 04:26 | hellofunk | many splendid holiday wishes to you folks |
| 04:40 | dysfun | so how many people are writing code instead of lazing about eating too much? |
| 04:44 | hellofunk | dysfun: yeah i'm working today |
| 04:44 | TEttinger | dysfun: I got an F# book on the last day of hanukkah |
| 04:44 | hellofunk | not too much food here to eat anyway |
| 04:44 | SagiCZ1 | good morning guys |
| 04:44 | TEttinger | thinking of working through that |
| 04:45 | dysfun | i used to love working christmas |
| 04:45 | dysfun | you spend most of the time in the pub anyway |
| 04:45 | hellofunk | TEttinger so wait every song in the entire book is in the key of F#? that would get interesting |
| 04:45 | dysfun | TEttinger: commiserations. i find f# to be horrible |
| 04:46 | dysfun | the marketing seemed to be largely centered around "hey, look we've implemented the |> operator which does for functions what the unix pipe does for stdio" |
| 04:46 | dysfun | their minds might be blown if they discovered -> |
| 04:46 | TEttinger | ha |
| 04:46 | SagiCZ1 | heh |
| 04:47 | dysfun | there's an online tutorial with repl for it somewhere |
| 04:47 | dysfun | but you need silverlight |
| 04:47 | SagiCZ1 | bleh |
| 04:47 | dysfun | i ran through most of it and decided i didn't like it |
| 04:47 | TEttinger | for games, I kinda think the JVM is a rat's nest of performance pitfalls |
| 04:47 | dysfun | clojure/clr |
| 04:47 | TEttinger | I really did spend a lot of time optimizing clojure code to use arrays, etc. |
| 04:47 | dysfun | it'll still work and you can pick up more recent versions of the libraries |
| 04:48 | dysfun | of course now you've got a slightly different problem |
| 04:48 | dysfun | but hey there are lots of games libraries for .net |
| 04:49 | TEttinger | indeed. I'll probably use monogame. java has libgdx, which is bound to clojure with play-clj, but I kinda doubt play-clj scales well since it abstracts so much |
| 04:49 | dysfun | fwiw i'm using jmonkeyengine for graphical stuff |
| 04:49 | dysfun | but i'm not trying to squeeze the last ounce of performance out of it |
| 04:50 | AimHere | If you're using monogame, why not just ramp up to Unity? |
| 04:50 | TEttinger | I can manage pretty well with libgdx and java right now, actually |
| 04:50 | TEttinger | ugh |
| 04:50 | dysfun | with the exceptions of gaming and compiling scala code, computers have been 'fast enough' for some while |
| 04:50 | TEttinger | Unity is a totally alien environment to me, it's very opposed to the way I like to develop |
| 04:51 | dysfun | yeah, but it feels like the future too |
| 04:51 | AimHere | It is a bit of a culture shock, sure, but it is quite pleasant |
| 04:51 | AimHere | Once you get used to it |
| 04:51 | dysfun | i asked a friend who'se been building games for a living for like 20 years about the good bits. he said a surprising thing: everyone (not just devs) uses unity, that's the value in it |
| 04:51 | dysfun | so teamwork is enhanced |
| 04:52 | dysfun | as someone who's sat on the project management side of the fence a little too often, this might be the killer feature |
| 04:52 | TEttinger | heh, I'm a one-man team so that point kinda is missed on me |
| 04:52 | AimHere | Well even if you're a lone dude, that does mean that there are plenty of people on the net able to answer any questions on IRC, StackOverflow, Unity forums and the like |
| 04:53 | dysfun | me too, but i'm also not working in a games studio |
| 04:53 | dysfun | the pricing model is fascinating actually |
| 04:53 | dysfun | i think they've been very clever |
| 04:54 | TEttinger | I'm sure they make a lot of money off asset store purchases |
| 04:54 | AimHere | The price is another killer feature |
| 04:54 | SagiCZ1 | yeah i thought jmonkey was worth mentioning.. it works pretty ok.. it would be lovely if someone made a clojure wrapper like they made seesaw, because the api is not great |
| 04:54 | dysfun | very hard to get ubiquity as a non open-source product |
| 04:54 | dysfun | SagiCZ1: i'm using some code someone else cribbed together and am writing a library as i go along |
| 04:54 | SagiCZ1 | dysfun: in clojure? |
| 04:54 | dysfun | SagiCZ1: but i'm mostly rendering in 2d right now, so it may not meet your needs |
| 04:54 | dysfun | yes clojure |
| 04:55 | SagiCZ1 | cool.. im using it for my bachelor thesis project, not sure if my profesor would let me switch to clojure.. |
| 04:55 | dysfun | oh, you're in java? |
| 04:55 | SagiCZ1 | yea |
| 04:55 | dysfun | sorry, you're on your own :) |
| 04:56 | SagiCZ1 | still, do you have any github project i could check out? |
| 04:56 | dysfun | i'll ping you a link once i've tidied it up a bit |
| 04:56 | SagiCZ1 | great, thanks |
| 04:57 | dysfun | but i should get back to my swift code |
| 04:57 | hellofunk | dysfun: how do you like swift |
| 04:58 | hellofunk | dysfun: i started in Obj-C before the ARC days and now I wonder what swift would be like had we sticked with iOS products |
| 04:58 | dysfun | it feels quite programmable on the whole. my complaints are largely around compiler segfaults, ridiculous error messages, objectionable c interop and decisions they made a long time ago in libraries because objectionable c |
| 04:59 | dysfun | e.g. i had to disable autorelease on an NSWindow because otherwise i got a bizarre runtime error |
| 04:59 | hellofunk | dysfun: in short, how is it an improvement over Obj-C, which I rather liked? |
| 04:59 | dysfun | memory management is a lot more automatic-feeling |
| 05:00 | dysfun | locals just drop out of scope quietly and drop the reference count |
| 05:00 | hellofunk | dysfun: more so than Arc? |
| 05:00 | dysfun | yeah |
| 05:00 | dysfun | and if you overwrite something with nil it decrements the refcount too |
| 05:01 | hellofunk | interesting. syntax as a whole, more elegant, or about same basket of boilerplate for classes, etc? |
| 05:01 | dysfun | that NSWindow thing was because swift's cleverness tried to double-dealloc an NSWindow |
| 05:02 | dysfun | oh the syntax is much nicer than objectionable C imo. much less verbose too |
| 05:02 | dysfun | there are some things that are tedious, mind |
| 05:02 | hellofunk | sounds nice. i really liked developing for apple products, i must admit. too bad swift wasn't around when i did |
| 05:02 | dysfun | especially if you're using xctest |
| 05:02 | dysfun | i'm starting to appreciate cocoa |
| 05:02 | dysfun | this is a desktop project, not ios though. i no longer own any ios devices |
| 05:03 | dysfun | cocoa seems largely well put together |
| 05:03 | dysfun | swift, they've obviously compromised a lot to make it mostly seamless with objectionable c, but it's a good language |
| 05:03 | dysfun | the compiler is crap though and it segfaults a lot compiling complex code |
| 05:04 | hellofunk | how do you get around that? |
| 05:04 | hellofunk | if you can't compile your code?! |
| 05:05 | dysfun | you... rewrite it :/ |
| 05:06 | dysfun | and hope that one day they'll fix the compiler |
| 05:06 | dysfun | i didn't say the experience was perfect, but i have to put up with a lot of shit in most languages |
| 05:06 | dysfun | part of why i like clojure so much is it takes care of most of that for you |
| 05:25 | ticking | I wonder how long it takes for cljs to get an eval after all, the original point that eval is needed for dev environments has kinda gone out of the window since a lot of IDEs are now written in cljs... |
| 05:27 | SagiCZ1 | what would be the predicate for take-while to return all elements until for some succesive two elements a condition is met? |
| 05:27 | SagiCZ1 | for example (1 2 3 4 5 5 6 7) --> (1 2 3 4 5 5) when the predicate is = |
| 05:27 | ticking | SagiCZ1: that would require state in the predicate or someting not that simple I think |
| 05:28 | SagiCZ1 | yeah.. |
| 05:28 | SagiCZ1 | maybe use partial to create succesive pairs.. |
| 05:28 | SagiCZ1 | partition |
| 05:28 | ticking | yeah |
| 05:28 | SagiCZ1 | ,(partition-all 2 1 (range 10)) |
| 05:28 | clojurebot | ((0 1) (1 2) (2 3) (3 4) (4 5) ...) |
| 05:28 | ticking | partition is the first thing I came up as well |
| 05:28 | ticking | SagiCZ1: you could also do |
| 05:29 | ticking | ,(first (partition-by = [1 2 3 4 5 5 6 7])) |
| 05:29 | clojurebot | (1 2 3 4 5 ...) |
| 05:29 | ticking | ,(first (partition-by = [1 2 5 5 6 7])) |
| 05:29 | clojurebot | (1 2 5 5 6 ...) |
| 05:29 | ticking | hrm sec |
| 05:31 | ticking | SagiCZ1: lol sorry, partition-by is not partition between... |
| 05:43 | hellofunk | maybe a simple recursive loop would be good in that case SagiCZ1 |
| 05:44 | luxbock | ,(reduce (fn [seen n] (if (= (last seen) n) (reduced seen) (conj seen n))) [] '(1 2 3 4 5 5 6 7)) |
| 05:44 | clojurebot | [1 2 3 4 5] |
| 05:46 | hellofunk | luxbock: but the reduce would still go through the entire seq, right? because reduce doesn't cut out on a test |
| 05:46 | luxbock | that's what `reduced` does |
| 05:46 | ticking | hellofunk: reduced will cut |
| 05:46 | hellofunk | well hot damn learned something new, that's awesome. didn't know that one. |
| 05:50 | dysfun | hrm, that would have been handy to know about |
| 05:52 | hellofunk | dysfun: if you didn't know reduced either, then i won't feel too bad |
| 05:52 | dysfun | why would you feel bad? i discover things all the time |
| 05:53 | dysfun | i've been paid to write code for over ten years now, not to mention all the unpaid before and i've not stopped learning yet |
| 06:07 | dysfun | okay, writing tests in swift/xctest is a lot more tedious than clojure/midje |
| 06:14 | hellofunk | dysfun: so in other words you can do it in clojure even more swiftly than swift |
| 06:17 | dysfun | because it's so unlike apple to employ marketing in the naming of things |
| 06:27 | ticking | dysfun: far better than iLanguage though |
| 06:28 | ticking | which is only the version without assignment and bitwise operations btw if you want that you need Language Pro |
| 06:32 | dysfun | hah |
| 06:48 | dysfun | thanks to multicultural britain, my local greasy spoon cafe is actually open today so we're outsourcing breakfast |
| 07:33 | hellofunk | dysfun: here in NL i had to go to train station to find anything open, and got myself some doner kebab |
| 08:16 | dysfun | hellofunk: well my flatmate and i have feasted on fryups. great stuff. |
| 08:38 | justin_smith | luxbock: don't use last on vectors, use peek |
| 08:38 | justin_smith | last is guaranteed linear time |
| 08:39 | justin_smith | peek is O(1) |
| 08:42 | justin_smith | ,(butlast (reductions (fn [prev n] (if (= prev n) (reduced n) n)) [1 2 3 4 4 5 6 7])) |
| 08:42 | clojurebot | (1 2 3 4) |
| 08:43 | justin_smith | (lazy version) |
| 10:47 | delexi | is there an abs function in clojure? |
| 10:50 | AimHere | delexi, a lot of mathematical functions are palmed off to java so that it becomes Math/function |
| 10:50 | AimHere | ,(Math/abs -0.3) |
| 10:50 | clojurebot | 0.3 |
| 10:51 | AimHere | It might not work with all numeric types |
| 10:54 | delexi | AimHere: Ah, dang, of course! Thanks! |
| 10:57 | SagiCZ1 | btw look at incanter if you care about infix notation and such things |
| 11:41 | AimHere | Hmmm, I'm feeling stupid. Is it possible to create a record with defrecord that has a circularly linked field, without mutable state? I figure that consigning the whole field to dirty old mutability forever because you only want to change it once to actually initialize it is a bit overkill |
| 12:47 | TimMc | &(Math/abs 5N) |
| 12:47 | lazybot | java.lang.IllegalArgumentException: No matching method found: abs |
| 12:48 | TimMc | &(.longValue 9999999999999999999999999999999999N) |
| 12:48 | lazybot | ⇒ 4003012203950112767 |
| 12:49 | TimMc | &(.longValue (inc' Long/MAX_VALUE)) |
| 12:49 | lazybot | ⇒ -9223372036854775808 |
| 12:49 | TimMc | :-( |
| 12:49 | andyf | .longValue is asking for truncation, yes? |
| 12:49 | TimMc | Apparently. |
| 12:50 | TimMc | So to get get the absolute value of a Number you'd have to do something with checking if it is < 0 and then multiplying by -1 if so. |
| 12:51 | andyf | math.numeric-tower should already have it implemented |
| 12:51 | andyf | I haven't used it personally, but its there in the docs |
| 12:51 | TimMc | *nod* |
| 12:53 | engblom | ,(println "Merry Christmas") |
| 12:53 | clojurebot | Merry Christmas\n |
| 13:32 | preschema | hi, is there a wiki engine written in Clojure? |
| 13:32 | preschema | also, is there a list anywhere of the various web-based softwares written in Clojure? |
| 13:43 | preschema | so in case there is no wiki engine written in Clojure yet, would anyone be interested in a collaboration to port Instiki from rails to Clojure? i think it would be great for Clojure, if done well. furthermore it will go live on a very big wiki used by pure mathematicians (where i am technical admin) |
| 13:47 | kenrestivo | you could go to http://crossclj.info/ and search for compojure, ring, even "wiki" |
| 13:48 | kenrestivo | i think searching for the basic compojure functions, and looking up all its usage, will give you pretty much all the existing clojure web apps, at least the ones indexed there |
| 13:49 | kenrestivo | "transitively used by 491 artifacts" eg http://crossclj.info/ns/compojure/1.3.1/project.clj.html |
| 13:50 | preschema | thanks |
| 13:51 | kenrestivo | tho there are web apps that don't use compojure, but most do. searching for ring might be good too. i find crossclj the best tool for choosing libraries or looking for example code for how to use one (esp when the documentation is thin). |
| 14:01 | jonathanj | yogthos: it seems like specifying :target-path in project.clj was breaking `lein ring uberjar` |
| 14:03 | yogthos | jonathanj: ah lein-ring is might be expecting a hardcoded location for the target? |
| 14:04 | jonathanj | yogthos: i'm not sure what the reason is, all i know is that removing that stopped the warning about missing a main method |
| 14:31 | newfriend | does anyone know how to enable syntax highligting in the cider-repl |
| 14:51 | justin_smith | AimHere: I would make the :children key (or whatever you call it in your record) a promise |
| 14:51 | justin_smith | that allows circularity via delayed evaluation, without mutability |
| 14:52 | justin_smith | though it does require deref for direct access - likely you would want to implement a protocol that hides all that ugliness |
| 14:52 | AimHere | Aha, I forgot laziness |
| 14:52 | justin_smith | well promises aren't lazy, per-se |
| 14:52 | justin_smith | but similar concept, for sure |
| 14:53 | AimHere | SICP tends to use promises in their implementation, as I recall |
| 14:54 | justin_smith | promises implement lazy-seqs, but are not lazy-seqs concretely :) |
| 14:54 | justin_smith | *can implement |
| 14:54 | justin_smith | I don't think clojure lazy-seqs use promises |
| 14:55 | AimHere | Won't it use a similar mechanic, even if hardcoded in Java? |
| 14:55 | justin_smith | (list 'new 'clojure.lang.LazySeq (list* '^{:once true} fn* [] body))) |
| 14:55 | justin_smith | that's lazy-seq (arg vector was [& body]) |
| 14:56 | justin_smith | not java, not a promise |
| 14:56 | justin_smith | well, partially java, OK |
| 14:56 | justin_smith | that looks more like delay than promise though |
| 14:57 | justin_smith | and delay isn't as nice for circular structures as promise is |
| 15:29 | OscarZ- | im trying to get NREPL server running on my Java application.. i suppose i need to run start-server somehow from native java.. any ideas? |
| 15:29 | OscarZ- | or is that even possible.. do I need to have native Clojure application for that? |
| 15:29 | justin_smith | OscarZ-: should just be a question of using clojure.lang.RT - but it would be easier to make a namespace of clojure code that takes care of all the details, and makes a function you can invoke from java |
| 15:29 | justin_smith | s/would/might |
| 15:30 | OscarZ- | yeah.. i'll probably have use for some helper functions in that namespace.. thanks ill look into RT |
| 15:31 | justin_smith | http://blog.jayfields.com/2011/12/clojure-java-interop.html this has a good intro in the second half |
| 15:32 | justin_smith | pretty simple actually |
| 15:38 | delexi | I am trying to solve the doublets wonderland-clojure-kata but got stuck with an error I don't know what to do with. The Exception along with the code can be found here: https://gist.github.com/5e29a9ab0bdecb6cdec1 What did I do wrong? |
| 15:39 | justin_smith | delexi: in the let binding for neighbors, map gets the args in the wrong order |
| 15:40 | justin_smith | I think you meant to use ->> instead of -> |
| 15:40 | justin_smith | (in fact every clause there gets the args in the wrong order, but ->> would fix that) |
| 15:42 | justin_smith | since it gets a function instead of a collection, and a collection instead of a function, you get the error "Don't know how to create ISeq from: doublets.solver$doublets$doublets_rec__3564$fn__3569" |
| 15:42 | delexi | ah, thank you, this removes the exception. Now off to see, why the code returns the wrong result! |
| 16:02 | grios | All Clojure code (and other lisps) I find has very short variable names, people seem to favour one-letter namer rather than something more descriptive. Is there a style guide that say's that's good, or is that just lisp tradition? //Confused code-reader |
| 16:02 | OscarZ- | justin_smith, cool i got it to work.. was really easy :) |
| 16:02 | justin_smith | grios: it really depends - I think super short names are common in fp |
| 16:03 | justin_smith | grios: also, in fp, sometimes the code is so general, no longer name would be especially helpful |
| 16:03 | grios | justin_smith: why? Do people need to save 5 bytes of source code? |
| 16:03 | justin_smith | (look at the variable names they use in math) |
| 16:03 | grios | justin_smith: ah, that kinda makes sense |
| 16:04 | justin_smith | ie. if you have a function like (defn dotwice [f] (fn [x] (f (f x)))) - f and x are probably the best names you can use there |
| 16:05 | justin_smith | grios: in haskell, they have "point free style" where they even eliminate variable names (it's all implicit application on unnamed args) |
| 16:05 | OscarZ- | justin_smith, heh yeah.. i always have trouble with that point free style |
| 16:16 | OscarZ- | justin_smith, in interop/Example.java, why is there no arguments in (defn main [] println) ? it seems that when its called from Java, there is argument passed f.invoke("hello world") ? |
| 16:29 | OscarZ- | ah its returning the function to java side.. misunderstood what its trying to do |
| 16:31 | OscarZ- | if i want to have something like a global variable that is only assigned once.. a bit like Java final, is it ok to just use def to assign it to some namespace? |
| 16:31 | OscarZ- | it will be some java object which methods i will be calling later on |
| 16:33 | justin_smith | OscarZ-: well, vars are mutable |
| 16:33 | chouser | yes, though you may want (defonce ^:constant foo value) |
| 16:33 | justin_smith | if you want something that is truly single assignment maybe you could use a promise or delay and hold onto that, and not its var |
| 16:34 | chouser | oh, sorry ^:const |
| 16:34 | OscarZ- | i see |
| 16:37 | chouser | I wouldn't worry about vars being technically mutable. People generally don't mutate them. |
| 16:39 | OscarZ- | yes, in this case im calling my nrepl setup code from Java application and i just want to pass in some object that i can refer to in my clojure code |
| 16:39 | OscarZ- | im impressed how to easy it was to get this thing going :) |
| 16:40 | justin_smith | clearly some thought was put into making it a usable API |
| 16:40 | OscarZ- | going to try the "bean" function you told about earlier |
| 16:45 | SagiCZ1 | how does one mutate a var? |
| 16:45 | justin_smith | SagiCZ1: def |
| 16:45 | SagiCZ1 | ,(def x 6) |
| 16:45 | clojurebot | #'sandbox/x |
| 16:45 | SagiCZ1 | ,(def x 7) |
| 16:45 | clojurebot | #'sandbox/x |
| 16:45 | SagiCZ1 | thats how? |
| 16:45 | justin_smith | yes, that mutates the var |
| 16:45 | SagiCZ1 | thats not something you would do in a production code though |
| 16:45 | justin_smith | one would hope not |
| 16:47 | SagiCZ1 | now that you are here.. do you have any idea what the exclamation marks in different function names mean? like why is the new run! function with exclamation mark when it does almost the same thing as doseq which has no ! .. |
| 16:48 | justin_smith | it's complicated and not super internally consistent. One general idea is that things unsafe in transactions often have ! |
| 16:49 | justin_smith | but in scheme things that do side effects have ! and we see some of that carried over too |
| 16:50 | SagiCZ1 | too bad its not consistent |
| 16:51 | SagiCZ1 | what is a transaction? |
| 16:51 | justin_smith | &(->> (all-ns) (mapcat ns-publics) (map (comp name key)) (filter #(.endsWith % "!"))) |
| 16:51 | lazybot | java.lang.SecurityException: You tripped the alarm! ns-publics is bad! |
| 16:51 | justin_smith | blergh |
| 16:51 | justin_smith | ,(->> (all-ns) (mapcat ns-publics) (map (comp name key)) (filter #(.endsWith % "!")) (clojure.string/join "; ")) |
| 16:51 | clojurebot | "vswap!; vreset!; set-error-mode!; set-agent-send-executor!; disj!; conj!; pop!; compare-and-set!; reset-meta!; set-error-handler!; set-agent-send-off-executor!; dissoc!; assoc!; reset!; alter-meta!; persistent!; run!; set-validator!; swap!; volatile!; io!; set-break-handler!" |
| 16:51 | andyf | You can also mutate at least the thread-locally bound value of a Var with set! I believe. |
| 16:51 | justin_smith | as you see, it's not many things that are named that way |
| 16:52 | justin_smith | andyf: and alter-var-root |
| 16:52 | SagiCZ1 | okay then |
| 16:53 | justin_smith | I wonder why ns-publics is restricted |
| 16:53 | justin_smith | (on lazybot, that is) |
| 17:19 | Dynasty | does anyone know if there is documentation for writing Light Table plugins? |
| 17:26 | dbacar | hello |
| 17:27 | dbacar | i have a web app initiated like this |
| 17:27 | dbacar | (def app (-> #'app-routes |
| 17:27 | dbacar | (enforce-content-type-middleware "text/html") |
| 17:27 | dbacar | (wrap-defaults site-defaults) |
| 17:27 | dbacar | (nses/wrap-noir-session {:store (memory-store nses/mem)}) |
| 17:27 | dbacar | )) |
| 17:27 | dbacar | |
| 17:28 | dbacar | it seems I use two session wrappers |
| 17:29 | dbacar | and in my application session-id seems to change in between requests |
| 17:29 | dbacar | so I lose the session |
| 17:30 | dbacar | it is convenient to use noir to have get and put! commands, is it still the recommended way to deal with sessions? |
| 17:31 | dbacar | any ideas? |
| 17:37 | dbacar | anyone here? |
| 17:37 | dbacar | anyone reading my message? |
| 17:38 | SagiCZ1 | i do |
| 17:38 | SagiCZ1 | but i have no idea how to help you.. sorry |
| 17:38 | hyPiRion | it's christmas day, most people are probably doing something with their family |
| 17:43 | dbacar | terribly sorry, i am new to emacs erc, so thought it was sth wrong with connection |
| 17:43 | dbacar | merry christmas |
| 17:43 | dbacar | :) |
| 17:44 | hyPiRion | happy holidays |
| 17:51 | octe | i have a nested list like this: http://pastebin.com/4YPSqGTL |
| 17:51 | octe | i want to extract the lists containing numbers from that |
| 17:51 | octe | transform it into ((30000139 30000144 30000140 30000142) (30000139 30000144 30000142) (30000139 30000144 30000143 30000142)) i guess |
| 17:52 | SagiCZ1 | you want to leave out the nils? |
| 17:52 | octe | and semi-flatten it |
| 17:52 | SagiCZ1 | whenever you encounter something like this, think first about how you actually got such a mess and try to fix it there |
| 17:52 | andyf | I was going to suggest flatten, but it sounds like you want some list structure to remain? |
| 17:53 | octe | yes |
| 17:53 | andyf | (remove nil? ...) is good for one level, at least. |
| 17:54 | octe | SagiCZ1, yes, that's probably something i need to fix. i became curios on how to solve this though |
| 17:55 | dbacar | would clojure.walk be helpful here? |
| 17:55 | SagiCZ1 | maybe treeseq |
| 17:55 | octe | it feels like it |
| 17:55 | octe | but i'm not sure ho |
| 17:55 | octe | w |
| 18:03 | SagiCZ1 | can i hook a listener to an atom to do something when its value changes? |
| 18:03 | SagiCZ1 | in seesaw particulaly |
| 18:04 | justin_smith | SagiCZ1: add-watch maybe? |
| 18:04 | SagiCZ1 | cool thanks |
| 18:05 | justin_smith | SagiCZ1: octe: yeah, tree-seq plus a filter based on (fn [el] (and (coll? el) (every? number el)) would probably do it |
| 18:07 | andyf | octe: This probably won't always do what you want, but it seems to work on the example given: (filter #(and (sequential? %) (every? number? %)) (tree-seq seq? seq d1)) |
| 18:07 | octe | justin_smith, thanks, i'll give it a try |
| 18:08 | andyf | Ah, missed justin_smith answer |
| 18:08 | octe | andyf, cool, that works |
| 18:11 | justin_smith | octe: https://www.refheap.com/95412 |
| 18:12 | justin_smith | andyf: haha, and you got the more concrete answer while I was busy composing, formatting, and pasting mine |
| 18:12 | justin_smith | but the fact that the two of us each came up with that is reassuring :) |
| 18:16 | SagiCZ1 | i have a collection on which i take while like this (take-while #(some-predicate %) coll), i also want to stop taking when the lement is nil.. how would i do that? |
| 18:17 | justin_smith | SagiCZ1: (take-while #(and (some %) (some-predicate %)) coll) |
| 18:17 | justin_smith | wait, no, not some |
| 18:17 | justin_smith | some? |
| 18:18 | justin_smith | I get the two confused sometimes :) |
| 18:18 | justin_smith | (doc some?) |
| 18:18 | SagiCZ1 | me too |
| 18:18 | clojurebot | "([x]); Returns true if x is not nil, false otherwise." |
| 18:18 | justin_smith | &(some? false) |
| 18:18 | lazybot | ⇒ true |
| 18:18 | justin_smith | yup, that's the right one |
| 18:18 | SagiCZ1 | thank you |
| 18:20 | SagiCZ1 | ,(map some? [nil 0 false true]) |
| 18:20 | clojurebot | (false true true true) |
| 18:20 | SagiCZ1 | ,(map boolean [nil 0 false true]) |
| 18:20 | clojurebot | (false true false true) |
| 18:20 | SagiCZ1 | i see |
| 18:23 | hex6 | What's the best practice to split up your project into several files? right now I have one ns and use (load "file") and (in-ns ...) |
| 18:23 | SagiCZ1 | you can group functions and have a namespaces for each of them |
| 18:35 | SagiCZ1 | i need to format a double |
| 18:35 | SagiCZ1 | ,(format "%.2d" 45.976) |
| 18:35 | clojurebot | #<IllegalFormatPrecisionException java.util.IllegalFormatPrecisionException: 2> |
| 18:36 | SagiCZ1 | ,(format "%.2f" 45.976) |
| 18:36 | clojurebot | "45.98" |
| 18:36 | SagiCZ1 | ,(String/format "%.2f" 45.976) |
| 18:36 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Double cannot be cast to [Ljava.lang.Object;> |
| 18:37 | SagiCZ1 | ,(String/format "%.2f" (to-array 45.976)) |
| 18:37 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unable to convert: class java.lang.Double to Object[]> |
| 18:37 | SagiCZ1 | ,(String/format "%.2f" (to-array [45.976])) |
| 18:37 | clojurebot | "45.98" |
| 18:37 | dbacar` | (= 3 4) |
| 18:37 | SagiCZ1 | ,(String/format Locale.US "%.2f" (to-array [45.976])) |
| 18:37 | clojurebot | #<CompilerException java.lang.ClassNotFoundException: Locale.US, compiling:(NO_SOURCE_PATH:0:0)> |
| 18:38 | dbacar` | ,(= 3 4) |
| 18:38 | clojurebot | false |
| 18:38 | dbacar` | oh my goodness :), ididnt know this |
| 18:38 | SagiCZ1 | ,(String/format java.util.Locale.US "%.2f" (to-array [45.976])) |
| 18:38 | clojurebot | #<CompilerException java.lang.ClassNotFoundException: java.util.Locale.US, compiling:(NO_SOURCE_PATH:0:0)> |
| 18:38 | SagiCZ1 | god damn |
| 18:38 | SagiCZ1 | what a hassle |
| 18:39 | SagiCZ1 | (String/format java.util.Locale/US "%.2f" (to-array [45.976])) |
| 18:39 | SagiCZ1 | ,(String/format java.util.Locale/US "%.2f" (to-array [45.976])) |
| 18:39 | clojurebot | "45.98" |
| 18:39 | SagiCZ1 | finally |
| 18:39 | SagiCZ1 | clojure should really make the format function to accept locale, this is just terrible |
| 18:41 | andyf | SagiCZ1: Why not just use format? |
| 18:41 | hex6 | What was wrong with ,(format "%.2f" 45.976)? |
| 18:42 | andyf | ah, because you need to specify a locale? |
| 18:42 | SagiCZ1 | whats wrong? it ASSUMES my locale.. and since my locale is non us, it uses different decimal separator |
| 18:42 | SagiCZ1 | i hate when someone ASSUMES locale.. horrible |
| 18:42 | SagiCZ1 | it solve 2 problems and creates 5000 new ones |
| 18:43 | andyf | You might have gotten there with a bit less hassle if you had read (source format) |
| 18:45 | JackRack | , (source format) |
| 18:46 | clojurebot | Source not found\n |
| 18:46 | SagiCZ1 | (source format) |
| 18:46 | JackRack | ,(source format) |
| 18:46 | clojurebot | Source not found\n |
| 18:46 | SagiCZ1 | did this ever work? |
| 18:47 | JackRack | ,(clojure.repl/source format) |
| 18:47 | clojurebot | Source not found\n |
| 18:57 | andyf | SagiCZ1: Try a local repl instead |
| 18:57 | SagiCZ1 | i just ctrl+click to see the source |
| 19:33 | sova | I am fascinated by clojurebot. does anyone know how it (she?) works? |
| 19:33 | alexbara` | how can I set styles on a snippet using Kioo/Enlive? |
| 19:53 | alexbara` | anyone around who has used much Enlive or Kioo that I could run a question by? |
| 19:57 | kl | What does (Boolean. "false") do? |
| 19:58 | kl | Specifically, it's the (Something. "something") syntax I'm looking to decipher |
| 20:00 | ambrosebs | kl: expands to (new Something "something") |
| 20:00 | ambrosebs | calls the 1 argument constructor on Something |
| 20:00 | kl | ambrosebs: I see, thank you! |
| 20:01 | ambrosebs | kl: np |
| 20:10 | andyf | kl: Strongly recommended against using the constructor for class Boolean, though, for Java and Clojure |
| 20:11 | andyf | because this.... |
| 20:11 | andyf | ,(if (Boolean. false) "true" "false") |
| 20:11 | clojurebot | #<AccessControlException java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")> |
| 20:11 | andyf | well, if you do that in a local repl, you will see "true" as the result, which is very surprising. |
| 20:12 | andyf | sova: There is source code in a GitHub repo for clojurebot, I'm pretty sure. |
| 20:14 | andyf | sova: Not sure if this is the most up to date repo: https://github.com/hiredman/clojurebot |
| 20:14 | kl | andyf: thanks for the heads up, I'm aware of that issue :) |
| 20:14 | kl | The text explained that problem, without the syntax (from what I saw, at least!) |
| 21:10 | ffwacom | is there any reason why 'lein test' would be taking forever to run? |
| 21:30 | mearnsh | stumped by a bug. see two examples at end, using a trusty prn to find where the first one fails and testing directly on that case (second example), works https://www.refheap.com/95414 |
| 22:15 | justin_smith | ffwacom: a common culprit for things like that is side effects (like creating a server or thread) at the top level of a namespace |
| 22:15 | justin_smith | ie. (def server (run-jetty ...)) |
| 22:15 | justin_smith | bad idea |
| 22:16 | ffwacom | hmm might be the case, datomic transactor is being started |
| 22:17 | justin_smith | mearnsh: the exception clearly states that the function "atom" is being used where a number is expected |
| 22:17 | justin_smith | but nothing in the code you pasted uses atom |
| 22:18 | justin_smith | also, using "atom" to mean things other than clojure.core/atom is going to confuse people |
| 22:18 | ffwacom | justin_smith: ah had some api calls being made |
| 22:18 | ffwacom | thanks |
| 22:19 | justin_smith | ffwacom: yeah, the common pattern is to def an "init" function, and either generate the resources you need inside that and return them, or fulfill a promise/ force a delay, whathaveyou |
| 22:19 | justin_smith | and just document that init must be called, of course |
| 22:20 | ffwacom | sounds good |
| 22:21 | justin_smith | actually, if you use delays (which only run when \they are dereffed) you may not need an init |
| 22:21 | justin_smith | depending on your logic of course |
| 23:15 | sova | andyf: thanks on the linkage. |