#clojure logs

2013-04-04

00:34davidchambersWhy does (keys "") return nil, whereas (keys "abc") is an error?
00:34davidchambershttp://stackoverflow.com/questions/15802559/why-does-keys-return-nil-in-clojure-whereas-keys-abc-is-an-error
00:38amalloydavidchambers: because (seq "") is nil
00:38amalloyand (keys m) is (map key (seq m)), more or less
00:39davidchambersamalloy: thanks, that makes sense
00:40tupihello. i am using clojure to write [learning to] imagej [no GUI] scripts. to strat with, i am trying to translate a small java code which comes from a marco recorded session... i see this line: "Prefs.blackBackground = true;" and the doc tells me ij has a Prefs class, the doc says: public static boolean blackBackground. how would I write the correspondig clojure expression?
00:43xeqitupi: (set! Prefs/blackBackground true) I think
00:44tupixeqi: tx
00:52tyler_whats a function to see if something is in a collection
00:53tyler_i tried contains? but that wasn't what i was looking for
00:53xeqi~contains
00:53clojurebotcontains is gotcha
00:53xeqihmm, did that text change?
00:53n_b,(doc contains)
00:53clojurebotGabh mo leithscéal?
00:54xeqityler_: ##(some #{:x} [:a :b :c :x])
00:54lazybot⇒ :x
00:54xeqi&(some #{:x} [:a :b :c])
00:54lazybot⇒ nil
00:54bbloomlynaghk: ok i can finally look at mysteries now, if you haven't solved it yet. heh.
00:54tyler_thats clever heh
00:54tyler_xeqi: thnx
01:15tupiin java they do: RoiManager rm = RoiManager.getInstance(); if (rm==null) rm = new RoiManager(); which i translated to:
01:15tupi(import '(ij.plugin.frame RoiManager)) (let [rm (RoiManager/getInstance)] (when-not rm (set! rm (new RoiManager))))
01:15tupibut rm is immutable, what would be the right thibg to do ?
01:16xeqi(let [rm (or (RoiManager/getInstance) (RoiManager.))] ...)
01:16RaynesI like to think RoiManager is a way to keep track of your illegal steroid injection plan.
01:17tupiof course! tx. sorry to ask basic Q, i am a beginner
01:17Raynesxeqi lives to serve.
01:19tupiin scheme, anythink that is not #f is #t, can i say in clojure anything that is not nil is true ?
01:20amalloytupi: anything that is not nil or false
01:20tupiok
01:22alex_baranoskyis anyone using reducers regularly?
01:25bbloomalex_baranosky: if you have an underlying question, ask that directly
01:26RaynesUh oh.
01:26RaynesA veteran just got "ask your real question"'d.
01:26Raynes~anyone
01:26clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
01:27alex_baranoskyfortunately, I was asking the question I care about
01:27RaynesI suspected as much.
01:28SegFaultAXBro, do you even Lisp?
01:28bbloomRaynes: i wasn't sure if there WAS an underlying question
01:28alex_baranoskywondering if anyone uses them regularly. They seem like something with a lot of potential but I don't hear people talking about them a ton.
01:28bbloomalex_baranosky: i said that because i'm using reducers in fipp, but not for their parallel nature
01:28bbloomalex_baranosky: so i didn't know if you were looking for popularity figures or help
01:29alex_baranoskybbloom: what do you use them for if not their parallel nature?
01:31bbloomalex_baranosky: they save the significant overhead of creating intermediate structures, so if you don't need laziness, they are a big perf win
01:31alex_baranoskybbloom: nice, there's a perfect example of something I should know more about
01:32bbloomalex_baranosky: https://github.com/brandonbloom/fipp/blob/master/src/bbloom/fipp/transduce.clj#L41-L44
01:32alex_baranoskybbloom: I was reading the implementation a while back, is it true that only vectors parallelize?
01:32bbloomthat's the reducer equiv of doseq
01:32bbloomthat each function is eager
01:33bbloomi use reducers to pipeline side effects at the end of the pipeline
01:33bbloomalex_baranosky: like i said: i don't use the parallel features :-P
01:33bbloomalex_baranosky: i stick a lazy seq in the top of the pipeline, so i'm guarented to be linear
01:34bbloomalex_baranosky: but each reduce function calls the next reducer function directly, which means that space complexity for intermediate data structures is constant.... and that constant is zero
01:34bbloomno chunking or anything like that
01:35alex_baranoskyfascinating
01:37alex_baranoskybbloom: space complexity is not something I've spent a ton of time thinking about
01:37alex_baranoskyI'm curious what your motivation for writing a better pprint are?
01:38bbloomalex_baranosky: ah, now i remember why your name is familiar! you had emailed me a while back when i mentioned i was between jobs :-)
01:39alex_baranoskybbloom: yep, that was me
01:39bbloomalex_baranosky: heh, so i wrote a better pretty printer sort of by accident. i never actually got around to the thing that had me researching it in the first place
01:39amalloyalex_baranosky: saving the allocations is probably a bigger win than parallelizing, since you can do the former all the time, and something concurrently foldable is not that common
01:39bbloomalex_baranosky: i wanted to experiment with some ideas regarding stylesheets & aspect-oriented rewriting of propertied trees
01:40amalloycertainly it's not true that only vectors can fold in parallel; anything can implement coll-fold. at the moment, i don't know of anything else that *does*, unless you count patches that haven't been applied to master
01:40bbloomalex_baranosky: my thought was that pretty printing could have colors or line breaking preferences that would be something i could apply stylesheets to play with
01:40bbloomalex_baranosky: what i discovered was that pretty printing is kinda complicated, heh
01:40bbloomalex_baranosky: so i got side tracked implementing an interesting algorithm, and never got around to the propertied tree beyond the basic pretty print document primitives
01:41amalloyeg, i submitted an impl of (reducers/range min max step) that can fold itself in parallel
01:41bbloomalex_baranosky: i thought pretty printing would be easier than a full on application/browser DOM, but apparently everything is always harder than it appears & my attention span is shorter than anticipated always
01:41devnHow do people generally choose to refer to set and string in the arglist of your function definitions?
01:41alex_baranoskyamalloy: yeah, so anything *Can* but by default only vectors do, cool
01:41devnspecifically "set" -- what do people use when a function specifically expects a set
01:42alex_baranoskybbloom: doing anything well could take a year or two :(
01:42amalloyalex_baranosky: that's not a very good summary. not every data structure can fold, and "by default" is misleading
01:42amalloyanything that can access bits of itself at random and knows its final size can implement fold, but not every data structure can do that
01:42bbloomamalloy: can proper linked lists fold? not really, unless you count the degenerate case of linear traversal
01:43alex_baranoskydevn: I have adopted this approach (defn f [foo-set] (set/difference foo-set #{:a})
01:43wliaoHi, is there a way to get macroexpanded source code during clojure compilation process.
01:44amalloybbloom: not really. you could implement it to walk over the list once to start, and then chop it up and reduce the chunks in parallel. if your reducef is much more expensive than walking the list, that'd be a win
01:44bbloomamalloy: ok, but that's assuming a finite sequence. probably the right API design choice to disallow that & force a `vec call
01:45amalloyyou certainly can't do it lazily
01:48tupihum, in the methods class summary i see getInstance, so i can use it in clojure like RoiManager/getInstance, but in the same summary i see runCommand, but (RoiManager/runCommand rm "reset") fails - translating java: rm.runCommand("reset");
01:49bbloomalex_baranosky: space complexity is something i've recently been thinking about a lot
01:50bbloomalex_baranosky: more generally, i keep finding that a surprising number of things can be thought of in terms of space vs time. not just algorithmic complexity
01:50alex_baranoskywhat project brought it to the forefront for you?
01:50alex_baranoskythere's probably something for me to learn around these concepts
01:51bbloomnothing really in particular. clojure has just fundamentally changed how i approach problems & a big part of that is rich's views on identity and value
01:51bbloomi feel like clojure has a damn near perfect model for working with finite data and instantaneous time
01:51amalloy(.runCommand rm "reset")
01:51bbloomit also provides a quite reasonable and far from broken model for working with time, timelines, and infinite data
01:52bbloombut there is so much more to explore there, i think
01:52bbloomand then when i started playing with factor & concatenative programming, i realized that you can even think of stack machines vs register machines as time vs space
01:53bbloomor consider variable bindings: lexical scope assigns a value to a name for an extend of space, but dynamic scope assigns a value to a name for an extend of time
01:53bbloomit's quite amazing how often computer science dualities can be reframed in terms of space vs time
01:54bbloomso now i just think about those two words/ideas anytime i encounter anything :-P
01:55alex_baranoskybbloom: don't dynamic bindings assign a variable for time as well as space?
01:57bbloomalex_baranosky: it's from push-thread-bindings to pop-thread-bindings. the binding macro has some notion of space, but that's just one composition of push & pop bindings
01:57alex_baranoskybbloom: I think there's some food for thought there. I recently worked on a project with work where I had to care about memory usage and calculation time more than in the past and I learned a lot in the process. I'd like to explore more of how reducers can also teach me something
01:58bbloomalex_baranosky: so not sure if reducers per say offer this idea uniquely. i assume you can get this same effect w/ regular lazy sequences, but fipp relies on "state transducers"
01:58bbloomalex_baranosky: and specifically, to accomplish the bounded space requirement, they are "finite state transducers"
01:59bbloomessentially little state machines that take messages in, do some processing against local state, and send some messages out
01:59bbloomeach step in the pipeline can be thought of like a little agent
01:59bbloomnot quite a clojure agent, which is not quite an erlang agent
01:59bbloomsimpler than both
02:00bbloomhere's map-state: https://github.com/brandonbloom/fipp/blob/master/src/bbloom/fipp/transduce.clj#L13-L24
02:00bbloomessentially, each mapper function returns [new-state mapped-value]
02:00bbloominstead of just mapped-value
02:00bbloomhttps://github.com/brandonbloom/fipp/blob/master/src/bbloom/fipp/printer.clj#L79-L90
02:01bbloomthat's a trivial state transducer which has as it's only state an integer called "position"
02:01bbloomthe same file has more complex state below
02:01bbloomthe pretty printer itself is a pipeline of transformations, each with it's own finite state
02:01bbloomsurely your distributed systems at runa do this kinda stuff all the time :-)
02:02bbloombut it's cool to see it in such raw form: none of the boilerplate around it to blue a complex topology of processes together
02:02bblooms/blue/glue
02:07bbloommeta comment: everybody forgive me for the philosophical ramblings. i had a very long day and then drank a bottle of wine
02:08alex_baranoskybbloom: sorry got pulled away. Cool stuff, I just need to go read the code again, and make something useful with reducers. That's the only way these ideas really sink in for me
02:09bbloomalex_baranosky: totally understand. i'm the same way. i guess the big thing for my use case was that reducers are eager, not lazy
02:09bbloomalex_baranosky: so keep that in mind if you're looking for a project idea
02:09alex_baranoskymost of the time I don't need lazy evaluation
02:11bbloommost of the time either is just as good as the other
02:11bbloomit's when you need side effects, that laziness stinks
02:11bbloomand it's when you have infinite structures that eagerness stinks
03:42worrelsikIs there some way to find out in the REPL which forms have been read and evaluated by using a (load-file my-file)?
03:56ejacksonworrelsik, I don't think so.
04:11worrelsikejackson: so opening the file in an editor is my best bet to find out ?
04:12ejacksonyeah
04:12worrelsikOr is there some sort of debugger-like way to step through the forms of the file?
04:18clgvworrelsik: the Clojure plugin "Counterclockwise" for Eclipse allows you to step through the code in debug mode.
04:19foo12worrelsik: are you trying to see where in a file the evaluation breaks?
04:22taliosI believe La Clojure for IntelliJ also has stepping support
04:22dan_bis there a reasonably elegant way to use lemningen to build java and/or c files? I think i need to add some jni stuff to my clojure project
04:23dan_bleiningen, even
04:24dan_b(to be slightly more precise "to build artefacts *from* java or c files")
04:25foo12dan_b: i'm pretty sure it has an option where you can just give a vector of java source folders and it'll compile those before it does the clojure
04:26ebaxtdan_b: http://nakkaya.com/2010/04/05/managing-native-dependencies-with-leiningen/ or http://antoniogarrote.wordpress.com/2010/09/08/zeromq-and-clojure-a-brief-introduction/ should get you started
04:26clgvdan_b: java is built-in - dont know about jni and c...
04:27foo12https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L241
04:27dan_bfoo12: ah, that second link looks v. useful, thanks
04:45worrelsikfoo12: No, I'm doing an exercise from Brian Maricks' book, and some functions I need to use are defined in a file. So I'd like to have an overview of which functions were defined
04:46worrelsikclgv, talios: thanks
04:50foo12can't you just do something like (ns-vars 'that.files.namespace)
04:52foo12... and probably filter out anything that file's namespace uses
04:52foo12okay nevermind
04:52clgvfoo12: you mean `ns-publics`, I think ;)
04:52foo12oh is that a thing?
04:53foo12that's good to know, thanks
04:53ejacksonoooh, something new :)
04:54clgv,(keys (ns-publics 'clojure.core))
04:54clojurebot(sorted-map read-line re-pattern cond->> keyword? ...)
05:14mpfundsteinwhen running LaClojure in IntelliJ, does someone now how i have to structure my src path so that .clj files get added to the classpath? When i require src/whatever/whatever.clj in src/whatever/test.clj i get FileNotFoundException Could not locate whatever/test__init.class or whatever/test.clj on classpath: clojure.lang.RT.load (RT.java:432)
05:20DerGuteMoritzhey guys, I get a StackOverflowError with lein deps :tree which seems to originate from leiningen.deps/check-for-range; any clues?
05:20DerGuteMoritzi.e. leiningen.deps/check-for-range calls itself to deeply
06:04otfrommorning
06:12hyPiRiongfredericks: with their factorizations?
06:12hyPiRionThat'd be fancy.
06:16Ember-is anyone making a replacement for clojuredocs.org?
06:16Ember-it bugs me that it hasn't been updated since 1.3
06:18babilenEmber-: The last time I asked this the answer was more or less: The code is on github, feel free to implement it. I've just checked and Zachary Kim never replied, so I have no idea if there is any interest in updating it ever.
06:21Ember-babilen: yeah, I've come to the same conclusion
06:22Ember-that's why I asked if anyone is actually recreating the site
06:22Ember-as far as I understand clojuredocs is written in ruby
06:22babilenIt is, yes.
06:22Ember-would make more sense for it to be written with clojure
06:23Ember-would make generating apidocs automatically a breeze
06:23Ember-then only thing needed in addition would be to add examples funtionality (which is the reason I actually like clojuredocs)
06:24babilenWhich would, essentially, mean that the entire website has to be reimplemented. It is probably possible to use the design though.
06:24Ember-yeah I know it would mean rewrite
06:24Ember-but that site is not *that* complicated
06:24Ember-few days from an experienced clojurist
06:25babilenyeah, which would be a wonderful service to the Clojure community
06:25Ember-yup
06:25Ember-once again a project which would be fun to make but so little time...
06:25Ember-which is most likely the reason this hasn't been done yet :)
06:26Ember-but, people on this channel could start the rewrite project as an opensource community project in github for example
06:26Ember-someone would have to take lead responsibility though
06:26Ember-preferably someone with more experience in clojure than me
06:26Ember-:P
06:28Ember-the need is there, someone would just have to start the project
06:29jballancEmber-: there is http://clojure-doc.org/
06:29jballancbut it's less of a replacement and more of a compliment
06:30jballancbut the community surrounding CDS seems much more engaged
06:30Ember-jballanc: yeah, not an ideal API reference
06:30jballanctheir Emacs and Vim tutorials are pretty great, though
06:31Ember-I don't disagree but what I'm talking here about is *good* api reference page
06:32Ember-clojuredocs is hands down the best out there (at least of what I'm aware of) but the problems mentioned above stand
06:34vijaykiranI agree that clojuredocs.org usecase is different than clojure-doc.org - I did start looking into existing code of clojure-docs.org and pondering about a rewrite
06:35vijaykiranlooks like the indexer and site are different projects - site is in Ruby, but the "indexer" is still Clojure AFAIU
06:38Anderkentcan i reference a type name via require/refer, or do I have to use import?
06:39vijaykiranAnderkent: java type ?
06:39Anderkentrecord, for example
06:40Anderkentit seems weird that i'd have to do (import my_other_ns.ARecord), manually replacing - with _, instead of (refer 'my-other-ns.MyRecord)
06:40hyPiRiongfredericks: Actually, I did something like that for some time ago. Not the natural numbers, but a sorted subset of them
06:40hyPiRionI can't remember what they were named, I'll have to look it up.
06:45vijaykiranAnderkent: because defrecord generates a class and it is different than clojure vars (?)
06:47murtaza52c When I start my lein repl, I keep getting this error - "NullPointerException java.util.concurrent.ConcurrentHashMap.hash (ConcurrentHashMap.java:332)" How do I look for the source of the error ?
06:48Bronsamurtaza52: (pst *e)
06:51murtaza52Bronsa: thanks for the tip
06:52Bronsa:)
07:01fractasticalhmm, the old "db-spec null is missing a required parameter" error greets me again
07:02piskettiIs there any documentation available for java.jdbc?
07:02piskettiOther than http://clojure.github.com/java.jdbc which basically just lists the function.
07:03piskettihttp://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples something like this but more systematic
07:03piskettiOr perhaps like in clojuredocs, with a few examples
07:04piskettiThat would be immensely helpful
07:09murtaza52I get the following stacktrace when typing "lein repl" https://www.refheap.com/paste/13253. Any ideas what could be causing it ?
07:12foo12just a guess but maybe a wrong namespace reference in project.clj?
07:14foo12or maybe the wrong leiningen
07:14foo12i had lein 1 hiding in my path somewhere and it did stuff like that on lein 2 projects
07:50murtaza52foo12 : Thanks. Yes there was a lein1, which I deleted and things started working :) Just for my info, how did u debug this, bcoz I couldnt make any connection between lein and the stacktrace.
07:59foo12murtaza52: i didn't really debug it, i just figured if lein breaks so badly it actually stacktraces before running anything either the project.clj is incredibly screwed up or it's the wrong version of lein
08:04murtaza52foo12: that is valuable advice, thanks :)
08:37Sonderbladehow do you get a value out of a map which has strings as keys?
08:38mpenet,(doc get)
08:38clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
08:40papachanquestion: if you want to compile an web app in clojure, do you compile a war for tomcat?
08:42hyPiRionpapachan: either a war or an uberjar
08:42hyPiRionring is able to do both
08:43papachanthanks hyPiRion
08:45winkone ring to serve them all
08:48jweisswow, referring to protocol functions by value is dangerous
08:49jweissat least, during development of said proto and the impls :)
08:52asalehclojure.core.logic question: can you use it to generate strings?
08:53hyPiRionasaleh: hmm...
08:53hyPiRionYou could probably generate sequences of integers representing strings
08:54asalehhyPiRion, will show gist so you know what I mean :)
08:54ebaxt,(let [fun (fn [] "foo")
08:54ebaxt isfun (fn [x] (and (not (map? x)) (ifn? x)))]
08:54ebaxt (prn (isfun fun))
08:54ebaxt (prn (isfun {})))
08:54clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
08:55hyPiRionokay
08:56ebaxt,(let [fun (fn [] "foo") isfun (fn [x] (and (not (map? x)) (ifn? x)))] (prn (isfun fun)) (prn (isfun {})))
08:56clojurebottrue\nfalse\n
08:57asalehgenerating strings with clojure logic problem : https://gist.github.com/AdamSaleh/5310152
08:57asalehhyPiRion, ^
08:59hyPiRionasaleh: str is impure, using e.g. (fresh [x y] (== y (str x))) won't work
08:59hyPiRionIt'll bind y to the .toString variant of the fresh variable x
09:00hyPiRionNot entirely sure whether logic has some way of doing that yet, perhaps dnolen could answer that if he were here
09:04asalehhyPiRion, ok, will try mailing list :)
09:05hyPiRionasaleh: yeah, I guess that's your best bet :)
09:45gmanikaI have a deftype A that uses deftype B and vice-versa and the Clojure compiler doesn't like that. How do I work around this? Can I toward-declare types or something?
09:45gmanikas/toward/forward/
09:56kxracan someone help me do some stuff to a list of words and get lein working?
09:58kxrai just need 15 minutes of help. 20 tops
10:08matthavenerkxra: sure, i can try
10:10nDuffkxra: In general, btw, it's preferable to ask your questions to the channel, rather than try to get a single volunteer (though you appear to have been successful in the latter endeavor in this case).
10:12kxranDuff: ah, thanks. i see. i asked for a volunteer because i thought i might need a lot of simple and didn't want to bog down the channel
10:13kxramy core.clj is on etherpad https://pad.riseup.net/p/5FI1GoysZUst
10:13kxrai'm currently just trying to get it to run before anything else
10:14nDuffkxra: That works for me.
10:14nDuffkxra: ...of course, you have to actually _do_ something with the wordlist inside the body to see it
10:14kxralein is giving me lots of errors
10:15nDuffkxra: Can you provide those somewhere, and your project.clj?
10:15gtrakis this bad form? ##(str (.sym :hello/asdf))
10:15lazybot⇒ "hello/asdf"
10:17kxranDuff: http://pastebin.ca/2349578
10:17kxragetting my project.clj now
10:17kxrahttp://pastebin.ca/2349580
10:17nDuffAhh.
10:18nDuffthe :main shouldn't be a filename
10:18nDuffkxra: ...but rather just the namespace name, :main words.core
10:18kxraah, i see
10:18kxraah! thanks
10:19kxrai wonder why lein didn't do that when i created the project
10:20TimMckxra: I think the default lein template is for libraries, not applications (which have a :main).
10:20nDuffkxra: ...well, not all programs _have_ a main
10:20kxraTimMc nDuff: ah! that makes sense
10:20TimMclein new app words
10:22TimMcYou can even do fancy things like `lein new app org.timmc/words`, which creates a project in a new directory called "words" with the appropriate group and artifact names, and src/org/timmc/words.clj.
10:22TimMcNo need for core.clj.
10:47kxranDuff: i've updated the etherpad to the most recent code, but now i'm getting even more errors
10:48kxrahttp://pastebin.ca/2349605
10:49nDuffkxra: your pastebin says lowercase, whereas your etherpad says lower-case
10:49gfredericksTimMc: now I know
10:50kxranDuff: ah, good catch. thanks
10:50kxrahard to keep them in perfect sync
10:50nDuffkxra: By the way, if you haven't played with it yet, the kind of experimentation you're doing right now is part of what Light Table is really, really good for.
10:51kxranDuff: ah, turns out there was a dash in both, but the one in emacs was some weird special character for some reason
10:51kxranDuff: i'll look at light table
10:52nDuffHeh. Don't let me dissuade you from emacs, though; Light Table is great for experimentation, but it's what I use for doing real work.
10:52nDuffs/it's/emacs is/
10:54kxrais lighttable libre software?
10:54piranhasomebody had a library for javascript which had a lot of clojure standard functions implemented (a-la partition-by, split-at, etc). I've seen it just few days ago and now I can't remember the name. Does anyone know what I'm talking about?
10:55kxraafter i fixed the special dash character, i still get these errors: http://pastebin.ca/2349610
10:55kxrafewer, at least!
10:56nDuffkxra: It's been promised that the core of the final product will be OSS; it may be supported by commercial add-ons or components.
10:56nDuffkxra: ...so, remember, your code has a :main in it
10:56nDuffkxra: that means you need to actually use gen-class with a -main function
10:56nDuffkxra: if you don't want to have that requirement, take the :main out of your project.clj
10:57nDuff(and then you won't compile to externally-runnable jars, but at this stage, do you really _need_ to?)
10:57nDuff("externally runnable" in the ''java -jar foo.jar'' sense, that is)
10:57piranhaah, found it: http://fogus.github.com/lemonad/
10:57kxranope
10:57nDuffkxra: It'd be easier if you had this in a git repository, by the way.
10:57nDuffkxra: having things split across multiple paste sources is a pain.
10:58kxratrue
10:58kxrai've actually been using darcs
10:58nDuffHeh.
10:58nDuff...and GNU Arch before that.
10:58nDuffAnyhow, when the bzr people think your SCM has performance problems, well... :P
10:59nDuffkxra: that said -- is your repo public?
10:59kxranDuff: yeah, i just need to update it. it's a total mess
11:04kxranDuff: http://hub.darcs.net/kxra/CS-0286
11:04nDuffkxra: (that said, I sorely miss back when DSCMs were competing in part on coming up with better merge algorithms)
11:05nDuffkxra: ...showing a bunch of Ruby there.
11:06nDuff...oh, under words/
11:06kxranDuff: yeah, the clojure is in words
11:06kxrasorry
11:07nDuffkxra: ''lein compile'' works fine. What are you actually doing to trigger the bug, ''lein run''? As I said before, you need to define a main- and use gen-class for that.
11:08nDufferr, -main, not main-
11:15kxranDuff: if i don't specify a main, lein run only tells me that i need to specify one
11:15nDuffkxra: Because you're using ''lein run'', yes.
11:15nDuffkxra: I'm not sure why you're using ''lein run'' at all.
11:15nDuffkxra: ...you can invoke your code directly from emacs, after all.
11:16nDuffkxra: anyhow -- I have an example that adds an appropriate -main, and am trying to figure out how to push it up to DarcsHub.
11:17kxranDuff: ah, i thought you said that it would only prevent me from compiling to jars
11:17nDuffkxra: Doesn't stop you from compiling to jars, either; stops those jars from being runnable.
11:17nDuff(as opposed to usable from libraries).
11:17kxraah, i see
11:18nDuffkxra: What does your emacs setup look like? Do you have nrepl, clojure-mode, and friends?
11:19nDuffkxra: See http://hub.darcs.net/charles-dyfis-net/CS-0286/browse/words/src/words/core.clj
11:19ppppaulpeople using drip with lein 2.1.2 ???
11:19lazybotppppaul: How could that be wrong?
11:19ppppauli love wrong
11:20ppppaulanyway, i seem to have lost my dripyness with my upgrade to lein 2.1.2 (i'm not sure what version i was using before)
11:20kxranDuff: i don't have much added on to emacs, but let me check those out
11:20nDuffkxra: if you don't have addons yet, I'd suggest using Emacs Live
11:21nDuffkxra: ...that gives you a full set tested and supported together
11:21nDuffkxra: see https://github.com/overtone/emacs-live
11:21nDuffkxra: ...also, the video at http://vimeo.com/22798433
11:24kxranDuff: emacs live is amazing.
11:25nDuffkxra: Yes. Yes, it is.
11:26kxranDuff: can i see all the languages it plays nice with? i'll need ruby, scala, prolog, and haskell
11:30murtaza52kxra: there are packages for most other languages in emacs. if they are not included with emacs-live u can install them separately. What emacs live gives you is a very easy way to get started with clojure and emacs.
11:30ppppauli use emacs dead
11:31kxramurtaza52: ah, i see. that's what i was wondering-- whether emacs-live was specific to clojure or just a general package
11:32murtaza52kxra: its an assembled to package to provide u all the settings to play with clojure. You can then add any other ones, or change remove existing ones for other languages. You will have to google for packages for other's and will usually find very good ones.
11:34kxranDuff: no if my goal is to count the number of times words start with each letter of the alphabet, would the simplest way to do that be to define a map then do something with doseq to sequentially tally the first letter of each word in the list?
11:34kxras/no if/so if
11:35degI'm about to try out ClojureScript. I come from a background in client/desktop programming and am comfortable in Clojure. I'm near-ignorant on the details of web technologies. What's the best path (sample code, tutorials, etc.) to ramp up on this learning curve. I want my first focus to be small, mildly-interactive, apps running in chrome on mobile devices.
11:37corecodehow do you get emacs to glow?
11:37corecodeor is that just a video processing feature
11:37murtaza52deg: look at webfui, also I just pushed a sample project I am working on that uses clojurescript + clojure - https://github.com/murtaza52/mashup
11:38ToBeReplacedkxra: didn't read whole thread so i might be missing context, but it sounds like you're looking for `frequencies`
11:38kxracorecode: good question. i assumed it was video processing
11:39murtaza52deg: also it may be nice if you gain an understanding of web technoligies in general before jumping to client side with clojurescript. So look at webnoir (which is no deprecated) and luminus
11:39gilbertw1deg: I learned it pretty easily using it to play around in nodejs....It's pretty quick and easy to setup and play with......I mainly used this: http://mmcgrana.github.com/2011/09/clojurescript-nodejs.html
11:40gilbertw1deg: and the js comparison: http://himera.herokuapp.com/synonym.html
11:43kralwho is doing tests with #clojure hashtag on twitter?
11:44corecodekxra: ok.
11:44deg(oops, looks like I was disconnect just after my last request. If anyone has answered me, please repeat. Sorry.)
11:47andyfingerhutkxra: Not sure if your question was answered, but if words is a collection of strings, you could do (frequencies (first words))
11:48andyfingerhutor if you want not only the count but a list of words starting with each letter: (group-by first words)
11:48kxraandyfingerhut: ah yeah, that's what i was looking for
11:48kxrathe count
11:48kxrai'm going to keep poking at it
11:48kxrathis is helping me understand clojure much better
11:49asteveso I have input called dir and I need to do something conditionally on the value of dir
11:49andyfingerhutThere's no harm in re-implementing frequencies or group-by yourself the first time, for the learning experience. But once you know they exist and how to use them, may as well.
11:49murtaza52deg: (as req psting again)look at webfui, also I just pushed a sample project I am working on that uses clojurescript + clojure - https://github.com/murtaza52/mashup
11:49asteveif it's 1 then I need to add to pos, if it's -1 then I need to add to neg
11:49murtaza52deg: also it may be nice if you gain an understanding of web technoligies in general before jumping to client side with clojurescript. So look at webnoir (which is no deprecated) and luminus
11:49astevethis seems simple but I'm confused on how to do it in clojure
11:50andyfingerhutasteve: Are you doing this in a loop or something, and the final result includes pos and neg?
11:50gilbertw1deg: I learned it pretty easily using it to play around in nodejs....It's pretty quick and easy to setup and play with......I mainly used this: http://mmcgrana.github.com/2011/09/clojurescript-nodejs.html
11:50gilbertw1deg: and the js comparison: http://himera.herokuapp.com/synonym.html
11:51astevesomething similar, I need to keep track of all pos and neg for all time for an element in a table, and also have the true standing; i.e. is the value currently pos or neg
11:53andyfingerhutThe condition is simple enough, e.g. (if (pos? dir) (something-positive) (if (neg?dir) (something-negative))). The main reason for my question is in case you wanted some kind of side effects in the actions.
11:54asteveI do need side effects but for easy of time and typing I may make it ugly like that
11:55asteveI think the real problem is that I need to get the current values for some of these table entries
11:55asteveand I'm all hopped up on percocet and can't think
11:55astevehah, anyway, thanks for the simple help
11:56andyfingerhutThat is for all positive and negative values, not just 1 and -1. You can also use (= dir 1) if you need to check for that specific value. Also (case dir 1 (something-1) -1 (something-minus-1) nil), where the nil is a "do nothing" case if it is neither 1 nor -1.
11:59nDuffkxra: Howdy -- just back from a meeting, and it looks like andyfingerhut came up with the same answer I would have.
12:00nDuffkxra: ...re: doseq, that should only be used when you're aiming for side effects (like printing); using it for calculations is generally a "code smell".
12:01asteve,(def dir 2) (if (pos? dir) (dir) (neg? dir) (+ dir 1)))
12:01clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
12:02andyfingerhutasteve: (dir) will try to call dir as a function. Leave off the parens there.
12:03astevewhoops
12:04andyfingerhutUnlike Java/C/etc. you can't just throw in extra parentheses without changing the meaning.
12:04asteveya, so I just need to clarify
12:05asteve(if (pos? dir) (+ 1 num) (neg? dir) (- num 1)) is the right syntax for an if elseif?
12:07nDuffasteve: no; if you wanted else conditions, you'd use cond
12:07andyfingerhutasteve: No, if only has a "then" and "else" branch, no else if capability. You could use cone if you want something like else if
12:08andyfingerhutYou can nest ifs to achieve else if, too, but it gets nested deeply pretty quickly.
12:08bbloomasteve: also, there are inc and dec functions for +1 and -1
12:08nDuffasteve: ie. (cond (pos? dir) (inc num) (neg? dir) (dec num) :else num)
12:09asteveok
12:18jcromartieI'm not entirely convince that it's worth the trouble to have factory functions for Compojure handlers, vs. just defining handlers themselves as top-level fns with dynamic vars for the data model
12:36nzhttp://www.techempower.com/blog/2013/03/28/framework-benchmarks/ compojure performs rather nicely in this benchmark
12:52olenhadHey guys, what's the idiomatic way of doing a lookahead peek in a coll whilst traversing it (saying during a reduce like operation)
12:54bbloomolenhad: i'd imagine that depends on the type of lookahead. is it a single element look ahead?
12:55olenhadsingle element
12:55olenhadbbloom: preferebaly single element
12:55S11001001(map vector s (rest s)) ;a lazy seq of element + next element, stops at 2nd-last
12:56bbloomolenhad: then it's cheap to just ask for the next element with first or second or fnext or whatever
12:57olenhadS11001001: That seems right, Thanks!
13:15ejacksonolenhad: another trick would be (map vector (partition 2 1 s))
13:16ejacksonyou could do n-ahead lookup nicely by changing 2 to n.
13:18Glenjaminnz: i saw someone ranking it by (performance)/(performance of fastest on same runtime), to get an estimate of "potential of platform uztilised" - compojure is poor if you measure it that way :(
13:21astevehow can I test a compojure program locally?
13:22astevenevermind
13:24thalassios_xelonhello room :) i get this exception java.lang.ClassFormatError: Invalid method Code length 105540
13:24thalassios_xelonwhat this means?
13:24thalassios_xelonCompilerException java.lang.ClassFormatError: Invalid method Code length 105540 in class file GrBDDSo/random_formula$eval1613, compiling:(NO_SOURCE_PATH:1:1)
13:25jcromartiewhat's your code?
13:25thalassios_xeloncode?
13:25jcromartiethalassios_xelon: can you share the code that causes the exception?
13:25clojurebotall ur code r belong to us
13:26nDuffthalassios_xelon: see http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#9279
13:26jcromartieit basically means that a .class file is invalid
13:26nDuffthalassios_xelon: ...in particular, search for the restriction on code_length
13:26thalassios_xeloni dont know what code_length means
13:26nDufffrom 4.8.1: The value of the code_length item must be less than 65536.
13:27nDuffthalassios_xelon: Your class is too big.
13:27jcromartienDuff: no, that code_length is for methods
13:27jcromartiecode on the JVM only lives inside methods
13:27jcromartieI don't think thalassios_xelon neds to become familiar with the internals of JVM class loading
13:27thalassios_xeloni am tottally newbie
13:27thalassios_xelon:)
13:28nDuffjcromartie: If an error is being triggered to the effect that the generated methods outstrip a JVM limit, sure, the details of that are unimportant, but the gist of it is useful.
13:28jcromartienDuff: yes, sure, it's always helpful to know more
13:28jcromartiethalassios_xelon: let's just step back. can you paste (at https://www.refheap.com/paste) the code that throws the exception?
13:29astevenow I'm getting somewhere!
13:29asteveso why doesn't lein uberjar build the same as lein ring server?
13:29jcromartieasteve: uberjar is general purpose
13:30astevejcromartie: how do I ensure that my app is built and packaged?
13:30thalassios_xelonhttps://www.refheap.com/paste/13264
13:31jcromartieasteve: you specify a main namespace with the :main option in your project.clj, then you implement (defn -main [& args] ) in your namespace
13:31astevehmm
13:31jcromartieasteve: then you can run your project from the uberjar like: java -jar myuberjar.jar options to main
13:31jcromartieand the arguments to -main are all strings
13:32nDuffthalassios_xelon: Would the full package (w/ dependencies and such) be available somewhere?
13:32nDuffthalassios_xelon: ...by the way, I don't see random-formula in there.
13:33jcromartieyeah, I suspect some kind of macroexpansion gone wild?
13:33nDuffis this happening at compile time or runtime?
13:34thalassios_xelonCompilerException java.lang.ClassFormatError: Invalid method Code length 105540 in class file GrBDDSo/random_formula$eval1613, compiling:(NO_SOURCE_PATH:1:1)
13:34nDuffthalassios_xelon: yes, but is it during a ''lein compile'', or while your code is actually being invoked (ie. triggered by an eval)?
13:35jcromartieasteve: but how you package your system depends on the destination
13:35nDuffthalassios_xelon: if it's the latter, it'd be interesting to look at just _what_ is being eval'd.
13:35asteveright, this is going to elasticbeanstalk and I don't think I have the option to specify the main; I thought the ring plugin was supposed to take care of that?
13:36thalassios_xelonthe error occurs on fuction call
13:36nDuffthalassios_xelon: then we need to see the code that's actually being put through eval by the function.
13:36nDuffthalassios_xelon: fortunately, it shouldn't be hard to print it to a log.
13:36thalassios_xeloni hava a (list 'let pairs ...) and pairs might be too large
13:37thalassios_xeloncan this be the problem?
13:38thalassios_xelonanyway thx guys,i keep in mind that somethin in the class is too big
13:38thalassios_xelonand i will search for the bug
13:39ispolinto refactor multiple nested "when-let"s, is the maybe-m monad from algo.monads the way to go, or is there something in the core already?
13:39bbloomispolin: cond->
13:40bbloomas-> etc
13:44ispolinbbloom: "as->"?
13:44bbloom(doc as->)
13:45clojurebot"([expr name & forms]); Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form."
13:45ispolinah, cool. I was trying to find it in the cheatsheet
13:45jcromartieasteve: are you using lein beanstalk?
13:45ispolinthanks
13:46astevejcromartie: no
13:46jcromartieasteve: that might be helpful...
13:47jcromartielein-beanstalk uses lein-ring to run the app
13:47asteveI thought about it
13:47jcromartielein ring war/lein ring uberjar are similar to lein jar and lein uberjar, but oriented around making a deployable J2EE war file
13:50asteveah
13:59thalassios_xeloni asked before i have an exception CompilerException java.lang.ClassFormatError: Invalid method Code length 78921 in class file GrBDDSo/random_formula$eval2355, compiling:(NO_SOURCE_PATH:1:1)
14:00thalassios_xeloni have a (eval (list 'let pairs ....)) in my code and the pairs get toooo big ,can be this the problem?
14:01jcromartiewhat's random-formula look like?
14:01jcromartiecan you just share that?
14:02thalassios_xelonthe problem isnt in the random formula ns,
14:02thalassios_xelonwait a sec
14:04jcromartie"Invalid method Code length 78921 in class file GrBDDSo/random_formula"
14:04jcromartiewould seem to indicate that it is
14:09frozenlockIf there a way to round numbers to a given precision? Kinda like (format "%.2f" 0.11111), but to return a number, instead of a string.
14:12amalloyuh. Math/round?
14:13frozenlockDoesn't that just round to a whole number?
14:13frozenlock,(Math/round 111.111)
14:13clojurebot111
14:14amalloy$javadoc java.lang.Math round
14:14lazybothttp://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#round(float)
14:15amalloyhuh. was sure there was a roundTo parameter of some kind
14:16pjstadigmultiply by 100, Math/round, then divide by 100
14:17pjstadigor maybe convert to a BigDecimal and round using a MathContext or something
14:17frozenlockany stupid move in this? https://www.refheap.com/paste/13269
14:18thalassios_xelonhttps://github.com/tkaryadis/GrBDDS this is my code in read me the bug
14:20thalassios_xelonthe bug is in the pformula ns
14:22pjstadigfrozenlock: if that works for you, then it's fine.
14:23frozenlockWell it works, but I'm always interested in any more efficient ways :)
14:24pjstadigif you need something like half even rounding or something, then you'd want to go for BigDecimal rounding
14:25pjstadigyou probably want BigDecimal instead of binary floating points anyway
14:25pjstadigunless you really, really know for sure that you want binary floating point numbers
14:25pjstadigand even then you probably want BigDecimals
14:26Glenjaminfrozenlock: why do you need to round to a number of decimal points but still have a floating point / numeric value?
14:27frozenlockGlenjamin: trying to make an invoice. $0.123122312 just seemed silly :/
14:28technomancy...!
14:28pjstadigfrozenlock: yeah you definitely should be using BigDecimals if you're doing currency calculations
14:29nDuffthalassios_xelon: doesn't run exactly as in the gist -- GrBDDSo.change-letters is referenced in some of that code, whereas the actual namespace has been renamed.
14:29frozenlocktechnomancy: Dad, did I do something wrong?
14:29frozenlockpjstadig: Understood
14:29technomancyfrozenlock: floats for currency
14:29pjstadighttp://speleotrove.com/decimal/
14:29Glenjaminfrozenlock: perhaps also DecimalFormat/Currency classes ?
14:30technomancyhttp://themosthorriblething.com/horribleimgs/d6SAIi.gif
14:30rcgfrozenlock, i'd keep as much precision as possible and only round on string output?
14:31nDuffthalassios_xelon: anyhow, fixing that, it generates a pretty huge function.
14:31rcgi.e., when you eventually print the resulting value
14:31astevewhen you get the really small shit to work, that's when you know you've made progress :)
14:31Glenjamini agree with rcg, you're only throwing away data otherwise
14:32Glenjaminunless you're dealing with the UK tax system, in which case the tax calculation formula does in fact throw away information at some points
14:32rcg(format "%.2f" 1.23456789)
14:33frozenlockGlenjamin: French-canadian tax system :P At least we don't tax the taxes anymore...
14:33Glenjaminwhen you do PAYE tax here, you have to round the monthly value to the nearest 10 at some point iirc
14:34nDuffthalassios_xelon: ...have a look at https://gist.github.com/charles-dyfis-net/773cfbf2c9d8e3d966cb
14:36nDuffthalassios_xelon: I'd suggest refactoring to not need such large functions as part of your evaluation model.
14:40frozenlockpjstadig: Interesting read!
14:40frozenlock:tps 0.49950000000000006 ... Ahhhh the trailing 6... must... keep... data
14:45thalassios_xelonnDuff, thx :))
14:45thalassios_xelonyou think the biggg let is the problem right?
14:46nDuffthalassios_xelon: Easy to test. Eval that string with and without the huge let.
14:46thalassios_xelonhow to fix it?
14:48nDuffShoot -- that wasn't even the whole thing
14:48nDuff...printer was set to elide.
14:53thalassios_xelonthx nDuff for the time you help me i also learned to find the code that caused the exception bye room:))
14:54nDuffthalassios_xelon: FWIW, I'm still working on it.
14:57thalassios_xelonok :)
14:58nDuffthalassios_xelon: The easy answer is not to include the huge thing in your eval.
14:58nDuffthalassios_xelon: if you generate a function that takes the huge thing on its argument list, for instance, you're set.
15:00ppppaulanyone here benchmark their clojure servers?
15:00ppppaulsiege or weighttp?
15:01ppppauli'm wondering what types of speed i should expect out of a barebone ring server
15:04nDuffppppaul: ...well, there was the big shootout the other week, which basically put Compojure at 1/3 the speed of the fastest thing benchmarked in any language
15:04n_bppppaul: https://github.com/ptaoussanis/clojure-web-server-benchmarks have you seen this?
15:04n_band the shootout http-kit did the other week
15:04n_bppppaul: http://http-kit.org/
15:07thalassios_xeloninternet failed nduff what you said? if you generate a function that takes the huge thing on its argument list, for instance, you're set.
15:07nDuffthalassios_xelon: that's what I said, yes.
15:08txdvhuge thing ... hehe
15:08thalassios_xelon:) ok thx very much
15:08nDuffthalassios_xelon: there's no reason to eval with that as a literal
15:08nDuff...when you can pass it around as data.
15:08nDuff...I'm expecting that it would.
15:08nDuff...but do report back.
15:09thalassios_xeloni think its easy to fix
15:09nDuff(not partial inside the eval, but partially applying the function you get out of the eval)
15:11naxuihello
15:11naxuii have a question
15:12nDuffnaxui: no need to introduce yourself or wait for volunteers -- it's normal form in IRC to just ask your question straight out.
15:13hyPiRionnaxui: hi there, just ask whatever you wonder about
15:13thalassios_xelonbye room :) thx for help
15:15jcromartieis add-watch really *still* alpha?
15:15jcromartieit's been there since 1.0
15:17pjstadigjcromartie: yes
15:19hyPiRionalpha essentially means that its semantics may still be changed in 1.x really
15:21hyPiRiongfredericks: I'm assuming that somewhere around 2.5 it will be like Erlang: Only performance improvements
15:22hyPiRionOr perhaps multiple different versions, one for debugging, a slim version for deploying apps, and a performant one for server stuff
15:26TimMcnDuff: Apparently that was too scary an idea.
15:26gfrederickshyPiRion: I expect by 4.0 we will have added refinements
15:27hyPiRionheh
15:27gfredericksand operator overloading
15:27hiredmanwe'll have a sweet pandas like library
15:28gfrederickskorma will finally get merged into clojure.core
15:28hiredmanhttp://vimeo.com/59324550
15:29gfredericksclojure 3.0: because it's not clojure-in-clojure until we've built a JVM
15:29TimMcIn the year 2525^W^W^Wclojure 4.0, protocols will be implemented using monad transformers... and vice versa.
15:29gideonitegfredericks: holy macaroni
15:30gfredericks(require '[clojure.jvm :as jvm])
15:31nDuffgfredericks: ${deity}, I hope not.
15:31TimMcClojure 4.0: Rich Hickey overwrites the universe's operating system with Clojure, says the language is finally complete.
15:31nDuffgfredericks: ...unless, by that time, korma has been rewritten to no longer be so macro-centric.
15:32gfredericksclojure 5.0: method_missing
15:32hiredmanhttps://github.com/lihaoyi/Metascala
15:32Glenjaminxeqi: i'll have a look
15:33xeqiGlenjamin: thanks, its my plan to get both patches in this evening for a new release
15:33Glenjaminxeqi: ah, i think it's to do with timezones when trying to use the asctime format
15:33Glenjaminwhich doesn't specify a timezone
15:33xeqiugh, *shiver*
15:33Glenjamini could increase the generated time from 1 hour to 1 day, which would pass the test suite - or just revoke support for the asctime format
15:34Glenjamin*-1 hour -> -1 day
15:35xeqihow were you able to tell its a timezone issue?
15:35Glenjamin1) asctime doesn't specify a timezone, 2) it's to do with times, it's always timezones, 3) i just reproduced - set my tz to EST and it fails, but works on UK time
15:36Glenjaminsoftware dev in the UK means when stuff defaults to GMT/UTC, it often appears to work - until it suddenly doesn't
15:38asteveis gmt ever different from utc?
15:38Glenjaminno, but UK is currently on BST, which is GMT+1
15:38Glenjaminoften software written here in winter breaks in spring :)
15:39xeqiGlenjamin: I think I'd vote for removing asctime for now and it can get added in another release
15:39Glenjaminsounds good, gimme 5 mins
15:39xeqiafter some more thought
15:39xeqithanks
15:42Glenjaminhrm, going to improve the "can't parse date" message as well - just realised the loop + try..catch approach leaves you with a null pointer if it fails
15:52ppppaulthanks nDuff and n_b ... following how http_kit did their benchmarks, i am having trouble replicating his results.... my req/sec max out at 160.... a far cry from the 600 000 (8 core machine, java maxing out all cores during benchmark)
15:59akhudekppppaul: did you do hte linux modifications?
16:02Glenjaminxeqi: would you prefer a second commit that removes the asctime support, or squashed into a single commit that never had it?
16:02xeqiGlenjamin: feel free to rebase it
16:02xeqi* squash
16:02ppppaulakhudek, ulimit is set the same, the ports are set the same
16:03ppppaulam i missing a mod other than those two?
16:03ppppaulbtw, ulimit was tricky to set
16:03Glenjaminxeqi: ok, pushed the fix to glenjamin/master
16:04Glenjaminpresumably that means travis is running their boxes in UTC
16:05xeqiGlenjamin: I'm kinda surprised I'm not, but I did reinstall recently
16:07Rich_Morindakrone: yt?
16:07akhudekppppaul: I haven't done that test myself, but I would guess that it's an OS limit. There may be something additional you need to do for your machine. Not sure.
16:17antares_ppppaul: it may be a good idea to ask the author. Default OS settings definitely are not optimal for 600K connections.
16:18nDuffppppaul: I can reproduce http_kit's results.
16:19nDuffppppaul: ...for that matter, I actually get much _faster_ HTTP connection times during the ab test
16:20ToBeReplacedis this still the preferred way to unroll a map into a funciton that has optional keyword keys?: (apply (fn [& {:keys [foo]}] (inc foo)) (apply concat {:foo 1}))
16:22xeqiGlenjamin: thanks again for fixing all that stuff
16:24number35hi all
16:24nDuffppppaul: ...well, strike that. I get much better results during the ab test; with his custom client, I'm peaking at 65,000 concurrent connections; looks like I missed an OS limit during setup/configuration.
16:25number35i am solving a little bit of 4clojure
16:25number35is there anyone who was solving it ?
16:26antares_number35: certainly. What is your question?
16:26aphyrHey cemerick, you ever come up with a (case+) which can use enums in AOT code?
16:26aphyrOr is my best bet still (condp =)?
16:27number35antares : i am not very experienced but i would like to make first step in (in a lame way) partially solve 73. and learn a little bit
16:27number35i am using this
16:27number35http://pastebin.com/P8Q2uTGy
16:27number35tu
16:27number35to
16:27number35http://www.4clojure.com/problem/73#prob-title
16:27number35get green light for first variant of problem 73
16:27number35but i get this
16:28number35clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox1145$eval5660$fn
16:28number35so obviously i am getting something wrong it takes the whole tic tac toe three vectors
16:28number35as one argument and i dont know why
16:28nDuffnumber35: would you consider using a pastebin without the animated advertisements?
16:29nDuffnumber35: refheap.com is somewhat preferred herebouts, being written in Clojure itself (source available on github).
16:29number35of course
16:29number35why not
16:30number35https://www.refheap.com/paste/e0ef736098821248f3ec45318
16:31number35here you have it on refheap
16:33gilbertw1number35: I think you need to wrap you arguments in an outer array: [[[a,b,c] [d,e,f] [g,h,i]]]
16:33nDuff*nod*.
16:34astevehas anyone here worked with the clojure library for dynamodb?
16:34gilbertw1number35: It looks like your waiting for 3 arrays instead of a single destructured arrray
16:36number35interesting
16:38number35gilbertw1: but check this i cannot change that part of the code
16:38number35http://www.4clojure.com/problem/73
16:38nDuffnumber35: you can add the extra wrapping [] in your fn call
16:38nDuffnumber35: that way you're expecting a single list as an argument and destructuring it, instead of expecting three lists.
16:39gilbertw1you need to change the argument list in your fn
16:39gilbertw1your defining and fn that takes three different arrays versus a single array containing three arrays
16:41nDuffnumber35: ...that is: (fn [[[a b c][d e f][g h i]]] ...)
16:42number35nice !
16:43number35thank you guys
16:51rwilcoxI've got a newbie question. I'm playing with the clj-time package and trying this code and getting an odd error. I'm dealing with a LocalDate type with both variables so I'm not sure what's up. Anyone have any thoughts? (in-days (interval (today) (local-date (year (today)) 1 1)))
16:51rwilcoxthe error I get: ClassCastException org.joda.time.LocalDate cannot be cast to org.joda.time.ReadableInstant clj-time.core/interval (core.clj:388)
16:51rwilcox(I'm trying to get the number of days it's been since the start of the year)
17:00rwilcoxnm: I switch everything to local-now, instead of local-date and it's now working :)
17:02Glenjaminrwilcox: it looks like LocalDateTime isn't a readable instant - probably something to do with lack of timezone information
17:03GlenjaminLocalDate even, not LocalDateTime
17:03Glenjaminthe joda time API docs probably make it easier to see the relationships
17:03rwilcoxGlenjamin: hmm, yeah was wondering if it really wanted TZ or time info
17:03rwilcoxGlenjamin: thank you :)
17:04Glenjaminsince you're doing the interval, you should just be able to use (now)
17:05Glenjamin(in-secs (interval (date-time (year (now)) 1 1) (now)) )
17:06hyPiRionoh dear, that looks messy
17:06hyPiRion(-> (now) year (date-time 1 1) (interval (now)) in-secs) is perhaps a bit better
17:07hiredmancemerick: https://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl/middleware/pr_values.clj#L6 importing the interface under Transport like this is kind of gross, consider using/requiring the protocol instead
17:08rwilcoxhyPiRion: Interesting. I need to read up on -> … this is kind of the first time I've sat down to write any kind of non-trivial Clojure
17:11cemerickhiredman: huh; at some (probably primordial) point in time, reify really needed the interface, not the protocol
17:11hyPiRionrwilcox: Ah. Sometimes it eases the readability quite a bit
17:11choixerhello everyone, writing my first code in clojure. Could you suggest solutions to parse html? (for example i need to find div with class .author and all links)
17:11hyPiRion,(use '[clojure.walk :only (macroexpand-all)])
17:11clojurebot#<SecurityException java.lang.SecurityException: denied>
17:11hyPiRion:o
17:11hyPiRionoh well
17:11hyPiRion,(clojure.walk/macroexpand-all '(-> (now) year (date-time 1 1) (interval (now)) in-secs))
17:11clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.walk>
17:11hyPiRionoh hurr
17:12hyPiRion&(clojure.walk/macroexpand-all '(-> (now) year (date-time 1 1) (interval (now)) in-secs))
17:12lazybot⇒ (in-secs (interval (date-time (year (now)) 1 1) (now)))
17:12cemerickhiredman: BTW: http://dev.clojure.org/jira/browse/NREPL-29 I have a fix for that floating around somewhere, will try to push that in over the weekend
17:13rwilcoxhyPiRion: … the frack… ?
17:13rwilcoxhyPiRion: I've got a lot of food for thought now
17:13hyPiRionrwilcox: Let me check if I can find a good link which explains it
17:14hiredmancemerick: ah, this is the thing I was asking about with pr-value?
17:14hyPiRionrwilcox: http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/
17:14cemerickhiredman: yup
17:14hiredmancool
17:15rwilcoxhyPiRion: oh cool. OHHH and that macroexpand thing was you telling the bot to unwrap that
17:16hyPiRionrwilcox: yeah
17:17hyPiRionclojure.walk/macroexpand-all is great to check if you understand a macro correctly
17:17hyPiRion(or if you've made one which expands right)
17:17hiredmancemerick: I have actually realized I don't actually need to override pr-value, but I would like to get between pr-value and eval in the stack, which I don't seem to be able to do either
17:17hiredmaneval being interruptable eval
17:18cemerickhiredman: look at the add-stdin middleware; it slips itself in between something supporting "eval" and the session middleware
17:19hiredmanyeah, maybe I jsut did this wrong
17:20cemerickI'd have no difficulty believing that there's bugs in the middleware dependency jumble. I need to revisit that impl significantly. The 'no deps' policy is a bummer.
17:24technoma`cemerick: since when do you live by the rules? =)
17:26astevemy ring functions are returning nil and my browser is showing the last route, I'm not sure why
17:28hiredmanhttps://gist.github.com/531453 gives you a linearized run list from a graph like {:a #{:b :c} :b #{:c} :c #{}}, where each value is a set of dependencies
17:29weavejesterasteve: What are you running it with?
17:30asteveweavejester: I've built an uberwar by lein ring uberwar and uploaded it to elastic beanstalk
17:31weavejesterasteve: And it worked locally?
17:31asteveno
17:31deggilbertwl: Sorry, I got called away by family right after I posted cljs question. Thanks for your answer.
17:31asteveI should also say that I'm testing it locally with lein ring server
17:31degmurtaz52: ditto
17:31gfredericksYo-Yo Ma + techno music => technoma
17:32weavejesterasteve: What functions are returning nil?
17:32asteveweavejester: I have a route that's matched and the request is sent to the proper function, the function returns nil
17:32asteveand the browser is displaying my last route which is not-found
17:33asteveit makes it difficult to debujg
17:33weavejesterasteve: So the issue isn't with Ring, it's with the function that returns nil?
17:33asteveweavejester: the issue is certainly with the function but I don't understand why ring chooses to show the last route?
17:33asteveunless my function is really returning a 404 and ring is showing the 404
17:33weavejesterasteve: Presumably you're using Compojure?
17:34asteveweavejester: yes
17:34weavejesterasteve: Compojure tries routes in order until it finds one that does not return nil.
17:34weavejesterasteve: So a route returning nil is the same as one that isn't matched.
17:34asteveah!
17:38asteveweavejester: actually I think you're the person to ask about rotary; what happens when I request an item with get-item that doesn't exist?
17:38weavejesterasteve: I can't recall off the top of my head. Probably throws an exception, because that's what the AWS libs tend to do when they can't find something.
17:39weavejesterasteve: Best thing to do is to try it and see,
17:39astevemy "try it and see" is resulting in unexpected results
17:41weavejesterasteve: What's the unexpected result?
17:41astevethe method returning nil when it should return a result
17:42asteveI'm checking to see if the item exists and I'm getting nil all the way up the chain
17:45weavejesterasteve: Let me just check and see what actually happens
17:46astevethanks
17:49aaelonyJust starting to work with XML, and I am counting first level tags with this: (count (:content (clojure.xml/parse (java.io.File. "myfilename" )))) This tells me that I have 113 child tags below the parent tag. I know that there are 4 types of child tags though. How can I get the counts for each of the 4 types of child tags?
17:49weavejesterasteve: Looks like it returns nil
17:50astevethanks
17:50weavejesterWhich is surprising, because the AWS libs don't usually do that
17:50weavejesterBut good, because returning nil for a key that isn't found is idiomatic Clojure.
17:52cemericktechnoma`: ha. I do, until I have good reason otherwise.
17:52cemericknREPL has actually had a no-deps rule from the start, long before it was a contrib.
17:54astevebah!
17:54astevewrong primary key the entire time
17:54asteveweavejester: thanks very much
17:54weavejesterNo problem
17:57weavejesterSometimes taking an ugly Java API and turning into a Clojure API can be very theraputic
17:58dakroneweavejester++
17:59hiredmanyou should try taking a java project and slow replacing the inside with clojure, it is great
18:00hiredmanslowly
18:01weavejesterI'm currently toying around with jmonkeyengine, which is a 3D game engine for Java
18:02weavejesterI had to abuse the :resources-path in Clojure, because the project, despite being quite recent, doesn't use Maven
18:03weavejesterAnd I also had to force Java 1.6 with .leinrc because OpenGL with Java 7 on OSX is missing some bits.
18:03weavejesterBut aside from that, it's working okay.
18:13hiredman/win 12
18:13rboydI just did that 5 minutes ago in another chan
18:31corecodeso what's the deal with hygienic macros? seems that clojure's macros are hygienic because of the reader?
18:32lynaghkbbloom: cemerick solved the mystery yesterday---it turned out to be a compiler bug related to closures. Thanks anyway, though =)
18:32bbloomlynaghk: hurray, compiler bugs. fun!
18:32technoma`corecode: clojure's macros aren't hygenic, but they don't suffer from the problems that hygenic macros are meant to solve.
18:32lynaghkbbloom: yeah, it was subtle as hell (for me, anyway)
18:32lynaghkbbloom: deets here: https://gist.github.com/lynaghk/0a8a3dd71cc3c830f507
18:33jackdanger1weavejester: could you share a link to the jmonkeyengine project? I'd love to play around with that.
18:33bbloomlynaghk: wacky.
18:33corecodetechnoma`: then i don't know what hygienic means
18:33lynaghkbbloom: I'm not doing anything to dig deeper though---if you're itching to get into the Clojure compiler internals feel free to investigate and make the world better for the rest of us =)
18:34bbloomlynaghk: nah. i got a contract i want to get done so i can get back to interesting stuff :-P
18:35technoma`corecode: CL's macro system makes accidental symbol capture bugs really easy to make; hygenic macros and auto-gensym (which clojure does) both make that problem go away
18:35corecodetechnoma`: so hygienic doesn't mean "no accidental symbolic capture"?
18:35lynaghkbbloom: yeah, I hear you on that.
18:41technoma`corecode: that's an oversimplification
18:41corecodeyea, i got that much :
18:41corecode:)
18:44technoma`http://www.reddit.com/r/programming/comments/7epv2/rich_hickeys_clojure_talk_at_the_jvm_language/c06gvar
18:51corecodeoh i wish i could reduce clj to a compact VM+memory allocator
18:51corecodethen i wouldn't have to bother with scheme
18:51powr-tocwhat's the difference between setting :durable false on queue start and :persistent false on publish?
18:52powr-tocit seems my queue started with durable false; is 2x quicker when I publish with :persistent false
18:54powr-tocoops wrong channel :-)
18:58asteveI would like to modify {:up 1 :down 1} to be {:up 2 :down 1}; what function is the best choice?
18:59asteveI only want to change the key :up
19:05arrdemcorecode: why not?
19:05arrdemif you throw out JVM compat it should be doable.
19:07weavejesterjackdanger1: http://jmonkeyengine.com/
19:07corecodearrdem: okay
19:08corecodearrdem: what do you think do i have to do?
19:08corecodearrdem: i'm looking at picobit, which is a VM in 8KB machine code
19:08corecodearrdem: but it's scheme, and i'd rather do clojure than scheme
19:09ivan&(update-in {:up 1 :down 1} [:up] inc) ; asteve
19:09lazybot⇒ {:down 1, :up 2}
19:09corecodeJIT is no option tho :/
19:09ivan&(assoc {:up 1 :down 1} :up 2)
19:09lazybot⇒ {:down 1, :up 2}
19:09astevewhy would you use assoc vs. update-in?
19:11arrdemthe only issue I forsee with doing scheme rather than R5RS
19:11arrdemis the size of the standard library
19:11arrdemasteve: update-in takes a function not a constant as its argument(s)
19:11sshackOkay, I have a simple problem. I've got a vector of vectors with keyword/values [[name: "George Smiley" age: 68], [name: "karla" age:56]]. If I have a name, how can I return the entire row?
19:12corecodearrdem: what do you mean by that?
19:12arrdemcorecode: clojure has more standard library symbols than common lisp
19:12arrdemthe R5RS standard fits in the index of the common lisp standard
19:13asteveah
19:13arrdemwhile clojure is nice, you can build it atop another lisp once you add synchronization primitives.
19:13corecodearrdem: you're saying r5rs < cl < clj, regarding size of stdlib
19:13lockshi, I want to use show, but my repl is saying clojure.contrib.repl-utils can not be located
19:13arrdemcorecode: in absolute terms yes.
19:14locksI'm using 1.5.1, did it get moved somewhere else?
19:14corecodearrdem: i guess that makes it so appealing.
19:15arrdemcorecode: yeah when I finally do my lisp vm I intend to do R5RS or R7RS when it comes out just due to library size.
19:16astevearrdem: ivan NullPointerException clojure.lang.Numbers.ops (Numbers.java:942) when doing (update-in data ["up"] inc)
19:16astevewhere data is {"down" "0", "standing" "1", "url" "google.com", "up" "2"}
19:16arrdemasteve: read the docs on update-in
19:16arrdemasteve: update-in applies a function to the current value
19:16arrdemand generates a new value therefrom
19:17arrdemwhich replaces the current value at that key
19:17arrdemassoc straight "sets" the key
19:17ivan&(inc "2")
19:17lazybotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
19:18corecodearrdem: how is lisp VM and library size connected?
19:19arrdemcorecode: if you want to be able to invoke a symbol, function or macro it has to come from somewhere
19:19locksanswered myself, it's clojure.java.javadoc now
19:19corecodearrdem: but most of the library is written in scheme/lisp
19:19corecodearrdem: no?
19:20corecodearrdem: only a few specials require implementation
19:20arrdemcorecode: depends. yes as you note what I would call the "elegant" lisps are defined in terms of some very small kernel
19:20arrdemcorecode: however Clojure's stdlib uses a looot of java calls
19:21arrdemcorecode: so you could absolutely define some primitives and then use a pre-written bootstrap to get r5rs working
19:21arrdemcorecode: but that ain't gonna happen with clojure.
19:21corecodearrdem: ah.
19:21corecodehm.
19:22corecodearrdem: is it mostly sequence/string handling, etc?
19:22arrdemcorecode: TBH I'm not familiar enough with clojure.core to comment.
19:23corecodeok
19:23arrdemcorecode: you're probably right but I won't confirm or deny.
19:27arrdemcorecode: TBH I suggest that you layer clojure over top of scheme
19:28arrdemcorecode: add futures and atoms so that you have some synchronization primitives, then with some well placed reader macros you should be able to build clojure in scheme.
19:29arrdemcorecode: 'cause the core features you need are namespaced symbols, threads and synchronized access variables
19:29corecodeyes
19:29corecodemy problem is that picobit has its own compiler written in racket
19:29arrdemcorecode: then keywords, the vector syntax and the map syntax is just reader sugar
19:29corecodeand i don't think it implements everything
19:29corecodei.e. no macros
19:30technoma`corecode: what about scheme bugs you in particular?
19:30corecodenow i have to learn racket to extend this
19:30technoma`lack of persistent data structures?
19:30arrdemcorecode: so this is the one I'm reading atm...
19:30technoma`most of the things that drive me nuts about elisp are not flaws that scheme shares
19:30corecodetechnoma`: the bareboneness is confusing
19:30technoma`except for the lack of associative data structure literals; ugh
19:30arrdemcorecode: http://www.stripedgazelle.org/joey/dreamos.html
19:31technoma`corecode: so are you coding to the standard instead of against chicken, racket, etc?
19:31technoma`that sounds exhausting =\
19:31corecodetechnoma`: i'm trying to be practical
19:31corecodetechnoma`: in the end i want something to run on a microcontroller
19:31technoma`seems like fully embracing a specific implementation is the only way to actually get anything done
19:31arrdemcorecode: check out the implementation of that scheme runtime. it's really cute 'cause it bootstraps r4rs using a small runtime and macros
19:32corecodethe picobit compiler is also fairly small, i guess. 3k lines of racket
19:33corecodebut my true goal is to investigate state machine-based programming
19:35muhooalex_baranosky: technomancy: is anyone actively working on slamhound these days?
19:37technoma`muhoo: alex occasionally pokes at it. it's been working decently enough for my uses that I haven't needed to recently.
19:37asteveI would like to bind a function to a variable if the function is not nil; is that not if-let?
19:38arrdemasteve: depends on the invocation but potentially.
19:39muhootechnoma`: it's kind of driving me crazy that there's no way to have two different ns'es that have the same var in them.
19:40arrdemmuhoo: it's evil, but you can def a var with the fully qualified name of the other
19:40muhoono i mean the same NAME, but different vars
19:41technoma`muhoo: you should only have to fix that once though; IIRC if you've put it in the ns already it should prefer it over another var
19:41asteve,((defn moop [] nil) (if-let [poom (moop)] poom)
19:41clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
19:41arrdemmuhoo: urgh that's a mess.
19:42muhooexample: foo/settings, and bar/settings . both named settings, but different ns'es. if i go into (ns baz), and run slamound, even if i want bar/settings it'll do (:require (foo :as bar))
19:42muhooeven if i *explicitly write* "bar/settings", it'll ignore that, and go require foo as bar
19:43muhooi'd just blow off slamhound, but it's essential for doing java interop :-(
19:43Apage43it is?
19:44muhooyeah, if you have (:import ... ) forms that are like a page long
19:44Apage43ah
19:44Apage43I have never really had to import more than a few things in one file
19:44technoma`muhoo: oh, if you refer to both of them in the same ns; that case probably isn't handled yet =\
19:44tieTYTwhy isn't there a def- ?
19:45technoma`it can handle the existence of two same-named vars but only if they're not refered in the same place; that does suck
19:45muhootechnoma`: right. hmm.
19:45muhoothe problem is, to be completely clear, is not that foo/settings is referenced in baz, but that foo/somethingelse is reference in baz
19:46technoma`oh; huh... weird
19:46technoma`I definitely haven't put it through heavy usage yet
19:46muhoowhich seems to cause it to want to pull in that ns. once it does, it seems to go, oh lookee here you have settings in this ns, perhaps this is what you meant
19:47muhooit's a great codebase. which means i don't understand it well enough to hack on it
19:47ToBeReplacedis there a filter-with like (filter-with [1 nil 2] [:a :b :c]) which would return '(:a :c) ?
19:47muhootechnoma`: tis ok. i'll just have to be careful just to watch what it does and work around stuff like this.
19:50technoma`muhoo: getting a failing test case as a pull request might be a nice start
19:51muhootechnoma`: cool, ok will do
20:01patchworkWhy would > lein clean hang?
20:02technomancy_patchwork: windows?
20:02patchworkNo, osx
20:02tieTYTi heard that steve yegge wrote this article about clojure but I can't find it by googling. Anyone have a link?
20:02technomancy_patchwork: hm; not sure. it's just rm -rf target
20:03patchworkCould it be the checking for plugins in profiles.clj?
20:03patchwork(just thought of that)
20:03patchworkdoes that get run before every command?
20:03technomancy_patchwork: plugins get loaded, yeat
20:03patchworkSo that is a remote request that could be hanging
20:03technomancy_you could try lein -o clean
20:04patchworkYeah that completed immediately!
20:04patchworkthanks!
20:05patchworkquile: I have a commit in develop for your errors
20:06patchworkIt should handle localization mismatches correctly now
20:06patchworklet me know
20:06patchwork(even for the case where the join model is not localized but the from and to models are)
20:06technomancy_patchwork: wrong channel =\
20:07patchworkHa! Thanks : ) I type in this window so much I didn't even check
20:09patchworkWe just had an issue where our client won't allow new clojure projects because its security static analyzer doesn't support clojure : (
20:09patchworkSerious bummer for us
20:10patchworktrying to find a way around using java
20:11arrdemclojurebot: ping
20:11clojurebotPONG!
20:11arrdemgood.
20:18jack_rabbitHow do I pull deps for my leiningen project into the repl?
20:19technomancy_jack_rabbit: you mean you changed project.clj and don't want to restart?
20:19jack_rabbitNo. I'm using nrepl, and they don't seem to be available. At least I can't (require) them.
20:20technomancy_you're probably not connected to the repl server you think you are
20:20jack_rabbitOh wait.
20:20jack_rabbitIt was.
20:20jack_rabbitSyntax syntax syntax. Forgot to quote the package, since you don't quote it when calling ns.
20:39combataircraft_Is there anybody interested in doing functional programming in JavaScript ecosystem?
20:39gfredericksIf we could do that bit over (ns vs require) how would we do it different?
20:42technomancy_gfredericks: making require a macro that took symbols for backwards-compat would unify things without requiring a time machine
20:44technomancy_if we could go back in time I'd say having (ns myns (require 'some.thingy)) wrap all its regular require function calls in a transactional load would have my vote for sure =)
20:45hiredman:(
20:45hiredmanrequire as a function is nice
20:45hiredmanmaking it a macro would not be
20:46technomancy_right; you wouldn't be able to map it, etc
20:46technomancy_yeah, I can't think of a good way to do it that would be backwards-compatible
20:46technomancy_which could be why no one's proposed anything?
20:47technomancy_making ns treat all non-keyword clauses as a body might be interesting
20:49technomancy_haven't really thought that through
20:52cemerickgfredericks: "copy racket" is a decent start, perhaps
20:52technomancy_cemerick: what
20:53technomancy_my only take-away from the racket keynote was "wow, I'm so glad we don't have to deal with any of that madness"
20:53technomancy_though that was more about compilation phases than the syntax I guess
20:54cemerickright, you can put whatever sugar you want on top
20:55cemerickmany of the pain points around ns and require is that there's stuff underneath that you wish you could affect, but can't
20:55technomancy_the fact that it's not extensible for stuff like ns+?
20:57gfredericksdoes racket have eval?
20:57cemericktechnomancy_: one manifestation, yeah
20:58cemerickgfredericks: stop trolling ;-)
20:58gfrederickscemerick: the seeming strict separation between compile-time and runtime makes me wonder
20:58gfredericksdo they pile the whole racket compiler into every excutable just in case you want to eval something?
20:59gfredericksmaybe a lightweight interpreted version?
20:59cemerickgfredericks: yes
21:00cemerickracket doesn't compile to C or anything
21:00technomancy_I think you can tree-shake eval out
21:00chessguyya'all know anything about a startup called runa? does a lot of clojure work
21:02gfredericksthey sponsored clojure/west last year
21:02arrdemtechnomancy_: really? I suppose that any code generation you could do and then eval could be expressed as a lambda tempate...
21:02chessguygfredericks: i heard they were the first company to put clojure code in production
21:02technomancy_arrdem: well, I don't know if racket has it specifically, but I know several schemes do
21:03gfrederickschessguy: that would be difficult to verify
21:03technomancy_chessguy: not quite
21:03technomancy_luc prefontaine was the first to post about it
21:03chessguytechnomancy_: that name doesn't ring a bell. not a relevancer?
21:04technomancy_chessguy: no. he works for a hospital IIRC.
21:04technomancy_predated runa by quite a bit; at least six months?
21:04technomancy_I think his was January of 09
21:04chessguytechnomancy_: i see
21:05chessguytechnomancy_: maybe i misunderstood
21:05chessguytechnomancy_: do you know anything about the runa guys? i'm curious about what kind of reputation they have in the community
21:06chessguyseems like they're doing some pretty serious statistical modeling work
21:07cemerickwho went to production first vs. who talked first, etc.
21:07technomancy_chessguy: we evaluated their clustering library in late 09 and found it to be kinda shaky
21:08chessguygotcha
21:09technomancy_you could read Clojure in Action; it was written by their founder
21:09chessguyindeed
21:10chessguyi saw his talk from strange loop on zolodeck. it was interesting
21:38tomojin clojurescript, (re-matches #"foo" nil) is []
21:39tomojI wonder if it should throw an exception or return nil?
21:42asteveclojure is a beautiful thing when it works
21:56mthvedt,(re-matches #"foo" nil)
21:56clojurebot#<NullPointerException java.lang.NullPointerException>
21:59gfredericks(throw (new javascript.lang.NullPointerException))
22:01kwertiiWhat's the easiest way to programmatically generate arguments for a function with destructuring {:as opts} that expects to be called like (foo "bar" :baz 1)?
22:02kwertiiThe best I've got is (apply (partial foo "asdf") [:bar 1]), which isn't very clean looking.
22:03ivanclojurebot: mapply?
22:03clojurebotYou could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args))))
22:04kwertiiivan: Nice. Thanks!
22:09murtaza52clojureboot: what is mapply doing?
22:09murtaza52clojurebot: what is mapply doing?
22:09clojurebotIt's greek to me.
22:12murtaza52A question about ns compilation and loading in jvm - I have a top level function call that I make in one of my ns. If I require than ns in my projects ex.core, then the call gets executed (This is what I want). So is the ex.core file of any project compiled and loaded into the jvm first ? (as I understand all other ns are compiled as needed)
22:18mmitchellfor learning purposes, i'm trying to wrap with-redefs with my own calling semantics using a macro. I have a function called "add" that I want to redefine, but I'd like to redefine it like this: (my-redef {:f1 add :f2 (constantly 10)}) -- any pointers for making this work?
22:19mmitchellI'm having problems with the un-quote splicing into (with-redefs [k1 v1...
22:22gfredericksmmitchell: can you paste the code that doesn't work?
22:23gfredericks(refheap.com)
22:26mmitchellgfredericks: ok, my real code is a little more complicated, but i think you'll get the idea
22:26mmitchellgfredericks: ok here you go: https://www.refheap.com/paste/13281
22:27gfredericksmmitchell: so lines 13+14 are the intended usage?
22:28mmitchellgfredericks: exactly yes
22:28mmitchelli tried to use a for, to pull the :fn1 and :fn2 values out for each "mock", but nothing I tried worked
22:30mmitchelljuxt would work work as well for each map, but expanding into the binding vector that "with-redefs" expects... I just can't figure it out
22:30gfredericksmmitchell: so on line 11
22:30gfredericksyou've got yourself a list of maps
22:30gfrederickseach with a :fn1 and :fn2 key
22:30mmitchellgfredericks: yes
22:30gfredericksand you want to turn that list of maps into a flat sequence of alternating fn1s and fn2s
22:31mmitchellexactly
22:31gfredericksit sounds like you're aware of how to make a sequence of pairs
22:31gfrederickswhich is half the way there
22:31gfredericks(you can do this outside the backtick by the way)
22:31mmitchelloh really?
22:32gfrederickssure
22:32gfredericksthe arguments are just data, you can play with them like data
22:32mmitchelloh right
22:33gfredericksbacktick just gives you templating and a couple safety mechanisms. it isn't even strictly necessary (as you must know since you didn't even use it in the mock macro)
22:33mmitchellahh right yes
22:34gfredericksso a list of pairs can be flattened with (apply concat pairs)
22:34gfredericksyou could unquote-splice those into the vector, or put them in a vector and unquote the whole vector in without splicing
22:35gfredericksat that point backtick is doing very little for you
22:35gfredericksand you might find it simpler to say (list* `with-redefs things body)
22:36mmitchellok thinking...
22:41mmitchellgfredericks: so i am trying this one out, but my function values are all nil: https://www.refheap.com/paste/13282
22:41gfrederickswelp that's exactly what I had in mind
22:42gfredericks(apply concat (map ...)) is (mapcat ...) btw
22:42mmitchelloh cool, good to know
22:42gfredericksbut why it doesn't work...
22:45gfredericksoh golly
22:45gfredericksof course
22:47gfredericksthe argument to with-mocks is not the maps
22:47gfredericksit's the call to mock
22:47mmitchelloh yes
22:47gfrederickswith-mocks does not see {:fn1 add :fn2 (constantly 10)} it sees (mock add (constantly 10))
22:48gfredericksyou could (comp (juxt :fn1 :fn2) macroexpand-1) instead of (juxt :fn1 :fn2)
22:48gfredericksbut this is getting ugly fast
22:49gfredericksso where you actually want to go depends on the nature of your "learning purposes" I suppose
22:50mmitchellgfredericks: interesting, well i'm learning already so this is good
22:52gfrederickswith-redefs-fn is a thing
22:54mmitchellgfredericks: actually, maybe "mock" should just be a function?
22:57gfredericksit could but if that's the only change you'd have the same problem
22:57mmitchellyeah
22:59gfredericksso one question is why you need `mock` to exist
23:00gfredericksbut with-redefs-fn can solve the problem because you don't need the redefinitions map to exist until runtime
23:00gfredericksthen the macroexpansion order isn't important anymore
23:01mmitchellgfredericks: well, my idea is that i would have a map for each "mock". Each map would also contain a :called key, which would be an integer that's incremented each time its called. I could then know whether or not a mock was actually called, and raise an error if it wasn't. Does that make sense?
23:02mmitchelloh yeah, i'll checkout with-redefs-fn
23:05gfrederickswell for that use case you want the map to exist at runtime, sort of. I've done call counts before by adding an atom as metadata on the function
23:07gfredericksanyhow I'm heading out; have fun
23:07mmitchellgfredericks: cool thanks for your help!
23:08gfredericksnp
23:51asteveI have a map that looks like {"first "this", "second" "that"} I would like to recreate the map such that {"first" "this", "second" "that plus new"}
23:51asteveupdate-in?
23:58arrdemasteve: if you want your update to be some function of the existing value yes
23:58asteveI'd really like to append the new string to the end
23:59arrdem,(update-in {"this" "that"} ["that"] str " and other")
23:59clojurebot{"that" " and other", "this" "that"}
23:59arrdem ,(update-in {"this" "that"} ["this"] str " and other")
23:59clojurebot{"this" "that and other"}
23:59arrdem,(doc update-in)
23:59clojurebot"([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."