#clojure logs

2015-01-01

01:05zophyit is very good for you to have me wishing you a happy new year !!
01:39rhg135I dont know yall well but i love you all and heres to even better code in 2015
01:50woortHey what is the command character for clojurebot?
01:51rhg135, i think
01:51clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: i in this context, compiling:(NO_SOURCE_PATH:0:0)>
01:51jwmhappy newyear
01:51woortnice, thank you
01:51woort,(+ 1 1)
01:51clojurebot2
01:52rhg135,(-> #'map meta)
01:52clojurebot{:ns #<Namespace clojure.core>, :name map, :added "1.0", :file "clojure/core.clj", :static true, ...}
01:52rhg135Grr
01:53rhg135,*clojure-version*
01:53clojurebot{:interim true, :major 1, :minor 6, :incremental 0, :qualifier "master"}
01:54rhg135why is it a dynamic var tho?
02:45kenrestivodoes core.async get upset when some consumers/producers of channels are go loops and others are jvm threads?
03:08rhg135kenrestivo: no which is great
03:09kenrestivothanks. trying to troubleshoot deadlocked/stuck threads in a production-sized app is not fun.
03:09kenrestivoeven converting everything to go loops, still something somewhere is locking up channels.
03:10rhg135id avoid threading till needed. Core.async wont care
03:26rhg135Good night #".+"
04:07dagda1_this comparison returns false (= [["dog"] ["cat"]] [["cat" "dog"]]) is there a way to compare that would compare irrespective of the order of the elements?
04:07dagda1_I mean this (= [["dog"] ["cat"]] [["cat"] ["dog"]])
04:09dagda1_this works (= (set [["dog"] ["cat"]]) (set [["cat"] ["dog"]]))
04:18cflemingIs it possible to macroexpand but to retain the line and column metadata?
04:18cflemingI can't get it to work.
04:19cfleming.(binding [*print-meta* true] (pr-str (read (LineNumberingPushbackReader. (StringReader. "(let [x (+ 2 3)] x)")))))
04:19cfleming,(binding [*print-meta* true] (pr-str (read (LineNumberingPushbackReader. (StringReader. "(let [x (+ 2 3)] x)")))))
04:19clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: LineNumberingPushbackReader, compiling:(NO_SOURCE_PATH:0:0)>
04:19cflemingBah
04:20cflemingAnyway, that returns "^{:line 1, :column 1} (let [x ^{:line 1, :column 9} (+ 2 3)] x)" as expected
04:21cflemingProduces "(let* [x (map nil nil)] x)"
04:22cflemingSorry, "(let* [x (+ 2 3)] x)", rather
04:22cflemingAll the line and column data has been stripped off
04:24cflemingIt seems that I can add metadata, but any metadata added to lists is removed - I guess this is because lists are always replaced with their macroexpansions?
04:27amalloycfleming: the compiler ordinarily sets the metadata itself, but macroexpand isn't the compiler
04:28cflemingamalloy: But in this case it's not preserving metadata that I've set either
04:28cflemingamalloy: I can set ^:test on the arg vector or the binding symbol, but if I set it on (+ 2 3) it gets lost
04:29cflemingamalloy: This also happens with riddley, which surprised me
04:29amalloyclj-865 iirc is one that mentions this
04:29amalloy$google clj-865 jira
04:29lazybot[[#CLJ-865] Macroexpansion discards &form metadata - Clojure JIRA] http://dev.clojure.org/jira/browse/CLJ-865
04:29amalloyi guess not, really. but related
04:30cflemingI was going to say that's the most surprising thing I've seen lately, but there are so many...
04:30cflemingWhat a PITA
04:31amalloyoh wait, you used clojure.walk/macroexpand-all?
04:31amalloyman, just never use that function
04:31amalloyit gets the easy cases right-ish, but misses a lot of subtleties
04:32cflemingamalloy: This also happens with riddley
04:32cflemingWhich is what I tried first
04:33amalloyriddley maps over lists, as i recall
04:33amalloybecause it has to look for macros inside the list to expand
04:33amalloyand of course map doesn't preserve metadata
04:34cflemingamalloy: https://www.refheap.com/95637
04:34cflemingNo, riddley isn't using map as far as I can see
04:35cflemingIt has its own walking function
04:36amalloyi was thinking of https://github.com/ztellman/riddley/blob/master/src/riddley/walk.clj#L228, cfleming
04:36amalloyits walking function uses map
04:37amalloybut anyway your example is a weird one, because the list you provided doesn't even exist in the output at all, so it's kinda not that surprising that the metadata you put on it doesn't appear
04:38cflemingRight, but intuitively it seems like you would want the metadata for a macro form to be preserved on the expansion
04:38cflemingMaybe that's not intuitive, I dunno - it seems like it to me
04:49zophyi should be able to map println over a persistent list, correct ?
04:50amalloyyes, zophy, but it will all end in tears
04:51amalloy~map
04:51clojurebotmap and the other sequence functions used to be lazy, but with the advent of chunked sequences, may or may not be lazy, consult your local ouija board
04:55SagiCZ1zophy: i think you are looking for doseq
04:55SagiCZ1,(doseq [e (range 5)] (println e))
04:56clojurebot0\n1\n2\n3\n4\n
05:04zophySagiCZ1, and amalloy, thanks, i can get it to work with doseq :)
05:06zophyheh, map worked for this in the cider-repl...
05:09SagiCZ1map does work but it is lazy so you have to force the evaluation with doall.. and it collects the result thus wasting memory
06:18zot1happy 2015! any other lively nerds in here?
06:18zot1i'm playing with misaki, and have never seen the #- form before — what does it do?
06:19zot1or is this perhaps part of his dsl in some way i can't yet track down?
06:20wagjozot1: cljx maybe?
06:21zot1could be — i've never touched cljx
06:22wagjozot1: feature expressions, so that yhou can use same source file for both CLJ and CLJS
06:23zot1interesting
06:23zot1(inc wagjo)
06:23lazybot⇒ 1
06:26wagjothanx
06:51mi6x3m-althey llasram, I managed to fix the issue
06:51mi6x3m-altby delaying the initialization of the decorator
06:52mi6x3m-altI moved it to a method called initialize() which is invoked after the instance is constructed
10:21zophy~seq
10:21clojurebotTitim gan éirí ort.
10:25zophypog mo thoin
10:36mi6x3mhey llasram, you here by any chance?
12:15dagda1_if I have a set like this (def a #{["cat" "man"] ["man" "snake"] ["spider" "cat"]}) then why is (first a) ["man" "snake"]
12:16mfikesTry (seq a)
12:16adulteratedjedior ffirst
12:17mfikes(The order is not defined, right, so any other element could be first in the seq)
12:19dagda1_mfikes why is it always ["man snake"
12:20dagda1_even (first (vec a)) returns ["man" "snake"]
12:20mfikesdagda1_: For that particular literal, the hash codes produced will be deterministic, but undefined. (Not truly random.)
12:20dagda1_mfikes: ah right, the hashcodes determine it, that makes snese
12:50andyfdagda1_: There is a set implementation in a library that preserves items in the order they were added, if that is useful to you. Also several ordered map variants that sort on insertion order, by values, or by a specified list of keys. See the cheatsheet for links to them: http://jafingerhut.github.io
12:53justin_smithdagda1_: maybe it's helpful to know that a hashset #{} is implemented as a tree, sorted by the hashcode
12:53dagda1_justin_smith: yes, that makes sense
12:53justin_smith,(hash ["cat" "man"])
12:54clojurebot12869706
12:54justin_smith,(hash ["man" "snake"])
12:54clojurebot1160122883
12:54justin_smithI guess there's still something I don't get, because I would have expected the "first" item to be the one with the smaller hash code
12:55justin_smithclearly it's not that simple
12:57dagda1_justin_smith: no, it can't be size, but there is a consistent algorithm
13:07andyfjustin_smith: Even for sets with the same set of elements, and are thus equal, the seq orders may be different, because hash collision items are put into linked lists in order of addition to the set.
13:07andyfi.e. it is possible (fairly rare) to have (= s1 s2) but (not= (seq s1) (seq s2))
13:14seangroveCan anyone help point out the problems in cljs (and tooling) that come from not having reified namespaces?
13:14seangrovecemerick ^^
13:17mi6x3mandyf: sounds fairly possible to me
13:27irctcshould I use deftype, records, or zippers to represent trees in clojure?
13:27irctcquad trees to be specific
13:27mi6x3mwhy not vectors or normal sequences?
13:28irctcmi6x3m: how would you recomend they be structured
13:29arrdemirctc: what problem are you trying to solve and why do you feel that a quad tree is in order
13:30irctcarrdem: looking for clusters of points in 2d space
13:31irctcarrdem: most of my points should be spread out in a path
13:32irctcarrdem: but occassionaly there may be clusters with a certain patter, I thought if the quad tree has a certain depth it indicates that there is more activity there
13:34arrdemso I don't think that bringing a deftype in will actually help you here
13:36arrdemthe advice I usually see given here is that you want to prototype with a map or some other easy to work with structure and then once you get that nailed down switch to a class generating thing which is a little less flexible.
13:37irctcarrdem: what class generating thing? records?
13:39arrdemirctc: deftype and defrecord both emit a customized class which can cause problems when you're working at a REPL
13:40arrdemhiredman has been quoted repeatedly steering people away from those, not that they don't work they just have pitfalls.
13:41irctcyeah i was trying to avoid them, but all the examples for trees in clojure are using these two
13:41irctcwhen defining custom data structures, (like quad trees or whatever) I don't need to make it a new type
13:41andyfAs was mentioned earlier, you can make trees with nested maps.
13:41irctcright?
13:43andyfIf you want different types of "nodes" in your tree, you can have a :kind or :type key with a value that tells you what 'type' it is.
13:43irctcarrdem: I actually did that, adding stuff blows up the stack though, I could try switching the recursive calls to loop/recur, but it seemed like zippers would help
13:44irctcarrdem: this is what i had
13:44irctchttp://pastebin.com/1GFqvxj6
13:48andyfirctc: There is a call to add-points with the wrong number of args in there, yes?
13:50irctcandyf: oh there might be
13:53andyfYou never have x or y coordinates the same as in other points? If you do, next-quad will return nil
13:55andyfIt seems like how balanced this quad-tree is depends heavily about the value of :len, and how spread out the points are that you are adding.
13:56andyfSeems you could easily end up with a long skinny tree with very little or no branching.
13:56andyfs/heavily about/heavily upon/
13:57andyfI haven't implemented a quad tree before, or looked at what variants exist, but I'd bet there are rebalancing variants that are more complex to implement, but guaranteed to avoid that problem regardless of the order in which points are added.
13:59justin_smithandyf: a quick search tells me for balancing you want k-D trees, which are a superset of octrees, which are a superset of quadtrees
14:01justin_smithbut it is trickier than regular balancing via rotation, because these trees have extra invariants that a linear tree does not
14:01andyfthat wouldn't surprise me.
14:02justin_smiththat is, you can see a normal red-black tree as a balanced 1d tree, where a quad tree is a unbalanced 2d, octree unbalanced 3d, k-d-tree balanced n-d
14:03justin_smith"The algorithm checks whether there could be any points on the other side of the splitting plane that are closer to the search point than the current best. In concept, this is done by intersecting the splitting hyperplane with a hypersphere around the search point that has a radius equal to the current nearest distance."
14:03andyfI also wouldn't be surprised if there is a rebalancing quad-tree for 2d that avoids some of the complexity of higher dimensions.
14:04justin_smithcould be, but k-d generalizes both up and down
14:21irctcandyf: that's probably true
14:21irctcandyf: yeah, i didn't account for edges
14:23rritochDoes anyone know how to fix a multiline regex so it doesn't break the java stack if there's no end to the match? https://github.com/rritoch/lein-sablecc/blob/master/src/leiningen/sablecc/compile.clj#L33
14:24rritochI made this code to strip out block comments so it would ignore any Package declarations in comments, but if there's a '/*' in the grammar, and no comment to close it /* */ I get a java stack error.
14:38kenrestivohuh, i've run into a situation where async/alts! locks up hard, even if there's a timeout, the timeout never fires.
14:38kenrestivo(async/alts! [kill-chan ins (async/timeout timeout)])
14:39kenrestivoaccording to tools.trace, alts! gets called, but never returns.
15:10ticking_I wonder why clojure allows for nil in collections while it disallows it in chans. Hindsight?
15:15godd2ticking_ perhaps because in a channel, you can be waiting for the next thing. You wouldn't shove nil through a channel, because empty space is simply waiting for the next thing to process. however in a collection, the space between members is discrete, so the only way to represent empty space between members is with nil.
15:16godd2since the default is "sit there and do nothing" for a channel, it's redundant to send a message which tells it to not do anything
15:16ticking_godd2: good explanation, but I wonder if :custom/nothinghere elements would be cleaner
15:17godd2Well I mean, if you think of the real world, sure, you can always send someone an empty box.
15:17justin_smithticking_: checking for truthy vs. falsey is more concise than checking for :custom/nothinghere
15:18godd2but it doesn't make sense to, let's say in a restaurant, send a cook an order with nothing on the ticket.
15:18ticking_nil to me is the value of "something nonsensical" so a collection with elements of a certain problem domain should contain the placeholder elements of said domain
15:18justin_smithmaybe the empty message could just be :yo/sup
15:18hellofunki'd enjoy any tips on making this little algorithm more elegant, which i'm sure is possible: https://gist.github.com/hellofunk/caf3de6b465d6e2ab2f6
15:18godd2ticking_ ah, well I'd say that nil isn't "nonsense", its just not anything else
15:19godd2its the answer to the question "what is a number which is even and odd?"
15:19godd2the question isn't nonsense, the answer is that there aren't any
15:20ticking_justin_smith: yeah but I would rather dispatch on my custom element than have an ambiguous (first []) (first [nil]) :/, maybe it's just a matter of taste though
15:21borkdudehow to check for byte-array with prismatic/schema?
15:22ticking_godd2: you mean as in (and (even? x) (odd? x)), but the answer to that is ironically false :P
15:22ticking_,(and (even? 0) (odd? 0))
15:22godd2no, that's the answer to the question "is this number even and odd"
15:22clojurebotfalse
15:23borkdudegot it (Class/forName "[B")
15:23godd2which is different from what I stated previously
15:24ticking_godd2: if you mean that the answer to "what is a number which is even and odd?" is nil, I'd disagree to
15:24godd2ticking_ oh? you have a different answer?
15:25ticking_godd2: ah good I understood correctly now :), yeah because nil is not a number
15:25godd2:P
15:26godd2now, in the restaurant example, if the cook came up and asked the servers if there was any work to be done, then nil would make sense, but that wouldn't be a channel anymore
15:27ticking_godd2: In the restaurant example I would expect the waiter to return a collection
15:27ticking_godd2: same goes for the ticket of work to be done
15:27ticking_godd2: clojure separates nil from '() for that reason right?
15:28godd2ticking_ right. its the difference between "give me the number which..." and "give me the list of numbers which..."
15:28godd2because an empty list has properties which nil does not
15:28godd2for example, you can put things into an empty list, but you can't put anything in nil
15:29ticking_I think a lot of bugs could be prevented if (conj [] nil) would be the identity
15:29godd2ticking_ perhaps, but you might also introduce other bugs
15:29ticking_,(conj nil 1)
15:29ticking_you think so ? ;P
15:29clojurebot(1)
15:30ticking_godd2: nil is the end of seqs as well as the empty map
15:30godd2,(cons nil 1)
15:30clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
15:31ticking_at least when it comes to operations that take them
15:31ticking_,(cons 1 nil)
15:31clojurebot(1)
15:31godd2,(cons '() 1)
15:31clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
15:32ticking_,(cons 1 '())
15:32ticking_conj and cons have reverse arguments
15:32ticking_godd2: yeah, but I wonder how we'd code if we didn't live in the constant fear of a nullpointer exception like the haskellers
15:32clojurebot(1)
15:32AimHereMaybe we'd code like the haskellers
15:33godd2ticking_ well I mainly code in Ruby, so I don't have that fear ;)
15:33ticking_AimHere: is that good or bad in you opinion :D
15:44ticking_godd2: A nice side effect would be that map could filter and assoc could dissoc, so no longer a need for the non existent dissoc-in
15:44ticking_godd2: the biggest downside I see is that (assoc [0 1 2] 1 nil) is inefficient in the current vector implementation
15:44borkdudecan you collect "normal" args in a list like (defn f [x y :as z] z)?
15:46simonAloha!
15:47simonIm quite new to clojure and are writing a blackjack game, and I represent a hands value as a list of lists since Aces can be either 1 or 11. I wanna define a function that calculates the set of possible values of a set and needs a way to combine a lists of lists to all the different lists that can be combined from them.
15:48simonThat is probably a bit confusing.
15:48simonBut in explenation.
15:48simon[[10] [9] [10]] -> [[10 9 10]] , [[5] [1 11]] -> [[5 1] [5 11]], [[1 11] [1 11]] -> [[1 1] [1 11] [11 1] [11 11]]
15:48andyfCross product, or Cartesian product, are two names for that.
15:48simonUsing the returned lists I wanna map a + reduce to get the different values.
15:49simonYeah, im using cartesian product to generate my deck.
15:49simonBut I dont relaly know how to do it for a list of lists, if that makes sense?
15:49andyfIf you want a library to help with that, with source code you can look at, math.combinatorics has it.
15:50simonOkok, thanks.
15:50andyfLibrary in general: https://github.com/clojure/math.combinatorics The particular function: https://github.com/clojure/math.combinatorics/blob/master/src/main/clojure/clojure/math/combinatorics.clj#L117
15:51andyfThat isn't necessarily a beginner-level function to read and understand easily, necessarily.
15:52andyfdepartment of redundancy department -- the number of times I reuse words in a sentence that I don't re-read and edit is alarming.
15:52simon:)
15:55simonSweet! Clojure is so neat. (apply ../cartesian-product (into () [[5] [1 11]])) -> ((5 1) (5 11))
15:55TEttingerthat shouldn't work, should it?
15:55TEttinger.. is already a symbol
15:55simonclojure-blackjack.core> (apply combo/cartesian-product (into () [[1 11] [5]]))
15:55TEttinger(doc ..)
15:55simon((5 1) (5 11))
15:56clojurebot"([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on the result, etc. For instance: (.. System (getProperties) (get \"os.name\")) expands to: (. (. System (getProperties)) (get \"os.name\")) but is easier to write, read, and understand."
15:56simonI didnt want to write out the library name.. :P
15:56TEttingerheh
15:57TEttinger,(for [a [5] b [1 11]] [a b])
15:57clojurebot([5 1] [5 11])
15:58TEttinger,(for [a [5] b [1 11]] (list a b)) ;for completeness
15:58clojurebot((5 1) (5 11))
15:58simonHmm, im a bit confused, the (into () ..) bit is uneccecary. So how how does (apply ../cartesian-product [[1 11] [5]]) work?
15:58simonSo you can apply functions to a sequence I guess and not just lists?
15:59TEttinger(into () [[5] [1 11]]) is the same as (list [5] [1 11]) and usually you don't need to ever use lists, vectors work in most of the same places
15:59simonNeato.
16:00Ent_(repeat 10)
16:00andyfsimon: cartesian-product is written to take a variable number of sequences as arguments
16:00simonandyf: yeah, that I understand.
16:00TEttingerit's called the seq abstraction in a lot of stuff that talks about clojure
16:00andyfIf it had instead been written to take a sequence *of* sequences, then apply would not be needed there.
16:00simonIts the apply that boggles my mind now. :)
16:01Ent_(take 1 (repeat "Hi"))
16:01andyfAs maybe a simpler example, + is written to take a variable number of arguments:
16:02andyf,(+ 1 2 3 4 5)
16:02clojurebot15
16:02Ent_,(take 1 (repeat "Hi"))
16:02clojurebot("Hi")
16:02Ent_,(repeat 10)
16:02clojurebot(10 10 10 10 10 ...)
16:02andyfbut you can't get a useful result calling it with 1 sequence:
16:02andyf,(+ '(1 2 3 4 5))
16:02clojurebot#<ClassCastException java.lang.ClassCastException: Cannot cast clojure.lang.PersistentList to java.lang.Number>
16:02andyfIf you have a sequence of numbers, and want to add them up, one way is to use apply:
16:02andyf,(apply + '(1 2 3 4 5))
16:02clojurebot15
16:02simonMy mental image of apply is that it just moves in the function into the list. i.e (apply str '(1)) => '(str 1) => (eval '(str 1))
16:03simonBut from the implementation of apply its clear thats not how it works.
16:03justin_smithsimon: ##(apply + 1 2 3 [4 5 6])
16:03lazybot⇒ 21
16:03Ent_,( #(+ %) '(1 2 3 4 5))
16:03clojurebot#<ClassCastException java.lang.ClassCastException: Cannot cast clojure.lang.PersistentList to java.lang.Number>
16:03andyfThe implementation of apply is a bit lower-level code than most Clojure
16:03andyffor performance reasons.
16:04andyfThere are other ways to write it that would look more like the way you described it in words.
16:05andyfIf you have a number of arguments that is known when you are writing the code, there isn't much reason to use apply. It is necessary to use apply in cases where you have a sequence of arguments at run time, and you don't know how long it is.
16:07simonSo, an implementation using apply is not idiomatic in this case you say?
16:07Ent_,( #(+ %) [1 2 3 4])
16:07simonhttp://pastebin.com/1C384QqL hand-value, at the end of the file.
16:07clojurebot#<ClassCastException java.lang.ClassCastException: Cannot cast clojure.lang.PersistentVector to java.lang.Number>
16:07justin_smithEnt_: what are you trying to do?
16:07andyfThe example of (apply + '( 1 2 3 4 5)) I would never write that way except as an example. I would write it (+ 1 2 3 4 5)
16:08Ent_seeing if I can do `apply` without using apply
16:08ticking_(fold + coll) for really large cols ;)
16:09justin_smithyeah, you can use reduce instead of apply for things like +
16:09justin_smith,(reduce + [1 2 3 4 5 6])
16:09clojurebot21
16:09justin_smithticking_: assuming by fold you mean reduce
16:09kenrestivoi wonder if the universe will explode if i do somthing to the effect of (async/go-loop [] (let [res (async/<! c)] (async/>! c (do-stuff res))))
16:09Ent_Ah that makes more sense
16:09Ent_thanks
16:10ticking_justin_smith clojure.reducers/fold
16:10justin_smithahh
16:10kenrestivoespecially since do-stuff can block
16:11justin_smithkenrestivo: locking vs. blowing?
16:11kenrestivoum, blowing?
16:11justin_smithup
16:11kenrestivolocking up, is what i've been experience
16:11ticking_simon, who said it was not idiomatic :)? sorry I missed the start
16:12kenrestivoi'm starting to think this message bus idea was very, very stupid.
16:12kenrestivobut it's hard to do this with discrete channels since there are circular relationships betwen the various components that need to communicate. a "network-like" bus with routing is optimal.
16:12ticking_btw does someone know of a clojure lib that takes two edn datastructures and returns a Om style assoc-in able diff?
16:13kenrestivoi feel like i'm trying to make core.async do stuff it was not designed to do.
16:14justin_smithkenrestivo: a good pattern is to take coordination vs. work that may block for a while, and put them in separate contexts, so there is always a quick response time from the coordinator
16:15kenrestivothat might work, a central router rather than a bus topology.
16:16justin_smiththe router can even split into more than one parallel unit, as long as none of them lock up on long running tasks
16:17justin_smithalso, Java Concurrency in Practice is a surprisingly good book, one of the items on the "Clojure reading list", worth looking at even if you aren't doing Java
16:17kenrestivoyeah, i feel like part of the problem is i do not have a deep understanding of what-all is going on under the hood in the jvm.
16:18ticking_I domt thi
16:18ticking_I dont think the people writing the jvm have that
16:19Muonickenrestivo: I've only just started looking at core.async, but it doesn't feel well suited to functioning as a message bus
16:20kenrestivothanks for the sanity check.
16:20Muonicmostly since multicasting doesn't fit in the model
16:20kenrestivowell there's pub/sub
16:20kenrestivoand mult/tap
16:22SagiCZ1whats the cure for a function that takes too many arguments?
16:22ticking_Yeah they seem to handle multicast reasonably well, even though some buffering is required
16:22Muonici was thinking, in the sense you mayw ant multiple recievers to get the same message
16:22Muonicit becomes awkward trying to use mult/tab + pub/sub to acheive that effect
16:22ticking_Muonic, yeah that is what mult is for
16:24ticking_really? hm, but creating a chan and tabing with it seema like its equivalent to a bus subscribe right?
16:25ticking_SagiCZ1, depends, an opts map?
16:27SagiCZ1cfleming: it would be nice to have some support of (:require [... :reger [list-of-symbols]]) ... for example if i already have some there, i would like to have new ones added automatically with alt+enter.. and if the caret is in the list-of-symbols, it could show all available symbols for refering on ctrl+space
16:29SagiCZ1cfleming: and other cool thing would be a better support of variable extraction (default ctrl+alt+v) which doesnt work well and doesnt work at all in repl console.. just throwing it out since i always forget these
16:29kenrestivoticking_: there's some ceremony with pub/sub, less so with mult/tap
16:30kenrestivoand the ceremony of pub/sub with mix becomes quite cumbersome. makes me think i'm Doing It Wrong.
16:30cflemingSagiCZ1: Yes, the better support for refer is definitely on the cards
16:31cflemingSagiCZ1: Do you have examples of the variable extraction not working?
16:31SagiCZ1it does work but i dont think i understand how can it help me.. it just replaces the selected sexp or value with the symbol 'value'.. i would expect it to be defined in the let or in root via def if there is no enclosing let
16:32ticking_kenrestivo: hm, yeah such a tight feedback loop with a channel feels a bit weird, but on the other hand if one imagines a channel as a queue it's not that strange
16:33ticking_feels like a infinite computation, but there are things hidden in our code everywhere just not as obvoous and scary
16:33cflemingSagiCZ1: When you do the extract, you have to select two things, the expression to extract, and where to extract it to
16:33cflemingSagiCZ1: At the point that you tell it to extract to, you'll get a new let binding
16:34cflemingSagiCZ1: If you select an existing let binding as the extract point, it will be added to that.
16:34lxsameerhey guys, how much clojure-android is slower than java on android ? is it noticeable ?
16:34cflemingSagiCZ1: I think what you're running into is a bug if you try to extract to the same point you're extracting from
16:35SagiCZ1cfleming: oh! it does work.. i didnt read the tooltip.. i thought it wanted me to select what i want to extract, which is something intellij does for java sometimes.. so i was choosing the lowest possible insertion which just replaces it with "value" .. but choosing enclosing let works fine
16:35cflemingSagiCZ1: Great - yeah, I need to fix that bug, it's almost never what you actually want to do but it's easy to do by mistake
16:36SagiCZ1cfleming: ok, but in repl the shortcut does nothing.. maybe its shadowed by something by my own settings
16:36cflemingSagiCZ1: I'll test that, it may be that it doesn't work - the REPL editor is subtly different in annoying ways
16:36Ent_@lxsameer I think it's quite slow. Atleast the time it takes for the app to start is quite long.
16:36cflemingSagiCZ1: If it doesn't work I'll fix for the next drop
16:37lxsameerEnt_: damn, thanks ,
16:37SagiCZ1cfleming: alright.. thanks for the info :)
16:37cflemingSagiCZ1: No worries!
16:37Ent_Yep, sure
16:39cflemingSagiCZ1: BTW for the extraction point selection I'm planning to add support for using ctrl-up/down to select only existing let bindings, since that's often what you want to do
16:40SagiCZ1cfleming: good idea, i am excited about this feature, i use it all the time in java
16:40cflemingSagiCZ1: Yeah, it's really useful
16:41cflemingSagiCZ1: I'll be adding extract method too sometime soon
16:41cflemingSagiCZ1: BTW inline binding works too, which I also use a lot
16:41SagiCZ1cfleming: what is that?
16:42cflemingSagiCZ1: If you no longer need a variable as a local binding, you can inline it and the uses will be replaced with the binding body, like inline variable in Java
16:42SagiCZ1cfleming: so thats basically extracting variable backwards?
16:43cflemingSagiCZ1: exactly
16:43SagiCZ1cfleming: hey this is way cool, i didnt know about this one, never used it.. smart
16:44SagiCZ1this will save some time too\
16:50justin_smithEnt_: some folks have addressed the startup time on android issues by compiling clojurescript (which has minimizing / tree shaking compilation via google closure)
16:51Ent_justin_smith: Oh. Guess the video I saw discussing it is now outdated.
16:54justin_smithoh, oops, meant to address that to lxsameer
16:55lxsameerjustin_smith: clojurescript ? I thought we use clojure itself
16:56justin_smithlxsameer: the point is clojurescript can load much faster / use less of the device's ram
16:56justin_smith(though it won't likely perform as well for a long running / computation heavy process, but that isn't the only kind of process you have in a mobile app)
17:00mfikeslxsameer: Sam Beran has been investigating this. It involves ClojureScript -> JS -> Java bytecode -> Dalvik. I put together a little repo making it easy to try the sequence up to the Java bytecode: https://github.com/mfikes/cljs-cl
17:02mfikeslxsameer: I was exploring whether Sam's approach can also be used to make "Clojure" command-line apps that run with low start-up time
17:04Ent_mfikes: Would you say as it stands, clojure-android is decent for making apps?
17:05mfikesEnt_: I don't have any real experience with it. I've been focusing on ClojureScript on iOS.
17:05arohnerI have lein fighweel finally working, but now how do I make the (Om) page re-render?
17:05Ent_ok
17:05arohner...re-render when fighweel determines that the code reloads, that is
17:07mfikesEnt_: Sam Beran's approach resulted in ridiculously fast launch time, FWIW. (I can't recall, but I think it was on the order of 100 ms or so.)
17:08Ent_mfikes: Cool. Will have a look at it.
17:09mfikesEnt_: His tweet about it: https://twitter.com/samberan/status/523929208595025920
17:10sameerynhojustin_smith: clojurescript ? I thought we use clojure itself
17:12Ent_mfikes: Thanks. going through google results for Sam & clojure-android stuf
17:13mfikesEnt_: I bet the real challenge with Sam's approach is host interop with the Android stuff. For example, with the command line stuff, I had to do this funky call to print (via JS into Java): https://github.com/mfikes/cljs-cl/blob/master/ClojureScript/print-fibs/src/print_fibs/core.cljs#L6
17:16Ent_mfikes: Given that Dalvik VM is different from JVM, is there any other way to do it? I wonder if we just have to sit down and reimplement the whole thing.
17:17mfikesEnt_: Perhaps you could embed a JavaScript engine in our Android app. That's what I do on iOS.
17:19mfikesEnt_: Or wait for Clojure to get faster (tree shaking, or whatever they are doing in the fastload branch?)
17:22Ent_mfikes: Is the overhead of embedded JS engine within acceptable range or are you still working on optimising it?
17:28mfikesEnt_: It is fine on iOS. There's the phase where it parses and loads the JS and this takes 386 ms (I think this was on an iPod touch). That will only get faster. After that, the CPU and memory effects during normal app usage haven't been something I've been able to notice, when comparing to other native apps I've made.
17:34justin_smithmfikes: as I understand it fastload is just lazy about loading definitions (and ends up being slower for longer processes because it needs to check whether things are loaded before running them)
17:35justin_smithmfikes: arrdem can tell us more about the details, but simplistically speaking since eval is defined to be present in clojure at runtime, you need a modified language definition to get tree shaking that works properly.
17:37mfikesjustin_smith: Interesting dilemma. I have no eval calls anywhere in any of my application-level code.
17:39mfikesjustin_smith: I guess I like all of the flexibility during dev, but it would be interesting to have all sorts of semantics-bending whole-program optimizations for deployment. But everything is fast enough for me. Simpler is better :)
17:44SagiCZ1when i call (take-while pred (iterate ... )) the pred is called twice before calling fn in iterate.. is that because of chunking?
17:44SagiCZ1the function i iterate can never return nil.. but the predicate sometimes gets nil as an argument.. i dont understand how is that possible
17:47SagiCZ1cant replicate it on a simpler example
17:48AimHereSo presumably the problem is something to do with whatever's in the ellipsis
17:49AimHereWhat' the function in the iterate?
17:49SagiCZ1it just returns an updated vector.. nothing fancy
17:49SagiCZ1the predicate checks whether the vector passes a condition
17:50SagiCZ1take-while:(0.5893322273289112 -0.014178434390894584 0.8908398415838613)
17:50SagiCZ1iterate:(0.5893322273289112 -0.014178434390894584 0.8908398415838613)
17:50SagiCZ1take-while:(0.5788656395366827 -0.11356364514133756 0.8944496094541826)
17:50SagiCZ1take-while:(0.5893322273289112 -0.014178434390894584 0.8908398415838613)
17:50SagiCZ1take-while:nil
17:52SagiCZ1i dont get it
17:53AimHereAgain, not enough info to go on
17:53SagiCZ1the predicate gets called when its not supposed to
17:54SagiCZ1or maybe i dont understand how this construct works
17:54SagiCZ1iterate should create lazy seq of elements.. which get passed to the predicate in take-while as one argument right?
17:54AimHereYes
17:55AimHereWhat happens if you '(take 100 (iterate inc ..))'?
17:55AimHereIs there a nil thrown up ever?
17:55SagiCZ1nope
17:55SagiCZ1that one works fine
17:56AimHereIs the predicate recursive?
17:56SagiCZ1the predicate is #(neg? (first (mmult (trans %) point class)))
17:58SagiCZ1so strange
17:58justin_smithand trans gets nil as an arg?
17:59SagiCZ1yes.. after random number of iterations
17:59SagiCZ1but (take 100 ... ) works
18:00SagiCZ1feels like all of my code is correct but the take-while iterate logic is acting up
18:01justin_smithiterate and take-while are really extensively used and debugged...
18:02SagiCZ1what can force the take-while predicate to be evaluated several times in a row without the iterated fn being called?
18:02justin_smithI think it's more likely your tracing logic is flawed than that happened
18:02SagiCZ1its like: iterate->pred->iterate->pred->iterate->pred->pred->pred->exception
18:03SagiCZ1yeah ok, its just println
18:03SagiCZ1not sure how to debug it
18:03SagiCZ1maybe i will dust off the debugger
18:15SagiCZ1ok, it was my mistake of course.. the nil was coming from the initial iterate value
18:27SagiCZ1how would i return the first positive number in collection?
18:28SagiCZ1[-4 -8 -9 -5 -9 10 13 46] --> 10
18:28SagiCZ1i think there might be a better way
18:28SagiCZ1,(last (last (take-while #(some neg? %) (partition 2 1 [-4 -8 -9 -5 -9 10]))))
18:28seangroveWhat are the advantanges of reified, first-class namespaces, and the disadvatanges of cljs' current implementation?
18:28clojurebot10
18:28seangrovednolen_: ^^ just in general
18:28seangroveNothing too detailed
18:29hipsterslapfightSagiCZ1: `(first (filter pos? collection)` maybe?
18:29SagiCZ1thats way better, thanks
18:29SagiCZ1(inc hipsterslapfight)
18:29lazybot⇒ 1
18:30hipsterslapfightnp
18:30AimHereI keep thinking that 'some' does that job, but it just gives the truthy value instead
18:32FrozenlockAimHere: That's because of 'pos?', not 'some'.
18:32Frozenlock,(some #(when (pos? %) %) [-4 -8 -9 -5 -9 10 13 46])
18:33clojurebot10
18:33AimHereYeah, I know
18:33AimHereYou can write the predicate to make some do that job, but then the first/filter dance becomes prettier
18:36FrozenlockThat's kind of sad in a way... I would love to have filter/some behave in the same way.
19:08justin_smithFrozenlock: instead of when, you can use and (which helps emphasize it's a value, not a side effect)
20:24justin_smithSagiCZ1: I just realized there is this one too: ##(first (drop-while neg? [-4 -8 -9 -5 -9 10 13 46]))
20:24lazybot⇒ 10
20:26ajmccluskeyAnyone know an easy way to print a transient map the same way a regular one is printed?
20:27rhg135i guess you could redefine print-method
20:27ajmccluskeyrhg135: right. I guess I'm really checking if there's an existing function or something quick and dirty.
20:28rhg135not that im aware of, ajmccluskey
20:28rhg135but wait for them smart folks
20:28ajmccluskeyhaha, thanks :)
20:30rhg135ajmccluskey: also this is quick and very dirty
21:52justin_smithhttp://stackoverflow.com/questions/27736719/core-async-machine-that-loops-until-a-fx-returns-true what this guy is doing looks smelly, but I don't know the right answer
22:19kenrestivoa weird side-effect of using core.async is, i've noticed, it pushes me toward writing imperative code. loops, and so on.
22:19kenrestivolooks like that guy got the disease too. "oh, i'll just busy-wait"
22:20kenrestivoi find the more i use core.async, the less functional my code is.
22:20kenrestivomaybe i should get on the transducer tip.
22:21jonasenkenrestivo: which isn't surprising since core.async isn't a functional construct
22:21AWizzArdjustin_smith: why did this guy not install an onload handler for the body? This function gets called by the JSVM when the body was loaded.
22:21AWizzArd<body onload="myFunction()">
22:22kenrestivoi'm tempted to say "use om or reagent", but that's too dismissive and proabbly unnecessarily heavyweight for what he's trying to do.
22:27kenrestivojustin_smith: it kind of begs the question: "why or what is creating that element, and why can't it do that (.start f) once it does?
22:30rhg135core.async is meant to do the communication
22:30rhg135hence the c in csp