#clojure logs

2010-12-04

00:06taliosOk - now I'm even more confused. My fn works when called directly, but fails from within my deftype/defrecord. May as well go back to gen-class'ing I think. hrm.
00:46talioshrm - it would seem deftype's don't automatically load namespaces. I think sticking with good ole genclass will do.
01:56ckytalios: Hahaha, small world. :-P
01:56talios'lo cky
01:56talioslong time :)
01:56ckyIndeed. :-)
01:57talioswhere abouts are you based these days?
01:57ckyDurham, NC. (Yes, I was bummed to not have heard about Clojure Conj until a month after the fact.)
01:58ckyI hope the next Clojure Conj will be in Durham again. I'd love to attend.
01:58taliosbummer :( wish I could have gone as well. hopefully i'll get to the next one. not a cheap weekend away from Auckland tho :(
01:59ckyYeah, I know. :-)
01:59taliosw00t - tests now fail due to non-implemented code, rather than cocked up code ;)
02:00cky:-P
02:02ckyAnyway, getting late here. Good seeing you again---I'm sure we'll chat some more. :-D
02:02taliosfinally getting around to looking into migrating the clojure-maven-plugin from java to clojure itself. been too long since I've done some actual clojure code tho - i'm all rusty :)
02:03ckyWow, you mentioned clojure and maven in the same sentence! I thought only chouser does that. :-P
02:03taliosI'm the crazy fool who started the plugin :)
02:04ckyMy response was that as far as I can imagine, the one relation clojure and maven share is the letter "e". :-P
02:04ckyHahaha, nice.
02:07quilethat's the most smileys I've seen in an IRC chat room in a while.
02:09harishtellaAnyone using (vim + screen/tmux ) to develop clojure?
02:14taliosI have a smiley addition. I have for a long time.
02:26taliosmmm, is there a simple way to convert a seq into a java.util.List?
02:27RaynesI just thought of the most awesome name for a Clojure text editor.
02:27Raynessexteditor
02:28RaynesI'm going to have to write a text editor for the sole purpose of using that name.
02:28taliosheh
02:30Raynes&(java.util.LinkedList. '(1 2 3))
02:30sexpbot⟹ #<LinkedList [1, 2, 3]>
02:30Raynestalios: Like that?
02:31Raynes&(instance? java.util.List (java.util.LinkedList. '(1 2 3)))
02:31sexpbot⟹ true
02:31Raynesj.u.List is an interface.
02:32Raynes&(instance? java.util.List '(1 2 3))
02:32sexpbot⟹ true
02:33taliosdoh - my defn is returning PersistentVector not PersistentList ( which is a j.u.List )
02:33Raynes&(instance? java.util.List [1 2 3])
02:33sexpbot⟹ true
02:33Raynessexpbot just disagreed.
02:33Raynes&(type [1 2 3])
02:33sexpbot⟹ clojure.lang.PersistentVector
02:34hiredman,(supers (class []))
02:34clojurebot#{clojure.lang.Seqable clojure.lang.IEditableCollection clojure.lang.ILookup clojure.lang.Counted clojure.lang.Sequential java.io.Serializable clojure.lang.APersistentVector clojure.lang.IObj clojure...
02:34hiredman,((supers (class [])) java.util.List)
02:34clojurebotjava.util.List
02:34Raynestalios: ^
02:39taliosfood even:)
02:40Raynestalios: Doon is even better.
02:42mroesslerTrying to eliminate reflection here, but unsure how: (.withMaximumValue (.dayOfYear yearago))
02:42mroesslermy type hints dont' seem to get rid of the warning.
02:49hiredmanmroessler: are you type hinting yearago?
02:50mroesslerhiredman: Trying to, yes. Its a joda DateTime object.
02:50hiredman^DateTime yearago
02:51mroesslerhiredman: Exactly. I have (.withMaximumValue (.dayOfYear ^DateTime yearago)) but I still get a reflection warning. I was surprised.
02:51hiredmanare you sure that is where you getting the warning?
02:52mroesslerreference to field dayOfYear can't be resolved. reference to field withMaximum value can't be resolved.
02:53mroessleram I hinting the wrong thing?
02:54hiredmandunno
02:54mroesslerok. Thanks!
04:22tufflaxWhy would I want to use a keyword with two colons? I know it got something to do with namespaces but I just don't understand why I need them or what they are good for. Can anyone shed some light on that for me?
04:57LOPPwhat's the idiomatic way of reporting and reacting to errors in clojure
05:42fliebelmorning
05:47fliebelIs there any way to automatically create getters on a record? so getSomething rather than (get :something)
05:50LOPPin what way
05:51LOPPas java methods?
05:51fliebelyea
05:51LOPPor clojure fns named like that
05:51fliebelNo, Java methods. I need to implement an interface that's only getters.
05:52LOPPwould help if I actually knew how to implement interfaces in clojure :D:D:
05:53fliebelI think I can get a long way with destructuring and the applying to a reify…
05:53LOPPbut generally you can get methods that need to be implemented by using java reflection
05:55lucian_fliebel: there's stuff about that http://clojure.org/java_interop
06:19fliebelMan, this is at least the 100th time I need to apply or thread to a macro.
06:20LOPPI don;t understand
06:22fliebel&(apply reify)
06:22sexpbotjava.lang.Exception: Can't take value of a macro: #'clojure.core/reify
06:34hoeckfliebel: that makes no sense, macros run at compiletime, applying (= invoking with varargs) happens at runtime
06:34fliebelhoeck: I know that, but I keep comming up with situations where I have a seq of arguments for a macro.
06:34hoeckbut you can write a macro and there do `(reify ~@args)
06:35fliebelSure, but that is a last resort to me. I'm now on a different path.
06:38hoeckso you're writing a bean class generator and need to generate mutliple getFoo methods?
06:38fliebelbean?
06:38clojurebotdon't forget, NetBeans is evil, and i want you to tell people that whenever they mention it
06:38hoeckto me, generating a list of specs and then doing (reify ~@method-specs) sounds reasonable
06:39fliebelhoeck: I figured half of them needs a small bit of extra modification, so I'll just write a deftype manually, it's not that much work with a decent editor.
06:40hoeckwriting macros to replace a few lines of duplication is sometimes a big turing tarpit :)
06:42fliebelhoeck: Even if the code to generate the methods is longer than the getters?
06:45hoeckespecially then
06:45fliebelwait. what's a turing tarpit?
06:48hoeckoh, my last definition was that this is something where you catch programmers in, doing useless stuff because you can
06:48hoeckwikipedia disagrees with me :/
06:55fliebelhrm, can anyone tell me how getServletPath, getRealPath and getContextPath would translate from servlet lingo to ring/clojure?
07:00charliekilofliebel: talke a look at https://github.com/alienscience/compojure-war-example/blob/master/src/context.clj
07:00fliebelthanks
07:05fliebelAm I correct that the other ones are just webroot+uri?
07:10mduerksenhmm, destructuring of structs is not the same as with maps. example: (defn tst [{:keys [a b]:or {a 1}}] (println a b)) (tst {}) -> 1 nil. this works as expected. when i do the "same" with a struct...
07:11RaynesMy Das keyboard all of a sudden fritzed out. I'm going to miss that keyboard. It's going to be a long time before I can buy one.
07:11mduerksen(defstruct st :a :b) (tst (struct st)) -> nil nil
07:11mduerksenis that behavior intended?
07:17hoeckmduerksen: (struct st) -> {:a nil :b nil}
07:17hoeckmduerksen: :a has a value, nil
07:17hoeckso destructuring wont use the default you supplied
07:20mduerksenhmm, it seems to be the same when merging a struct with a map: (merge {:a 1} (struct st)) -> nil nil
07:20bartjis there an idiomatic way of iterating through a hash-map?
07:25fliebelDoes this satisfy Enumeration<String>? (.elements (java.util.Vector. ["a" "b" "c"]))
07:26bartjor in other words:
07:27bartjI always tend to create a new map like this:
07:28bartj,(time (zipmap (keys {:a 1 :b 2 :c 3}) (map #(* 10 %) (vals {:a 1 :b 2 :c 3}))))
07:28clojurebot"Elapsed time: 0.592 msecs"
07:28clojurebot{:c 30, :b 20, :a 10}
07:31mduerksendarn, got disconnected. a solution would be something like this: (merge-with #(if %1 %1 %2) {:a 1} (struct st)). but this is ugly, is there a more elegant way?
07:36fliebel&(into {} (map #(vector (key %) (* 10 (val %))) {:a 1 :b 2 :c 3}))
07:36sexpbot⟹ {:a 10, :b 20, :c 30}
07:36fliebelbartj: ^^
07:38_atoanother: (reduce (fn [m [k v]] (assoc m k (* 10 v))) {} {:a 1 :b 2 :c 3})
07:38bartj(time (into {} (map #(vector (key %) (* 10 (val %))) {:a 1 :b 2 :c 3})))
07:38bartj,(time (into {} (map #(vector (key %) (* 10 (val %))) {:a 1 :b 2 :c 3})))
07:38clojurebot"Elapsed time: 0.816 msecs"
07:38_atoand also: clojure.contrib.generic.functor/fmap
07:38clojurebot{:a 10, :b 20, :c 30}
07:38_atoI tend to prefer the zipmap one myself in practice, it's usually more elegant, even if it does create more temporary objects
07:39bartj_ato, amazingly, its faster too
07:42fliebelCan anyone tell me why this returns java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.Class? https://gist.github.com/728155
07:42bartj_ato, the fmap solution is cool too
07:42bartjthough I am a bit non-plussed asto why only the value of the map-entry gets passed
08:22LajlaSo like
08:22Lajlawhy doesn't map make a map.
08:23LajlaI always wondered that
08:24Lajla&(map #(* % %) [1 2 3 4 5])
08:24sexpbot⟹ (1 4 9 16 25)
08:30Lajla&(map #(* % %) {:I 2 :worship 4 :his 5 :shadow})
08:30sexpbotjava.lang.ArrayIndexOutOfBoundsException: 7
08:30Lajla&(map #(* % %) {:I 2 :worship 4 :his 5 :shadow 5})
08:30sexpbotjava.lang.ClassCastException: clojure.lang.MapEntry cannot be cast to java.lang.Number
08:34fliebel(map type {:a 1 :b 2})
08:34fliebel&(map type {:a 1 :b 2})
08:34sexpbot⟹ (clojure.lang.MapEntry clojure.lang.MapEntry)
08:35tscheiblis there some function similar to 'filter' which does return let's say a vector instead of a lazy sequence which can accept side-effects in the predicate function
08:35tscheibl?
08:36fliebelLajla: So it returns MapEntries rather, which you can put back into a map if you want to.
08:36LOPPwhat the hell
08:36LOPPof course it enumerates entries
08:36LOPPjust like java map
08:38fliebel&(doc val)
08:38sexpbot⟹ "([e]); Returns the value in the map entry."
08:42tscheibl..hmm.. will try reduce instead of filter
08:48fliebelI guess chouser was right… I'm not even touching FastCGI yet, and already seeing heisenbugs. :( I got a deftype that works fine when I paste it in the repl, but gives a classcastexception when I require it. There is nothing but the deftype and a ns declaration in the file.
08:52LOPPheisenbugs?
08:53fliebelLOPP: I only learnt about them yesterday… Bugs that dissapear as soon as you try to look at them.
08:54LOPPwell in this case they just don't appear in repl
08:54LOPPso you need a debugger or something]
08:54fliebelright
08:54LOPPor so I'm guessing
08:57fliebelLOPP: You can think of any case why the repl might work and the code not?
08:57LOPPnope, I'm not knowledgeable about clojure internals
08:58tscheibl..ok.. 'reduce' saved my day :)
08:58LOPPclojure is relatively new so it's bound to have bugs
08:59LOPPlol I can't even find a good eclipse plugin for it
09:01LOPPI wonder what cemerick is using though
09:02lucianLOPP: i doubt a lot of lisp people are using eclipse
09:04fliebelLOPP: I think it was because my name used hyphens?
09:05LOPPreally?
09:05LOPPthat's just silly
09:05LOPPI saw cemerick use eclipse on one of his videos
09:06LOPPand I was wondering what he was using
09:06fliebelIt seemingly took my camelcased name, and turned into a hyphenized name. I can't believe my own eyes...
09:06LOPPI used some eclipse plugin advertised on clojure.org and it worked poorly/didn't work
09:06fliebelLOPP: Might be ccw?
09:06pdk`lisp folk seem to be mostly emacs evangeists
09:07LOPPyeah I'm using clojure box which is basically emacs
09:07LOPPbut I'm used to eclipse
09:07LOPPbut that eclipse plugin didn't support autocomplete or anything good
09:07LOPPwait fliebel, you defined the type as a camel case name
09:08LOPP?
09:08fliebelwell, I don't know what I'm doing, but Clojure is giving me crap back.
09:09fliebelI did a deftype using a camelcased name, and it's just not there when I require it.
09:10bartjare the values returned by keys and vals always in the correct sequence order of the key,val of the map?
09:11fliebelbartj: Yes, I believe so.
09:11bartjfliebel, is there *any way* there could be a goof-up ? I too am not 100% sure.
09:12fliebelbartj: I'm 100% sure someone who know said they are guaranteed to be in hte right order.
09:13bartjfliebel, ok, thanks!
09:15fliebeltechnomancy: fliebel: keys and vals is guaranteed to always be consistently ordered when called on the same map
09:15fliebelbartj: ^^
09:18mduerksenbartj, fliebel: the same question came into my mind recently. i'm still not sure it is a good idea to depend on the consistent ordering. even if the current implementation guarantees this, i would argue that it isn't guaranteed idiomatically. after all, a map is not necessarily ordered.
09:20bartjmduerksen, thank you. yes, depending on it does seem flaky
09:21fliebelI don't agree about that. There is not something like a random ordering, it's just not alphabetical or something.
09:23fliebelSo even a hash map will always return the same order for the same map. And that is the only promise you get. as soon as you change a tiny bit of the map, nothing is guaranteed anymore.
09:45raekfliebel: did you find the Heisen-bug?
09:46fliebelraek: Well, after moving back and forht a few lines, it just stopped happening.
09:47raekah, now it really starts to sound like quantum mechanics!
10:04mduerksenfliebel: i'm sorry, my connection seems to be unreliable, did you respond to my last post?
10:05Raynes<fliebel> I don't agree about that. There is not something like a random ordering, it's just not alphabetical or something.
10:05Raynes<fliebel> So even a hash map will always return the same order for the same map. And that is the only promise you get. as soon as you change a tiny bit of the map, nothing is guaranteed anymore.
10:06Raynesmduerksen: ^ That's what he said after you last spoke.
10:08mduerksenRaynes: thank you.
10:11mduerksenfliebel: it's not a random ordering, true. but i still don't see why the ordering of 'keys' has to be the same ordering of 'vals' in terms of what the function name promises. to me, it feels "wrong"
10:13BelafHi everybody. Is clojure.contrib.duck-streams supposed to work in Windows?
10:13raekBelaf: I suppose so
10:14raek(since 1.2, most of the stuff in duck-streams is available in clojure.core and clojure.java.io. prefer these for a new project)
10:16BelafI had an issue with it today... oh, thanks, let me check if the one in clojure.core or clojure.java.io works better.
10:18BelafIt was about file-str, by the way. Did it move to another namespace also?
10:19raekthis does something very similar: http://clojuredocs.org/clojure_core/clojure.java.io/file
10:20BelafThanks, I'm going to check it.
10:20raekyou pass it the path segments as arguments, and it returns a file(path) that uses the directory separator of the platform
10:21p_l|homeoooh, somone tried to make a portable pathname system? :)
10:22BelafThe issue with c.c.duck-streams/file-str is actually a bug in replacing the file separator by means of replaceAll. It was already mentioned in this same channel in February this year.
10:24fliebelDoes anyone know what sendError is supposed to do to a servlet response?
10:31BelafI see that clojure.java.io/file doesn't attempt to translate [/\\] to File/Separator as file-str did, so it might be safer... I'll need to wait and be back on windows to test this :-(
10:33raekio/file is simply a wrapper for java.io.File: http://download.oracle.com/javase/6/docs/api/java/io/File.html
10:33raek"User interfaces and operating systems use system-dependent pathname strings to name files and directories. This class presents an abstract, system-independent view of hierarchical pathnames."
10:34fliebelI believe they use a colon in the abstract stuff?
10:34BelafAllright. Thanks raek, this seems what I was looking for.
10:34raekI don't think it is string based
10:35raekuntil it is needed in OS calls
10:44p_l|homeBelaf: most portable pathname systems don't use string representaion
10:44p_l|home*representation
10:44p_l|homeCL's are struct with a list for directory path
10:47BelafI see. I was using file-str as it was already in duck-streams and I was using duck-streams/copy already. It was working fine in linux, but when I tried it on windows... the clojure.java.io/file solution seems much better. Thanks
10:48p_l|homeBelaf: pathnames are a hell. Always use a portable variant if it's available, doubly so on Java where you really don't know where your app will end up working
10:48p_l|homeand I've got access to at least one machine that requires all slots in *CL* pathname spec (which is I think the most broad ever) and still has up-to-date JVM
10:49Belafwhat do you mean by "all slots in *CL* pathname spec" ?
10:51p_l|homeBelaf: Common Lisp pathnames are structs, which have slots that contain host, device, directory, filename, extension and version :)
10:52p_l|homeand yes, I've got access to machines that have all of those *used*
10:52BelafOh, I see. and the number of slots is limited.
10:53p_l|homeBelaf: well, limited by the definition of the struct in question. The directory slot contains a proper list of directories
10:54BelafI see that clojure.file.io also provides a copy function... I can drop duck-streams altogether, then :-)
11:20bartjRaynes, have you hosted the Clojure quiz some-place?
11:46canderaAnyone know why, when I lein uberjar this ultra-simple program (https://gist.github.com/728308) and run it via java -jar repro-1.0.0-SNAPSHOT-standalone.jar foo.txt, it fails with a "java.lang.NoClassDefFoundError: clojure/contrib/io/Streams" ?
12:07raekcandera: are you using matching versions of clojure and contrib?
12:07raekoh, saw the additional comments in the gist
12:08raekyou could use clojure.java.io/reader
12:09raekbut it is wierd that you get the error
12:28kaiserhi, what's the time complexity of conj in a hash-set?
12:28kaiseris it constant?
12:29raekwell, "pretty much". :) ir
12:29raekit's O(log32 n)
12:30kaiserhmmm...how do you know, raek?
12:31raekso if you have about 4000000000 entries in your hash-set, conjing will have to traverse about 6 or 7 levels
12:31raekit is implemeneted as a tree with a branching factor of 32
12:31raekkaiser: http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/
12:32kaiseris there a way to put something in a hashset in constant time?
12:33raekno, O(log32 n) is what clojure provides.
12:33kaiserdisj in hash-sets are log32 too?
12:34raekwhich is in practice very close to sontant time (since you cannot have more than 2^32 hash values)
12:34raekyes
12:35kaiserhmmm...i make a lot of conj operations...
12:35raekclojure's persistent data structures are inteded to be used as if their operations are constant time
12:35kaiseri understand...
12:37kaiserthe 32 in log32 means that y = log32N => 32^y = N
12:39raekyes
12:39kaiserthanks
12:41raekin the screencasts, Rich Hickey himself explains the design choices of the data structures: http://clojure.blip.tv/posts?view=archive&amp;nsfw=dc
12:41kaisergonna see, thanks raek
12:42raek"Hammock-driven Development" from the first conference is up now too, I see...
12:44mtyakacandera: This looks like a leiningen bug. Are you using 1.4.0? You might want to give 1.3.1 a try.
13:52LOPPis there some library I could use to parse HTML in a simiral fashion to XML parsers?
13:53raekLOPP: tagsoup is a java lib that has the api of a xml parser
13:53LauJensenLOPP: Dont look for anything other than Enlive
13:53raekLOPP: it is very often used throught Enlive
13:53raek:)
13:53wtetzneryou could also try NekoHTML
13:54raekLOPP: in case you have seen the output from clojure.xml: Enlive uses the same format
14:08LOPPok
14:14hippiehunterIs there something similar to if-let that takes more then 2 forms in its binding vector?
14:14hippiehunterwhile still checking the value that is
14:19LOPPI don't get it
14:19LOPPif sequences are null when there are no more items
14:20LOPPwhat does rest on an empty list return
14:20LOPP&(seq [])
14:20sexpbot⟹ nil
14:20LOPP&(rest (seq []))
14:20sexpbot⟹ ()
14:20LOPPweird
14:20tonylhippiehunter: as far as I know, there isn't
14:21LOPPwhat kind of seq is ()?
14:21tonyl(class '())
14:21tonyl&(class '())
14:21sexpbot⟹ clojure.lang.PersistentList$EmptyList
14:22tonylrest doesn't check ahead if there is anything in the list, next does
14:22tonylthat is my understanding
14:31LOPPbut I wasn't using list
14:31LOPPI was using sequences
14:31LOPP&(class (rest (seq [])))
14:31sexpbot⟹ clojure.lang.PersistentList$EmptyList
14:31LOPPhm
14:31LOPPweird
14:35raekLOPP: sequences may not be nil when there are no elements
14:37raekfor instance, until (lazy-seq (when (zero? (rand-int 2)) (list "foo"))) is forced, it has not "decided" whether it should be nil or ("foo")
14:37raekhowever, if you call seq on something empty, you always get nil
14:37raek() is the empty (persistent) list
15:44dnolenLogos 0.1, https://github.com/swannodette/logos, fun stuff. Now to read up on Skew Binary Random Access Lists and Finger Trees.
16:47psantaclarahas anyone played with aleph?
16:52digashi am building binary protocol client based on aleph
16:54psantaclaradigash: excellent. I'm just trying to get the hello-world example from github working and encountering problems.
16:54psantaclara(use 'lamina.core 'aleph.http)
16:54psantaclarasamx:
16:54psantaclara(defn hello-world [channel request]
16:54psantaclara (enqueue channel
16:54psantaclara {:status 200
16:54psantaclara :headers {"content-type" "text/html"}
16:54psantaclara :body "Hello World!"}))
16:54psantaclara(start-http-server hello-world {:port 8080})
16:54psantaclarai took that directly from the readme and it is throwing an exception somewhere in the aleph code base
16:55digashi am not using the http server part, but what is the exception?
16:56psantaclarajava.lang.IllegalArgumentException: No implementation of method: :enqueue- of protocol: #'lamina.core.channel/Channel found for class: aleph.core.channel$splice$reify__2991
16:56LOPPguys, what's the best way to handle errors in clojure
16:57LOPPI heard lisp has much better mechanisms for that than just simple exceptions
16:57psantaclarathe hello-world fn isn't receive a "channel" as its first argument but rather a aleph.core.channel$splice$reify__2991
17:00digashpsantaclara: hmm, got to run but i used quite a few parts of aleph and have not ran into problems, it is evolving quite quickly so use the latest and greatest if you can
17:01psantaclaradigash: roger that. Thanks. :)
17:01digashi usually use the tcp to establish pipeline-channels and then just enqueue or read-channel etc.
17:05psantaclaradigash: I'm ultimiately interested in web sockets but i thought i would try a vanilla get request first.
17:12psantaclaraoh, nice, i just had to use the more recently github clone. the hosted version of aleph on clojars is old.
18:25raekLOPP: there are multiple solutions. you could return special values, throw exceptions (you need gen-class to make your own types, though), or use a lib (which can give you even more freedom), such as c.c.error-kit and c.c.condition
18:59vIkSiTlo all
19:00vIkSiTi'm trying to return a value based on an input to a function. so something like (defn myfn [va] (cond ((= (:a val) 1) <assign local variable to use after the cond>))))
19:01vIkSiTfor instance, i may choose to return the contents of a file or the output from another function
19:01vIkSiTbut i'm not sure how to assign local variables using the cond
19:01vIkSiTideas?
19:02raekyou would want to do something like (defn myfn [val] (let [x (if (= (:a val) 1) ...foo... ...bar...)] ...))
19:02raekin clojure, you cannot change local variables
19:03hiredmanvIkSiT: cond also doesn't take pairs like that, check the docs
19:03raekso they even aren't called "local variables", but simply "locals" or "local values"
19:03vIkSiTaaah right, i can prolly use it like that.
19:03vIkSiThiredman, oh hmm. let me check
19:04raekthe diff from CL and scheme is that you drop the grouping parens in clojure
19:06vIkSiThiredman, this seems to work? http://paste.lisp.org/display/117338
19:11raekvIkSiT: in that paste, you didn't have the extra pairs of parens that you had in the snippet you wrote here
19:11vIkSiTaah
19:11vIkSiTgotcha
19:13vIkSiTbtw, has anyone here used aleph?
19:14vIkSiTI'm trying to figure out how to stop the server (and restart it, to uptake new code)
19:15raekvIkSiT: if you replace (start-http-server hello-world {:port 8080}) with (start-http-server #'hello-world {:port 8080}) in the hello world example, you don't need to restart the server
19:15vIkSiTaah
19:15vIkSiTwhy is this?
19:16vIkSiTi see. it re-evals the hello-world fn each time?
19:16raekwhen you call the start-http-server function, the current value of hello-world is pulled out
19:16vIkSiTgreat
19:16raek(i.e. the current function it holds)
19:17raekwith the var-quote (#'), it will give the var itself to start-http-server
19:17raekvar objects happens to implement the function interface (clojure.lang.IFn) and does so by calling the contained value as a function
19:18vIkSiTthis is useful
19:18raekso, if you re-evaluate the defn for hello-world, the server should change (if you are using the modified version)
19:18vIkSiTlet me try this out
19:18raek(well, the server itself does not change per se)
20:24vIkSiThmm, i'm trying to read n lines from a file, pass each line to a functiona call, and store the resultant map into a bigger map
20:24vIkSiTsomething like (-> (read-file "filename") (myfn)) ..
20:25vIkSiTbut whats the best way to "accumulate" these results?
20:37brehautvIkSiT: that would depend on what you are going to do with the results surely?
20:38brehautbut using an (into {} (map key-val-generating-mapping input-seq))
20:38brehautwould be a good start
20:38brehautkey-val-generating-mapping would return a vector of the key for the overall map and a value which is the resultant map you talked about earlier
20:43brehautvIkSiT: http://clojuredocs.org/clojure_core/clojure.core/into
20:49vIkSiTbrehaut, ah thanks for the info
20:49vIkSiTwas doing something similar: http://paste.lisp.org/display/117341
20:49brehautvIkSiT: no prob
20:49vIkSiTbut the resultant value is a lazyseq, and i'd like it to be a map of maps
20:49vIkSiTideas?
20:49brehautinto {} should do that
20:49vIkSiThmm
20:50brehautinto pours whatever seq you provide it into the first argument
20:50vIkSiTright
20:50vIkSiTso in the paste above, into should pour {:entry line} into {}
20:50brehautyup
20:51vIkSiTbut lets say I want v to look like : {:mainresults [{:entry line} {:entry line} ... ]}
20:52vIkSiTbrehaut, how would that happen here?
20:52brehautsorry im a little confused what you mean there
20:53brehautalso looking at your snippet, your use of into unnecessary
20:53vIkSiTbrehaut, let me explain. i'm basically reading a number of lines, and i'd like to convert this to json..
20:53brehautcan you make a snippet of the input and what you want as output please
20:53vIkSiTso i need a map of the form : {:main [{:1 a} {:2 b} ... }
20:53vIkSiTsure
20:55vIkSiThttp://paste.lisp.org/display/117341#1
20:56rata_vIkSiT: http://nakkaya.com/2010/06/15/clojure-io-cookbook/
20:57rata_but why do you want every line to be in one map?
20:57rata_that's kind of weird
20:58rata_*each line
20:58rata_you better put them all in just one map
20:58vIkSiTrata_, each line is an entry, and the map contains say, its ID for now (and later on other attributes from parsing that line)
20:58rata_or make a vector, that's already indexed by number
20:58vIkSiTfor instance, I could do something like:
20:59brehautsomething liek
20:59brehaut(defn f [name]
20:59brehaut {:main (vec (zipmap (map keyword (iterate inc 1))
20:59brehaut (read-file name)))})
20:59brehaut?
20:59vIkSiThttp://paste.lisp.org/display/117341#2
20:59brehautwait no thats wrong too
21:00vIkSiT(assoc {} :entries (vec (let [v {}]
21:00vIkSiT (for [line lines]
21:00vIkSiT (assoc v :entry line)))))
21:00vIkSiTi do that right now
21:00vIkSiTbut i wasn't sure how to change :entry to the counter
21:00vIkSiTsuch that it increments each time
21:00brehautvIkSiT: do you understand immutable datastructures?
21:00vIkSiTindeed
21:00vIkSiTooh. zipmap
21:02brehautvIkSiT: to start, you shouldnt need to use assoc with an empty map literal there; just use a map literal
21:02vIkSiTbrehaut, agreed
21:02brehaut(in both places)
21:06vIkSiTbrehaut, how were you converting int to a keyword?
21:07rata_vIkSiT: that code is weird and the output you want is strange... I really don't get why you want maps that have just one key-value pair
21:07brehautvIkSiT: i agree with rata_ that its strange
21:07rata_vIkSiT: instead of using a map, you should be using a vector
21:07vIkSiTrata_, brehaut - each line is actually transformed into a map as well on read
21:08brehaut {:main (vec (map (fn [k v] {(-> k str keyword) v}) (iterate inc 1) (read-file name)))})
21:08brehautthats closer to what you want
21:08brehautits pretty horrible
21:08vIkSiTso it would look like : {:1 {:account "1" :name "abc" :foo "bar"}}
21:08vIkSiTyes, i can also have a vec of maps
21:08rata_vIkSiT: you should transform lines into values, not maps, unless you want each line to be a map of more than just one key-value pair
21:09vIkSiTrata_, the latter..
21:09vIkSiTi'm basically parsing each line of a log file
21:09rata_ok... then, a vec of maps is ok
21:10rata_so (vec (map generating-map-fn (read-file filename))) is all what you need
21:10rata_and generating-map-fn is a function that receives a string and returns a map
21:12vIkSiTrighto
21:12brehautim lost now :P
21:12brehautglad you two seem to have worked it out
21:12vIkSiThehe
21:13vIkSiTthere's one issue still
21:13vIkSiTlets say the file i read is really long
21:13vIkSiTduck-streams/read-lines may consume all memory.
21:13rata_then you use the second example in the link I gave you
21:13vIkSiTis there a way to lazy-read the file?
21:13vIkSiTah
21:16vIkSiTbtw, do you guys use clojure on production systems?
21:17vIkSiTor mostly as a hobby, just yet?
21:17brehautvIkSiT: what counts as a production system? http://brehaut.net/ is running on clojure but its entirely small fry
21:17vIkSiTbrehaut, ah, sure. i mean data intensive stuff, clusters, et al.
21:17vIkSiTi know flightcaster.com and runa.com run it, but was curious if someone here does it
21:18brehautwell a bunch of the people who have built those system do hang out here
21:18brehauti know that backtype guys do
21:19rata_vIkSiT: I'm developing a Clojure library to simulate biological systems... don't know if that's what you mean
21:19vIkSiTah yes, i know nathanmarz..
21:20rata_what's the most similar function to Python string's split?
21:20vIkSiTrata_, cool
21:20vIkSiTi use .split mostly
21:20rata_ok =)
21:20vIkSiTalso re-seq
21:20brehautrata_ clojure.string/split ?
21:21brehaut(1.2.0 onward)
21:21vIkSiTinteresting.
21:21rata_thanks =)
21:22brehautclojure.string brings across stuff previously in contrib.strutils i believe
21:36brehautyikes, a clj quick reference ive found is 56 pages
21:37rata_good bye guys... see you soon
22:03hippiehunterhow do I make an array of strings for java interop?
22:04danlarkin(into-array ["foo" "bar"])
22:05hippiehunterdoesnt that make an array typed as object?
22:05danlarkinwhy don't you try it and find out
22:07hippiehunter(into-array ["bla"]) works but (array (vec ("hello"))) doesnt
22:07hippiehunterinteresting
22:08danlarkinthat's because vec doesn't do what you think it does
22:08hippiehunteryeah i gathered that
22:08danlarkin,(vec "hello")
22:08clojurebot[\h \e \l \l \o]
22:08hippiehunter,(vec ("hello"))
22:08clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
22:09danlarkinthere you're trying to invoke the string "hello"
22:09danlarkinperhaps you mean to quote that list
22:09hippiehunteryeah i did
22:09hippiehunter,(vec '("hello"))
22:09clojurebot["hello"]
22:09rata_hi
22:10danlarkininto-array doesn't need to take a vector, any collection will do
22:11danlarkinif you already have a list you can just pass that in, no need to vec it
22:13rata_do you know how to store time intervals and associated data to then be able to efficiently find within which time interval a certain time is?
22:23vIkSiThmm, has anyone here used aleph?
22:23vIkSiTi was wondering how i would update a channel in real time, in order to stream a series of numbers to the page?
23:45rata_chouser: I'm seeing your Conj talk about finger-trees... they are amazing!! =)
23:46brehautrata_: got a link for that?
23:47rata_brehaut: http://talk-finger-tree.heroku.com
23:47brehautthanks
23:54rata_I think counted-sorted-set is exactly what I need =)