2015-12-28
| 01:32 | BRODUS | say i have a data shaped like this, [{:k1 [{:k2 v]} ...} ...] . is there a succinct way to update every k2 ? |
| 01:33 | BRODUS | like this i mean [{:k1 [{:k2 v} ...]} ...] |
| 01:33 | jeaye | Where are the other k2s? |
| 01:33 | jeaye | All in that one vector under :k1? |
| 01:34 | BRODUS | each element in each vector have the same keys |
| 01:34 | jeaye | got it |
| 01:34 | jeaye | I'd use map and update-in, I think. |
| 01:38 | jeaye | ,(let [m [{:k1 [{:k2 42}]} {:k1 [{:k2 77}]}]] (map #(update % :k1 (fn [_] [{:k2 :meow}])))) |
| 01:38 | clojurebot | #object[clojure.core$map$fn__4537 0x1bfa7223 "clojure.core$map$fn__4537@1bfa7223"] |
| 01:39 | jeaye | gah |
| 01:39 | jeaye | ,(let [m [{:k1 [{:k2 42}]} {:k1 [{:k2 77}]}]] (map #(update % :k1 (fn [_] [{:k2 :meow}])) m)) |
| 01:39 | clojurebot | ({:k1 [{:k2 :meow}]} {:k1 [{:k2 :meow}]}) |
| 01:40 | jeaye | BRODUS: ^ given each k2, run a function on it to update it to :meow |
| 01:40 | jeaye | Is that what you're looking for? |
| 01:40 | BRODUS | hmmm |
| 01:41 | jeaye | Of course, the function could do anything with the value. |
| 01:42 | jeaye | ,(let [m [{:k1 [{:k2 42}]} {:k1 [{:k2 77}]}]] (map #(update % :k1 (fn [v] [{:k2 (* 2 (:k2 (first v)))}])) m)) |
| 01:42 | clojurebot | ({:k1 [{:k2 84}]} {:k1 [{:k2 154}]}) |
| 01:42 | jeaye | Doubles each value, for example. |
| 01:43 | BRODUS | theres more than 1 element k1's collection |
| 01:43 | BRODUS | sorry, should have made that clearer |
| 01:43 | jeaye | And you only want to mess with the k2s, right? |
| 01:43 | BRODUS | right |
| 01:44 | BRODUS | i was thinking there would be a more succinct way than map and update, theres still lots of core functions i don't know |
| 01:45 | jeaye | same |
| 01:46 | jeaye | BRODUS: Well, if you don't want to toy with update, which is your best bet, I think, there's always https://github.com/nathanmarz/specter |
| 01:46 | jeaye | Though I've found its documentation to be hit-and-miss. |
| 01:46 | BRODUS | nice |
| 01:49 | jeaye | BRODUS: If you know the index of the k2s, you can do this: |
| 01:49 | domgetter | BRODUS: There aren't very many succinct ways to dig into nested data structures in Clojure. That's why the author of Spectre made that tool |
| 01:49 | jeaye | ,(let [m [{:k1 [{:k2 42}]} {:k1 [{:k2 77}]}]] (map #(update-in % [:k1 0 :k2] (fn [_] :meow)) m)) |
| 01:50 | clojurebot | ({:k1 [{:k2 :meow}]} {:k1 [{:k2 :meow}]}) |
| 01:50 | jeaye | BRODUS: The above will dig into :k1, then the zeroth element, then pull out :k2. You may be able to change 0 into some logic for that entry to get the right index. |
| 01:50 | jeaye | Assuming you're looking to just use core functions. |
| 01:51 | BRODUS | thanks for the help, i'll try it out when i get home |
| 01:51 | jeaye | domgetter: It's one of my biggest gripes with clojure. Unfortunately, specter hasn't been very approachable. |
| 02:02 | jmibanez | I'm migrating a system to Clojure; one of the bits I have to port is the domain model (and the entities for it). Our domain model has some entities which use single table inheritance. I've been looking at sqlkorma, and there doesn't seem to be any explicit support for single table inheritance (or inheritance for that matter). What's the best way to support this? |
| 02:02 | jmibanez | (Or at least, what alternatives are there to sqlkorma that have some support for single table inheritance?) |
| 02:04 | domgetter | jmibanez: https://github.com/razum2um/awesome-clojure#orm-and-sql-generation |
| 02:05 | jmibanez | domgetter: Awesome, thanks |
| 02:05 | jmibanez | (pun intended) |
| 02:07 | jmibanez | Hmm... sqlkorma seems to be my best bet for what I need... reading more docs now |
| 02:09 | domgetter | I'm surprised I've never heard of anyone try to do ORM from the other side. That is, have some sort of object model in SQL to interact with an OO language. |
| 02:10 | jmibanez | domgetter: very difficult if you're coming from SQL. ORMs are a bit of a hack IMHO, but sort of necessary |
| 02:17 | domgetter | also, it doesn't make sense from a dependency perspective. A database doesn't depend on a webapp, but the webapp depends on the database. |
| 03:12 | visof | hi guys |
| 03:13 | visof | is there anybody using imagez or anything similiar? |
| 03:13 | visof | all what i want to do is to iterate over pixels of the image? |
| 03:39 | TEttinger | visof: in real time, when serving an image, what's the context? |
| 03:42 | visof | TEttinger: just get the pixels of the image to binarize the image, i'm doing this as example for learning |
| 03:43 | visof | TEttinger: so the ultimate goal isn't binarization but howto deal with the image |
| 03:43 | TEttinger | ah ok |
| 03:43 | TEttinger | java2d isn't that bad, surprisingly |
| 03:43 | visof | i found imagez use get-pixels and return array for it |
| 03:43 | TEttinger | I haven't used imagez |
| 03:43 | visof | array of ints |
| 03:43 | visof | TEttinger: what did you use? |
| 03:43 | TEttinger | more likely it's returning an array of bytes |
| 03:44 | TEttinger | I'd be kinda surprised if it was ints, though I guess I could see it |
| 03:44 | visof | yeah but how can i use it, i suppose it should be 2D array |
| 03:44 | TEttinger | no |
| 03:45 | visof | TEttinger: how can the pixels aligened in 1D array? |
| 03:45 | visof | the image is 2D array |
| 03:45 | TEttinger | typically the internal representation of pixels in a lot of image formats is a 1D array of bytes, where a single row is a fixed length |
| 03:45 | TEttinger | so you might have a 10x10 image, that uses 400 bytes in a 1D array |
| 03:46 | TEttinger | every 4 bytes are red, green, blue, alpha. then that repeats |
| 03:46 | TEttinger | so the first 40 bytes are the first row |
| 03:47 | TEttinger | this is a common trick in a lot of heavily optimized array-based code, since in Java and lots of other languages, a 2D array stores an array per row, and then one more array for all the rows |
| 03:47 | TEttinger | that uses more memory, or for file formats, wastes space |
| 03:47 | domgetter | visof: it's generally "faster" to represent images as single array of integers and then when you actually put it on the screen, check how "wide" the image is, and then wrap around and keep putting pixels on the screen |
| 03:47 | TEttinger | yep |
| 03:48 | TEttinger | images are pretty much always rectangular, so it works |
| 03:48 | domgetter | So when doing low-level graphics you have to constantly keep two versions of the image in your head. The long list of integers, and the pixels those integers represent when they're put on the screen. |
| 03:48 | visof | domgetter: TEttinger i found the values as negatives |
| 03:49 | domgetter | visof: what's the file format |
| 03:49 | visof | (doseq [i pixels)] (prn i)) |
| 03:49 | TEttinger | also how big or small are the values |
| 03:49 | visof | i'm doing this |
| 03:49 | TEttinger | -128 to 127 probably? |
| 03:49 | TEttinger | or is there anything in the many-thousands range |
| 03:50 | domgetter | visof: depending on the format of the image, it uses different integers to represent colors |
| 03:50 | domgetter | also, it may be using all kinds of compression, so you can't just look at the raw data |
| 03:51 | domgetter | Computerphile on Youtube has a great set of videos explaining how JPEG works. Here's one: https://www.youtube.com/watch?v=n_uNPbdenRs |
| 03:52 | domgetter | Don't be discouraged by the complexity, though. JPEG is designed to solve a certain problem. "raw" image formats don't do anything tricky to the pixel integers |
| 03:52 | TEttinger | you may be dealing with a byte array, and bytes almost always represent 0-255 in most formats. Java in its infinite "wisdom" does not allow that, and all bytes go from -128 minimum to 127 max. you can easily turn negative numbers into the correct versions (and leave already correct numbers unchanged) with |
| 03:52 | TEttinger | ,(bit-and -128 255) |
| 03:52 | clojurebot | 128 |
| 03:52 | TEttinger | ,(bit-and -1 255) |
| 03:52 | clojurebot | 255 |
| 03:52 | TEttinger | ,(bit-and 1 255) |
| 03:52 | clojurebot | 1 |
| 03:53 | TEttinger | ,(bit-and 127 255) |
| 03:53 | clojurebot | 127 |
| 03:53 | TEttinger | if you are dealing with file formats, you shouldn't be at an early step in learning a programming language |
| 03:53 | TEttinger | there's probably a simpler way |
| 03:54 | visof | TEttinger: domgetter part of the pixels https://www.refheap.com/113183 |
| 03:54 | visof | domgetter: i have tried gif and jpg |
| 03:54 | domgetter | visof: Yea jpeg isn't going to be intelligible |
| 03:54 | TEttinger | ,(Long/toHexString -14803426 |
| 03:54 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 03:55 | TEttinger | ,(Long/toHexString -14803426) |
| 03:55 | clojurebot | "ffffffffff1e1e1e" |
| 03:55 | TEttinger | that's interesting |
| 03:55 | domgetter | It's using compression to save the bytes in a tricky way |
| 03:55 | TEttinger | ,(Integer/toHexString -14803426) |
| 03:55 | clojurebot | "ff1e1e1e" |
| 03:55 | TEttinger | a ha! |
| 03:55 | TEttinger | yeah it isn't compressing at all, domgetter |
| 03:55 | TEttinger | that's either ARGB or ABGR |
| 03:55 | domgetter | oh I guess you're right |
| 03:56 | domgetter | my money is that it's agbr and it's grey |
| 03:56 | domgetter | oh |
| 03:56 | TEttinger | I hope you're wrong |
| 03:56 | TEttinger | because gbr is going to be a new invention :) |
| 03:56 | domgetter | nvm |
| 03:56 | domgetter | haha |
| 03:56 | TEttinger | but yeah, looks dark gray, fully opaque |
| 03:57 | domgetter | visof: the reason we can tell is that FF1E1E1E is using 2 characters for every color |
| 03:57 | domgetter | so FF is 255 for alpha (fully visible), 1E is 30 for R, G, and B |
| 03:58 | TEttinger | ,[0xFF 0x1E 0x1E 0x1E] |
| 03:58 | domgetter | just like in css it's 0-255 |
| 03:58 | clojurebot | [255 30 30 30] |
| 04:00 | TEttinger | I've started to really enjoy working on compression and related stuff. I took great pleasure in the fact that some choices I made allowed 8.5 GB of mostly images (not including OS overhead for 2.4 million files) to compress down to 53 MB with 7-zip |
| 04:00 | TEttinger | less than 1% the size |
| 04:06 | visof | TEttinger: so each value represent 1 pixel, not as 40 bytes for the first row right? |
| 04:06 | visof | TEttinger: i mean in this case |
| 04:06 | TEttinger | correct |
| 04:06 | visof | TEttinger: thanks man |
| 04:07 | TEttinger | it's storing alpha (transparency, 255 is opaque, 0 is clear) first. |
| 04:07 | TEttinger | then either red green blue, or blur green red |
| 04:07 | TEttinger | *blue green red |
| 04:07 | TEttinger | I can't really tell without seeing an image |
| 04:07 | TEttinger | if you try it on an all-red image, that would tell me |
| 04:08 | TEttinger | (even a 1x1 pixel image of 1 red pixel) |
| 04:41 | visof | TEttinger: there? |
| 04:42 | TEttinger | hello! |
| 04:42 | visof | hi |
| 04:43 | ded | (Newb.) I'm running a ring/compojure server from within lein repl. How can I set a breakpoint in a route handler? |
| 04:43 | visof | when i apply Long/toHexString i got this https://www.refheap.com/113184 |
| 04:43 | visof | TEttinger: so its divided into 4 bytes? |
| 04:44 | TEttinger | yep |
| 04:44 | TEttinger | also, I think they are integers, so Long/toHexString (when you call it on a negative number) will fill an extra 8 F in there |
| 04:45 | TEttinger | you may want Integer/toHexString |
| 04:47 | visof | TEttinger: ah that work, now i got 8 |
| 04:47 | TEttinger | cool |
| 05:24 | blt | how might I traverse a nested persistentarraymap, returning a nested persistentarraymep of the keys all the way down? |
| 05:47 | justin_smith | of the keys mapped to what? |
| 05:48 | blt | justin_smith: i would just like to see the hierarchy of keys from a map |
| 05:48 | blt | nested map* |
| 05:49 | justin_smith | but you said you wanted a map of the keys, so what are they mapped to? |
| 05:49 | justin_smith | I can show you how to get a nested list of the keys |
| 05:49 | justin_smith | but you need to map them to something in order to have a map |
| 05:49 | blt | justin_smith: that would be cool |
| 05:49 | blt | no requirements, just tinkering |
| 05:51 | blt | justin_smith: perhaps a map isn't the best way to represent it anyhow |
| 05:53 | blt | justin_smith: i sort of suck at thinking about traversing trees, collecting data from nodes, and building up other representations. grrr |
| 05:53 | justin_smith | ,(->> {:a {:b 0} :c {:d {:e 1}}} (tree-seq coll? seq) (filter map?) (mapcat keys)) |
| 05:53 | clojurebot | (:a :c :b :d :e) |
| 05:53 | justin_smith | maybe that isn't what you want though |
| 05:57 | blt | justin_smith: i imagined there would be a way to maintain the hierarchy of the keys. |
| 05:57 | justin_smith | I'm sure there is |
| 05:57 | blt | perhaps returning a list of paths to every key would work though |
| 05:58 | justin_smith | oh, that's one of the 4clojure problems... |
| 05:59 | blt | justin_smith: cool, i'll dig around on it. i'll drop a line if i come up w/ anything |
| 05:59 | blt | thanks for the tree-seq sample. that's neat |
| 06:00 | justin_smith | I'm looking for it now - I know I solved it but don't have it handy |
| 06:01 | justin_smith | blt: http://www.4clojure.com/problem/146 |
| 06:08 | blt | justin_smith: thanks for grabbing that. i'm looking it over now |
| 06:08 | justin_smith | ,(#(into {} (map (fn [where] [where (get-in % where)]) (mapcat (fn [k] (map (fn [k'] [k k']) (keys (get % k)))) (keys %)))) '{m {1 [a b c] 3 nil}}) |
| 06:08 | clojurebot | {[m 1] [a b c], [m 3] nil} |
| 06:08 | justin_smith | that solution works for the examples, but blows up for some other hash-maps I fed it, so it is imperfect |
| 06:08 | justin_smith | it's actually not great code, it could be improved |
| 06:10 | justin_smith | looks like it only works for nestings two deep :( - I need to fix that |
| 06:56 | anti-freeze | Hi everyone, how would one modify a core.async channel so that every time a take is made, the value is passed through a function? |
| 06:57 | BRODUS | anti-freeze, why can't you just apply the function on the output of the take? |
| 06:58 | BRODUS | (f (<! channel)) |
| 06:58 | anti-freeze | BRODUS: Thanks. I'm just having some difficulty figuring out how to architect core.async stuff in clojurescript, where blocking is a no no |
| 06:59 | BRODUS | anti-freeze: NP, if you've got an hour to spare I would watch this video, https://www.youtube.com/watch?v=VrmfuuHW_6w |
| 06:59 | BRODUS | its a great run through of core async |
| 07:00 | BRODUS | and in clojurescript you would be using go blocks since there are no threads to block |
| 07:01 | anti-freeze | BRODUS: Oh thanks! I've already watched the one by Rich Hickey and the one by the guy that wrote the go macro, but I still have difficulty understanding how I would pipe a whole bunch of go blocks in to something I could use. |
| 07:03 | BRODUS | if you skip to ~25:40 in that video it shows the ways you can connect channels together |
| 07:04 | anti-freeze | BRODUS: Nice, I'll watch the whole thing now. My unfamiliarity with core.async basically the only thing holding me back from finishing this app quickly. |
| 07:04 | BRODUS | are you using Om? |
| 07:06 | troydm | guys can anyone explain me why the code that I'm trying to profile when used with time like this: (time (myfunc)) says it runs in 0.8131313 msecs but actually takes roughtly 10 seconds to run? |
| 07:07 | anti-freeze | BRODUS: reagent, using it has actually been the easiest part. I just expose an interface that returns a channel with USB devices and then when that channel is processed, I update a reagent atom and then everything just works. Its the only part where something in a go block modifies shared state |
| 07:07 | troydm | is time measuring actual time and not CPU time right? |
| 07:10 | BRODUS | anti-freeze: cool. how do you get device information through the browser? |
| 07:12 | anti-freeze | BRODUS: I'm using electron on node, so it's just a simple (js/require "usb"). I'm using this USB library (https://github.com/nonolith/node-usb) and a macro to convert JS callbacks in to async channels (https://github.com/gilbertw1/cljs-asynchronize). |
| 07:23 | tekacs | question: is 13s with no profiles.clj a 'normal' startup time for 'lein repl'? |
| 07:26 | tekacs | (I'm aware it's supposed to be 'slow', but I'm just checking to get a ballpark, since figures I've seen were more like 2-3s) |
| 07:31 | troydm | dnolen: I think I've found the root cause of slow down issue related to http://dev.clojure.org/jira/browse/LOGIC-177 but I need you also to look at the code just to be sure I'm on correct train of thoughts |
| 07:38 | TEttinger | ,(let[L #(if(< % 0)%2 %3)rh #(mod % 1.0)rl(comp double int)mix(fn[S C](let[R #(int(mod % 2.0))](fn[x y](*(L y -1 1)(+(L x 0.5 0)((nth(iterate (fn[[v m a b]](let[X(C(S a 0.5))Y(C(S b 0.5))][(+(S(bit-or(*(R a)2)(R b))m)v)(* m 4)X Y]))[0 1.0(Math/abs x)(Math/abs y)])32)0))))))morty #(*(+((mix * identity)% %2)((mix / identity)% %2))0.5)] (morty 1.5 -1.5)) |
| 07:38 | clojurebot | -3.375 |
| 08:09 | visof | hi guys |
| 08:09 | visof | is there anybody use clojure + openbsd? |
| 08:42 | dnolen | troydm: that's how it's supposed to work - that issue doesn't have any new information yet |
| 08:55 | troydm | dnolen: I've added a comment on the JIRA |
| 08:56 | dnolen | troydm: the comment doesn't tell me anyting at all |
| 08:56 | dnolen | there's no explanation of what the perceived issue is to be |
| 08:56 | dnolen | zero analysis |
| 08:57 | troydm | dnolen: sorry, well it's recursive call of walk-term both from walk* and walk-term itself |
| 08:57 | dnolen | troydm: that also doesn't tell me anything |
| 08:57 | dnolen | recursive walk is fine if you' |
| 08:57 | dnolen | re not visiting the same node |
| 08:58 | troydm | dnolen: that's the problem, it's visiting child nodes multiple times |
| 08:58 | dnolen | troydm: so explain how you believe it is |
| 08:58 | dnolen | there's no explanation of the issue in the comments |
| 08:59 | dnolen | assume I haven't look at this code in a while :) |
| 09:00 | troydm | dnolen: walk* is if the tree-term is found which calls walk-term again however, walk-term is called outside of it |
| 09:00 | dnolen | troydm: not here - please do this in the comments now |
| 09:00 | troydm | dnolen: ohh okey |
| 09:01 | dnolen | thanks |
| 09:06 | visof | ,(apply merge-with conj [{:hello [1]} {:hello [2]}] |
| 09:06 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 09:06 | visof | ,(apply merge-with conj [{:hello [1]} {:hello [2]} |
| 09:06 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 09:06 | visof | ,(apply merge-with conj [{:hello [1]} {:hello [2]}) |
| 09:06 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )> |
| 09:07 | visof | ,(apply merge-with conj [{:hello [1]} {:hello [2]}]) |
| 09:07 | clojurebot | {:hello [1 [2]]} |
| 09:07 | visof | ,(apply merge-with (comp conj flatten) [{:hello [1]} {:hello [2]}]) |
| 09:07 | clojurebot | #error {\n :cause "Wrong number of args (2) passed to: core/flatten"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (2) passed to: core/flatten"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 36]\n [clojure.core$comp$fn__4483 invoke "core.clj" 2442]\n [clojure.... |
| 09:07 | visof | ,(apply merge-with (comp flatten conj) [{:hello [1]} {:hello [2]}]) |
| 09:07 | clojurebot | {:hello (1 2)} |
| 09:08 | visof | ,(apply merge-with (comp flatten conj (partial into [])) [{:hello 1} {:hello 2}]) |
| 09:08 | clojurebot | #error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [clojure.core$transduce invokeStatic "core.clj" 6575]}]\n :trace\n [[clojure.core$transduce invokeStatic "core.clj" 6575]\n [clojure.core$into invokeStatic "core.clj" 6591]\n [clojure.core$into invoke "core.cl... |
| 09:09 | troydm | dnolen: okey I've edited the comment, not sure if I'm correct in explaining it but it's easier understood if u put println call at the start of walk* function and try calling it yourself |
| 09:11 | visof | ,(apply merge-with (comp flatten conj (partial conj [])) [{:hello 1} {:hello 2}]) |
| 09:11 | clojurebot | {:hello (1 2)} |
| 09:12 | dnolen | troydm: thanks, already looks more informative :) I will take a deeper look when I have time |
| 09:12 | troydm | dnolen: sure np |
| 09:15 | augustl | seems I broke mori.hash.. https://gist.github.com/augustl/828ec7ce730610054f3b |
| 09:16 | augustl | the 2nd conj and subsequent conjs on the value returned from mori.remove changes the value but does not change the hash code |
| 09:17 | augustl | any mori or cljs users around that has seen similar behaviour? |
| 09:18 | pvinis | hello. i have a lazy seq, and i want to see if it has more than 5 items, should i do count? or should i try to not realize the whole thing if there are 5 items already? |
| 09:18 | pvinis | also, how would i do that? with take? |
| 09:19 | ridcully | ,(count (take 5 (range))) |
| 09:19 | clojurebot | 5 |
| 09:19 | ridcully | ,(count (take 5 (range 2))) |
| 09:19 | clojurebot | 2 |
| 09:19 | BRODUS | ,(count (take 6 [1 2 3 4 5])) |
| 09:19 | clojurebot | 5 |
| 09:20 | pvinis | aha. so just put a take before the count then? |
| 09:20 | augustl | perhaps I should try to build mori myself, no release has been made in npm after this commit https://github.com/swannodette/mori/commit/46c9194b3c4bc93fc4b402925b9417add3b0a3ba |
| 09:20 | pvinis | that makes sense.. |
| 09:20 | pvinis | thanks |
| 09:38 | TimMc | augustl: Wow, that's pretty bad. |
| 09:41 | TimMc | augustl: What happens if you conj 5 instead? |
| 09:41 | TimMc | (Is it possible you just lucked out?) |
| 09:57 | augustl | TimMc: ah, I'll check :) |
| 10:00 | augustl | TimMc: unfortunately not https://gist.github.com/augustl/7701d965c6e2f7484d69 |
| 10:00 | TimMc | OK, so not a cool party trick then. |
| 10:00 | augustl | would have been neat :) |
| 10:01 | augustl | t-shirt idea: I used a value, but all I got was borked value semantics |
| 10:03 | augustl | my fancy React based gui suddenly stopped updating when my state changed :) |
| 10:05 | augustl | It seems that mori.hash doesn't compute anything, it just reads a property on the mori object |
| 10:05 | augustl | so my prime suspect is cache invalidation :) |
| 10:47 | TimMc | fun |
| 11:12 | sm0ke | Hi any boot users here? |
| 11:12 | sm0ke | I recently updated to boot 2.5.x and hell broke lose |
| 11:13 | sm0ke | any hints on how to use the `target` task? |
| 11:58 | engblom | Could someone find out why the clj-gpio library does not work as unprivileged user. I am not skilled enough to understand everything in the code. Using "spit" and "slurp" I sucessfully manipulate the GPIO as an unprivileged user, so the clj-gpio should not have any problem either |
| 11:59 | engblom | (spit "/sys/class/gpio/export" "4") (spit "/sys/class/gpio/gpio4/direction" "out") (spit "/sys/class/gpio/gpio4/value" "1") <---- These 3 lines successfully puts the led to shine. |
| 12:00 | engblom | I am not able to do it with help of the library |
| 12:21 | TimMc | engblom: If you poke around in the code, does it just try to write to file the same way you are? |
| 12:21 | TimMc | and what is the failure mode? |
| 12:22 | engblom | (def port (open-port 4)) |
| 12:22 | engblom | CompilerException java.io.FileNotFoundException: /sys/class/gpio/gpio4/value (Permission denied), compiling:(form-init7914451877660249273.clj:1:11) |
| 12:23 | justin_smith | yeah, only root can use a port number that low |
| 12:23 | justin_smith | oh wait, that's gpio? never mind |
| 12:23 | engblom | justin_smith: it is about GPIO port numper |
| 12:23 | engblom | number* |
| 12:23 | TimMc | mumble mumble file type and what flags are used for opening it |
| 12:24 | engblom | TimMc: https://github.com/peterschwarz/clj-gpio/blob/master/src/main/clojure/gpio/core.clj |
| 12:24 | engblom | TimMc: There you find the open-port function |
| 12:25 | TimMc | It's opening a RandomAccess file, that's my guess as to the issue. |
| 12:25 | engblom | TimMc: It is opened as rw according to the source |
| 12:26 | TimMc | I don't know *why* it would be the problem, since I don't know enough about unix file handles and such, but that's where I'd start poking around. |
| 12:26 | engblom | I do not even know why RandomAccessFile is used at all in this library. |
| 12:27 | engblom | The file is anyway only one byte, with either 1 or 0. |
| 12:27 | justin_smith | I wouldn't expect opening a device file random access to make any sense |
| 12:28 | justin_smith | you read from it or write to it, keeping it open randomaccess feels weird |
| 12:29 | engblom | If this library would work as it is supposed to do, I would use it in the school where I am teaching. The school has been ordering 10 raspberry pi |
| 12:30 | engblom | It looks like I will have to drop the idea of using Clojure together with the raspberry pi |
| 12:31 | justin_smith | what about just a slurp/spit to the device file instead of opening random access? |
| 12:32 | engblom | justin_smith: That library had a event listener. With it I would be able to wait for a gpio-button press without busy looping |
| 12:32 | engblom | justin_smith: That is the feature I was hoping for to use |
| 13:12 | TimMc | engblom: Might be worth forking the library. |
| 13:14 | banjiewen | Is there any way to make a deftype's fields private without making them mutable? |
| 13:17 | justin_smith | banjiewen: not that I know of, but you could make a constructor function that closes over whatever data you like. |
| 13:18 | justin_smith | but I guess that wouldn't be visible to the methods in the type, so never mind |
| 13:18 | banjiewen | Thanks, no worries. |
| 13:19 | justin_smith | banjiewen: while I realize there is more nuance than this, the general idea with clojure is often that immutable data doesn't need to be hidden. |
| 13:19 | justin_smith | if you need something that contradicts that, you'll likely need to do something by hand (eg. gen-class), the clojure conveniences won't help much |
| 13:20 | tdammers | hiding stuff at the module level should be enough usually |
| 13:20 | tdammers | (in terms of encapsulating complexity locally, that is) |
| 13:20 | justin_smith | it's kind of a difference between lisp culture and java culture, where clojure goes a bit more to the lisp side |
| 13:23 | banjiewen | Well, this case is mostly a style concern - I'm implementing a Java interface that defines getters with names matching the "expected" field names |
| 13:24 | banjiewen | Doesn't seem to be a way to avoid just changing the field name with deftype, unfortunately |
| 13:24 | justin_smith | ahh - so the normal way to do it would be to have private fields exposed by the getters |
| 13:24 | banjiewen | Well, at least to hide the implementation detail of the override, right |
| 13:25 | banjiewen | I'd hoped that the field access provided by deftype would cover the interface's implementation, but it turns out that it doesn't - I get `AbstractMethodError`s at runtime. |
| 13:26 | justin_smith | yeah, it's not magic at all |
| 13:26 | banjiewen | Trivially avoided by using a different name for the fields and writing the interface implementation manually, but I'd like to hide that detail. |
| 13:26 | justin_smith | my temptation would be to use a field called _name that is exposed by the getName method |
| 13:27 | justin_smith | and since it's immutable, you know the client can't break it (without extensive effort), and it's their own obvious fault if they start using the feild |
| 13:28 | banjiewen | Yep, that's where I'm headed |
| 13:28 | justin_smith | on the other hand, there is gen-class, which can have exactly the semantics you describe (which would be normal in java), but it's a bigger pain in the ass to use |
| 13:29 | banjiewen | Thanks for the tip. Maybe down the road. |
| 13:43 | engblom | If I would want to watch two files for changes (not busy waiting) and regardless of which one of those two had a change I would want the content of both, what library should I look into? |
| 13:44 | justin_smith | engblom: one moment - I contributed to a lib that does this via nio, but am forgetting the name, grubbing my github for it... |
| 13:47 | justin_smith | engblom: this lib does file watchers https://github.com/ToBeReplaced/nio.file |
| 13:47 | engblom | justin_smith: Thanks! |
| 13:50 | justin_smith | this is the specific function https://github.com/ToBeReplaced/nio.file/blob/master/src/org/tobereplaced/nio/file.clj#L187 - there is a function above it to make a watcher |
| 13:50 | justin_smith | (you would make one watcher, and register both paths to it) |
| 13:53 | justin_smith | sorry, the watcher arg wants a WatchService, returned by the watch-service function (it's been a while since I played with this) |
| 13:56 | engblom | justin_smith: Without documentation, it seem to be too difficult for me... :/ |
| 14:00 | augustl | Created a leiningen repo demonstrating the mori issue from earlier today: https://github.com/augustl/cljs-issue-filter-conj-hashcode cc TimMc |
| 14:00 | augustl | as the README demonstrates, the issue occurs in cljs as well (obviously, I guess) |
| 14:04 | TimMc | And that's the latest released cljs, isn't it? I'd file a Jira ticket. |
| 14:09 | TimMc | https://github.com/clojure/clojurescript/wiki/Reporting-Issues |
| 14:09 | TimMc | Urgh, why does Emacs sometimes color blocks of code red as I edit it? |
| 14:10 | TimMc | It's sticky, too -- I can't cut and paste it back in without it keeping the color. |
| 14:11 | justin_smith | TimMc: yeah, fontification in emacs is of two varieties - overlays which disappear with copy/paste and porperties which are kept with copy/paste iirc |
| 14:12 | TimMc | Is there a way to ask for a recoloring? |
| 14:12 | justin_smith | overlays are for transitive UI, properties are used by eg. syntax highlighting |
| 14:12 | justin_smith | m-x font-lock-fontify-buffer |
| 14:12 | justin_smith | it can be lazy about re-calculating, but that forces it |
| 14:12 | augustl | TimMc: http://dev.clojure.org/jira/browse/CLJS-1524 :) |
| 14:12 | augustl | yeah that's the latest cljs afaik |
| 14:20 | justin_smith | I have to say, I'm so glad I downloaded cljs.jar and figured out how to directly run cljs.jar with java and generate the js from a repl - it's good to take a peek at the man behind the curtain |
| 14:21 | justin_smith | and to know exactly how much your tooling is doing, as opposed to what the underlying functionality it's wrapping does, etc. |
| 14:27 | TimMc | justin_smith: Thanks! I'll give that a shot next time. |
| 14:32 | Newbie | Hello |
| 14:33 | Guest14595 | there is any chance to learn clojure for making mud games like with dice rolling or chat with dices? |
| 14:33 | Guest14595 | I do not have background in the coding tho. I just want to learn it rather like a hobby |
| 14:33 | Guest14595 | and to do my game for me as part of learning. :3 |
| 14:34 | justin_smith | Guest14595: I think clojure would be a great platform for making a mud, though it would require a bit of learning about network / socket stuff |
| 14:35 | justin_smith | ,(defn d [count sides] (apply + (repeatedly count (inc (rand-int sides))))) |
| 14:35 | clojurebot | #'sandbox/d |
| 14:36 | justin_smith | ,(d 3 6) ; 3d6 |
| 14:36 | Guest14595 | that's great. but how I can use clojure language for use? I mean. as an app, or browser stuff? |
| 14:36 | clojurebot | #error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [clojure.core$repeatedly$fn__5099 invoke "core.clj" 4924]}]\n :trace\n [[clojure.core$repeatedly$fn__5099 invoke "core.clj" 4924]\n [clojure.lang.LazySeq sval "LazySeq.java" 40]\n [clojure.lang.LazySeq seq "La... |
| 14:36 | justin_smith | err |
| 14:36 | justin_smith | ,(defn d [count sides] (apply + (repeatedly count #(inc (rand-int sides))))) |
| 14:36 | clojurebot | #'sandbox/d |
| 14:36 | justin_smith | ,(d 3 6) ; 3d6 |
| 14:36 | clojurebot | 9 |
| 14:36 | Guest14595 | wow |
| 14:37 | justin_smith | ,(zipmap [:int :dex :wis :con :str :cha] (repeatedly #(d 3 6))) |
| 14:37 | clojurebot | {:int 13, :dex 12, :wis 11, :con 10, :str 11, ...} |
| 14:37 | pilne | after many hours of pondering at work, i've decided to stick with clojure as the basis for my near/mid (and possibly long) term development, and just enjoy learning haskell for the enlightenment it offers. |
| 14:37 | Guest14595 | justin_smith thank you. i see you can even use stats! :D |
| 14:37 | Guest14595 | awesome |
| 14:37 | pilne | the sexy jvm libraries and.. "simpler" thought process (for me) of coding in a lisp are just too hard to walk away from |
| 14:38 | justin_smith | Guest14595: that sort of thing is very easy in clojure - there are still a few hard things to learn to use clojure well though :) |
| 14:38 | Guest14595 | but still the question in my mind how to use it as a usable thing? is conjure can be like used in web-browsed, or just app as so to speak .exe? :D |
| 14:38 | justin_smith | pilne: yeah, clojure seems to fit my iterative way of making things (and I feel like if I were smarter I could do the haskell way...) |
| 14:39 | justin_smith | Guest14595: clojure is good for web apps, but it could also be the classic kind of mud server you telnet to as well |
| 14:40 | justin_smith | probably, when first starting, you could just run the initial version in a terminal |
| 14:40 | pilne | same (: i just don't have the time (right now) to *stop the world* and dedicate all my efforts to haskell. I had a lot of drinks one night and realized it is ok to like both LMAO |
| 14:40 | newbie112 | Hmm... interesting. |
| 14:40 | justin_smith | connect it to the network later |
| 14:40 | pilne | heck, i even discovered forth... and think it is way cooler than "c" for low level stuff >.< |
| 14:41 | newbie112 | Thank you, I will just start with that free book http://www.braveclojure.com/getting-started/ - is that good for beginner? I do not have background in any coding besides script kidding in html, lol. |
| 14:41 | justin_smith | heh - forth is fun. also, when a haskell guy calls js or clojure untyped I'm like erm... forth is untyped, these other langs are just typed at the last minute |
| 14:41 | justin_smith | newbie112: yeah, if you don't mind the silly tone, braveclojure is a decent intro |
| 14:42 | justin_smith | pilne: like, the difference between "that's a number not a function", and just going ahead and calling the memory location that number maps to |
| 14:42 | newbie112 | No worries, when learning stuff I do not mind anything. You have better ones to start with? |
| 14:42 | pilne | types are not the be-all and end-all, good code comes from the programmer, not the language (unless we're talking code-monkey corporate blueprint/boilerplate stuff... the it is kinda just "procedure") |
| 14:43 | pilne | a really quick and fun intro is "casting spels in clojure" (no, that isn't a typo for spells) |
| 14:43 | justin_smith | pilne: I do sometimes miss the kind of silly stuff even the c compiler catches for me when refactoring especially, that clojure won't ever catch until runtime |
| 14:43 | pilne | it kinda glosses over a few things... but it gives you a feel for the language |
| 14:43 | justin_smith | newbie112: oh yeah, the spels in clojure one is probably right up your alley |
| 14:44 | pilne | and while the haskell community is uber friendly and helpful, the clojure community (at least on freenode) seems to be a lot more... jovial |
| 14:44 | pilne | and i'm a fuggin goofball |
| 14:44 | newbie112 | justin_smith sorry for bothering, you mean that one ? http://www.lisperati.com/clojure-spels/casting.html |
| 14:45 | pilne | yeup (: it is a clojure-ized version of a classic by Mr. Barski |
| 14:46 | justin_smith | yup - smart suggestion on that one pilne I forgot |
| 14:46 | justin_smith | newbie112: that one ends up being like a single person mud as you work on it |
| 14:46 | pilne | np, it was probably the most enjoyable tutorial i ever did regardless of the language |
| 14:46 | pilne | so it kinda sticks out in my mind (like an arrow to the knee?) |
| 14:47 | justin_smith | pilne: someone should really make some of this stuff more idiomatic for clojure |
| 14:47 | justin_smith | like - calling hash-map and using symbols as keys? wow |
| 14:47 | justin_smith | haha |
| 14:48 | newbie112 | wow |
| 14:48 | pilne | quick and dirty lol |
| 14:48 | newbie112 | its really funny way to learn stuff |
| 14:48 | pilne | like my ex girlfriend |
| 14:49 | pilne | at least he admits where he isn't being idiomatic |
| 14:49 | pilne | plus, he's making it all "type into the repl" so that probably effected his choices |
| 14:50 | justin_smith | sure, but (hash-map 'foo "a" 'bar "b") as opposed to {:foo "a" :bar "b"} |
| 14:50 | pilne | yeah... i cringed a bit, maybe it was targeted at an earlier version of clojure originally? i only started at 1.7 myself |
| 14:51 | justin_smith | pilne: I think the whole symbols thing is required - maybe '{foo "a" bar "b"} would be the best translation |
| 14:51 | justin_smith | doesn't break the other code - I don't think this is a clojure version issue at all, we've had hash-map literals for ages. |
| 14:53 | pilne | maybe that is more of an idiomatic CL way to do it... and since that's his original love??? idk, maybe i'll email him >.< just for poops and laugs |
| 14:53 | pilne | laughs* |
| 14:54 | justin_smith | yeah, it's probably just a least-effort direct translation from CL |
| 14:54 | justin_smith | that's what it looks like |
| 14:56 | pilne | what i like most about clojure, is that (in theory) i can dip into say kotlin or scala as a "include" if they can do something in an easier/better way (: (kotlin because it claims 100% compatibility with java, and... straight up java rustles my jimmies) |
| 14:57 | justin_smith | pilne: scala is weird - it's easy to go back and forth with frege but it's pretty much one way scala calling clojure if you want to use them together |
| 14:57 | pilne | hmmm, noted |
| 14:57 | justin_smith | also frege has the cool things from scala :P |
| 14:58 | justin_smith | pilne: scala adds weird abstractions outside of what the jvm defines (where clojure works very hard to be vanilla jvm compatible in comparison) |
| 14:59 | pilne | ahhh, so... not to sound too... silly, scala is kinda jvm++ whereas clojure tries to be jvm |
| 14:59 | justin_smith | you can easily use clojure from java, java from clojure; with scala it's only use java from scala, use clojure from scala, the other direction isn't really feasible |
| 14:59 | clojurebot | Cool story bro. |
| 14:59 | pilne | so since kotlin is 100% java interop either direction, it *should* work in place of java (in theory) |
| 15:00 | justin_smith | pilne: yeah, something like that. They add abstractions that aren't made accessible from outside scala itself, and they add restrictions that are hard to work with from outside their lang. |
| 15:00 | pilne | very good to know, ty (: |
| 15:00 | justin_smith | pilne: yeah, if java->kotlin and kotlin->java are both easy, clojure->kotlin kotlin->clojure should both be easy as well |
| 15:01 | pilne | hrm |
| 15:01 | pilne | frege is at jdk9 |
| 15:01 | pilne | looks like daddy needs to find a ppa |
| 15:01 | justin_smith | also if you've been playing with haskell and have scala on the radar, definitely check out frege |
| 15:01 | justin_smith | haha |
| 15:01 | justin_smith | really, frege needs 9? |
| 15:01 | pilne | says "should run" digging for a minimum requirement |
| 15:02 | justin_smith | pilne: they generate byte code iirc, so they should be very explicit about what minimum version they target (and I would be super surprised if it was 9) |
| 15:03 | pilne | ahhh, there was a problem with jdk9 if it was detected as the only environment |
| 15:04 | justin_smith | looks like it supports 1.7 ? |
| 15:04 | pilne | 7 is the minimum |
| 15:04 | justin_smith | confirmed! |
| 15:05 | pilne | although this probably means i need to get purescript for my javascript side of things *grumbles about the gf and her webapps |
| 15:05 | justin_smith | heh |
| 15:07 | pilne | she's a frickin artistic genius, and has a lot of good ideas, but since i "like" coding it is something "we can do together honey" >.< a wise man (my father) once told me "happy wife, happy life" and since she'd be my wife if we lived in a common-law marriage state... |
| 15:11 | pilne | i did however put my foot down at 1) owning an apple computer and 2) paying for the priviledge of deploying to iOS until we can actually see some decent monetary income from these projects she has |
| 15:11 | pilne | the couch was pretty comfy that week |
| 16:17 | tolstoy | Kotlin. Interesting. Does it seem to be going places? |
| 16:19 | tolstoy | Default to immutability? |
| 16:19 | tolstoy | Looks reasonably clean. |
| 16:36 | justin_smith | tolstoy: I don't think it defaults to immutability anywhere, it's just an attempt to be a less boiler-plate java on the jvm |
| 16:36 | pilne | boiler-plate, the TPS reports of programming >.< |
| 16:40 | pilne | why are the "heavyweight" IDEs so popular in the java world? |
| 16:41 | justin_smith | instead of making a less clumsy language, they try to make the editor do the tedious stuff automatically |
| 16:41 | tolstoy | Pilne: because there are just so many files. Every little concept is yet another file and the IDE's are pretty good at managing that. |
| 16:41 | tdammers | actually the language is kind of designed with an IDE in mind |
| 16:41 | tdammers | verbose syntax, because the IDE takes care of most of the typing for you anyway |
| 16:42 | justin_smith | there is an equal and opposite problem in the haskell world - people think that any tooling is a symptom of a defect in the language, so there isn't a really strong IDE |
| 16:42 | tolstoy | The root of all evil are huge code bases, but that's a minority opinion, I guess. If your app needs and IDE, it's too big. ;) |
| 16:42 | tdammers | efforts are being made, but I believe the reason why no strong IDE exists is because nobody finds the lack of one painful enough |
| 16:43 | pilne | meh, i've *never* had a good experience with eclipse, intellij, or netbeans |
| 16:43 | tolstoy | Do you work on 10-year cash-cow legacy apps? |
| 16:44 | pilne | moi? no, i work on my own crap-tastic code (or tutorials) 100% of the time (so far) |
| 16:44 | tolstoy | I've worked with people who do amazing things with Intellij digging around ancient code bases. |
| 16:44 | tdammers | the situation in Haskell is that while a good IDE would make the situation better, everyone who is capable of writing one has a much easier and cheaper way at hand for solving their immediate problems |
| 16:44 | tolstoy | Like digging through the levels of Troy. |
| 16:45 | tdammers | why write an IDE when you can write a library |
| 16:45 | tdammers | (likewise, why maintain a code snippets database in your IDE when you have macros built right into the language) |
| 16:46 | tolstoy | An IDE is partly about the language, but it's also all that other stuff, like a database inspector, test runner, build machine integrationer, Jira ticket whateverer and Agile Scrum burner downer. |
| 16:46 | visof | hi guys |
| 16:46 | tolstoy | Some people really like that kind of thing. |
| 16:47 | visof | ,(apply merge-with (partial conj []) [{:hello 1} {:hello 3} {:hello 4}]))) |
| 16:47 | clojurebot | {:hello [[1 3] 4]} |
| 16:47 | visof | ,(apply merge-with (comp flatten (partial conj [])) [{:hello 1} {:hello 3} {:hello 4}]))) |
| 16:47 | clojurebot | {:hello (1 3 4)} |
| 16:47 | visof | when i apply the last expression to very big list i got stackoverflow |
| 16:47 | visof | is there an efficient alternative to do the same? |
| 16:48 | tdammers | well, at least in the Windows world, IDEs often make up for the lack of modularity and composability in the OS itself |
| 16:48 | visof | i guess the problem in comp |
| 16:49 | tolstoy | I used to say that Linux made a pretty good IDE and a pretty good App Server. |
| 16:50 | allenj12 | do i need a macro for this http://pastebin.com/G8eEpKrS? or is there a function out there im missing? |
| 16:52 | visof | allenj12: get-in https://clojuredocs.org/clojure.core/get-in |
| 16:52 | justin_smith | (let [in [{:hello 1} {:hello 3} {:hello 4}] ks (distinct (mapcat keys in)) init (zipmap ks (repeat []))] (apply merge-with conj init in)) |
| 16:52 | allenj12 | visof: oh thank you! |
| 16:52 | justin_smith | ,(let [in [{:hello 1} {:hello 3} {:hello 4}] ks (distinct (mapcat keys in)) init (zipmap ks (repeat []))] (apply merge-with conj init in)) ; visof |
| 16:52 | clojurebot | {:hello [1 3 4]} |
| 16:54 | visof | justin_smith: do you think it's efficient than (apply merge-with (comp flatten (partial conj [])) [{:hello 1} {:hello 3} {:hello 4}]))) ? |
| 16:54 | visof | justin_smith: also do you know why i got this stackOverFlow error? |
| 16:54 | justin_smith | visof: yes, and unlike flatten it is well behaved |
| 16:54 | justin_smith | visof: because flatten sucks |
| 16:54 | visof | ,(time (apply merge-with (comp flatten (partial conj [])) [{:hello 1} {:hello 3} {:hello 4}])))) |
| 16:54 | clojurebot | "Elapsed time: 0.293985 msecs"\n{:hello (1 3 4)} |
| 16:55 | visof | ,(time (let [in [{:hello 1} {:hello 3} {:hello 4}] ks (distinct (mapcat keys in)) init (zipmap ks (repeat []))] (apply merge-with conj init in)) |
| 16:55 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 16:55 | visof | ,(time (let [in [{:hello 1} {:hello 3} {:hello 4}] ks (distinct (mapcat keys in)) init (zipmap ks (repeat []))] (apply merge-with conj init in))) |
| 16:55 | clojurebot | "Elapsed time: 0.39815 msecs"\n{:hello [1 3 4]} |
| 16:55 | justin_smith | visof: also, unlike the flatten version, you don't need conditionals on all your other code to figure out if the values were put in a collection or not |
| 16:55 | ridcully | ,(time (apply merge-with #(conj (if (vector? %1) %1 [%1]) %2) [{:hello 1} {:hello 3} {:hello 4}])) |
| 16:55 | clojurebot | "Elapsed time: 0.245 msecs"\n{:hello [1 3 4]} |
| 16:56 | justin_smith | ridcully: what I don't like about that is that spawns a whole bunch of if checks, seeing if you have combined values or not for a given key |
| 16:56 | ridcully | yeay it feels very clumsy |
| 16:56 | amalloy | also it doesn't work if you want your map to store vectors |
| 16:56 | justin_smith | if you plan on ever using the return value that is |
| 16:56 | ridcully | at least it's flatten-less |
| 16:56 | justin_smith | amalloy: excellent point |
| 16:57 | amalloy | just like (apply merge (for [m ms, [k v] m] {k [v]})) |
| 16:57 | justin_smith | ,(let [in [{:hello [1]} {:hello [3]} {:hello [4]}] ks (distinct (mapcat keys in)) init (zipmap ks (repeat []))] (apply merge-with conj init in)) ; other versions break here |
| 16:57 | clojurebot | {:hello [[1] [3] [4]]} |
| 16:57 | amalloy | er |
| 16:57 | amalloy | apply merge-with conj, of course |
| 16:57 | justin_smith | amalloy: nice |
| 16:58 | amalloy | into |
| 16:58 | amalloy | not conj. jeez |
| 16:58 | amalloy | justin_smith: it's kinda a classic |
| 16:58 | amalloy | i'm just too scatter-brained right now to remember it correctly all at once apparently :P |
| 16:59 | justin_smith | ,(apply merge-with into (for [m [{:hello 1} {:hello 3} {:hello 4}] [k v] m] {k [v]})) |
| 16:59 | clojurebot | {:hello [1 3 4]} |
| 16:59 | justin_smith | amalloy: I think into is the right answer, and that's awesome I hope I remember it next time I need it |
| 17:01 | justin_smith | visof: amalloy 's answer is the right one |
| 17:01 | justin_smith | ,(time (apply merge-with into (for [m [{:hello 1} {:hello 3} {:hello 4}] [k v] m] {k [v]}))) |
| 17:01 | clojurebot | "Elapsed time: 0.837625 msecs"\n{:hello [1 3 4]} |
| 17:01 | amalloy | my christmas gift to you, justin_smith |
| 17:01 | justin_smith | aww, shucks |
| 17:05 | pilne | hrm, maybe i'll give intellij another shot.... seems like it is the only ide out there that can support clojure/kotlin/frege (and of course java, scala, and ceylon (scala and ceylon being things i want to "understand" if not use). |
| 17:06 | tolstoy | There's always Emacs. ;) |
| 17:07 | pilne | if i were to go the emacs way, i'd be hard pressed not to use "spacemacs" :p |
| 18:13 | allenj12 | how do you type hint for vectors? |
| 18:14 | allenj12 | ^Vector does not work but ^String does which i find weird |
| 18:14 | justin_smith | allenj12: clojure.lang is not in scope by default |
| 18:15 | justin_smith | ,(defn v [^clojure.lang.Vector x] x) |
| 18:15 | clojurebot | #error {\n :cause "clojure.lang.Vector"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: clojure.lang.Vector, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.ClassNotFoundException\n :message "clojure.lang.Vector"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java... |
| 18:15 | justin_smith | ,(defn v [^clojure.lang.PersistentVector x] x) |
| 18:15 | clojurebot | #'sandbox/v |
| 18:15 | justin_smith | one also needs to get the class name right of course |
| 18:17 | allenj12 | justin_smith: ah i see so ^clojure.lang.PersistantVector |
| 18:17 | allenj12 | justin_smith: thank you |
| 18:17 | justin_smith | yeah, np |
| 18:17 | allenj12 | ,(defn v [^clojure.lang.PersistentVector x] x) |
| 18:17 | clojurebot | #'sandbox/v |
| 18:18 | justin_smith | that might be less ugly if you import the class in your ns, of course |
| 18:20 | supersym | How would I iterate a CopyOnWriteArrayList iterator in Clojure? (third party Java lib interop :( ) |
| 18:20 | supersym | seq won't work on it |
| 18:21 | justin_smith | supersym: have you tried iterator-seq ? |
| 18:35 | devth_ | can a record refer to itself? |
| 18:36 | TimMc | Only through shenanigans, I think. |
| 18:36 | devth | oh wait, i just remembered it's the 1st param to every fn O_O |
| 18:36 | TimMc | lulz |
| 18:36 | devth | must be the ipa |
| 18:36 | TimMc | :-) |
| 18:37 | justin_smith | ,(defrecord Shenanigans [] Object (toString [this] (Shenanigans.))) |
| 18:37 | clojurebot | sandbox.Shenanigans |
| 18:38 | justin_smith | ,(str (Shenanigans.)) |
| 18:38 | clojurebot | #error {\n :cause "sandbox.Shenanigans cannot be cast to java.lang.String"\n :via\n [{:type java.lang.ClassCastException\n :message "sandbox.Shenanigans cannot be cast to java.lang.String"\n :at [sandbox.Shenanigans toString "NO_SOURCE_FILE" -1]}]\n :trace\n [[sandbox.Shenanigans toString "NO_SOURCE_FILE" -1]\n [clojure.core$str invokeStatic "core.clj" 529]\n [clojure.core$str invoke "core.c... |
| 18:38 | justin_smith | see, that's the right error! |
| 18:38 | justin_smith | I should have picked a better method though |
| 18:41 | justin_smith | ,(defrecord Shenanigans [] Object (clone [this] (Shenanigans.))) ; much tidier |
| 18:41 | clojurebot | sandbox.Shenanigans |
| 18:41 | justin_smith | ,(.clone (Shenanigans.)) |
| 18:41 | clojurebot | #sandbox.Shenanigans{} |
| 18:41 | justin_smith | TimMc: see, it can totally refer to itself |
| 19:03 | supersym | justin_smith: nope... thanks |
| 19:05 | supersym | works perfect *tips his hat* |
| 19:05 | justin_smith | cool |
| 19:12 | {blake} | OK, got a Java object (CellRangeAddressList) which implements java.util.list<CellRangeAddress>...how do I clojureize that? (Or does the template screw things up?) |
| 19:13 | justin_smith | {blake}: generics are a fiction that only javac believes in, they don't exist in the vm |
| 19:13 | {blake} | So, you're saying there is no spoon? |
| 19:13 | justin_smith | exactly - you can use into or vec to put it in a vector |
| 19:14 | justin_smith | {blake}: javac will enforce generics, just like it does checked exceptions, neither of which are enforced on the level clojure interacts with the vm |
| 19:14 | {blake} | justin_smith: Huh. Well, I've been trying that. Vec, into, seq... |
| 19:15 | {blake} | "Unable to convert: class org.apache.poi.ss.util.CellRangeAddressList to Object[]" |
| 19:15 | justin_smith | if it implements List it will work with into... |
| 19:15 | justin_smith | hmm |
| 19:15 | devth | just realized i don't know whether clojure uses javac or if it has its own compiler that emits jvm bytecode. can someone enlighten me? |
| 19:16 | justin_smith | devth: clojure has its own bytecode emitter |
| 19:16 | {blake} | For "into []" I get "Don't know how to create ISeq from: org.apache.poi.ss.util.CellRangeAddressList" |
| 19:16 | justin_smith | devth: there are java files in clojure.core, and javac is used for those, of course |
| 19:16 | devth | justin_smith: ok cool. are they used in separate phases? |
| 19:16 | justin_smith | devth: right, the javac compiling only happens when compiling clojure.core itself from source |
| 19:17 | justin_smith | devth: at runtime, clojure uses its own bytecode emitter, and doesn't use javac at all |
| 19:17 | devth | ah. makes sense. thanks |
| 19:17 | justin_smith | {blake}: according to the javadoc org.apache.poi.ss.util.CellRangeAddressList does not implement List https://poi.apache.org/apidocs/org/apache/poi/ss/util/CellRangeAddressList.html |
| 19:18 | TEttinger | https://poi.apache.org/apidocs/org/apache/poi/ss/util/CellRangeAddressList.html#getCellRangeAddresses() |
| 19:18 | justin_smith | {blake}: that class is bad and the people who implemented it should feel bad |
| 19:18 | {blake} | justin_smith: Wut? Isn't that what... |
| 19:18 | TEttinger | indeed |
| 19:19 | TEttinger | {blake}: extends Object . |
| 19:19 | justin_smith | {blake}: read it and weep, it inherits directly from Object |
| 19:19 | {blake} | Oh, crap, it's the underlying, hidden _list field that implements list. |
| 19:19 | TEttinger | you can get an array with https://poi.apache.org/apidocs/org/apache/poi/ss/util/CellRangeAddressList.html#getCellRangeAddresses() |
| 19:20 | {blake} | Which is what I was looking at and which is completely inaccessible. Y |
| 19:20 | TEttinger | which should work with into |
| 19:20 | justin_smith | yup, that should be the trick |
| 19:20 | justin_smith | one of those apis that makes you say WAT |
| 19:20 | TEttinger | {blake}: am I coming through OK? is there static on the line? |
| 19:21 | {blake} | TEttinger: Yeah! Thanks! |
| 19:21 | TEttinger | woo |
| 19:21 | {blake} | lotta poi |
| 19:21 | pilne | screw it all... just gonna use atom because it is comfortable, and use a terminal for a repl, screw these smeggin IDEs >.< |
| 19:21 | {blake} | in my life |
| 19:22 | pilne | although i need to hope someone will write a grammar for ceylon by the time i decide to start futzing around with it >.< |
| 19:22 | justin_smith | pilne: I have three terminals open for my three repls, it works nicely |
| 19:22 | justin_smith | pilne: why would you need a grammar? |
| 19:23 | pilne | for syntax hilighting.... i feel like a blind lesbian in a fish market without it >.< |
| 19:24 | justin_smith | pilne: I know you are just trying to joke around but I can't help noticing how many of your jokes are about women and seem sexual in nature, and that's OK among your friends I'm sure but it's not the appropriate kind of joking for this forum. |
| 19:24 | pilne | i apologise and will tone it down |
| 19:26 | TEttinger | alternatively: I feel like I'm pitching a no-hitter on LSD; things keep happening and I don't know why |
| 19:26 | TEttinger | https://www.youtube.com/watch?v=_vUhSYLRw14 |
| 19:26 | justin_smith | TEttinger: lol |
| 19:26 | TEttinger | it happened once! |
| 19:26 | justin_smith | TEttinger: classic story, if that link goes where I think it does |
| 19:26 | TEttinger | yes |
| 19:27 | TEttinger | "performance reducing drugs" |
| 19:30 | TEttinger | ellis' remark about "I only saw signals, like a traffic light" reminded me of highlighting gone haywire |
| 19:49 | justin_smith | TEttinger: now I want to make a "word salad highlighter" that would just randomly shift colors of parts of a buffer over time |
| 19:49 | justin_smith | screen saver style |
| 19:50 | justin_smith | perhaps forming 2d shapes that have no relation to the content of the file |
| 19:51 | Bronsa | justin_smith: ever tried M-x zone? |
| 19:51 | justin_smith | Bronsa: is that the one that makes the text drip and such? |
| 19:52 | Bronsa | yeah |
| 19:54 | justin_smith | nice, my buffer's dripping |
| 19:54 | Bronsa | zone-when-idle after 1s is a fun way to mess with a coworker leaving their laptop unlocked |
| 19:54 | justin_smith | oh man, I'll have to remember that one |
| 20:07 | pilne | all i have to do to mess with my coworkers is re-arrange the bookmarks in the shared IE (ugh), or the desktop... such funzies lol |
| 21:07 | TEttinger | justin_smith: already implemented in my text-based game lib. http://i.imgur.com/SEw2LXe.gifv |
| 21:08 | TEttinger | I really want to get to finishing this lib's latest version; once there's a non-beta I think I could write a more idiomatic clojure binding |
| 21:13 | BRODUS | i get that its really bad style, but is there any other reason why you shouldn't use a def within a function? |
| 21:24 | TEttinger | BRODUS: there are times when there's no way around it. but the problem is the defined thing is unusable until that fn is called, though "declare" can help somewhat, and there's no way to tell other than checking the name if it has the right value (from the fn executing successfully and defining your thing). |
| 21:24 | TEttinger | it's also more than a little confusing |
| 21:25 | TEttinger | "why do I need to call X before I ever do anything with Y?" "why doesn't Y have top-level documentation?" |
| 21:31 | BRODUS | TEttinger2: Thanks |
| 21:35 | ben_vulpes | BRODUS: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
| 21:36 | BRODUS | ? |
| 21:36 | ben_vulpes | def-in-defn |
| 21:37 | ben_vulpes | it's going to break important stuff like `doc' and `src' |
| 21:40 | BRODUS | im not doing it, i was putting a function inside a let and it raised a few questions for me |
| 21:49 | pilne | ok, i was truly scarred working in java (1.2 or 1.3) in college, is it "not as bad" now to use it from clojure where needed (so i can abandon my search for a language to use in its place?) |
| 21:50 | pilne | it was j2se 1.2 or 1.3 for further clarification |
| 21:54 | amalloy | pilne: 1.5 introduced a few big quality-of-life features. the language is still broadly the same though |
| 21:54 | neoncontrails | pilne: it's verrry different. I don't know about better, but the generic types are a really substantial change to the langauge |
| 21:54 | neoncontrails | *language |
| 21:55 | pilne | hrm... maybe i'll just cross my fingers and hope that between clojure and frege i won't have to use "pure" java >.< kotlin seem to be a pita unless i want to sell my soul to jetbrains/intellij >.< (too bad for them there is nothing to buy) |
| 21:56 | neoncontrails | pilne: I've always considered Clojure an alternate syntax for Java, rather than a stand-alone language — it helps keep my expectations low :) |
| 21:59 | pilne | heh (: |