#clojure logs

2011-01-29

00:00semperostheir dev's don't always get them updated in the maven repo's particularly quickly
00:01semperosmefesto: thanks, makes absolute sense
00:01mefestosemperos: np
00:58semperosreally cool that clojureql prints the query as the "string representation" of the table, without having to bind *debug* like Lau's earlier video shows
01:25joshua__&findfn 1 2 3
01:25sexpbotjava.lang.Exception: Unable to resolve symbol: findfn in this context
01:25joshua__findfn 1 2 3
01:25joshua__%findfn 1 2 3
01:25joshua__$findfn 1 2 3
01:25sexpbot[clojure.core/bit-or clojure.core/bit-xor clojure.core/+ clojure.core/unchecked-add]
01:26joshua__$findfn 4 5 9
01:26sexpbot[clojure.core/+ clojure.core/unchecked-add]
01:26joshua__$findfn 2 3 8
01:26sexpbot[]
01:32brehaut$findfn #(cons %2 %1) '() [1 2 3] '(3 2 1)
01:32sexpbotjava.lang.Exception: Unreadable form
01:32brehautlame
01:33brehautthat'll teach me to read the doc first
07:06dedeibelis clojuredocs.org down for you too? :-/
07:08raekno. the search gives a 500 though.
07:09dedeibelPrecise.
07:57fliebelhow does the mail feature of sexpbot work? just $mail name message, right?
07:58stephanmghello.
07:58fliebelhi
08:05m1ll3` /msg stephanmg yo
08:05m1ll3`lol irssi
08:07m1ll3`anybody knows where i can get this SimAnt clojure demo from rich hickey?
08:07fliebel$mail clgv I Think the answer is either x=2, y=6 or x=3, y=4. https://gist.github.com/801804
08:07sexpbotMessage saved.
08:08fliebelm1ll3`: No… sounds interesting.
08:09stephanmgmaybe we should ask kotarak.
08:10m1ll3`not on
08:11incandenzahttp://clojure.googlegroups.com/web/ants.clj
08:12__name__incandenza: this did not execute with 1.2 last i tried
08:13m1ll3`thx. i'll try it
08:13incandenzawell, that is the original example... it may need some updates by now
08:15__name__I am confused that rather many constants are program global. is this recommended?
08:16jkruegerassuming that you have two java classes, where one extends the other. if you now extend both of these classes with a protocol, is it possible to call the parent classes implementation of the extended protocol from the derived classes implementation ?
08:16fliebelhm, it opens a window with a greeen square for me.
08:16fliebeluhm, blue rather
08:20m1ll3`you need to start it from repl
08:21fliebelhah! howrks!
08:22fliebelquite a lot of cpu and threads :)
08:22incandenzayup, still works for me, too.
08:22__name__m1ll3`: why do you need to start it from repl?
08:22fliebel__name__: You need to call some things to start it
08:22fliebelsee the comment at the bottom.
08:22incandenza__name__: to start the program, you need to run the stuff in the 'comment' section at the end
08:23__name__oh
08:24fliebelI'm not exactly sure hwat these ants are trying to do, and why hey do it so randomly ;)
08:26m1ll3`great. works
08:26m1ll3`my system's screwed now lol
08:26incandenzahere's the talk where he explains it: http://blip.tv/file/812787
08:26__name__wouldn't it be a bit better to use $CPU threads for that?
08:26__name__$ANTS threads sounds like a lot of overhead
08:26stephanmgants seek for food driven by pheromones.
08:34__name__this is fun to watch
08:34fliebelincandenza: This is clojure 1.0?
08:39incandenzafliebel: not sure if it's been updated, but it still works on 1.2. the talk was from april 2008
08:39fliebelright
08:46fliebelheh, at least he decided to keep his glasses on his nose now...
10:00bartjis there a "between" function to check if a number is between two numbers
10:00bartjI want to use that instead of:
10:01bartj(or (>= n lower) (<= n upper))
10:02tonylnot that I know of
10:03__name__bartj: why or?
10:05raek,(<= 1 5 10)
10:05clojurebottrue
10:05raek,(<= 1 20 10)
10:05clojurebotfalse
10:06bartj,(doc <=)
10:06clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically non-decreasing order, otherwise false."
10:07bartj__name__: oops; yeah, and should be used
10:07raekall the <=, <, =, et.c., operations can take more than 2 args
10:07raek(< a b c d) is the same as (and (< a b) (< b c) (< c d))
10:08bartjso you mean to say:
10:08__name__bartj: (defn between [min max n] (and (>= n min) (<= n max)))
10:09raek(if (<= lower n upper) (... between ...) (... not between ...))
10:14bartjcool! thanks!
10:17bartjraek: you always show me a better way :)
10:29robonobowhenever i move a function to another namespace and try to use it at the repl, i get the error that the function is already defined, how do i fox that?
10:29robonobos/fox/fix
10:29sexpbot<robonobo> whenever i move a function to another namespace and try to use it at the repl, i get the error that the function is already defined, how do i fix that?
10:31raekrobonobo: you (ns-unmap 'dependent.namespace 'the-var) and then you can use the new one
10:31tonylmaybe ns-unmap
10:32raekyou can also call (remove-ns 'dependent.namespace) to start over completely
10:32raekbut in that case, make sure the repl is in another namespace and that you remove all namespaces that have used that one too
10:34dedeibelI am a bit confused - there is "every?" and "not-every?" and "not-any?" but no "any?", I was also missing something like "not-zero?". Any explanation for that, isn't it inconsistent?
10:34raeke.g. scenario: (ns a (:use b)). if you ns-remove b, be sure to ns-remove a too
10:34raekdedeibel: an "any?" function can be more general. instead of just returning true, it could return the item itself
10:35raekdedeibel: this function is 'some'
10:36raek,(some odd? [0 2 4 5 6 8])
10:36raek,(some #(when (odd? %) %) [0 2 4 5 6 8])
10:36clojurebottrue
10:36clojurebot5
10:36raekso, 'some' is just like "any?", but even more powerful
10:37raekbut yeah, for the sake of symmetry, one could say that not having 'any?' is a bit inconsistent
10:38raekre. complements of predicates: in these cases, it's common to use 'not' or the compound 'if-not' and 'when-not'
10:39tonylor complement
11:24robonobois there a to-the-power-of symbol in clojure?
11:24robonobolike ** in python
11:24robonobo2**3 = 8
11:30dedeibelraek: okay, thanks for the insight
11:32dedeibel:D
11:44tonylronobo: I am not sure, but there is Math/pow
11:46robonobotonyl: i know, but i don't like using long function names when doing math. Anyway, i just made a ** function that calls math/pow
11:47tonylthere is also clojure.contrib.generic.math-functions/pow
11:47tonylthat is longer
11:47tonylbut
11:47tonyly
11:47tonylyou can require or use it
11:48tonylor clojure.contrib.math/expt
12:47neilcjis there a function that takes a library and returns a list of its public variables?
12:49Raynes&(keys (ns-interns 'clojure.core))
12:49sexpbotjava.lang.SecurityException: You tripped the alarm! ns-interns is bad!
12:49RaynesOf course it is.
12:49Raynesneilcj: ^
12:50Raynesns-interns returns a map of symbols to vars from whatever namespace you pass it. Calling keys on it just gets you a list of symbols in that namespace.
12:50RaynesAs for publics...
12:51raekns-publics?
12:51Raynes&(doc ns-publics)
12:51sexpbotjava.lang.SecurityException: You tripped the alarm! ns-publics is bad!
12:51Raynes'course.
12:51raek"Returns a map of the public intern mappings for the namespace."
12:51RaynesYeah, that's what I was looking for. :D
12:52neilcjthat works, thanks guys
12:52raekthe lib has to be loaded first
12:58jaleyHi guys! I want clojure.contrib.logging calls to write to a file in /var/log - where should I be looking? I think it's picked up commons-logging from my classpath for a dependent library i'm using. is this configurable in commons-logging.properties or something? I've been googling away about apache commons logging and I just get overwhelmed with complex stuff that I don't need :/
13:07SergeyDWhat do you think of adding ":binding" into the "for" construct? Is it a bad idea because "for" is lazy and it can lead to problems when crossing thread boundaries?
13:07SergeyDBTW, what is the right place to propose language changes?
13:08SergeyDLike the above )
13:11chouserSergeyD: The google group is the place to say such things
13:12chouserI don't think I've ever wanted to do a binding inside a 'for'
13:13chouserSergeyD: you have a use case for :binding between two iteration expressions in the same 'for'?
13:17SergeyDchouser, may be I'm overusing bindings now and not using "for" the right way.
13:17SergeyDchouser, I have this: (dorun (for [i (range 4) j (range 3)] (binding [*offset-x* (* i *width) *offset-y (* j *height*)] (make-stuff!))))
13:19SergeyDchouser, I will look for the best practices of using bindings.
13:20_pyr_hi
13:43chouserSergeyD: I'd recommend using binding less frequently. Is there a reason you couldn't pass offset-x and offset-y as args to make-stuff!
13:43chouser?
13:43chouserpyr: hi
13:47SergeyDchouser, I'm exploring using bindings for cross-a-lot-of-functions parameters to make my code more concise.
13:52LauJensenMorning
13:52SergeyDEvening :)
13:54ScriptorAfternoon!
14:06bartjdoesn't re-gsub replaces globally ?
14:06bartjfor eg: to replace industries and ltd from company names, I use the following:
14:06bartj, (re-gsub #"^(industries|ltd)[\s]+|[\s]+(industries|ltd)[\s]+|[\s]+(industries|ltd)$" " " "apar industries ltd")
14:06clojurebotjava.lang.Exception: Unable to resolve symbol: re-gsub in this context
14:07LauJensenSergeyD: Scriptor Look up UGT
14:07bartjbut, I get "apar ltd"
14:08bartjwhat am I doing wrong ?
14:10bartjie. why isn't the last ltd removed ?
14:10SergeyDLauJensen, I see :)
14:16bartjit seems to me that re-gsub is not doing a "global" substitute
14:17LauJensenbartj: Go check in #perl :)
15:23robonobois there some kind of combination of some and map that returns the first element for which the given function returned true and false when none of them did?
15:25robonobowait, i can use filter and first
15:27pauldoowhere am I going wrong with this: (let [r (ref 10)] (set! r (inc @r)) @r)
15:27pauldootrying to simply modify a ref..
15:28mefestomissing dosync?
15:29pauldoomefesto: adding dosync doesn't help..
15:29mefestopauldoo: and for refs i think you need ref-set
15:30mefestohttp://clojure.org/refs
15:30pauldoomefesto: brilliant - ref-set + dosync fixed it
15:30pauldoohm.. this is interesting, because I'm only using this var/ref on a single thread
15:31mefesto,(let [r (ref 10)] (dosync (alter r inc)))
15:31clojurebot11
16:14mjg123Hi - I'm having trouble with compojure routes: deploying as a .war to tomcat with context-root of "tb", I know how to create a route which would match (eg) http://localhost:8080/tb/myresource
16:14mjg123(GET "myresource ...) or (GET "tb/myresource ...) - neither works.
16:15mjg123ahh - s/I know/I don't know/
16:15LauJensenmjg123: try moustache, everything nests, ie (app ["tb"] (app ["x"] ... ["y" .. etc))) so that all of your routes are moved up behind /tb/*
16:18mjg123nice. The answer to my original question seems to be (GET "/tb/myresource" ...)
16:21LauJensenwow you got that from reading up on moustache? Man christophes makes solid docs
16:21mjg123was multitasking
16:43jaleyhi everyone. since updating leiningen 1.3.1 to 1.4.2, i get the help printed followed by a FileNotFoundException no matter what command i'm trying to run. anyone else seen this?
16:45technomancyjaley: how did you upgrade? just "lein upgrade"?
16:46jaleytechnomancy: no.. actually i didn't know that existed so i copied the latest version of the script
16:46technomancycan you paste the stack trace? I've never heard of that happening
16:47jaleytechnomancy: ok, i just ran lein upgrade and it's fixed
16:47jaleyException in thread "main" java.io.FileNotFoundException: (No such file or directory)
16:47jaley at java.io.FileInputStream.open(Native Method)
16:47jaley at java.io.FileInputStream.<init>(FileInputStream.java:106)
16:47jaley at java.io.FileInputStream.<init>(FileInputStream.java:66)
16:47jaley at clojure.lang.Compiler.loadFile(Compiler.java:5817)
16:47jaley at clojure.main$load_script.invoke(main.clj:221)
16:48jaley at clojure.main$script_opt.invoke(main.clj:273)
16:48jaley at clojure.main$main.doInvoke(main.clj:354)
16:48clojurebotclojure bot is not immune to ,(iterate inc 0)
16:48jaley at clojure.lang.RestFn.invoke(RestFn.java:437)
16:48jaley at clojure.lang.Var.invoke(Var.java:373)
16:48technomancyI didn't mean literally paste =(
16:48jaley at clojure.lang.AFn.applyToHelper(AFn.java:169)
16:48jaley at clojure.lang.Var.applyTo(Var.java:482)
16:48jaley at clojure.main.main(main.java:37)
16:48jaley
16:48jaleythat was the trace, before it fixed
16:48jaleytechnomancy: oh. sorry. clojurebot is upset
16:49technomancyis this cygwin or something?
16:49jaleylinux. ubuntu server 10.04 (i think)
16:51jaleytechnomancy: it's working fine now. will remember there's an upgrade feature next time :)
16:52technomancyoh, what was the fix?
16:52jaleytechnomancy: i just ran the upgrade as su, that seemed to work
16:54LauJensenhehe
16:54technomancycouple weeks and we'll have .deb packages
16:55jaleytechnomancy: for leiningen?
16:56technomancyyeah
16:57jaleynice. are you sticking it in a launchpad repo thing?
16:57technomancyprobably
19:24cc_hello, quite new to clojure here. I was wondering if someone can clear up a with-open problem for me
19:24cc_(with-open [rdr (reader "project.clj")] (count (line-seq rdr)))
19:24cc_that one works fine, however for some reason if i try to take 2 instead the stream closes
19:25cc_(with-open [rdr (reader "project.clj")] (take 2 (line-seq rdr)))
19:25cc_this gives: java.io.IOException: Stream closed
19:25cc_any idea why?
19:26tomoj&(do (take 2 (repeatedly #(println "foo"))) nil)
19:26sexpbot⟹ nil
19:26tomoj&(take 2 (repeatedly #(println "foo")))
19:26sexpbot⟹ (foofoonil nil)
19:27tomojline-seq and take are lazy
19:28tomojcount forces the file i/o to happen inside the with-open by iterating through the whole line seq
19:28tomojwith (take 2 (line-seq rdr)), no file i/o happens until the seq is forced, when the repl tries to print the return value
19:28tomojbut by then with-open has returned and the reader is closed
19:28cc_ah, so i need to force evaluation with doseq?
19:29tomojdoseq would be good if you are iterating through the lines and doing something for each
19:29tomojin your example above, (doall (take 2 (line-seq rdr))) should work, I think
19:31cc_that worked. Thanks alot for clearing that up :)
21:08yayitsweidoes anyone have experience using clojure and selenium together?
23:24andyfingerhutI'd like to do (int x) where x is a primitive long, and truncate the value to the least significant 32 bits if the value is outside the range of an int. And I want it to be as fast as Java could do it, or within 2x the speed Java could. Any thoughts?