#clojure logs

2016-01-03

00:38jarsherineHi everyone
00:38jarsherineGood morning
00:55MorTal1tydoes anybody know if there is an up to date land of lisp but in clojure
01:16kenrestivoum, nope it's not for me
01:17kenrestivoJan 02, 2016 10:10:36 PM org.apache.http.impl.execchain.RetryExec execute
01:17kenrestivoINFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://clojars.org:443: Network is unreachable
01:18kenrestivook, well it is now, just popped up
01:26kenrestivoi'm pretty sure the mirrors function of lein doesn't actually fallback or mirror
02:40kopasetik"I haven’t yet seen a loop that can’t be decomposed into a combination of map, filter, reduce." - @dustingetz
02:40kopasetikAgree?
02:43amalloynot as stated. consider: int sum = 0, i = 0; while (i++ < 100) sum += i;
02:43amalloythis is easily stated in clojure as (reduce + 0 (range 101)), but you didn't admit other functions like range
02:45kopasetikamalloy: Good call
02:45amalloykopasetik: it's close, though, if you refine it to: loops that consume an input list
02:45kopasetikBasically, I'm wondering whether I'll be able to solve typical brainteaser interview questions using Clojure...
02:45amalloythen you get into the universality of folds
02:45amalloyyes
02:46amalloywell, i can. whether you can i can't vouch for
02:46kopasetikamalloy: Heh, I guess that's why I'm practicing
02:47kopasetikmap, reduce, and filter are much less confusing than for loops
02:47kopasetikNested for loops are the worst
02:49TEttingerkopasetik: no, hardly
02:50TEttingerfor(byte i = 0; i < 50; i--)
02:50TEttingerunchecked java arithmetic wraparound!
02:55TEttingerfor(byte x=-128,y=1; x<y; y<<1,x>>>1) {System.out.println(y);} //how many numbers will this print?
02:56TEttingerI like to think someone completely new entered the channel, saw that, and noped out of here
06:03annotationsincljhow do you write this in clj - public interface Foo { @MyAnnotation(hello="World") String foo(Bar input); }
06:04annotationsinclj,(definterface Foo (^String foo [^Bar input] ))
06:04clojurebotsandbox.Foo
06:05annotationsincljhow about the annotation
07:25taspatHi, after creating a basic lein project, cider-jack-in completes with no warnings. But doing C-c M-. I get "cannot find resource".
07:26MJB47try doing C-c C-k first
07:26MJB47?
07:27MJB47in a clj file
07:27taspatMJB47: i tried that, but same issue remains
07:27MJB47what symbol are you trying to find?
07:28MJB47a clj core one or one of your own?
07:28taspatprintln and .toUpperCase
07:29MJB47i assume you can send code to cider fine?
07:30taspatyes
07:30MJB47im afraid i dont know then :(
08:34Guest63553hi
08:36Guest63553:(
08:38kwladykaIs it possible to get RUM with rum/defc rum/defcs and macro < works in Intellij IDEA with Cursive? Especially i mean about indent, jump to definition, refactoring, show parameters etc. Or to configure is myself?
09:09maxxcanexit
09:30taspathi again, I do M-. on clojure function println in a basic lein project. However, C-c M-. yet does not work (reporting that resource was not found). M-. does not work .toUpperCase (asks for member of class..), neither does C-c M-. work
09:30taspathere is my .lein/profiles.clj
09:30taspathttps://gist.github.com/anonymous/f2ffc15f4531c7b73239
09:30taspatcider-jack-in executes with no errors
09:31taspatshould I include some paths of jdk, clojure in profiles.clj file?
09:31taspati searching on web for a solution but cannot find anything :/
09:33kwladykataspat should you write it on #emacs or similar channel?
09:39kwladykataspat but... i tried emacs yesterday with installation brew install emacs --HEAD --with-cocoa --with-gnutls --with-librsvg, and most of things works for me
09:40kwladykabut.... for me intellij is better
09:40kwladykabut :) did lessons with emacs learn me a lot how to use intellij better!
10:08tcrawleyjustin_smith: I've updated the wiki page with your workaround: https://github.com/clojars/clojars-web/wiki/Mirrors
11:30justin_smithtcrawley-away: cool
11:39justin_smithannotationsinclj left, but this is the answer https://gist.github.com/richhickey/377213
15:07taspatrender-component gets 2 arguments, but in this case I case pass hello-world function in (), [] or without any parentheses. https://gist.github.com/anonymous/226f527e71988e3df170
15:07taspathow does this work?
15:07ridcullyisnt there an opening ( missing on the first reagent call?
15:08ridcullyalso [] is just a vector
15:08ridcully,[+ - / *]
15:08clojurebot[#object[clojure.core$_PLUS_ 0x53aa3856 "clojure.core$_PLUS_@53aa3856"] #object[clojure.core$_ 0x56e7d31d "clojure.core$_@56e7d31d"] #object[clojure.core$_SLASH_ 0x2bbebe4a "clojure.core$_SLASH_@2bbebe4a"] #object[clojure.core$_STAR_ 0x1d4af67e "clojure.core$_STAR_@1d4af67e"]]
15:10justin_smithtaspat: passing the component inside [] is just redundant nesting
15:10justin_smithcallign the component (hello-world) means that @app-state is only looked up once (when it mounts), and future changes won't be seen
15:10justin_smithpassing it as hello-world will cause re-rendering with @app-state changes
15:11justin_smithtaspat: my preference is to pass in app-state as an argument to the component
15:11justin_smithtaspat: this makes testing cleaner, and makes the control/data flow more explicit
15:14taspatthanks justin_smith, where can i read about this more?
15:16justin_smithtaspat: the official reagent intro is good
15:23taspatjustin_smith: nice, I checked source code and the answer in render dom/render function
15:23taspatthanks again
15:28kwladykaSomebody know how to setup Intellij to works with rum functions rum/defc and rum/fecfs and also macro < ? I need functions like refactoring, show parameters, jump to source code etc.
15:32rhg135cfleming has mentioned adding a way to define the syntax for custom macros
15:33rhg135Might be implemented now
15:44kwladykammm i will try find something tomorrow in google
16:48aaelony#geekstogo
19:47slesterlein repl throwing "Could not locate main__init.class or main.clj on classpath" errors could mean what exactly? :(
19:48justin_smithslester: something is trying to (require 'main) and main.clj does not exist
19:48justin_smithor it's on the wrong place in the classpath
20:24m4ckhi peeps
20:25m4ckI'm trying to distinguish refs and atoms. I understand refs to be useful for when you need to update multiple identities in tandem.
20:25m4ckHowever, atoms would seem just as useful for that purpose too. Could anybody help make the distinction?
20:25justin_smithm4ck: you can't coordinate multiple atoms safely
20:26m4ckjustin_smith: not even if they're being swap!'d in the same transaction?
20:26justin_smithm4ck: for example if you have a container a, and a conainer b, and you need to increment one while decrementing the other (classic banking scenario), there is no safe way to do this with atoms
20:26justin_smithm4ck: swap! is not safe in transactions
20:26justin_smiththat's what the ! in swap! actually means
20:27m4ckI see!
20:27justin_smithm4ck: most things in clojure.core that end with ! are not safe inside transactions
20:27m4ckSo why would you not use a ref everywhere?
20:27justin_smithm4ck: because you can store multiple values in one atom
20:28justin_smithbecause sometimes your application logic doesn't require an atomic change that touches multiple containers
20:29m4ckMultiple values in one atom?
20:29justin_smithyes
20:29m4ckhttps://clojuredocs.org/clojure.core/atom <- indicates otherwise (although I'm sure I'm misunderstanding somehow)
20:29justin_smith,(def a {:a 0 :b [1 2 3]})
20:29clojurebot#'sandbox/a
20:29m4ckoh, in terms of a collection, ok
20:29justin_smiththere are multiple values in that hash-map
20:30justin_smithright
20:30m4ckThat is do-able with a ref though, right?
20:30justin_smithyes, but multiple values in one collections does not perform as well as using a ref for each value
20:31justin_smithrefs tend to be more complex to use, but perform better, and be more flexible
20:31justin_smithm4ck: consider, if you had all customer accounts in one hash-map in an atom, how much it would retry swaps
20:31justin_smithm4ck: every time two customer orders overlapped in time, you would have to run retries
20:32justin_smithrefs allow for a smarter design with less retries (because you can have finer granularity while still having atomic operations)
20:32m4ckRight, I get that now - I _think_ that clarifies everything
20:32justin_smithbut yeah, for most stuff, if it's not a performance bottleneck, we do just usually put a bunch of stuff in a hash-map in an atom, because that's simpler / easier to set up
20:33justin_smithm4ck: also, always remember that if you have side effects inside swap! or transact calls, you can see very odd results
20:33m4ckyup, I know to steer clear of that :)
20:34m4ckthanks for the help
20:34justin_smithm4ck: similarly, putting mutable objects inside an atom or ref (since retries won't work as designed)
20:34justin_smithnp
22:02devthelegant way of turning [:a 1 :b 2] into {:a 1 :b 2} ?
22:02devthof course i figured it out right after asking :)
22:02devth,(apply hash-map [:a 1 :b 2])
22:02clojurebot{:b 2, :a 1}
22:08devth,(take-nth 1 [:a 1 :b 2])
22:08clojurebot(:a 1 :b 2)
22:08devthwat?
22:09devth,(take-nth 2 [:a 1 :b 2])
22:09clojurebot(:a :b)
22:09devthi want 1 and 2
22:09justin_smith,(take-nth 2 (rest [:a 1 :b 2]))
22:09clojurebot(1 2)
22:09devthsure but why?
22:09devthseems strange
22:09justin_smithbecause it takes the first item, and then drops n
22:10justin_smithI mean sure, it could drop n and then take the next
22:10devthok. guess that makes sense.
22:10justin_smiths/n/n-1
22:13pilne... is it strange that the ability to mix my two favorite languages (lisp and haskell) almost... at-will has made me come to really like the jvm?
22:14justin_smithhaha, nice
22:14devthpilne: what's your haskell-on-jvm?
22:14pilnefrege
22:15devthcool. haven't played with it yet.
22:15devthgood?
22:16pilnesuper close to haskell, a few quirks due to the jvm, but the authors are definitely handling it well (it seems very inspired by clojure in how it brings a lisp syntax to the jvm without feeling "obligated" to be "common lisp")
22:17devthsounds awesome
22:18pilneand a stated goal is to be a "dialect" of haskell
22:20amalloyfrege compiles to java source code, really. that's an unusual approach
22:21pilnefor running on the jvm?
22:21amalloyyeah
22:22amalloybytecode is more common
22:22pilnei can see that actually
22:23devthwonder what perf implications/limitations are like
22:25pilnei'm not sure, i'm currently at that phase where i feel a bit... handcuffed by haskell compared to a lisp, so i'd probably just be calling functions written in frege from clojure for now
22:29pilnei love me some lisp, but the modern ecosystem of CL just feels like it is slipping, and haskell seems to offer a lot of what i enjoy in something "on the metal"
22:30pilneclojure saved me from a lot of headaches (:
22:39pilnealrighty.. stupid work stupid early tomorrow, ciao for niao!
23:09devth,(clojure.set/difference #{1 2 3} #{2})
23:09clojurebot#error {\n :cause "clojure.set"\n :via\n [{:type java.lang.ClassNotFoundException\n :message "clojure.set"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[java.net.URLClassLoader$1 run "URLClassLoader.java" 366]\n [java.net.URLClassLoader$1 run "URLClassLoader.java" 355]\n [java.security.AccessController doPrivileged "AccessController.java" -2]\n [java.net.URL...
23:09justin_smithdevth: you need to require clojure.set first
23:09devthclearest way to remove an item from a set?
23:09devthjustin_smith: ah
23:09justin_smithdevth: if it's a single item, you can just use disj
23:10justin_smith,(disj #{1 2 3} 2)
23:10clojurebot#{1 3}
23:10devthoh right. forgot about that. thanks
23:47_theriffer_whats the best way to merge a map into every occurrence of another map by its key in a deeply nested data structure (tree like)