#clojure logs

2014-04-24

00:04oinksoftakhudek: hm, ok, yea, tbh i do not like the korma structure, but i ignored that feeling
00:04oinksoftakhudek: i'll take a look at the jdbc pattern
00:25danlamannamaybe i have a huge hole in my understanding, i can conf/disj to a set but still need to define it somehow
00:26TEttinger,(def here-you-go #{1 2 3})
00:26clojurebot#'sandbox/here-you-go
00:26TEttinger,here-you-go
00:26clojurebot#{1 3 2}
00:28danlamannayeah 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:31TEttinger,(let [set-thing #{1 2 3}] (conj set-thing 5))
00:31clojurebot#{1 3 2 5}
00:32danlamannasuppose i have a loop within that let block though, there's no way to append to that set-thing each iteration, is there?
00:33TEttingerdo you mean the macro called loop, or something loop-like?
00:33danlamannasomething loop-like, it happens to be doseq in this case
00:34danlamannahttps://gist.github.com/11241529 to be precise, mentioned-files being the culprit
00:34TEttingerit seems like that's the wrong looping thing to use to me, but I'll check
00:36TEttingeryeah that won't do what you intend I think
00:36TEttingerthe defs will either overwrite a global value or not overwrite anything, I can't remember which
00:37beamsoit seems weird to use def instead of let in that code
00:37danlamannait works correctly, i'm just talking in the interest of best practice
00:37danlamannabeamso: 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:39TEttingeryou can also let an atom
00:40gtuckerkellogghmm, i upgraded leiningen to 2.3.4, and now it's complaining about cider-nrepl
00:40beamsomentioned-files could be a ref or an atom.
00:40beamsoyou could even have mentioned-files as a dynamic def outside main
00:41danlamannai feel like this would be a pretty common scenario
00:42beamsoactually, 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:44beamsothe number of duplicates is the difference in size between what is returned from --apply-options and the size of the set
00:52amalloydanlamanna: the idea is to not use a for-side-effects looping construct like doseq at all
00:53danlamannaamalloy: 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:53amalloyinstead, you reduce over files, with an accumulator that's building up a duplicates list
00:53amalloyor mentioned files, rather
00:53danlamannaamalloy: these are the functional programming-esque things i'm trying to get better at.
00:54amalloyin your example, it's not even clear what mentioned-files is for: you only write it, never read it!
00:54amalloyso it's hard to replace the code that builds it - why is it even there?
00:54amalloyoh, no, it's in the when
00:54danlamannaamalloy: i use it to check if the file has been mentioned before
00:55danlamannaamalloy: i'm not *totally* fargone :P
00:56gtuckerkelloggis there a way to force leiningen to reinstall a jar?
00:56gtuckerkellogga dependency, that is
00:57beamsodelete the .jar and run lein deps again?
00:57Frozenlo`gtuckerkellogg: delete it from .m2
00:58amalloydanlamanna: https://gist.github.com/amalloy/11241974 is the most obvious rewrite of your main loop
00:58gtuckerkelloggty.
00:59amalloythe function that's reducing is in charge of taking the mentioned-file list and a file, and producing a new mentioned-file list
01:00danlamannaamalloy: i see
01:00amalloyare you coming from C? (printf "%s\n" x) is a weird way to write (println x)
01:01danlamannaamalloy: yes
01:01amalloyi mean, i love printf, and find it usually much more readable than combining strings with str. but here it's a bit silly
01:01danlamannaamalloy: 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:04bitemyapparrdem: really?
01:06TEttingerheyy it's everybody's favorite haskell spammer
01:07bitemyappTEttinger: https://twitter.com/bitemyapi
01:07TEttingerhow goes bitemyapp
01:07bitemyappTEttinger: it goes very well...typed.
01:08TEttingerwhat is that, bitemyapp?
01:08TEttingerthat API
01:08bitemyappI think it's a poorly tuned markov chain fed bot
01:14amalloyspeaking of gibberish-generating bots, http://git-man-page-generator.lokaltog.net/ is pretty convincing
01:15bbloomamalloy: i wonder how many ppl were WTF-ing hard before he put that warning banner up
01:16technomancyaww--there's a banner now?
01:16technomancylame
01:16technomancythat site is masterful
01:17gtuckerkelloggso I upgraded lein, and cider-nrepl 0.1.0-SNAPSHOT is breaking the repl even on a new project with the default template.
01:17gtuckerkelloggHas anyone else seen this?
01:18gtuckerkelloggmy profiles.clj contains [cider/cider-nrepl "0.1.0-SNAPSHOT"] as a :plugin
01:21beamsohttps://github.com/clojure-emacs/cider-nrepl/issues/37
01:25seangroveAhk, scoped css limits CSS to a given element, *and* its descendants. So close, yet so far...
01:26bbloomseangrove: yeah, that scoped thing is wildly wrong
01:27seangrovebbloom: Something about inmates and the asylum...
01:27bbloomseangrove: the DOM inherently lacks the necessary separation between a source template and the expanded result
01:27bbloomseangrove: logical vs visual tree, etc
01:28seangrovebbloom: Yeah, I think about the amount of work that could be used across libraries if there were a better common denominator
01:28bbloomyou 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:29seangroveInstead, 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:31bbloomreact.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:32seangrovebbloom: If you're looking to grind your teeth http://oksoclap.com/p/P3aS4GtR2L
01:33seangroveI'm not sure who's on this panel, but they need to have a long think about things.
01:33bbloomseangrove: i can't make sense of these notes & i probably don't want to
01:34seangrovebbloom: No, it's all just madness
01:49beamsodo people use clojure/data.xml for xml or something else?
02:08dissipatedoes anyone know of a way to run tests in parallel?
02:12beamsomy googling says that you can't :/
02:27oinksoftis there a way to call a function dynamically
02:27oinksoftlike clojure.core / 'map ...
02:28oinksoftwhere 'map is variable
02:28beamsoapply
02:29oinksoft?
02:29beamso,(max [1 2 3])
02:29clojurebot[1 2 3]
02:29beamso,(apply max [1 2 3])
02:29clojurebot3
02:29oinksoft...
02:29oinksofti want to dynamically access members in a namespace
02:29beamsoi was just using the worked examples from http://clojuredocs.org/clojure_core/clojure.core/apply
02:30beamsohow you get your dynamic function is up to you, but apply will let you execute that function with arguments that you give ti
02:30beamso*it.
02:30oinksoftyes, i know that
02:31oinksoftmy question was about the how you get your function
02:32oinksoftlet's say i want to define a function (call-in-core map - (range 10))
02:33oinksoftor (call-in-core 'map - (range 10))
02:33oinksoftthe improtant part is the 'map being variable, ignore that this brekas maps being lazy
02:35oinksofti see functions like ns-publics, but not ones to access the ns
02:35pyrtsaoinksoft: See resolve or ns-resolve
02:35oinksoftpyrtsa: thanks!
02:36pyrtsaThey return the Var, which you can either call directly or access with @x or (deref x).
02:37dissipateclojurecheck hasn't been updated in 2 years. is it abandonware? https://github.com/jbondeson/clojurecheck
02:37oinksoftpyrtsa: this is what i needed, thanks
02:40dissipatenevermind, found test.check
02:40dissipatehttps://github.com/clojure/test.check
02:51oinksoftlack of pattern matching is a pain when writing an api
02:51oinksoftwhat do you do?
02:51beamsopattern matching?
02:52oinksoftit'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:52oinksofti'm not sure how to avoid writing lots of -type variants
02:53oinksoft(foo 1 2) ... (foo-with-vec 1 [2 3])
02:53oinksoftbecause of the restirction on mutliple overloads w/ same arity
02:54noidioinksoft, have you tried https://github.com/clojure/core.match and https://github.com/jamii/strucjure ?
02:54oinksoftdoing (if (vector? 2nd-param ... seems ugggly
02:56oinksoftnoidi: yea but seems like lipstick on a pig for simple type switching
02:56oinksoftnoidi: you would have to do (match [(vector? arg2)] [true] ... [false ....
02:56akhudekoinksoft: you could look at multimethods
02:57oinksoftyea, i just wish there were a less verbose way :( that is probably the cleanest, thanks!
03:11wunkihow 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:17ivanwunki: maybe https://github.com/fredericksgary/catch-data but haven't tried this
03:19ivanor just use a single catch block and use (ex-data e) to decide what to do
03:23badlambdaI 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:29sm0kesounds like a sales pitch
03:39wunkiivan: thanks, will try `ex-data`!
03:40Glenjaminwunki: you might be able to use slingshot - although i'm unsure if that works on generic ex-info calls
03:40dbaschbadlambda: it looks like your code would be cleaner if you were using 1s and 0s instead of true/false
03:41wunkiGlenjamin: I tried using slingshot, but wasn't able to get it to work
03:41wunkiGlenjamin: but that's probably my incompetence
03:41dbaschbadlambda: also, (range 0 n) = (range n)
03:43dbaschbadlambda: get-indices-where-true should be implemented with for
03:46dbaschbadlambda: (if (nil? something) nill some-code) = (when-not something some-code)
03:51dbaschbadlambda: if you’re removing things at specific locations, look into using vectors instead of lists
03:51dbaschbadlambda: there’s little reason to use pure lists. Check out subvec
03:53clgvbadlambda: 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:55clgvbadlambda: (if (nil? x) nil (something ...)) is better written as (when x (something ...))
03:56dbaschbadlambda: more importantly, your code doesn’t compile :)
04:02dbaschbadlambda: (filter #(not (in? % l2)) l1) = (remove #(in? % l2) l1)
04:05rolfbare there any exciting ways to use #() to build an anonomyous function and make it recursive?
04:06clgvrolfb: no. you need to use the verbose form
04:07clgvrolf: oh wait. recur should work^^
04:07rolfbclgv: checking
04:08clgv,(#(if (zero? %1) %2 (recur (dec %1) (* %1 %2))) 5 1)
04:08clojurebot120
04:08clgvrolfb: factorial ^^
04:08rolfb% and %1 is the same?
04:08clgvyes
04:08rolfbclgv: where can i read up on syntatic sugars like % in short form?
04:08clgvuse %1 if you have more than one param
04:09clgvrolfb: I guess most books should include it. some info is here as well http://clojure.org/reader
04:10rolfbclgv: perfect, thanks
04:14dbasch,(#(recur))
04:14clojurebotExecution Timed Out
04:14clgvdbasch: bad boy ;)
04:14dbasch:)
04:14clgvclojurebot: poor bot. botsnack!
04:14clojurebotPardon?
04:15clgvclojurebot: botsnack
04:15clojurebotthanks; that was delicious. (nom nom nom)
04:16lockssnacks won’t save you come the skynet revolution
04:19rolfblocks, you are everywhere
04:20locksrolfb: it’s part of my “learn by osmosis” approach. so far haven’t had much success.
04:20rolfblocks: smart, i'm trying learn by 4clojure and asphyr
04:20rolfbseems to be working ok
04:21locksasphyr?
04:21rolfbaphyr
04:21rolfbsorry
04:21rolfbhttp://aphyr.com/posts/301-clojure-from-the-ground-up-welcome
04:22locksoh
04:22locksI did a chunk of 4clojure too, and I have joy of clojure on my kindle
04:22rolfbhaven't gotten to joy of clojure yet as the back says you need some familiarity with clojure before reading it
04:22lockscuriously, I’m watching this https://www.youtube.com/watch?v=XeWP60DK6O0&feature=youtube_gdata
04:23rolfbinteresting, thanks
04:23rolfblocks: related to aphyr; https://twitter.com/fogus/status/459015590112681984
04:23locksJOY’s pacing isn’t a walk in the park, for sure
04:23locksI saw it, I’m following fogus :]
04:24rolfbi'm at problem 39 in 4clojure, but feeling a tiny bit stuck on a good way to solve it
04:24clgva student of mine said that he learned much faster with "programming clojure (2nd edition)" than with "clojure programming (O'Reilly)"
04:25rolfbclgv; oh really? i started the latter one
04:25locksthose titles aren’t confusing at all
04:26rolfbholloway vs emerick?
04:26clgvright
04:26locksspeaking of, I also got this http://shop.oreilly.com/product/0636920030409.do?intcmp=il-prog-books-videos-cat-intsrch_clojure_ct
04:27clgvoh whats that?
04:27rolfbhalloway, not holloway
04:28locksit’s kind of the video equivalent to JOY
04:28rolfblocks, interesting as well :)
04:28locksthey blitz through the hows and whys of clojure
04:32rolfbis there a way to pretty print vectors and such in the repl?
04:33rolfblike in APL
04:33rolfb*ducks*
04:33clgvclojure.pprint/pprint is a built-in function to do that
04:33clgvpretty printing I mean, dont know about APL ;)
04:34rolfb(clojure.pprint/pprint (vector [1 2 3] [:a :b :c])) doesn't do much in terms of formatting
04:35rolfbwhoops
04:35clgvrolfb: maybe I did not understand what you mean. do you mean something like clojure.core/format?
04:35rolfbclgv; i would love to get ... the above to print like
04:35rolfb[[1 2 3]
04:36rolfb[:a :b :c]]
04:36rolfbon two lines
04:36rolfbthat's what I feel is a pretty print
04:41noidirolfb, http://richhickey.github.io/clojure/clojure.pprint-api.html#clojure.pprint/*print-right-margin*
04:41noidihttp://richhickey.github.io/clojure/clojure.pprint-api.html#clojure.pprint/*print-miser-width*
04:53rolfbnoidi; thanks
05:18badlambdaclgv, dbasch: thanks for the feedback
05:53irctc_hey.... can anyone help me ny telling how to hide a properties file in clojure
05:54irctc_i am using leiningen framework for my clojure web application and there is no private folder.. where to keep the properties file??
05:54lazybotirctc_: Definitely not.
06:15clgvirctc_: what do you want to do? what is "hiding" supposed to mean in this context? what is you reason to "hide" that file?
06:22sm0ke:D
06:23clgvlazybot: you'd ask the same, right???
06:23lazybotclgv: How could that be wrong?
06:23sm0kemay be he is packaging passwords with code, interesting question though
06:23sm0keirctc_: you can not hide it but you can obfuscate it
06:24sm0keDRM sucks brother, nothing will be hidden ultimately
06:31clgvsm0ke: yeah, I also think that he want to package passwords or something similar...
06:33sm0kenow wonder there is no "licencing" frameworks
06:33sm0keat least i havent seen any
06:36rolfb,(format "testing")
06:36clojurebot"testing"
06:40sm0ke,(prn \♥)
06:40clojurebot\♥\n
06:40sm0kehmm
06:40sm0ke,(prn "♥")
06:40clojurebot"♥"\n
06:40sm0ke,(pr \1)
06:40clojurebot\1
06:41clgv(char "♥")
06:41clgv,(char "♥")
06:41clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number>
06:41clgv,(map char "♥")
06:41clojurebot(\♥)
06:41clgvlol^^
06:42clgv,(-> "♥" first long)
06:42clojurebot9829
06:42sm0ke,'
06:42clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
06:42sm0keugh
06:42sm0ke,(pr '♥)
06:42clojurebot
06:43sm0keyes!
06:43clgvclojurebot: smoke |is| ♥
06:43clojurebotAlles klar
06:43sm0kehmm weird, ##(defn ♥ [] (pr '♥))
06:43lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
06:43clgvoops ;)
06:44clgvclojurebot: sm0ke |is| ♥
06:44clojurebotAlles klar
06:44clgvsm0ke?
06:44clojurebotsm0ke is smoke
06:44rolfbdef is bad?
06:44clgvweird
06:44sm0kehmm weird, ##(defn foo [] (pr '♥))
06:44lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
06:44clgvrolfb: for lazybot yes ;)
06:44sm0kewth is wrong
06:44clgv,(defn ♥ [] (pr '♥))
06:44clojurebot#'sandbox/♥
06:44sm0ke,(♥)
06:44clojurebot
06:44clgv,(♥)
06:44clojurebot
06:44clgv^^
06:45rolfbinteresting
06:45jballancclgv: doesn't clojurebot take a while to learn something new?
06:45sm0kewow clojure is nice
06:45clgvclojurebot is more liberal ;)
06:45jballancclojurebot: sm0ke |is| ♥
06:45clojurebotIn Ordnung
06:45clgvjballanc: no it should associate that immediately
06:45clgvsm0ke?
06:45jballancsm0ke?
06:45clojurebotsm0ke is ♥
06:45clojurebotsm0ke is </3
06:45jballanc:P
06:45clgvroflmao
06:46sm0keweird
06:46clgvit seems to pick facts randomly now?
06:46owl-v-,()
06:46luxbockneed some help with a macro: https://gist.github.com/luxbock/11249913
06:46clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol:  in this context, compiling:(NO_SOURCE_PATH:0:0)>
06:46jballancoh, I was under the impression he had some elementary ML implementation
06:46owl-v-,
06:46clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol:  in this context, compiling:(NO_SOURCE_PATH:0:0)>
06:46clgvjballanc: not that I know.
06:46sm0keML is a heavy term
06:46jballancowl-v-: that character is a weird spot in the unicode plane
06:46luxbockwhy does the macro return the gensym'd symbol name when I use it with map?
06:47sm0keclojurebot: |is| |is| equality
06:47clojurebotexcusez-moi
06:47owl-v-
06:47clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: π in this context, compiling:(NO_SOURCE_PATH:0:0)>
06:47sm0ke,'π
06:47clojurebotπ
06:48owl-v-,'
06:48clojurebot
06:48owl-v-:)
06:48wink,(def π 3.14)
06:48clojurebot#'sandbox/π
06:48clgvluxbock: because %1 and %2 are gensyms
06:48owl-v-
06:48clojurebot3.14
06:48clgvluxbock: you can not map macros
06:48owl-v-:)
06:48clgvat least not as you intended
06:48sm0keclojurebot: π |is| 3.14
06:48luxbockhmm ok
06:48clojurebotYou don't have to tell me twice.
06:49owl-v-lol
06:49sm0keclojurebot: π?
06:49clojurebotπ is 3.14
06:49sm0keclojurebot: pi |is| π
06:49clojurebotAck. Ack.
06:49sm0keclojurebot: pi?
06:49clojurebotpi is 3.14
06:49sm0kewhoa!
06:49owl-v-clojurebot: :smart?
06:49clojurebotexcusez-moi
06:50owl-v-clojurebot: clojurebot |is| :french
06:50clojurebotRoger.
06:50clgvluxbock: you can use 'map at macroexpansion time within a macro to reach that goal
06:51clgvclojurebot: are you tired of all these requests??
06:51lazybotclgv: What are you, crazy? Of course not!
06:51clojurebotTitim gan éirí ort.
06:51luxbockclgv: can you elaborate on how that would work?
06:51clgvoops wrong bot :D
06:52luxbockI 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:52luxbockso 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:52clgvluxbock: use something similar to `(do ~@(map (fn [a b] `(fundef ~a ~b)) ...))
06:53ssiderishow about storing them in a map with the keys being the numbers
06:53luxbockok, 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:54ssideriswhen do you get access to the numbers? at runtime?
06:54clgvyeah one macro to generate multiple definitions with the definition macro
06:54luxbockyeah, at runtime
06:54ssiderismacros run at compile time
06:54clgvbut if you do not know the values at compiletime that wont work
06:55clgvluxbock: my heuristic tells me that you are on the wron path
06:55luxbockerr, actually I get to access them at compile time, as in they are defined in the code
06:55luxbockhehe it's quite possible, my initial approach was much simpler but then I got stuck trying to figure this out as a puzzle
06:55clgvluxbock: cant you use partial at runtime?
06:56luxbockwell 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:56luxbockso inside this nested map are a list of numbers which represent allowed bet-sizes in the game
06:57luxbockso 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:58luxbockbut 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:58luxbockI often end up over thinking these things
06:59clgvluxbock: choose the simplest approach ;)
07:26kras,(tree-seq coll? #(if (false? %) '() (identity %)) [1 2 [3 4 false]])
07:26clojurebot([1 2 [3 4 false]] 1 2 [3 4 false] 3 ...)
07:26krasHi help with the above
07:27krasI am expecting it to insert '() as a child node wherever there is false
07:28clgvkras: tree-seq returns a seq and not a tree. you need something like clojure.walk/prewalk
07:28krasclgv: I just need a seq but the children function is inserting a '() for false
07:29krasthat is not happening
07:29kras,(doc tree-seq)
07:29clojurebot"([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:29kraspasting it with a shorter input
07:29clgvkras: well an empty list of children wont occur in the seq ;)
07:29kras,(tree-seq coll? #(if (false? %) '() (identity %)) [3 4 false])
07:30clojurebot([3 4 false] 3 4 false)
07:30clgvkras: try '(())
07:30clgv,(tree-seq coll? #(if (false? %) '(()) (identity %)) [1 2 [3 4 false]])
07:30clojurebot([1 2 [3 4 false]] 1 2 [3 4 false] 3 ...)
07:30clgvah lol "false" has no children
07:30clgvsince it is not a collection due to "coll?"
07:31clgvwhy dont you just map over the seq after it is constructed to replace those false values?
07:32clgv,(map #(if (false? %) '() %) (tree-seq coll? #(if (false? %) '(()) (identity %)) [1 2 [3 4 false]]))
07:32clojurebot([1 2 [3 4 false]] 1 2 [3 4 false] 3 ...)
07:32krasI could do that but thought if it works it would be elegant
07:33clgv,(map #(if (false? %) '() %) (tree-seq coll? seq [1 2 [3 4 false]]))
07:33clojurebot([1 2 [3 4 false]] 1 2 [3 4 false] 3 ...)
07:33kras,(map #(if (false? %) '() %) (tree-seq coll? seq [3 4 false]))
07:33clojurebot([3 4 false] 3 4 ())
07:34clgvkras: in this case it is only complicated to integrate it
07:34krasyeah this is what I need but still can't understand why the children function is not working
07:42krasokay got it now
07:43kras,(tree-seq coll? (fn [x] (map #(if (false? %) '() (identity %)) x)) [3 4 false])
07:43clojurebot([3 4 false] 3 4 ())
07:44gfredericks,(tree-seq coll? (partial map #(if (false %) () %)) [3 4 false])
07:44clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn>
07:45gfredericks,(tree-seq coll? (partial map #(if (false? %) () %)) [3 4 false])
07:45clojurebot([3 4 false] 3 4 ())
07:47krasgfredericks: I tried with partial but switched back to fn
07:47krasbut after seeing this its more readable
07:50clgvkras: the children function is only called on data the returned true for branch?
07:51clgv,(coll? false)
07:51clojurebotfalse
07:52clgv;)
07:52krasclgv: yep I realized it and modified it above
08:21wunkiI'm doing something wrong with destructuring an Exception with slingshot. Anyone see what it is? https://gist.github.com/wunki/11252574
08:31wunkior does slingshot not deal with `ex-info` exception, only with it's own `throw+`
08:38pjstadigwunki: hmm i thought it handled ex-info, too, but i don't see anything particularly wrong with your code
08:39pjstadigwunki: do you have control over the code that throws? could it just use throw+ instead?
08:40pjstadigah https://github.com/scgilardi/slingshot/issues/35
08:40pjstadig^wunki
08:41wunkipjstadig: thanks, great find
08:41wunkipjstadig: will resort to basic catch all exception and destructure it with `ex-data`
08:41pjstadigyeah that should work
08:43wunkipjstadig: result (works!) https://gist.github.com/wunki/11253195
08:43pjstadigwunki: cool! though it might be a tad safer to catch ExceptionInfo instead of Exception
08:44pjstadigi mean i guess ex-data returns nil for non ExceptionInfo exceptions so maybe that comports with the behavior you want
08:44clgvwunki: well now you can steal the slingshot code to write your own try+ that deals with exceptioninfo in a similar concise way ;)
08:45mpenethttps://github.com/fredericksgary/catch-data is nice
08:45mpenetsimpler
08:45clgvmpenet: ah well that gfredericks guy did that already ;)
08:46mpenet:)
08:47clgvbut why not patch the slingshot library?
08:47pjstadigslingshot predates ex-info, so it may be that a simpler lib based on ex-info is in order
08:48pjstadighadn't heard of catch-data
08:48pjstadigclgv: a patch could still be sent to slingshot
08:48clgvwell you could simply use ex-info when it is available and otherwise slingshot.ExceptionInfo
08:49pjstadigsure, but if you're writing new code why not use ex-info?
08:49clgvdid I suggest that?
08:50clgvpjstadig: looks to me as if slingshot is the parent of exceptioninfo looking at the source of both
08:51clgvI wonder why Clojure did not add more support for ex-info in terms of catching ^^
08:51pjstadigit is now since ex-info is available on clojure 1.3+ (i think?)
08:51clgv1.4
08:54gfredericksclgv: github.com/fredericksgary/catch-data
08:55mpenetgfredericks: I beat you to it :) still a fan btw
08:55clgvgfredericks: yes, that was the reason for my comment ;)
08:56gfredericksoh ha
08:56gfredericksapparently I didn't scroll up very far :)
08:56clgvhappens to all of use ;)
08:57clgvgfredericks: btw is there an error in the Readme? I'd expected :ex on the right side "{bar :foo, :ex the-exception}"
08:57gfredericksnope!
08:58gfredericksit's analogous to :keys, :as, and other special destructuring things
08:58clgvoh. not so intuitive since there is no vector or something similar to hint that
08:59gfredericksyeah, I'm not sure how I feel about vectors for single bindings
08:59ssiderisdeciding on the syntax of macros is one of the hardest problems in lisps I think
08:59gfredericksI wonder how many data points we could find on existing macros
08:59gfrederickscompojure is +vector
08:59gfrederickswell nevermind
09:00clgvgfredericks: 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:00gfredericksclgv: ooh you mean _inside_ the map?
09:00gfredericks:as isn't followed by a vector
09:01clgvgfredericks: humm right. why not use :as here? ;)
09:02clgvdistinction between content map and exception?
09:02gfredericksright
09:02gfredericksyou can still use :as, you just get the map
09:03gfredericksthe 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:03gfrederickshey I could add more destructuring keys for msg, cause, etc :) that'd be...obnoxious?
09:05clgvgfredericks: :cause would be awe some. saves you getting the exception via :ea and cal .getCause on it
09:06clgvmaybe :message as well
09:07clgvmaybe we should a ticket to Jira to get this into core ;)
09:07mpenet+1
09:13gfredericksthe weakest reason to put something in core is "I don't want to bother getting it from a library"
09:13gfredericksand I think that's all that applies here
09:15winkinclude ALL the batteries</meme>
09:15ssideriswhat's a good reason to put something in core?
09:16winkif it gets reimplemented on a daily base and is non-composable with a low number of builtins, imo
09:17ssiderisin that case, I find it weird that we don't have a map-keys and a map-vals in core
09:20stuartsierrassideris: I've brought it up, along with other stuff from the old contrib library map-utils.
09:21ssiderisstuartsierra: oh great, thanks :-)
09:21stuartsierraNo promises though.:-)
09:22ssiderisI understand, and it's good that it's hard to introduce new things into core
09:22mpenetI 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:22mpenetcatch-data is a bit more subtile imho
09:23ssiderismpenet: so how do you implement "map-keys"?
09:23stuartsierraYeah, I loop over maps with reduce-kv. The one I'm more interested in is deep-merge.
09:24mpenetssideris: 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:25mpenetreduce-kv*
09:25mpenetI guess spliting core in many namespaces couldn't hurt one day... hopefully
09:28ssiderissorry for being slow, could you give me a quick example of how to use reduce-kv for transforming the keys of a map?
09:29Bronsassideris: (reduce-kv (fn [m k v] (assoc m (f k) v)) {} the-map)
09:29mpenet,(reduce-kv (fn [m k v] (assoc m (str k) v)) {} {:a 1 :b 2})
09:29clojurebot{":a" 1, ":b" 2}
09:29stuartsierra,(reduce-kv (fn [m k v] (assoc m (str k) v)) {} {:a 1 :b 2})
09:29clojurebot{":a" 1, ":b" 2}
09:29stuartsierrampenet: Ha! We wrote the same example.
09:29ssideristhanks a lot!
09:29mpenet:)
09:29hyPiRiongreat minds think alike
09:30stuartsierraAnd so do we.
09:30mpenetwe should make a wish now I guess
09:33krasis tree-seq overkill for 4clojure #95
09:33krashttp://pastebin.com/mdEGU3tQ
09:33kraschecking for binary-tree?
09:57clgvkree: yeah
09:58clgvkree: a recursive function suffices
10:19zeeshanlakhanireiddraper: around for a quick test.check q?
10:19zeeshanlakhanior anyone really, working w/ test.check
10:20hyPiRionzeeshanlakhani: go ahead
10:21zeeshanlakhaniwhat would be the best approach compose two separate generators of gen/elements
10:21zeeshanlakhanibeing the same type of data
10:21zeeshanlakhaniwas trying to use gen/bind to make a new gen of the combined elements
10:22hyPiRionzeeshanlakhani: (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:23zeeshanlakhaniah, right, duh on my part
10:23hyPiRionyou could also use gen/frequency if you want to scew the probabilities
10:23zeeshanlakhanione-of right on, derp, thanks hyPiRion
10:23hyPiRionnp
10:23zeeshanlakhaniyeah, i was about to go that route, but one-of should suffice
10:26sandbagsI'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:28sandbagsfor ref, this is what I have https://gist.github.com/mmower/a43b150391d74f5af421
10:29sandbagsi'd expect only one of the functions to appear in the resulting .clj/.cljs files
10:31sandbagsack... unbalanced parens
10:31sandbagsworks fine
10:39dabbelinginclojuhello, i have a simple question I want to write a function which gives me the most frequent strings out of a given string
10:40cbpthe most frequent substrings?
10:41dabbelinginclojuyes
10:42dabbelinginclojuthis is what I got so far : (defn topten [x] ((map count (map val (group-by identity (clojure.string/split x #"\s+"))))))
10:42CookedGryphondabbelingincloju: have you seen the function frequencies?
10:43cbpoh separated by spaces
10:43cbpso the most common words?
10:43dabbelinginclojuyes exactly
10:43cbpjust split them and then use frequencies then
10:43xsynisn't that exactly frequencies
10:43dabbelinginclojuha
10:43dabbelinginclojuok
10:46ashishhello is there is any method to read file without given relative path
10:47CookedGryphonashish: ... you'll have to be more specific, what path *do* you have?
10:51gwzhey does clojure allow unrestricted mutation
10:52hyPiRiongwz: as unrestricted as you can be in Java, but it's pretty clumsy to do so in Clojure.
10:53hyPiRionIt's easier to be immutable by design
11:08dabbelinginclojufound a nice one
11:08dabbelingincloju (defn map-count [amap key] (assoc amap key (inc (get amap key 0))))
11:11devn,(defn foo-agent [x] (agent (-> 1 inc inc)))
11:11clojurebot#'sandbox/foo-agent
11:13luxbockis there a better way to do this: (fn one-two-or-three [x] (some #{:one :two :three} [x]))?
11:13devn,(foo-agent 'whatever)
11:13clojurebot#<Agent@1ec9818: 3>
11:14devn,(#{:one :two :three} [:x :one :y :z])
11:14clojurebotnil
11:14devnderp
11:14luxbockI'm looking to test just one variable
11:14devnshort answer, no
11:14devnwhat you're doing looks good
11:14luxbockk, thanks
11:22mzarellaHas anyone here played with promises within node.js? Has your code become unruly? If not, how did you get around it!
11:26arrdemmzarella: wrong chan?
11:27mzarellaI guess, I'm looking at clojure's away of handling async and it's appealing
11:30yediwut, what is this datomicscript foolishness
11:30gtrakmzarella: yes
11:31yedi(after reading some) whoa that is sweet
11:34arrdemyedi: lunk?
11:38Mandararrdem, http://tonsky.me/blog/decomposing-web-app-development/
11:46tolitiusis 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:51justin_smithbut...
12:02tolitiusdid not realize I lost connection in the middle of the sentence… talking about network partitions :)
12:02tolitiusso here it is in full:
12:02tolitiusis 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:03clgvhaha
12:03justin_smithbut...
12:03justin_smithtolitius: I think you need to either link to a pastebin or break it up into smaller sentences
12:04tolitiusshoot, ok, let's refactor then
12:04tolitiusis 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:04tolitiusbefore 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:05justin_smithtolitius: I think templates have free reign on how they interpret the arguments they see
12:05justin_smiththat said, you need to provide arguments in such a way that the template ends up seeing them
12:05nDuffWhile 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:06justin_smithtemplates have the full power of clojure, to interpret your "new" request plus args however they like
12:06tolitiusjustin_smith: yes, besides when the args start from "--" and now ":"
12:06tolitiushence just wanted to check what else is coming..
12:07tolitiusor there is a convention to not use prefixes at all..
12:07justin_smithI don't see why you would need prefixes
12:07justin_smiththough something like key:value or key=value seems intuitive enough, and easy to parse
12:08justin_smithbut I am not a lein dev, they may have more nuanced advice
12:08justin_smith(and they are on this channel)
12:08tolitiuswell, usually options intuitively are provided with ":" e.g. you-app :with-something
12:09justin_smithI would not have intuited that, personally
12:09tolitiusbut in this case there is a collision of options for lein new vs. options for a template
12:16technomancytolitius: 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:16technomancytolitius: it sounds like that's not happening in your case?
12:18tolitiustechnomancy: yea, I think what happens it just treats ":template-arg-1" as a "lein new" options vs. a custom template option
12:19technomancycould you open a bug report?
12:19technomancythat logic is really awful iirc; kind of regretting having lein new take args itself
12:19tolitiusand does not pass it along to (defn "template name" …. )
12:19tolitiustechnomancy: sure, will do
12:40yedi_in secretary, is there a way to trigger the history on some state changes / routes, but not on others?
12:47coventry`nDuff: I don't know of such a thing, but custom buffers aren't too mysterious. Check out async/impl/buffers.clj
13:08dnolen_big changes landed in Om 0.6.1, please test https://groups.google.com/forum/#!topic/clojurescript/Yhysh2HDb_w
13:15seangrovednolen_: Cool stuff, thanks
13:34danneuI'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:35danneucore.async with a control/poison channel comes to mind but i'm not sure how to listen for poison within a tight loop
13:40danneuof 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:43arrdemdanneu: 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:46danneuarrdem: b-b-but my toy bitcoin implementation needs a toy miner for its toy mining pool
13:47arrdemdanneu: http://hugelolcdn.com/i/240652.gif
13:47rasmustois that a 290?
13:47arrdemrasmusto: I think so
13:47arrdem(dec so)
13:48lazybot⇒ -8
13:48rasmustoarrdem: er, I think I meant r9
13:48rasmustonumbering is so confusing nowadays, it's looped around and intersected across manufacturers :p
13:49arrdemnVidia's isn't too bad, but ATI's is silly
13:49arrdemIntel just uses ungoogleable codenames...
13:49rasmustohd40000
13:49rasmusto"dusty tunnel"
13:53justin_smithhardware version numberwang
13:53rem7I 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:53rem7integer, I don't know why its still consuming 1.5GBs after running.
13:53dbaschbtw, that git is from https://www.youtube.com/watch?v=000al7ru3ms
13:53arrdemdbasch: hahahahaha
13:54dbaschrem7: you’re reading everything into memory at once
13:54arrdem(ind dbasch) ;; laughing uncontrollably
13:54arrdem(inc dbasch)
13:54lazybot⇒ 3
13:55dbaschrem7: also, how do you measure java’s memory usage? for all you know it’s been garbage-collected and not really in use
13:56dbaschrem7: but still, you should do the count lazily
13:56rem7dbasch: yeah, that's fine, I don't mind if it reads the whole file, I just want it to get it clear after
13:56arrdemrem7: 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:56dbaschrem7: it probably does, you just can’t know from looking at process memory usage
13:56arrdem$google github jq
13:56lazybot[stedolan/jq · GitHub] https://github.com/stedolan/jq
13:57justin_smithoften 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:57rem7dbasch: the problem is that java is using all those resources, now other services in the box don't have that memory available
13:58rem7arrdem: simplified version of the problem (there's a lot more going on) :p
13:58rem7arrdem: but I can replicate my issue with that
13:58justin_smithrem7: also, you can use jvisualvm, which comes with the jdk, to look at what the memory in your jvm is being used for
13:58hiredmanrem7: you need to set the max heap on your jvm lower
13:58justin_smithand to track allocation and freeing over time
14:00dbaschrem7: do you have one single json objectin that file, or can you read them one at a time?
14:01rem7dbasch: 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:01dbaschhiredman: but if he sets the max heap lower, it might blow up
14:01hiredmandbasch: that is another problem
14:01shiranaihitowhat 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:02rem7setting 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:02hiredmanrem7: how have you decided the plugin is using all of it?
14:03stuartsierrarem7: that's going to be really hard to guarantee. The JVM cannot partition or set quotas on its heap.
14:03rem7the server runs fine without my plugin at around 600MBs
14:03rem7once I use my plugin it goes up to ~2GBs
14:03hiredmanrem7: I suggest googling and reading up and determining jvm memory usage
14:03rem7have to run a new instance, more pricy :p
14:03dbaschrem7: what does your json look like? can you refhreap a sample?
14:03danneushiranaihito: 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:04hiredmanrem7: the jvm is just not returning the memory to the os
14:04shiranaihitodanneu: are you handing off web sockets to core.async somehow, or.. ?
14:05justin_smithshiranaihito: 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:05danneushiranaihito: oh, i see. for websocket work i use aleph.
14:05shiranaihitohmm
14:05hiredmanI'd suggest googling/reading up on check the jvm memory usage, tools like top and ps can be very misleading
14:06danneurem7: GSON looks like the 'SAX parser for json' http://stackoverflow.com/questions/10657725/parser-for-json-in-servlet-just-like-sax-for-xml
14:06shiranaihitojustin_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:06danneuor maybe even parsed-seq would work for you https://github.com/dakrone/cheshire#decoding
14:06arrdemjustin_smith: aleph is just a http-kit wrapper AFAIK
14:07shiranaihitoarrdem: oh? i thought it was based on netty somehow
14:07justin_smithshiranaihito: 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:07shiranaihitojustin_smith: sounds sensible
14:07justin_smitharrdem: makes sense
14:07danneushiranaihito: you aren't gonna get bottlenecked on perf. use the abstraction that you like and the one that makes it easy for you.
14:07stuartsierraAleph wraps Netty, not http-kit.
14:07hiredmanrem7: http://www.juhonkoti.net/2010/10/19/crash-course-to-java-jvm-memory-issues-to-sysadmins
14:08shiranaihitodanneu: i guess you like aleph's abstraction better then?
14:09shiranaihitohmm.. i wish there was an obvious choice for a web platform, like there's Datomic for a database :P
14:09TekhneCan 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:10justin_smithshiranaihito: clojure hates "platforms" and "frameworks" generally - people like to compose small things that do one job
14:10Tekhne(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:10justin_smithshiranaihito: unless I misunderstand what you mean by platform
14:10technomancyTekhne: learning Emacs while learning Clojure isn't really a good idea
14:10shiranaihitojustin_smith: well, maybe that was a bad choice of words.. i'm not exactly hankering for some bloated enterprisey J2EE monstrosity either :P
14:11rasmustoTekhne: try lighttable if you're just getting started with 4clojure
14:11technomancyI recommend coming back to Emacs after you're comfortable with Clojure tooling
14:11Tekhnetechnomancy: yea, I realize it can be frustrating, but I'm okay with that.
14:11Tekhnerasmusto: I tried lighttable, but I didn't like it. I may revisit that later when more development has been completed.
14:12danneushiranaihito: 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:12shiranaihitoTekhne: 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:12rasmustoTekhne: did you not like the clojure integration? or the editor itself?
14:12technomancyTekhne: I don't know of any videos, bit the clojure-doc.org tutorial on emacs is pretty good
14:12Tekhneshiranaihito: No worries. Thanks for the suggestion. I will definitely be checking out IntelliJ later, but for now I really want to learn Emacs.
14:13technomancyhttp://clojure-doc.org/articles/tutorials/emacs.html
14:13rasmustoTekhne: 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:13Tekhnerasmusto: the editor itself, but I expect that I'll like it more as more features are built, and as it becomes more stable.
14:13technomancytl;dr: use better-defaults, cider, paredit, and magit
14:14shiranaihitoTekhne: 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:14dbaschthe one thing that I wish existed is a friend plug-in for persistent user management
14:14danneuTekhne: 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:14dbasche.g create-user, set-password, stuff like that
14:15Tekhnetechnomancy: I installed someone's variation on the starter kit, and so far so good.
14:15arrdemeeeeeeh starter kits...
14:15arrdemI give you a week before you throw it out, take it appart, steal what you like and roll your own config
14:15technomancyaw crap; the tutorial still recommends the starter xit
14:16technomancykit
14:16rasmustoTekhne: /minimal/ starter kits are fine
14:16TekhneI guess what I'm really looking for now is how to people do interactive development effectively, especially things like debugging, reloading changes, etc.
14:16rasmustoTekhne: clojure.tools.namespace.repl/refresh is a good thing for reloading
14:16Tekhneshiranaihito: yea, they have good stuff.
14:17rasmustoTekhne: https://github.com/clojure/tools.trace is useful in certain situations
14:17Tekhnedanneu: Yea, cool. I'm using Cider and Paredit now. I like it...just trying to get better.
14:17TekhneI found a cool debugging macro that someone was using. That's been helpful for printing out the results of intermediate forms.
14:18shiranaihitoTekhne: 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:18justin_smithTekhne: small pure functions that are easy to verify because they don't care about state, plus the repl for interactive exploration
14:18justin_smithbonus if the repl is in your browser for easy copy / paste to the code
14:18technomancyTekhne: tools.trace is pretty rad
14:18danneuTekhne: 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:18Tekhnerasmusto, technomancy: cool, i'll check out trace.
14:18arrdemTekhne: tracer is pretty groovy too if you don't mind huge prints.
14:18Tekhnedanneu: oh, cool. that's a good idea.
14:19danneuAnother 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:19arrdemone 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:19TekhneSo, 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:20TekhneI think I get it now, though, but I'm not sure all the things can be "reloaded" or not.
14:20technomancyTekhne: redefinition is exactly the whole point of vars =)
14:20technomancyonly during development though
14:20Tekhnetechnomancy: yea, well, I'm still groking Clojure. I think I thought the immutability thing went further than it does.
14:20technomancyarrdem: dude
14:21arrdemtechnomancy: wat do
14:21technomancylein clean =(
14:21technomancyif you have to clean, at least do it in the same jvm
14:21technomancylein do clean, test
14:21arrdemtechnomancy: noted <3
14:21technomancybut you shouldn't need to clean, because you shouldn't ever do AOT during development
14:22Tekhnedanneu: 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:22technomancy[1] - unfortunate gen-class requirements excepted
14:23danneuTekhne: bindings are mutable, but the values they hold are generally immutable
14:23nDuffI'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:23Tekhnedanneu: Yea :-), I think I get that now, after coding for a bit.
14:24shiranaihitobtw, has some kind of standard emerged for working with ring and web sockets? .. or is that a confused question? :p
14:25justin_smithnDuff: dynamic bindings don't play well with things that use multiple threads, never have
14:25justin_smithat least in clojure
14:25danneuTekhne: 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:25nDuffshiranaihito, ...I'd consider (or, rather, I'm actively using) http-kit rather than ring's Jetty adapter.
14:25Tekhnerasmusto: (doc clojure.tools.namespace.repl/refresh) doesn't seem to do the trick and Googling doesn't seem to be too helpful.
14:26Tekhnerasmusto: n/m
14:26TekhneI found something.
14:26nDuffjustin_smith, indeed, though there are often workarounds -- bound-fn and kin. Just not sure whether any of them are particularly usable with ring.
14:26justin_smithnDuff: 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:26shiranaihitonDuff: and it Just Works etc?
14:26shiranaihito:P
14:26TravisDDoes the clojure compiler inline simple functions?
14:26shiranaihitojustin_smith: what are you referring to?
14:27justin_smithshiranaihito: binding / dynamic vars don't behave nicely with things that spawn multiple threads
14:27arrdemTravisD: the existing Clojure compiler does _nothing_
14:27arrdemTravisD: the JVM may play tricks, but the Clojure compiler will not.
14:27justin_smithshiranaihito: that is the source of his problem
14:27TravisDarrdem: Ah, cool. How clever is the JVM?
14:28justin_smithTravisD: it is kind of legendary in its field actually
14:28arrdemTravisD: 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:28nDuffTravisD, 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:28Tekhnerasmusto, technomancy: tools.trace does look very cool.
14:29arrdemjustin_smith: however there are other JITs that are more specialized, much more aggressive and arguably higher performance :P
14:29Tekhnedanneu: so, how do you go about cleaning up the repl? Do you just restart it occasionally?
14:29TravisDThat's also pretty cool - is it possible to make the JVM more eager to optimize?
14:29justin_smitharrdem: sure - I didn't claim it was the best, but it is definitely well known for performing well, and considered a reference point
14:29arrdemTravisD: there are JVM options for tuning the JIT, but I can't claim any familiarity with them.
14:30danneuTekhne: 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:30TravisDHehe, thanks. I'll read up on it if it becomes important :)
14:30rasmustoTekhne: c.t.n.r/refresh will clean up old vars
14:30martinklepschI 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:30amalloyTravisD: the jvm jit is pretty sensible as-is. attempts to tinker with it generally end in ruins
14:30Tekhnedanneu: ah, okay.
14:30Tekhnerasmusto: oh, that's good.
14:30arrdemTravisD: I doubt that tweaking the JIT with command line options will ever save you if you get performance woes.
14:30justin_smithTravisD: 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:30danneuBut i'm really good at hanging the repl when i use unbuffered core.async channels and borked `go` loops... :(
14:30arrdemTravisD: what amalloy said :P
14:31TravisDamalloy: 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:31amalloy,(let [[first more] [:name [:first-name :last-name]]] (for [x more] [first x]))
14:31clojurebot([:name :first-name] [:name :last-name])
14:31amalloyTravisD: but that's just what you want
14:31justin_smithTravisD: if it only runs for a short time, and actually completes on time, what needs optimizing?
14:31TravisDhm, good point
14:31amalloyif your code only runs a few times, then spending cycles figuring out how to optimize it is a waste
14:32justin_smithTravisD: timing sensitive stuff?
14:33TravisDAh, no, some experiments. I guess if I leave the jvm running things that can be optimized will be optimized
14:33TravisDover multiple runs of the experiment
14:33TravisDand timing is not so essential
14:33TravisDanyways, I'm running a bit late :( I will talk to you later!
14:34justin_smithtiming not essential, running late... the irony
14:34amalloy(inc justin_smith)
14:34lazybot⇒ 35
14:34stuartsierraIn -server mode the JVM usually needs at least 10,000 iterations before it starts optimizing.
14:36sritchieany core.async users in the room?
14:36sritchieI want to go from a sequence of channels to a channel with a single sequence of results
14:36sritchie(->> channel-seq (a/merge) (a/into [])) seems to be the way
14:36sritchieis there a function shortcut for this?
14:37alejandrosritchie: I've used (async/mapcat< identity ch)
14:37alejandroactually, I don't think that necessarily does what you want
14:38sritchieyeah, it doesn't stop
14:39alejandrosritchie: doesn't a/merge do what you need? why the into?
14:39sritchiea/merge returns a channel with all the items, but not as its own collection
14:39sritchieI end up blocking with a/<!! to return the sequence to the outer world
14:39sritchiestill integrating this code with some old non async code
14:43TravisDjustin_smith: :D haha
15:03yedilooks like a datomicscript got something akin to a cnd from cognitect
15:04yedithe .clj version is gone too =/
15:04arrdemT_T
15:04yedimaybe cognitect is working on a cljs peer or something...
15:04alejandroyedi: looks like it got renamed?
15:05alejandrohttps://twitter.com/nikitonsky/status/459403600775876608
15:05yediyea i'm assuming the author got contacted about it (i'm sure it wasn't in a malicious manner)
15:05yediah yea, though the .clj version disappeared as well
15:06oinksoftwhere is edn/write?
15:06oinksoftor edn/write-string
15:06yedihttps://github.com/tonsky/datascript/commit/5beb53d7db03bd274b109c823b182214151b5058#diff-d02cef01feeeb3bc679ca8cf787cf538L1
15:06oinksoftis there a function to encode a structure as edn?
15:06amalloy&(doc pr-str)
15:06lazybot⇒ "([& xs]); pr to a string, returning it"
15:07coventry`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:07oinksoftthanks amalloy
15:08coventry`How you intend to, that is. :-)
15:08bodie_having a hard time understanding why this "let" isn't working
15:08bodie_http://cljbin.com/paste/53596009e4b0e996c66f0533
15:08bodie_I keep getting CompilerException java.lang.RuntimeException: Unable to resolve symbol: debug? in this context
15:08amalloybodie_: wrong syntax for multi-arity functions
15:08amalloy(defn f ([] ...) ([x] ...))
15:09bodie_ahhhh
15:09bodie_herp derp, thanks :)
15:11amalloybut also, (let [x y] (foo)) doesn't do anything, if foo doesn't refer to x in that lexical scope
15:11bodie_just noticed that
15:11bodie_I have a global (def debug-mode? false)
15:12dbaschbodie_: that should be a single arity function really
15:12martinklepschany hints how to transform something {:name [:first-name :last-name]} to [[:name :first-name] [:name :last-name]]?
15:12martinklepschbit stuck currently, could be the two beers earlier this evening...
15:12bodie_hrm
15:20aaron__hi
15:21stuartsierramartinklepsch: ,(reduce-kv (fn [out k v] (into out (map (fn [x] [k x]) v))) [] {:name [:first-name :last-name]})
15:21fu86What is the preferred way to run "tasks" from a leiningen driven clojure project?
15:22fu86Like a Rake task in ruby
15:26stuartsierrafu86: Easiest way is just to invoke them from the REPL. You can also use `lein run -m`
15:30fu86stuartsierra: lein run -m is great, thanks!
15:30dnolen_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:31stuartsierrafu86: you're welcome!
15:37coventry`I imagine dereferencing an atom should be pretty fast. You could pass an atom into start-miner! and communicate that way.
15:43coventry`What coin/protocol are you targeting, out of curiosity?
15:43bodie_dbasch, something more like this? http://cljbin.com/paste/53596883e4b0e996c66f0534
15:44bodie_or is there a simpler approach
15:53cbpI'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:55bodie_cbp, I'm not gonna lie, I'm clawing my way through bad stackoverflow advice
15:56bodie_the syntax for that would be more like [foo :or {:debug true}] right?
15:56dbaschbodie_: why is this not enough? (defn basic-query [& debug] (client/get (digitalocean-paths :droplets) {:throw-exceptions (not (or debug debug-mode?))}))
15:57bodie_because I'm still learning how to deal with option args correctly. heh
15:58cbpbodie_: no i dont think that will compile
15:58bodie_optional*
15:59cbpbodie_: [& [{:keys [debug] :as opts}]]
15:59cbpor something of the sort
16:00bodie_I'm trying to imitate the syntax clj-http gives me with a map of optional named arguments
16:00coventry`I would be pretty excited to learn of a more extensible miner than the reference implementation, no matter how slow.
16:04coventry`I guess a few have popped up since I last looked, though.
16:06devnanyone know if there's a way to reformat something like '({:a 1 ...} {:b 2 ...} ...} like how clojure.pprint would print it?
16:06devnfor emacs?
16:07gtrakdevn: might be a good idea for a cider middleware
16:09gtrakI end up reformatting edn manually a lot.. would be nice to select it and M-x cider-prettify-sexp or something
16:10arrdemI'd throw money at a cider pprint middleware...
16:13gtrakhttps://github.com/clojure-emacs/cider/issues/535
16:13arrdemdunno if it belongs in cider or in an nrepl middleware...
16:14Guest72910~anyone
16:14clojurebotanyone is anybody
16:14arrdemand there's always technomancy's proposal for nrepl support for images.
16:14gtrakarrdem: the cider bit would be just mangling the buffer
16:14technomancyI wrote all this like five months ago; you guys are slackers
16:14gtrakthe pprint op could be used for other stuff
16:14arrdemtechnomancy: sorry I don't have the time to keep up with you, Bronsa, dnolen et all...
16:15technomancywhat I really want to see is a middleware that renders stack traces as jpegs with a bunch of compression artifacts
16:15gtraktechnomancy: you wrote it, or you *wrote* it :-)
16:15technomancyjust to show those whiners who say coljure stack traces couldn't possibly get any worse
16:15arrdem(inc technomancy)
16:15lazybot⇒ 106
16:16gtrakthe new stacktrace navigation is pretty nice
16:16justin_smithstack trace rickroll mode?
16:16technomancyis that really too much to ask
16:16gtraknever gonna deref null..
16:16technomancylawl
16:16arrdemone day karma in here is gonna be measured in µtechnomancy
16:16amalloymartinklepsch: it looks like you missed my earlier answer, (let [[first more] [:name [:first-name :last-name]]] (for [x more] [first x]))
16:17martinklepschamalloy, oh yeah, indeed
16:17gtraktechnomancy: 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:18technomancysweet
16:19guns,(let [{:keys [l]} '(:l "list") {:keys [v]} [:v "vector"]] [l v])
16:19clojurebot["list" nil]
16:20gunsHow long has this been true?
16:20gunsForgot to (apply hash-map opts), but discovered the destructuring still worked!
16:20gtrakit doesn't work, you get nil
16:21justin_smiththat's kind of weird, unless I am reading it wrong
16:21gtrak,(let [{:keys [l]} '(:l "list") {v 1} [:v "vector"]] [l v])
16:21clojurebot["list" "vector"]
16:21gtrakguns: ^
16:21gunsgtrak: so destructuring '(:l "list") is expected?
16:21gtrakah! that is weird.
16:22gunssmells like a convenience hack
16:22gtrakguns: I think a long time back there was a change added to make varargs hash-map destructuring work.
16:22gtraklike 1.2ish
16:22gtrakthis is that
16:22gunsgtrak: so it's dependable?
16:22gtrakyea
16:22gtrakbut ugly
16:23gunsgotch
16:23gunsa
16:23gtrakit makes (fn [& {:keys [a b c]}]) work
16:24gunsI see
16:24justin_smith,(let [{x :x y :y z :z} '(:x 0 :y 1 :z 42)] [x y z])
16:24clojurebot[0 1 42]
16:24gtrak,((fn [& {:keys [a b]}] [a b]) :a 1 :b 2)
16:24clojurebot[1 2]
16:25gtraki prefer to just use maps
16:25gtraksince you can merge n stuff
16:25justin_smithyeah, I think all the experts agree that cl style kwargs are a bad idea and opts maps are better
16:26gtrakjustin_smith: all the experts except clojure.core :-)
16:26amalloymaps 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:26gtrakjustin_smith: http://dev.clojure.org/display/community/Library+Coding+Standards
16:27arrdemgtrak: that'd be a fine example if it was (release-sharks {:laser-beams true} 2) tho...
16:27gtrakyea
16:27arrdemwonder if I can edit that...
16:28gtrakapply-kw sucks
16:28gtraktoo much mental overhead
16:28coventry`rem7: If that snippet is representative, you have one humungous json object.
16:28gtrakjust use maps
16:28arrdemgtrak: refresh
16:28gtrakrefresh?
16:28justin_smithgtrak: with how vehemently I have seen people object to kwargs, I am surprised to see clojure.core recommend them
16:29gtrakhttps://groups.google.com/forum/#!topic/clojure-dev/9ctJC-LXNps/discussion
16:29hiredman*shrug*
16:30gtrakhaven't heard people complain about it in quite a while
16:30gtrakit was all the rage in 2012
16:30justin_smitharrdem: haha
16:30justin_smithgtrak: I think it comes up whenever kwargs are seen, we just see fewer examples of it now
16:30arrdemedited again for formatting
16:32gtrakarrdem: better than which?
16:32gtrakmaybe 'not as bad'
16:33justin_smithhttp://rosettacode.org/wiki/Named_parameters#Clojure I think this could at least be worded more clearly
16:34arrdemhttp://dev.clojure.org/display/community/Library+Coding+Standards comments?
16:34arrdemor just fix it if you've got wiki access :P
16:41TravisDDoes 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:49meliponehello! 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:51justin_smithmelipone: you can use ring.middleware.resource/wrap-resource
16:51justin_smithmelipone: and write the file to a directory wrapped by wrap-resource
16:51Frozenlockmelipone: Is the file on your disk, or generated on-the-fly?
16:52justin_smithFrozenlock: well if it isn't on some fs, it isn't a file
16:53nil~guards
16:53clojurebotSEIZE HIM!
16:53Frozenlockjustin_smith: how would you call a csv/zip/pdf generated by the webserver and sent directly to the user?
16:53nil~coin
16:53clojurebotI don't understand.
16:54nilthat makes two of us
16:54arrdemnil: different bot for one...
16:54arrdemlazybot: coin
16:54lazybotarrdem: Tails.
16:54arrdemjustin_smith: ^
16:54nilarrdem: http://www.arrdem.com/i/really.gif
16:55arrdemnil: I'll use my own gifs thank you
16:55arrdem<3
16:55meliponejustin_smith: okay, thanks!
16:56meliponeFrozenlock: the file is on my disk
16:56nilarrdem: wish there was a listing in /i tho
16:56karlswait
16:56nilarrdem: plz 2 make it
16:57karlsdammit, sorry, wrong window
16:57justin_smithFrozenlock: fair point
16:58justin_smithFrozenlock: 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:59Frozenlockyour turn to have a fair point.
16:59FrozenlockBut I'll still call it a 'file' :-p
17:00justin_smithwell, it's that special kind of 'file' that can
17:00justin_smith't be opened with java.io.File
17:02FrozenlockOther than that, no problem!
17:03justin_smithFrozenlock: for a while I have had this dream of directly synthesizing an mp3 or mp4 stream
17:03Frozenlockjustin_smith: what are you waiting for?
17:03justin_smithno original data that gets encoded, just an algorithm demo-scene style that directly generates data to be decoded
17:03cbpbodie_: sorry I went out to eat. What was your question?
17:04justin_smithFrozenlock: the time and motivation to figure out a weird binary stream format :) it will come soon
17:04justin_smithspeaking of files that are not files
17:04FrozenlockI'm sure the guys at overtone would love that
17:04Frozenlockpfff, time, who needs that!
17:05justin_smithpeople with day jobs and girlfriends and hobbies :P
17:07llasram`justin_smith: I'm pretty sure you were just describing someone's hobby. And maybe their day job. Probably not their girlfriend, though.
17:09cbp$mail bodie_ I went out to eat, msg me if you need help.
17:09lazybotMessage saved.
17:09arrdemso... should this not work? https://github.com/arrdem/meajure/blob/master/src/meajure.clj#L108
17:09justin_smithllasram: heh
17:09arrdemit seems like I'm hitting this as a problem.. ##(class (num 3))
17:09lazybot⇒ java.lang.Long
17:10arrdemso I guess I need a (doseq [] (defmethod..))?
17:12justin_smitharrdem: what are you expecting num to do? http://docs.oracle.com/javase/7/docs/api/java/lang/Number.html
17:13justin_smithit's an abstract class, Long is one of its concrete subclasses
17:13justin_smithor am I misunderstanding?
17:13arrdemjustin_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:14arrdemjustin_smith: https://github.com/clojure/algo.generic/blob/master/src/main/clojure/clojure/algo/generic/math_functions.clj#L46
17:15arrdemjustin_smith: https://github.com/clojure/algo.generic/blob/master/src/main/clojure/clojure/algo/generic/arithmetic.clj#L190
17:16justin_smitharrdem: so if I understand correctly, that defmethod means any unspecialized subclass of java.lang.Number gets that same method applied
17:16arrdemjustin_smith: right. that's what I expected too.
17:16oinksofthow do i write functions that should handle nil case? do they all have to start with (if nily-thing) or (when nily-thing) ?
17:16oinksoftin erlang you address this sometimes w/ f(undefined) -> ...
17:16dbaschoinksoft: it depends on what you want to do for the nil case
17:16oinksoftreturn nil
17:17AeroNotix(when ..) is a reasonable thing to do
17:17oinksoftit starts to feel like some boilerplate at a point though
17:17oinksoftAeroNotix: 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:17arrdemjustin_smith: this is what I'm seeing. https://www.refheap.com/80043
17:17dbaschoinksoft: no, when allows you to have more than one because there’s no else
17:17dbaschoinksoft: and returns the last one
17:17oinksofti understand
17:18justin_smithoinksoft: the right way to use when is controversial
17:18oinksofti seem to have joined the fray :)
17:18justin_smithoinksoft: for your semantics, use and
17:18justin_smithless controversial, does what you want
17:18justin_smithand makes it clear you are talking about values
17:18lemonodoris there actually controversy over when? or just 1 or 2 people who have different ideas?
17:18oinksoftit just feels like i have if-let/when-let everywhere :(
17:19justin_smith(not lining up side effects)
17:19AeroNotixoinksoft: just like you have case/if everywhere in erlang
17:19AeroNotixor multiple function heads
17:19justin_smith,(let [thing nil] (and thing (+ thing 42)))
17:19clojurebotnil
17:20AeroNotix,(if-let [thing nil] (+ thing 42))
17:20clojurebotnil
17:20AeroNotixshorter, expresses better intent
17:20arrdemjustin_smith: looks like it's something funky to do with aot and my library -_-
17:20AeroNotiximho
17:21oinksoftmy code is bad because it shold be a reduction
17:21justin_smithAeroNotix: the let was for convenience, assuming something else passed in or bound the value
17:21justin_smith(in the actual case that is)
17:21gunsI really like (when-some []); didn't think I would
17:22gtrakwhat's a compelling example of when-some?
17:22tbaldridgeguns: yeah, it's kindof....."winsome"
17:22rasmusto(doc when-some)
17:22clojurebot"([bindings & body]); bindings => binding-form test When test is not nil, evaluates body with binding-form bound to the value of test"
17:22justin_smitharrdem: wait, those two are in the opposite order of the declaration
17:22tbaldridgeat least that's what I think of
17:22justin_smithunit / num vs. num / unit
17:22guns:)
17:22justin_smitharrdem: is that your bug?
17:23arrdemjustin_smith: that shouldn't matter.
17:23gunsgtrak: (when-some [v (<!! channel)] …)
17:23tbaldridgegtrak: core.async was what it was created for, you can get into problems with when-let and core.async
17:23gtrakah
17:23justin_smitharrdem: oh never mind you had both defined
17:24gtrakI guess if you pass false, I've not had to do that yet.
17:24gtrakor is there more to it?
17:25tbaldridgenope, that's it
17:25tbaldridgeand no, I never pass false either, but apparently someone does
17:25gunsit can be nice to communicate simple booleans
17:25justin_smithI find a boolean-free-diet helps with that
17:25gtrakseems like it's easier to remember to not pass false than it is to remember to use these :-)
17:26tbaldridgeI kindof agree,
17:26arrdemjustin_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:26gunsI've fallen to basically always using when-some over when-let
17:26tbaldridgeand even then, all the core.async stuff uses (when (not (nil?)) anyways
17:26arrdemjustin_smith: updating to "1.0.1", cleaning and restarting seems to have fixed it.
17:26justin_smitharrdem: oh, glad you found it, because that all looked right to me
17:27gunssomething vs nothing is fundamentally different than truthiness
17:27justin_smithwhen has overloading ever *not* caused issues I wonder
17:27gunsDynamic typing just makes clojurists a little lazy on this
17:28gunsimho
17:28justin_smithalso the "when in doubt return nil" kind of thing
17:30gtrakjustin_smith if exceptions were less awkward..
17:34cbpI wonder what it would take to implement conditions in clojure
17:34AeroNotixcbp: please no
17:34AeroNotixcommon lisp conditions?
17:34cbpyee
17:34AeroNotixnah
17:34cbp:-(
17:34AeroNotixJust a bad idea which was centred around REPL-programming assuming that the application always had someone sat in-front of it
17:35justin_smithgtrak: http://minimemes.net/wp-content/uploads/2014/04/1398375042716.jpg
17:35AeroNotixYou don't want your application to throw up a restart on an AWS instance for example
17:35whodidthishit 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:35AeroNotixthat's just weird
17:35AeroNotixwhodidthis: isn't that similar to the knapsack problem?
17:36TEttingerit's in order
17:36AeroNotix(perhaps it's too late in the day for me to be thinking of algorithms)
17:36AeroNotixTEttinger: but you can't be greedy
17:36rasmustowhodidthis: use a loop w/ 3 bound vars, your list, an accumulator (< 5), and the mini-vector you're building up
17:36AeroNotixrasmusto: but that's greedy
17:37justin_smith(inc rasmusto) ; yep, that's what I would have suggested
17:37lazybot⇒ 11
17:37justin_smithAeroNotix: a vector is already eager
17:37rasmustoAeroNotix: well, he asked for a vector out
17:37AeroNotixI don't mean in laziness
17:37gtrakwhodidthis: partition-all
17:37AeroNotixI mean that you might be able to make better groups analyzing the whole thing
17:37justin_smithgtrak: how would partition-all know the accumulated sum?
17:38justin_smithAeroNotix: I did not read such a task from his example, the order was unchanged
17:38gtrakfilter
17:38gtrakjustin_smith: ahhh
17:38AeroNotixjustin_smith: whatever
17:38AeroNotixunderspecified
17:38AeroNotixback to not caring
17:39amalloyif you don't mind using flatland.useful, whodidthis, it's an easy problem: https://www.refheap.com/6897866b0f83943b5a0e72489
17:40amalloyand that's lazy, of course
17:40gtrakI'd probably use reduce
17:40justin_smithyeah, actually reduce is better than loop (but the same semantics)
17:40amalloysrsly? laziness is a way better default than reduce
17:40arrdemjustin_smith: thoughts on that commented log implementation I've got?
17:41gtrakamalloy: glue's pretty clever
17:41clojurebotHuh?
17:41justin_smithamalloy: I was comparing to loop, not laziness
17:41amalloygtrak: it's amazingly general, but not *quite* so much so that it's useless
17:41gtrakhence useful :-)
17:41rasmustogtrak: It'd use a reduction on a map with 4 entries, right? (xs, mini-vec, current-sum, and result)
17:41amalloyyou can implement all of clojure's partitioning functions, and many more beside, with glue
17:42justin_smitharrdem: looking now
17:42gtrakrasmusto: yea
17:43rasmustogtrak: cool, so yeah, same as the loop thing, but lazy (and more clear arguably)
17:43TEttinger,(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:43clojurebot[[1 3 5] [2 2 1] [3 3] [2]]
17:43amalloyrasmusto: reduce is never lazy
17:44rasmustooh, nm. "glue" was the lazy example
17:44gtrakrasmusto: yea, reduce isn't lazy, just more data-ish
17:44tbaldridgedeclarative is what you are looking for, it's more declarative
17:45gtraki guess that's one way of putting it, I mean more 'reified' I think.
17:45whodidthisthanks guys, clojure so compact ill have to study these for a "while"
17:47TEttingermine isn't very good, but it has no dependencies at least
17:49amalloyif i were writnig this function with no dependencies, it would look like https://www.refheap.com/ced27e80b9d970edd08eb7cde
17:51turbofailhm. it just occurred to me that i barely ever use assoc on vectors
17:51oinksoftwhat is the non-lazy (map)?
17:52arrdemmapv?
17:52justin_smithmapv
17:52justin_smithor doseq, depends what you want
17:52justin_smithor (dorun (map ...))
17:52arrdempmap may be non-lazy :P
17:52justin_smithor (doall map)
17:53gtrakturbofail: ##(assoc [] 20 :kaboom)
17:53lazybotjava.lang.IndexOutOfBoundsException
17:56justin_smitharrdem: that as-> x v with a later for [[k v]] is confusing
17:57justin_smitharrdem: 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:58justin_smithor wait, this would be a way to take linear sound pressure and do dB operations on it
17:59justin_smithbut 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:59arrdemyeah I did some searching and it sounds like by convention the log of a value with units is a scalar
17:59arrdemor meaningless
17:59justin_smitheither I am way confused or this is all wrong
18:00arrdemI just pushed a 1.0.2 that deletes that snippet because you're right, it's silly
18:00justin_smithI was really looking for something meaningful but over my head
18:00justin_smithhah
18:01arrdem:P yeah the reason for the ;; todo: ponder is that I was looking for something complicated myself :P
18:03justin_smithto go linear -> log I think you do a log op on the value, and swap out linear units for log ones
18:03justin_smithso now we have a more complex unit object ?
18:04justin_smithsince a number cannot tell you how to un-curve it
18:04arrdemer. that's interesting...
18:05arrdemyou're right, I could rework this to store everything log base i, but I don't see a reason to do so.
18:05arrdemthe 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:05justin_smitharrdem: or a unit could tell you how to delinearize / linearize for conversions, but that feels quite OO
18:06justin_smiththat may be an acceptible bit of OO though
18:08arrdemyeah. my log math hacks are rusty... with the introduction of calculators I never had to learn log table tricks.
18:11gtrakis there a lein plugin that demonstrates making derived source-artifacts available on the classpath?
18:11justin_smitharrdem: as long as a conversion is reversible you could have various arbitrary curve defining converters (with log just being a simple example)
18:11justin_smitharrdem: for example in audio we have sones which take both frequency and log pressure intensity into account
18:12arrdemjustin_smith: that'd be nice... I've been kinda frustrated that powers of ten on the same type don't silently convert.
18:12justin_smitharrdem: well that's not a curve, but a similar but simpler concept
18:12justin_smithbut yeah, the same system could have silent promotion of SI units
18:12arrdemjustin_smith: I'm gonna grab food, but I'd love to seen an example
18:16justin_smitharrdem: never mind about sones, that is not a reversible unit, it is a multi-variable nonlinear formula, apples and apple shaped bricks
18:20arrdemsince I'm musing about conversions I wonder if I can bolt meajure atop either frinj or minderbinder...
18:21coventry`Tekhne: I've found this macro handy for working through 4clojure problems. https://www.refheap.com/79836
18:21justin_smithcoventry`: that is very cool
18:22arrdemisn't that equivalent to clojure.test/are?
18:23amalloycoventry`: 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:23justin_smithbut it uses the 4clojure _ format
18:23coventry`https://github.com/tonsky/datascript
18:24coventry`You had me kicking myself for not cloning it earlier for a second there. :-)
18:30coventry`The parameter vectors need to go inside the lists.
18:40coventry`martinklepsch: (mapcat (fn [[k v]] (map (partial vector k) v)) name-map)
19:44coventry`dnolen_: thanks.
20:22mudgenhello
20:23mudgenhow is the clojure programming going everybody?
20:23nightflylispy
20:24mudgengreat
20:31arrdemmudgen: http://i.imgur.com/5PfDzhS.png
20:31arrdemmudgen: https://pbs.twimg.com/media/BdZYs5lCUAAGVEy.png
20:31arrdemtoo many doges. can't link the right one. plz help
20:42hlshipmudgen: let me check for you
20:42hlshiphow is the clojure programmng going?
20:42hlshiphlship: let me check for you
20:42hlshiphow is the clojure programming going?
20:42hlship...
20:43nightfly(going? clojure-programming)
21:02FrozenlockAnyone knows how to deactivate the markdown support in tower?
21:04fitzohAnyone 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:08reiddraperI've pushed some more docs up to test.check: https://github.com/clojure/test.check/blob/master/doc/generator-examples.md
21:12Frozenlocknvm, I just needed to add '!' at the end of my keyword to keep the text as is.
21:24arrdemreiddraper: first example in that link, missing lparen on the requre =P
21:24arrdems/l/r/g
21:25reiddraperarrdem: fixed, thanks
21:25arrdemreiddraper: 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:26arrdemalso why's the "anything but 5" example entitled anything but 13?
21:26reiddraperarrdem: poor proof-reading :)
21:27arrdemreiddraper: you should see my reddit posts... 200 LoC for statistics and analytic econ, 0 proofreading
21:28arrdemalso the reid's have kinda got to stick together... proofreading is hard anyway :P
21:28reiddraperarrdem: 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:28reiddraperarrdem: ha, yes indeed re: reid
21:29arrdemreiddraper: awesome library, I look forwards to using it!
21:29reiddraperarrdem: appreciate that
21:30arrdemwill report further typos loudly and publicly as I notice them =D
21:31reiddraperplease do :)
21:31ghadishaybanfitzoh: your :else clause is outside the cond
21:32fitzohghadishayban: thanks, I’m slowly making progress… was also using seq as a variable :x
21:35ghadishaybanfitzoh: np. happy to help. Also -- careful with shadowing names like 'chan
21:36ghadishaybancouple 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:38ghadishaybanso it's implicitly distinguishing between the timeout and the end of items (both make nil values)
21:38fitzohthat part’s intentional, I don’t *think* I care about the timeout channel, just using it a way to kill the process
21:38fitzohlemme get an updated paste, think I’m just about there
21:39fitzohhttps://www.refheap.com/80103
21:41ghadishaybanfitzoh: 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:42ghadishaybanfitzoh: more pedantry: seq is being shadowed
21:43fitzohaye, 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:43ghadishaybanfitzoh: whoops was looking at wrong paste
22:15kelseygithis question is a bit confused
22:15kelseygibut if i have a persistentvector
22:15kelseygiand i call map over it
22:16kelseygiand then filter the result
22:16kelseygithe resulting vector isn't lazily evaluated, right?
22:16kelseygilike, two passes have been made over the vector?
22:16eggheadno kelseygi
22:16eggheadit is O(n)
22:16eggheadso single pass
22:16eggheadand yes the result is lazy
22:16eggheadit builds up a lazy chain of operations over each item in the collection
22:17kelseygiah ok interesting
22:17kelseygiso is map + filter equivalent to doing a for with a :when expression in it?
22:18eggheadya kelseygi you can look at it like that
22:18eggheadexcept for comprehensions can do all sorts of other crazy things like cross products
22:19kelseygiright
22:19kelseygiif i don't want that though sounds like it's a readability/style question then?
22:21eggheadI don't think for is lazy
22:21eggheadso for example with map/filter/etc you can return lazy lists, for other people to make further transformations to
22:22joegallofor is lazy
22:22eggheadnvm then :)
22:23joegalloi think of map and for as being just slightly different syntax for the same sort of operation...
22:23joegallothere 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:24joegallowhen the fn in your map becomes too big, then you can jump to for before jumping to a named def'd fn
22:24joegallobut its just an alternate syntax
22:25joegallo(i know, i know, they handle multiple seqs differently and stuff...)
22:27kelseygiok, i was deciding between mapping w/ a named function and (for [seq] blah blah)
22:27arrdemOkay, so I've created a reader literal implementation... how do I make Clojure pr to the reader literal? custom .toStr implementation?
22:27joegalloyeah, if it's a named fn already, then just stick with map, i'd say
22:28kelseygiif i also need to filter, would you still recommend that?
22:28joegallo(for [x some-seq] (inc x)) is way better as (map inc some-seq)
22:28joegallototally
22:28jack_rabbitIn what package do I find the trigonometric functions
22:28joegalloalthough you might want to join my cult of ->>
22:28arrdemjack_rabbit: they're all already present in Math/
22:28arrdem,(Math/sin (/ Math/PI 2))
22:28joegallo,(Math/sin 3.14159)
22:28clojurebot1.0
22:28clojurebot2.65358979335273E-6
22:28jack_rabbitarrdem, thanks.
22:29jack_rabbitarrdem, what namespace is that? A clojure one, or a java thing?
22:29arrdemjack_rabbit: it's a hack to expose the Java math library
22:29jack_rabbitgreat.
22:29jack_rabbitThanks for the help. I've been googling for like 10 minutes.
22:29arrdemjack_rabbit: which is usually a feature... if you have custom numeric types then clojure.algo.generic is your project.
22:30jack_rabbitno, nothing fancy for me. :)
22:30arrdembut you can have metadata with your numbers!*
22:30arrdem* at a massive slowdown
22:30joegallokelseygi: that is, (filter even? (map inc (range 5))) is lovely code, but there's nothing wrong with (->> (range 5) (map inc) (filter even?))
22:30kelseygijoegallo trying to decipher the diff between -> & ->> right now
22:30joegallo(but with newlines where i have lots of spaces)
22:30joegallokelseygi: ->> puts things in as the last argument, but -> puts them in as the first
22:30arrdemkelseygi: -> threads the first form into the first position of subsequent forms. ->> threads the first form into the tail position.
22:31joegallowhich 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:31arrdemand you want as-> for things that mix the two :P
22:31joegallodon't cross the streams, arrdem!!!
22:31joegallo:)
22:32technomancyI had to debug some code in leiningen that nested three ->>s inside another ->>
22:32joegalloswoon
22:32technomancyit was buggy, but no one noticed because of all the obfuscation
22:33FrozenlockMy limit is 2 ->>. After that I use `let'.
22:33kelseyginow i'm trying to figure out why the examples here wouldn't work with -> http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E
22:34technomancyand one of the arrows was for a single call, not even a chain
22:34Frozenlocko_O
22:35joegallokelseygi: it's where things end up. (->> (range 5) (map inc)) ends up being treated as (map inc (range 5))
22:35joegallobut if you used ->, then it would be treated as (map (range 5) inc)
22:35joegallowhich doesn't make any sense at all ;)
22:36kelseygiok
22:36kelseygijeez, light table makes me feel stupid
22:37kelseyginow that i finally got a damn repl open i see it :P
22:38arrdemkelseygi: if it makes you feel any better, I've stuck with Emacs because I couldn't figure out the repl either :P
22:39arrdemthoughts... is a macro justified her? https://www.refheap.com/80114
22:59tolitiusdnolen_: 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:39kwertiiSuppose 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:46kwertiiGiving a parameter in the constructor and having the implementation select the appropriate execution seems clunky
23:51gunskwertii: that's less clunky than 2 different record types
23:52kwertiiguns: that's what I was thinking, too :/
23:52kwertiibut I can't think of a better option
23:53kwertiiI 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:53gunsthat sounds the opposite of DRY :)
23:54kwertiiThe source code, I mean
23:54kwertiiYou'd write 1 function for each implementation method, and if they change, just auto-regenerate the records
23:54gunsyes, I realize. macros. but then you run into equality issues
23:55kwertiiyes.
23:55gunsI think a case statement in the protocol implementation -> different functions sounds fine
23:56kwertiiPractically speaking, it will be fine in my particular case, but it's really fragile as a general solution
23:56gunsDo you need a general solution? You're looking for a record factory then…
23:57gunsanyway, I'm only piping up because nobody else in the channel is listening
23:57kwertiiI 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:58kwertiiThis is trivial to solve in oo, and completely non-obvious in Clojure
23:58gunsyou can use definterface to extend a set of interfaces