2014-04-24
| 00:04 | oinksoft | akhudek: hm, ok, yea, tbh i do not like the korma structure, but i ignored that feeling |
| 00:04 | oinksoft | akhudek: i'll take a look at the jdbc pattern |
| 00:25 | danlamanna | maybe i have a huge hole in my understanding, i can conf/disj to a set but still need to define it somehow |
| 00:26 | TEttinger | ,(def here-you-go #{1 2 3}) |
| 00:26 | clojurebot | #'sandbox/here-you-go |
| 00:26 | TEttinger | ,here-you-go |
| 00:26 | clojurebot | #{1 3 2} |
| 00:28 | danlamanna | yeah sorry - i was referring to guns' comment (a while ago) about me using def within a function when i should do some local binding |
| 00:31 | TEttinger | ,(let [set-thing #{1 2 3}] (conj set-thing 5)) |
| 00:31 | clojurebot | #{1 3 2 5} |
| 00:32 | danlamanna | suppose i have a loop within that let block though, there's no way to append to that set-thing each iteration, is there? |
| 00:33 | TEttinger | do you mean the macro called loop, or something loop-like? |
| 00:33 | danlamanna | something loop-like, it happens to be doseq in this case |
| 00:34 | danlamanna | https://gist.github.com/11241529 to be precise, mentioned-files being the culprit |
| 00:34 | TEttinger | it seems like that's the wrong looping thing to use to me, but I'll check |
| 00:36 | TEttinger | yeah that won't do what you intend I think |
| 00:36 | TEttinger | the defs will either overwrite a global value or not overwrite anything, I can't remember which |
| 00:37 | beamso | it seems weird to use def instead of let in that code |
| 00:37 | danlamanna | it works correctly, i'm just talking in the interest of best practice |
| 00:37 | danlamanna | beamso: that's what i mean, let seems to be the consensus - but i don't see how since the value would be unable to be appended to each iteration |
| 00:39 | TEttinger | you can also let an atom |
| 00:40 | gtuckerkellogg | hmm, i upgraded leiningen to 2.3.4, and now it's complaining about cider-nrepl |
| 00:40 | beamso | mentioned-files could be a ref or an atom. |
| 00:40 | beamso | you could even have mentioned-files as a dynamic def outside main |
| 00:41 | danlamanna | i feel like this would be a pretty common scenario |
| 00:42 | beamso | actually, given that mentioned-files appears to be intended to be a set, you could just initialise it with all the files from --apply-options |
| 00:44 | beamso | the number of duplicates is the difference in size between what is returned from --apply-options and the size of the set |
| 00:52 | amalloy | danlamanna: the idea is to not use a for-side-effects looping construct like doseq at all |
| 00:53 | danlamanna | amalloy: i'm starting to realize that. based on http://stackoverflow.com/questions/940712/redefining-a-letd-variable-in-clojure-loop and http://en.wikibooks.org/wiki/Clojure_Programming/By_Example#Immutable_data |
| 00:53 | amalloy | instead, you reduce over files, with an accumulator that's building up a duplicates list |
| 00:53 | amalloy | or mentioned files, rather |
| 00:53 | danlamanna | amalloy: these are the functional programming-esque things i'm trying to get better at. |
| 00:54 | amalloy | in your example, it's not even clear what mentioned-files is for: you only write it, never read it! |
| 00:54 | amalloy | so it's hard to replace the code that builds it - why is it even there? |
| 00:54 | amalloy | oh, no, it's in the when |
| 00:54 | danlamanna | amalloy: i use it to check if the file has been mentioned before |
| 00:55 | danlamanna | amalloy: i'm not *totally* fargone :P |
| 00:56 | gtuckerkellogg | is there a way to force leiningen to reinstall a jar? |
| 00:56 | gtuckerkellogg | a dependency, that is |
| 00:57 | beamso | delete the .jar and run lein deps again? |
| 00:57 | Frozenlo` | gtuckerkellogg: delete it from .m2 |
| 00:58 | amalloy | danlamanna: https://gist.github.com/amalloy/11241974 is the most obvious rewrite of your main loop |
| 00:58 | gtuckerkellogg | ty. |
| 00:59 | amalloy | the function that's reducing is in charge of taking the mentioned-file list and a file, and producing a new mentioned-file list |
| 01:00 | danlamanna | amalloy: i see |
| 01:00 | amalloy | are you coming from C? (printf "%s\n" x) is a weird way to write (println x) |
| 01:01 | danlamanna | amalloy: yes |
| 01:01 | amalloy | i mean, i love printf, and find it usually much more readable than combining strings with str. but here it's a bit silly |
| 01:01 | danlamanna | amalloy: i tend to err on the side of caution, i was doing something in python the other day and it decided to print a newline for me as well |
| 01:04 | bitemyapp | arrdem: really? |
| 01:06 | TEttinger | heyy it's everybody's favorite haskell spammer |
| 01:07 | bitemyapp | TEttinger: https://twitter.com/bitemyapi |
| 01:07 | TEttinger | how goes bitemyapp |
| 01:07 | bitemyapp | TEttinger: it goes very well...typed. |
| 01:08 | TEttinger | what is that, bitemyapp? |
| 01:08 | TEttinger | that API |
| 01:08 | bitemyapp | I think it's a poorly tuned markov chain fed bot |
| 01:14 | amalloy | speaking of gibberish-generating bots, http://git-man-page-generator.lokaltog.net/ is pretty convincing |
| 01:15 | bbloom | amalloy: i wonder how many ppl were WTF-ing hard before he put that warning banner up |
| 01:16 | technomancy | aww--there's a banner now? |
| 01:16 | technomancy | lame |
| 01:16 | technomancy | that site is masterful |
| 01:17 | gtuckerkellogg | so I upgraded lein, and cider-nrepl 0.1.0-SNAPSHOT is breaking the repl even on a new project with the default template. |
| 01:17 | gtuckerkellogg | Has anyone else seen this? |
| 01:18 | gtuckerkellogg | my profiles.clj contains [cider/cider-nrepl "0.1.0-SNAPSHOT"] as a :plugin |
| 01:21 | beamso | https://github.com/clojure-emacs/cider-nrepl/issues/37 |
| 01:25 | seangrove | Ahk, scoped css limits CSS to a given element, *and* its descendants. So close, yet so far... |
| 01:26 | bbloom | seangrove: yeah, that scoped thing is wildly wrong |
| 01:27 | seangrove | bbloom: Something about inmates and the asylum... |
| 01:27 | bbloom | seangrove: the DOM inherently lacks the necessary separation between a source template and the expanded result |
| 01:27 | bbloom | seangrove: logical vs visual tree, etc |
| 01:28 | seangrove | bbloom: Yeah, I think about the amount of work that could be used across libraries if there were a better common denominator |
| 01:28 | bbloom | you don't want to scope to a sub tree, you want to scope to a node set by the component that produced those nodes |
| 01:29 | seangrove | Instead, the best we can do is, "store some state and styles on some dom nodes, and expect that you probably own the subtree, so you can rip it apart if you need to. If you need to share, well, good luck." |
| 01:31 | bbloom | react.js is like an assembler. it's the last reasonable stage you want to deal with, but it's still awkward and complex b/c the architecture is awkward and complex |
| 01:32 | seangrove | bbloom: If you're looking to grind your teeth http://oksoclap.com/p/P3aS4GtR2L |
| 01:33 | seangrove | I'm not sure who's on this panel, but they need to have a long think about things. |
| 01:33 | bbloom | seangrove: i can't make sense of these notes & i probably don't want to |
| 01:34 | seangrove | bbloom: No, it's all just madness |
| 01:49 | beamso | do people use clojure/data.xml for xml or something else? |
| 02:08 | dissipate | does anyone know of a way to run tests in parallel? |
| 02:12 | beamso | my googling says that you can't :/ |
| 02:27 | oinksoft | is there a way to call a function dynamically |
| 02:27 | oinksoft | like clojure.core / 'map ... |
| 02:28 | oinksoft | where 'map is variable |
| 02:28 | beamso | apply |
| 02:29 | oinksoft | ? |
| 02:29 | beamso | ,(max [1 2 3]) |
| 02:29 | clojurebot | [1 2 3] |
| 02:29 | beamso | ,(apply max [1 2 3]) |
| 02:29 | clojurebot | 3 |
| 02:29 | oinksoft | ... |
| 02:29 | oinksoft | i want to dynamically access members in a namespace |
| 02:29 | beamso | i was just using the worked examples from http://clojuredocs.org/clojure_core/clojure.core/apply |
| 02:30 | beamso | how you get your dynamic function is up to you, but apply will let you execute that function with arguments that you give ti |
| 02:30 | beamso | *it. |
| 02:30 | oinksoft | yes, i know that |
| 02:31 | oinksoft | my question was about the how you get your function |
| 02:32 | oinksoft | let's say i want to define a function (call-in-core map - (range 10)) |
| 02:33 | oinksoft | or (call-in-core 'map - (range 10)) |
| 02:33 | oinksoft | the improtant part is the 'map being variable, ignore that this brekas maps being lazy |
| 02:35 | oinksoft | i see functions like ns-publics, but not ones to access the ns |
| 02:35 | pyrtsa | oinksoft: See resolve or ns-resolve |
| 02:35 | oinksoft | pyrtsa: thanks! |
| 02:36 | pyrtsa | They return the Var, which you can either call directly or access with @x or (deref x). |
| 02:37 | dissipate | clojurecheck hasn't been updated in 2 years. is it abandonware? https://github.com/jbondeson/clojurecheck |
| 02:37 | oinksoft | pyrtsa: this is what i needed, thanks |
| 02:40 | dissipate | nevermind, found test.check |
| 02:40 | dissipate | https://github.com/clojure/test.check |
| 02:51 | oinksoft | lack of pattern matching is a pain when writing an api |
| 02:51 | oinksoft | what do you do? |
| 02:51 | beamso | pattern matching? |
| 02:52 | oinksoft | it's easier to munge this stuff in a lang like python, but in a functional language guards and real pattern matching like in erlang are nice |
| 02:52 | oinksoft | i'm not sure how to avoid writing lots of -type variants |
| 02:53 | oinksoft | (foo 1 2) ... (foo-with-vec 1 [2 3]) |
| 02:53 | oinksoft | because of the restirction on mutliple overloads w/ same arity |
| 02:54 | noidi | oinksoft, have you tried https://github.com/clojure/core.match and https://github.com/jamii/strucjure ? |
| 02:54 | oinksoft | doing (if (vector? 2nd-param ... seems ugggly |
| 02:56 | oinksoft | noidi: yea but seems like lipstick on a pig for simple type switching |
| 02:56 | oinksoft | noidi: you would have to do (match [(vector? arg2)] [true] ... [false .... |
| 02:56 | akhudek | oinksoft: you could look at multimethods |
| 02:57 | oinksoft | yea, i just wish there were a less verbose way :( that is probably the cleanest, thanks! |
| 03:11 | wunki | how would I catch an error based on the `:type` supplied here: https://github.com/Prismatic/fnhouse/blob/master/src/fnhouse/middleware.clj#L55-L63 |
| 03:17 | ivan | wunki: maybe https://github.com/fredericksgary/catch-data but haven't tried this |
| 03:19 | ivan | or just use a single catch block and use (ex-data e) to decide what to do |
| 03:23 | badlambda | I have implemented Donald Knuth's algorithm X in Clojure. I am looking to improve on my implementation and value your feedback. https://www.refheap.com/79579 |
| 03:29 | sm0ke | sounds like a sales pitch |
| 03:39 | wunki | ivan: thanks, will try `ex-data`! |
| 03:40 | Glenjamin | wunki: you might be able to use slingshot - although i'm unsure if that works on generic ex-info calls |
| 03:40 | dbasch | badlambda: it looks like your code would be cleaner if you were using 1s and 0s instead of true/false |
| 03:41 | wunki | Glenjamin: I tried using slingshot, but wasn't able to get it to work |
| 03:41 | wunki | Glenjamin: but that's probably my incompetence |
| 03:41 | dbasch | badlambda: also, (range 0 n) = (range n) |
| 03:43 | dbasch | badlambda: get-indices-where-true should be implemented with for |
| 03:46 | dbasch | badlambda: (if (nil? something) nill some-code) = (when-not something some-code) |
| 03:51 | dbasch | badlambda: if you’re removing things at specific locations, look into using vectors instead of lists |
| 03:51 | dbasch | badlambda: there’s little reason to use pure lists. Check out subvec |
| 03:53 | clgv | badlambda: you got a lot of nested maps there. you should break them up in several functions or at least use threading via ->> and some comments in-between |
| 03:55 | clgv | badlambda: (if (nil? x) nil (something ...)) is better written as (when x (something ...)) |
| 03:56 | dbasch | badlambda: more importantly, your code doesn’t compile :) |
| 04:02 | dbasch | badlambda: (filter #(not (in? % l2)) l1) = (remove #(in? % l2) l1) |
| 04:05 | rolfb | are there any exciting ways to use #() to build an anonomyous function and make it recursive? |
| 04:06 | clgv | rolfb: no. you need to use the verbose form |
| 04:07 | clgv | rolf: oh wait. recur should work^^ |
| 04:07 | rolfb | clgv: checking |
| 04:08 | clgv | ,(#(if (zero? %1) %2 (recur (dec %1) (* %1 %2))) 5 1) |
| 04:08 | clojurebot | 120 |
| 04:08 | clgv | rolfb: factorial ^^ |
| 04:08 | rolfb | % and %1 is the same? |
| 04:08 | clgv | yes |
| 04:08 | rolfb | clgv: where can i read up on syntatic sugars like % in short form? |
| 04:08 | clgv | use %1 if you have more than one param |
| 04:09 | clgv | rolfb: I guess most books should include it. some info is here as well http://clojure.org/reader |
| 04:10 | rolfb | clgv: perfect, thanks |
| 04:14 | dbasch | ,(#(recur)) |
| 04:14 | clojurebot | Execution Timed Out |
| 04:14 | clgv | dbasch: bad boy ;) |
| 04:14 | dbasch | :) |
| 04:14 | clgv | clojurebot: poor bot. botsnack! |
| 04:14 | clojurebot | Pardon? |
| 04:15 | clgv | clojurebot: botsnack |
| 04:15 | clojurebot | thanks; that was delicious. (nom nom nom) |
| 04:16 | locks | snacks won’t save you come the skynet revolution |
| 04:19 | rolfb | locks, you are everywhere |
| 04:20 | locks | rolfb: it’s part of my “learn by osmosis” approach. so far haven’t had much success. |
| 04:20 | rolfb | locks: smart, i'm trying learn by 4clojure and asphyr |
| 04:20 | rolfb | seems to be working ok |
| 04:21 | locks | asphyr? |
| 04:21 | rolfb | aphyr |
| 04:21 | rolfb | sorry |
| 04:21 | rolfb | http://aphyr.com/posts/301-clojure-from-the-ground-up-welcome |
| 04:22 | locks | oh |
| 04:22 | locks | I did a chunk of 4clojure too, and I have joy of clojure on my kindle |
| 04:22 | rolfb | haven't gotten to joy of clojure yet as the back says you need some familiarity with clojure before reading it |
| 04:22 | locks | curiously, I’m watching this https://www.youtube.com/watch?v=XeWP60DK6O0&feature=youtube_gdata |
| 04:23 | rolfb | interesting, thanks |
| 04:23 | rolfb | locks: related to aphyr; https://twitter.com/fogus/status/459015590112681984 |
| 04:23 | locks | JOY’s pacing isn’t a walk in the park, for sure |
| 04:23 | locks | I saw it, I’m following fogus :] |
| 04:24 | rolfb | i'm at problem 39 in 4clojure, but feeling a tiny bit stuck on a good way to solve it |
| 04:24 | clgv | a student of mine said that he learned much faster with "programming clojure (2nd edition)" than with "clojure programming (O'Reilly)" |
| 04:25 | rolfb | clgv; oh really? i started the latter one |
| 04:25 | locks | those titles aren’t confusing at all |
| 04:26 | rolfb | holloway vs emerick? |
| 04:26 | clgv | right |
| 04:26 | locks | speaking of, I also got this http://shop.oreilly.com/product/0636920030409.do?intcmp=il-prog-books-videos-cat-intsrch_clojure_ct |
| 04:27 | clgv | oh whats that? |
| 04:27 | rolfb | halloway, not holloway |
| 04:28 | locks | it’s kind of the video equivalent to JOY |
| 04:28 | rolfb | locks, interesting as well :) |
| 04:28 | locks | they blitz through the hows and whys of clojure |
| 04:32 | rolfb | is there a way to pretty print vectors and such in the repl? |
| 04:33 | rolfb | like in APL |
| 04:33 | rolfb | *ducks* |
| 04:33 | clgv | clojure.pprint/pprint is a built-in function to do that |
| 04:33 | clgv | pretty printing I mean, dont know about APL ;) |
| 04:34 | rolfb | (clojure.pprint/pprint (vector [1 2 3] [:a :b :c])) doesn't do much in terms of formatting |
| 04:35 | rolfb | whoops |
| 04:35 | clgv | rolfb: maybe I did not understand what you mean. do you mean something like clojure.core/format? |
| 04:35 | rolfb | clgv; i would love to get ... the above to print like |
| 04:35 | rolfb | [[1 2 3] |
| 04:36 | rolfb | [:a :b :c]] |
| 04:36 | rolfb | on two lines |
| 04:36 | rolfb | that's what I feel is a pretty print |
| 04:41 | noidi | rolfb, http://richhickey.github.io/clojure/clojure.pprint-api.html#clojure.pprint/*print-right-margin* |
| 04:41 | noidi | http://richhickey.github.io/clojure/clojure.pprint-api.html#clojure.pprint/*print-miser-width* |
| 04:53 | rolfb | noidi; thanks |
| 05:18 | badlambda | clgv, dbasch: thanks for the feedback |
| 05:53 | irctc_ | hey.... can anyone help me ny telling how to hide a properties file in clojure |
| 05:54 | irctc_ | i am using leiningen framework for my clojure web application and there is no private folder.. where to keep the properties file?? |
| 05:54 | lazybot | irctc_: Definitely not. |
| 06:15 | clgv | irctc_: what do you want to do? what is "hiding" supposed to mean in this context? what is you reason to "hide" that file? |
| 06:22 | sm0ke | :D |
| 06:23 | clgv | lazybot: you'd ask the same, right??? |
| 06:23 | lazybot | clgv: How could that be wrong? |
| 06:23 | sm0ke | may be he is packaging passwords with code, interesting question though |
| 06:23 | sm0ke | irctc_: you can not hide it but you can obfuscate it |
| 06:24 | sm0ke | DRM sucks brother, nothing will be hidden ultimately |
| 06:31 | clgv | sm0ke: yeah, I also think that he want to package passwords or something similar... |
| 06:33 | sm0ke | now wonder there is no "licencing" frameworks |
| 06:33 | sm0ke | at least i havent seen any |
| 06:36 | rolfb | ,(format "testing") |
| 06:36 | clojurebot | "testing" |
| 06:40 | sm0ke | ,(prn \♥) |
| 06:40 | clojurebot | \♥\n |
| 06:40 | sm0ke | hmm |
| 06:40 | sm0ke | ,(prn "♥") |
| 06:40 | clojurebot | "♥"\n |
| 06:40 | sm0ke | ,(pr \1) |
| 06:40 | clojurebot | \1 |
| 06:41 | clgv | (char "♥") |
| 06:41 | clgv | ,(char "♥") |
| 06:41 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number> |
| 06:41 | clgv | ,(map char "♥") |
| 06:41 | clojurebot | (\♥) |
| 06:41 | clgv | lol^^ |
| 06:42 | clgv | ,(-> "♥" first long) |
| 06:42 | clojurebot | 9829 |
| 06:42 | sm0ke | ,' |
| 06:42 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 06:42 | sm0ke | ugh |
| 06:42 | sm0ke | ,(pr '♥) |
| 06:42 | clojurebot | ♥ |
| 06:43 | sm0ke | yes! |
| 06:43 | clgv | clojurebot: smoke |is| ♥ |
| 06:43 | clojurebot | Alles klar |
| 06:43 | sm0ke | hmm weird, ##(defn ♥ [] (pr '♥)) |
| 06:43 | lazybot | java.lang.SecurityException: You tripped the alarm! def is bad! |
| 06:43 | clgv | oops ;) |
| 06:44 | clgv | clojurebot: sm0ke |is| ♥ |
| 06:44 | clojurebot | Alles klar |
| 06:44 | clgv | sm0ke? |
| 06:44 | clojurebot | sm0ke is smoke |
| 06:44 | rolfb | def is bad? |
| 06:44 | clgv | weird |
| 06:44 | sm0ke | hmm weird, ##(defn foo [] (pr '♥)) |
| 06:44 | lazybot | java.lang.SecurityException: You tripped the alarm! def is bad! |
| 06:44 | clgv | rolfb: for lazybot yes ;) |
| 06:44 | sm0ke | wth is wrong |
| 06:44 | clgv | ,(defn ♥ [] (pr '♥)) |
| 06:44 | clojurebot | #'sandbox/♥ |
| 06:44 | sm0ke | ,(♥) |
| 06:44 | clojurebot | ♥ |
| 06:44 | clgv | ,(♥) |
| 06:44 | clojurebot | ♥ |
| 06:44 | clgv | ^^ |
| 06:45 | rolfb | interesting |
| 06:45 | jballanc | clgv: doesn't clojurebot take a while to learn something new? |
| 06:45 | sm0ke | wow clojure is nice |
| 06:45 | clgv | clojurebot is more liberal ;) |
| 06:45 | jballanc | clojurebot: sm0ke |is| ♥ |
| 06:45 | clojurebot | In Ordnung |
| 06:45 | clgv | jballanc: no it should associate that immediately |
| 06:45 | clgv | sm0ke? |
| 06:45 | jballanc | sm0ke? |
| 06:45 | clojurebot | sm0ke is ♥ |
| 06:45 | clojurebot | sm0ke is </3 |
| 06:45 | jballanc | :P |
| 06:45 | clgv | roflmao |
| 06:46 | sm0ke | weird |
| 06:46 | clgv | it seems to pick facts randomly now? |
| 06:46 | owl-v- | ,() |
| 06:46 | luxbock | need some help with a macro: https://gist.github.com/luxbock/11249913 |
| 06:46 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 06:46 | jballanc | oh, I was under the impression he had some elementary ML implementation |
| 06:46 | owl-v- | , |
| 06:46 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 06:46 | clgv | jballanc: not that I know. |
| 06:46 | sm0ke | ML is a heavy term |
| 06:46 | jballanc | owl-v-: that character is a weird spot in the unicode plane |
| 06:46 | luxbock | why does the macro return the gensym'd symbol name when I use it with map? |
| 06:47 | sm0ke | clojurebot: |is| |is| equality |
| 06:47 | clojurebot | excusez-moi |
| 06:47 | owl-v- | ,π |
| 06:47 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: π in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 06:47 | sm0ke | ,'π |
| 06:47 | clojurebot | π |
| 06:48 | owl-v- | ,' |
| 06:48 | clojurebot | |
| 06:48 | owl-v- | :) |
| 06:48 | wink | ,(def π 3.14) |
| 06:48 | clojurebot | #'sandbox/π |
| 06:48 | clgv | luxbock: because %1 and %2 are gensyms |
| 06:48 | owl-v- | ,π |
| 06:48 | clojurebot | 3.14 |
| 06:48 | clgv | luxbock: you can not map macros |
| 06:48 | owl-v- | :) |
| 06:48 | clgv | at least not as you intended |
| 06:48 | sm0ke | clojurebot: π |is| 3.14 |
| 06:48 | luxbock | hmm ok |
| 06:48 | clojurebot | You don't have to tell me twice. |
| 06:49 | owl-v- | lol |
| 06:49 | sm0ke | clojurebot: π? |
| 06:49 | clojurebot | π is 3.14 |
| 06:49 | sm0ke | clojurebot: pi |is| π |
| 06:49 | clojurebot | Ack. Ack. |
| 06:49 | sm0ke | clojurebot: pi? |
| 06:49 | clojurebot | pi is 3.14 |
| 06:49 | sm0ke | whoa! |
| 06:49 | owl-v- | clojurebot: :smart? |
| 06:49 | clojurebot | excusez-moi |
| 06:50 | owl-v- | clojurebot: clojurebot |is| :french |
| 06:50 | clojurebot | Roger. |
| 06:50 | clgv | luxbock: you can use 'map at macroexpansion time within a macro to reach that goal |
| 06:51 | clgv | clojurebot: are you tired of all these requests?? |
| 06:51 | lazybot | clgv: What are you, crazy? Of course not! |
| 06:51 | clojurebot | Titim gan éirí ort. |
| 06:51 | luxbock | clgv: can you elaborate on how that would work? |
| 06:51 | clgv | oops wrong bot :D |
| 06:52 | luxbock | I have a list of numbers of whose values I don't know beforehand, and I'd like to generate a function from each of them and store that to be used later |
| 06:52 | luxbock | so I could just use anonymous functions, but I think it would be cleaner if every function would get its name from the number it was created from |
| 06:52 | clgv | luxbock: use something similar to `(do ~@(map (fn [a b] `(fundef ~a ~b)) ...)) |
| 06:53 | ssideris | how about storing them in a map with the keys being the numbers |
| 06:53 | luxbock | ok, so in this case I would have one macro for creating the function, and then another macro that calls the other macro on a collection? |
| 06:54 | ssideris | when do you get access to the numbers? at runtime? |
| 06:54 | clgv | yeah one macro to generate multiple definitions with the definition macro |
| 06:54 | luxbock | yeah, at runtime |
| 06:54 | ssideris | macros run at compile time |
| 06:54 | clgv | but if you do not know the values at compiletime that wont work |
| 06:55 | clgv | luxbock: my heuristic tells me that you are on the wron path |
| 06:55 | luxbock | err, actually I get to access them at compile time, as in they are defined in the code |
| 06:55 | luxbock | hehe it's quite possible, my initial approach was much simpler but then I got stuck trying to figure this out as a puzzle |
| 06:55 | clgv | luxbock: cant you use partial at runtime? |
| 06:56 | luxbock | well here's what I'm trying to do: I'm generating a game-tree from a set of rules which are stored in a nested map |
| 06:56 | luxbock | so inside this nested map are a list of numbers which represent allowed bet-sizes in the game |
| 06:57 | luxbock | so at first I had them be just numbers, but then I thought since all the bet sizes are used with in realtion to the size of a pot at some point in the game, then I could just make them functions that take the pot size as the argument and return the bet-size |
| 06:58 | luxbock | but it might be better to have them be just numbers and have a separate function that calculates the bet size for a given pot size |
| 06:58 | luxbock | I often end up over thinking these things |
| 06:59 | clgv | luxbock: choose the simplest approach ;) |
| 07:26 | kras | ,(tree-seq coll? #(if (false? %) '() (identity %)) [1 2 [3 4 false]]) |
| 07:26 | clojurebot | ([1 2 [3 4 false]] 1 2 [3 4 false] 3 ...) |
| 07:26 | kras | Hi help with the above |
| 07:27 | kras | I am expecting it to insert '() as a child node wherever there is false |
| 07:28 | clgv | kras: tree-seq returns a seq and not a tree. you need something like clojure.walk/prewalk |
| 07:28 | kras | clgv: I just need a seq but the children function is inserting a '() for false |
| 07:29 | kras | that is not happening |
| 07:29 | kras | ,(doc tree-seq) |
| 07:29 | clojurebot | "([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree." |
| 07:29 | kras | pasting it with a shorter input |
| 07:29 | clgv | kras: well an empty list of children wont occur in the seq ;) |
| 07:29 | kras | ,(tree-seq coll? #(if (false? %) '() (identity %)) [3 4 false]) |
| 07:30 | clojurebot | ([3 4 false] 3 4 false) |
| 07:30 | clgv | kras: try '(()) |
| 07:30 | clgv | ,(tree-seq coll? #(if (false? %) '(()) (identity %)) [1 2 [3 4 false]]) |
| 07:30 | clojurebot | ([1 2 [3 4 false]] 1 2 [3 4 false] 3 ...) |
| 07:30 | clgv | ah lol "false" has no children |
| 07:30 | clgv | since it is not a collection due to "coll?" |
| 07:31 | clgv | why dont you just map over the seq after it is constructed to replace those false values? |
| 07:32 | clgv | ,(map #(if (false? %) '() %) (tree-seq coll? #(if (false? %) '(()) (identity %)) [1 2 [3 4 false]])) |
| 07:32 | clojurebot | ([1 2 [3 4 false]] 1 2 [3 4 false] 3 ...) |
| 07:32 | kras | I could do that but thought if it works it would be elegant |
| 07:33 | clgv | ,(map #(if (false? %) '() %) (tree-seq coll? seq [1 2 [3 4 false]])) |
| 07:33 | clojurebot | ([1 2 [3 4 false]] 1 2 [3 4 false] 3 ...) |
| 07:33 | kras | ,(map #(if (false? %) '() %) (tree-seq coll? seq [3 4 false])) |
| 07:33 | clojurebot | ([3 4 false] 3 4 ()) |
| 07:34 | clgv | kras: in this case it is only complicated to integrate it |
| 07:34 | kras | yeah this is what I need but still can't understand why the children function is not working |
| 07:42 | kras | okay got it now |
| 07:43 | kras | ,(tree-seq coll? (fn [x] (map #(if (false? %) '() (identity %)) x)) [3 4 false]) |
| 07:43 | clojurebot | ([3 4 false] 3 4 ()) |
| 07:44 | gfredericks | ,(tree-seq coll? (partial map #(if (false %) () %)) [3 4 false]) |
| 07:44 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn> |
| 07:45 | gfredericks | ,(tree-seq coll? (partial map #(if (false? %) () %)) [3 4 false]) |
| 07:45 | clojurebot | ([3 4 false] 3 4 ()) |
| 07:47 | kras | gfredericks: I tried with partial but switched back to fn |
| 07:47 | kras | but after seeing this its more readable |
| 07:50 | clgv | kras: the children function is only called on data the returned true for branch? |
| 07:51 | clgv | ,(coll? false) |
| 07:51 | clojurebot | false |
| 07:52 | clgv | ;) |
| 07:52 | kras | clgv: yep I realized it and modified it above |
| 08:21 | wunki | I'm doing something wrong with destructuring an Exception with slingshot. Anyone see what it is? https://gist.github.com/wunki/11252574 |
| 08:31 | wunki | or does slingshot not deal with `ex-info` exception, only with it's own `throw+` |
| 08:38 | pjstadig | wunki: hmm i thought it handled ex-info, too, but i don't see anything particularly wrong with your code |
| 08:39 | pjstadig | wunki: do you have control over the code that throws? could it just use throw+ instead? |
| 08:40 | pjstadig | ah https://github.com/scgilardi/slingshot/issues/35 |
| 08:40 | pjstadig | ^wunki |
| 08:41 | wunki | pjstadig: thanks, great find |
| 08:41 | wunki | pjstadig: will resort to basic catch all exception and destructure it with `ex-data` |
| 08:41 | pjstadig | yeah that should work |
| 08:43 | wunki | pjstadig: result (works!) https://gist.github.com/wunki/11253195 |
| 08:43 | pjstadig | wunki: cool! though it might be a tad safer to catch ExceptionInfo instead of Exception |
| 08:44 | pjstadig | i mean i guess ex-data returns nil for non ExceptionInfo exceptions so maybe that comports with the behavior you want |
| 08:44 | clgv | wunki: well now you can steal the slingshot code to write your own try+ that deals with exceptioninfo in a similar concise way ;) |
| 08:45 | mpenet | https://github.com/fredericksgary/catch-data is nice |
| 08:45 | mpenet | simpler |
| 08:45 | clgv | mpenet: ah well that gfredericks guy did that already ;) |
| 08:46 | mpenet | :) |
| 08:47 | clgv | but why not patch the slingshot library? |
| 08:47 | pjstadig | slingshot predates ex-info, so it may be that a simpler lib based on ex-info is in order |
| 08:48 | pjstadig | hadn't heard of catch-data |
| 08:48 | pjstadig | clgv: a patch could still be sent to slingshot |
| 08:48 | clgv | well you could simply use ex-info when it is available and otherwise slingshot.ExceptionInfo |
| 08:49 | pjstadig | sure, but if you're writing new code why not use ex-info? |
| 08:49 | clgv | did I suggest that? |
| 08:50 | clgv | pjstadig: looks to me as if slingshot is the parent of exceptioninfo looking at the source of both |
| 08:51 | clgv | I wonder why Clojure did not add more support for ex-info in terms of catching ^^ |
| 08:51 | pjstadig | it is now since ex-info is available on clojure 1.3+ (i think?) |
| 08:51 | clgv | 1.4 |
| 08:54 | gfredericks | clgv: github.com/fredericksgary/catch-data |
| 08:55 | mpenet | gfredericks: I beat you to it :) still a fan btw |
| 08:55 | clgv | gfredericks: yes, that was the reason for my comment ;) |
| 08:56 | gfredericks | oh ha |
| 08:56 | gfredericks | apparently I didn't scroll up very far :) |
| 08:56 | clgv | happens to all of use ;) |
| 08:57 | clgv | gfredericks: btw is there an error in the Readme? I'd expected :ex on the right side "{bar :foo, :ex the-exception}" |
| 08:57 | gfredericks | nope! |
| 08:58 | gfredericks | it's analogous to :keys, :as, and other special destructuring things |
| 08:58 | clgv | oh. not so intuitive since there is no vector or something similar to hint that |
| 08:59 | gfredericks | yeah, I'm not sure how I feel about vectors for single bindings |
| 08:59 | ssideris | deciding on the syntax of macros is one of the hardest problems in lisps I think |
| 08:59 | gfredericks | I wonder how many data points we could find on existing macros |
| 08:59 | gfredericks | compojure is +vector |
| 08:59 | gfredericks | well nevermind |
| 09:00 | clgv | gfredericks: no I did not want to suggest adding a vector. it's just the thing that distinguish :keys syntax from usual bindings and it's missing there ;) |
| 09:00 | gfredericks | clgv: ooh you mean _inside_ the map? |
| 09:00 | gfredericks | :as isn't followed by a vector |
| 09:01 | clgv | gfredericks: humm right. why not use :as here? ;) |
| 09:02 | clgv | distinction between content map and exception? |
| 09:02 | gfredericks | right |
| 09:02 | gfredericks | you can still use :as, you just get the map |
| 09:03 | gfredericks | the trouble is that for most use cases you just care about the map, but only making the map available for binding makes it impossible to get the actual exception when you need it |
| 09:03 | gfredericks | hey I could add more destructuring keys for msg, cause, etc :) that'd be...obnoxious? |
| 09:05 | clgv | gfredericks: :cause would be awe some. saves you getting the exception via :ea and cal .getCause on it |
| 09:06 | clgv | maybe :message as well |
| 09:07 | clgv | maybe we should a ticket to Jira to get this into core ;) |
| 09:07 | mpenet | +1 |
| 09:13 | gfredericks | the weakest reason to put something in core is "I don't want to bother getting it from a library" |
| 09:13 | gfredericks | and I think that's all that applies here |
| 09:15 | wink | include ALL the batteries</meme> |
| 09:15 | ssideris | what's a good reason to put something in core? |
| 09:16 | wink | if it gets reimplemented on a daily base and is non-composable with a low number of builtins, imo |
| 09:17 | ssideris | in that case, I find it weird that we don't have a map-keys and a map-vals in core |
| 09:20 | stuartsierra | ssideris: I've brought it up, along with other stuff from the old contrib library map-utils. |
| 09:21 | ssideris | stuartsierra: oh great, thanks :-) |
| 09:21 | stuartsierra | No promises though.:-) |
| 09:22 | ssideris | I understand, and it's good that it's hard to introduce new things into core |
| 09:22 | mpenet | I never had the need for these personnaly, when it's a comp+2args away... same goes for filter+first, I think it got rejected a few times as well |
| 09:22 | mpenet | catch-data is a bit more subtile imho |
| 09:23 | ssideris | mpenet: so how do you implement "map-keys"? |
| 09:23 | stuartsierra | Yeah, I loop over maps with reduce-kv. The one I'm more interested in is deep-merge. |
| 09:24 | mpenet | ssideris: if you mean something that preserves the map type reduce-kw, if proper map (comp map keys). in anyway it's stuff that maybe is not worth growing core (which is quite huge already) |
| 09:25 | mpenet | reduce-kv* |
| 09:25 | mpenet | I guess spliting core in many namespaces couldn't hurt one day... hopefully |
| 09:28 | ssideris | sorry for being slow, could you give me a quick example of how to use reduce-kv for transforming the keys of a map? |
| 09:29 | Bronsa | ssideris: (reduce-kv (fn [m k v] (assoc m (f k) v)) {} the-map) |
| 09:29 | mpenet | ,(reduce-kv (fn [m k v] (assoc m (str k) v)) {} {:a 1 :b 2}) |
| 09:29 | clojurebot | {":a" 1, ":b" 2} |
| 09:29 | stuartsierra | ,(reduce-kv (fn [m k v] (assoc m (str k) v)) {} {:a 1 :b 2}) |
| 09:29 | clojurebot | {":a" 1, ":b" 2} |
| 09:29 | stuartsierra | mpenet: Ha! We wrote the same example. |
| 09:29 | ssideris | thanks a lot! |
| 09:29 | mpenet | :) |
| 09:29 | hyPiRion | great minds think alike |
| 09:30 | stuartsierra | And so do we. |
| 09:30 | mpenet | we should make a wish now I guess |
| 09:33 | kras | is tree-seq overkill for 4clojure #95 |
| 09:33 | kras | http://pastebin.com/mdEGU3tQ |
| 09:33 | kras | checking for binary-tree? |
| 09:57 | clgv | kree: yeah |
| 09:58 | clgv | kree: a recursive function suffices |
| 10:19 | zeeshanlakhani | reiddraper: around for a quick test.check q? |
| 10:19 | zeeshanlakhani | or anyone really, working w/ test.check |
| 10:20 | hyPiRion | zeeshanlakhani: go ahead |
| 10:21 | zeeshanlakhani | what would be the best approach compose two separate generators of gen/elements |
| 10:21 | zeeshanlakhani | being the same type of data |
| 10:21 | zeeshanlakhani | was trying to use gen/bind to make a new gen of the combined elements |
| 10:22 | hyPiRion | zeeshanlakhani: (gen/one-of [first-gen second-gen]) would create a new generator which uses the first gen 50% of the time, second gen 50% of the time |
| 10:23 | zeeshanlakhani | ah, right, duh on my part |
| 10:23 | hyPiRion | you could also use gen/frequency if you want to scew the probabilities |
| 10:23 | zeeshanlakhani | one-of right on, derp, thanks hyPiRion |
| 10:23 | hyPiRion | np |
| 10:23 | zeeshanlakhani | yeah, i was about to go that route, but one-of should suffice |
| 10:26 | sandbags | I'm trying to use CLJX at the function level, I assumed the annotation worked at the s-exp level (like #_) but my .clj file ends up with the #+cljs (defn ...) in it, do I have this wrong somehow? The docs are a bit vague on how #+xxx operates |
| 10:28 | sandbags | for ref, this is what I have https://gist.github.com/mmower/a43b150391d74f5af421 |
| 10:29 | sandbags | i'd expect only one of the functions to appear in the resulting .clj/.cljs files |
| 10:31 | sandbags | ack... unbalanced parens |
| 10:31 | sandbags | works fine |
| 10:39 | dabbelingincloju | hello, i have a simple question I want to write a function which gives me the most frequent strings out of a given string |
| 10:40 | cbp | the most frequent substrings? |
| 10:41 | dabbelingincloju | yes |
| 10:42 | dabbelingincloju | this is what I got so far : (defn topten [x] ((map count (map val (group-by identity (clojure.string/split x #"\s+")))))) |
| 10:42 | CookedGryphon | dabbelingincloju: have you seen the function frequencies? |
| 10:43 | cbp | oh separated by spaces |
| 10:43 | cbp | so the most common words? |
| 10:43 | dabbelingincloju | yes exactly |
| 10:43 | cbp | just split them and then use frequencies then |
| 10:43 | xsyn | isn't that exactly frequencies |
| 10:43 | dabbelingincloju | ha |
| 10:43 | dabbelingincloju | ok |
| 10:46 | ashish | hello is there is any method to read file without given relative path |
| 10:47 | CookedGryphon | ashish: ... you'll have to be more specific, what path *do* you have? |
| 10:51 | gwz | hey does clojure allow unrestricted mutation |
| 10:52 | hyPiRion | gwz: as unrestricted as you can be in Java, but it's pretty clumsy to do so in Clojure. |
| 10:53 | hyPiRion | It's easier to be immutable by design |
| 11:08 | dabbelingincloju | found a nice one |
| 11:08 | dabbelingincloju | (defn map-count [amap key] (assoc amap key (inc (get amap key 0)))) |
| 11:11 | devn | ,(defn foo-agent [x] (agent (-> 1 inc inc))) |
| 11:11 | clojurebot | #'sandbox/foo-agent |
| 11:13 | luxbock | is there a better way to do this: (fn one-two-or-three [x] (some #{:one :two :three} [x]))? |
| 11:13 | devn | ,(foo-agent 'whatever) |
| 11:13 | clojurebot | #<Agent@1ec9818: 3> |
| 11:14 | devn | ,(#{:one :two :three} [:x :one :y :z]) |
| 11:14 | clojurebot | nil |
| 11:14 | devn | derp |
| 11:14 | luxbock | I'm looking to test just one variable |
| 11:14 | devn | short answer, no |
| 11:14 | devn | what you're doing looks good |
| 11:14 | luxbock | k, thanks |
| 11:22 | mzarella | Has anyone here played with promises within node.js? Has your code become unruly? If not, how did you get around it! |
| 11:26 | arrdem | mzarella: wrong chan? |
| 11:27 | mzarella | I guess, I'm looking at clojure's away of handling async and it's appealing |
| 11:30 | yedi | wut, what is this datomicscript foolishness |
| 11:30 | gtrak | mzarella: yes |
| 11:31 | yedi | (after reading some) whoa that is sweet |
| 11:34 | arrdem | yedi: lunk? |
| 11:38 | Mandar | arrdem, http://tonsky.me/blog/decomposing-web-app-development/ |
| 11:46 | tolitius | is there a name convention for lein template arguments? just upgraded to lein 2.3.4, and I see it brought this commit along: https://github.com/technomancy/leiningen/commit/c575b7b82b0d0fc8a5de2168f81679aa0f685d8a#diff-d9b21eee7e79dbee2062d1cae55d8a74 which will ignore template arguments that start with ":". before I could do "lein new [template name] [project name] :with-xyz", where ":with-xyz" was treated as an argument, but |
| 11:51 | justin_smith | but... |
| 12:02 | tolitius | did not realize I lost connection in the middle of the sentence… talking about network partitions :) |
| 12:02 | tolitius | so here it is in full: |
| 12:02 | tolitius | is there a name convention for lein template arguments? just upgraded to lein 2.3.4, and I see it brought this commit along: https://github.com/technomancy/leiningen/commit/c575b7b82b0d0fc8a5de2168f81679aa0f685d8a#diff-d9b21eee7e79dbee2062d1cae55d8a74 which will ignore template arguments that start with ":". before I could do "lein new [template name] [project name] :with-xyz", where ":with-xyz" was treated as an argument, but |
| 12:03 | clgv | haha |
| 12:03 | justin_smith | but... |
| 12:03 | justin_smith | tolitius: I think you need to either link to a pastebin or break it up into smaller sentences |
| 12:04 | tolitius | shoot, ok, let's refactor then |
| 12:04 | tolitius | is there a name convention for lein template arguments? just upgraded to lein 2.3.4, and I see it brought this commit along: https://github.com/technomancy/leiningen/commit/c575b7b82b0d0fc8a5de2168f81679aa0f685d8a#diff-d9b21eee7e79dbee2062d1cae55d8a74 which will ignore template arguments that start with ":". |
| 12:04 | tolitius | before I could do "lein new [template name] [project name] :with-xyz", where ":with-xyz" was treated as an argument, but now neither "--with-xyz" nor ":with-xyz" are good, is there a convention? should it be just: "lein new [template name] [project name] with-xyz"? |
| 12:05 | justin_smith | tolitius: I think templates have free reign on how they interpret the arguments they see |
| 12:05 | justin_smith | that said, you need to provide arguments in such a way that the template ends up seeing them |
| 12:05 | nDuff | While core.async has a few dropping channel types, I'd ideally like to have a channel where I can fail rather than blocking or dropping data when the buffer is full. (Alternately, dropping data and setting a flag would work too). Will I be building this myself, or are any of y'all aware of such a thing existing? |
| 12:06 | justin_smith | templates have the full power of clojure, to interpret your "new" request plus args however they like |
| 12:06 | tolitius | justin_smith: yes, besides when the args start from "--" and now ":" |
| 12:06 | tolitius | hence just wanted to check what else is coming.. |
| 12:07 | tolitius | or there is a convention to not use prefixes at all.. |
| 12:07 | justin_smith | I don't see why you would need prefixes |
| 12:07 | justin_smith | though something like key:value or key=value seems intuitive enough, and easy to parse |
| 12:08 | justin_smith | but I am not a lein dev, they may have more nuanced advice |
| 12:08 | justin_smith | (and they are on this channel) |
| 12:08 | tolitius | well, usually options intuitively are provided with ":" e.g. you-app :with-something |
| 12:09 | justin_smith | I would not have intuited that, personally |
| 12:09 | tolitius | but in this case there is a collision of options for lein new vs. options for a template |
| 12:16 | technomancy | tolitius: we intercept a few things but the intent is that everything the new task doesn't use itself gets passed to the template function. |
| 12:16 | technomancy | tolitius: it sounds like that's not happening in your case? |
| 12:18 | tolitius | technomancy: yea, I think what happens it just treats ":template-arg-1" as a "lein new" options vs. a custom template option |
| 12:19 | technomancy | could you open a bug report? |
| 12:19 | technomancy | that logic is really awful iirc; kind of regretting having lein new take args itself |
| 12:19 | tolitius | and does not pass it along to (defn "template name" …. ) |
| 12:19 | tolitius | technomancy: sure, will do |
| 12:40 | yedi_ | in secretary, is there a way to trigger the history on some state changes / routes, but not on others? |
| 12:47 | coventry` | nDuff: I don't know of such a thing, but custom buffers aren't too mysterious. Check out async/impl/buffers.clj |
| 13:08 | dnolen_ | big changes landed in Om 0.6.1, please test https://groups.google.com/forum/#!topic/clojurescript/Yhysh2HDb_w |
| 13:15 | seangrove | dnolen_: Cool stuff, thanks |
| 13:34 | danneu | I'm writing a toy cryptocoin miner that connects to a mining pool, listens for the workload, and starts a miner in its own thread. `(start-miner! workload)`. I need to be able to halt the miner when, say, the pool tells me to crunch a new workload. And spin a new miner up with the new workload. |
| 13:35 | danneu | core.async with a control/poison channel comes to mind but i'm not sure how to listen for poison within a tight loop |
| 13:40 | danneu | of course now it's obvious that i shouldn't be checking this sort of thing in a tight loop and instead maybe process calculation batches and check after every batch... |
| 13:43 | arrdem | danneu: are you just trying to explore the protocol or what? 'cause you're gonna get something hillariously cute like 1KH/s with a Java miner. |
| 13:46 | danneu | arrdem: b-b-but my toy bitcoin implementation needs a toy miner for its toy mining pool |
| 13:47 | arrdem | danneu: http://hugelolcdn.com/i/240652.gif |
| 13:47 | rasmusto | is that a 290? |
| 13:47 | arrdem | rasmusto: I think so |
| 13:47 | arrdem | (dec so) |
| 13:48 | lazybot | ⇒ -8 |
| 13:48 | rasmusto | arrdem: er, I think I meant r9 |
| 13:48 | rasmusto | numbering is so confusing nowadays, it's looped around and intersected across manufacturers :p |
| 13:49 | arrdem | nVidia's isn't too bad, but ATI's is silly |
| 13:49 | arrdem | Intel just uses ungoogleable codenames... |
| 13:49 | rasmusto | hd40000 |
| 13:49 | rasmusto | "dusty tunnel" |
| 13:53 | justin_smith | hardware version numberwang |
| 13:53 | rem7 | I have a pretty simple function that parses a ~250mb json file and returns a count for one of the elements... the problem is that once this function finishes it looks like my java app using 1.5GBs after the function call. https://gist.github.com/rem7/4ada6ff9c57eed997cdc normaly I wouldn't care, but this function is a plugin in a server, and the server is not reporting its using all of this memory, Am I missing something? all I need back form this function is an |
| 13:53 | rem7 | integer, I don't know why its still consuming 1.5GBs after running. |
| 13:53 | dbasch | btw, that git is from https://www.youtube.com/watch?v=000al7ru3ms |
| 13:53 | arrdem | dbasch: hahahahaha |
| 13:54 | dbasch | rem7: you’re reading everything into memory at once |
| 13:54 | arrdem | (ind dbasch) ;; laughing uncontrollably |
| 13:54 | arrdem | (inc dbasch) |
| 13:54 | lazybot | ⇒ 3 |
| 13:55 | dbasch | rem7: also, how do you measure java’s memory usage? for all you know it’s been garbage-collected and not really in use |
| 13:56 | dbasch | rem7: but still, you should do the count lazily |
| 13:56 | rem7 | dbasch: yeah, that's fine, I don't mind if it reads the whole file, I just want it to get it clear after |
| 13:56 | arrdem | rem7: if all you're doing is streaming data and counting one field, you could probably do that with jq and a bash script :P |
| 13:56 | dbasch | rem7: it probably does, you just can’t know from looking at process memory usage |
| 13:56 | arrdem | $google github jq |
| 13:56 | lazybot | [stedolan/jq · GitHub] https://github.com/stedolan/jq |
| 13:57 | justin_smith | often the jvm will have a max mem usage, and starting - it will allocate more as it needs it (up to max) but it won't neccessarily let it go when it is done |
| 13:57 | rem7 | dbasch: the problem is that java is using all those resources, now other services in the box don't have that memory available |
| 13:58 | rem7 | arrdem: simplified version of the problem (there's a lot more going on) :p |
| 13:58 | rem7 | arrdem: but I can replicate my issue with that |
| 13:58 | justin_smith | rem7: also, you can use jvisualvm, which comes with the jdk, to look at what the memory in your jvm is being used for |
| 13:58 | hiredman | rem7: you need to set the max heap on your jvm lower |
| 13:58 | justin_smith | and to track allocation and freeing over time |
| 14:00 | dbasch | rem7: do you have one single json objectin that file, or can you read them one at a time? |
| 14:01 | rem7 | dbasch: how can I read them one at a time? I don't mind doing that… the file is pretty formatted, so one object takes multiple lines |
| 14:01 | dbasch | hiredman: but if he sets the max heap lower, it might blow up |
| 14:01 | hiredman | dbasch: that is another problem |
| 14:01 | shiranaihito | what are the pros and cons of http-kit, aleph (+lamina) and netty? i'm trying to scrape together a "standard platform" for my future web apps, but i'm having a hard time figuring out "the right tools".. i'd like to be prepared for async stuff as well, even though most things will still be synchronous like usual |
| 14:02 | rem7 | setting the max heap lower isn't an option as I do want ~2GB used by java… the server can use all it wants, but the plugin it calls shouldn't hoard all of that memory |
| 14:02 | hiredman | rem7: how have you decided the plugin is using all of it? |
| 14:03 | stuartsierra | rem7: that's going to be really hard to guarantee. The JVM cannot partition or set quotas on its heap. |
| 14:03 | rem7 | the server runs fine without my plugin at around 600MBs |
| 14:03 | rem7 | once I use my plugin it goes up to ~2GBs |
| 14:03 | hiredman | rem7: I suggest googling and reading up and determining jvm memory usage |
| 14:03 | rem7 | have to run a new instance, more pricy :p |
| 14:03 | dbasch | rem7: what does your json look like? can you refhreap a sample? |
| 14:03 | danneu | shiranaihito: i use jetty and drop in core.async if i need async stuff. it's straight forward. i use aleph/lamina for more complex things like, say, running a tcp-server/client. |
| 14:04 | hiredman | rem7: the jvm is just not returning the memory to the os |
| 14:04 | shiranaihito | danneu: are you handing off web sockets to core.async somehow, or.. ? |
| 14:05 | justin_smith | shiranaihito: aleph is really cool and well designed, http-kit is lightweight and fast. They are the best bets for async http stuff (websockets especially) that I know of |
| 14:05 | danneu | shiranaihito: oh, i see. for websocket work i use aleph. |
| 14:05 | shiranaihito | hmm |
| 14:05 | hiredman | I'd suggest googling/reading up on check the jvm memory usage, tools like top and ps can be very misleading |
| 14:06 | danneu | rem7: GSON looks like the 'SAX parser for json' http://stackoverflow.com/questions/10657725/parser-for-json-in-servlet-just-like-sax-for-xml |
| 14:06 | shiranaihito | justin_smith, danneu .. but which one should i choose? i've seen some nice-looking benchmarks for http-kit, but.. does that stuff matter in the real world? :P |
| 14:06 | danneu | or maybe even parsed-seq would work for you https://github.com/dakrone/cheshire#decoding |
| 14:06 | arrdem | justin_smith: aleph is just a http-kit wrapper AFAIK |
| 14:07 | shiranaihito | arrdem: oh? i thought it was based on netty somehow |
| 14:07 | justin_smith | shiranaihito: I go with the lightest thing / best performing thing that does the job, until feature needs force me to chose otherwise. So I use http-kit and I like it |
| 14:07 | shiranaihito | justin_smith: sounds sensible |
| 14:07 | justin_smith | arrdem: makes sense |
| 14:07 | danneu | shiranaihito: you aren't gonna get bottlenecked on perf. use the abstraction that you like and the one that makes it easy for you. |
| 14:07 | stuartsierra | Aleph wraps Netty, not http-kit. |
| 14:07 | hiredman | rem7: http://www.juhonkoti.net/2010/10/19/crash-course-to-java-jvm-memory-issues-to-sysadmins |
| 14:08 | shiranaihito | danneu: i guess you like aleph's abstraction better then? |
| 14:09 | shiranaihito | hmm.. i wish there was an obvious choice for a web platform, like there's Datomic for a database :P |
| 14:09 | Tekhne | Can anyone recommend some videos to watch which show someone coding something in Clojure and Emacs? I'm trying to get a sense of people's workflow so that I can go read up on the components of that workflow. |
| 14:10 | justin_smith | shiranaihito: clojure hates "platforms" and "frameworks" generally - people like to compose small things that do one job |
| 14:10 | Tekhne | (I just finished my first Clojure book and I'm now trying to learn Emacs while I go through the www.4clojure.com exercises) |
| 14:10 | justin_smith | shiranaihito: unless I misunderstand what you mean by platform |
| 14:10 | technomancy | Tekhne: learning Emacs while learning Clojure isn't really a good idea |
| 14:10 | shiranaihito | justin_smith: well, maybe that was a bad choice of words.. i'm not exactly hankering for some bloated enterprisey J2EE monstrosity either :P |
| 14:11 | rasmusto | Tekhne: try lighttable if you're just getting started with 4clojure |
| 14:11 | technomancy | I recommend coming back to Emacs after you're comfortable with Clojure tooling |
| 14:11 | Tekhne | technomancy: yea, I realize it can be frustrating, but I'm okay with that. |
| 14:11 | Tekhne | rasmusto: I tried lighttable, but I didn't like it. I may revisit that later when more development has been completed. |
| 14:12 | danneu | shiranaihito: i already have experience with the libs that aleph is composed of (lamina, gloss) and it's just a higher level of abstraction. core.async is low level in comparison. never tried http-kit. you can't really lose by giving them all a shot. |
| 14:12 | shiranaihito | Tekhne: sorry to not answer your actual question, but i'd recommend looking into IntelliJ IDEA + Cursive Clojure.. IDEA is just hands down the best IDE out there, and it's great for editing just about anything you'd need in a web app |
| 14:12 | rasmusto | Tekhne: did you not like the clojure integration? or the editor itself? |
| 14:12 | technomancy | Tekhne: I don't know of any videos, bit the clojure-doc.org tutorial on emacs is pretty good |
| 14:12 | Tekhne | shiranaihito: No worries. Thanks for the suggestion. I will definitely be checking out IntelliJ later, but for now I really want to learn Emacs. |
| 14:13 | technomancy | http://clojure-doc.org/articles/tutorials/emacs.html |
| 14:13 | rasmusto | Tekhne: and learn emacs by all means, a basic setup isn't too bad. I just had trouble doing vim->emacs personally, hence my suggestion |
| 14:13 | Tekhne | rasmusto: the editor itself, but I expect that I'll like it more as more features are built, and as it becomes more stable. |
| 14:13 | technomancy | tl;dr: use better-defaults, cider, paredit, and magit |
| 14:14 | shiranaihito | Tekhne: i'd say that whenever there's a JetBrains IDE for the language you're working with, it's the best tool for the job |
| 14:14 | dbasch | the one thing that I wish existed is a friend plug-in for persistent user management |
| 14:14 | danneu | Tekhne: i think the most important workflow to get setup in Emacs is to use Cider so you can eval code within the editor itself (and use Paredit-mode). `C-c C-k` evals entire buffer, `C-c C-e` evals previous sexpr. i don't use a whole lot else |
| 14:14 | dbasch | e.g create-user, set-password, stuff like that |
| 14:15 | Tekhne | technomancy: I installed someone's variation on the starter kit, and so far so good. |
| 14:15 | arrdem | eeeeeeh starter kits... |
| 14:15 | arrdem | I give you a week before you throw it out, take it appart, steal what you like and roll your own config |
| 14:15 | technomancy | aw crap; the tutorial still recommends the starter xit |
| 14:16 | technomancy | kit |
| 14:16 | rasmusto | Tekhne: /minimal/ starter kits are fine |
| 14:16 | Tekhne | I guess what I'm really looking for now is how to people do interactive development effectively, especially things like debugging, reloading changes, etc. |
| 14:16 | rasmusto | Tekhne: clojure.tools.namespace.repl/refresh is a good thing for reloading |
| 14:16 | Tekhne | shiranaihito: yea, they have good stuff. |
| 14:17 | rasmusto | Tekhne: https://github.com/clojure/tools.trace is useful in certain situations |
| 14:17 | Tekhne | danneu: Yea, cool. I'm using Cider and Paredit now. I like it...just trying to get better. |
| 14:17 | Tekhne | I found a cool debugging macro that someone was using. That's been helpful for printing out the results of intermediate forms. |
| 14:18 | shiranaihito | Tekhne: they really do.. and it's extremely powerful straight out of the box, as opposed to emacs or vim where you have to scrape together various plugins and (afaik) still won't reach the same level of productivity as with a JB IDE |
| 14:18 | justin_smith | Tekhne: small pure functions that are easy to verify because they don't care about state, plus the repl for interactive exploration |
| 14:18 | justin_smith | bonus if the repl is in your browser for easy copy / paste to the code |
| 14:18 | technomancy | Tekhne: tools.trace is pretty rad |
| 14:18 | danneu | Tekhne: my approach for fast/exporatory coding in Emacs is to put (func-im-working-on "some sample input") at the bottom of the file and spam `C-c C-k` as I work on `func-im-workin-on`'s implementation. Cider's buffer eval returns the last expression in the file. |
| 14:18 | Tekhne | rasmusto, technomancy: cool, i'll check out trace. |
| 14:18 | arrdem | Tekhne: tracer is pretty groovy too if you don't mind huge prints. |
| 14:18 | Tekhne | danneu: oh, cool. that's a good idea. |
| 14:19 | danneu | Another approach is to drop a bunch of (assert (= ... (func-im-working-on ...)) at the bottom of the file as I spam C-c C-k to get instead assertion feedback if i break something. and i can eventually move the assertions into a test file. |
| 14:19 | arrdem | one window with "watch 'lein clean;lein test'", one window of Emacs, and a pre-commit hook that ensures all test pass :P, debugging done at a Cider repl. |
| 14:19 | Tekhne | So, one thing about clojure that was confusing me with interactive coding was that I had it in my head that vars, etc. couldn't be redefined, so I didn't understand how I could reload things in the repl. |
| 14:20 | Tekhne | I think I get it now, though, but I'm not sure all the things can be "reloaded" or not. |
| 14:20 | technomancy | Tekhne: redefinition is exactly the whole point of vars =) |
| 14:20 | technomancy | only during development though |
| 14:20 | Tekhne | technomancy: yea, well, I'm still groking Clojure. I think I thought the immutability thing went further than it does. |
| 14:20 | technomancy | arrdem: dude |
| 14:21 | arrdem | technomancy: wat do |
| 14:21 | technomancy | lein clean =( |
| 14:21 | technomancy | if you have to clean, at least do it in the same jvm |
| 14:21 | technomancy | lein do clean, test |
| 14:21 | arrdem | technomancy: noted <3 |
| 14:21 | technomancy | but you shouldn't need to clean, because you shouldn't ever do AOT during development |
| 14:22 | Tekhne | danneu: I like your suggestion about spamming `C-c C-k` on a temp fn at the bottom, though. That's exactly the kind of tip I'm looking for and was hoping to spot in videos of people coding. |
| 14:22 | technomancy | [1] - unfortunate gen-class requirements excepted |
| 14:23 | danneu | Tekhne: bindings are mutable, but the values they hold are generally immutable |
| 14:23 | nDuff | I'm trying to start a HTTP server to share some application state. Using http-kit, I find that (defn run-server [state-atom] (binding [*serve-this-atom* state-atom] (httpkit/run-server (site my-routes))) doesn't quite work -- it looks like the bindings aren't propagated to the thread running the server. Is there a better-practices approach? |
| 14:23 | Tekhne | danneu: Yea :-), I think I get that now, after coding for a bit. |
| 14:24 | shiranaihito | btw, has some kind of standard emerged for working with ring and web sockets? .. or is that a confused question? :p |
| 14:25 | justin_smith | nDuff: dynamic bindings don't play well with things that use multiple threads, never have |
| 14:25 | justin_smith | at least in clojure |
| 14:25 | danneu | Tekhne: what tends you bite you though is that the state of your repl gets dirty over time. for example, you might define function `foo` and later delete it. but `foo` is still defined in the namespace and you don't notice that you still have calls to `foo` in your code. and you don't get "foo is not defined" until you restart your repl. |
| 14:25 | nDuff | shiranaihito, ...I'd consider (or, rather, I'm actively using) http-kit rather than ring's Jetty adapter. |
| 14:25 | Tekhne | rasmusto: (doc clojure.tools.namespace.repl/refresh) doesn't seem to do the trick and Googling doesn't seem to be too helpful. |
| 14:26 | Tekhne | rasmusto: n/m |
| 14:26 | Tekhne | I found something. |
| 14:26 | nDuff | justin_smith, indeed, though there are often workarounds -- bound-fn and kin. Just not sure whether any of them are particularly usable with ring. |
| 14:26 | justin_smith | nDuff: it could be argued that one of http-kit's benefits is exposing code that doesn't quite behave right under some async conditions :) |
| 14:26 | shiranaihito | nDuff: and it Just Works etc? |
| 14:26 | shiranaihito | :P |
| 14:26 | TravisD | Does the clojure compiler inline simple functions? |
| 14:26 | shiranaihito | justin_smith: what are you referring to? |
| 14:27 | justin_smith | shiranaihito: binding / dynamic vars don't behave nicely with things that spawn multiple threads |
| 14:27 | arrdem | TravisD: the existing Clojure compiler does _nothing_ |
| 14:27 | arrdem | TravisD: the JVM may play tricks, but the Clojure compiler will not. |
| 14:27 | justin_smith | shiranaihito: that is the source of his problem |
| 14:27 | TravisD | arrdem: Ah, cool. How clever is the JVM? |
| 14:28 | justin_smith | TravisD: it is kind of legendary in its field actually |
| 14:28 | arrdem | TravisD: the HotSpot JIT is pretty friggin cleaver, but it's limited in some respects by lack of static type information and static properties of the code it's working on. |
| 14:28 | nDuff | TravisD, quite clever, though it typically does expensive operations only after code has been running for a while, so you see performance improve over the course of runtime. |
| 14:28 | Tekhne | rasmusto, technomancy: tools.trace does look very cool. |
| 14:29 | arrdem | justin_smith: however there are other JITs that are more specialized, much more aggressive and arguably higher performance :P |
| 14:29 | Tekhne | danneu: so, how do you go about cleaning up the repl? Do you just restart it occasionally? |
| 14:29 | TravisD | That's also pretty cool - is it possible to make the JVM more eager to optimize? |
| 14:29 | justin_smith | arrdem: sure - I didn't claim it was the best, but it is definitely well known for performing well, and considered a reference point |
| 14:29 | arrdem | TravisD: there are JVM options for tuning the JIT, but I can't claim any familiarity with them. |
| 14:30 | danneu | Tekhne: it usually isn't a problem. and when i mess up, i just `M-x cider-restart`. i don't need to do it often enough for it to be painful. |
| 14:30 | TravisD | Hehe, thanks. I'll read up on it if it becomes important :) |
| 14:30 | rasmusto | Tekhne: c.t.n.r/refresh will clean up old vars |
| 14:30 | martinklepsch | I want to convert something like this [:name [:first-name :last-name]] to this [[:name :first-name] [:name :last-name]] — any ideomatic/simple ways to do this? |
| 14:30 | amalloy | TravisD: the jvm jit is pretty sensible as-is. attempts to tinker with it generally end in ruins |
| 14:30 | Tekhne | danneu: ah, okay. |
| 14:30 | Tekhne | rasmusto: oh, that's good. |
| 14:30 | arrdem | TravisD: I doubt that tweaking the JIT with command line options will ever save you if you get performance woes. |
| 14:30 | justin_smith | TravisD: turning on server mode helps (to be done in production of course) - lein puts things in a different mode that is optimized for startup rather than throughput during dev time, by default |
| 14:30 | danneu | But i'm really good at hanging the repl when i use unbuffered core.async channels and borked `go` loops... :( |
| 14:30 | arrdem | TravisD: what amalloy said :P |
| 14:31 | TravisD | amalloy: Ah, too bad. I'm thinking that almost all of my code will only run for a short time. So, if the JIT only optimizes code after some time, then maybe I wouldn't get any benefit at all |
| 14:31 | amalloy | ,(let [[first more] [:name [:first-name :last-name]]] (for [x more] [first x])) |
| 14:31 | clojurebot | ([:name :first-name] [:name :last-name]) |
| 14:31 | amalloy | TravisD: but that's just what you want |
| 14:31 | justin_smith | TravisD: if it only runs for a short time, and actually completes on time, what needs optimizing? |
| 14:31 | TravisD | hm, good point |
| 14:31 | amalloy | if your code only runs a few times, then spending cycles figuring out how to optimize it is a waste |
| 14:32 | justin_smith | TravisD: timing sensitive stuff? |
| 14:33 | TravisD | Ah, no, some experiments. I guess if I leave the jvm running things that can be optimized will be optimized |
| 14:33 | TravisD | over multiple runs of the experiment |
| 14:33 | TravisD | and timing is not so essential |
| 14:33 | TravisD | anyways, I'm running a bit late :( I will talk to you later! |
| 14:34 | justin_smith | timing not essential, running late... the irony |
| 14:34 | amalloy | (inc justin_smith) |
| 14:34 | lazybot | ⇒ 35 |
| 14:34 | stuartsierra | In -server mode the JVM usually needs at least 10,000 iterations before it starts optimizing. |
| 14:36 | sritchie | any core.async users in the room? |
| 14:36 | sritchie | I want to go from a sequence of channels to a channel with a single sequence of results |
| 14:36 | sritchie | (->> channel-seq (a/merge) (a/into [])) seems to be the way |
| 14:36 | sritchie | is there a function shortcut for this? |
| 14:37 | alejandro | sritchie: I've used (async/mapcat< identity ch) |
| 14:37 | alejandro | actually, I don't think that necessarily does what you want |
| 14:38 | sritchie | yeah, it doesn't stop |
| 14:39 | alejandro | sritchie: doesn't a/merge do what you need? why the into? |
| 14:39 | sritchie | a/merge returns a channel with all the items, but not as its own collection |
| 14:39 | sritchie | I end up blocking with a/<!! to return the sequence to the outer world |
| 14:39 | sritchie | still integrating this code with some old non async code |
| 14:43 | TravisD | justin_smith: :D haha |
| 15:03 | yedi | looks like a datomicscript got something akin to a cnd from cognitect |
| 15:04 | yedi | the .clj version is gone too =/ |
| 15:04 | arrdem | T_T |
| 15:04 | yedi | maybe cognitect is working on a cljs peer or something... |
| 15:04 | alejandro | yedi: looks like it got renamed? |
| 15:05 | alejandro | https://twitter.com/nikitonsky/status/459403600775876608 |
| 15:05 | yedi | yea i'm assuming the author got contacted about it (i'm sure it wasn't in a malicious manner) |
| 15:05 | yedi | ah yea, though the .clj version disappeared as well |
| 15:06 | oinksoft | where is edn/write? |
| 15:06 | oinksoft | or edn/write-string |
| 15:06 | yedi | https://github.com/tonsky/datascript/commit/5beb53d7db03bd274b109c823b182214151b5058#diff-d02cef01feeeb3bc679ca8cf787cf538L1 |
| 15:06 | oinksoft | is there a function to encode a structure as edn? |
| 15:06 | amalloy | &(doc pr-str) |
| 15:06 | lazybot | ⇒ "([& xs]); pr to a string, returning it" |
| 15:07 | coventry` | dnolen_: Can you say a bit more about how you thread child-specific data through to the child without polluting the parent's view? |
| 15:07 | oinksoft | thanks amalloy |
| 15:08 | coventry` | How you intend to, that is. :-) |
| 15:08 | bodie_ | having a hard time understanding why this "let" isn't working |
| 15:08 | bodie_ | http://cljbin.com/paste/53596009e4b0e996c66f0533 |
| 15:08 | bodie_ | I keep getting CompilerException java.lang.RuntimeException: Unable to resolve symbol: debug? in this context |
| 15:08 | amalloy | bodie_: wrong syntax for multi-arity functions |
| 15:08 | amalloy | (defn f ([] ...) ([x] ...)) |
| 15:09 | bodie_ | ahhhh |
| 15:09 | bodie_ | herp derp, thanks :) |
| 15:11 | amalloy | but also, (let [x y] (foo)) doesn't do anything, if foo doesn't refer to x in that lexical scope |
| 15:11 | bodie_ | just noticed that |
| 15:11 | bodie_ | I have a global (def debug-mode? false) |
| 15:12 | dbasch | bodie_: that should be a single arity function really |
| 15:12 | martinklepsch | any hints how to transform something {:name [:first-name :last-name]} to [[:name :first-name] [:name :last-name]]? |
| 15:12 | martinklepsch | bit stuck currently, could be the two beers earlier this evening... |
| 15:12 | bodie_ | hrm |
| 15:20 | aaron__ | hi |
| 15:21 | stuartsierra | martinklepsch: ,(reduce-kv (fn [out k v] (into out (map (fn [x] [k x]) v))) [] {:name [:first-name :last-name]}) |
| 15:21 | fu86 | What is the preferred way to run "tasks" from a leiningen driven clojure project? |
| 15:22 | fu86 | Like a Rake task in ruby |
| 15:26 | stuartsierra | fu86: Easiest way is just to invoke them from the REPL. You can also use `lein run -m` |
| 15:30 | fu86 | stuartsierra: lein run -m is great, thanks! |
| 15:30 | dnolen_ | coventry`: any component will be able to get to the app-state via a special-key in :shared, like :app-state. This will be a new "subroot". If anyone transacts on this data it will only trigger subtree updating. this is all that's need to break the explicit connection between parent data and child data. |
| 15:31 | stuartsierra | fu86: you're welcome! |
| 15:37 | coventry` | I imagine dereferencing an atom should be pretty fast. You could pass an atom into start-miner! and communicate that way. |
| 15:43 | coventry` | What coin/protocol are you targeting, out of curiosity? |
| 15:43 | bodie_ | dbasch, something more like this? http://cljbin.com/paste/53596883e4b0e996c66f0534 |
| 15:44 | bodie_ | or is there a simpler approach |
| 15:53 | cbp | I'd usually make the options map explicit though optional because if you destructure the keys from the arguments it becomes a pain when you need to pass down those keys down to other functions |
| 15:55 | bodie_ | cbp, I'm not gonna lie, I'm clawing my way through bad stackoverflow advice |
| 15:56 | bodie_ | the syntax for that would be more like [foo :or {:debug true}] right? |
| 15:56 | dbasch | bodie_: why is this not enough? (defn basic-query [& debug] (client/get (digitalocean-paths :droplets) {:throw-exceptions (not (or debug debug-mode?))})) |
| 15:57 | bodie_ | because I'm still learning how to deal with option args correctly. heh |
| 15:58 | cbp | bodie_: no i dont think that will compile |
| 15:58 | bodie_ | optional* |
| 15:59 | cbp | bodie_: [& [{:keys [debug] :as opts}]] |
| 15:59 | cbp | or something of the sort |
| 16:00 | bodie_ | I'm trying to imitate the syntax clj-http gives me with a map of optional named arguments |
| 16:00 | coventry` | I would be pretty excited to learn of a more extensible miner than the reference implementation, no matter how slow. |
| 16:04 | coventry` | I guess a few have popped up since I last looked, though. |
| 16:06 | devn | anyone know if there's a way to reformat something like '({:a 1 ...} {:b 2 ...} ...} like how clojure.pprint would print it? |
| 16:06 | devn | for emacs? |
| 16:07 | gtrak | devn: might be a good idea for a cider middleware |
| 16:09 | gtrak | I end up reformatting edn manually a lot.. would be nice to select it and M-x cider-prettify-sexp or something |
| 16:10 | arrdem | I'd throw money at a cider pprint middleware... |
| 16:13 | gtrak | https://github.com/clojure-emacs/cider/issues/535 |
| 16:13 | arrdem | dunno if it belongs in cider or in an nrepl middleware... |
| 16:14 | Guest72910 | ~anyone |
| 16:14 | clojurebot | anyone is anybody |
| 16:14 | arrdem | and there's always technomancy's proposal for nrepl support for images. |
| 16:14 | gtrak | arrdem: the cider bit would be just mangling the buffer |
| 16:14 | technomancy | I wrote all this like five months ago; you guys are slackers |
| 16:14 | gtrak | the pprint op could be used for other stuff |
| 16:14 | arrdem | technomancy: sorry I don't have the time to keep up with you, Bronsa, dnolen et all... |
| 16:15 | technomancy | what I really want to see is a middleware that renders stack traces as jpegs with a bunch of compression artifacts |
| 16:15 | gtrak | technomancy: you wrote it, or you *wrote* it :-) |
| 16:15 | technomancy | just to show those whiners who say coljure stack traces couldn't possibly get any worse |
| 16:15 | arrdem | (inc technomancy) |
| 16:15 | lazybot | ⇒ 106 |
| 16:16 | gtrak | the new stacktrace navigation is pretty nice |
| 16:16 | justin_smith | stack trace rickroll mode? |
| 16:16 | technomancy | is that really too much to ask |
| 16:16 | gtrak | never gonna deref null.. |
| 16:16 | technomancy | lawl |
| 16:16 | arrdem | one day karma in here is gonna be measured in µtechnomancy |
| 16:16 | amalloy | martinklepsch: it looks like you missed my earlier answer, (let [[first more] [:name [:first-name :last-name]]] (for [x more] [first x])) |
| 16:17 | martinklepsch | amalloy, oh yeah, indeed |
| 16:17 | gtrak | technomancy: I think we're ready to rip out existing eval code. I'd like to use it as a chance to try out nrepl-discover. |
| 16:18 | technomancy | sweet |
| 16:19 | guns | ,(let [{:keys [l]} '(:l "list") {:keys [v]} [:v "vector"]] [l v]) |
| 16:19 | clojurebot | ["list" nil] |
| 16:20 | guns | How long has this been true? |
| 16:20 | guns | Forgot to (apply hash-map opts), but discovered the destructuring still worked! |
| 16:20 | gtrak | it doesn't work, you get nil |
| 16:21 | justin_smith | that's kind of weird, unless I am reading it wrong |
| 16:21 | gtrak | ,(let [{:keys [l]} '(:l "list") {v 1} [:v "vector"]] [l v]) |
| 16:21 | clojurebot | ["list" "vector"] |
| 16:21 | gtrak | guns: ^ |
| 16:21 | guns | gtrak: so destructuring '(:l "list") is expected? |
| 16:21 | gtrak | ah! that is weird. |
| 16:22 | guns | smells like a convenience hack |
| 16:22 | gtrak | guns: I think a long time back there was a change added to make varargs hash-map destructuring work. |
| 16:22 | gtrak | like 1.2ish |
| 16:22 | gtrak | this is that |
| 16:22 | guns | gtrak: so it's dependable? |
| 16:22 | gtrak | yea |
| 16:22 | gtrak | but ugly |
| 16:23 | guns | gotch |
| 16:23 | guns | a |
| 16:23 | gtrak | it makes (fn [& {:keys [a b c]}]) work |
| 16:24 | guns | I see |
| 16:24 | justin_smith | ,(let [{x :x y :y z :z} '(:x 0 :y 1 :z 42)] [x y z]) |
| 16:24 | clojurebot | [0 1 42] |
| 16:24 | gtrak | ,((fn [& {:keys [a b]}] [a b]) :a 1 :b 2) |
| 16:24 | clojurebot | [1 2] |
| 16:25 | gtrak | i prefer to just use maps |
| 16:25 | gtrak | since you can merge n stuff |
| 16:25 | justin_smith | yeah, I think all the experts agree that cl style kwargs are a bad idea and opts maps are better |
| 16:26 | gtrak | justin_smith: all the experts except clojure.core :-) |
| 16:26 | amalloy | maps are so much better than keyword args. the two-character savings is dwarfed by the inconvenience of doing anything but calling the function with literal args |
| 16:26 | gtrak | justin_smith: http://dev.clojure.org/display/community/Library+Coding+Standards |
| 16:27 | arrdem | gtrak: that'd be a fine example if it was (release-sharks {:laser-beams true} 2) tho... |
| 16:27 | gtrak | yea |
| 16:27 | arrdem | wonder if I can edit that... |
| 16:28 | gtrak | apply-kw sucks |
| 16:28 | gtrak | too much mental overhead |
| 16:28 | coventry` | rem7: If that snippet is representative, you have one humungous json object. |
| 16:28 | gtrak | just use maps |
| 16:28 | arrdem | gtrak: refresh |
| 16:28 | gtrak | refresh? |
| 16:28 | justin_smith | gtrak: with how vehemently I have seen people object to kwargs, I am surprised to see clojure.core recommend them |
| 16:29 | gtrak | https://groups.google.com/forum/#!topic/clojure-dev/9ctJC-LXNps/discussion |
| 16:29 | hiredman | *shrug* |
| 16:30 | gtrak | haven't heard people complain about it in quite a while |
| 16:30 | gtrak | it was all the rage in 2012 |
| 16:30 | justin_smith | arrdem: haha |
| 16:30 | justin_smith | gtrak: I think it comes up whenever kwargs are seen, we just see fewer examples of it now |
| 16:30 | arrdem | edited again for formatting |
| 16:32 | gtrak | arrdem: better than which? |
| 16:32 | gtrak | maybe 'not as bad' |
| 16:33 | justin_smith | http://rosettacode.org/wiki/Named_parameters#Clojure I think this could at least be worded more clearly |
| 16:34 | arrdem | http://dev.clojure.org/display/community/Library+Coding+Standards comments? |
| 16:34 | arrdem | or just fix it if you've got wiki access :P |
| 16:41 | TravisD | Does anyone know if the clatrix/solve function does 'the right thing' for over and under conditioned systems of equations? I see that it drops down into LAPACK if the constraint matrix is tagged as positive or symmetric |
| 16:49 | melipone | hello! I am writing an application in the browser using compojure, hiccup and jetty. When I write a file, how can I make it available for download on the client? |
| 16:51 | justin_smith | melipone: you can use ring.middleware.resource/wrap-resource |
| 16:51 | justin_smith | melipone: and write the file to a directory wrapped by wrap-resource |
| 16:51 | Frozenlock | melipone: Is the file on your disk, or generated on-the-fly? |
| 16:52 | justin_smith | Frozenlock: well if it isn't on some fs, it isn't a file |
| 16:53 | nil | ~guards |
| 16:53 | clojurebot | SEIZE HIM! |
| 16:53 | Frozenlock | justin_smith: how would you call a csv/zip/pdf generated by the webserver and sent directly to the user? |
| 16:53 | nil | ~coin |
| 16:53 | clojurebot | I don't understand. |
| 16:54 | nil | that makes two of us |
| 16:54 | arrdem | nil: different bot for one... |
| 16:54 | arrdem | lazybot: coin |
| 16:54 | lazybot | arrdem: Tails. |
| 16:54 | arrdem | justin_smith: ^ |
| 16:54 | nil | arrdem: http://www.arrdem.com/i/really.gif |
| 16:55 | arrdem | nil: I'll use my own gifs thank you |
| 16:55 | arrdem | <3 |
| 16:55 | melipone | justin_smith: okay, thanks! |
| 16:56 | melipone | Frozenlock: the file is on my disk |
| 16:56 | nil | arrdem: wish there was a listing in /i tho |
| 16:56 | karls | wait |
| 16:56 | nil | arrdem: plz 2 make it |
| 16:57 | karls | dammit, sorry, wrong window |
| 16:57 | justin_smith | Frozenlock: fair point |
| 16:58 | justin_smith | Frozenlock: it's a byte-stream until saved on disk, is how I would put it (I had to fix our image resizing lib to stop touching the disk for remote artifacts (ie. amazon s3) so I guess I get pedantic about what is or is not a file as far as the server is concerned) |
| 16:59 | Frozenlock | your turn to have a fair point. |
| 16:59 | Frozenlock | But I'll still call it a 'file' :-p |
| 17:00 | justin_smith | well, it's that special kind of 'file' that can |
| 17:00 | justin_smith | 't be opened with java.io.File |
| 17:02 | Frozenlock | Other than that, no problem! |
| 17:03 | justin_smith | Frozenlock: for a while I have had this dream of directly synthesizing an mp3 or mp4 stream |
| 17:03 | Frozenlock | justin_smith: what are you waiting for? |
| 17:03 | justin_smith | no original data that gets encoded, just an algorithm demo-scene style that directly generates data to be decoded |
| 17:03 | cbp | bodie_: sorry I went out to eat. What was your question? |
| 17:04 | justin_smith | Frozenlock: the time and motivation to figure out a weird binary stream format :) it will come soon |
| 17:04 | justin_smith | speaking of files that are not files |
| 17:04 | Frozenlock | I'm sure the guys at overtone would love that |
| 17:04 | Frozenlock | pfff, time, who needs that! |
| 17:05 | justin_smith | people with day jobs and girlfriends and hobbies :P |
| 17:07 | llasram` | justin_smith: I'm pretty sure you were just describing someone's hobby. And maybe their day job. Probably not their girlfriend, though. |
| 17:09 | cbp | $mail bodie_ I went out to eat, msg me if you need help. |
| 17:09 | lazybot | Message saved. |
| 17:09 | arrdem | so... should this not work? https://github.com/arrdem/meajure/blob/master/src/meajure.clj#L108 |
| 17:09 | justin_smith | llasram: heh |
| 17:09 | arrdem | it seems like I'm hitting this as a problem.. ##(class (num 3)) |
| 17:09 | lazybot | ⇒ java.lang.Long |
| 17:10 | arrdem | so I guess I need a (doseq [] (defmethod..))? |
| 17:12 | justin_smith | arrdem: what are you expecting num to do? http://docs.oracle.com/javase/7/docs/api/java/lang/Number.html |
| 17:13 | justin_smith | it's an abstract class, Long is one of its concrete subclasses |
| 17:13 | justin_smith | or am I misunderstanding? |
| 17:13 | arrdem | justin_smith: right. I'm trying to go through this... https://github.com/clojure/algo.generic/blob/master/src/main/clojure/clojure/algo/generic.clj#L31 |
| 17:14 | arrdem | justin_smith: https://github.com/clojure/algo.generic/blob/master/src/main/clojure/clojure/algo/generic/math_functions.clj#L46 |
| 17:15 | arrdem | justin_smith: https://github.com/clojure/algo.generic/blob/master/src/main/clojure/clojure/algo/generic/arithmetic.clj#L190 |
| 17:16 | justin_smith | arrdem: so if I understand correctly, that defmethod means any unspecialized subclass of java.lang.Number gets that same method applied |
| 17:16 | arrdem | justin_smith: right. that's what I expected too. |
| 17:16 | oinksoft | how do i write functions that should handle nil case? do they all have to start with (if nily-thing) or (when nily-thing) ? |
| 17:16 | oinksoft | in erlang you address this sometimes w/ f(undefined) -> ... |
| 17:16 | dbasch | oinksoft: it depends on what you want to do for the nil case |
| 17:16 | oinksoft | return nil |
| 17:17 | AeroNotix | (when ..) is a reasonable thing to do |
| 17:17 | oinksoft | it starts to feel like some boilerplate at a point though |
| 17:17 | oinksoft | AeroNotix: it seems like when is for if you have a body of expressions, and if is for a single expr? or am i mistaken? |
| 17:17 | arrdem | justin_smith: this is what I'm seeing. https://www.refheap.com/80043 |
| 17:17 | dbasch | oinksoft: no, when allows you to have more than one because there’s no else |
| 17:17 | dbasch | oinksoft: and returns the last one |
| 17:17 | oinksoft | i understand |
| 17:18 | justin_smith | oinksoft: the right way to use when is controversial |
| 17:18 | oinksoft | i seem to have joined the fray :) |
| 17:18 | justin_smith | oinksoft: for your semantics, use and |
| 17:18 | justin_smith | less controversial, does what you want |
| 17:18 | justin_smith | and makes it clear you are talking about values |
| 17:18 | lemonodor | is there actually controversy over when? or just 1 or 2 people who have different ideas? |
| 17:18 | oinksoft | it just feels like i have if-let/when-let everywhere :( |
| 17:19 | justin_smith | (not lining up side effects) |
| 17:19 | AeroNotix | oinksoft: just like you have case/if everywhere in erlang |
| 17:19 | AeroNotix | or multiple function heads |
| 17:19 | justin_smith | ,(let [thing nil] (and thing (+ thing 42))) |
| 17:19 | clojurebot | nil |
| 17:20 | AeroNotix | ,(if-let [thing nil] (+ thing 42)) |
| 17:20 | clojurebot | nil |
| 17:20 | AeroNotix | shorter, expresses better intent |
| 17:20 | arrdem | justin_smith: looks like it's something funky to do with aot and my library -_- |
| 17:20 | AeroNotix | imho |
| 17:21 | oinksoft | my code is bad because it shold be a reduction |
| 17:21 | justin_smith | AeroNotix: the let was for convenience, assuming something else passed in or bound the value |
| 17:21 | justin_smith | (in the actual case that is) |
| 17:21 | guns | I really like (when-some []); didn't think I would |
| 17:22 | gtrak | what's a compelling example of when-some? |
| 17:22 | tbaldridge | guns: yeah, it's kindof....."winsome" |
| 17:22 | rasmusto | (doc when-some) |
| 17:22 | clojurebot | "([bindings & body]); bindings => binding-form test When test is not nil, evaluates body with binding-form bound to the value of test" |
| 17:22 | justin_smith | arrdem: wait, those two are in the opposite order of the declaration |
| 17:22 | tbaldridge | at least that's what I think of |
| 17:22 | justin_smith | unit / num vs. num / unit |
| 17:22 | guns | :) |
| 17:22 | justin_smith | arrdem: is that your bug? |
| 17:23 | arrdem | justin_smith: that shouldn't matter. |
| 17:23 | guns | gtrak: (when-some [v (<!! channel)] …) |
| 17:23 | tbaldridge | gtrak: core.async was what it was created for, you can get into problems with when-let and core.async |
| 17:23 | gtrak | ah |
| 17:23 | justin_smith | arrdem: oh never mind you had both defined |
| 17:24 | gtrak | I guess if you pass false, I've not had to do that yet. |
| 17:24 | gtrak | or is there more to it? |
| 17:25 | tbaldridge | nope, that's it |
| 17:25 | tbaldridge | and no, I never pass false either, but apparently someone does |
| 17:25 | guns | it can be nice to communicate simple booleans |
| 17:25 | justin_smith | I find a boolean-free-diet helps with that |
| 17:25 | gtrak | seems like it's easier to remember to not pass false than it is to remember to use these :-) |
| 17:26 | tbaldridge | I kindof agree, |
| 17:26 | arrdem | justin_smith: it looks like it was an issue with my deps. the scratch project I was working in used "1.0.0" which was bugged. |
| 17:26 | guns | I've fallen to basically always using when-some over when-let |
| 17:26 | tbaldridge | and even then, all the core.async stuff uses (when (not (nil?)) anyways |
| 17:26 | arrdem | justin_smith: updating to "1.0.1", cleaning and restarting seems to have fixed it. |
| 17:26 | justin_smith | arrdem: oh, glad you found it, because that all looked right to me |
| 17:27 | guns | something vs nothing is fundamentally different than truthiness |
| 17:27 | justin_smith | when has overloading ever *not* caused issues I wonder |
| 17:27 | guns | Dynamic typing just makes clojurists a little lazy on this |
| 17:28 | guns | imho |
| 17:28 | justin_smith | also the "when in doubt return nil" kind of thing |
| 17:30 | gtrak | justin_smith if exceptions were less awkward.. |
| 17:34 | cbp | I wonder what it would take to implement conditions in clojure |
| 17:34 | AeroNotix | cbp: please no |
| 17:34 | AeroNotix | common lisp conditions? |
| 17:34 | cbp | yee |
| 17:34 | AeroNotix | nah |
| 17:34 | cbp | :-( |
| 17:34 | AeroNotix | Just a bad idea which was centred around REPL-programming assuming that the application always had someone sat in-front of it |
| 17:35 | justin_smith | gtrak: http://minimemes.net/wp-content/uploads/2014/04/1398375042716.jpg |
| 17:35 | AeroNotix | You don't want your application to throw up a restart on an AWS instance for example |
| 17:35 | whodidthis | hit me up with some advice on going about from a vector like [1 3 5 2 2 1 3 3 2] to [[1 3 5] [2 2 1] [3 3] [2]] so the latter has vectors of at least a sum of 5 |
| 17:35 | AeroNotix | that's just weird |
| 17:35 | AeroNotix | whodidthis: isn't that similar to the knapsack problem? |
| 17:36 | TEttinger | it's in order |
| 17:36 | AeroNotix | (perhaps it's too late in the day for me to be thinking of algorithms) |
| 17:36 | AeroNotix | TEttinger: but you can't be greedy |
| 17:36 | rasmusto | whodidthis: use a loop w/ 3 bound vars, your list, an accumulator (< 5), and the mini-vector you're building up |
| 17:36 | AeroNotix | rasmusto: but that's greedy |
| 17:37 | justin_smith | (inc rasmusto) ; yep, that's what I would have suggested |
| 17:37 | lazybot | ⇒ 11 |
| 17:37 | justin_smith | AeroNotix: a vector is already eager |
| 17:37 | rasmusto | AeroNotix: well, he asked for a vector out |
| 17:37 | AeroNotix | I don't mean in laziness |
| 17:37 | gtrak | whodidthis: partition-all |
| 17:37 | AeroNotix | I mean that you might be able to make better groups analyzing the whole thing |
| 17:37 | justin_smith | gtrak: how would partition-all know the accumulated sum? |
| 17:38 | justin_smith | AeroNotix: I did not read such a task from his example, the order was unchanged |
| 17:38 | gtrak | filter |
| 17:38 | gtrak | justin_smith: ahhh |
| 17:38 | AeroNotix | justin_smith: whatever |
| 17:38 | AeroNotix | underspecified |
| 17:38 | AeroNotix | back to not caring |
| 17:39 | amalloy | if you don't mind using flatland.useful, whodidthis, it's an easy problem: https://www.refheap.com/6897866b0f83943b5a0e72489 |
| 17:40 | amalloy | and that's lazy, of course |
| 17:40 | gtrak | I'd probably use reduce |
| 17:40 | justin_smith | yeah, actually reduce is better than loop (but the same semantics) |
| 17:40 | amalloy | srsly? laziness is a way better default than reduce |
| 17:40 | arrdem | justin_smith: thoughts on that commented log implementation I've got? |
| 17:41 | gtrak | amalloy: glue's pretty clever |
| 17:41 | clojurebot | Huh? |
| 17:41 | justin_smith | amalloy: I was comparing to loop, not laziness |
| 17:41 | amalloy | gtrak: it's amazingly general, but not *quite* so much so that it's useless |
| 17:41 | gtrak | hence useful :-) |
| 17:41 | rasmusto | gtrak: It'd use a reduction on a map with 4 entries, right? (xs, mini-vec, current-sum, and result) |
| 17:41 | amalloy | you can implement all of clojure's partitioning functions, and many more beside, with glue |
| 17:42 | justin_smith | arrdem: looking now |
| 17:42 | gtrak | rasmusto: yea |
| 17:43 | rasmusto | gtrak: cool, so yeah, same as the loop thing, but lazy (and more clear arguably) |
| 17:43 | TEttinger | ,(reduce #(if (>= (apply + (last %1)) 5) (conj %1 [%2]) (update-in %1 [(dec (count %1))] (fn [coll] (conj coll %2)))) [[]] [1 3 5 2 2 1 3 3 2] ) |
| 17:43 | clojurebot | [[1 3 5] [2 2 1] [3 3] [2]] |
| 17:43 | amalloy | rasmusto: reduce is never lazy |
| 17:44 | rasmusto | oh, nm. "glue" was the lazy example |
| 17:44 | gtrak | rasmusto: yea, reduce isn't lazy, just more data-ish |
| 17:44 | tbaldridge | declarative is what you are looking for, it's more declarative |
| 17:45 | gtrak | i guess that's one way of putting it, I mean more 'reified' I think. |
| 17:45 | whodidthis | thanks guys, clojure so compact ill have to study these for a "while" |
| 17:47 | TEttinger | mine isn't very good, but it has no dependencies at least |
| 17:49 | amalloy | if i were writnig this function with no dependencies, it would look like https://www.refheap.com/ced27e80b9d970edd08eb7cde |
| 17:51 | turbofail | hm. it just occurred to me that i barely ever use assoc on vectors |
| 17:51 | oinksoft | what is the non-lazy (map)? |
| 17:52 | arrdem | mapv? |
| 17:52 | justin_smith | mapv |
| 17:52 | justin_smith | or doseq, depends what you want |
| 17:52 | justin_smith | or (dorun (map ...)) |
| 17:52 | arrdem | pmap may be non-lazy :P |
| 17:52 | justin_smith | or (doall map) |
| 17:53 | gtrak | turbofail: ##(assoc [] 20 :kaboom) |
| 17:53 | lazybot | java.lang.IndexOutOfBoundsException |
| 17:56 | justin_smith | arrdem: that as-> x v with a later for [[k v]] is confusing |
| 17:57 | justin_smith | arrdem: regarding the actual logic, now that I think I am reading it properly, wouldn't you want the unit to be intrinsically log vs. linear? (ie. something like dB) or am I misunderstanding? |
| 17:58 | justin_smith | or wait, this would be a way to take linear sound pressure and do dB operations on it |
| 17:59 | justin_smith | but something feels wrong about taking the log of the value, and dividing the unit by E - the latter is still linear so you will get nonsense? |
| 17:59 | arrdem | yeah I did some searching and it sounds like by convention the log of a value with units is a scalar |
| 17:59 | arrdem | or meaningless |
| 17:59 | justin_smith | either I am way confused or this is all wrong |
| 18:00 | arrdem | I just pushed a 1.0.2 that deletes that snippet because you're right, it's silly |
| 18:00 | justin_smith | I was really looking for something meaningful but over my head |
| 18:00 | justin_smith | hah |
| 18:01 | arrdem | :P yeah the reason for the ;; todo: ponder is that I was looking for something complicated myself :P |
| 18:03 | justin_smith | to go linear -> log I think you do a log op on the value, and swap out linear units for log ones |
| 18:03 | justin_smith | so now we have a more complex unit object ? |
| 18:04 | justin_smith | since a number cannot tell you how to un-curve it |
| 18:04 | arrdem | er. that's interesting... |
| 18:05 | arrdem | you're right, I could rework this to store everything log base i, but I don't see a reason to do so. |
| 18:05 | arrdem | the whole reason for this library was to be able to do multiplication between factors with units and make sure that the final units were what I expected ;P |
| 18:05 | justin_smith | arrdem: or a unit could tell you how to delinearize / linearize for conversions, but that feels quite OO |
| 18:06 | justin_smith | that may be an acceptible bit of OO though |
| 18:08 | arrdem | yeah. my log math hacks are rusty... with the introduction of calculators I never had to learn log table tricks. |
| 18:11 | gtrak | is there a lein plugin that demonstrates making derived source-artifacts available on the classpath? |
| 18:11 | justin_smith | arrdem: as long as a conversion is reversible you could have various arbitrary curve defining converters (with log just being a simple example) |
| 18:11 | justin_smith | arrdem: for example in audio we have sones which take both frequency and log pressure intensity into account |
| 18:12 | arrdem | justin_smith: that'd be nice... I've been kinda frustrated that powers of ten on the same type don't silently convert. |
| 18:12 | justin_smith | arrdem: well that's not a curve, but a similar but simpler concept |
| 18:12 | justin_smith | but yeah, the same system could have silent promotion of SI units |
| 18:12 | arrdem | justin_smith: I'm gonna grab food, but I'd love to seen an example |
| 18:16 | justin_smith | arrdem: never mind about sones, that is not a reversible unit, it is a multi-variable nonlinear formula, apples and apple shaped bricks |
| 18:20 | arrdem | since I'm musing about conversions I wonder if I can bolt meajure atop either frinj or minderbinder... |
| 18:21 | coventry` | Tekhne: I've found this macro handy for working through 4clojure problems. https://www.refheap.com/79836 |
| 18:21 | justin_smith | coventry`: that is very cool |
| 18:22 | arrdem | isn't that equivalent to clojure.test/are? |
| 18:23 | amalloy | coventry`: there are a number of lein plugins for 4clojure, which will download a problem's test cases and create a clojure.test clause for it |
| 18:23 | justin_smith | but it uses the 4clojure _ format |
| 18:23 | coventry` | https://github.com/tonsky/datascript |
| 18:24 | coventry` | You had me kicking myself for not cloning it earlier for a second there. :-) |
| 18:30 | coventry` | The parameter vectors need to go inside the lists. |
| 18:40 | coventry` | martinklepsch: (mapcat (fn [[k v]] (map (partial vector k) v)) name-map) |
| 19:44 | coventry` | dnolen_: thanks. |
| 20:22 | mudgen | hello |
| 20:23 | mudgen | how is the clojure programming going everybody? |
| 20:23 | nightfly | lispy |
| 20:24 | mudgen | great |
| 20:31 | arrdem | mudgen: http://i.imgur.com/5PfDzhS.png |
| 20:31 | arrdem | mudgen: https://pbs.twimg.com/media/BdZYs5lCUAAGVEy.png |
| 20:31 | arrdem | too many doges. can't link the right one. plz help |
| 20:42 | hlship | mudgen: let me check for you |
| 20:42 | hlship | how is the clojure programmng going? |
| 20:42 | hlship | hlship: let me check for you |
| 20:42 | hlship | how is the clojure programming going? |
| 20:42 | hlship | ... |
| 20:43 | nightfly | (going? clojure-programming) |
| 21:02 | Frozenlock | Anyone knows how to deactivate the markdown support in tower? |
| 21:04 | fitzoh | Anyone care to tell me what I’m doing wrong with core/async? I’m working on a function that given a channel c, number of items n, and timeout t, returns a seq of n items if they’re available from c within t, else nil https://www.refheap.com/80093 clear enough explanation? |
| 21:08 | reiddraper | I've pushed some more docs up to test.check: https://github.com/clojure/test.check/blob/master/doc/generator-examples.md |
| 21:12 | Frozenlock | nvm, I just needed to add '!' at the end of my keyword to keep the text as is. |
| 21:24 | arrdem | reiddraper: first example in that link, missing lparen on the requre =P |
| 21:24 | arrdem | s/l/r/g |
| 21:25 | reiddraper | arrdem: fixed, thanks |
| 21:25 | arrdem | reiddraper: the support for gen/frequency is interesting... do you have a use case where it matters? seems like even frequency is just as good if not better... |
| 21:26 | arrdem | also why's the "anything but 5" example entitled anything but 13? |
| 21:26 | reiddraper | arrdem: poor proof-reading :) |
| 21:27 | arrdem | reiddraper: you should see my reddit posts... 200 LoC for statistics and analytic econ, 0 proofreading |
| 21:28 | arrdem | also the reid's have kinda got to stick together... proofreading is hard anyway :P |
| 21:28 | reiddraper | arrdem: gen/frequency allows you to control distribution, which can be important for controlling how likely your functions get called with different classifications of input. IN that example, you may not want to litter 50% of your tests with returning nil, but you do want it to happen in some smaller percent of test runs |
| 21:28 | reiddraper | arrdem: ha, yes indeed re: reid |
| 21:29 | arrdem | reiddraper: awesome library, I look forwards to using it! |
| 21:29 | reiddraper | arrdem: appreciate that |
| 21:30 | arrdem | will report further typos loudly and publicly as I notice them =D |
| 21:31 | reiddraper | please do :) |
| 21:31 | ghadishayban | fitzoh: your :else clause is outside the cond |
| 21:32 | fitzoh | ghadishayban: thanks, I’m slowly making progress… was also using seq as a variable :x |
| 21:35 | ghadishayban | fitzoh: np. happy to help. Also -- careful with shadowing names like 'chan |
| 21:36 | ghadishayban | couple other things I can help with. (you'll have to forgive me i work on core.async). the timeout chan isn't ever read, it's discarded in the _ |
| 21:38 | ghadishayban | so it's implicitly distinguishing between the timeout and the end of items (both make nil values) |
| 21:38 | fitzoh | that part’s intentional, I don’t *think* I care about the timeout channel, just using it a way to kill the process |
| 21:38 | fitzoh | lemme get an updated paste, think I’m just about there |
| 21:39 | fitzoh | https://www.refheap.com/80103 |
| 21:41 | ghadishayban | fitzoh: that looks like it should work (does it? =) Might point you to core.async/take, which you can use in conjunction with a timeout |
| 21:42 | ghadishayban | fitzoh: more pedantry: seq is being shadowed |
| 21:43 | fitzoh | aye, it’s doing what I want… I was looking at take for a while, but wasn’t quite sure how it would work, doesn’t it only take a single channel? |
| 21:43 | ghadishayban | fitzoh: whoops was looking at wrong paste |
| 22:15 | kelseygi | this question is a bit confused |
| 22:15 | kelseygi | but if i have a persistentvector |
| 22:15 | kelseygi | and i call map over it |
| 22:16 | kelseygi | and then filter the result |
| 22:16 | kelseygi | the resulting vector isn't lazily evaluated, right? |
| 22:16 | kelseygi | like, two passes have been made over the vector? |
| 22:16 | egghead | no kelseygi |
| 22:16 | egghead | it is O(n) |
| 22:16 | egghead | so single pass |
| 22:16 | egghead | and yes the result is lazy |
| 22:16 | egghead | it builds up a lazy chain of operations over each item in the collection |
| 22:17 | kelseygi | ah ok interesting |
| 22:17 | kelseygi | so is map + filter equivalent to doing a for with a :when expression in it? |
| 22:18 | egghead | ya kelseygi you can look at it like that |
| 22:18 | egghead | except for comprehensions can do all sorts of other crazy things like cross products |
| 22:19 | kelseygi | right |
| 22:19 | kelseygi | if i don't want that though sounds like it's a readability/style question then? |
| 22:21 | egghead | I don't think for is lazy |
| 22:21 | egghead | so for example with map/filter/etc you can return lazy lists, for other people to make further transformations to |
| 22:22 | joegallo | for is lazy |
| 22:22 | egghead | nvm then :) |
| 22:23 | joegallo | i think of map and for as being just slightly different syntax for the same sort of operation... |
| 22:23 | joegallo | there are some differences beyond this, but basically (map (fn [x] lots of stuff here) some-seq) is usually better as (for [x some-seq] lots of stuff here) |
| 22:24 | joegallo | when the fn in your map becomes too big, then you can jump to for before jumping to a named def'd fn |
| 22:24 | joegallo | but its just an alternate syntax |
| 22:25 | joegallo | (i know, i know, they handle multiple seqs differently and stuff...) |
| 22:27 | kelseygi | ok, i was deciding between mapping w/ a named function and (for [seq] blah blah) |
| 22:27 | arrdem | Okay, so I've created a reader literal implementation... how do I make Clojure pr to the reader literal? custom .toStr implementation? |
| 22:27 | joegallo | yeah, if it's a named fn already, then just stick with map, i'd say |
| 22:28 | kelseygi | if i also need to filter, would you still recommend that? |
| 22:28 | joegallo | (for [x some-seq] (inc x)) is way better as (map inc some-seq) |
| 22:28 | joegallo | totally |
| 22:28 | jack_rabbit | In what package do I find the trigonometric functions |
| 22:28 | joegallo | although you might want to join my cult of ->> |
| 22:28 | arrdem | jack_rabbit: they're all already present in Math/ |
| 22:28 | arrdem | ,(Math/sin (/ Math/PI 2)) |
| 22:28 | joegallo | ,(Math/sin 3.14159) |
| 22:28 | clojurebot | 1.0 |
| 22:28 | clojurebot | 2.65358979335273E-6 |
| 22:28 | jack_rabbit | arrdem, thanks. |
| 22:29 | jack_rabbit | arrdem, what namespace is that? A clojure one, or a java thing? |
| 22:29 | arrdem | jack_rabbit: it's a hack to expose the Java math library |
| 22:29 | jack_rabbit | great. |
| 22:29 | jack_rabbit | Thanks for the help. I've been googling for like 10 minutes. |
| 22:29 | arrdem | jack_rabbit: which is usually a feature... if you have custom numeric types then clojure.algo.generic is your project. |
| 22:30 | jack_rabbit | no, nothing fancy for me. :) |
| 22:30 | arrdem | but you can have metadata with your numbers!* |
| 22:30 | arrdem | * at a massive slowdown |
| 22:30 | joegallo | kelseygi: that is, (filter even? (map inc (range 5))) is lovely code, but there's nothing wrong with (->> (range 5) (map inc) (filter even?)) |
| 22:30 | kelseygi | joegallo trying to decipher the diff between -> & ->> right now |
| 22:30 | joegallo | (but with newlines where i have lots of spaces) |
| 22:30 | joegallo | kelseygi: ->> puts things in as the last argument, but -> puts them in as the first |
| 22:30 | arrdem | kelseygi: -> threads the first form into the first position of subsequent forms. ->> threads the first form into the tail position. |
| 22:31 | joegallo | which ends up meaning that you want ->> for things that work with seqs (like map and filter), but you want -> for things that work with collections, like assoc and dissoc |
| 22:31 | arrdem | and you want as-> for things that mix the two :P |
| 22:31 | joegallo | don't cross the streams, arrdem!!! |
| 22:31 | joegallo | :) |
| 22:32 | technomancy | I had to debug some code in leiningen that nested three ->>s inside another ->> |
| 22:32 | joegallo | swoon |
| 22:32 | technomancy | it was buggy, but no one noticed because of all the obfuscation |
| 22:33 | Frozenlock | My limit is 2 ->>. After that I use `let'. |
| 22:33 | kelseygi | now i'm trying to figure out why the examples here wouldn't work with -> http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E |
| 22:34 | technomancy | and one of the arrows was for a single call, not even a chain |
| 22:34 | Frozenlock | o_O |
| 22:35 | joegallo | kelseygi: it's where things end up. (->> (range 5) (map inc)) ends up being treated as (map inc (range 5)) |
| 22:35 | joegallo | but if you used ->, then it would be treated as (map (range 5) inc) |
| 22:35 | joegallo | which doesn't make any sense at all ;) |
| 22:36 | kelseygi | ok |
| 22:36 | kelseygi | jeez, light table makes me feel stupid |
| 22:37 | kelseygi | now that i finally got a damn repl open i see it :P |
| 22:38 | arrdem | kelseygi: if it makes you feel any better, I've stuck with Emacs because I couldn't figure out the repl either :P |
| 22:39 | arrdem | thoughts... is a macro justified her? https://www.refheap.com/80114 |
| 22:59 | tolitius | dnolen_: added an option for Om, in case anybody else needs a non LightTable start: https://github.com/tolitius/www#om-template (mentioned it at #phillyete) |
| 23:39 | kwertii | Suppose I have a record that extends several different protocols. I want the user to have a choice between 2 implementations for one of the protocols, but all of the others have the same implementation. What's the best way to implement this? |
| 23:46 | kwertii | Giving a parameter in the constructor and having the implementation select the appropriate execution seems clunky |
| 23:51 | guns | kwertii: that's less clunky than 2 different record types |
| 23:52 | kwertii | guns: that's what I was thinking, too :/ |
| 23:52 | kwertii | but I can't think of a better option |
| 23:53 | kwertii | I considered coding up some machinery to auto-generate 2 record types with the same single codebase for the shared implementations, which could then be specialized in an extend-protocol. That's at least DRY |
| 23:53 | guns | that sounds the opposite of DRY :) |
| 23:54 | kwertii | The source code, I mean |
| 23:54 | kwertii | You'd write 1 function for each implementation method, and if they change, just auto-regenerate the records |
| 23:54 | guns | yes, I realize. macros. but then you run into equality issues |
| 23:55 | kwertii | yes. |
| 23:55 | guns | I think a case statement in the protocol implementation -> different functions sounds fine |
| 23:56 | kwertii | Practically speaking, it will be fine in my particular case, but it's really fragile as a general solution |
| 23:56 | guns | Do you need a general solution? You're looking for a record factory then… |
| 23:57 | guns | anyway, I'm only piping up because nobody else in the channel is listening |
| 23:57 | kwertii | I was hoping there was some clever aspect of protocols and records that I missed that'd address this. In an OO world, I'd just write a base class and take 2 subclasses of it that each implement the same interface, but with different code |
| 23:58 | kwertii | This is trivial to solve in oo, and completely non-obvious in Clojure |
| 23:58 | guns | you can use definterface to extend a set of interfaces |