#clojure logs

2011-08-30

00:00technomancyredinger: try clearing out ~/.emacs.d/swank; that should probably do it
00:01scgilardithey're still both .el files masquerading as .elc
00:02redingeryeah, they're still there
00:02redingeras .elc files
00:06technomancyderp; I'm not restarting Emacs in between testing it
00:08flazzgiven a list of key value pairs how can i build a map? is there a better way than reduce?
00:09scgilardiare the pairs vectors or sequential in-line '([:a 1] [:b 2]) vs. '(:a 1 :b 2)
00:09[swift]hmm.. does anyone know how you can access the window object in clojurescript? window/document works, for example, but i can't see how to call a method on the window object directly
00:11semperosflazz: ##(apply hash-map [:a 1 :b 2 :c 3])
00:11lazybot⇒ {:a 1, :c 3, :b 2}
00:11semperosthat structure?
00:11flazzscgilardi: the former, unflattened per se
00:11scgilarditry (into {} my-list-of-pairs)
00:11technomancyok, whew, now it works with a fresh emacs and a clear ~/.emacs.d/swank dir
00:11technomancyfor reals this time
00:11semperos##(into {} [ [:a 1] [:b 2] ])
00:12lazybot⇒ {:a 1, :b 2}
00:12amalloyscgilardi, flazz: that version only works if they're actually vectors, not just lists
00:12flazzi can make them vectors
00:12flazzi'm pulling the values from a java object
00:12flazzi'm really asking for the most idiomatic clojure way, reduce works great but i'm not sure on its readability
00:14flazzscgilardi: into works great
00:14redingertechnomancy: First time it compiles just fine and works, second time error cannot load slime-cdf... with no extension
00:16technomancyhm; the docstring for load-file claims that should work
00:16technomancybut it does not
00:16scgilardiflazz: great
00:17redingeryeah, adding the extension to load-file seems to fix it
00:17srid@?
00:17clojurebot@ is splicing unquote
00:18technomancywell, I gotta take off, but thanks for he help
00:18technomancywill have it sorted out tomorrow
00:18redingersure!
00:23dnolenthe ClojureScript compiler is neat.
00:50scottjdnolen: thanks for :use :only patch, I hoped someone would do that
00:55scottjjust applied it, works fine
00:56scottjbtw livereload + cljs-watch is pretty nice
01:01dnolenscottj: nice! livereload?
01:02scottjit's a ruby program + chrome extension that will monitor in this case the bootstrap.js and reload the page when it's changed
01:02scottjit does the same for html/css
01:03scottjall I had to do for configuration was tell it to ignore my.js etc and only monitor bootstrap.js
01:05scottjalso anyone who hasn't botherd to setup ctags for cljs this works --langmap=Lisp:+.clj+.cljs
01:20flazzshould the io! macro be used as close to the io as possible?
01:22amalloyit should be used anywhere you want to assert that you're not in a transaction
01:23scottjflazz: normally it's in the function that does io but not necessarily right by the io (often removed from it by let/bindings that don't do io)
01:25flazzso if i'm doing a java call that does IO i would have it in my function?
01:26scottjonly if you're using refs
01:26amalloyscottj: i don't follow that last
01:28amalloyi mean, i don't think i've ever bothered to write (io!) in my own code. but if i were writing a library that did IO via some java interop, i would be pleased if i remembered to use (io!)
01:28amalloyso that the client doesn't accidentally call my code from a transaction
01:29scottjamalloy: fair enough
01:35scgilardiI continued to work on the clojure-jack-in loader in a fork: https://github.com/scgilardi/swank-clojure/tree/1.3.x . It's working for me now. I sent a pull request to technomancy.
01:47MasseRIs (doto (.clone foo) (sumtin)) a good pattern for having an immutable interface when dealing with java objects?
01:48hiredmanthere is not substitute for reading documentation
01:48hiredmanno amount of cloning will ever give you an immutable value
01:48MasseRhiredman: True, but it reduces the risk of side-effects
01:49hiredmannope
01:52MasseRhiredman: Let's say I have some javascript object (say, a Calendar), which I bounce around different functions. On one of them, I need to call a setter, and all of the functions now get the modified object
01:52MasseRThere is no longer the original
01:53amalloyit doesn't give you any meaningful protections. (sumtin foo) can still modify both foo *and* (.clone foo). you might end up having *two* objects not= to the original foo
01:54MasseRamalloy: It hides the modifications inside the functions. Especially if the modified foo is not the value I want, but rather modifying foo, allows me to .get the value I'm interested in
01:54amalloyMasseR: you are free to do anything you want, but it does not hide any modifications
01:54MasseR(.get (doto (.clone cal) (.set Calendar/DAY_OF_MONTH 1)) Calendar/DAY_OF_WEEK)
01:54amalloyfoo can hold a reference to a mutable object
01:55amalloythen (.clone foo) can mutate the object referred to, and foo will appear different
01:55MasseRAh now I see where you're going
01:55MasseRYou're right
01:55MasseRSo, I just need to live with the mutations
01:59amalloyFWIW, i think that code would be clearer with some arrows:
01:59amalloy(-> (.clone cal) (doto (.set ...)) (.get Calendar/...))
01:59amalloybut i'm notoriously wrong about such things, so take that with a grain of salt
02:03hiredmanthere is not guarantee of how deep the copy clone creates provides
02:03hiredmanyou are just churning out useless copies of objects (garbage)
02:04hiredmanread the doccs
02:04jblomois there a string trim function that takes a set of characters instead of whitespace?
02:05MasseRBtw, way off topic, but duckduckgo is magnificent in finding java docs. You can either use a bang pattern !java to redirect to oracles search (meh) or just write "java calendar" and get a zero-click info straight from the class.
02:09amalloyjblomo: not that i know of. i'd just write one with regexes
02:09jblomo,(->> "/my/test/path/" (drop-while #{\/}) reverse (drop-while #{\/}) reverse)
02:09clojurebot(\m \y \/ \t \e ...)
02:09jblomo,(apply str (->> "/my/test/path/" (drop-while #{\/}) reverse (drop-while #{\/}) reverse))
02:09clojurebot"my/test/path"
02:10jblomoi wonder what's faster
02:10amalloynot that :P
02:12amalloyi mean, i guess i could be wrong, but you're traversing the whole string a little more than 3 times, and you're calling StringBuilder.append about a zillion times
02:13amalloywhereas a regex replace can look at the front, look at the back, and copy the middle once
02:13amalloy&(rseq "test")
02:13lazybotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Reversible
02:14amalloyreally? that is super lame
02:14jblomoyea, i think you're probably right constructing all those strings
02:14jblomolooks like clojure.string does it manually with recur
02:14jblomohttps://github.com/clojure/clojure/blob/f30995c86056959abca53d0ca35dcb9cfa73e6e6/src/clj/clojure/string.clj#L190
02:15hiredmanor you can write a reduce or a loop
02:15hiredmanI mean, regexs :/
02:15amalloyhiredman: you usually know the right answer here. is there a reason that (rseq "some-str") doesn't work? of course String doesn't implement Reversible, but anything that's Indexed and Counted should in theory be rseqable
02:15amalloy(and, yes, Strings are none of those *either*, but there's special-casing for count and nth on strings already)
02:17hiredmanI got nothing
02:17amalloyanyone excited about waiting several months for a patch/ticket to be rejected?
03:39scottjpinot remotes are awesome
03:51michaelr525hello!
03:53tsdhIs there a way to make the REPL automatically pretty-print the results of expressions?
03:54scottjtsdh: there's a thread from ~1mo ago about that
03:54tsdhscottj: Thanks, I'll look it up.
03:56hiredmanpprint does a pretty good job
03:56hiredman(repl :print pprint)
03:57hiredmanit does deref vars, which is kind of annoying
04:00tsdhhiredman: Where's the function `repl' defined?
04:01hiredmanclojure.main
04:03tsdhhiredman, scottj: I've found the thread where Phil explains how to do exactly that for leiningen projects. Thanks for the pointer!
04:25michaelr525it
04:25michaelr525err
04:36amalloyso if i write (let [xs (take n (iterate f x))] (last xs)), the compiler does the locals-clearing for me, right? i don't have to worry about hanging onto N (possibly large) elements all at once?
05:01clgvhow do I set up a local repository for my self-written libraries that leiningen can use? is it possible to do this via leiningen only (plugins)?
05:02hiredmanlein install
05:03raekclgv: you already have one :)
05:03raeksee "lein help install"
05:05clgvraek: I dont get it completely. ok there is already a local repository. but how do it get my own first leiningen project to add to it, so that my second leiningen project can use it?
05:06scottjcd project1; lein install; cd project2; add project1 to project.clj ; lein deps
05:07clgvscottj: oh thanks. I'll try that in a few
05:07scottjor cd project2; ln -s ~/project1 checkouts/project1;
05:07scottjthat way you don't have to lein install all your changes for porject 2 to see them
05:08clgvoh that sounds interesting. does the checkout approach give me access to the project without having to build a jar at all?
05:08scottjyeah
05:08scottjbtw lein install builds jar for you
05:08clgvgreat. thats even better.
05:09clgvI only supply the jar once in a while to one of my students
05:10clgvI remember a repository for java dependencies that was mentioned here - what was its URL?
05:11scottjclojars?
05:11clojurebotcontributing to clojars is a great idea! see http://groups.google.com/group/clojars-maintainers/browse_thread/thread/d4149ec96316d5b1
05:12clgvscottj: not really. there are mainly clojure jars. I meant jars of java projects.
05:13clgvmight it be jarvana.com?
05:13scottjidk
05:20clgvah maven central as default rpository in leiningen has my dependency as well^^
05:38robermanndoes exist a macro/function similar to javadoc, but working with Clojure's own code? It should point to http://clojuredocs.org/
05:50scottjnot that I know of, I use (defun jsj-clojure-example (name) (interactive "sFunction (ex. clojure.set/join): ") (browse-url (concat "http://clojuredocs.org/clojure_core/" name "#examples"))) (define-key clojure-mode-map (kbd "C-c d") 'jsj-clojure-example) in emacs
05:52Raynesrobermann, scottj: https://github.com/dakrone/cd-client
05:54robermannthank you both :)
05:54RaynesI'll add support to lazybot.
06:00robermannRaynes: cd-client does not open a new browser, right?
06:01RaynesThe browse-to function does, but the rest don't.
06:04robermannok
06:17clgvCan I tell leiningen to ignore the .gitignore file in my "classes" directory when performing "lein clean"?
06:24michaelr525clgv: i don't know about ignoring from leiningen, but maybe you shouldn't put there the gitignore file..
06:24michaelr525afair, you can ignore whole directories from the gitignore at the root directory
06:25clgvmichaelr525: but then I couldn't keep the "classes" directory in git which is annoying with eclipse ;)
06:26michaelr525you want to keep just the directory but not the files in it?
06:27clgvindeed
06:28michaelr525then you can ignore /classes/* from .gitignore
06:29clgvI can, but if there is no file in "classes" it cant be added to git ;)
06:30clgvit's a hack but there seems to be no way to tell git to create that directory since it only manages files
06:30michaelr525you can put a file there, then add two rules to .gitignore, one to ignore everything in classes and another an exception to the first rule for the dummy file
06:31clgvbut the dummy file will be delete on every "lein clean" which is the annoying thing ,)
06:31michaelr525hehe
06:32michaelr525and then the directory disappears from git?
06:33michaelr525i mean, add file -> add to git with directory -> delete file -> direcotry still in source control?
06:34clgvmost likely no
06:37clgvhumm the does using the "checkouts" directory require any special way to add the checkout to the dependencies in the project.clj?
06:39michaelr525i don't know. but regarding the previous question I just tested it and it keeps the directory.
06:39clgvyou did a a clone of he project and the directory was created?
06:39michaelr525yes
06:40michaelr525but the strange file is the deleted file was also there
06:40michaelr525hmmm
06:40michaelr525s/file/ting
06:40michaelr525s/ting/thing
06:40lazybot<michaelr525> s/file/thing
06:40michaelr525lazybot: (what)
06:41michaelr525oh cool
06:43michaelr525ah no, you were right
06:43michaelr525I didn't commit the changes
06:43michaelr525the directory disappears on clone
06:43clgvdirectories are only part of the name of the files in git afaik
06:44michaelr525ah
07:01triyo_Is there a way to compile/build a .clj file as if it where a .cljs file in ClojureScript? I have a Clojure module that fully conforms to ClojureScript.
07:04triyoMeaning if I rename my file to .cljs, it compiles.
07:06manutter1triyo: not quite sure what you mean by "compile/build as if it were a .cljs file"
07:06manutter1you mean compile it as JavaScript?
07:06triyoTo compile a cljs to js, you run (closure/build ...)
07:06triyoyup
07:07triyoso I have a module that actually can be used in Clojure and ClojureScript
07:08manutter1what operating system? If you're running Linux you might try making a symbolic link to the .clj file and give the link a .cljs suffix
07:08manutter1dunno if that would work in windows
07:08triyoHowever, to compile it in CLJS space, I have to rename the file.... I could right a script that does that automatically during cljs build process.
07:09triyoor as you say a s-link
07:09triyoWondering if this would be a common practice. Soundsa bit to hackish
07:11triyoI'm looking at the source and the .cljs extensions are hardcoded.
07:11Fossithat sucks
07:11Fossia lot
07:12RaynesMan, that was stupid. I ran 'cake killall' on my server. I just killed every website/service that I run on that thing. :|
07:12RaynesI guess it isn't running off a cake instance, thankfully.
07:12triyoRaynes: thats not to bad. Last week I ran rsync on higher level directory. ;)
07:13Raynes:)
07:15Raynes$cd clojure.core map
07:15lazybotclojure.core/sorted-map: http://clojuredocs.org/v/1494
07:15lazybotclojure.core/ns-unmap: http://clojuredocs.org/v/1577
07:15lazybotclojure.core/zipmap: http://clojuredocs.org/v/1579
07:15Raynes$examples clojure.core map
07:15lazybothttps://gist.github.com/1180686
07:16RaynesLadies and gentlement, I give you clojuredocs support in lazybot. Enjoy.
07:17pyrnice!
07:17triyovery cool
07:30robermanncool!
07:32clgv$help
07:32lazybotYou're going to need to tell me what you want help with.
07:32clgv$help cd
07:32lazybotclgv: Search clojuredocs for something.
07:33RaynesYeah, that isn't all that helpful.
07:33clgvhmm a command listing when using $help would be great ;)
07:33manutter1$help commands
07:33lazybotTopic: "commands" doesn't exist!
07:33RaynesI think there is a command that lists commands somewhere.
07:34RaynesOh, I commented it out. I think there was an issue where there were so many commands that I couldn't gist them all.
07:35clgvRaynes: could you provide a lazybot instance for #clojure.de as well?
07:35RaynesThere was an outdated partially hand-written list of commands on the wiki, but I moved the repo recently and it broke all the links.
07:36RaynesSure.
07:36Raynes$join #clojure.de
07:36lazybotRaynes: It is not the case that you don't not unhave insufficient privileges to do this.
07:36Raynes$login
07:36lazybotYou've been logged in.
07:36Raynes$join #clojure.de
07:36RaynesI'll make him autojoin there.
07:36clgvah nice. thx. :)
07:36clgvlets see what happens when I do that:
07:36clgv$login
07:36clgvhumm nothing like I guessed ;)
07:37Raynes:p
07:38RaynesHe's actually supposed to print a message saying that your credentials are incorrect, but it threw an NPE instead.
07:38manutter1Not as informative, but just as effective :)
07:38clgvlol, k. I always cause exceptions in other peoples software ;)
07:39clgvit's hobby of mine :P
07:44clgvjava.classpath still has no official release on clojars where the warn-on-reflection flag is disabled. there only SNAPSHOT versions of others which leiningen complains about when building an uberjar
07:44clgv$login
07:45Raynes$shell git pull
07:45lazybotUpdating f88166f..b36c238 Fast-forward src/lazybot/plugins/login.clj | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
07:45Raynes$reload
07:45lazybotReloaded successfully.
07:45Raynesclgv: Give that another go.
07:45clgv$login
07:45lazybotUsername and password combination/hostmask do not match.
07:45RaynesThere we go.
07:45clgv:)
08:22michaelr525hey
08:22michaelr525!
08:22michaelr525(set-face-attribute 'default nil :font "Droid Sans Mono-12" :weight 'bold)
08:22michaelr525
08:22michaelr525how to set my font to be bold by default?
08:22michaelr525the above line doesn't do it
08:27Fossii guess you should ask in #emacs or such
08:29michaelr525good idea!!!
08:36solussdwhat happened to clojure.str/as-str ?
08:36solussd*clojure.string/as-str
08:37chouserwhat does it do?
08:39solussd,(clojure.string/as-str :mykeyword)
08:39clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string>
08:39solussdshould return "mykeyword"
08:39chousersolussd: I think 'name' works for that now
08:40solussdwell, it was in clojure.contrib.string is clojure.string not the same thing?
08:40solussdok
08:40solussd,(name :blah)
08:40clojurebot"blah"
08:40solussdcool thanks
08:40chousernp
08:57clgvWhat happens if I reference multiple standalone uberjars in my clojure main project where each of these uberjars may contain a different clojure version?
09:01manutter1cljv: (cue the bit from Ghostbusters where he warns the mayor about "fire raining from the skies, cats and dogs living together" etc...)
09:02manutter1My Java skills are way rusty, but I do remember Classpath Version Hell
09:02robermannhow could I customize "lein repl" startup? For example, I'd like to execute some predefined use/require, something as http://www.learningclojure.com/2010/03/conditioning-repl.html
09:03robermanncljv: in general, the first element found in the classpath will be used
09:06michaelr525I wonder in what use case can Aleph be usefull?
09:06michaelr525Especially in the context of using it for web server/service.
09:07michaelr525https://github.com/ztellman/aleph/
09:07michaelr525I wonder
09:07michaelr525I wanda
09:07michaelr525I wonder
09:07michaelr525I wanda
09:07robermannmichaelr525: async web service client
09:08robermannthe caller is not locked in waiting the response
09:08michaelr525there is nothing new in this, that's what ajax is about
09:08michaelr525where aleph makes things simpler/advanced?
09:09clgvis there a lein plugin for packaging a jar (not uberjar) together with its dependencies other than clojure&contrib in an archive?
09:09robermannAleph seems server-side
09:10robermann(both sides)
09:11michaelr525the async server (async response) is new, but I can't think of a case where this can be usefull
09:11tomojwebsocket is an example
09:12michaelr525for websocket why and aleph async web server would be better than a regular web server?
09:12robermannI could think all use cases targeted now by JMS/Tibco
09:12tomojit might be, because this is something netty is good at
09:12tomojalso consider implementing something like the twitter streaming api
09:13michaelr525sorry, not familiar with it..
09:13tomojwell, just long-lived streaming http responses with live updates from different sources coming in
09:13tomojaleph makes that a piece of cake
09:13michaelr525oh
09:13robermannasync messaging services server 2 server
09:13michaelr525hmm
09:14tomojI don't even know how you might do it another way
09:14robermannin http
09:14robermannsuppose, for example, you want send data from your server to another server which would collect your logs
09:15robermannwhy your thread should wait the response?
09:15michaelr525it shouldn't, you create a new thread and make a request :)
09:16tomojif that works, you don't need aleph
09:16robermannbut that thread would lock the caller, in general; you could also give it to a framework an free your thread
09:16michaelr525that's why I wonder
09:17tomojif you're serving thousands of websocket connections, that won't work :)
09:17tomojs/thousands/<big number>/
09:17robermannit is the reason which lies under java io versus java nio
09:17michaelr525shit, i have to catch a train, sorry to leave in the middle of an interesting discussion, but I'll be back in half an hour or so
09:18tomojyeah, the spots where aleph is going to be useful are mostly the spots where async io would be useful
09:18robermannno problem; this discussion could be of your interest http://java.dzone.com/articles/java-nio-vs-io
09:20robermann(although that discussion is on java)
09:29st3fanis there a better solution for https://gist.github.com/1180874 ?
09:30st3fani wish i could see other people's solutions on 4clojure
09:31manutter1Depends on your definition of "better" I suppose. :)
09:31st3fanmanutter1: more elegant :)
09:31manutter1What problem number is that again?
09:31clgvst3fan: there should be a more efficient one with respect to runtime
09:31Scriptormanutter1: https://4clojure.com/problem/27
09:31Scriptorhmm, can't seem to log back into 4clojure
09:32st3fanjust wondering if i really need to special case the string one
09:32clgvst3fan: strings behave like seqs
09:32gtklockerHello clojures
09:32clgv&(reverse "blablubb")
09:32lazybot⇒ (\b \b \u \l \b \a \l \b)
09:32st3fan&(seq '(1 2 3))
09:32lazybot⇒ (1 2 3)
09:32st3fanoh!
09:33st3fanone sec :)
09:33clgv&(= "blaalb" (reverse "blaalb"))
09:33lazybot⇒ false
09:33Scriptoryea, it's easily a one liner :)
09:33clgvlol haha
09:33clgv&(= (seq "blaalb") (reverse "blaalb"))
09:33lazybot⇒ true
09:33st3fanyeah so this is nicer: https://gist.github.com/1180887
09:34Scriptorthat's what I have, although I used the shortcut syntax
09:34Scriptorfor anonymous functions
09:34st3fanright
09:34st3fan4clojure is great
09:34st3fanlearning a lot
09:35clgvif you know you have something with a given length (i.e. no lazy-seq) then you can be more efficient by iterating from front to middle and back to middle while comparing
09:35clgvthen you will only have n/2 comparisons and not n
09:36st3fansmart
09:37manutter1,(/ 5 2)
09:37clojurebot5/2
09:38manutter1$findfn [5 2] 2
09:38lazybot[clojure.core/second clojure.core/last clojure.core/count clojure.core/peek clojure.core/fnext]
09:39clgv&(quot 5 2)
09:39lazybot⇒ 2
09:40manutter1Oh yeah, that's what I was looking for :)
09:40clgv$findfn 5 2 2
09:40lazybot[clojure.core/max-key clojure.core/cond clojure.core/dosync clojure.core/sync clojure.core/char-escape-string clojure.core/with-loading-context clojure.core/*clojure-version* clojure.core/with-precision clojure.core/quot clojure.core/case clojure.core/min-key cloju... https://gist.github.com/1180907
09:41tomojwhee
09:41clgv$findfn 7 3 2
09:41lazybot[clojure.core/quot clojure.core/unchecked-divide]
09:44robermann,show logs
09:44clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: show in this context, compiling:(NO_SOURCE_PATH:0)>
09:47ohpauleezis findfn only part of sexpbot?
09:48clgvohpauleez: it is part of lazybot
09:49ohpauleezclgv: thanks
09:51mattmitchellIs there a way to view the source code of a function? I seem to remember a repl utility that allowed you to do that?
09:51coopernursemattmitchell: (source foo)
09:52mattmitchellcoopernurse: hmm, I got "unable to resolve symbol: source in this context"
09:52clgv&(source source)
09:52lazybotjava.lang.Exception: Unable to resolve symbol: source in this context
09:52clgv&(source doc)
09:52lazybotjava.lang.Exception: Unable to resolve symbol: source in this context
09:53mattmitchellcoopernurse: is that in the repl only?
09:53mattmitchellI'm in emacs using slime
09:53michaelr525back!
09:53clgvits either clojure.repl or clojure.contrib.repl-utils
09:54coopernursemattmitchell: I'm reading the docs to source, and it will only work if the .clj file is in the classpath
09:54mattmitchellcoopernurse: ok, is it clojure.contrib.repl-utils/source ?
09:54clgv&(use 'clojure.repl)
09:54lazybot⇒ nil
09:54clgv&(source source)
09:54lazybot⇒ Source not found nil
09:54clgv&(source doc)
09:54lazybot⇒ Source not found nil
09:54clgv&(source defn)
09:54lazybot⇒ Source not found nil
09:55clgvhm lazybot seems not to have access to the sources
09:55coopernurse&(doc source)
09:55lazybot⇒ "Macro ([n]); Prints the source code for the given symbol, if it can find it. This requires that the symbol resolve to a Var defined in a namespace for which the .clj is in the classpath. Example: (source filter)"
09:55mattmitchell,clojure.contrib.repl-utils/source
09:55clojurebot#<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.contrib.repl-utils, compiling:(NO_SOURCE_PATH:0)>
09:55Raynes$help source
09:55lazybotRaynes: Link to the source code of a Clojure function or macro.
09:55RaynesBut that command only works for core and contrib namespaces.
09:55coopernurseyeah, so I think it all depends on whether you have source in your classpath
09:55coopernurseI'm not sure if clojure.jar contains .clj files, or just .class files
09:56coopernurselet me look
09:56Raynes$cd clojure.repl source
09:56lazybotclojure.repl/source: http://clojuredocs.org/v/2445
09:56lazybotclojure.repl/source-fn: http://clojuredocs.org/v/2449
09:56robermanncoopernurse: contains also .cli
09:56coopernurserobermann: yeah, jar tvf shows a fair number of .clj files
10:03st3fanhm wow the web repl on http://try-clojure.org/ is awesome
10:04st3fani want to make an ipad specific version of that
10:04st3fanipad optimized
10:10coopernursest3fan: yeah, someone released a clojure repl for android. nifty, but w/o a real keyboard, not something to spend much time with imho
10:12st3fani know .. will just be nice to play around when i am bored and i just have my iphone or ipad with me
10:13st3fanhm i could do a special keyboard for the iPad with a bunch of shortcuts
10:13TimMcgiant paren buttons
10:14TimMcand other braces
10:14st3fanyeah
10:14TimMcOr with paredit mode, just the opening braces.
10:18st3fani find paredit really tricky to use
10:18st3fanspecially when you need to correct things
10:18TimMcIt took a little getting used to.
10:18TimMcKeep the cheatsheet handy.
10:18st3fanbut i probably simply don't know the right commands
10:24robermannis it possible to customize "lein repl" with an auto-load script?
10:25clgvsee :repl-init at https://github.com/technomancy/leiningen/blob/stable/sample.project.clj#L102
10:29ddwwkI'm having issues with clojure.java.shell. (sh "wget" "https://example.com/50meg.mp3&quot;) hangs
10:29ddwwkwhere example.com is not real
10:30ddwwksomethings work, but large files aren't working. And I've read around somewhere that the io can be glitchy with shell, but I can't figure out a workaround
10:30robermannclgv: it seems to work when using "lein interactive" (because requires a project.clj) and not "lein repl"? I mean, in order to use :repl-init I need a project.clj in the current dir?
10:34clgvrobermann: right, :repl-init is for projects. I don't know if there are other configuration options for "lein repl" outside of projects.
10:36pjstadigddwwk: could you not just use an HTTP client to get the file?
10:38ddwwkpjstadig: I'd like to, but I had to use a patched version of clj-http that supports cookies (for authentication), and after a looong time of testing I still couldn't figure out how to get the cookies to work.
10:38ddwwkactually, the clj-http was returning 'ssl failed with peer" or something like that
10:40ddwwkso I might have needed to make clj-http ignore ssl mismatches, but wget seemed to be the solution of least drag.. because I was able to export the cookies from cookies from selenium in such a way as to allow wget to actually succeed from the command line
10:41ddwwkclj-webdriver has been kicking a$$
10:41robermannclgv: mmm after googling a bit it seems that just having a user.clj in the classpath should solve my needs
10:41ddwwkif only it had a headless "get" command, it'd kick more
10:41clgvrobermann: ah interesting
11:11okidowuhelp wanted on running clojure in NB 6.91. Downloaded and installed plug-in. problem with maven build/compile
11:11pjstadigddwwk: you could also try a Java http client...it sounds like shelling out isn't going to work reliably
11:11ddwwkpjstadig: I may have to do that. like use common's http client directly
11:14okidowuHi, has any one used NB clojure
11:15coopernurseokidowu: no, but do use intellij
11:16okidowuNeed a free IDE
11:18coopernurseokidowu: intellij community edition is free, and works with la clojure
11:18TimMcokidowu: emacs
11:18clgvokidowu: eclipse and CCW are free
11:19coopernurseokidowu: install screencast here for intellij/clojure: http://www.screenr.com/PEMs
11:20okidowuok will try. thanks
11:24dnolenambrosebs is on a roll, https://github.com/frenchy64/Logic-Starter/blob/master/src/logic_introduction/numbers.clj
11:25ambrosebsdnolen: starting to get the hang of reading prolog :)
11:26ambrosebsone thing that struck me is the declarative docstring
11:27ambrosebscommunicates the role of the function perfectly
11:29dnolenambrosebs: very cool.
11:31dnolenspeaking of which, one big hurdle I'd like to cross with core.logic is environment trimming / runtime groundness analysis. Would really bring us within striking distance of SWI-Prolog perf on many more benchmarks. would also make core.logic efficient for parsing.
11:33ambrosebsdnolen: what do you mean by parsing?
11:34dnolenProlog has definite clause grammars, so it's ideal for parsing and it doesn't have the lexing/parsing distinction.
11:35ambrosebs*opens prolog book*
11:37pdk[11:33] <ambrosebs> dnolen: what do you mean by parsing?
11:37pdkparsing in general or
11:38ddwwkso one could build languages?
11:39ambrosebspdk: parsing definitive clause grammars .. I think
11:45ambrosebs"A very important application area of Prolog is parsing. In fact, Prolog originated from attempts to use logic to express grammar rules and to formalize the process of parsing"
11:57ddwwkso I am looking over the clj-http tests and I see the headers expressed in this way: {:headers {"Accept-Encoding" "identity, gzip"}}
11:57ddwwkand {:headers {"Accept" "application/json"}}
11:58ddwwkso, I'm wondering if something like this would work: {:headers {"Cookies" "name=value; name2=value2"}}
12:00TimMcddwwk: How long would those cookies last, and what domain are they attached to?
12:02ddwwkTimMc: not long. I'm using them in conjunction with clj-webdriver (selenium) that crawls a Remedy work ticket web interface. Trying to automate the downloading of documents.
12:04ddwwkit looks like Accept and Accept-Encoding are hardcoded into clj-http
12:04ddwwkin case statements
12:05ddwwkcan't tell yet if random other headers are merged in
12:05insideouton that topic, does anyone know what is the best fork of clj-http?
12:06ddwwkI'm looking at: https://github.com/vitalyper/clj-http/blob/master/src/clj_http/client.clj
12:06ddwwkwhich seems fairly recent, with some tweaks
12:06ddwwkbrb
12:11insideoutddwwk: it see wrap-accept and wrap-accept-encoding. is that what you mean?
12:18dnolenambrosebs: using Prolog for parsing is pretty sweet. Again, the beautiful part is that you don't need a separate lexing step.
12:20ambrosebsdnolen: so is it just perf that stops us doing similar things in minikanren?
12:20ambrosebsor is there something tied to prolog?
12:20dnolenambrosebs: DCG stuff is already there. But it's not efficient because of the lack of groundness analysis and lack of environment trimming.
12:22ambrosebsright, I'm guessing other minikanren implementations do this?
12:22edwIs there an HTTP *client* out there that will return a ring-style response?
12:22dnolenambrosebs: they do not.
12:22ambrosebsah :)
12:23dnolenambrosebs: it's a problem with miniKanren's design that I'd like to solve.
12:23dnolenambrosebs: it's not a big deal for many logic programs. But for parsing where you're looking at every single character, you do not want to unify and grow your substitution map for each char.
12:26ambrosebsdnolen: interesting
12:27dnolenambrosebs: I did a bunch of work on it, but I didn't arrive at a satisfactory solution.
12:28ambrosebsdnolen: good to hear
12:29ambrosebsI think it's about time I studied the minikanren implementation
12:29ambrosebshaven't read most of Byrd's dissertation yet
12:30dnolenambrosebs: it's pretty cool. I would look at the Scheme miniKanren implementation since it's a lot less code to look at ~200 lines. my implementation is hardly any different - just longer because of perf reasons and because Clojure terms are not just lists.
12:31ambrosebs200? sheesh
12:31dnolenambrosebs: yeah it's pretty amazing.
12:57ddwwkback
13:00ddwwkinsideout: yea, I don't see an extra "wrap-any-other-headers"
13:02ddwwkthis version has cookie support: https://github.com/r0man/clj-http/tree/cookies
13:03ddwwkbut I was getting ssl errors, so I am still not sure whether I was feeding it cookies in the correct format.
13:04TimMcddwwk: What I meant was, that isn't enough information for cookies.
13:05ddwwkTimMc: ah.. yes.. as I've been investigating it though, I believe the other information associated with cookies are held by the browser.
13:05ddwwkwhen we send a get request that has cookies associated with it, at least for wget, it only wants the name value pairs, and not the expiration date, the domain, etc.
13:06ddwwkwithin the http header of the get request
13:06TimMcAh, I suppose there's a difference between setting a new cookie (which needs that info) and updating the value of an existing one.
13:06ddwwkin the browser state, however, it'll have more thorough informatino
13:06ddwwkright
13:06ddwwkI think when the server sets the cookie, it sends all the information
13:07TimMcStill, the first time you set it, you need all that stuff.
13:07ddwwkTimMc: yea, and selenium has all that stuff because it is automating a real instance of the browser.
13:08ddwwkso I wonder, does clj-http (cookie version) want only the cookies as described in a get header, or the full cookies, as would be managed by a client.
13:09ddwwkand then apache.commons http client would have to know what to do with the full cookie objects when creating the get
13:24ddwwkthis might work: https://github.com/mamciek/clj-http/blob/fc1033c48ba917b48c8bd1a8eaef4bef6152536d/src/clj_http/core.clj
13:33ddwwkThis is good too: https://github.com/mattrepl/clj-apache-http/tree/5f7c156c557bd5c97d5b03da406d8ac6bfbfad37
13:33ddwwkcommenting here for later reference
13:52amalloyst3fan: what paredit is *especially* good at is correcting things. if you find it harder to do with paredit than without, you're missing out on some cool commands
13:54ibdknoxdnolen: when did cljs get :use?
13:55dnolenibdknox: I submitted a patch (not worked in yet), you'll see the problem even if you switch to require.
13:55dnolenibdknox: http://dev.clojure.org/jira/browse/CLJS-65
13:55ibdknoxdnolen: awesome
13:57ibdknoxdnolen: k, I'll look into it. I wonder if I have to clean the output directory.. :/
13:59dnolenibdknox: yeah the :use :only thing is nice. hopefully the patch is up to snuff. ClojureScript compiler is not scary.
13:59scottjdnolen: :use :only works with cljs-watch for me with pinot, but not with my own namespaces
13:59ibdknoxout of curiosity
13:59dnolenscottj: can you elaborate your issue on that ticket ?
14:00ibdknoxhave either of you tried compiling from the repl?
14:00scottjdnolen: where are you getting the warning and error, my cljs-watch does't look like that?
14:00ibdknoxI suspect this is a compiler level issue
14:00scottjibdknox: nope
14:01dnolenibdknox: that's what I was doing before. in fact when working on :use :only cljs-watch wasn't working for me, so switch to compiling from REPL
14:01dnolenscottj: sorry I confused, I thought you were saying the patch didn't work on your own namespaces ?
14:02ibdknoxdnolen: hmm, well the only thing I'm doing is calling cljs.closure/build
14:02scottjdnolen: at least in cljs-watch, yes, I haven't tried outside that. I was wondering if the output in issue you posted was actually from cljs-watch, since I don't get that maybe I'm behind
14:03ibdknoxscottj: that's a compiler error
14:03ibdknoxscottj: you only get that when the javascript engine chokes
14:03dnolenibdknox: yeah it's not clear to me what's going on, cljs-watch chokes, compiling at REPL works. I admit I didn't look really closely.
14:04ibdknoxdnolen: no worries :)
14:07ibdknoxweird
14:08ibdknoxdoing require works for me
14:08ibdknoxwith cljs-watch
14:09dnolenscottj: ibdknox: stuff to look into :) I wasn't sure I got my patch 100% and this good stuff to know.
14:09scottjibdknox: do you think not having access to request will be a problem with remotes? I think with json you can return cookies, with remotes you'd have to do it in js instead of http I think
14:10scottjibdknox: you mean requireing and using the same thing works? I tried that without success
14:10ibdknoxscottj: do you have dnolen's patch for use?
14:10scottjyeah
14:10scottjI'm using it with pinot namespaces fine
14:10ibdknoxI haven't tried it with that yet
14:10ibdknoxwithout it
14:10ibdknoxcljs is working
14:10ibdknoxerr
14:10ibdknoxcljs-watch
14:10scottjok, I see
14:11ibdknoxit may have nothing to do with that, though :)
14:11scottjone advantage of :use :only is it makes ctags work better
14:12scottjif you have ph/html you can't M-. to go to the definition, but with use only you'll have html and then M-. works
14:13ibdknoxok
14:13ibdknoxyeah, I confirmed that it worked with the latest cljs
14:13ibdknoxand multiple local files
14:13ibdknoxtried it with 3 local ns's
14:13ibdknoxnow trying from scratch, just to make sure
14:15scottjibdknox: btw I still have .#foo.cljs problems
14:15scottjmy file had unsaved changes in emacs, Building ClojureScript files in :: srcjava.io.FileNotFoundException: The file src/emailatask/cljs/.#frontend.cljs does not exist.
14:16scottjibdknox: just updates cljs-watch, still have problem. Are you just using or actually calling the functions after using them?
14:18ibdknoxI just put that file in my directory
14:18ibdknox.#frontend.cljs
14:18ibdknoxit doesn't pick it up
14:18ibdknoxscottj: did you put cljs-watch on your path?
14:19mattmitchellhow do you get the highest int value out of a list?
14:19ibdknoxm(doc max)
14:19ibdknox,(doc max)
14:19clojurebot"([x] [x y] [x y & more]); Returns the greatest of the nums."
14:19mattmitchelldoh! max :)
14:19mattmitchellthanks
14:19ibdknox,(apply max [1 2 3])
14:19clojurebot3
14:20amalloy&(apply min-key - [1 2 3]) ;; if you want people to hate you
14:20lazybot⇒ 3
14:20ibdknoxlol
14:21ibdknox:-p
14:22amalloy&(last (sort [1 2 3])) ;; if you want to leave in some slow bits to magically improve later?
14:22lazybot⇒ 3
14:22ibdknoxscottj: because if you did, you'll have to copy that file over every time you pull
14:22ibdknoxamalloy: gotta get that job security ;)
14:24ibdknoxdnolen: I'll try your patch tonight, but I'm fairly confident a base install of clojurescript and cljs-watch are working ok with local requires
14:24scottjibdknox: my path includes ~/src/cljs-watch which is the repo, copy where?
14:25ibdknoxscottj: k, a lot of people simply copy the script into something already on their path
14:25scottjif I touch .\#foo.cljs realfile.cljs then I get a NPE probably bc .\#foo.cljs doesn't have namespace
14:26scottjwhere in cljs are you blocking . files?
14:26scottjoh ext-filter
14:26ibdknoxhttps://github.com/ibdknox/cljs-watch/blob/master/cljs-watch#L53
14:27ibdknoxscottj: the only way I can see that failing is if your system isn't reporting the correct name
14:30scottjibdknox: it's some kind of link, I don't know about this stuff. lrwxrwxrwx 1 scott scott 27 2011-08-30 14:28 .#frontend.cljs -> scott@mamey.8204:1314574098
14:30scottjit doesn't .exists or .isFile in java
14:31furdI'm having a really confusing issue where I have two functions that do the same thing.
14:31ibdknoxscottj: wait... it doesn't pass .isFile?
14:32scottjit's kind of a good warning that I haven't saved :)
14:32furdOne of them dramatically faster than the other.
14:32ibdknoxscottj: because that line also checks for that too
14:32furdBut when I use the faster version of the function in another function, the results I get are much, much slower when compared to the.. slower function?
14:32ibdknoxfurd: are you using lazy-seqs?
14:32furdI put up a https://gist.github.com/1181618
14:33rindolfHi all. Is the best way to work on clojure code be using Counterclockwise+Eclipse, or do people here use vim/etc.?
14:33furdIt's being passed a lazy-seq in the form of a range
14:34ibdknoxrindolf: I think emacs is the most prevalent here
14:34technomancyrindolf: usually the best way is whatever you're already most comfortable with
14:34scottjibdknox: are you manually editing cljs-watch and the .clj file
14:34ibdknoxrindolf: I use vim most of the time though
14:34rindolfibdknox: ah, OK.
14:34ibdknoxscottj: sadly, yes
14:35ibdknoxibdknox: once I move it into clojurescript, I won't have to have the file embedded
14:35ibdknoxlol
14:35ibdknoxtalking to myself again
14:40sridOuroboros
14:40scottjibdknox: does cljs-watch filtering only effect what files it watches not what files cljs compiles?
14:42ibdknoxscottj: correct
14:42amalloytechnomancy: well, i learned emacs for clojure and i'm glad i did. but it's reasonable to stick with what you know for a while so that it's less overwhelming
14:42ibdknoxscottj: your issue is probably with the compiler itself
14:43scottjibdknox: yeah I think so
14:44furdI don't understand why the function that is so much slower in isolation would provide results so much faster when given a range vs the other, faster sum-divisors function, am I missing something huge and life altering?
14:45ibdknoxscottj: btw, in response to the remotes thing, you should be able to set cookies like you normally would in noir inside of a remote
14:46ibdknoxfurd: I would continue to simplify your case
14:46scottjibdknox: oh I'm not using noir, do you put your cookies on the ring response map?
14:46ibdknoxscottj: later down the line, yes
14:46scottjibdknox: that's another thing, remotes worked great with compojure w/o noir I hope that's able to continue
14:46dnolenibdknox: yeah, not certain what's up, was pretty sure I tested several times w/o my patch. If I run into the issue again I will elaborate the exact steps to reproduce.
14:47scottjibdknox: if you return a map from a remote it's not treated as a ring response map is it?
14:47ibdknoxscottj: I probably won't go out my way to do that, no, since the point is to provide an end to end solution
14:47scottjibdknox: btw it was cool how remotes are just functions and you can call them on the clojure side too
14:48ibdknoxdnolen: okidoke, let me know :)
14:48scottjwhat's pinotid for?
14:49ibdknoxscottj: events primarily
14:51scottjibdknox: have you used advanced mode? I did run into a problem where some code worked fine in normal mode but the event type got removed in advanced mode I suspected because the compiler just saw :submit not the event name EventType/SUBMIT or whatever it is
14:53ibdknoxscottj: I haven't messed with advanced much yet, since it takes so much longer to compile. Those issues should be pretty easy to fix though.
14:53ibdknoxscottj: I actually do lookup EventType/*
14:53scottjibdknox: maybe at runtime not compile time
14:55scottjibdknox: also, a plain ajax helper function would be a nice additon to pinot
14:56simardI'm trying to run the mandlebrot example that uses penumbra, but I'm getting an error when evaluating (ns example.gpgpu.mandelbrot ...) with slime after a few seconds: org.lwjgl.DefaultSysImplementation.getPointerSize()I [Thrown class java.lang.UnsatisfiedLinkError]
14:57amalloysimard: missing a native library, i guess?
14:57simardI can see a few INFO lines from the "lein swank" server before this happens, saying PM penumbra.Natives extractNativeLibs
14:57simardI did run lein deps and lein native-deps before, but I guess I'm still missing something
14:58technomancysupposedly penumbra sidesteps the whole native-deps stage now
14:58technomancyit handles all the native code internally
15:00furdibdknox: Okay, I went to a more simple case of filtering a range using the predicate to remove other factors but I still can't see how this is possible: https://gist.github.com/1181618
15:03amalloyfurd: for example, A could be faster at small numbers while B is faster at large numbers
15:03amalloyfor your particular functions i don't know if that's the case, but it's easily possible
15:04amalloybut also your most recent gist times sum-divisors the first time, and abundantlist the second, so you can't draw any strong correlations between the two input sizes
15:06ibdknoxscottj: yeah I'll get to adding those sorts of things eventually :)
15:06furdamalloy: A is faster until about 5, and then B becomes faster and faster as time goes on
15:07furdamalloy: Timing the two different functions was to see sum-divisors in isolation vs a function that uses sum-divisors
15:08furdamalloy: when using filter on a range it should be just like using the function on one number, just over and over right?
15:10ddwwkit would be cool to edit cljs from http://www.ymacs.org/demo/
15:21furdHmm so I printed out the times for individual numbers in a range and yeah, it seems that specific numbers are much faster with B than A and some numbers are much faster with A than B. Fun.
15:21furdThanks for the help, sorry for the newbie ridiculousness.
15:23simarddo I need to install/load SLIME before M-x clojure-jack-in ? and where should I run that command from anyway, core.clj ?
15:23simard(should I actually unload/uninstall SLIME before trying M-x clojure-jack-in ?)
15:23hiredmanjust run clojure-jack-in
15:25amalloyfurd: i just noticed (let [sum (reduce * ...)]). is that really what you meant? it seems so implausible that you can get a meaningful sum by multiplying a bunch of numbers
15:25simardif I C-x C-e I get: Symbol's function definition is void: lisp-eval-last-sexp
15:25hiredmanwhat version of emacs?
15:26simard23.3.1
15:26hiredmanwait
15:26hiredmanC-x C-e what?
15:26furdamalloy: Its a method of getting the sum of all the divisors of a number by finding the prime factors and multiplying them together
15:26hiredmannew to emacs?
15:26hiredmanM-x clojure-jack-in
15:26simardhiredman: C-x C-e anything from a Clojure buffer
15:26simardsay.. a string
15:26simardor a number, or anything
15:27hiredmandid you run clojure-jack-in?
15:27simardyes :)
15:27hiredmanand what happened?
15:27simardI do have that *swank* buffer, that says a server is listening on port 63217
15:27furdamalloy: http://planetmath.org/encyclopedia/FormulaForSumOfDivisors.html has a breakdown of the algorithm
15:27hiredmando you have a slime buffer?
15:28amalloyfurd: the prime factors of 10 are 5 and 2, which multiply to 10. the sum of the divisors of 10 is 5+2+1=8, right?
15:28simardno, not right now
15:28simardthe core.clj only has the Clojure mode on
15:28hiredmanso for some reason it failed to conenct
15:28hiredmanM-x slime-connect
15:28simardhum prolly my .emacs then
15:28hiredmanlocalhost
15:28hiredman63217
15:28simardyeah it works
15:29amalloyfurd: thanks for the link, looks interesting
15:29furdamalloy: You take the exponents of the primes, increase it by one, subtract one from that total and divide it by the prime - 1
15:29simardisn't clojure-jack-in supposed to do that though ?
15:29hiredmanyes
15:29hiredmanbut it failed for some reason
15:29simardok, I'll clean up my .emacs a little
15:29simardperhaps some slime configuration there that's messing with clojure-mode
15:30furdamalloy: It works a bit quicker than simply getting the divisors in a lot of cases as it turns out but I'm still not well versed in clojure enough for my implementation to seem very clean
15:34Somelauw#python-forum
15:40amalloyfurd: i made it a little more readable, i think, at https://gist.github.com/1181797 - i don't understand what the (if) test is for, or i think it could be made nicer
15:44furdamalloy: Awesome, thanks!
15:45furdamalloy: The if statement was because I needed the sum of "proper" divisors
15:45furdamalloy: And that algorithm includes the number itself in the count of divisors which ins't proper
15:46amalloyso just subtract the number itself at the end?
15:46furdamalloy: So I had it remove the number from the total, unless it was 1 (in the case of primes)
15:46furdamalloy: Maybe I should have it just do a prime check at the start instead, I'll compare the speed difference
15:46amalloyfurd: sorry, i meant the first if
15:46amalloythe one inside the map/for
15:47furdamalloy: Oooh
15:47furdamalloy: Just another section of that algorithm that isn't listed on that site. If the prime only has one occurrence in the list of prime factors
15:47furdamalloy: You can get the number by adding one to the number instead of doing the other calculations
15:48furdamalloy: I'm really terrible at knowing what would be faster/slower so if actually doing that check is slower than just computing it every time that could be removed I suppose as it still gets you the same result
15:49amalloyno, it's got to be faster with the test
15:49PiskettiParedit is driving me crazy. Is there really not a way to delete (move) a single paren without disabling paredit? Help!
15:50amalloyPisketti: stop trying to delete/move parens, and use the paredit commands for sexp editing
15:50hiredmanPisketti: why would you do that?
15:50amalloywhat form do you have now, and what do you want?
15:50PiskettiSometimes it's easier to move a single paren than some big chunk of stuff inside the parens
15:50amalloyPisketti: that's only true if you don't know how to do things with paredit
15:50hiredmanM-s or M-r
15:51Piskettithat's probably very true
15:51dnolenPisketti: select the paren and cut it out. but there commands for moving the left/right paren
15:51amalloyPisketti: so if you believe it's true, then learn how to use paredit instead of looking for escape hatches to do stuff the hard way
15:53amalloy(which is why i prposed you tell us what you have and what you wish you had: then you can learn the right way)
15:53Piskettiamalloy: Ok. I'll do that. Do you have any tips for where to look for enlightenment? :)
15:53amalloyyes, in #clojure or #emacs or #lisp or http://www.emacswiki.org/emacs/PareditCheatsheet
15:54PiskettiWell, one specific example. I have a list and I want to remove the parens altogether. How do I proceed?
15:54amalloylike hiredman said, M-r
15:54amalloyer, M-s
15:55Piskettiokay, I missed that. Thanks both of you.
15:58NetpilgrimPisketti: I'm also in the process of learning to use paredit. It's great but doesn't work in slime-repl without some rebinding of keys (e.g. M-s).
16:00PiskettiNetpilgrim: You've overcome the moments when you just want to turn it off?-)
16:03rata_hi
16:03NetpilgrimPisketti: I have turned it off before in the repl because I was to lazy to rebind the keys. But I already don't know how I ever edited clojure source buffers without it. You basically don't have to think about parens at all anymore.
16:03rata_Netpilgrim: rainbow-parens? paredit?
16:04Netpilgrimrata_: paredit; what's rainbow-parens?
16:04rata_you must see it
16:04Netpilgrimrata_: O wait, I think I've seen it somewhere. It colors corresponding parens, right?
16:05rata_yes
16:06rata_I love it... clojure code seems a little bit plain otherwise
16:06PiskettiNetpilgrim: I'm sure paredit is great once you learn to use it. Currently my biggest problem is ignorance.
16:07Netpilgrimrata_: Perhaps I'll give it a try but I think it might be too intrusive – too much color for things I don't really have to see with automatic indentation and paredit keeping everything in order.
16:07rata_Netpilgrim: you see them less actually
16:07rata_because colors have been rightly chosen
16:08rata_or maybe I'm just used to it
16:08NetpilgrimPisketti: Just keep the cheat sheet handy and look commands up when you need them. Probably the same way you have learned to use emacs, at least I have.
16:09duck1123There's always C-h m as well
16:10PiskettiNetpilgrim: Yeah. Fortunately learning paredit is only a minor annoyance compared to the learning curve of emacs
16:12NetpilgrimPisketti: O just think how much fun it is to learn something new. That's why I changed from vim to emacs – just seeing how other people live. (And I liked it.)
16:13Netpilgrimrata_: Do you use rainbow-delimiters.el?
16:14PiskettiNetpilgrim: The fun of learning something new was the main reason I got into Clojure in the first place.
16:14amalloyPisketti: it's a trap! now you have to learn five more new things!
16:15PiskettiI knew it!
16:15rata_Netpilgrim: no, rainbow-parens.el
16:16PiskettiThe whole lisp experience has been the most eye opening experience for a long time
16:17NetpilgrimPisketti: Yeah, there are parallels for me between working with vim and trying out emacs, and working with Java and trying out Clojure. Just the thought that there is a way to do something familiar in a very different way.
16:18PiskettiI'd love to work with Clojure instead of Java. Someday maybe.
16:20NetpilgrimDoes anybody else have the urge to improve on your own sentences after the first draft like sourcecode? (second draft: “a very different way to do something familiar”) :)
16:24NetpilgrimSpeaking of improving. I have a working solution for 4clojure problem 43 (http://4clojure.com/problem/43) here: https://gist.github.com/1181919 But there must be way to do it without the ugly loop, or isn't there?
16:25Netpilgrim4clojure is great by the way!
16:33amalloyNetpilgrim: there's always a way :)
16:34amalloymy first solution was something like (for [offset (range n)] (take-nth n (drop n coll)))
16:34amalloy&(let [coll (range 1 10), n 3] (for [offset (range n)] (take-nth n (drop offset coll))))
16:34lazybot⇒ ((1 4 7) (2 5 8) (3 6 9))
16:35amalloybut someone tweeted a much nicer solution: ##(let [coll (range 1 10), n 3] (apply map list (partition n coll)))
16:35lazybot⇒ ((1 4 7) (2 5 8) (3 6 9))
16:37Netpilgrimamalloy: Now, those two look more pleasing than what I've written. And I have to study clojure.core, I did know neither take-nth nor partition.
16:37amalloy<3 partition
16:38amalloyNetpilgrim: see also ##(doc split-at), which would improve your existing solution a little
16:38lazybot⇒ "([n coll]); Returns a vector of [(take n coll) (drop n coll)]"
16:38Netpilgrimamalloy: Basically partition does exactly what my loop was for.
16:39Netpilgrimamalloy: O, so many useful functions. :)
16:39amalloyNetpilgrim: it will do a lot more, if you ask nicely
16:39amalloy&(partition 2 1 (range 5))
16:39lazybot⇒ ((0 1) (1 2) (2 3) (3 4))
16:40Netpilgrimamalloy: Hm, looking at your last example, I think I've actually used partition in one of the earlier problems to find identical neighbors in a seq. I must have forgotten about it.
16:42Netpilgrimamalloy: No, I did something like (map coll (rest coll) ...) there.
16:42amalloy&(doc partition-by)
16:42lazybot⇒ "([f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of partitions."
16:42amalloy&(partition-by identity '(a b b c a a d))
16:42lazybot⇒ ((a) (b b) (c) (a a) (d))
16:44Netpilgrimamalloy: This is just great. Now i want to go back and redo all my solutions to the 4clojure problems. :)
16:44amalloyyou should! it's good for you
16:45simardI have a fresh install of emacs24, a clean .emacs, added marmalade to package list, installed clojure-mode, make sure I had "lein upgrade" and "lein plugin install swank-clojure 1.3.2", and then from a project did M-x clojure-jack-in : the server starts in the *swank* buffer, but there's nothing connecting anywhere
16:45simardnote that I don't have slime anymore, but it seems clojure-mode has it bootstrapped
16:45simard(hence I cannot do M-x slime-connect now)
16:45simardwhat went wrong ?
16:47amalloyNetpilgrim: that said, (map f coll (rest coll)) is a nice little idiom i always forget to use because i love partition so much. eg, (map + coll (rest coll)) is nicer than (map (partial apply +) (partition 2 1 coll))
16:47amalloybut i'm sure i'd write the latter
16:49st3fanwhat is marmalade?
16:50amalloy$dict marmalade
16:50lazybotamalloy: noun: A clear, jellylike preserve made from the pulp and rind of fruits, especially citrus fruits.
16:50amalloy(rimshot)
16:50NetpilgrimBTW: Is there a collection of design patterns for functional programming somewhere? (Surely, there must be.)
16:50st3fanNetpilgrim: funny, i was just thinking, hey i can do a lot of 4clojure problems much better with those tricks
16:50st3fanwell they are not really tricks, ust good usage of the lib
16:50amalloyst3fan: it's like elpa. pre-packaged elisp
16:51technomancyspreadable elisp
16:51st3fani shall look into it :)
16:51technomancyit's basically clojars for elisp
16:51amalloyNetpilgrim: if you search for "functionap programming design patterns", you'll mostly find people saying stuff like "design patterns are an indication your language is not powerful enough to *actually* abstract things for you; patterns in functional programming are just functions"
16:52amalloyi don't think they're 100% right there, but they're not crazy either. who needs the Visitor pattern when you have map and reduce?
16:53simardso this should have been working out of the box right..
16:54Netpilgrimamalloy: Perhaps I'm still too new to the language to easily see how to approach typical problems
16:55Netpilgrimamalloy: On the other hand there are things like using mutual recursion with trampoline to implement a finite state machine (just read about it in JoC) which I think is a fantastic pattern, but perhaps that's too specific.
16:57rata_do you know which characters are printed as _ by the repl aside the underscore?
16:58hiredmannone
16:58Netpilgrimrata_: In emacs it might be a non-breaking space, usually in a different color though.
16:59rata_it doesn't have a different color
16:59rata_do you know how to delete/catch them?
17:00hiredmanis this clojure or clojurescript?
17:00rata_clojure
17:01Netpilgrimrata_: Where does this character come from?
17:01hiredmanare you good for unicode across the board?
17:03rata_hiredman: no
17:03rata_Netpilgrim: it comes from a html
17:04rata_I was wrong, it wasn't the repl, it was emacs as Netpilgrim said
17:04rata_in the repl it is printed as a space
17:04rata_I'm using enlive
17:04rata_to do screenscraping
17:05rata_how can I replace those non-breaking spaces by simple spaces?
17:06Netpilgrimrata_: Why would you want to? They are usually there for a reason. Otherwise just do some search and replace. (I don't know how to do it in Clojure.)
17:07rata_Netpilgrim: I want that because #"\s" doesn't catch it and I need it to do so
17:08NetpilgrimWhy don't you just include it – [\s ] instead of \s?
17:09Netpilgrimrata_: Perhaps you could even redefine \s.
17:10rata_Netpilgrim: because [\s ] wouldn't catch it either
17:10amalloyi seriously doubt you could redefine \s
17:11Netpilgrimrata_: Why wouldn't [\s ] catch it? The space in there is of course the non-breaking space.
17:11rata_how do you write the non-breaking space?
17:12Netpilgrimrata_: Just use [\s\u00a0].
17:12rata_Netpilgrim: oh thanks! =)
17:13rata_and do you know how to redefine \s?
17:13Netpilgrimrata_: No problem. I love the non-breaking space and use it all the time.
17:14Netpilgrimrata_: No. And how amalloy said (who has way more knowledge about this than I do) it's probably not possible.
17:14rata_ok
17:15Netpilgrimrata_: I guess \s is hardcoded somewhere in the implementation of java.util.regex.Pattern.
17:17Netpilgrimrata_: But in generell
17:17Netpilgrimrata_: But in general the non-breaking space can be a bit of a problem because it's not seen in the source code (except in emacs and perhaps some other editors).
17:18Netpilgrimrata_: A few weeks ago I broke an application at work because I added some non-breaking spaces in an XML config file and the parser choked. :)
17:19rata_hahahaha
17:19Netpilgrimrata_: The diffs were a bit problematic because apparently there were no differences.
17:20rata_yes, it's a hatable char
17:20rata_*hate-able?
17:23Netpilgrimrata_: Thinking about it, I can understand why it’s not included in the whitespace characters. Whitespace by it’s very definition denotes a place where you can break text.
17:25Netpilgrimrata_: Which raises the question if you are correct in including the character in your pattern.
17:25rata_I want to remove them as my regex doesn't work well in some cases
17:25Netpilgrimrata_: What’s the regex supposed to do?
17:28rata_take some info from some <p>...</p> in the html
17:29Netpilgrimrata_: You want to match what's between the tags?
17:29rata_no
17:29rata_I use enlive to extract the text
17:35Netpilgrimrata_: Enlive looks interesting. Does it work with sloppy HTML 4, or does it need well-formed XHTML?
17:36rata_it works with sloppy html 4
17:36rata_afaik
17:37raekit uses tagsoup, so it even understands 90's street html
17:38Netpilgrimraek: Street HTML is a nice description for what I've seen in the 90's (and later).
17:42wwmorganWhat is the library or contrib function that takes a predicate and a collection and returns [(filter p coll) (remove p coll)] ?
17:42rata_wwmorgan: separate?
17:42amalloywell, clojure.contrib.seq-utils/separate, but a shorter name is (juxt filter remove)
17:43rata_amalloy: you still in love with juxt?
17:43wwmorganthanks! rata_, amalloy. I'll pick one of those
17:43rata_=P
17:43amalloyrata_: we haven't set a date yet, but we're definitely getting married, yeah
17:44rata_hahahahaha
17:48simardcould anyone get penumbra to work ?
17:51simardhere is the problem: http://pastebin.com/cfhGE5yp
17:59rata_is there a way to split a regex in several lines?
18:00rata_(using the #"" reader macro)
18:06SomelauwFor 4clojure, I would really like it to see alternative solutions. I would like to see ways to improve my solutions.
18:06stirfoo`rata_: isn't there a flag to allow that?
18:07amalloyno
18:07amalloySomelauw: please feel free to start a forum or something, somewhere on the web, and i'll link to it. it's not really part of what i'm good at, and i don't want to deal with moderating it either
18:08rata_stirfoo`: you mean multiline? that's for another thing
18:09amalloy$javadoc java.util.regex.Pattern
18:09lazybothttp://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html
18:09amalloyrata_: http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#COMMENTS and http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#compile(java.lang.String, int)
18:10stirfoo`rata_: no I was thinking something like Python's verbose flag: re.X
18:10amalloythe clojure reader macro does not expose the /x modifier, but java does
18:10stirfoo`amalloy: ah
18:16arohneribdknox: in noir, is there any way to get access to the request (not just params) in a normal defpage? looks like the only way to do so is with a pre-route
18:17arohnerspecifically, I need the :body to handle a POST
18:18duncanmsigh, 2 hours i've been battling JRuby
18:19duncanmand i finally realized, i've been programming Ruby's Hashes like they're Clojure maps
18:19duncanmand other than clojure (and i guess Scala), no one else has immutable dictionaries
18:19amalloycoughaskellcough
18:19duncanmoh right
18:20duncanmand now i'm really confused: what's the point of having #collect, #select, #inject if the data structure is not functional?
18:20duncanmi don't even know how i'm supposed to use those APIs now
18:21ibdknoxarohner: there was a thread on this on the mailing group
18:21ibdknoxyeah, here we go
18:21ibdknoxarohner: https://groups.google.com/forum/#!topic/clj-noir/M5qCktV3CPU
18:23coopernursearohner: there was another noir thread about this too. there's talk of generalizing access to the request object in the future
18:24ibdknoxcoopernurse: maybe even by tonight ;)
18:24coopernurseibdknox: nice!
19:22sridchallenge -- find the algorithmic complexity of the hamming number solution here: http://def-learn.blogspot.com/
19:23sriduse of set and conj seems like cheating. i was trying to come up with an optimal version.
19:23Somelauwwhat is up with the netsplit?
19:25hiredmansrid: you should move the lazy-seq to be around the whole fn body instead of just the tail of the fn
19:28amalloysrid: easy, n*logn
19:28sridbtw, that blog is not mine
19:29sridamalloy: what is n?
19:29amalloyfinding the first n elements
19:29sridok, but this solution will iterate till 1000th number, which is not same as 1000
19:29hiredmanwell good, it's the same dumb blog that I saw in the planet clojure feed that puts a vector into a LinkedList then calls seq fns on it
19:30hiredmanhttp://def-learn.blogspot.com/2011/08/programming-praxis-reverse-sublists.html <-- dumb
19:30amalloyhiredman: yeah, i actually wrote an angry letter to planetclojure about how bad that one was and can we please not publish this
19:30amalloynot that one, actually. the one about...a sorted ring or something
19:31amalloyhttp://def-learn.blogspot.com/2011/08/programming-praxis-cyclic-sorted-list.html <-- at least as bad as the one hiredman points to
19:31hiredmanthe hilarious thing is the first comment on http://programmingpraxis.com/2011/08/26/reverse-every-k-nodes-of-a-linked-list/ the page he links to, has a a clojure solution sans the stupid linked list
19:31sridheh
19:31amalloysrid: you say "but", but you don't seem to be disputing anything anyone's said
19:32sridamalloy: you said n*logn. but the 'n' in this complexity is not the N in "first 1000"
19:32amalloyyes it is
19:32amalloyto find the first N items in the hamming sequence takes n*logn time
19:33sridok, let's find it out. what is the complexity of `conj` on a set of size k?
19:33amalloylogk, because it's a sorted set
19:34sridand how many times is conj called for finding the Nth number? N times, correct?
19:34amalloymhm
19:34sridnow what is the upper bound in the set 's'? (hint -- it is not N)
19:35sridupper bound in size of set 's'
19:36amalloyone upper bound would be 3N. there may be an upper bound that is not so high, but it will be a constant factor
19:40amalloysrid: so what are you getting at? is log(N) a bound on the size of s, somehow, or something like that?
19:42sridhmm, yes .. 3N is the upper bound for size of the sorted set. so, it is n*lg(n)
19:45amalloythere might well be a proof that, for large N, the number of items *actually added* to the set for most iterations averages out to something pretty small. because when you're looking at small numbers like 30, it's quite likely that 60, 90, and 150 have all been added already
19:46amalloyif |S| could be bounded at log(N) for large enough N, you could convince me that the running time is smaller than N*log(N)
19:46tomojdoes it matter whether you actually add something?
19:46amalloytomoj: not for the current iteration. but if you don't, it makes future iterations faster
19:46ibdknoxany thoughts on why tools.namespace.find-namespaces-on-classpath returns empty when in a war file?
19:46tomojah
19:47hiredmanibdknox: war files tend to be run in more complex (classpath wise) environments
19:49hiredmanmy guess those tools are worthless the minute you leave a simple repl behind
19:49ibdknoxhiredman: it works nicely in jars
19:49ibdknoxhiredman: just seems to break with war files (so far)
19:50hiredmanjars are not complex
19:50ibdknoxsure, I was just saying it does make it past the repl :) Maybe not much further haha
19:50hiredmanyou've never used jars on the repl?
19:51hiredmanthere is nothing complex abouts jars on the classpath at all, or wars for that matter
19:51hiredmanthe complexity arises via the interactions between classloaders
19:52ibdknoxrighto
20:03hiredmansomething like (.getResource (.getClassLoader clojure.lang.RT) "clojure/lang") is your best bet
20:05hiredmanwhere clojure.lang.RT is replaced by some class that most likely got loaded by a loader that knows where your resource is
20:05hiredmanand "clojure/lang" is replaced with the dir prefix from the namespaces you want to load
20:21polypus74anything special have to be done to call variable arity java ctors?
20:21polypus74i'm getting an error when i try the usual (MyClass. ...)
20:21mudgeanyone heard what rich hickey is doing lately?
20:22hiredmanpolypus74: variable arity is a java language fiction, it really takes an array
20:23polypus74hiredman: ahh, so from clojure i should pack into array first? ty
20:24iceymudge: I heard he was starting an Iron Maiden cover band and they're planning on touring Europe
20:24iceybut i might have misheard
20:24mudgeicey: wow, that is a change
20:25polypus74i heard britney spears myself
20:25mudgeicey: i didn't know he was into music like that
20:25iceymudge: yeah, i guess that's why he's been growing his hair out
20:25mudgeicey: ohhhh, that explains a lot
20:25hiredmanI heard he was laying in a hammock when irene hit and is now somewhere over the atlantic
20:25coopernursejust pushed an oauth wrapper for signpost that works with appengine: https://github.com/coopernurse/clj-appengine-oauth
20:27mudgehiredman: i hope he is okay
20:27hiredmanhis brain is still functional
20:27hiredman~rimshot
20:27clojurebotPardon?
20:27hiredmanclojurebot: jerk
20:27clojurebotExcuse me?
20:28mudgehiredman: thank goodness, sounds like his head is pretty immutable
20:28hiredmanheyo
20:33mudgehey, is there a way to clean out all namespaces in a running clojure program and then reload all the namespaces?
20:33mudgethis way I could change source code, delete all the namespaces, then reload all the namespaces in the same running process
20:34technomancymudge: C-c C-l in slime forces a reload of the current buffer as well as all the namespaces it requires
20:34technomancynot quite the same but possibly close enough
20:36mudgetechnomancy: that's cool, but I want to do this outside develpment, see i push new source code changes to a remote server via git, and don't have a connection to it in emacs
20:36mudgei have jetty running on a remote server and I push changes to the clojure source code to it through git
20:36hiredmansounds horrible
20:36mudgehiredman, why?
20:37technomancyfrom what I've heard tomcat can do restartless reloads with classloader magicks
20:37hiredman^-
20:37technomancybut I have never used tomcat, so don't trust me
20:37mudgei have a website running on a remote server and after I am finished with some development it is easy to push those changes to the website
20:37hiredmanuse a feature created for the functionatility you want, don't abuse other mechanisms
20:39mudgehiredman, Heroku uses git to delpoy websites, i'm doing the same thing
20:39hiredmana. heroku bluids a slug and deploys that and b. git is not a deploy tool
20:40hiredman(and c. I don't care what they do)
20:40hiredmanhttp://devcenter.heroku.com/articles/slug-compiler
20:45mudgehiredman: i also have an automatic mechanism for extracting the application source from git and deploying it once it is on the server
20:45mudgehiredman: do you have any websites that you need to make changes to from time to time? curious how you might do it
20:47hiredmancontent changes should be made to the content source (some database, static files, whatever) application changes require an app restart
20:47hiredmanI doubt you have an automatic mechanism because you are here asking about implementing such a mechanism
20:48devn"Fuck it, we'll do it live."
20:49mudgelike Heroku I use a git hook to check out the source code without the git repository and put it in the right place on the server
20:49mudgehiredman: yes, still working on it, but some of it is done
20:49hiredmannah, github uses a git hook to build a slug, and then the slug gets deployed, if you want to go that route, setup tomcat, have a githook build a war, and deploy the war
20:50hiredman(this is not an endorcement of tomcat in anyway)
20:50coopernurseone thing to note about tomcat hot deploy
20:51coopernurseeventually you will probably run out of JVM PermGen space
20:51devnnote the eventually
20:52hiredmanheck, have you git hook restart jetty
20:52hiredmanyour
20:52coopernursethis article explains the issue well, but it's a little tl;dr http://blogs.oracle.com/fkieviet/entry/classloader_leaks_the_dreaded_java
20:52devntl;dr
20:52devn;)
20:52hiredmanboring;dr
20:53mudgehiredman, yea, good idea, that's what I was thinking, butttt, when i restart jetty my website goes down and I don't like the slow start of java when starting up jetty -- which is why i want to keep jetty running, and just wipe out and reload all the namespaces from the source code which might have changes
20:53coopernurseit would be interesting if clojure based webapps fare better in this regard, as they tend to have fewer dependencies..
20:53mudgechanged*
20:54devnmudge: You could just edit in a running REPL?
20:54devnSetup a remote REPL?
20:54hiredmanmudge: how many users do you have?
20:55devnStage your changes locally and then in the REPL make the relevant changes
20:55hiredman:(
20:55devnThen do a full deploy later on
20:55mudgehiredman, not enough users to justify this on a basis of users
20:55mudgehiredman, i just want to do it
20:55mudgedevn, yes a remote repl would be nice
20:55devnmudge: suggestion: anything is possible, however ugly it may be -- go for it
20:55hiredmanmudge: then build a proper classloader based hot redeploy
20:56hiredmanif you are doing it for fun
20:56devnmudge: or do the "good enough"
20:56devnand just hack the shit out of it -- bailing wire, tinfoil and duct tape
20:56mudgehiredman: yea, that sounds great, i have no idea how to do that, i guess i can check google
20:56mudgedevn: yea, sounds fun
20:57devnmudge: use what you know. if that seems overly complicated then do what you can to get closer to the ideal world you've concocted. :)
20:57mudgeokay
20:57devnmudge: my advice is very non-specific, but I think you will be surprised at some of the cleverness you can get away with
20:58devnmake a mess and then clean it up :)
20:58coopernursemudge: how many wars do you have deployed in jetty? just one?
20:58mudgei just wondered if there was a simple way to clean out all the clojure namespaces and reload them, i know that ring has wrap-reload that reloads namespaces but it doesn't get rid of old names
20:58mudgei don't deploy wars, i embed jetty in my web apps
20:59devnmudge: so, old names, like you want to rebind a function of the same name or something?
20:59hiredmanmudge: that is the first thing that'll have to go
20:59devnlike (defn foo [] (+ 1 1)) => (defn foo [] (+ 1 9))
20:59mudgedevn: i want to change the source code and then have the running clojure program pick up the changes of the source code, but also get rid of names no longer referenced in the source
20:59hiredmanbuild a war using lein-war or lein-ring or whatever, use jetty-runner to run the war
20:59devnBecause you could fuel that whole thing from a remote REPL with a bit of hackery
21:00devnI need to run -- best of luck mudge
21:00mudgethanks devn
21:00hiredmanmudge: it more less seems like you want to do things the way people do them with ruby, but this is not ruby
21:01coopernurseoff the wall idea: if you want to avoid downtime, you could spin up a new instance of your app on another port, and either have a proxy (nginx) flip forward rules, or (easier) flip a iptables port forward rule
21:01mudgecoopernurse: interesting idea
21:02coopernursesomething like: iptables -t nat -I PREROUTING --src 0/0 --dst 0/0 -p tcp --dport 80 -j REDIRECT --to-ports 8080
21:02coopernurseand then flip: iptables -t nat -I PREROUTING --src 0/0 --dst 0/0 -p tcp --dport 80 -j REDIRECT --to-ports 8090
21:02coopernurseprobably not a _huge_ bash script to do the startup / port flip
21:02devn^not a bad idea
21:04coopernursewould make a nice recipe to share.. common problem on the jvm (slow start)
21:04coopernurseand I've had too many strange issues with JVM classloaders to recommend hot deploy.. at least on the sun/oracle vm
21:04devncoopernurse: Clojure programmers don't write their apps in clojure. They write the language they use to write their apps in clojure.
21:04devnerr @ mudge
21:05devnRemember that. Whens someone tells you no. Tell them yes.
21:05devnThe world is your oyster, yadda yadda. Okay, definitely running now. Later
21:05coopernurseme too. g'night guys
21:05mudgecoopernurse: yea, definitely, reminds me, I've been looking at jark for clojure shell scripting, it provides a persistent jvm
21:20zakwilsonI want to apply a function to a user-supplied symbol referring to a value in my program, e.g. (some-fn (eval (read-string user-data))). Aside from the user being able to supply a symbol name that would expose data that users shouldn't get, what could possibly go wrong?
21:22chouserif they're only supplying the symbol, you can be safer and faster by avoiding eval
21:23zakwilsonThey supply the symbol as a string. How do I get the associated value without using eval?
21:23chouser(some-fn (resolve (symbol your-string)))
21:23chouseror maybe: (some-fn (deref (resolve (symbol your-string))))
21:24zakwilsonYeah, deref is needed, but I think resolve is what I wanted. Thanks.
21:29amalloyderef shouldn't actually be necessary, should it? when called as a function, the var will forward to the function
21:31zakwilsonIt appears to forward the equivalent of (var the-symbol).
21:35zakwilsonMeh. It works in the repl, but when I tried doing it in my app, I kept getting NPEs. Since I'm just using this to serve appropriate stylesheets, I'll just keep a map of names of stylesheets. It's not cool and lispy, but it's probably safer.
22:16simard(pmap #(* % %) (range 100)) why does this result in a java.util.concurrent.RejectedExecutionException ?
22:19tomojswank?
22:19clojurebotswank is try the readme. seriously.
22:19tomojhmm http://stackoverflow.com/questions/7004292/rejectedexecutionexception-and-clojure-concurrency
22:20tomojfor me deleting swank-clojure from ~/.lein/plugins and reinstalling 1.4.0-SNAPSHOT was the fix
22:23simardok I'll try that
22:26simardtomoj: worked like a charm, thank you :)
22:51mudgesrid: looks cool
23:01solussdhow do you efficiently trim characters off the end of a string?
23:06amalloysolussd: ##(doc subs)?
23:06lazybot⇒ "([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive."
23:10solussdis that going to be more efficient than a drop-while reverse drop-while reverse str?
23:16amalloyabout a hundred times more so, yes
23:16amalloy(estimate comes with no warranty explicit or implied)
23:21solussdah, but I need to trim arbitrary characters in a set. E.g. "/blah/ " => "blah" (removing characters in #{\/ \ })
23:22tomojdidn't this happen yesterday
23:23tomojoh, not quite
23:24amalloysolussd: so walk the string, decide what indices to drop from, and do the drop all at once, if you care about efficiency
23:25amalloytomoj: yesterday it was a guy named jblomo diong exactly the same thing. a bit weird if it's a coincidence
23:26michaelr525hello!
23:26solussdk.. I was surprised that trim, ltrim and trim exist but nothing that trims an arbitrary set of characters.
23:26solussdeasy enough. thanks!