#clojure logs

2011-02-06

00:00sritchiewould you all consider this the best way to extract a 4 digit year from a filename?
00:00sritchie,(first (re-find #"(\d{4})" "precl_mon_v1.0.lnx.2000.gri0.5m.gz"))
00:00clojurebot"2000"
00:36redline6561Hi there. I'm a CL guy so sorry if this is a dumb question. Is there something I can use *from* the SLIME REPL to download and load libraries (ala quicklisp)?
00:36redline6561I know about leiningen but heard it might not support this use case...
02:37ekoontzanyone know how to set up ring?
02:37ekoontzhttps://github.com/mmcgrana/ring
02:38ekoontzhttp://pastebin.com/EjzHHHQ4
02:43ekoontzohh i have to run "lein deps"
02:44ekoontznice, "Hello World from Ring" works :)
02:46ztellmanhiredman: can you explain your earlier "that looks familiar" comment?
02:46ztellmanif there are any other similar libraries/bits of code around, I'd like to see them
03:33LauJensenekoontz: make sure you check out Moustache as well
03:34ekoontzhey LauJensen
03:34LauJensenYo yo :)
03:34ekoontzthat's a markup language right?
03:35ekoontzoh ok : https://github.com/cgrand/moustache
03:38ekoontzstuck in dependency hell : https://gist.github.com/813227
03:40ekoontzhow do people set their classpaths while using clojure..maybe dumb question..?
03:40brehautekoontz: with lein or cake doing dependancy management
03:41ekoontzi created a ~/bin/clj which is a shell script: https://gist.github.com/813230
03:42ekoontzbut i shouldn't have to keep adding .jars to my CLASSPATH right?
03:43brehautekoontz: github.com/technomancy/leiningen/ or https://github.com/ninjudd/cake
03:43ekoontzbrehaut: cool
03:43ekoontzbut i have leiningen installed
03:43ekoontzi can do lein deps
03:43brehautyou specify your dependancies for a project, and they manage downloading them and other dependancies, and then generate your classpath for you as needed
03:44ekoontzthat's in project.clj right?
03:44brehautyes
03:44ekoontzok but suppose i want to start clj interactively
03:45brehautif you want just a random repl, cake might provide one? otherwise i use cljr which is built on lein, and allows you to install packages
03:45brehautlein repl
03:45ekoontzok yeah ..repl
03:45ekoontzlet me try that..thanks :)
03:45brehautits all in the tutorial for lein
03:45ekoontzso what is cake about..is that a competitor to lein?
03:45brehautsort of ?
03:45brehautfor basic usage they are equivalent
03:46brehautbut they diverge on issues of plugins and expert features
03:46ekoontzwhich do you prefer
03:46brehautim not a tool using monkey, i get by with the most basic of lein features
03:47ekoontzok
03:47ekoontzso basically use "lein repl" yeah?
03:47brehautyeah
03:48brehautyou can also get lein to generate a packaged jar file which contains all your dependancies with uberjar which can make deployment super easy
03:49ekoontzhm ok, thanks, will keep that in mind..
03:51ekoontzbrehaut: sorry, what am i doing wrong here ? https://gist.github.com/813236
03:51brehautyou dont use ns forms in a repl
03:51brehautreplace that with
03:52brehaut(use 'compojure.core ring.adapter.jetty) (require '[compojure.routes :as routes])
03:53ekoontzbrehaut: https://gist.github.com/813238
03:54brehautyou have compojure in your dependancies in project.clj and run lein deps?
03:54brehautand the ring jetty adapter?
03:55ekoontzi have the default project.clj in compojure
03:55brehauti dont use compojure sorry, so i dont know what that looks like
03:55ekoontzok
03:56brehautsorry its late here. i have to head to bed
03:56ekoontzthanks dude :)
03:56ekoontzi'll figure it out eventually
04:08fliebelmorning
04:37Dranikhi all!
04:37Dranikis there a way not to specify the exact versions of libs in leiningen project.clj?
04:38Dranike.g. I want just the latest libs regardless of their exact version
04:43fliebelDranik: Some offer -SNAPSHOT versions
04:43Dranikfliebel, so the answer is "no" ?
04:43fliebelOther than that, it is considered bad practice, because it can break your code later.
04:44fliebelI think it is.
04:44Dranikfliebel, so how should I learn the exact number of the latest version?
04:45fliebelDranik: For Clojure code, byt looking at the version in project.clj or by looking at the Clojars page.
04:45fliebelFor Java code… Good luck!
04:46Dranikfliebel, thanks!
04:50ekoontznewb clojure q: how do i load a .clj file into the repl?
04:50ekoontze.g. https://github.com/scottjad/slice/blob/master/src/slice/example.clj
04:50fliebel(use 'slice.example)
04:50Dranikalso you may (load-file "my.clj")
04:51ekoontzfleibel: thanks, that works :)
04:52ekoontzDranik: cool that works too
05:01DranikI've loaded the namespace using the "use" command, then changed something. How to reload the namespace?
05:12fliebelCould anyone have a look with me at this function? http://pastebin.com/NcuciA3z It's the newer version of https://github.com/pepijndevos/ArmageDOM/blob/master/src/armagedom/dom.clj but it does not work yet. It gives a java.lang.ClassCastException
05:14fliebelThe new part is the reduce statement ate line 12
05:16fliebelOKay, I know what's wrong, but I dont know how to fix it.
05:32fliebelThe problem is that I can't return 2 functions to trampoline.
05:39fliebelOh, whatever, what is the deepest XML file you've ever seen?
05:57simonfxrhow can i get the class instance of a certain type? (java syntax: java.lang.Integer.class)
06:03gko(class ...)
06:06simonfxrthx
06:34raek,java.lang.Integer
06:34clojurebotjava.lang.Integer
06:34raek,(class java.lang.Integer)
06:34clojurebotjava.lang.Class
06:34raek,(class 1)
06:34clojurebotjava.lang.Integer
06:34raeksimonfxr: ^
07:33shortlordcan I get
07:33shortlordsry
07:34shortlordcan I get a value of a ref that I've just changed in a transaction in the same transaction by dereferencing it?
07:43dunkI'm a bit lost on how to get a clojure install with slime. Is there a tutorial somewhere? What's the most up-to-date method?
07:43clojurebotclojureql is http://github.com/LauJensen/clojureql
08:54rrc7czif you have (ns x (:use y)), then a (gen-class) with a method impl (defn -myEval [this sexpr] (eval (read-string sexpr))), why do calls to (.eval (MyClass.) "some symbol in ns y") throw Unable to resolve symbol? Other methods in the gen-class refer to symbols in y and it's fine. I'm guessing the compiler converts all symbols to fully ns qualified?
08:58rrc7czthinking about it more, I assume the (:use) in the ns is just for the compiler to resolve everything correctly, but then the class runs in its own ns w/out anything refered except core. I could probably put a (use) call in the myEval impl
09:17jaskirathey guys, does anyone here use erc?
09:27rrc7cz jaskirat: I'm on it now
11:07odyssomaycan I terminate a reduce call if some condition is met?
11:08opqdonutno, not really
11:08opqdonutyou'll need to implement a custom breakable-reduce
11:09odyssomayok
11:36odyssomayIs there a "drop-first" function?
11:38jkruegerpdyssomay: you mean rest ?
11:38odyssomay...
11:39odyssomayyes
11:39odyssomay:)
11:43odyssomayIs it possible to reload already loaded files?
11:46jkruegerodyssomay: yes. you can also add a hint to the namespace that results in each depending namespace being reloaded as well
11:46jkruegerwhich is good for unit tests. for example
11:49jkruegerspecifically you can add a :reload or :reload-all keyword to each require form
11:50odyssomayjkrueger: thank you
12:43ldhafter I (use 'some.namespace) from the REPL, then modify the underlying source file, is there a way to reload the new version?
12:47shortlordis there an easy way to convert a normal java.util.Map directly into a clojure map?
12:49zonpantlildh: (use :reload-all 'some.namespace)
12:49ldhzonpantli: ah, thanks
13:10odyssomayIs there a function similar to "take-while" which instead of sending each element to the specified function, sends the elements so far?
13:11odyssomayEx: ("take-while" (fn [x] (not (= (count x) 3))) '(3 6 1 7)) => (3 6 1)
13:11odyssomayor maybe (3 6)
13:14pdkanyone in here familiar with counterclockwise
13:14pdkgiving me a null pointer in eclipse whenever i open a file
13:15pdkmore specifically file -> open file... on any .clj file = null pointer
13:24rindolfHi all. Would it be acceptable if I start a philosophical discussion/QA-session about the philosophy of Clojure?
13:25odyssomayrindolf: sounds good to me
13:25rindolfodyssomay: OK.
13:25pdkwe're used to em
13:27rindolfFirst of all an introduction, I am http://www.shlomifish.org/ (Shlomi Fish) and I mostly write Perl 5, shell and C daily (while knowing many other languages to some extent), and I've been waiting for a modern, usable, Lisp dialect for quite a while now.
13:28rindolfI've had some hopes for Paul Graham's Arc, but eventually started my own effort (no code - only planning) called Park, which eventually became Spark, which kinda suffered from the second system effect.
13:28rindolfThen Arc came out, and it was disappointing. While being kinda brief, it lacked many advanced features.
13:28rindolfSo I've heard of clojure.
13:29rindolfNow I'm not sure if clojure has all the CSy features that I came to expect and like, but at least it's there and ready and has become somewhat popular and "hip".
13:30rindolfOK, first question - does the core Clojure language aims for Minimalism (e.g: a la Scheme), or does it prefer to have some dark corners so programmers can express themselves and so it will be usable?
13:31pdkit seems to me it doesn't have anything quite as hackish as common lisp loop
13:31odyssomaypdk: for?
13:32pdkthough it does have some extra junk intended for java interop that probably isn't as clean as the core language
13:32rindolfI think iterate is a little nicer than loop in CL.
13:32pdknah cl's loop macro is different from for
13:32rindolfIt's a third party extension.
13:32pdkcl's loop slices dices and purees while being a hulking mess from a purity standpoint
13:32RaynesClojure, first and foremost, tries to be a practical language. It's only as minimal as practicality allows for.
13:33pdksometimes the java brain damage shows through when you write code for java interop
13:33odyssomaypdk: yes, but I don't quite like the style of for anyway, it reminds me much of loop
13:33pdkcoercing primitives and type hints especially
13:34pdklimitations of clojure's host platform also explain why loop/recur and explicit tco exist
13:35rindolfRaynes: OK, that sounds reasonable.
13:40odyssomayHow come for example using "reverse" on a string, doesn't result in a string?
13:41a_robbinsHey guys, I'm working through the clojure koans and I am having trouble figuring out some behavior. Apparently (list first-name last-name) is different from '(first-name last-name). Is there a reader macro for making lists? If I just do (first-name last-name), it will try to execute first-name as a function.
13:42rindolfNow regarding APIs, I realise that you can use all the Java APIs in clojure, which is a good thing. Languages without APIs are in my opinion not very attractive.
13:43odyssomaya_robbins: http://www.lisperati.com/clojure-spels/casting.html
13:44odyssomaya_robbins: http://www.lisperati.com/clojure-spels/casting.html (if you didn't catch it)
13:45rindolfOf course, from my experience it's hard to install many third-party APIs for Java (a la Perl's CPAN) with maven being the beast that it is.
13:45a_robbinsodyssomay: thanks, I read through that
13:45a_robbinsodyssomay: I'll read through that*
13:45ekoontzrindolf: project.clj looks pretty nice
13:45rindolfekoontz: what is it?
13:46ekoontzinstalls dependencies
13:46ekoontza la maven
13:46rindolfekoontz: ah.
13:46rindolfekoontz: can they be Java ones too? Or only clojure ones?
13:46ekoontzyep, java too :)
13:46odyssomayAren't they java only?
13:46ztellmanrindolf: anything with a Maven repository
13:46rindolfztellman: hmmm.... :-S
13:46ztellmanclojars provides a maven repository for clojure projects
13:47ztellmantrivial to set up
13:47ekoontzthen do lein deps
13:47ztellmanand most established java projects have their own
13:47anthony__If I have "key1:value1;key2:value2;key3:value3" and want to convert it to {key1 value1 key2 value2 key3 value3}, what functions should I start looking at?
13:47rindolfCan it easily interface with RPM/Deb-dpkg/etc.?
13:48ekoontzi don't know about that; i use it on mac os x for now
13:48ztellmananthony__: split on ";", then (apply hash-map ...) on the resulting sequence
13:48ztellmansorry, split on ":"
13:48anthony__ztellman: Thanks. hash-map was my missing function. :D
13:56rindolfWhat did I also want to ask?
13:56rindolfLet me see.
13:59rindolfhttp://www.perl.com/pub/2007/12/06/soto-11.html - if you didn't read that, you should. How does clojure feel about being a language for writing quick (and sometimes dirty) code? And for "catering to mere mortals"?
14:05ztellmanrindolf: I don't think anyone's fundamentally opposed to quick and dirty code, but the general message from on high is that Clojure should be a powerful tool for knowledgable users
14:05rindolfztellman: well, I don't see these as necessarily contradictory.
14:06ztellmanno, but there's a fundamental lower bar in terms of knowledge to use Clojure effectively
14:06ztellmana novice can't easily use Clojure in a "quick and dirty" way
14:07rindolfztellman: I mean, it's hard to write quick-and-dirty stuff in C and in Java, etc. but in Perl/Python/PHP/Ruby/etc. you can also write complex stuff , but also quick-and-dirty-stuff.
14:07ztellmanhmm, maybe I'm just conflating the quick and dirty and "mere mortals" comments
14:07rindolfztellman: would you accept a ClojureScript extension?
14:08ztellmanrindolf: what would that be, exactly?
14:08rindolfztellman: also see http://perl.plover.com/yak/12views/samples/notes.html#sl-39
14:09ztellmanbrb
14:09rindolfztellman: see ya.
14:15ztellmanrindolf: maybe this just speaks to my particular biases, but I don't think designing a language around one-liners is a particularly great idea
14:15ztellmanor rather, I don't think a language needs to be able to do both one-liners and large-scale programs
14:16ztellmanthere are plenty of good scripting tools out there, why would Clojure try to displace them?
14:16rindolfztellman: well, I don't think we should make sure a language is usable only for one liners.
14:16rindolfand some of my perl -e programs are longer than 80 chars.
14:16rindolfztellman: well, if people use clojure on the command line, they will eventually use it for more serious stuff.
14:17rindolfztellman: some of them at least.
14:17ztellmanrindolf: sure, that's one way to build a community
14:17ztellmanit worked very well for perl
14:17ztellmanbut it's not the only way
14:17ztellmanobviously the one-liner/big program distinction is a spectrum, not a dichtomy
14:18rindolfRight.
14:18rindolfAnyway, maybe I should try creating something like ClojureScript.
14:18ztellmanI'd be interested to see that
14:18rindolfYes.
14:19rindolfOne of the problems I found with Scheme and to a lesser extent CL was that they tended to be very verbose/wordy by default.
14:19rindolfLong identifiers, etc.
14:19rindolfYou could avoid it eventually by writing many abstractions, but that's hardly a solution.
14:19odyssomayrindolf: that's a good thing
14:19ztellmanagain, i think it's just what you're optimizing for
14:20rindolfPaul Graham talked about it.
14:20rindolfodyssomay: you mean verbosity?
14:20odyssomayrindolf: yes
14:20rindolfodyssomay: why?
14:20ztellmanPaul Graham said that concision = expressiveness, which I'm wholly unconvinced of
14:20rindolfztellman: http://www.paulgraham.com/power.html
14:20odyssomayrindolf: because when it's verbose, I can understand my programs
14:20rindolfHmm... there's such a word as concision.
14:21rindolfodyssomay: well, if it's too verbose, you'll have a problem following it.
14:21ztellmanha, yeah, I didn't just make it up
14:21odyssomayrindolf: which is?
14:21ztellmanunnecessary verbosity = lack of expressiveness, sure
14:21ztellmanbut that doesn't necessarily imply the converse
14:21rindolfodyssomay: I'm not a fan of using obscure identifiers, but I still think that conciseness is important.
14:22odyssomayI mean, of course I can see the problem of verbosity (ztellman got it), but for me verbosity always comes out on top
14:23ztellmanI think the key is that if some boilerplate is getting in the way of you understanding your own code, you can abstract it away
14:24rindolfYes, I think that preferably the language or the API-collection (CPAN/etc.) that you're using should make you avoid this boilerplate by default.
14:25ztellmanrindolf: is that a language design issue, or a social convention issue?
14:26rindolfztellman: well, if anyone has their own favourite and incompatible abstractions, then it creates fragmentation.
14:26ztellmanrindolf: definitely true
14:26ztellmanbut one of the things that I think Clojure got very right was choosing what the language forces people to standardize on
14:27ztellmanmutability is the big one
14:27ztellmanbecause two libraries that deal with that differently would basically be incompatible
14:28ztellmannot baking everything into the language will cause some growing pains due to people inventing their own conventions
14:28ztellmanbut I think the idea is that the community will adopt conventions over time, as various approaches are proved out
14:29rindolfztellman: yes, if people share their abstractions and APIs online as FOSS, then eventually standards emerge.
14:30ztellmanrindolf: which seems to be happening at a pretty good clip
14:30ztellmanso I'm not personally very concerned by the fragmentation issue
14:33a_robbinsI use django, a python web framework, and they are having a very similar ongoing discussion about what to bring into the contrib package, and what to leave out in the community. It seems like the basic dilemma is you can either 1) bless something and make it contrib, slowing down development on that problem since it is harder to modify than someone's personal project or 2)let everyone make their own solutions out in the community, whi
14:33a_robbinsch fragments and makes it hard for newer users to know what the available packages are.
15:02rindolfHi all.
15:03LauJensenrindolf: yo yo
15:03rindolfLauJensen: I went to take a bath.
15:04LauJensenrindolf: thanks for sharing
15:04rindolfI see ztellman , and a_robbins have gone.
15:04rindolfLauJensen: sorry. :-(.
15:04LauJensen?
15:04rindolfLauJensen: regarding the "thanks for sharing."
15:04LauJensenIt was said with a smile
15:04rindolfLauJensen: ah, OK.
15:05LauJensen:)
15:05rindolfWell, maybe I'll try working on a ClojureScript something.
15:05rindolfClojure has something like eval "string" right?
15:05rindolfOr only eval (SEXPR)?
15:05LauJensen&(read-string "(+ 2 2)")
15:05sexpbot⟹ (+ 2 2)
15:06LauJensen&(-> "(+ 2 2)" read-string eval)
15:06sexpbotjava.lang.SecurityException: You tripped the alarm! eval is bad!
15:06rindolfWow.
15:06rindolfThis -> looks cool.
15:06rindolfI had a similar idea.
15:06rindolfFor Park->Spark I mean.
15:15kumarshantanuhas anybody tried using fn names with dash/underscore in protocols and then using them in Java? does it work?
15:17Rayneskumarshantanu: Don't hold me to it, but I seem to remember Clojure converting the names to something Javable under the hood.
15:41kumarshantanuRaynes: that possibly means i need to know converted names pattern if i want to use them in Java
16:07Raynesdefn: Ping
16:09LauJensenkumarshantanu: - becomes _, IIRC
16:23phenom_hey guys, im having some trouble understanding the male/female example from Programming Clojure ... why does the sequence not cause a SOE but the direct call does ?
16:27rindolfphenom_: can you give a URL?
16:27rindolfphenom_: is Programming Clojure available online?
16:27phenom_rindolf: no it's not ... ill do a pastie
16:28rindolfphenom_: thanks.
16:28rindolfphenom_: I'm not a clojure expert, though, but it's standard procedure.
16:28kumarshantanuLauJensen: i tested and found both dash and underscore work in Clojure..that leads me to suspect they have separate encoding pattern (certainly for the dash, because it)
16:28kumarshantanu..it's not valid in Java..
16:30rindolfWell, maybe Java symbols accept arbitrary strings internally.
16:30rindolfWith some special API calls, not using code directly.
16:31phenom_rindolf: http://pastie.org/1535093
16:32joshua__$findfn {:test "123"} "123"
16:32sexpbot[]
16:32rindolfphenom_: what is SOE?
16:32phenom_stackoverflowexception
16:33joshua__&(key {:test "123"})
16:33sexpbotjava.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry
16:33joshua__Is that what is suppose to happen?
16:33joshua__&(doc key)
16:33sexpbot⟹ "([e]); Returns the key of the map entry."
16:34joshua__&(key (first {:test "123"}))
16:34sexpbot⟹ :test
16:35joshua__Ah, so the ArrapMap has map entries. I think I get it now.
16:36joshua__$findfn (first {:test "123"}) "123"
16:36sexpbot[clojure.core/val clojure.core/second clojure.core/last clojure.core/peek clojure.core/fnext clojure.core/rand-nth]
16:36joshua__&(doc val)
16:36sexpbot⟹ "([e]); Returns the value in the map entry."
16:37joshua__Yeay, found the function I was looking for.
17:09__name__hello
17:09brehautmorning __name__
17:10rindolfHi __name__
17:10__name__how is it ensure that a transaction completes at some time?
17:10__name__*ensured
17:10__name__i mean, what if there's two concurrent threads that keep spawing transactions and one always wins?
17:11brehaut__name__: complicated heuristics ;)
17:11__name__sounds fun :)
17:11companion_cubeit's STM magic :)
17:11brehaut__name__: http://java.ociweb.com/mark/stm/article.html
17:12brehautits probably a bit out of date now, but it'll give you more info than you want :P
17:13__name__brehaut: thank you
17:18__name__working on a laptop without having a proper table sucks
17:18__name__:(
17:32riddochcA random idea to plant in someone's head: because of homoiconicity, one could make a clojure project to ease migrating a clojure project from clojure 1.2 to 1.3.
17:33riddochcIt'd be a practical application of code-walking, anyway.
18:16brehautis there a short hand for (let [r (exp...)] (when (seq r) (something r))) ?
18:18riddochcbrehaut: Look for when-let?
18:19brehautriddochc: an empty seq is truthy
18:20riddochcIf that's the case, (when (seq r) ... ) might not be what you want?
18:21brehautr is the result of a complex expression
18:21brehautwhen doesnt bind
18:21brehauthence i have a let wrapping a when with a seq test
18:22riddochcHmm. http://clojuredocs.org/clojure_core/clojure.core/when-let
18:22brehauti guess i can just move the expression round
18:23riddochcI suppose you could *make* a shorthand... (defn blah [exp something] (let [r (exp...)] (when (seq r) (something r))))
18:24brehautmeh it'll do
18:24brehautcheers
18:24riddochcI'm really not the best one to be giving advice on this, really. I'm sure someone else knows.
18:25brehautno worries. i rejiggered thing saround so that when-let is a bit cleaner.
19:22cheezeyso im trying to use lein with a library that uses jni. how would i do this =>
19:25ssiderischeezey: there is a native-deps parameter to lein
19:25ssiderisit goes in project.clj
19:26ssiderisfor example:
19:26ssideris:native-dependencies [[penumbra/lwjgl "2.4.2"]]
19:26cheezeyoh
19:27cheezeyis there a place that lists all the options? i guess i suck at searching
19:27ssiderislein's default repo is clojars
19:27ssiderishttp://clojars.org/
19:28ssideris(there is a browse link in there)
19:41cheezeyssideris: thnx
19:41joshua__$findfn "longstringwhichcontaintsanother" "contains" true
19:41sexpbot[clojure.core/not= clojure.core/distinct?]
19:42joshua__<joshua__> $findfn "contains" "longstringwhichcontaintsanother" true
19:42joshua__$findfn "contains" "longstringwhichcontaintsanother" true
19:42sexpbot[clojure.core/not= clojure.core/distinct?]
19:43joshua__$findfn "contains" "longstringwhichcontainsanother" true
19:43sexpbot[clojure.core/not= clojure.core/distinct? clojure.contrib.string/substring?]
19:44joshua__Love that function sooo much.
20:02TimMcwhoa
20:02TimMc$findfn 2 2 4
20:02sexpbot[clojure.core/unchecked-multiply clojure.core/+ clojure.core/* clojure.core/unchecked-add]
20:02TimMcThat's superb.
20:03TimMcBut what about exponentiation?
20:04ChousukeI don't think there's any exponentiation function in core or contrib
20:16joshua__It only searches a few libraries for the sake of speed.
20:17joshua__I don't think that math libraries that might have exponentiation are among the ones it searches.
20:18joshua__$(src find-fn)
20:18joshua__&(src find-fn)
20:18sexpbotjava.lang.Exception: Unable to resolve symbol: src in this context
20:23joshua__If you want to check out the function it is at: https://github.com/Raynes/sexpbot/blob/master/src/sexpbot/plugins/clojure.clj towards the bottom of the page
20:29joshua__Where can I grab an sha-256 function for clojure?
20:30joshua__Nevermind, think I found what I was looking for.
20:31RazWellesAnyone have examples of loading .net assemblies in clojureclr?
20:37TimMcjoshua__: Where?
20:37KirinDaveWhy do I try to explain coding concepts on HackerNews? :(
20:37KirinDaveIt always goes wrong.
20:37joshua__https://github.com/tebeka/clj-digest/blob/master/README.rst
20:38joshua__How so KirinDave?
20:38KirinDavehttp://news.ycombinator.com/item?id=2185810 (and down)
20:38KirinDaveJerk makes statements about actor model
20:38KirinDaveSome of which are not even wrong
20:38KirinDave(as in they're so bizarre to be nonsense)
20:42RazWellesis there any example code for clojureclr anywhere?
20:44joshua__Honestly, I don't understand what you two are talking about well enough to agree or disagree, but more people to be supporting your statements than his. Maybe that Proverb about correcting fools leading to trouble applies?
20:44joshua__Obviously I'm going to need to add a project that will force me to learn concurrency to my to-do list. ;/
20:47KirinDavejoshua__: He's just very full of passion for such an uninformed dude.
20:48TimMcWait a tick... what's the difference between let and let*?
20:49TimMcThis is isn't like Scheme...
20:49Chousukelet is a porcelain macro, let* is the actual "plumbing" :P
20:50Chousukelet basically adds destructuring on top of let*, there's no difference otherwise.
20:50TimMcAh! So that's why there's no destructuring in let*... I should be using let anyway.
20:50TimMcFascinating.
20:50Chousukeyeah
20:50Chousukethere's also fn* which is similar.
20:51Chousukeyou'll see them in macroexpansions, but nowhere else really.
20:52TimMcWell, you'll see them in newbie code too. :-P
20:52TimMc(let* at least)
20:53ChousukeI wonder. Why would they use let*? /
20:53Chousukeit's not documented anywhere
20:53Chousukeyou can get by without knowing it even exists
20:53hiredmanlet* in cl is like clojure's let
20:54TimMcChousuke: In R5RS Scheme, let does not evaluate each init-expr in the scope of the preceding bindings.
20:54TimMclet* is the form to use for that.
20:55TimMcI had no reason to expect any difference. :-)
21:01TimMcChousuke: Also, if they hadn't read http://clojure.org/lisps closely, like me. >_<
21:06RazWelleshow do I access a method when it's like.. indrect by 2? aka object.object2.method()
21:06RazWelles(let [temp_instance object] (.object2.method args1 args2))?
21:07brehaut,(doc ..)
21:07clojurebot"([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on t...
21:07RazWellesty
21:11brehautRazWelles: if it might return nil, you may find -?>> in clojure.contrib.core useful too;
21:11brehaut-?>> is like -?>> but it will short circuit to nil if any of the intervening forms returns nil
21:11RazWellesahh ok, ty :)
21:12brehauts/ -\?>>/->>/
21:12sexpbot<brehaut> -?>> is like->> but it will short circuit to nil if any of the intervening forms returns nil
21:22ChousukeI think you mean ->
21:23brehauti dont
21:24Chousukehmm, I'm not sure how ->> is any better than ->
21:24Chousukeat least for method calls.
21:24brehautin this case it doesnt matter
21:24brehauti meant -?> rather than -?>> i think
21:25Chousukeanyway, using -> with .foo symbols is IMO somewhat nicer than .., but use whichever you want.
21:25brehautChousuke: the advantage of .. is that it is explicity java object interop
21:26Chousukewell so are .foo symbols :)
21:26Chousukeit's more typing, but I prefer having the . for any java methods.
21:26brehautfair enough
21:26gfrlogwhat are people using for sinatra-style http servers in clojure these days?
21:28brehautgfrlog: what is 'sinatra-style' ?
21:28gfrlogwelp
21:29gfrlogfairly minimal. if it parses the path and the query string and the post params and such that'd be nice
21:29gfrlogbut don't need too much else I don't think
21:29brehautthen then answer is whatever server you like, and ring as the base layer
21:30brehautadd compojure or moustache for route dispatch
21:30brehautmost people stick with jetty for the server, but its basically one line in the whole thing
21:30weavejesterRing handles query and post params, so any Ring-based framework would do
21:32brehautgfrlog: that approach is the default in clojure
21:33gfrlogyes but which library?
21:33brehautgfrlog: it depends on taste. ring to start.
21:33gfrlogokay
21:33gfrlogI will look at that, thanks
21:33brehauti have a preference for moustache for routing, and i suspect weavejester prefers compojure
21:34weavejesterHaha - yes, you'd be correct ;)
21:34brehaut:)
21:34gfrlogand these are all mutually exclusive?
21:34weavejesterI've actually been working on an example Compojure project: https://github.com/weavejester/compojure-example
21:34gfrlogno sane reason to combine them?
21:34weavejesterNot really
21:34brehautnot really mutally exclusive
21:34brehautthey both generate ring handlers
21:34weavejesterCompojure and Moustache handle routing. So, I mean, you could use them both
21:34brehautbut you probably wouldnt choose to use both as they cover 90% the same ground
21:34weavejesterBut they do the same thing, more or less
21:35brehautmy gut feeling is that if you are coming from ruby/rails, compojure's routing may feel more familiar
21:35weavejesterReally? I'd have though Moustache was more like Rails, in that it has a static routing system.
21:35gfrlogI've actually done a lot with 2-year-old compojure
21:35weavejesterCompojure is I guess more like Sinatra
21:36brehauthah ok :)
21:36gfrlogbut I gathered it changed a lot more recently
21:36weavejestergfrlog: which version?
21:36brehautim from django land, so i dont really know rails other than what i looked at about 3 or 4 years ago
21:36gfrlogweavejester: was there a major change a year or two ago?
21:36gfrlogI don't have the source code on hand
21:37brehautgfrlog: basicly ring came into existance and compojure no longer duplicates that affort
21:37weavejesterThe major change was probably the move to Ring.
21:37gfrlogokay
21:37brehautweavejester: and seperation of hiccup into its own thing?
21:37gfrlogcertainly some version prior to that
21:37weavejesterYeah.
21:37gfrloghiccup was still part of it too
21:37weavejesterI started off building Compojure as a monolithic framework
21:37weavejesterThen Ring came along
21:38weavejesterso I factored out all of Compojure's parameter, cookie, session etc. stuff to Ring
21:38weavejesterAnything that wasn't framework-specific.
21:38weavejesterthe html generating I stuffed into ring
21:38weavejesterEr, hiccup
21:38weavejesterSo all that's left is about 200 lines of routing code.
21:38gfrlogmy coworker and I were actually just commisioned to rewrite the whole thing in rails
21:39gfrlogsince I didn't write the original app, I consider it legacy clojure code
21:39weavejesterHaha - to be honest, Rails is pretty nice, and more mature. I use it in my day job.
21:39weavejesterI think Ring, Compojure, etc. have greater potential than Rails
21:40weavejesterThe design is better, I think.
21:40brehautweavejester: seconded
21:40weavejesterBut Rails has so much stuff for it
21:40brehautand thats rails etc ;) django is my day job
21:40weavejesterDjango has a lot of stuff too
21:40brehautand i feel the same way about it
21:40weavejesterthey're far more mature, so if I wanted to get a web app out fast, I'd probably use Rails
21:40weavejesterfor now
21:41weavejesterBut when I'm programming for fun
21:41weavejesterClojure is better than Ruby :)
21:41brehautthe new clojureql is also a very replacement for an ORM too :)
21:41weavejesterYeah. Clojure web development libraries are coming along very quickly!
21:42brehautyup! its exciting
21:42gfrlogI think I agree with just about everything that has been said
21:42weavejesterI use Sinatra a lot at work for APIs and stuff, and I think Compojure has already overtaken it.
21:42brehautim hoping to get a v1.1 of my xml-rpc library out along with a pingback implementation at 1.0 in the next month
21:42weavejesterIMHO of course ;)
21:43brehautheh
21:43gfrlogcompojure was named after a more superior cultural icon
21:43weavejesterWhich cultural icon was that?
21:44gfrlogI hadn't planned on taking the joke this far
21:45weavejesterhaha - ok
21:45gfrlogmy apologies.
21:46weavejesternp
21:47arbschtweavejester: hi! btw, there is a #compojure channel too :) sometimes people ask questions there
21:47brehautfor the curious: i wrote a few words about getting started with fnparse http://brehaut.net/blog/2011/fnparse_introduction
21:48weavejesterI really should keep on IRC
21:49weavejesterThus far I've tended to just use Google groups
21:50gfrlogso if I want to programmatically start/stop a ring server
21:51gfrlogthen I should ask here if anybody knows how to do that
21:51gfrlogdoes anybody know how to do that?
21:52gfrlogI'd like to be able to start one in a separate thread and then stop it later
21:55gfrlogI assume the second part is the trick one
21:56gfrlogtricky*
21:56brehautgfrlog: i think there might be an example snippet on the ring github somewhere?
21:56brehauti just kill my whole jvm ;)
21:57weavejesterThere is lein-ring
21:57weavejesterWhich can start a ring server from the console
21:57gfrlogyeah, that's how I would normally do it. I'd like to run this from within a test though.
21:57weavejesterlein ring server
21:57weavejesterAh, I see
21:57gfrlogI'm testing an HTTP client
21:57weavejesterThere's a test in the Ring repo that does that
21:58gfrlogI'll take a look, thanks
21:58weavejesterhttps://github.com/mmcgrana/ring/blob/master/ring-jetty-adapter/test/ring/adapter/jetty_test.clj
21:59weavejesterBut you can also test Ring just by sending request maps directly to the handler
21:59gfrlogI think {:join? false} is the key there?
22:00weavejesterYeah, that causes it to run in a background thread
22:00weavejesterOr rahter, not to block
22:00gfrlogweavejester: I'm not trying to test ring, I'm trying to test my client. I'm using ring to mock a rails project
22:00weavejesterah, I see
22:00gfrlogwhereas in the rails project I use functional tests to mock the clojure client
22:04brehautriddochc: excellent :) if you spot any errors or weirdness, flick me a message
22:04riddochcI've had some problems getting fnparse to work under clojure more recent than 1.2, because of some errors in its dependencies in c-contrib. I posted about it on the list a few weeks ago, didn't get a reply.
22:06brehauti figured it might be the case so i specifically mentioned clj 1.2 and fnparse 2.2.7
22:06riddochcI was going to try to use it to parse the git-fast-import format, as part of a project to convert between a mediawiki export dump and a file-based git repository of wiki pages.
22:06riddochcI'm not sure whether I'll actually be continuing that project, though.
22:08riddochcBut it looks like the coffee shop is closing momentarily, so I should be going. I'll let you know how it reads, brehaut, once I finish reading it later.
22:08brehautcheers
22:21joshua__$findfn {:test "123"} :test {}
22:21sexpbot[clojure.core/dissoc]
22:26gfrlog$findfn partial (partial partial)
22:26sexpbotjava.security.PrivilegedActionException: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$partial (NO_SOURCE_FILE:0)
22:41ttmrichterOK, I'm seeing some oddity in the 1.2 REPL. Could anybody explain to me what's happening here?
22:41ttmrichteruser=> (def six `六)
22:41ttmrichter#'user/six
22:41ttmrichteruser=> six
22:41ttmrichteruser/m
22:42brehautttmrichter: seems to be working sensible for me (other than an encoding problem)
22:42brehautuser=> six
22:42brehaut\?
22:43ttmrichterYou think displaying "m" instead of 六 is sensible?
22:43brehauti dont get m, i get \?
22:44bdeshamI'm looking for a function to merge maps together, but which will merge arbitrarily deeply
22:44bdeshamfor example, (merge-deeply {:a {:b 1}} {:a {:c 5}}) should give {:a {:b 1, :c 5}}
22:44brehautuser=> (int six)
22:44brehaut20845
22:44bdeshamdoes such a thing exist in core or clojure-contrib?
22:44hiredmanttmrichter: you are using jline?
22:44ttmrichterhiredman: Yes.
22:44hiredmanjline doesn't do utf-8 properly
22:44ttmrichterbrehaut: (int six)
22:44ttmrichterjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Character (NO_SOURCE_FILE:0)
22:45ttmrichterhiredman: Ah. Is there an alternative I could use?
22:45brehautttmrichter: see hiredman's comment
22:45hiredmanrlwrap
22:46ttmrichterIs there a quick pointer to using rlwrap for clojure's REPL somewhere?
22:47hiredmanrlwrap java …
22:48ekoontzis there a function to return the hash-map minus a given element?
22:48ekoontzreturn a hash map i mean
22:49bdeshamdissoc?
22:49bdesham(dissoc {:a 4, :b 5} :a) -> {:b 5}
22:49ekoontzcool, thanks bdesham, that works :)
22:51bdesham:-)
22:53ekoontzi tried google but no luck
22:53ekoontzactually i see it now: http://faustus.webatu.com/clj-quick-ref.html#map
23:00bdeshamto answer my own question... it looks like (deep-merge-with (fn [_ b] b) map1 map2) will do what I wanted
23:01ttmrichterhiredman, brehaut: Thanks for the help.
23:06sritchie_hey all - is there a good idiomatic way to check if an item exists in a collection? something like:
23:06sritchie_,((fn [x y coll] (some #(= [x y] %) coll)) 4 5 [[4 3][4 3]])
23:06clojurebotnil
23:06sritchie_,((fn [x y coll] (some #(= [x y] %) coll)) 4 5 [[4 5][4 3]])
23:06clojurebottrue
23:06brehautthe idiom depends on the collection
23:07sritchie_brehaut: I'm using the for macro to generate all combinations of these tiles: http://modis-land.gsfc.nasa.gov/MODLAND_grid.htm
23:07sritchie_brehaut: but I need to ignore the tiles that don't touch the globe at all
23:07anthony__What's the most elegant way to see if a string contains a substring out of a set of strings? ie "Does string a contain string b, c, or d?" It seems like I can maybe use some, but I'm not sure...
23:08sritchie_anthony__: one second, one that one
23:08brehautsritchie_: if existence is your requirement, then use a set
23:09brehaut,(#{[4 5] [5 3]} [4 5])
23:09clojurebot[4 5]
23:09brehaut,(#{[4 5] [5 3]} [23 12])
23:09clojurebotnil
23:10brehautor, if you really care about a bool ##(contains? #{[4 5] [5 3]} [4 5])
23:10sexpbot⟹ true
23:10sritchie_anthony__: (fn [str substrings] (some #(substring? % str) substrings))
23:10sritchie_brehaut: okay, that makes sense
23:12anthony__sritchie: Awesome -- I knew there was a beautiful way to do it. Thanks a lot.
23:13sritchie_no problem
23:16sritchie_brehaut: I think you joked about this some other day -- what does sexpbot do if you ask it to realize an infinite sequence?
23:17brehautsritchie_: it runs things in a timeout sandbox
23:17brehautit shouldnt ever run forever
23:17brehautthere are some cases where it doesnt alert you to the timeout failure though
23:18sritchie_brehaut: got it, I suppose there's no reason it should be expected to run longer than some sort time, given its environment
23:18sritchie_s/sort/short
23:18sexpbot<sritchie_> brehaut: got it, I suppose there's no reason it should be expected to run longer than some short time, given its environment
23:18brehautyup
23:18brehautalso its capped to never realize a large sequence to the channel
23:19brehaut$(range 10000000)
23:19brehaut##(range 100000000)
23:19sexpbotjava.lang.OutOfMemoryError: Java heap space
23:19brehautthat was surprising
23:20sritchie_busted
23:21brehautRaynes is probably going to give me some grief for that now :P
23:21sritchie_it tried to go the extra mile for you, and look what happened
23:21Raynesbrehaut: I have the heap setting fairly low. That isn't that uncommon.
23:21Raynes$kill
23:21sexpbotKILL IT WITH FIRE!
23:21RaynesYou didn't break him yet.
23:21brehautphew
23:23brehautout of curiousity, why does it blow stack? holds onto head?
23:26ekoontzanyone tried redis or mongodb with clojure?
23:26hiredmannot limiting the print level
23:31sritchie_brehaut: if I'm building a set from multiple collections, is there a way to apply across all collections?
23:31sritchie_let me give an example:
23:31sritchie_,(apply conj [] (for [x (range 2) y (range 2)] [x y]))
23:31sritchie_
23:31clojurebot[[0 0] [0 1] [1 0] [1 1]]
23:31sritchie_that works great
23:32sritchie_,(apply conj [] (for [x (range 2) y (range 2)] [x y]) (for [x (range 3 5) y (range 3 5)] [x y]))
23:32clojurebot[([0 0] [0 1] [1 0] [1 1]) [3 3] [3 4] [4 3] [4 4]]
23:32sritchie_but here, conj gets applied to all elements of the first for, plus the entire second for
23:33brehautfirst up
23:34brehaut(vec (for [x (range 2) y (range 2)] [x y]))
23:35sritchie_brehaut: okay, internalized
23:35brehautsecondly, arent you wanting sets?
23:35sritchie_yeah, I wanted to build up a collection to pass to set
23:36brehautsets support fast unions
23:36brehaut(union (set (for [x (range 2) y (range 2)] [x y])) (set (for [x (range 3 5) y (range 3 5)] [x y])))
23:36brehaut(union is in clojure.set)
23:37sritchie_that's perfect, of course that's it
23:37sritchie_brehaut: the proper function always exists
23:37brehautit does
23:38sritchie_brehaut: it's sort of odd, taking advantage of all of these recursive functions without having to write any of them
23:38brehautyup
23:39sritchie_brehaut: I've been working with scheme, too, and the worlds are very different. Though I did find something today that needed loop/recur, and a cond statement
23:39brehautcond is not infrequent in clojure
23:51cemerick~max
23:51clojurebotmaxine is http://research.sun.com/projects/maxine/
23:51cemerickoh well
23:51cemerickmaxine is cool, though
23:54Raynes$max
23:54sexpbotThe most users ever in #clojure is 317
23:54Raynescemerick: lrn2bot