2016-01-03
| 00:38 | jarsherine | Hi everyone |
| 00:38 | jarsherine | Good morning |
| 00:55 | MorTal1ty | does anybody know if there is an up to date land of lisp but in clojure |
| 01:16 | kenrestivo | um, nope it's not for me |
| 01:17 | kenrestivo | Jan 02, 2016 10:10:36 PM org.apache.http.impl.execchain.RetryExec execute |
| 01:17 | kenrestivo | INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://clojars.org:443: Network is unreachable |
| 01:18 | kenrestivo | ok, well it is now, just popped up |
| 01:26 | kenrestivo | i'm pretty sure the mirrors function of lein doesn't actually fallback or mirror |
| 02:40 | kopasetik | "I haven’t yet seen a loop that can’t be decomposed into a combination of map, filter, reduce." - @dustingetz |
| 02:40 | kopasetik | Agree? |
| 02:43 | amalloy | not as stated. consider: int sum = 0, i = 0; while (i++ < 100) sum += i; |
| 02:43 | amalloy | this is easily stated in clojure as (reduce + 0 (range 101)), but you didn't admit other functions like range |
| 02:45 | kopasetik | amalloy: Good call |
| 02:45 | amalloy | kopasetik: it's close, though, if you refine it to: loops that consume an input list |
| 02:45 | kopasetik | Basically, I'm wondering whether I'll be able to solve typical brainteaser interview questions using Clojure... |
| 02:45 | amalloy | then you get into the universality of folds |
| 02:45 | amalloy | yes |
| 02:46 | amalloy | well, i can. whether you can i can't vouch for |
| 02:46 | kopasetik | amalloy: Heh, I guess that's why I'm practicing |
| 02:47 | kopasetik | map, reduce, and filter are much less confusing than for loops |
| 02:47 | kopasetik | Nested for loops are the worst |
| 02:49 | TEttinger | kopasetik: no, hardly |
| 02:50 | TEttinger | for(byte i = 0; i < 50; i--) |
| 02:50 | TEttinger | unchecked java arithmetic wraparound! |
| 02:55 | TEttinger | for(byte x=-128,y=1; x<y; y<<1,x>>>1) {System.out.println(y);} //how many numbers will this print? |
| 02:56 | TEttinger | I like to think someone completely new entered the channel, saw that, and noped out of here |
| 06:03 | annotationsinclj | how do you write this in clj - public interface Foo { @MyAnnotation(hello="World") String foo(Bar input); } |
| 06:04 | annotationsinclj | ,(definterface Foo (^String foo [^Bar input] )) |
| 06:04 | clojurebot | sandbox.Foo |
| 06:05 | annotationsinclj | how about the annotation |
| 07:25 | taspat | Hi, after creating a basic lein project, cider-jack-in completes with no warnings. But doing C-c M-. I get "cannot find resource". |
| 07:26 | MJB47 | try doing C-c C-k first |
| 07:26 | MJB47 | ? |
| 07:27 | MJB47 | in a clj file |
| 07:27 | taspat | MJB47: i tried that, but same issue remains |
| 07:27 | MJB47 | what symbol are you trying to find? |
| 07:28 | MJB47 | a clj core one or one of your own? |
| 07:28 | taspat | println and .toUpperCase |
| 07:29 | MJB47 | i assume you can send code to cider fine? |
| 07:30 | taspat | yes |
| 07:30 | MJB47 | im afraid i dont know then :( |
| 08:34 | Guest63553 | hi |
| 08:36 | Guest63553 | :( |
| 08:38 | kwladyka | Is 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:09 | maxxcan | exit |
| 09:30 | taspat | hi 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:30 | taspat | here is my .lein/profiles.clj |
| 09:30 | taspat | https://gist.github.com/anonymous/f2ffc15f4531c7b73239 |
| 09:30 | taspat | cider-jack-in executes with no errors |
| 09:31 | taspat | should I include some paths of jdk, clojure in profiles.clj file? |
| 09:31 | taspat | i searching on web for a solution but cannot find anything :/ |
| 09:33 | kwladyka | taspat should you write it on #emacs or similar channel? |
| 09:39 | kwladyka | taspat 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:40 | kwladyka | but.... for me intellij is better |
| 09:40 | kwladyka | but :) did lessons with emacs learn me a lot how to use intellij better! |
| 10:08 | tcrawley | justin_smith: I've updated the wiki page with your workaround: https://github.com/clojars/clojars-web/wiki/Mirrors |
| 11:30 | justin_smith | tcrawley-away: cool |
| 11:39 | justin_smith | annotationsinclj left, but this is the answer https://gist.github.com/richhickey/377213 |
| 15:07 | taspat | render-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:07 | taspat | how does this work? |
| 15:07 | ridcully | isnt there an opening ( missing on the first reagent call? |
| 15:08 | ridcully | also [] is just a vector |
| 15:08 | ridcully | ,[+ - / *] |
| 15:08 | clojurebot | [#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:10 | justin_smith | taspat: passing the component inside [] is just redundant nesting |
| 15:10 | justin_smith | callign the component (hello-world) means that @app-state is only looked up once (when it mounts), and future changes won't be seen |
| 15:10 | justin_smith | passing it as hello-world will cause re-rendering with @app-state changes |
| 15:11 | justin_smith | taspat: my preference is to pass in app-state as an argument to the component |
| 15:11 | justin_smith | taspat: this makes testing cleaner, and makes the control/data flow more explicit |
| 15:14 | taspat | thanks justin_smith, where can i read about this more? |
| 15:16 | justin_smith | taspat: the official reagent intro is good |
| 15:23 | taspat | justin_smith: nice, I checked source code and the answer in render dom/render function |
| 15:23 | taspat | thanks again |
| 15:28 | kwladyka | Somebody 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:32 | rhg135 | cfleming has mentioned adding a way to define the syntax for custom macros |
| 15:33 | rhg135 | Might be implemented now |
| 15:44 | kwladyka | mmm i will try find something tomorrow in google |
| 16:48 | aaelony | #geekstogo |
| 19:47 | slester | lein repl throwing "Could not locate main__init.class or main.clj on classpath" errors could mean what exactly? :( |
| 19:48 | justin_smith | slester: something is trying to (require 'main) and main.clj does not exist |
| 19:48 | justin_smith | or it's on the wrong place in the classpath |
| 20:24 | m4ck | hi peeps |
| 20:25 | m4ck | I'm trying to distinguish refs and atoms. I understand refs to be useful for when you need to update multiple identities in tandem. |
| 20:25 | m4ck | However, atoms would seem just as useful for that purpose too. Could anybody help make the distinction? |
| 20:25 | justin_smith | m4ck: you can't coordinate multiple atoms safely |
| 20:26 | m4ck | justin_smith: not even if they're being swap!'d in the same transaction? |
| 20:26 | justin_smith | m4ck: 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:26 | justin_smith | m4ck: swap! is not safe in transactions |
| 20:26 | justin_smith | that's what the ! in swap! actually means |
| 20:27 | m4ck | I see! |
| 20:27 | justin_smith | m4ck: most things in clojure.core that end with ! are not safe inside transactions |
| 20:27 | m4ck | So why would you not use a ref everywhere? |
| 20:27 | justin_smith | m4ck: because you can store multiple values in one atom |
| 20:28 | justin_smith | because sometimes your application logic doesn't require an atomic change that touches multiple containers |
| 20:29 | m4ck | Multiple values in one atom? |
| 20:29 | justin_smith | yes |
| 20:29 | m4ck | https://clojuredocs.org/clojure.core/atom <- indicates otherwise (although I'm sure I'm misunderstanding somehow) |
| 20:29 | justin_smith | ,(def a {:a 0 :b [1 2 3]}) |
| 20:29 | clojurebot | #'sandbox/a |
| 20:29 | m4ck | oh, in terms of a collection, ok |
| 20:29 | justin_smith | there are multiple values in that hash-map |
| 20:30 | justin_smith | right |
| 20:30 | m4ck | That is do-able with a ref though, right? |
| 20:30 | justin_smith | yes, but multiple values in one collections does not perform as well as using a ref for each value |
| 20:31 | justin_smith | refs tend to be more complex to use, but perform better, and be more flexible |
| 20:31 | justin_smith | m4ck: consider, if you had all customer accounts in one hash-map in an atom, how much it would retry swaps |
| 20:31 | justin_smith | m4ck: every time two customer orders overlapped in time, you would have to run retries |
| 20:32 | justin_smith | refs allow for a smarter design with less retries (because you can have finer granularity while still having atomic operations) |
| 20:32 | m4ck | Right, I get that now - I _think_ that clarifies everything |
| 20:32 | justin_smith | but 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:33 | justin_smith | m4ck: also, always remember that if you have side effects inside swap! or transact calls, you can see very odd results |
| 20:33 | m4ck | yup, I know to steer clear of that :) |
| 20:34 | m4ck | thanks for the help |
| 20:34 | justin_smith | m4ck: similarly, putting mutable objects inside an atom or ref (since retries won't work as designed) |
| 20:34 | justin_smith | np |
| 22:02 | devth | elegant way of turning [:a 1 :b 2] into {:a 1 :b 2} ? |
| 22:02 | devth | of course i figured it out right after asking :) |
| 22:02 | devth | ,(apply hash-map [:a 1 :b 2]) |
| 22:02 | clojurebot | {:b 2, :a 1} |
| 22:08 | devth | ,(take-nth 1 [:a 1 :b 2]) |
| 22:08 | clojurebot | (:a 1 :b 2) |
| 22:08 | devth | wat? |
| 22:09 | devth | ,(take-nth 2 [:a 1 :b 2]) |
| 22:09 | clojurebot | (:a :b) |
| 22:09 | devth | i want 1 and 2 |
| 22:09 | justin_smith | ,(take-nth 2 (rest [:a 1 :b 2])) |
| 22:09 | clojurebot | (1 2) |
| 22:09 | devth | sure but why? |
| 22:09 | devth | seems strange |
| 22:09 | justin_smith | because it takes the first item, and then drops n |
| 22:10 | justin_smith | I mean sure, it could drop n and then take the next |
| 22:10 | devth | ok. guess that makes sense. |
| 22:10 | justin_smith | s/n/n-1 |
| 22:13 | pilne | ... 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:14 | justin_smith | haha, nice |
| 22:14 | devth | pilne: what's your haskell-on-jvm? |
| 22:14 | pilne | frege |
| 22:15 | devth | cool. haven't played with it yet. |
| 22:15 | devth | good? |
| 22:16 | pilne | super 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:17 | devth | sounds awesome |
| 22:18 | pilne | and a stated goal is to be a "dialect" of haskell |
| 22:20 | amalloy | frege compiles to java source code, really. that's an unusual approach |
| 22:21 | pilne | for running on the jvm? |
| 22:21 | amalloy | yeah |
| 22:22 | amalloy | bytecode is more common |
| 22:22 | pilne | i can see that actually |
| 22:23 | devth | wonder what perf implications/limitations are like |
| 22:25 | pilne | i'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:29 | pilne | i 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:30 | pilne | clojure saved me from a lot of headaches (: |
| 22:39 | pilne | alrighty.. stupid work stupid early tomorrow, ciao for niao! |
| 23:09 | devth | ,(clojure.set/difference #{1 2 3} #{2}) |
| 23:09 | clojurebot | #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:09 | justin_smith | devth: you need to require clojure.set first |
| 23:09 | devth | clearest way to remove an item from a set? |
| 23:09 | devth | justin_smith: ah |
| 23:09 | justin_smith | devth: if it's a single item, you can just use disj |
| 23:10 | justin_smith | ,(disj #{1 2 3} 2) |
| 23:10 | clojurebot | #{1 3} |
| 23:10 | devth | oh 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) |