#clojure logs

2015-09-30

00:16sm0ke,`memoize
00:16clojurebotclojure.core/memoize
00:16sm0keshouldbe in cljs.core
02:25amalloyakkad: (a) why do you need a bigger stack, really; (b) why is it a fight? just set the appropriate jvm option
03:24Guest21161i'm looking for a clojure library which i can use to navigate websites: fill in forms, login, download a file etc
03:30algernonenlive sounds like something you could use for that.
03:56nowprovisionenlive works well but won't handle any on page javascript
03:56nowprovisionpersonally I prefer phathomjs for this sort of stuff
03:57nowprovisionor actually even node.js with cheerio over enlive for extraction but for interaction phanthom js, and enlive as an alternative for building web pages (css path substitutions)
05:12marshzorif I have a seq that I'm fairly certain will always contain one element, is there a good way to extract that element? Currently I'm using (first myseq)
05:13marshzorI have a list of ui elements, each with an id. I get an event saying element with id=foo was clicked. so I get (filter #(= (:id event) (:id %)) ui-elements)
05:14hyPiRionmarshzor: you can do (let [[elem] myseq] elem) if you need to bind the result
05:14marshzorinteresting, let me give that a try
05:14hyPiRioner, I mean (let [[elem] myseq] my-code)
05:15marshzormhm I knew what you meant
05:16marshzordefinitely seems more sane than what I had, although I'm not sure how this would act if the seq actually did contain more than one element
05:16marshzor,(let [[elem] '(1)] elem)
05:17clojurebot1
05:17marshzor,(let [[elem] '(1 2)] elem)
05:17clojurebot1
05:17marshzorso is it just sugar for first?
05:17hyPiRionyeah
05:17marshzorah okay
05:17hyPiRion,(macroexpand '(let [[a] b] a))
05:17clojurebot(let* [vec__77 b a (clojure.core/nth vec__77 0 nil)] a)
05:32fehrenbach,(source first)
05:32clojurebotSource not found\n
06:00visofhi guys
06:01visofhow can i declare function with two options artgument in defprotocol?
06:02visof(defprotocol Hello (foo [a]) (foo [x y])) ? and handle it (defn foo ([x] "Hello") ([x y] "hello hello")) ?
06:02visofis this correct?
06:10bendlasapparently build.clojure.org is down and this prevents dependency resolution hence startup of projects depending on datomic
07:09visofis there any tool which can take file.clj and autoindent it?
07:53mavbozovisof, https://github.com/weavejester/cljfmt
08:24nowprovisionit's not perfect quite perfect, vim clojure plugin disasgrees with a small indent rule (which I think clojure style guidelines agrees with vim clojure)
08:24nowprovisionbut at least it diffs rather than forces the hand like gofmt (and vim-go)
08:33nowprovisionvisof, (defprotocol P (foo [this] [this arg2]))
08:33nowprovisionvisof, (defrecord R [] P (foo [this] this) (foo [this arg2] arg2))
08:52marshzordoes anyone know a good way to evaluate a seq of bools? I want to know if they are all true
08:53schmir,(doc every?)
08:53clojurebot"([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."
08:54tdammers,(all [true true true true])
08:54clojurebot#error {\n :cause "Unable to resolve symbol: all in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: all in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: all in this conte...
08:54tdammerspff
08:54tdammers,(and [true true true true])
08:54clojurebot[true true true true]
08:54tdammers,(apply and [true true true true])
08:54clojurebot#error {\n :cause "Can't take value of a macro: #'clojure.core/and"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/and, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Can't take value of a macro: #'clojure....
08:54tdammersthat didn't go as expected
08:55marshzoryep, that's what I was looking for schmir, ty
09:08dzhus`If I update dependencies in my project.clj, can I get CIDER to pick the up in the classpath without killing the REPL buffer and jacking in from scratch?
09:27schmirdzhus`: there's vinyasa that may help a bit (at least with new dependencies). upgrading probably doesn't work though (just guessing)
09:37ionthasIs there any way to apply a function to each vector inside a vector? (def v3 [[10 [1 2]] [30 [4 5]]]) I would like to apply a custom function to each vector. Using (apply) results on a "Wrong number of args exception".
09:37dzhus`ionthas: I believe you might use something from clojure.walk
09:38ionthasI will take a look, thanks!
09:51oddcullyionthas: sounds like map
09:53ionthasoddcully: I have done a loop/recur through all my vector and I apply the function to each vector. I supose there's a more idiomatic way to do it. :/
09:55oddcully,(map (fn [[_ v]] (apply + v)) [[10 [1 2]] [30 [4 5]]])
09:55nowprovisionyes clojure.walk if they are at unpredicable depths
09:55clojurebot(3 9)
09:55oddcullyi don't know, what you are after
10:16devn,(require '[clojure.walk :as walk])
10:16clojurebotnil
10:20devnwas going to drop an example, but yeah, might make more sense to hear what you're looking for
10:20devnsince oddcully's example will do what you first described
10:21justin_smithionthas: (for [subcoll coll] (apply f subcoll)) might do what you want?
10:24ionthasnvm folks I already solved the problem with a solution similar to the one provided for justin_smit. Thank your for your ideas.
10:24devn,(for [subcolls :)
10:24clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :>
10:24devnderp
10:30dzhus`I believe that using components library implies that I need to have a "main" function in my app that will actually start the components?
10:31dzhus`But I do `lein ring uberjar` to build my app which only requires ring routes to be defined, can I somehow tweak the main function it generates for me to include components startup?
10:33justin_smithdzhus`: do component startup in the function that returns your handler
10:39dzhus`justin_smith: I don't think that I have one. I have a defintion of my routes and handlers but no function that "returns" them
10:45justin_smithdzhus`: I forget if lein ring has a mechanism for this directly... but if nothing else you should be able to define the handler in terms of a delay (so that it only runs when the handler is to be used, and only runs on first usage)
10:46justin_smith(def initialized (delay (startup-system))) (def handler (fn [request] @initialized (real-handler request))
10:47justin_smiththe only problem with this is it makes the very first request to the newly started server wait for system init
10:48justin_smithdzhus`: LOL ignore the above hack - just look at the README here - use :init https://github.com/weavejester/lein-ring#general-options
10:48dzhus`duh, should have looked there
10:48dzhus`thanks
10:49justin_smithheh, np, but the delay trick is generally useful if you need to hack in init in something that doesn't provide the option :)
12:21hlolliwho's would know of cleaver way to make a function that finds the avarage of two numbers in a list and put into new list, so I could get: [0.5 1.5 2.5 3.5] from [1 3] and [0 1 2 3] from [0 2]
12:23jeremyheilerhlolli: use something like (map avg (partition ...))
12:23jeremyheilerand then flatten it
12:24justin_smithjeremyheiler: or you could just use mapcat instead of map
12:24justin_smithflatten is pretty terrible
12:24hlolliso far I have (vec (flatten (for [[x y] (partition 2 1 on-s)]
12:24hlolli (list (- y (/ (+ y x) 2)) (+ y (/ (+ y x) 2))))))
12:25jeremyheilerjustin_smith: i meant the general idea of flatten
12:25jeremyheilerjustin_smith: trying not give the whole answer away ;-)
12:25justin_smithjeremyheiler: OK, well mapcat does that all in one go with your mapping
12:25jeremyheileryes, that' better
12:25hlolliwell, I use flatten shamelessly, damn.
12:25blake_I guess you'd have to.
12:26blake_I mean, if you had any shame...
12:26justin_smithhlolli: flatten has a few issues - it breaks things that could otherwise work with collections as arguments, and it can do unexpected things for some inputs
12:27blake_And speaking of shame, I have a realized LazySeq that refuses to be iterated over. What's up with that?
12:27hlolliok, never ran into any problems so far. Its just that some functions always return extra parenthesis. For example everyting after the & sign
12:28hlolliI know its for good reason, but I tend to flatten it or unqote splice it.
12:28blake_like, (map #(println %) my-lazy-seq) produces nothing.
12:28hlollitried doall ?
12:28blake_Yep.
12:28hlolliand take?
12:28blake_take?
12:29hlolli(take n coll)
12:29blake_huh, no...
12:29blake_I didn't know that was a thing. I'm still trying to figure out how this can happen.
12:30blake_Nope, (take n coll) doesn't work either.
12:30blake_Count returns the right number of items.
12:31blake_First returns the first item. Last returns the last item. Map produces nothing. For produces nothing.
12:31hlolli,(take 5 (map #(conj "hoho" %) (cycle "1")))
12:31clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IPersistentCollection>
12:32hlolli,(take 5 (map #(conj "hoho" %) [(cycle "1")]))
12:32clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IPersistentCollection>
12:33hlolli,(take 5 (map #(conj "hoho" %) (cycle ["1"])]))
12:33clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
12:33hlollilast time :)
12:33blake_heh
12:33hlolli,(take 5 (map #(conj "hoho" %) (cycle ["1"])))
12:33clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IPersistentCollection>
12:33hlollidamn, fukkit, I should do it in my own repl first.
12:34hlolli,(take 5 (map #(conj [1] %) (cycle [2 3])))
12:34clojurebot([1 2] [1 3] [1 2] [1 3] [1 2])
12:35hlolli,(type (take 10 (cycle "a")))
12:35clojurebotclojure.lang.LazySeq
12:35hlollicycle is a lazy seq....
12:36hlolliare you using the lazy-seq function?
12:36blake_Nope. I got this LazySeq out of a map.
12:37blake_It responds to no iterative requests from what I can tell.
12:37blake_If I say (into #{} my-lazy-seq) I get nothing back.
12:38blake_wait..
12:39hlolliwell, you may need to map/apply/reduce it.
12:39blake_It does response to (into #{}).
12:39blake_er respond to
12:39blake_I'm trying to map it and it acts as though it's empty
12:39blake_While claiming to have 2 items, showing me the first, last...
12:40hlolliyes, it doednt calcualte the lazy sequence. Is it infinite?
12:40blake_Nope, it's very finite. One or two items. I mean, eventually, it could be several dozen. But well short of infinity. =P
12:41hlollihow about (into #{} (doall my-lazy-seq)) or (map #(into #{} %) my-lazy-seq)
12:42blake_Newp.
12:42blake_Into [] and #{} do make "copies" but they won't iterate either.
12:42blake_This has to be something burningly stupid.
12:43blake_If first, last and rest work on it, how can map possibly not?
12:46hlolliIm very surprised, there is something you are overseeing, is I would see this I could maybe help better.
12:47blake_https://www.refheap.com/110118
12:47blake_Lotsa printlns in there.
12:47hlollihave you tried simply (apply hash-map lazy-seq)
12:50blake_That seems to wrap things up in another layer. Still doesn't iterate, though.
12:50xeqiblake_: for and map are lazy, those printlns never get realized and thus never print
12:51blake_xeqi: Hmm. OK. I have to think about that because they weren't originally printlns.
12:55blake_OK. So...I was using map for side-effects. That's gotta be the problem.
12:56justin_smithblake_: didn't someone ask about doall?
12:56blake_justin_smith: Yeah, and I had doall.
12:56justin_smithin the wrong place then?
12:57justin_smithblake_: in 1.7 you can use run! instead of map (if you don't need the return value) - same arg usage
12:57blake_justin_smith: Yeah. And I was testing with (map (println... which I shouldn't do. And then following it up with a map to produce side-effects.
12:57justin_smithblake_: ahh, OK
12:58blake_justin_smith: The issue (mentally) is that I'm thinking in pure functions--but underneath I've got a Java object.
12:58blake_When I transition between them, I have...issues.
14:08sven42Hi - is there any way to call elisp functions from the clojure cider repl? I want to (read-string "prompt:")
14:14mgaaresven42: eval-last-sexp
14:23trissso how would you chaps go about parsing blobs of EDN out of a Markdown file?
14:23trissspecificly keywords and maps
14:24trissI really want to associate the blobs of EDN with the most recent header in the markdown some how too.
14:39TimMctriss: Arbitrary EDN would be hard to spot, yeah.
14:39TimMcFor example, this sentence contains 9 valid EDN blobs.
14:40trissyup. but I'm just after keywords and maps
14:41trissso this sentance only :contains only {2 "EDN blobs"}
14:41trissor is that 5 I guess....
14:41trissthink I'm gonna just reg-ex for them and then parse
14:42TimMcI'd look for #"(^|\s)[:{]" a pushback reader try feeding those into read.
14:42TimMc*in a
14:42trissdo any of the clojure based markdown libs give you nice structured output?
14:42trissTimMc: precisley what i'm thinking!
14:43numbertenwill throwing an exception short circuit a let binding in clojure?
14:43TimMcAre you going to be running your documentation through tests? :-D
14:44TimMcnumberten: Like in (let [a (/ 1 0) b (println "b")] ...), you're wondering if b's value is computed?
14:44numberten(let [a 1 b (throw (Exception. "bad")) (c (foo b))] (etc))
14:44numbertenseems dangerous, if the entire function doesn't propagate the exception
14:45numbertenTimMc: yeah that
14:45TimMcWell, the exception stops execution of the entire let expression, so yeah, further bindings are not evaluated -- nor the body.
14:51numbertenthanks
15:25amalloyso guys, i realized the other day that `(~x ~@xs) is fewer characters than (cons x xs). alert the press, we don't need cons anymore!
15:26oddcullyfetch me my codecolf putter
15:29fuuduCodersmetimes verbosity matters :-P
15:49ghadishaybanoh man I miss clojure.
15:49ghadishaybanbeen doing python and Spark lately
15:49ghadishaybanLanguages Matter.
15:50aaelonyghadishayban: are you doing Spark from Clojure?
15:51aaelonyghadishayban: also, is it reasonable to try to do python via pixie-lang with clojure syntax ?
16:03neoncontrailsaaelony: your suggestion kind of reminds me of a project I've been mulling over. How hard do you think would it be to implement a Python interpreter in Clojure?
16:05aaelonyneoncontrails: wouldn't it be great to use libs like scikit-learn from a clojure syntax?
16:05neoncontrailsIt seems like one of those projects which would be easy to set up, but possibly hard to get right. Lots of edge cases
16:05aaelonycertainly
16:09ghadishaybanaaelony: not from clojure. Team isn't really Lisp / FP oriented
16:09neoncont_Sorry, battery died. Can you think of any technical hurdles that would make interpreting scipy from Clojure painfully difficult?
16:10neoncont_If I'm not mistaken, part of the magic of scikit comes from a C-based implementation
16:37xemdetianeoncont_, it seems faster just to get jython and clojure to talk :)
17:03aaelonyghadishayban: I think both https://github.com/gorillalabs/sparkling and https://github.com/yieldbot/flambo offer Spark use from Clojure
17:06aaelonyneoncont_: not sure, but this talk on pixie got me thinking these crazy-like ideas about using python libs from clojure syntax... https://www.youtube.com/watch?v=1AjhFZVfB9c
17:23TEttingeraaelony: ghadishayban left, I wanted to mention that I encountered some pitfalls trying to get some spark concepts to carry over to clojure
17:24TEttingeraaelony: it is neat how clojure seems to be revitalizing lisp dev a bit, that and racket
17:24TEttingerpeople seem to be more willing to make new languages that are unashamed to use parentheses
17:27aaelonyTEttinger: I agree. Speaking for myself, I find that it is easier to come back to a project and figure out what is going on just by looking at each function involved. In other languages, it's unclear what an object is doing under the hood and what is being changed inadvertently or mysteriously. Just my 2 cents.
17:28justin_smithTEttinger: you can't really use python libs from pixie though.
17:28justin_smithTEttinger: it uses rpython to compile a vm that does not contain the python runtime - the python runtime would be a separate (and I think incompatible) target for rpython. Pixie doesn't load python libs.
17:29TEttingerTEttinger is not who you mean
17:29aaelonyaaelony: I plead ignorance here. But it would be cool if it were so.
17:29justin_smithTEttinger: oh, sorry
17:29TEttingerhehe
17:30justin_smithaaelony: my above directed at TEttinger was actually responding to what you said
17:30aaelonyjustin_smith: I realize that
17:30aaelony:)
17:33mcescheriosjdf
17:33mceschersorry
17:33justin_smithtoday's contestants in "tech acronym or keyboard noise" are...
17:34anei once sneezed and wrote tanstaafl when i meant to write that is
18:00blake_Hey, all: Trying to use wrap-anti-forgery and ALL my POST pages are returning Invalid Anti-Forgery Token. I can see the token inside the page. I used the (anti-forgery-field) function. I put csrf/wrap-anti-forgery just above session.
18:00blake_And yet...