#clojure logs

2014-05-09

02:10amalloyAWizzArd: i think you define a goal that succeeds only when one of those things is true, and then use that goal in your function
02:10amalloywait, core.match, not core.logic
02:12amalloyso define a function: (defn small-or-even [x] (or (#{1 2 3} x) (even? x))), (match [x] ([(n :guard small-or-even)] ...)). i don't recall core.match syntax exactly, but i think you see the idea, AWizzArd
03:59brackiHow do I doto with static methods?
04:00brackiCompilerException java.lang.RuntimeException: Expecting var, but Mysql is mapped to class com.twitter.finagle.exp.Mysql
04:02Glenjamin,(doto "1" (Integer/valueOf))
04:02clojurebot"1"
04:03Glenjaminnot the best example, but i couldn't think of any mutating static methods
04:05brackiI'm trying to call a builder...
04:06brackihttps://github.com/twitter/finagle/blob/master/finagle-mysql/src/main/scala/com/twitter/finagle/Mysql.scala#L95
04:07Glenjaminoh, that's just (doto (Mysql/withCredentials "user" "pass") (.withDatabase "db") (.newRichClient "blah"))
04:07Glenjamini think
04:07Glenjaminthe first call is static, the rest operate on the return value
04:08brackiAh, OK. Got that mixed up... Thanks
04:08Glenjaminassuming that they all return this, otherwise you might need ->
04:09clgvGlenjamin: they do not need to return anything for usage with "doto"
04:10clgv,(seq (doto (java.util.LinkedList.) (.add 1) (.add 3) (.add 7)))
04:10clojurebot(1 3 7)
04:11clgvyou need them to return the modified object if you want to use `->`
04:39lee_Hello I want to know how the html content in to string (actually i am using ckeditor to write the question fo next line it will show <p> on the database how i am remove these html elements) so that i am getting the question according the my format
04:41lee_Hello I want to know how the html content converting in to string (actually i am using ckeditor to write the question fo next line it will show <p> on the database how i am remove these html elements) so that i am getting the question according the my format means in next line . at that time it will come in a single line
04:45maxthoursielee_: sorry I'm not able to understand your question
04:46winkme neither
04:47Glenjaminclgv: good point, i meant in the context of a fluent method chain - if they don't return `this` for chaining, doto won't work either
04:47Glenjaminso actually, bracki -> is the correct form to use to call a fluent method chain
04:48Glenjamindoto may or may not work, but -> should always work
04:48clgvGlenjamin: doto works always for side effects no matter what the methods/functions return
04:48Glenjaminclgv: yes, but it's unclear if https://github.com/twitter/finagle/blob/master/finagle-mysql/src/main/scala/com/twitter/finagle/Mysql.scala#L93 is side-effecting or not
04:49lee_<maxthoursie> i am using ckeditor in my web-app i enter the string in it . but this string display in a single line but i want to show that in a multiple line
04:49clgvGlenjamin: well that looks like chaining in scala so I'd use "->" in clojure
04:50maxthoursielee_: you want to break a line into multiple lines? What do you want to break on?
04:50Glenjaminyeah, the original question was about doto, which threw me off :)
04:51lee_yes
04:52lee_<maxthoursie> description of content
04:52lee_<maxthoursie> i am using split it not work properly
04:53maxthoursielee_: could you show what you use now?
04:55lee_<maxthoursie> ckeditor plugin in js file and from where i enter the data is myapp.routes.example and where i want to display is myapp.routes.ex2
04:57ddellacostalee_: give us a gist/refheap/etc. dump of the relevant code and we can help you. As it is there is too little information.
05:03lee_<maxthoursie> my html page is cont.html where i put my ckeditor .The myapp.routes.ex1111 render this cont.html page i filled the info in ckeditor and submit it another file is in myapp.routesex22222where i want to display that info , and i want to display the info in a proper format mmean it comes in a line but it come with a <p> info </p> which is not right
05:05szymanowskiis there any hack to allow :refer :all in cljs?
05:25maxthoursielee_: sorry I really don't follow you, could you post some code in a gist?
05:28shadow_princeHi there! Can't reaize how to implement inputstream on clojure. I tried with proxy, but read method dont return result, but accept veriable, that needed to be written in. Its not mutable, so I can't assign it. How can I workaround it?
05:31phillordIf I open a new Clojure file in Emacs, cider-jack-in and cause an error I get a cute stack trace, centered and in lots of colours. If I do the same thing in a leiningen project, I get a single coloured stack trace left-justified. Anyone know why the difference and how to get the cute stack trace in a leiningen project?
05:35brackiWhat's the best way to track down ClassCastExceptions when interop'ing w/ Java?
05:38lee_Actually i want parsing the string, i want my string is treat as in html format
05:40maxthoursiephillord: I believe that transformation is done inside emacs, so I don't think there's a way
05:41phillordah -- so why is it openly happening when I am not using a lein project?
05:42maxthoursiephillord: You don't get that with lein projects inside emacs?
05:42phillordI get two totally different output formats
05:42maxthoursiephillord: ah, reread your first message.
05:42maxthoursieAll I can say is that it works here
05:42phillordah
05:43phillordthat's interesting, so maybe I have screwed something up somewhere with either leiningen or with my cider config
05:43maxthoursieI get colored stacktraces for leiningen projects inside emacs
05:43maxthoursieany hint in the *messages* buffer?
05:44phillordno
05:44phillordnothing at all -- I only discovered that it wasn't working in lein a couple of days ago, when I found that it was working outside
05:50phillordwhere is your clojure mode coming from?
05:50phillordsorry, mean cider
05:56martinklepschI'm trying to setup background processing with carmine but get a null pointer exception when running the most basic example from the readme: https://www.refheap.com/85286
05:57maxthoursiephillord: I have cider 0.5.0 iirc
05:57maxthoursiephillord: installed with package-install
06:00phillordhmmm
06:00phillordsame for me
06:00phillordwell, AFAICT, it's not emacs doing it -- emacs is just interpreting the ANSI colour symbols
06:00phillordso, I am guesing lein isn't doing that
06:02martinklepschanyone an idea why carmine could be failing in that simple case?
06:07martinklepschI was missing the connection macro in front: (wcar* ... )
06:17martinklepschI'm trying to start the carmine worker like so now: (wcar* (car-mq/start my-worker))
06:18martinklepschbut (car-mq/queue-status nil "index-queue") doesn't put any messages in :done
06:21martinklepschanyone used the worker part of carmine?
06:33io__i want to automate bulk downloading of files(i.e. PDF) from a webpage via imacros firefox addon, i dont know how to make it happen? can anyone help?
06:33ssideriswhich one is faster: core.match or matchure?
06:33ssiderisio__: wrong channel?
06:36ambrosebsssideris: does matchure work with recur?
06:37clgvssideris: you could take a characteristik example thats not too small and measure both via criterium
06:37ssiderisambrosebs: not sure, I was thinking of using it as an advanced code+destructuring
06:38ssiderisclgv: I probably will, but I thought to ask here in case it was common knowledge
06:39ambrosebsssideris: core.match works fine with recur, matchure didn't play nicely.
06:39ambrosebsmight have changed
06:40ssiderisambrosebs: I'm not sure I follow, are you saying that if you use a matchure call within a loop/recur it doesn't behave as expected?
06:42ambrosebsIIRC using recur on the right hand side of a pattern doesn't work in some cases. search "matchure recur"
06:42ambrosebsI've never used matchure
06:43ssiderisambrosebs: thanks, that's useful to know. it may not end up being a problem with me
06:44ambrosebsssideris: maybe. performance == loop/recur in clojure :)
06:45ssideriswe shall see, I think my use case is very simple :-)
06:46ambrosebsssideris: disclosure: I worked on core.match
06:46ambrosebsa long time ago :)
06:47ssiderisambrosebs: I know, I follow the mailing list ;-)
06:47ssiderishow's core.typed going?
06:52ambrosebsssideris: kicking into gear
06:52ambrosebs:)
06:52ssiderisgreat!
07:19brackiCan anybody point to some documentation on how to interface with Scala, esp. Some/Option?
07:22agarmanyou have to use Scala like Java
07:23agarmanwith the problem that Scala libraries written & documented for Scala require you to use apply / unapply and know how Scala does default parameters
07:24agarmanwhat Scala library are you using?
07:24brackihttps://github.com/twitter/finagle/blob/master/finagle-mysql/src/main/scala/com/twitter/finagle/mysql/Value.scala
07:25brackiTrying to write a wrapper around finagle-mysql as an enhancement for https://github.com/jcrean/clj-finagle
07:25agarmanfor Clojure, treat None as Nil and just unwrap Some
07:25agarmanif you're writing a wrapper
07:26agarmanhttp://stackoverflow.com/questions/5839697/why-is-the-use-of-maybe-option-not-so-pervasive-in-clojure
07:27brackiagarman: Saw that already but TLDR ;)
07:29agarmansummary is that Clojure doesn't have a Maybe Monad, Nil Punning works just fine in most cases
07:30agarmanso dealing with Scala Option type write a function that unwraps Option
07:32brackiThanks
08:36AWizzArdslightly OT: in Emacs/Cider I would like to add my own indentations for some functions. Any pointers?
08:37justin_smithM-: (apropos-variable ".*lisp.*indent.*")
08:37justin_smiththis works for other things too, just change the regex :)
08:38justin_smithinstead of M-: you can use M-x ielm or hit C-j or C-M-X in the appropraite place in the *scratch* buffer
08:40AWizzArdjustin_smith: interestingly when I grep for “reify” or “proxy” in my cider (elpa) installation I find nothing. It seems it isn’t defined there how to indent those.
08:41AWizzArdjustin_smith: ah okay, because this is done in clojure-mode. All clear, thanks.
08:41justin_smithAWizzArd: they are elisp vars, you don't reify them, you just use setq to change them
08:41justin_smiththey are part of lisp mode, which is the parent of clojure mode
08:42justin_smiththe clean way to do it would be to add-hook on clojure-mode-hook to set those variables (iirc they are buffer local so can be set per file)
08:42justin_smithalso, expect your codebase to end up all messed up if anyone edits code with other settings :P
08:43justin_smithfor values of "all messed up" = "inconsistent indentation" of course
08:43AWizzArdjustin_smith: I didn’t plan to call reify in emacs lisp :) Just was searching where reify was defined for Clojure.
08:43justin_smithI don't see where reify would even come in?
08:45AWizzArdhttps://github.com/clojure-emacs/clojure-mode/blob/master/clojure-mode.el#L957
08:49justin_smithahh so you want to change the rules for indenting reify?
08:49AWizzArdjustin_smith: wanted to see examples for complex cases, such as reify or deftype. So I can play with indentation for Om.
08:50justin_smithit looks like the complex rules are for proxy, or deftype or defrecord (relatively complex)
08:51AWizzArdyes
08:51justin_smith(describe-function #'put)
08:51maxthoursieI heard someone implementing a clojure mode for their editor complaining about the complex, irregular indenting of clojure code
08:52maxthoursieI do find my self expressing much more with whitespace in lisp compared to other langs
08:52justin_smithAWizzArd: if you run that code I just posted in emacs, you will see how put works - it is assoc where you can assoc onto any symbol, and lookup is slow
08:53justin_smithmaxthoursie: I think most of the clojure indent customs are just derived from emacs' defaults for lisp
08:54justin_smithAWizzArd: of course the other difference from assoc is it mutates the store :)
08:56maxthoursiejustin_smith: that's probably true. It's all emacs's fault :)
08:56justin_smithmaxthoursie: I think that here emacs is a proxy for centuries of lisp tradition
08:56justin_smithfor values of century ~= 50 years
08:57maxthoursiejustin_smith: right
09:01clgvident everything with 2 spaces is probably the easiest identation rule ;)
09:14phillordhas anyone got any ideas why stacktraces only colorize in Emacs when I am *not* in a lein project -- it works fine with a raw clojure file, but not at all with a file that is part of a project
09:14mdrogalisphillord: I noticed the same thing, but I never found the pattern.
09:14phillordI asked earlier, and I know that it is not affecting others
09:15phillordAFAICT, the colour comes from the middleware somewhere!
09:15mdrogalisHeh.
09:16phillordBut I've tried, with an emacs -q, I've just recreated my .lein, and on a newly created lein project with nothing in it. Tried debugging -- all the call backs make it hard, but still can't see it.
09:17phillordit's a shame, because it's quite cute -- I only realised it did it at all yesterday
09:17mdrogalisIt's more like a pleasant surprise when I see the colors. :P Only happens once in a while, but when it does - I'm pleased.
09:17phillordthey definately help
09:18phillordI mean, it's almost a pleasure to have your code crash with colours on, don't you think?
09:19mdrogalisHaha, yes.
09:19mdrogalisHow angry can you really be?
09:20phillordperhaps, I should give in -- I mean, if I actually get the colours all the time, my code quality will probably drop, just so I can see more.
09:21mdrogalisHaha.
09:39liviu10what's the advantage of using a semaphore over a monitor
09:42mikerodsemaphore sounds cooler :P
09:43mikerodjoking, but a I think http://stackoverflow.com/questions/7335950/semaphore-vs-monitors-whats-the-difference explains it reasonably
09:52michaelr525hi
09:53michaelr525in emacs-live is there a "find references" for functions?
09:53michaelr525or other symbols
09:54AWizzArdamalloy_: yes, that could make sense, to move this all into the guard.
09:56jcromartiecompojure style question: I keep mixing up different ways of connecting routes and params to handlers
09:58jcromartiehttps://gist.github.com/jcromartie/d4b6d752e1d001de1724
09:59jcromartieIs there any good example out there of a good balance?
09:59jcromartiesometimes I feel like I get way too much logic going on in the (GET …) body etc.
10:04sverihi, lets say I have a list of maps like this: ({;key 1 :key2 "f" } {:key 3 :key2 "3" } {:key :key2 "fsdf" }) and want that list to be sorted after the value of a key in the map, is there a function available in clojure or do I have to write it myself?
10:05mdrogalis,(doc sort-by)
10:05clojurebot"([keyfn coll] [keyfn comp coll]); Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array."
10:05bbloomsveri: can you give your expected output for that input?
10:06sveribbloom: ({;key 1 :key2 "f" } {:key :key2 "fsdf" } {:key 3 :key2 "3" }) if I sort it after the value of :key
10:06sverimdrogalis: ok, so I have to make use of sort-by, thank you :-)
10:07bbloom,(sort-by :key '({;key 1 :key2 "f" } {:key 3 :key2 "3" } {:key :key2 "fsdf" }))
10:07clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
10:07bbloom,(sort-by :key '({;key 1 :key2 "f" } {:key 3 :key2 "3" } {:key :key2 "fsdf" })))
10:07clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
10:07bbloom,(sort-by :key '({key 1 :key2 "f" } {:key 3 :key2 "3" } {:key :key2 "fsdf" }))
10:07clojurebot#<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>
10:07bbloomsheesh
10:07bbloom,({;key 1 :key2 "f" } {:key 3 :key2 "3" } {:key 4 :key2 "fsdf" })
10:07clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
10:07bbloom,(sort-by '({key 1 :key2 "f" } {:key 3 :key2 "3" } {:key 4 :key2 "fsdf" }))
10:07clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/sort-by>
10:07bbloom,(sort-by :key '({:key 1 :key2 "f" } {:key 3 :key2 "3" } {:key 4 :key2 "fsdf" }))
10:07clojurebot({:key 1, :key2 "f"} {:key 3, :key2 "3"} {:key 4, :key2 "fsdf"})
10:07bbloomok finally fixed up that syntax lol
10:08sveribbloom: thanks a lot, I didnt know it was that easy
10:08sveriagain I was thinking to much around the corner
10:48TimMcclojurebot: You can't spell REPL without EPL.
10:48clojurebotCool story bro.
10:49akazlouwhat is the idiomatic clojure way of iterating with accumulating the result: 1. using loop/recur with accumulator as one of the loop binding or 2. for and filter the result after?
10:49bbloomakazlou: reduce
10:50bbloom,(reduce + 0 [1 3 5])
10:50clojurebot9
10:50TimMcloop is better if you are accumulating or tracking multiple bits of "state".
10:51TimMc(You can still do it with reduce, but it can be harder to read.)
10:53akazlouno reduce is not what I want in my context, for example, iterating over vec of vecs, and do something on each of the element, and either return something or nil for example, if the data satisfies the requirements, I could use loop and put piece of data into the accumulator and return it when no more recur, or "for" with [nil <piece of data> ..] and then do filter for all, but not nil
10:55bbloomakazlou: ah, ok, there's two primary patterns for that
10:55bbloom1) is use mapcat
10:55bbloom2) use loop or reduce w/ a sequence state variable, return that at the end
10:56bbloomexample: ##(mapcat (fn [x] (when (odd? x) [x x])) [1 2 3 4 5])
10:56lazybot⇒ (1 1 3 3 5 5)
10:56bbloomthe idea is you just wrap your result in [] or if there is no result, you return nil
10:57bbloomalternatively: ##(reduce conj [] (range 5))
10:57lazybot⇒ [0 1 2 3 4]
10:58bbloomand you can do that with a state variable too: ##(reduce (fn [[i v] x] [(inc i) (conj v x)]) [0 []] (range 5))
10:58lazybot⇒ [5 [0 1 2 3 4]]
10:58bbloomi ignore the state, but show how to thread it through
10:58bbloomor just write an explicit loo
10:58bbloomp
10:58bbloomakazlou: that answer it?
11:03arrdem,(/ 1000 8)
11:03clojurebot125
11:03akazlouI guess yes, nice examples, thank you. My usage pattern so far to use loop, will try mapcat for the new tasks and see how it fits, maybe it is better than loop-s I've been writing before
11:04arrdem,(* 125 (/ 100 3))
11:04clojurebot12500/3
11:04arrdem,(double (* 125 (/ 100 3)))
11:04clojurebot4166.666666666667
11:04akazloureduce with the state is also nice example, thanks
11:14clgv,(* 125 (/ 100.0 3))
11:14clojurebot4166.666666666667
11:17justin_smithI'm working on my java skills as a portfolio building / skill building thing, and I gotta say you can do some nifty things with java 8 type inference and lambdas (it's no clojure or haskell to be sure, but compared to vanilla java it is awesome)
11:18justin_smithI predict a clojure fork or rewrite once java 8 becomes a reasonable expectation (or at least hope for one)
11:19justin_smithjvm 1.8 of course, is what I mean there
11:20bbloomjustin_smith: what would be the benefit of such a fork or rewrite?
11:22justin_smithbbloom: now methods have a first class syntax
11:23justin_smithwell - I wonder if it is just a syntax or a change in jvm actually
11:23bbloomjustin_smith: i'm pretty sure it's just syntax....
11:23justin_smithoh, don't mind me then :)
11:23bbloomthere's no reason for anybody to ever write another clojure in java again
11:23justin_smithOK
11:23arrdemjustin_smith: the issue with a project like that is that for the most part Clojure code is very tricky to type 'cause we use structured maps everywhere. I've toyed with the idea of using core.typed to do type introduction on the basis of map structures but it's nontrivial.
11:23justin_smithbbloom: maybe the features were deceptive
11:24llasramIt might prompt adding a nicer method->IFn syntax
11:25justin_smithyeah, in java 8 you can pass Class::method as an arg to a method
11:25seangroveI wish someone would do a proper clojure-in-clojure, based of some solid research
11:25justin_smithand the method then calls that method on the args it would like etc.
11:25seangroveMake certain parts specifiable...
11:25seangroveI don't know, kind of an 'extensible clojure'
11:25arrdemwhat on earth does that mean....
11:25bbloomhaha
11:26bbloomit's a P2 project, but it's not stalled :-P
11:26seangrovearrdem: Just the mutterings of a madman
11:26arrdemseangrove: we're all mad here...
11:27llasramAt some point Clojure needs to learn about the Java 8 function interfaces. And decide what to with IFn wrt them
11:27justin_smithllasram: much better put than my blabbering :)
11:27justin_smith(inc llasram)
11:27lazybot⇒ 23
11:28justin_smithhttp://docs.oracle.com/javase/8/docs/api/java/util/function/Function.html
11:28justin_smithfor example the Function interface has a compose method, etc.
11:29justin_smithmaybe that's an ugly part of clojure that we don't want to revisit, but maybe there is potential in utilizing or integrating that stuff
11:29llasramJust making AFn implement more interfaces like it already does with e.g. Runnable would allow using Clojure functions in Java 8 functional APIs, but not vice versa
11:30justin_smithllasram: yeah, I am still puzzling this set of classes / apis / features out, but that sounds about right
11:33arrdemtbaldridge: if only so I can start coalating my notes, is the plan (if one exists) for my GSoC compiler to be a tools.emitter.* project or is this a point of discression?
11:33llasramjustin_smith: Silly Java... Why couldn't it just stay all boring and OO/imperative?
11:34arrdemllasram: because people like us want to build nice fuctional systems atop the JVM...
11:39justin_smithif nothing else this seems like a chance to make cleaner and more succinct code in the .java files in clojure.core, if we ever wanted that (acknowledging of course that wanting a fully self hosting clojure is a thing, and long term they are incompatible)
11:46meliponehello! which debugging tool are you using in the REPL? I would like to get breakpoints.
11:50coventrymelipone: There aren't very good tools for that. To get the data at a particular point of execution into the REPL, I often (def dbg (atom nil)) before the function in question then (reset! dbg interesting-expression), maybe followed by a throw, and re-run the program.
11:50coventrymelipone: Then you can access to the data in @dbg.
11:52coventryThere's also schmetterling, which will actually do a breakpoint with a repl in that execution context.
11:52justin_smithcoventry: with the caveat that the breakpoint must be an exception (the two are kind of complected in schmetterling, but that may be inevitable)
11:53justin_smiththe problem with schmetterling: if you provoke an exception in the context repl, everything is hosed (maybe we can fix that soon...)
11:54roelofwhy doe sthis (http://pastebin.com/eU0zWZND
11:55meliponecoventry: what's @dbg?
11:55roelofnot work well on this part : (toggle #{:a :b :c} :a)
11:55coventrymelipone: Just dereferencing the atom you put the data in.
11:56coventry,(do (def dbg (atom nil)) (dotimes [i n ] (swap! dbg conj i)) @dbg)
11:56clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: n in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:56edlothiolroelof: I think you're missing an if
11:56coventry,(do (def dbg (atom nil)) (dotimes [i 10 ] (swap! dbg conj i)) @dbg)
11:56clojurebot(9 8 7 6 5 ...)
11:57kenrestivomeliphone: i use tools.trace
11:57roelofoke, I thought on contains? that would not be needed because the outcome is true or false
11:57coventrytools.trace is useful for simple data, but often inadequate if you want to get a reproducible test case in the repl.
11:58meliponecoventry: oh, but I want to stop the program and maybe rerun it. how do you do that with a throw?
11:59roelofedlothiol: but you are right. With a if it works fine . But as I said I always thought on contains? you do not need a if
11:59meliponekenrestivo: does tools.trace has breakpoints?
12:00kenrestivonot AFAIK.
12:00coventrymelipone: Stick all the args to the function you're studying into the debug repl, and (apply function @dbg) in the repl. It's definitely not as nice as a breakpoint.
12:02edlothiolroelof: well... I don't know how you got that idea, you can't just leave out ifs
12:04roelofedlothiol: I did it here :(or (apply <= a-seq) (apply >= a-seq))) and it worked well. I see false and true when I expected it
12:04bbloomroelof: you didn't leave out an if... or has an if in it
12:04bbloom(doc or)
12:04clojurebot"([] [x] [x & next]); Evaluates exprs one at a time, from left to right. If a form returns a logical true value, or returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expression. (or) returns nil."
12:04bbloomyou can go look at (source or) too
12:05roelofbbloom: clojure still suprise me
12:05coventryhttps://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L813
12:08gmc__I’m trying to run through the basic example in Lobos, but I keep getting the following error: “Unable to resolve symbol: *db* in this context, compiling:(lobos/connectivity/jdbc_2.clj:14:1)”
12:08gmc__Anyone seen that before?
12:08roelofAnother question I have to look if a seq has duplicates. Can I count each element somehow ?
12:09coventry(doc frequencies)
12:09clojurebot"([coll]); Returns a map from distinct items in coll to the number of times they appear."
12:09mdeboardoh nice
12:09mdeboardwow
12:09mdeboardthat's handy.
12:12roelofcoventry: that not what Im looking for. I have to make a form which does this : (contains-duplicates? [1 1 2 3 -40]) ;=> true
12:12roelofand I just learned to use count
12:12roelofhmm, maybe use apply or map
12:13coventrySomething like (defn contains-duplicates? [seq] (< 1 (apply max (vals (frequencies seq))))), maybe.
12:13coventryThat's inefficient compared to stopping when you hit the first duplicate though, I suppose.
12:16coventryAlso, that'll throw if seq is empty.
12:23roelofI thought this (http://pastebin.com/chd9JyrN) would work but I see this error message : ompilerException java.lang.IllegalArgumentException: let requires a vector for its binding in structured-data:90, compiling:(/home/roelof/clojure/structured-data/src/structured_data.clj:90:3)
12:23roelofmaybe clojure is not my language
12:23akazlouI'm trying to understand, is it against the Clojure philosophy that some of the funcs work correctly when only applying to a vector, for example, like update-in or assoc, and similar, so is it common to transform the input to vector first (using vec) and then apply the before-mentioned functions
12:24akazlouagainst I mean, that lots of functions don't care whether the input is seq, list or vec
12:24akazlouor even map
12:24bbloomroelof: have you picked up a book on it?
12:25bbloom(doc let)
12:25clojurebot"([bindings & body]); binding => binding-form init-expr Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein."
12:25bbloomroelof: maybe read this & the rest of the page: http://clojure.org/special_forms#Special Forms--(let [bindings* ] exprs*)
12:26roelofbbloom: yep, the course is providing info and Im reading clojure for the brave
12:29bbloomroelof: is this an in-person course? or online?
12:30roelofbbloom: its a online course . Here is the page Im working on : http://iloveponies.github.io/120-hour-epic-sax-marathon/structured-data.html
12:30bbloomroelof: all of those examples clearly show how let bindings work, so i'm not sure where you got the idea that the vector brackets were optional
12:31roelofbbloom: sorry. I miss you now. what do you mean ?
12:31bbloomnevermind
12:36arrdemdeployment jars are just the source code packed, right? clojure deps don't ship as just .class files in a .jar.
12:36technomancyarrdem: you can put .class files in a jar, but then you're a bad person who has betrayed all the trust your friends have put in you
12:38arrdemtechnomancy: good. that's what I thought.
12:38felixfloresHey guys I made a visual map of :db.part/db for datomic
12:38felixfloreshttps://raw.githubusercontent.com/felixflores/datomic_explanation/master/doc/figures/render/entity_zero.png
12:38felixfloreswhat do you guys think?
12:38felixfloreshttps://github.com/felixflores/datomic_explanation/blob/master/doc/figures/render/entity_zero.pdf
12:38teslanickbigger?
12:38felixfloreshere's the pdf
12:38roelofI have now this : http://pastebin.com/vAfwv7r4 and see this error : ArityException Wrong number of args (5) passed to: structured-data$contains-duplicates-QMARK-$element clojure.lang.AFn.throwArity (AFn.java:437)
12:38teslanickbetter!
12:39roelofI think somewhere along the line I lost track of things
12:41felixfloresWhat do you guys think?
12:48akazlounvm, I found mapv
12:49PigDudejustin_smith: thanks for the advice about Calendar, but if i'm using a java/clj-specific API i'll go whole hog w/ Joda/clj-time on that side of things. of course i say that now, the world of java libraries etc is still very new to me :) so plenty of time to reconsider
12:59boblarrickDoes anyone know of a Om tutorial that demonstrates submitting a simple form?
13:01coventryboblarrick: Submitting a form to a server is kind of orthogonal to the concerns om addresses. Do you mean updating the client view based on the form data, independent of server response? Otherwise, you just set a callback which sends the data to the server.
13:01tnksnot to start a flame war of personal preference, but is there a popular number of spaces for indentation (guessing either 2 or 4)
13:01tnksI have to set my editor to something, and thought I'd ask first.
13:01manutterI see a lot of code with 2-space indents
13:01justin_smithtnks: there is no real controversy - two spaces
13:02coventryDie in a fire you heretic.
13:02justin_smithI've never even seen an argument about it
13:02teslanickAlso, in Clojure, indentation is typically all over the place ya?
13:02technomancytnks: special forms indent by two, regular function calls indent subsequent lines to the column of their first argument.
13:02tnkstechnomancy: okay.
13:02manuttertrue that
13:02technomancyit's such a relief to be free of formatting wars
13:03technomancyso we can focus on more important things like editor wars
13:03justin_smithtechnomancy: even that is unbalanced enough that the "editor war" is more like a state of occupation
13:03technomancyhehe
13:03bbloomshhh don't mention cond
13:04technomancyjustin_smith: it's a peacekeeping operation dammit
13:04PigDudejustin_smith: i see a fair amount of clj code that writes out hashes like js objects (new line for each key, indented two spaces)
13:04clgvcoventry: :P
13:04PigDudejustin_smith: my editor doesn't like that end neither do i :P
13:04clgvtechnomancy: did the emacs operating system finally get a decent editor? ;)
13:04PigDudelike in the project.clj example on https://github.com/emezeske/lein-cljsbuild
13:05justin_smithPigDude: I'm just saying that things like that are seen as abberations - it isn't like we have a significant disagreement about which way that should be (that I've seen at least)
13:06boblarrickcoventry: Yeah I'm just having some trouble extracting what I need from the Om wiki
13:06PigDudejustin_smith: yea, i like that i can just =% in vi and know it is right, or if it's wrong it reveals misordered ) quickly :)
13:07boblarrickI have a server that accepts GET requests + query params and responds the way I want
13:07boblarrickand an Om front end that works with a hard-coded URL
13:07boblarricktrying to get to place where the user can submit a form in place of the hardcoded URL
13:08boblarrickwas hoping there was a example app that demonstrated a simple form
13:15coventryboblarrick: Don't know any simple public examples, sorry
13:20mordocaiHey, could use some help. I'm going through "The Joy of Clojure" 2nd edition(it is an early access) and an example isn't working. Take a look https://www.refheap.com/85295? I'm getting and errors that the argument list isn't a vector, which seems valid, but I don't see how to make the example work completely.
13:20mordocaiI'm getting errors*
13:23justin_smithmordocai: weird, I get no such error in my repl
13:23cbpmordocai: there doesnt seem to be any error with that
13:23PigDudei think he needs to include the code using this
13:23justin_smith,(defn neighbors ([size yx] (neighbors [[-1 0] [1 0] [0 -1] [0 1]] size yx)) ([deltas size yx] (filter (fn [new-yx] (every? #(< -1 % size) new-yx)) (map #(vec (map + yx %)) deltas))))
13:23clojurebot#'sandbox/neighbors
13:24cbp(neighbors 10 [2 2])
13:24cbp,(neighbors 10 [2 2])
13:24clojurebot([1 2] [3 2] [2 1] [2 3])
13:24justin_smithlooks good?
13:24mordocaiPigDude: I'm getting a compiler error, nothing is using it
13:25mordocaiI'm using cider-eval-buffer, i'll try using lein repl directly
13:26PigDudeoh, huh, yea, runs fine here
13:27cbpyou must not be pasting the same thing on your repl
13:29mordocaiOkay, so lein repl doesn't work either. I'm using clojure 1.6.0 with lein 2.3.4 on java 1.80_05. I'm not pasting into repl, it is in a file in my project. I'm wondering if there error is somewhere else and i'm not realizing it.
13:31llasrammordocai: Maybe paste up the whole file?
13:32mordocaillasram: Yeah, it's collections.clj here: https://github.com/mordocai/learning-clojure/blob/master/src/learning/collections.clj.
13:32mordocaiIf you clone that repo it is a full project
13:32cbpmordocai: the first defn is wrong
13:33mordocaioh... duh...
13:33mordocaiI had an empty vector there before. Thanks
13:33mordocaiThe error was saying 1:26 which confused me, if it had said line 2 I might have figured it out myself lol
13:35PigDudethe only way i know how to zip a list in clojuer is (map vec colls). but this is not lazy so it means i can't use it w/ my lazy structures. how do you turn elements from two lazy collections into [c1 c2] [c1-1 c2-2] ... ?
13:35mordocaiBy the way, so far the community in this channel has been great. Kudos to you guys.
13:36cbpPigDude: it is lazy due to map
13:36llasramPigDude: Do you mean (map vector coll1 coll2) ?
13:37PigDudecbp: then in practice i'm geting it wrong
13:37PigDude,(take 10 (map vec [(iterate inc 1) (iterate inc 2)]))
13:37PigDude(never ends)
13:37clojurebot#<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>
13:37llasram,(take 10 (map vector (iterate inc 1) (iterate inc 2)))
13:37clojurebot([1 2] [2 3] [3 4] [4 5] [5 6] ...)
13:37cbpPigDude: use itlike llasram
13:37PigDude(map vector) not (map vec0?
13:38PigDudeok
13:38llasramThe version you posted just turns each collection separately into a vector
13:39cbpPigDude: also the first one you pasted is lazy, though wrong
13:40cbpto check if its lazy you can just put it in a var and it must return instantly
13:40cbp(def x lazy-operation)
13:40PigDudehm ok
13:41cbpthe way youre doing it makes the repl print it which realizes it
13:41llasram,(map vec [(range 0 3) (range 1 4)])
13:41clojurebot([0 1 2] [1 2 3])
13:42PigDudeah ok cbp
13:42coventryboblarrick: session has a rather involved example, but it might give you some ideas about how to get the data out of the form and to the server. https://github.com/kovasb/session/blob/master/src/cljs/session/editor.cljs#L39
13:42PigDudethat's why i include `take 10` in those sorts of tests
13:43cbpyou can also do (type lazy-operation)
13:43cbpalthough im not sure checking if things are lazy is of any help
13:43llasramPigDude, cbp: the real problem is that the resulting lazy sequence only has 2 items, each consisting of the result of producing a concrete vector from an infinite lazy sequence
13:44mordocaiI learn so much just by reading this channel...
13:44PigDudedo you have a process for breaking down large functions?
13:45cbpLarge as in big number of lines?
13:45cbpif they're pure functions you can just break them wherever you want :-)
13:45PigDudei have a really ugly 40-line function w/ several ifs, lets, etc. but the loop/recur requires maintaining some state, and each branch in the decision tree must do the same things to maintain this state ... that is the chief culprit here
13:46PigDudei just don't see how to break apart a loop that requires more than one piece of state, short of doing some really ugly reduce call w/ some ad-hoc acc structure
13:46jcromartiePigDude: can you share it?
13:46PigDudesheepishly
13:46jcromartiedon't be ashamed
13:46PigDudehttps://www.refheap.com/a4ac1d207818bd7cf31c3f7e6
13:47llasramPigDude: that's generally what I do (reduce w/ a vector of state), and is usually fine
13:47PigDudellasram: hm ok ..
13:48PigDudeone insight is that the index is the same in each branch but the first. i was reluctant to do the `assoc' at a higher level though because it's nice to have it be local to each branch
13:48jcromartiePigDude: one basic tactic is to pull out the common parts (in this case being the recur from several places) and parameterize it
13:49jcromartiePigDude: so you could probably recur from one place after calculating all of the new values
13:49bbloomPigDude: you may consider replacing your arg lists with a map
13:49bbloomand breaking the various branches down in to functions that operate on that map
13:50PigDudejcromartie: is this akin to doing 'ret = ...' 'return ret'?
13:50PigDudejcromartie: or is there a larger discussion around where to put tail calls?
13:51PigDudejcromartie: that's good advice, thanks
13:51jcromartiealso, a bunch of ifs usually turn into a cond nicely
13:51bbloomPigDude: generally, i think this function is simply doing too much
13:51jcromartieand partial application could help shorten some of these things
13:51bbloomi'd break it in to a lazy seq of the data to write & then the writing logic
13:51bbloomthat will eliminate all your do-blocks
13:51PigDudebbloom: yea, it is maintaining the log entries and also the index, but the two happen at the same time ... this is not my strength
13:52jcromartiei.e. you are always calling write-interval with the same firs three args
13:52jcromartieso you could say (let [write (partial write-interval store id iter-size)] ...)
13:52bbloomPigDude: see if you can use lazy-seq over lexical closures to create a sequence of operations to perform
13:53bbloomthen you can just doseq over that & call write in a tight loop
13:53PigDudejcromartie: interesting, i didn't know that was common, it looks good
13:54jcromartiealso destructuring
13:54jcromartie (loop [[iter-size & remaining] intervals
13:54PigDudebbloom: heh, i wouldn't understand how that worked though :)
13:54jcromartiethen lose the (let [iter-size… and replace (rest unprocessed) with remaining
13:54bbloomPigDude: sure you could
13:54PigDudejcromartie: oh ok! so that's like [H|T] in erlang
13:55bbloomPigDude: you're doing data transformation & side effecting in the same code. unless you need to do that for (meausred!) perf reasons, you should always try to separate those out. you'll get shorter/cleaner code that is easier to debug
13:55mordocaiSo, i have a theory, but can someone explain to me how the % works in ,(take 10 (map vector (iterate inc 1) (iterate inc 2)))
13:55mordocaiWrong paste
13:55mordocai,(map #(map + [5 3] %) [[-1 0] [1 0] [0 -1] [0 1]])
13:55clojurebot((4 3) (6 3) (5 2) (5 4))
13:55PigDudejcromartie: but this function only recurs from two of the branches
13:56bbloomPigDude: in this case, you'd do something like (defn log-entries [args...] (let [rec (fn [state] ...)] (lazy-seq (rec initial-state)))
13:56PigDudejcromartie: so i can't just put the recur at the bottom ... see the branch ordering, this is what i'm having trouble w/ too. and now i'm overwhelmed :( let me take a breath
13:56jcromartieyeah :(
13:56bbloomwell i guess you need (fn rec [... so it can make the recursive call :-P
13:56lemonodoranyone using coveralls.io & clojure (with lein-cloverage)? I’ve followed the steps at http://blog.bfontaine.net/2014/02/15/using-coveralls-with-clojure/ and it mostly works, but coveralls has trouble finding my source files: https://coveralls.io/files/195713441
13:56bbloomPigDude: if you use a lazy seq, you don't need to worry about tail position as much b/c the tail calls happen on the caller stack when the lazy seq is traversed
13:57PigDudebbloom: what you don't see at the top is that log entries are in increasing size, so it's very expensive to pull out an entry you don't need
13:57PigDudebbloom: or to operate on one unnecessarily
13:57PigDudebbloom: ok, i think i need to use lazy-seq to abstract this, i'll study it more now
13:58bbloomPigDude: i'm not sure what you mean by that. guessing from looking at this you only hit some external oracle for the fetch-index call
13:58bbloomeverything else seems output-only, no?
13:58PigDudebbloom: the way it actually works is by limiting key size, but to be space-efficient and correct it tries to fit as much as possible in a key
13:59PigDudebbloom: the index itself is just stored in another key; it's meant to work on nything that stores keys and values
13:59PigDudebbloom: so it's not write-only because keys get moved .. a problem in the design i'm working on, but w/ growing key size like that, i think you have to move keys
13:59bbloomPigDude: the result is nil, correct?
14:00PigDudebbloom: yep
14:00seangrovebbloom: Progressing on being able to quickly layout nested components http://dl.dropbox.com/u/412963/Screenshots/ek.png
14:00bbloomPigDude: it might be worth studying how Fipp uses mapcat-state such that this is the only "side effect" of the entire pretty printer: https://github.com/brandonbloom/fipp/blob/master/src/fipp/printer.clj#L215
14:01bbloomPigDude: not saying that this code is perfect. i'd rather a "yield" like operator, but the trick of mapcat-state is pretty general & it's so much nicer to debug this code than something with interleaved effects
14:01bbloomseangrove: more details?
14:02PigDudebbloom: thanks for the good code example!
14:03seangrovebbloom: This is composing look-less/layout-less components, and applying the style/layout separately. The screenshot is laid out via the extended/hacked ui-pass system
14:03PigDudebbloom: and don't worry, i write some pretty-ish functions too :) https://www.refheap.com/1b262e07aefa75a558d14b230
14:03bbloomseangrove: cool
14:03PigDudebbloom: (i'm sure that could be shortened too!)
14:05cbpmordocai: % is a placeholder for a variable in an anonymous function
14:06cbpmordocai: http://clojure.org/reader look there for anonymous functions
14:06mordocaiAm I right in thinking that #(< -1 % size) is the same as (fn [item] (< -1 item size))?
14:06cbpyes
14:06mordocaiKk, that was what was confusing me. Either the book didn't explain it or I didn't grok it lol
14:07cbpjoy of clojure isnt a beginners book
14:07mordocaiMeh, it is close enough. That's the first thing so far that has confused me.
14:08mordocaiIf I was new to programming too though...
14:10stuartsierramordocai: a common mistake is #([:foo %]) which expands to (fn [x] ([:foo x]))
14:16mordocaistuartsierra: Would the correct version be #(vector :foo %)?
14:16stuartsierramordocai: Yes, or just (fn [x] [:foo x])
14:18bbloom#(-> [:foo x])
14:18bbloom:-P
14:18stuartsierraOh no
14:18stuartsierraHere we go again.
14:19bbloomhaha
14:20coventrybbloom: Does t/each not call its argument when the value from mapcat-state is nil? The example at https://github.com/brandonbloom/transduce#usage could maybe use a little clarification.
14:22bbloomcoventry: sorry, i'm not sure i follow what's not clear.... each calls its function on each element of the sequence resulting from the mapcat
14:22bbloomcoventry: each doesn't look at the state at all
14:22bbloomcoventry: each is just a function version of doseq
14:24coventrySo in the case switch, :n returns [arg nil], :c returns [n (repeat n arg)], I guess the :c case is producing the "abcd" characters in the output, why doesn't [arg nil] produce some representation of nil?
14:24coventryShould probably just read the source.
14:25bbloom,(print nil)
14:25clojurebotnil
14:25bbloomer rather:
14:25bbloom,(print-str nil)
14:25clojurebot"nil"
14:25bbloomer nevermind, i forgot what the example was
14:26cespareIs there a way to run a single clojure.test test?
14:26technomancycespare: deftest macroexpands to a defn
14:26bbloomoh dur... coventry: it's b/c ##(apply mapcat (repeat 5 nil))
14:26lazybot⇒ ()
14:26bbloomcoventry: nil could just be []
14:26bbloomyou don't need the src to understand it
14:27coventryOh, right. Thanks.
14:28cesparetechnomancy: what about fixtures?
14:29technomancycespare: my understanding is you'd have to call the fixture function with the deftest as the arg
14:30bbloomcoventry: i had forgotten the example so i thought you were talking about ##(str nil)
14:30lazybot⇒ ""
14:31coventrybbloom: right, and I was reading mapcat-state as map-state.
14:38coventryIt'd probably be clearer if you showed the output of map-state, then mapcat-state with print to show the idea of using it to separate the side-effect from the pure calculation.
14:38bbloomcoventry: had you read mapcat-state correctly, would it have been clear? :-P
14:52llasramHas anyone done a persistent sorted set of unboxed longs?
14:54hiredmanllasram: dunno, you could wrap https://github.com/ztellman/immutable-int-map as a set I suppose
14:55llasramhiredman: I was thinking of that... Also looks like the referenced original work includes sets
14:55hiredmanI assume it stores keys as primitives
14:56hyPiRionllasram: do you need them to be mergeable? Otherwise I would guess judy arrays would be more performant
14:57hiredmanperformant or use less memory?
14:58hyPiRionExcept hrm, not sure which operations you need on the set?
14:58hiredmanoh, I am thinking of a patricia trees
14:58hiredmanor tries, whatever
14:59llasramhyPiRion: Yeah, merge-able. I'm trying to decide how far down the yak-shaving hole I want to go making a friendly HyperLogLog++ implementation
14:59sm0keso i have this testing utility class which has changed over versions, of a library i am using. How do i test against different class versions? anything better than reflection here?
15:00sm0kesomething clean and clever which can be done with lein pofiles may be?
15:02nooniansm0ke: that sounds doable, should just be able to put the different deps in different profiles and invoke lein with the correct one, you probably want the different deps + some common ones so i think lein has a syntax with the specific profile and a '+'
15:02sm0kenoonian: yes true, thats what i am already doing
15:03hyPiRionllasram: I'd guess hiredman's recommendation is the best then
15:03sm0kebut the problem is the same class which was called FooBar in profile :foo1.1 is FooBarBaz in profile :foo1.2
15:04noonianick
15:04sm0keso i need something like different test source paths itself
15:04sm0kehurm even that is doable
15:04hyPiRionsm0ke: put the tests separately through test-paths in the profiles
15:04noonianyeah, which is also doable, but not nice because you basically need duplicate directory trees
15:05sm0kehyPiRion: exactly my thoughts :D
15:05sm0kenoonian: i dont see any other way also
15:06sm0kereflection is more ugly here
15:06hyPiRionsm0ke: you could maybe set the :default test selector in :test-selectors, although that wouldn't remove compile errors
15:07noonianor you could use env variables (or in project.clj profiles using environ) and have a macro that checks the env and inserts the correct class?
15:07sm0keyea, also it would be too much work, excluding tests, or putting annotations
15:07nooniannot nice at all
15:08sm0kei guess duplicating same code namespaces according to profiles is better
15:09sm0keso the default test path is everything under /test right? i need to fix it to something like /test/common in main profile
15:09noonianyeah, i'd probably go with that
15:09sm0keand add /test/foo1.x in each profiles?
15:10hyPiRionyeah
15:10hyPiRionthat's the most evident I guess
15:10sm0kethanks noonian hyPiRion
15:19coventrybbloom: Yeah, but I tend to misread a lot more when I'm looking at alien expressions of a calculation.
15:25bbloomcoventry: the library is simple enough to read it its entirety in about 3 minutes, so i don't feel compelled to overdo the documentation :-P
15:42dkinzerfg
15:43bbloom^c
16:17gyimIs there a Clojure library that makes it easy to trace a running multi-threaded application? For example, I want to know whether a function was called (on another thread), what argument it got, etc
16:18gyimwhen I have to do this I usually redefine the function in question, add some logging, etc - it works, but I wonder whether somebody made a lib for this
16:18ambrosebsgyim: seen tools.trace?
16:22gyimhmm, i checked it before, but i overlooked its (trace-ns) and (trace-vars) functions...
16:32gfrederi`reiddraper: have I bugged you about using seeds on individual trials instead of larger runs?
16:33gfredericksI think I remember doing that
16:38gyimanything more versatile than tools.trace? For example, I might want to measure invocations/secs for a function, or write a log only if a condition holds on the function arguments
16:39justin_smithgyim: well, you can get a lot of info from a good jvm profiler
16:39gyimno, my primary focus is live debugging
16:40gyimfor example, i see null pointer exceptions in the logs => i want to check what input the function got
16:41gyimi am thinking about writing a small lib for these things, but if such a tool exists, it's even better...
16:52mikerodI'm getting the infamous "clojure.lang.Compiler$CompilerException: java.lang.ClassFormatError: Invalid method Code length 248014 in class file <fname>" . For some reason I was under the impression that this was only an issue with AOT-compilation. I suppose not?
16:53mikerodI see it comes from a "<ns-path>s$fn__15616$fn__15617" sort of class name.
16:53mikerodThis is with a macro expanding into a large fn-body.
16:54mikerodSo I guess this has to get a class generated to represent it, and therefor can overflow the method size limits. Regardless of AOT vs not.
16:54amalloymikerod: right. every function definition is a class definition
16:54amalloywhether those ever appear on disk dosen't matter; the classes still have to follow the jvm spec
16:55mikerodamalloy: I've been able to "dodge" the issue of large literals by not AOT'ing a ns before. So I guess some paths are different in regards to this.
16:56mikerodI guess I find it tricky to see where the lines are really drawn.
16:57mikerodI understand the the fn is getting compiled into a JVM-spec class. I'm assuming the fn-body ends up occumpying a single method body to some degree.
16:58amalloyyes, each arity is exactly one method body
16:59mikerodamalloy: So in the case of large data literals, there is a difference between AOT vs non-AOT though? This sort of relates to a really old post https://groups.google.com/forum/m/#!topic/clojure/5VZDSjgt6BQ.
17:01amalloyseems plausible. i don't know a lot about that
17:01mikerodI've read up on this a bit before and inspected the Compiler some. It seems like it comes down to whether or not the code you are generating with the macro needs to be held in a class or not.
17:02mikerode.g. if I make a macro that generates a huge map, it doesn't need to be held as a class constant, if not AOT
17:03mikerodHowever, if I do it in a fn-body, I'm curious if it now needs to be held in a constant.
17:03mikerodThese things are subtle.
17:17jdkealyanybody use the friend library and know how to handle sign-up? I can create a user in datomic, but don't know how to log the user in. Right now i'm redirecting to login after sign-up
17:19sritchiejdkealy: yeah, I can help
17:20sritchiejdkealy: you have to make a new friend workflow that intercepts posts to the signup route
17:20sritchie(and (= uri "/signup")
17:21sritchie (= request-method :post))
17:21sritchie(when (and (= uri "/signup")
17:21sritchie (= request-method :post))
17:21sritchiejdkealy: here's what I do
17:21sritchiehttps://gist.github.com/sritchie/e7c6135aa7eab706544c
17:22sritchiethat's the workflow I made, rather
17:44expez(gdom/getChildren (gdom/getElement "queue")) <- why does this return an array when called with regular javascript, but in clojurescript (type...) returns #<function HTMLCollection() { [native code] }> ?
17:44expezI tried mapping over this result and was surprised.
17:46expezIs this even the recommended way to grab stuff out of the dom occasionally, or should I be using something like jayq?
17:47nullptrexpez: that returns NodeList, which is considered "ArrayLike" in google closure speak
17:48expez!(Array | NodeList) <- what does this type notation for getChildren from the google api mean?
17:49nullptrit means it returns an array or a nodelist, and doesn't return null
17:49expezIs this their notation for either? And Chrome just happened to tansform a NodeList into an Array before I saw it in the console?
17:49mmitchellre. prismatic's schema -- anyone know if it's possible to have a coercer rename a key?
17:50nullptrexpez: if you see the code it returns element.children when possible, but falls back to goog.array.filter for IE8
17:52expeznullptr: thanks. Is it common to use something like jayq, or do most clojurescript projects try to rely on the closure library as much as possible?
17:52nullptras closure library is a superset of jquery (excluding third party libs) i would certainly advise not including jquery for the core functionality
17:52nullptrit's much lighterweight to use the closure stuff given that its optimized for adv compilation
17:53expezeveryone already has every version of jquery ever published on their computer it's connected to the internet :)
17:53nullptreven if it's in cache, it still has to parse/load it
17:54nullptrif you do lots of dom selection and don't mind paying a slightly higher cost than goog.dom will impose there's always goog.dom.query
17:57expezhmm, can't find the api docs for that namespace
17:58nullptrit's under third_party in the actual closure-library source if that helps
18:05martinklepschWhen I want to do upserts with elastisch do I need to use the native client or can I somehow do that using the rest client too?
18:27bbloomsometimes i forget just how hard it is to write a macro without having first written the code that the macro will expand to
18:27bbloomi know for a fact i'm going to need a macro, so i start typing it... and fail hard... then i write it by hand 3 times, and the macro impl becomes obvious
18:29amalloybbloom: does having a concussion help with the macro writing?
18:29bbloomamalloy: only one way to find out
18:31SegFaultAXbbloom: I find it's usually easier to work backwards from the expanded form anyway.
18:31SegFaultAXEven if I know exactly how I want to write the macro.
18:38bbloomSegFaultAX: oh yeah, totally. which is why i'm beating my own head for skipping ahead prematurely :-P
18:47programmancerMy IRC bot insists it saw the following raw message: " t o b 0 r k ... ..."
18:47programmancerI can not possibly imagine this is a legal message according to the specs.
18:47bbloomsounds like somebody is trying *to b0rk* your parsing code
18:48programmancerDo networks generally follow the specs? Or do they consider it more of a general guide line?
18:48programmancerThey succeeded with flying colors.
18:48Frozenlo`err... what's the way to solve the 'NodeList is not iseqable' in cljs?
18:48programmancerI can change the parser, of course, but I wonder what else the networks may have in store for me.
18:48programmancerI suspect they may be including line breaks in their MOTD.
18:52programmancerThey're supposed to end the line with \r\n, but I suppose they could be sending multiple lines separated by \n and then ending them in \r\n.
19:15Glenjamini'm experimenting with the full form of (reducers/fold) - [combinef reducef coll], if my reducef doesn't support an arity-0 call i get an exception
19:15Glenjaminbut according to the docs, only combinef should be called with 0 args
19:16Glenjamincould anyone point me at what i'm doing wrong?
19:23amalloyGlenjamin: could you paste a specific example?
19:26Glenjaminhrm, in trying to distil a reproducible case, it's started working...
19:27amalloyas is so often the case
19:27Glenjaminah, no it hasn;t
19:28Glenjaminalthough i think i have found the problem
19:28Glenjaminseems to be a bug in immutable-int-map
19:40Glenjaminyep, slight oversight when extending CollFold to the collection - https://github.com/ztellman/immutable-int-map/issues/2
19:43Glenjaminalthough i'm struggling to think of an example where the combining function would return a different identity to the reducing function
19:49amalloyGlenjamin: that happens all the time, just like when you reduce and your initial value is of a different type than the list elements
19:50Glenjaminfor the inner reduce to work, it has to know what the type of acc is in [acc x], but with fold acc is supplied by combinef
19:51Glenjaminso when would (not= (combinef) (reducef))
19:57amalloywell, i guess at the moment i can't think of any. it's been two years since i really dealt with reducers
19:57amalloyi'm pretty sure at the time i believed it made sense
19:57amalloyhave you read the stuff at http://clojure.org/reducers, Glenjamin?
19:58Glenjaminyeah, reading it again now
19:58Glenjamini think it makes sense that the combinef "owns" the collection to reduce into
19:59Glenjaminbut assuming you write a reduce, then expand into a fold - i think (combinef) and (reducef) will always be the same
20:00Glenjamini might post this on the mailing list, there must be a possible example :s
20:08Glenjaminah, got it
20:08Glenjaminthe reducing function can be polymorphic
20:09Glenjaminand re-used with different folds
20:09Glenjaminbut the function producing the value has to decide what it's producing
20:54toanhi guys, i'm over confused by this bit of code.
20:54toan> (reduce #(+ (* % 2) %2) 0 '(1 0 1 0 1 0) )
20:56toanit returns the right bin to dec value, 48
20:57dbasch,(reduce #(+ (* % 2) %2) 0 '(1 0 1 0 1 0) )
20:57clojurebot42
20:59toanyeah, sorry 42
20:59dbaschbtw, you don’t need the 0 before the list
20:59toanthx, maybe that maybe clearer for me
21:00amalloyunless he wants (bin2dec ()) to be 0 rather than an exception
21:00toanah
21:00amalloyor, no, i guess it'd be 0 anyway
21:01amalloystill, i don't think adding the explicit 0 as a starting-point is bad
21:01dbasch, (reduce #(+ (* %1 2) %2) '() )
21:01clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox/eval55/fn--56>
21:01dbaschmatter of taste I guess
21:02toani'm just really confused.
21:02dbaschtoan: what about?
21:02toanin this example the first element to get worked is the first one, correct?
21:03toanhow does the become 2^5?
21:04dbaschbecause reduce keeps the result and applies the function to that and the next element
21:04toanoh...
21:05toanthat's tricky
21:05toanthx!!
21:05toanthat's why the dummy %1 was necessary
21:05dbaschyes, “f should be a function of 2 arguments”
21:06amalloydummy? in what way is %1 there a dummy?
21:06dbaschit’s not a dummy, it’s the first argument
21:06toanwell, i'm new, so i guess the term is incorrect
21:06toanplace-holder if you will
21:07dbasch,(doc reduce)
21:07clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i...
21:07amalloythe word isn't wrong, the meaning is. placeholder is just as wrong: that %1 is an important part of the computation
21:08toanso what would be the term to describe the value assign?
21:10dbaschtoan: it’s the same as (fn [arg1 arg2] (+ (* arg1 2) arg2))
21:10toanbut, also thanks for the help.
21:10amalloyi mean, it's a function argument. in a reduce, it's often called the accumulator (the value you're building up)
21:10toanfair enough
21:11toanaccumulator. thx
21:12toanthis shit hurts my brain
21:15dbaschtoan: programming hurts everyone’s brains at some point
21:20toan=)
21:23gfredericksreiddraper: I just spent 5 hours tracking down a bug that I'm 90% sure results from test.check using stateful randomness
21:24reiddraperYeah?
21:25gfredericksbecause bind needs to consume randomness during the shrink process
21:25gfredericksso the shrink tree is sensitive to what order you walk it in
21:25gfredericksI don't think this effects normal users
21:25gfredericksjust people like me who tweak things :)
21:26gfredericksI'm wondering if this could be fixed in bind without overhauling all the pseudorandom code
21:27reiddrapergfredericks: hmm, ok. I'll have to give that some thought.
21:27gfredericksif I see a fix in bind I'll make a ticket
21:35reiddrapergfredericks: ok, thanks. Shrinking _should_ be deterministic, but that's a _should_, not _is_ :)
21:36gfredericksreiddraper: if you're curious, here's my repro code: https://github.com/fredericksgary/test.check/blob/fork-debug/scratch.clj
21:37reiddrapergfredericks: I'm out now, but will take a look when I can, thanks
21:37gfredericksnp
22:50l1xwe should build a website, core review as a service
22:50l1xcode*
22:50l1xtalking about code reviews, is there anybody willing to go through ~300 lines of clojure and give me a review?
22:51rpaulol1x: depends; CRaaS is a premium paid service these days...
22:51rpaulo:p
22:52l1x:)
22:52l1xi am the only clojure dev in the office and even scala guys just meh on my clojure, no real interest to learn, understand it
22:53l1xbut this channel is actually pretty good in terms of best practicies
22:53seangrovel1x: I think it's just GitHub and making projects ;)
22:53l1xbeen there, done that :)
22:54Jaoodbut scala has strong type system...
22:54Jaood:)
22:54l1xhahah, true that, so i can lose all of my hair over "why did you pass in a vector while i am expecting a list" sort of problems
23:13amalloyl1x: a good general rule: make it as easy as possible for someone to help you. nobody's going to say "yes, please, i want to help, can i have a link to your code", but if your request for code review includes a link, someone may be interested enough to have a look
23:29l1xcool :)
23:48MrMiracleevening all