#clojure logs

2011-12-30

00:20emezeskeAny clojurescript compiler people in here?
00:38fryguyis it normal for "lein repl" to take 5+ seconds to start?
00:39technomancyfryguy: yeah, you'll want to see if you can install a client JVM; it starts a lot faster than the server JVM
00:39fryguywhat is a lot faster in this case?
00:40technomancythe time it takes to launch the process
00:40fryguyi mean how much faster
00:40fryguyalso:
00:40fryguy~% java -version
00:40clojurebotexcusez-moi
00:40fryguyjava version "1.6.0_22"
00:40fryguyOpenJDK Runtime Environment (IcedTea6 1.10.4) (ArchLinux-6.b22_1.10.4-1-x86_64)
00:40fryguyOpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
00:40technomancyon an SSD with a weak processor I get the repl coming up in about 0.7s
00:43technomancya weak cpu being a 1.8 GHz core 2 duo
00:43fryguytrying to find out how to get a client vm now
00:44technomancyyou'll need it compiled for 32-bit for starters
00:44fryguythere's not 64-bit client vm?
00:45technomancyright
00:45fryguythat sucks
00:46technomancyyeah, I need to put together some docs for that; maybe on the wiki
00:47technomancyit used to be easy to get a 32-bit oracle JDK on ubuntu, but for some reason the openjdk builds are only available as 64-bit
00:49fryguytrying to find them for my distro now, PITA
00:50technomancyactually sorry; the 0.7s number was the boot time for lein itself; the time it takes to start a repl will be longer
00:50technomancystill, it'll definitely be better than 5s
00:53fryguyi guess I can just live with poor start times for now
00:53fryguynot like i'll be starting repls all of the time, if I do this right i'll have my repl up and connected to my text editor and that's it
00:54technomancyyeah, that's basically the reason I haven't bothered getting set up with a client JVM; I just don't start a new process very often.
00:55fryguyso i've got "clj" as an executable, and lein, will get interaction with text editor next. Hopefully that's all I'll need in the short term to get things done
00:56amalloyi suggest deleting clj with a flamethrower. lein repl will just make you happier
00:56amalloythere are people who disagree with me here, but most of the time when you want a repl, use lein
00:57technomancyamalloy: there are?
00:57fryguyso, here's a silly question, if I do JUST lein self-install, and nothing else, does that give me clojure too? or do I need clojure before I use lein?
00:57amalloyi've heard rumblings once or twice, technomancy
00:57fryguyi installed clojure from my distro's package repository
00:57technomancyrumblings, you say?
00:57amalloyi forget from who; some heretics
00:57technomancy~guards
00:57clojurebotSEIZE HIM!
00:58technomancyfryguy: yeah, that's usually not very useful
00:58technomancycommon mistake
00:59fryguyso I JUST need lein?
00:59fryguy(and a jdk obviously), nothing else?
01:00technomancyplus whatever it takes to make your editor work with clojure
01:00fryguyright
01:00fryguyi thought lein would be more analogous to cabal from haskell
01:01amalloydoes he actually need a jdk? i kinda thought clojure only needed a jre but haven't really investigated
01:02technomancydepends on if you want a debugger and/or javca
01:02technomancy*javac
01:02amalloyoh right, durn that javac
01:05technomancyfor some reason people tend to use it
01:05technomancyno idea why
02:09emezeskeOkay, I've encountered a situation where I can "lein run ..." my project, and it throws an exception.
02:09emezeskeThen, if I touch a particular .clj file in my src/ directory
02:10emezeskeAnd "lein run ..." again, no exception is thrown and it works just fine
02:10emezeske(and I mean touch as in the unix command; no change to its contents)
02:10emezeskeThis is really hurting my brain...
02:20simonadameitemezeske: strange situation… though it doesn't sound totally inconceivable to me.. dont those build tools decide, what to recompile based on last modification date?
02:21emezeskesimonadameit: Yeah, I assume so
02:21emezeskesimonadameit: I noted all the timestamps on the *.class files, though, and then touched my special file and reran things
02:22emezeskesimonadameit: None of the *.class files were modified
02:22emezeskeSo I wonder if maybe making the file newer than it's *.class files makes clojure interpret it instead of using the .class file on disk
02:23emezeskeThe weird thing is, though, that I'm not changing contents of the .clj file, so it should work the same from a .class or interpreted from a .clj
02:27emezeskeWeird... it looks like the {:macro true} metadata is not being stored in the class files
02:27emezeskeWhen I run things without AOT, though, the macros have ^{:macro true}
02:30simonadameitemezeske: sounds like that could be a clojure bug?
02:30simonadameitemezeske: I wish you good luck, gotta go to work
02:30emezeskesimonadameit: It's beginning to look that way... X.X
02:30emezeskesimonadameit: thanks for the input!!
02:32amalloyemezeske: whoa, that sounds pretty weird. what was happening that made you start looking at macro meta?
02:32emezeskeamalloy: uh, I don't remember. I've been digging at this for like 20 hours
02:32emezeskeThere's problems with using the clojurescript compiler when it's AOT compiled
02:32emezeskesometimes
02:33emezeskeAnd it's due to the way it determines "what's a macro"
02:33emezeskeIt checks the metadata for :macro=true
02:33ibdknoxwhy are you trying to aot compile the cljs compiler?
02:33emezeskeI'm trying to package it up as an uberjar
02:33amalloyibdknox: i send IRC msgs to my IRC client to ask it to talk to y'all
02:34ibdknoxamalloy: hm?
02:34emezeskeAnyway, the {:macro true} metadata is apprently not stored in AOT class files
02:34amalloyi was going for a yo dawg thing: compiling the compiler, /msging the irc client...didn't work out that well
02:35ibdknoxhaha
02:35ibdknox:p
02:35emezeskeI guess the metadata is not stored at all, and just the basic stuff is regenerated when loading the class files?
02:35emezeske(by basic stuff I mean line no, file, etc)
02:35emezeskeWait, that doesn't make sense... The line-no/file would need to be stored...
03:34kralmorning
03:35Scriptormarnin
05:47przemek_Hi, I have a question. I'm wondering what is the idiomatic way to create a new map out of some other map in a way that we want to modify some of its values.
05:48przemek_say we have a map {:a {:foo 1 :bar 2} ... } and we need to modify :foo for some entries and we want to produce a new map
05:49przemek_in Scala there is something like "yield"
05:49przemek_so I can get to entry k/v and can yield value(s) so at the end it is the final new map
05:50przemek_no idea how to accomplish this simply in Clojure
05:51przemek_any ideas highly appreciated :)
05:51raekprzemek_: check out the *-in functions: update-in, assoc-in, get-in
05:52raek,(update-in {:a {:foo 1}} [:a :foo] inc)
05:52clojurebot{:a {:foo 2}}
05:53przemek_yeah
05:53przemek_thanks a lot!
06:02raekprzemek_: it's usually simpler to answer a "how do I ___?" question if you can show an example input and an example of the desired output
06:06przemek_ok
06:07przemek_actually it still does not seem simple to me
06:07przemek_Given: {"foo" {:x ... :y ...} "bar" {:x ... :y ...} ...}
06:07przemek_I want to have all entries that match some predicate to have :x value modified, say changed to 1:
06:07przemek_{"foo" {:x 1 :y ...} "bar" {:x 1 :y ...} ... }
06:07przemek_note I don't know the key name/position
06:08przemek_have read http://clojuredocs.org/clojure_core/clojure.core/update-in and still not sure...
06:12raekI think this is easier to do if you break down the problem into smaller pieces
06:12przemek_surely, but still it is just 1 level of nesting and a simple map
06:13raek(defn update-outer-map [m] (into (empty m) (for [[key val] m] [key (update-inner-map val)])))
06:13raek(defn update-inner-map [m] (if (pred? (:x m)) (assoc m :x 1) m))
06:13mageslayerdenHi guys. I am trying emacs+slime+clojure. And something breaks :). Maybe someone knows the magic spell? I see only - error in process filter: Elisp destructure-case failed: (:write-string "2 " :repl-result)
06:14mageslayerdenit's when I am trying to eval (+ 1 1)
06:14przemek_it kinda makes sense :) I will check that out
06:14mageslayerdenI am using slime from macmalade repo :)
06:17raekprzemek_: but of course you can do all this in one function. just inline update-inner-map into the for
06:18raekin this case update-outer-map could also have been written (defn update-outer-map [m] (zipmap (keys m)) (map update-inner-map (vals m))))
06:18raeksince you only want to change the values of the outer map
06:35raekmageslayerden: make sure you don't have slime installed in your OS package manager (e.g. apt-get) and that you don't have slime-clj, swank-clj, and swank-clojure installed in emacs
06:36mageslayerdenI uninstalled official slime. The problem is without swank-clj - slime does not start, just emits another error
06:36raekthe only clojure related elisp package you should have in a basic setup is clojure-mode (and if you don't use clojure-jack-in: also slime and slime-repl)
06:37mageslayerdenslime and slime-repl have been installed from elpa as well
06:37raekmageslayerden: swank/slime-clj is an alternative implementation of swank and slime. do not mix them with the usual ones
06:38raekthat project has been renamed, but the versions with the old names are still available
06:38mageslayerdenOk. I got it. btw. is it possible to unload slime-clj without restarting emacs?
06:40raekbasic setup: clojure-mode (and possibly slime and slime-repl) on the emacs side and swank-clojure on the leiningen side
06:41antares_vijaykiran: hey
06:41mageslayerdenok. I'll to restart emacs to test it now. Thanks a lot
06:41raekstarting swank-clojure from emacs is a very outdated approach (not counting features that use lein to do it, like clojure-jack-in and various lein elisp packages)
06:43vijaykiranantares_: Hi
06:43antares_vijaykiran: you had a question in #travis, correct?
06:44mageslayerdenraek: without slime-clj, I get - byte-code: Symbol's function definition is void: slime-buffer-name
06:44mageslayerden
06:44vijaykiranantares_: yeah :)
06:45antares_vijaykiran: you problem seems to be what several people had with re-published artifacts
06:45antares_vijaykiran: on travis-ci.org, dependencies are installed from scratch. Locally it is usually not the case. Try (re)moving ~/.m2 and see if you can reproduce the issue locally, then :exclude clojure dependency like this: https://github.com/michaelklishin/monger/blob/master/project.clj#L7
06:46mageslayerdenraek: here is my emacs+slime config - http://pastebin.com/UD3rLPhP
06:48vijaykiranantares_: oh .. thanks a lot, I don't have any tests but I'll try your tip
06:49antares_vijaykiran: hm, what do you mean you don't have any tests?
06:49antares_vijaykiran: then why put your project on travis-ci.org? :)
06:49raekmageslayerden: when you install slime or when you use it?
06:49raekit is normal to get these kind of errors when installing
06:49vijaykiranantares_: just to "test" :)
06:49mageslayerdenwhen? just 2 hours ago :)
06:50antares_vijaykiran: ok. Well, one issue is already revealed :)
06:51mageslayerdensorry. I misunderstood you. This error is shown when I am starting emacs.
06:54vijaykiranantares_: I've another question - do you know if there's an easy way to use test database from travis (Clojure) ?
06:54raekmageslayerden: sorry, but I don't know what to do except for trying commenting out lines in the .emacs.d file
06:55antares_vijaykiran: we provide mysql, postgresql, sqlite, mongodb, riak, couchdb, redis and some projects download & install neo4j and so on
06:55antares_vijaykiran: http://about.travis-ci.org/docs/user/database-setup/
06:55mageslayerdenraek: looks like like it is related to hippie-expand. I removed hippie-expand, but the error with eval is the same
06:55antares_vijaykiran: create your databases in before_script, that is usually it
06:56raekmageslayerden: I got to go now, but you can read more in the official docs for swank-clojure: https://github.com/technomancy/swank-clojure
06:56mageslayerdenraek: thanks, I'll try
06:56raekif you are going to follow a guide, this is the *only* one you should look at
06:56vijaykiranantares_: yes, saw that page. But was wondering if different config is needed for clj apps
06:56antares_vijaykiran: no
06:57mageslayerdenraek: I tried maybe a dozen already :), but thanks :)
06:57vijaykiranantares_: okies .. thanks, will RTFM and drop by #travis if I'm stuck!
07:00antares_vijaykiran: for example, I have https://github.com/michaelklishin/monger and https://github.com/michaelklishin/neocons on travis. https://github.com/doctrine/dbal/blob/master/.travis.yml is a good example of testing against multiple relational databases.
07:01antares_vijaykiran: cool, let us know what you think :)
07:18benoystjust a stupid question, but why clojure.xml/parse does not accept a string (except as uri) but only files?
07:19benoystI've a function returning a java.lang.String which happens to be an xml doc but parse refuses to munch it.
07:20benoystI'm sure it's very basic but I can't get out of this issue.
07:33cemerick,(clojure.xml/parse (java.io.ByteArrayInputStream. (.getBytes "<html></html>" "UTF8")))
07:33clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.xml>
07:33cemerick,(require 'clojure.xml)
07:33clojurebotnil
07:33cemerick,(clojure.xml/parse (java.io.ByteArrayInputStream. (.getBytes "<html></html>" "UTF8")))
07:33clojurebot{:tag :html, :attrs nil, :content nil}
07:33cemerickbenoyst: ^^
07:34benoystcemerick: just for the records: big fan!
07:34benoystthis is the offending code: http://maleloria.org/temp/hard-times-with-xml.txt
07:35benoystoh. ByteArrayInputStream.
07:35benoystI guess I dit not get something right here.
07:35benoyst(but I thought I did that in my code)
07:37cemerickbenoyst: what's the actual error you're getting?
07:40benoystcemerick: java.lang.String cannot be cast to clojure.lang.IFn. I guess there are too many () somewhere?
07:41cemerickbenoyst: from-raw-msg-to-details calls my-saml-xml, which looks to be a string.
07:44benoystoh yes, but (parse-saml-message mysamlxml) throws the IFn error ... before even playing with the from-...
07:44benoyst(I'm converting a base64xml to xml to get some data in it)
07:45cemerickbenoyst: can you paste the error + stack trace?
07:47benoystsure!
07:54benoystcemerick: I'm very grateful for your time. I've updated my file here: http://maleloria.org/temp/hard-times-with-xml.txt
07:54benoyst(repl session + strack trace)
07:56SomelauwIs there some way to get slime/leiningen/clojure/emacs outside a Java heap space error without restarting emacs?
07:56SomelauwI got myself into infinite a recursion without TR.
07:57cemerickbenoyst: oh: (saml-xml)
07:58benoyst(big shame on me in 3, 2, 1...)?
07:58benoystoh you mean (.getBytes (saml-xml) "UTF-8"))] instead of (.getBytes saml-xml "UTF-8"))] right?
07:58cemerickyes
07:59benoystyes.
07:59benoystbig shame in me *now* :)
07:59benoyston
07:59cemerick(foo) invokes foo as a function; since saml-xml is a string, that won't work :-)
08:00benoystyes! can't believe I made that. Sorry. and *many* thanks for your expert eye on that!
08:00cemerickYou're welcome. no need to be sorry :-)
08:00benoystcemerick: many thanks!
08:05benoyst(much better now!)
08:14vijaykiranis there an easy way to see the dependency tree for a lein project ?
08:15cemerickvijaykiran: lein pom && mvn dependency:tree, assuming you have maven installed
08:15Rayneslein pom && mvn dependency:tree
08:15chouservijaykiran: the best I've been able to do is trace the load function, so you can see which namespaces are loading which.
08:15Raynescemerick: Dude.
08:15cemerickA better alternative is incoming
08:15cemerickRaynes: Dude!
08:16RaynesI don't know how your latency made that look, but mine made it appear as if we said that at *exactly* the same time. Like, two a microsecond.
08:16Raynesto*
08:16vijaykirancemerick: how do I trace - sorry noob here
08:16cemericktrace?
08:16clojurebottrace is http://richhickey.github.com/clojure-contrib/trace-api.html
08:16lazybotNooooo, that's so out of date! Please see instead http://clojure.github.com/clojure-contrib/trace-api.html and try to stop linking to rich's repo.
08:17cemerickgawd, dueling bots
08:17RaynesHahaha, clojurebot just got told.
08:17chouserexcept they're both wrong
08:18cemerickchouser: He lives! I thought you'd abandoned us irc plebs for good. ;-)
08:18chouserhttps://github.com/clojure/tools.trace
08:19chouserwell, I am getting sufficient Clojure fixes at work now.
08:19cemerickOh, so we were just your fling on the side. I get it.
08:19cemerick:-D
08:20chouserI don't need IRC to stem the gnawing desperate craving for Clojure discussions.
08:20cemericks'ok, I'm sorta absent these days a bit as well
08:21chouserfling? More like I'm selling now, so don't need my old dealer.
08:22SomelauwWhy is this code not lazy?
08:22Somelauwhttp://pastebin.com/b0QJsDRz
08:25chouserSomelauw: why do you think it isn't?
08:25Somelauwchouser: Executing it results in an infinite loop.
08:26SomelauwOr at least, it hangs.
08:27SomelauwAnd ends in a heap memory error if I don't stop it.
08:27chouser(first (primes)) returns promptly for me
08:28Somelauwer, my bad
08:29chouserThat suggests it actually is lazy, but that copmuting some of the later elements of the seq consumes large amounts of time and memory
08:30SomelauwI tried writing this prime function. Then got a heap error. I restarted emacs and wrote it all over again and this time I forgot to use the take command.
08:32Somelauwchouser: I know this is not the most efficient way.
08:34Somelauwthanks
09:00solussdis there a more straightforward way to splice in a list of arguments to a defrecord than a macro? e.g. If I have a record call Blah that takes 2 args and I have [arg1 arg2], I need (Blah. arg1 arg2)
09:03cemericksolussd: use (->Blah arg1 arg2)
09:04solussdcemerick: but my arg1 and arg2 are in a vector, how do I splice them in w/o a macro?
09:04cemerick(apply ->Blah arg1 arg2)
09:04hank_the_hobocemerick? I'm a user of nREPL. it says in the docs to contact you on IRC.
09:04solussd(apply ->Blah [arg1 arg2])
09:05solussdthis ->RecordType is new to me, is it new to clojure?
09:05cemericksolussd: yeah, sorry, typing too fast :-)
09:05cemericksolussd: new in 1.3, discussed here http://dev.clojure.org/display/design/defrecord+improvements
09:05cemerickhank_the_hobo: ut-oh :-)
09:05cemerickwhat's up?
09:06solussdcool thanks!
09:06hank_the_hobo@cemerick. why uh oh. it's nifty and useful and many thanks for that.
09:06hank_the_hobo1 comment:
09:07hank_the_hobothe latest iteration seems to be introducing a dependency on java.awt for some strange reason. not sure what awt has to do with a REPL
09:07hank_the_hoboI'm using it on Android which has no AWT. is this something that can be factored out into a separate module.
09:08cemerickhank_the_hobo: I think it's more likely that you're doing something to prompt AWT to start up.
09:08cemerickOh.
09:08cemerickHrm.
09:09hank_the_hoboit's says java.awt.RenderedImage somewhere in the code if I'm not too tired to tell things apart
09:09cemerickhank_the_hobo: so you're using 0.0.6-SNAPSHOT?
09:10hank_the_hobonot actively but I did a little look ahead
09:10cemerickYeah. You're right.
09:11hank_the_hobo@cemerick I might have to fork it anyway ... the other problem on android is that threads come with very small default stack sizes so I had to change the part where the executor is init'd with the threadfactory
09:11hank_the_hoboandroid has 8k by default which is not enough to eval moderately complex expressions
09:11hank_the_hoboso I might fork it anyway
09:12cemerickhank_the_hobo: some fairly significant improvements will be coming to nREPL soon that will make the AWT issue go away.
09:12hank_the_hobooh
09:12hank_the_hobook
09:12cemerickI'm not even sure I'm going to put out a 0.0.6 release
09:12hank_the_hobowell I'm worried for nothing then.
09:12cemerickProbably going to "jump" to 0.1.0 with a new architecture
09:13hank_the_hobothanks keep up the good work
09:14cemerickhank_the_hobo: a patch to customize the thread stack size would be most welcome, though.
09:15cemerickI might end up changing what you produce so as to satisfy other configuration requirements as well, but I'd at least know what you need on android.
09:15hank_the_hobo@cemerick ok no probs
09:15cemerickheh, or you can just file a bug: http://dev.clojure.org/jira/browse/NREPL
09:15cemerick:-P
09:16hank_the_hoboah is that how it works ... couldn't find the bug function on github that some other accounts have
09:16cemerickYeah, nREPL is a contrib project, so everything is in JIRA / confluence.
09:22solussdis (into {} (vec my-record)) the best way to squeeze a hash-map from a record?
09:23cemericksolussd: just (into [] my-record) will do — though worrying about concrete types like that should be a warning signal.
09:24solussdbut I want a map
09:24cemerickRecords are maps!
09:24TimMcsolussd: There are different kinds of maps.
09:24solussdright--
09:24solussdyou had [], I wanted {}, which also works. :)
09:24TimMcah, into [] <- got it
09:25TimMcsolussd: Yes, (into {} ...) is fine.
09:25solussdI'm using (into {} my-record) now, thanks!
09:25solussdI swear that didn't work before…
09:26cemerickTimMc: [] was (another) typo on my part, I still suspect solussd is doing an unnecessary conversion.
09:26solussdis (into {} my-record) ok?
09:26TimMcsolussd: What's the use-case here?
09:27solussdI need to pass the contents of a record as a map for :attrs in a map for clojure.xml/emit
09:28solussdso (clojure.xml/emit {:tag :something :attrs (into {} my-record)})
09:28TimMcAnd it doesn't treat records as maps?
09:28solussdi thought it didnt-- but then, i also thought the into wasn't working.. (testing...)
09:29goodieboyanyone here use noir?
09:29solussdthat works… :D
09:55solussdwhy doesn't this work? (. java-array length) ?
09:56hoecksolussd: because .length isn't a property or method of java arrays, its java syntax
09:56hoecksolussd: like String.class
09:57solussdoh, ok. Do I have to make it a seq then?
09:57solussd(to get the length)
09:59jodaroyou should be able to use count
09:59hoecksolussd: no, (count java-array) does the right thing for you
09:59solussdthanks
10:10TimMcI recently found myself annoyed that Java doesn't have a IntegerNumber marker interface on Long, Integer, Short, Byte, and BigInteger.
10:11TimMc(and similar for the floating-point numbers.)
10:12TimMcWould multimethods (with a derive hierarchy) be an effective way of getting that information?
10:18TimMc$findfn (int-array 5) 5 ; solussd
10:18lazybot[clojure.core/count clojure.core/alength]
10:19TimMcI think alength would be used when performance was essential.
10:20solussdthanks
10:50jodarowoop, my first ANN: http://groups.google.com/group/clojure/browse_thread/thread/7ae3e1926f02b20f
11:17TimMc"ANN"?
11:18TimMcnvm, announcement
11:40TimMchoeck: I had no idea that was sugar. Array classes are just one big lie, eh?
11:40TimMcs/sugar/syntax/
11:45hoeckTimMc: they are 'special', I don't like that, no one will notice it except when starting to use clojure
11:55solussdhow do I get a sub-array of a plain java array?
12:10semperossolussd: what's your array look like? (gist/pastebin) and do you need to return a Java array, or are you looking to make it a Clojure datastructure?
12:11solussdsemipros its for a genetic algorithm where I'm randomly piecing together sub-arrays to form 'children'. Don't need to go back to a clojure data structure
12:11solussd*semperos^
12:11semperosok
12:11semperosby sub-array, do you mean you have something like [1 2 [:a :b] 3 4] and you need the [:a :b] ?
12:12solussdwell, it's a java character array created like this: (char-array \a \b \c)
12:12solussdI might want just the \b and \c, for example
12:12solussdso, what I need is a sub-array copy function
12:12solussdin java it is System.arraycopy
12:13cemericksolussd: that's what it is in Clojure too ;-)
12:14ibdknoxcemerick: I'll get you my feedback by tomorrow, sound good?
12:14cemerickibdknox: perfect, thanks :-)
12:14cemerickI saw a commit that looks like it fixed the bug I think I found?
12:14ibdknoxit wasn't a bug per se, I actually did it on purpose, it was just a dumb decision :)
12:15ibdknoxwasn't consistent with everything else
12:15ibdknoxso yep!
12:15ibdknoxall fixed
12:31TimMcsolussd: Why are you using arrays instead of vectors?
12:32solussdperformance I guess
12:32ibdknoxI missed the beginning of that conversation so I didn't respond with ##(doc subvec) ;)
12:32lazybot⇒ "([v start] [v start end]); Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not supplied, defaults to (count vector). This operation is O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done."
12:32ibdknoxhard to beat constant time "copies"
12:33ibdknoxif copying is the main overhead
12:33solussdI doubt it is though..
12:33ibdknoxhuh?
12:33ibdknoxoh
12:33ibdknoxyeah, I have no idea what you're doing :)
12:35ibdknoxsolussd: out of curiosity, did you benchmark the difference between an array solution and a vector one?
12:35TimMcsolussd: "performance I guess" <-- if you haven't profiled your code, don't try to optimize
12:35ibdknoxthat's what I was getting at ^^
12:35solussdsimple example: two parents: 'abcdef' and 'uvwxyz' would make children like: 'abcxyz' 'xyzdef', etc. Need millions of these where I'm taking sub-arrays from each parent and concatenating them together into a new array
12:36ibdknoxcopying is definitely the overhead then :p
12:36solussdwell, the vector solution runs terribly.. looking to try a straight java-array approach
12:37ibdknoxare you using seqs? Vectors are really fast, seqs are really slow
12:37solussdwell I start with strings that are 'cast' to vecs and then back to strings… that might be part of the problem
12:37ibdknoxah
12:38ibdknoxthat could do it
12:38ibdknox,(source subs)
12:38clojurebotSource not found
12:38ibdknoxI assume that is really fast ^
12:39ibdknoxdo you really need them to be vectors? if you're just doing crossovers, it seems like that would be unnecessary
12:39TimMcsolussd: Just keep in mind that subvec and substring hold a reference to the original, preventing garbage collection.
12:40ibdknoxthat might actually be more memory efficient in the long run if all patterns are just parts of some base set
12:41ibdknoxyou'd only define that set once, assuming subvec does the smart thing
12:41solussdhmm
12:42solussdit's only the original string that isn't ever collected, i can live with that
12:43ibdknoxIt'd be easy to find out :)
12:44solussdthanks
12:46choffsteinHello everyone! This is a real, real shot in the dark -- and I know it isn't the right place to ask -- but does anyone have experience in developing a REST API for services that don't have cookie storage (and therefore can't rely on regular session authentication methods)? I could really use some resources on how to implement a secure "authentication key" system.
12:46choffsteinSecurity isn't my forte -- and so far, I am just giving each client a unique key and having them just connect over https with their unique key to identify themselves
12:47flazzis slime-repl for clojure supposed to 'use' clojure.repl?
12:47technomancy_flazz: most (all?) of the stuff in clojure.repl is obsoleted by slime functionality
12:48flazztechnomancy_: what about doc?
12:48technomancy_flazz: C-c C-d d will handle that
12:48technomancy_not obsoleted exactly... overshadowed maybe?
12:48flazztechnomancy_: omg, nice, thanks
12:48technomancy_there's a nice reference in the swank-clojure readme
12:50ldhi'm trying to use clojure.test to check existence of all elements in a collection against a set: (are [v] (my-set v) my-collection). however, 'are' wants discrete values and not an explicit collection. how can i expand my-collection to work here?
12:51technomancy_ldh: (is (every? my-set my-collection))
12:53ibdknoxldh: (is (every? my-set my-collection)
12:53ibdknoxdarn
12:53ibdknoxbeat to the punch :p
12:53ldhgreat, thanks guys
13:09rangenhi. the screencast about sequences is broken, it only shows for few seconds: http://blip.tv/clojure/clojure-sequences-740581
13:13tmciverchoffstein: I'm a http security newb myself but since you are using SSL, you could use http's Basic Authentication, I think.
13:13tmciverchoffstein: I intend to do something like this in a web app I'm working on.
13:14tmciverchoffstein: of course the problem with that is there's no good 'log out' mechanism, to my knowledge.
13:15technomancy_rangen: there's a thread on the mailing list about how to get downloadable versions of the videos from a few weeks ago
13:18choffsteintmciver: Yeah -- yeah, that's an interesting though. But I would definitely want some sort of session timeout
13:18choffsteintmciver: I'm currently in #security where I am getting lots of interesting ideas about using certs for client auth and that sort of stuff
13:19tmciverchoffstein: cool
13:20tmciverchoffstein: you'll have to let me know what you find; they won't let me in! :(
13:20choffsteinNo?
13:21tmciverYeah, I tried to join #security on freenode. says you need to be invited.
13:27TimMchaha
13:28TimMctmciver: I bet you need to register your nick first.
13:38rangentechnomancy: found it, but still no luck. that episode is borken also on itunes version
13:38technomancyrangen: might want to post on the mailing list about it then
13:38technomancyI'd be happy to get off blip.tv
13:43rangenthere was a post about this issue in september, but no replies
14:00juhu_chapaIs there a modular contrib project related to network sockets programming?
14:15ssiderishello
14:18solussdhow do you tell emacs to compile every form in a file (working in emacs/slime). I usually compile each form using c-c c-c
14:19TimMcCompile?
14:19TimMcYou mean eval in REPL?
14:38axle_512_anyone know why incanter charts would be plotted with jagged lines?
14:38ssiderissolussd: c-c c-l
14:38ssideriswhile in the relevant buffer
15:24cemerickFYI: Mostly Lazy Episode 0.0.3: Chris Granger (@ibdknox) at Clojure Conj 2011 http://wp.me/p1Y10D-M
15:25jonasenEU överväger att utvidga sin Atalanta-operation till Somalias kust, uppgav Tyskland på fredagen. För tillfället opererar EU:s antipiratstyrka i farvattnen mellan Somalia och Jemen och på Indiska oceanen.
15:26jonasensorry
15:33TimMccemerick: Nice!
15:33hugodv
15:40ibdknoxlatest Mostly Lazy Podcast submitted to HN: http://news.ycombinator.com/item?id=3409001
15:46jodarorad
15:53solussdcan I still use clojure.contrib.lazy-xml in 1.3?
16:08society__does anyone have any ideas for utilizing json-str with bson data from mongodb that contains and ObjectId key which isn't recognized by the standard implementation?
16:08Bronsacemerick: ping
16:09cemerickhi :-)
16:09Bronsain mostly lazy episode 0.0.3 the link to Noir is mistyped, should be webnoir.org, you wrote webnoir.com
16:10cemerickThanks, fixed. I always do that.
16:11Bronsagreat interviews though
16:11ibdknoxnobody wants to go there anyways ;)
16:11ibdknoxit's an evil place.
16:19cemerickibdknox: I've never understood what it is — a splash page with a tune, and that's it?
16:20ibdknoxI meant my website lol. But yeah... I have no idea
16:20ibdknoxeven weirder are some of the links off of it: http://www.webnoir.com/bob/sackson.htm
16:26mcrittendenman there's all kinds of good stuff in there. http://gog.is/site:webnoir.com
16:27ibdknoxso weird
16:36cemerickibdknox: they've gotten more traffic in the past 6 months than in the past 6 years! ;-)
16:36ibdknoxhaha
16:36ibdknoxcemerick: It's my gift to them ;)
16:54mcrittendendecent way to remove non-ascii chars from a string, anyone?
16:56jodaromcrittenden: i had a function that would tell me if a string contained non-ascii characters somewhere
16:56jodarodidn't remove them, though
16:56jodarolet me find it
16:56mcrittendenthat would definitely be helpful jodaro
16:57TimMcmcrittenden: A regex with [^[:ascii:]] or some such would do it.
16:57raekmcrittenden: perhaps you could use clojure.string/replace and a regex for non-ascii chars?
16:58raek(str/replace the-string #"[^\u0000-\u007F]" "")
16:59raek,(clojure.string/replace "abcåäö" #"[^\u0000-\u007F]" "")
16:59clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string>
16:59TimMcmcrittenden: Do you want ASCII control chars removed too?
16:59mcrittendenTimMc: yep, if possible
16:59TimMcand tab? :-)
16:59mcrittendenyep
17:00raekok, make that \u0020-\u007E
17:00jodaroall i was doing was checking to see if the character arg was in the 32-127 range
17:00mcrittendenawesome, thanks all
17:00raekascii chars 32 to 126 are printable
17:00raek127 is a control char
17:01jodarocrap, it might have gone away with a botched repl
17:01jodarosorry, right, 126
17:01raekmcrittenden: you need this to generate a URL or sometihng?
17:01TimMcmcrittenden: Writing a hex viewer? https://github.com/tmciver/hexdump/blob/master/src/hexdump/core.clj
17:01raekconsider the case where a string contains only non-ascii characters (e.g. russian)
17:01TimMcWait, you're removing them, not replacing them.
17:02raeka hex viewer should operate on bytes, not character
17:02raeks
17:02TimMc(^ not my repo)
17:02mcrittendenraek, nope, I just have a bunch of txt files with nonprintable chars and i was hoping to write a clj script to clean them up
17:03raekwhy are there "nonprintable chars" there in the first place? mixed binary and textual data?
17:04mcrittendentbh I'm not sure, seems to be maybe fancy chars like curly quotes that someone's editor screwed up at some point
17:04mcrittendenat least that's my guess
17:04jodaro tr -cd "[:print:]" < file1
17:04jodaroman tr
17:05jodarothat might be what you want
17:05TimMcmcrittenden: And your text editor is barfing?
17:06mcrittendenTimMc: nope, I'm importing these txt files into a CMS which is barfing
17:06mcrittendenjodaro that's awesome, tr is new to me.
17:07raekmcrittenden: you are probably decoding the file with the wrong charset. the best way would be to find out which encoding scheme the file uses, and read it with that
17:08raekmcrittenden: sometimes you can use the 'file' command line program to find it out
17:08TimMcOr they've been through the charset wringer and no longer have a correct charset.
17:11mcrittendengotta run, thanks again guys
17:37tscheiblread-string is damn slow in Clojurescript (except on v8... e.g. Chrome Browser)
18:39technomancyif you have written or are interested in writing a leiningen plugin, please read this proposal for a new way to handle plugins: https://groups.google.com/group/leiningen/browse_thread/thread/db4f8336f565d626
18:46technomancyalso, did anyone try out that slime-compile-presave hook I posted yesterday?
18:46technomancyI wasn't sure if it was crazy or not, but it's growing on me
18:47TimMctechnomancy: Nah, it's not hardcore enough. It should run tests too.
18:47technomancyaw yeah
18:48TimMc(Really, it should be a pre-commit-hook.)
18:48amalloytechnomancy: fyi i love slime, and i am never-ever gonna try that hook
18:48TimMcI think I would use it if it just *told* the file didn't compile, but didn't block the save.
18:49amalloyi want to save non-compiling stuff all the time
18:49technomancyTimMc: pre-commit hooks that take > 1s drive me nuts
18:49technomancyamalloy: that's what people say about paredit too
18:49amalloyyeah but they're wrong and i'm always right
18:50technomancyoh yeah; I forgot
18:50amalloyseriously though: maybe i'm trying to write something top-down for a while, using functions that don't exist yet. i can't save my thoughts because the computer can't run them yet? it's not supposed to be able to run them
18:51RaynesI agree, that hook is useless for me.
18:51technomancyturn on auto-declare? ={
18:51RaynesI save things *compulsively*.
18:51technomancy=)
18:52RaynesLike, every two words that I type ends in C-x C-s
18:52technomancyRaynes: so write better code, duh.
18:52technomancybasically it forces you to take smaller, more correct steps
18:54technomancywell anyway, it'll never be the default, but I'll probably add it as a swank payload with the defvar set to nil
18:54TimMcCan't hurt.
18:54MenTaLguYif nothing else you can always put in stubs
18:54MenTaLguYto let things compile
18:55technomancyMenTaLguY: what we need is a smalltalk-style debugger that offers to create defns that don't already exist
18:55technomancyactually ... damn.
18:55technomancywe really do
18:55MenTaLguYhmm
18:55technomancyslime already has customizable restarts, which swank-clojure doesn't use at all
18:56TimMcyay condition systems
18:56technomancy"This var wasn't found. Would you like to 0) abort, 1) refer it from another namespace or 2) add a defn in the current one?"
18:56TimMc"3) DWIM"
18:56technomancyor delegate to slamhound
18:56TimMcwhich opens http://www.reddit.com/ in your browser
18:57MenTaLguY"It looks like you're trying to reference a var. Would you like help with that?"
18:57technomancyhahaha
18:57TimMcYes! We're one step closer to vim-clippy.
18:58MenTaLguYso I've got a bit of code that I've been trying to make not ugly
18:58MenTaLguYanyone want to have a look and make suggestions for expressing it in a more lucid way?
18:58amalloy~anyone
18:58clojurebotJust 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 ..."
18:59technomancyI need to take off, but if you bring it by next Thursday I could. =)
19:00MenTaLguYnot sure if i'll make it to Seajure or not
19:00MenTaLguYbut thanks
19:00MenTaLguYthis is the bit I'm wrestling with at the moment if anyone else wants to have a look:
19:00MenTaLguYhttps://gist.github.com/1542110
19:01MenTaLguYbasically I've got a bunch of maps which describe transitions in an NFA
19:02MenTaLguYwith the :default key in the map, if present, providing a default transition
19:02amalloywell, lookup-edge is (some edges [label :default])
19:02MenTaLguYokay, that helps a bit
19:03MenTaLguYhm
19:04MenTaLguYactually it really needs to be (get edges label (edges :default)), I just realized
19:05MenTaLguYsince you can still have an explicit edge to the error state even when there's a default
19:06MenTaLguYanyway, merge-nfa-edges is the really ugly part (to me)
19:07amalloyindeed. i think you'd be happier if you threw away most of the lets, and all of the maps, and replaced them with a for
19:07amalloy(let [labels (...)] (into {} (for [[k v] labels] [k (whatever v)])))
19:09MenTaLguYhmm
19:26MenTaLguYamalloy: hm, well, this seems a bit better: https://gist.github.com/1542110
19:32amalloypersonally all the defn-s make me sad. i don't care for defn- most of the time anyway, but in particular here you're making the functions *so* small that like a third of the screen space is taken up by giving names to snall ideas
19:33amalloyand passing around arguments (eg edges-map) when you could just be using the one in the local scope if you inlined the functions
19:38MenTaLguYlookup-edge actually gets used elsewhere, so that's factored out for th sake of DRY
19:38MenTaLguYI guess I see your point about merge-nfa-targets
19:38MenTaLguYbut the indentation was getting quite deep
19:40amalloywell, you can do other things to combat that, if it bothers you
19:40amalloyeg, don't (let) the labels - inline that into the for initializer
19:41amalloytoss in some more liberal newlines, trading vertical for horizontal space
19:42amalloyhttps://gist.github.com/1542246 doesn't get very wide, for example
19:43MenTaLguYyeah, that's not too bad
19:48jodarohrm
19:48MenTaLguYso the last thing I need to do here is if all of the targets for a particular label are nil, the resulting target should be nil, and not the empty set
19:48jodaroCan't set!: *ns* from non-binding thread
19:50MenTaLguYIOW (merge-nfa-edges {\c nil, \d #{2} :default #{3}} {\c nil, :default #{4}}) => {\c nil, \d #{2}, :default #{3 4}}
20:01MenTaLguYamalloy: thoughts on this approach? https://gist.github.com/1542110
20:02amalloy(if (empty? x) nil x) is (not-empty x)
20:03MenTaLguYgreat, thanks
20:03amalloywhich means you no longer need the (let) either
20:04TimMc&(doc not-empty)
20:04lazybot⇒ "([coll]); If coll is empty, returns nil, else coll"
20:04TimMcThat's an odd one.
20:05amalloyTimMc: for when you want to (seq x) but without destroying its type
20:05amalloyie, test for emptiness
20:05TimMcsweet
20:06MenTaLguYthis kind of case, basically, I want either nil or a non-empty set
20:17MenTaLguYamalloy: all right, I think I have something I feel better about now; thank you
21:18lnostdali think i've asked about this before -- i've probably forgotten the answer .. but what's up with futures and exceptions? .. sometimes they "creep through" and sometimes they only show themselves when i deref the future
21:20technomancythey shouldn't ever escape the future thread until they're derefed
21:20TimMclnostdal: Is something printing stack traces of intermediate exceptions?
21:20lnostdalok, perhaps something is derefing them when printing the result
21:20technomancythough it could be derefed in surprising ways, like pr-str
21:21lnostdal..or when showing a printed representation of the future object
21:21lnostdalright, ok, makes sense again then
21:22lnostdal,(let [it (future (/ 42 0))] (Thread/sleep 100) it)
21:23clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.ArithmeticException: Divide by zero>
21:23lnostdalthat'll fail every time .. i.e. not racy
21:23lnostdal(..not racing with :pending status..)
21:23lnostdalthere are so many things that can go wrong .. heh
21:24lnostdal..i don't think printing should "be the same" as dereffing here
21:24lnostdal..because the proper handlers (catch blocks) aren't in place everywhere
22:14jodaroso
22:14jodarofor better or worse
22:14jodaroi have a function that uses in-ns
22:14jodarothat function gets called by something else in a future
22:14jodaroand that, apparently, doesn't work
22:15jodarogiving me an illegalstateexception
22:15jodarowith the error Can't set!: *ns* from non-binding thread
22:18technomancywow, in-ns used inside a function?
22:18amalloyjodaro: it's pretty weird to be changing what namespace you're in at runtime
22:19jodaroyeah, i figured i was doing something wacky to begin with
22:19jodaroit was working great in the unit tests
22:19jodaroits all related to protocol buffers
22:20jodarotrying to protobuf-load dynamically based on a string that has the protobuf type
22:20jodarousing like
22:20jodaro(deref (resolve (symbol protobuf-name)))
22:22jodarobut i had to in-ns to the ns where i call defprotobuf
22:25amalloyi mean, it seems like something you can do at compile-time instead of runtime. but you can easily enough just do like...(binding [*ns* whatever] (...stuff...)) instead of using in-ns
22:27emezeskehmm, is there a standard way to force non-laziness like "doseq", but to still collect the results like "for" ?
22:28emezeskeor does one just have to use (doall (for ...)) to get that behavior?
22:53chipdudetransient objects are marked alpha, but data.json uses them. is this OK because the transient doesn't escape the interface?
22:53akhudekemezeske: lookup doall
22:53jodaroamalloy: that works, thanks
22:53technomancychipdude: transients crossing API boundaries would be super-sketchy even if they weren't alpha
22:54chipdudeok
22:54chipdudethat said, my question's answer is yes?
22:55emezeskeakhudek: yeah, I saw doall; what I want is essentiall (doall (for ...))
22:55emezeskeakhudek: I just wondered if there was already a combo macro
22:55emezeskeakhudek: I just wrote my own called "dofor"
22:55akhudekyou have the solution, there is no precanned macro or function
22:56emezeskecool, that's what I wanted to know, thanks
23:26TimMctechnomancy: They *claim* to be alpha...
23:27TimMcThey've been there for two versions of clojure.core and they're recommended all over the place for performance-requiring stuff.
23:28technomancyheh; yeah I just realized promise/deliver is alpha and has been around even longer
23:35amalloyat least in 1.3 some of the alpha notifications have started going away
23:35TimMcamalloy: Which ones?
23:36amalloyjuxt is the one i know about, but there are more
23:36TimMcHaha, juxt was "alpha"?
23:37amalloyas late as 1.2.1
23:37TimMcMaybe the vec vs. lazy seq decision was alpha, but there's no way it would have been removed.
23:39emezeskeWooo, my new lein plugin for compiling ClojureScript is done! http://github.com/emezeske/lein-cljsbuild
23:41emezeskeIf you use cljs-watch or lein-clojurescript, you may want to check out lein-cljsbuild
23:50fryguywow, nailgun with VimClojure is a pain in the ass
23:55adiabatichi, I'm doing https://www.4clojure.com/problem/21 and I"ve been able to come up with (fn [coll index] ((first (drop index coll)))), but I'm getting a java.lang.ClassCastException saying that it can't cast a java.lang.Integer to a clojure.lang.IFn. My first guess is that I transposed the two arguments (I'm reimplementing nth), but everything looks OK. Can someone give me a hint as to where I messed up?
23:59amalloytoo many parens