#clojure logs

2010-07-26

00:35brehautpresumably there is a library in clojure or contrib to make walking directories and files easy?
00:35brehaut(i also presume im not smart enough to have found it yet)
00:37brehautignore me, file-seq appears to be it
00:39technomancyfile-seq is sweet
00:40technomancydaaku: things get added to Clojure, but there has only been one purposeful instance of breakage so far since 1.0
01:02brehautdoes the #(... %) macro have any way to type hint the % outside of converting to an (fn ..) form ?
01:14BahmanHi all!
01:56vu3rddtechnomancy: ping
01:57vu3rddtechnomancy: I am facing some problem with the lein if I compile the lein uberjar myself.
01:58vu3rddany help to fix it will be great! I sent the error to the list a couple of days ago
01:58daakutechnomancy: cool. that makes me hopeful :)
02:00daakui just noticed i wrote this, and seemed like a common thing i write (the 3x get part): (nil? (get (get (get req :cookies) "fbc") :value)) -- is there a better way to write this? (things in the middle may be nil)
02:02hiredman(-> reg :cookies (get "fbc") :value nil?)
02:02slyrusvu3rdd: did you update lein recently? ISTR some uberjar bustage being fixed recently
02:02daakuhiredman: cool, thanks
02:03OliverUv(nil? (reduce #'get (req :cookies "fbc" :value)))
02:03hiredmanOliverUv: this isn't common lisp
02:04OliverUvthen implement reduce
02:04hiredmanif you want to use a function in reduce you just use it
02:04OliverUvit is fairly straight forward
02:04hiredman(reduce get …
02:04OliverUvah
02:04hiredmanyour list there at the end will be evaluated as a function call
02:04OliverUvoh yeah I just remembered, ? for scheme, p for cl
02:05OliverUvyou are right about that too
02:05hiredman,(macroexpand-1 '(-> reg :cookies (get "fbc") :value nil?))
02:05clojurebot(clojure.core/-> (clojure.core/-> reg :cookies) (get "fbc") :value nil?)
02:05OliverUvoh damn, I was in #clojure, I thought I was in #lisp
02:05OliverUvsorry
02:06hiredman,(macroexpand-1 '(clojure.core/-> (clojure.core/-> reg :cookies) (get "fbc") :value nil?))
02:06clojurebot(clojure.core/-> (clojure.core/-> (clojure.core/-> reg :cookies) (get "fbc")) :value nil?)
02:10cobol_experthi, what's the syntax for defn default parameter values?
02:10cobol_expertif there is one
02:11dsantiagoThere isn't one.
02:12cobol_expertdang
02:12dsantiagoThough you could define multiple versions of the function with different arities that behave that way.
02:13cobol_expertthanks, for some reason I thought defn provided that
02:33vu3rddslyrus: I am using the released lein version 1.2.0 to create a uberjar of the latest lein
02:34vu3rddslyrus: I created a new uberjar of lein (current git master) and tried it. Still same problem
02:34vu3rddit is something to do with maven-ant-tasks
02:36vu3rddOk, problem goes away if I change java invokation in lein with -noverify option. Very wierd..
02:41hiredmanwhy are you uberjaring lein?
02:56vu3rddhiredman: I am trying to build lein itself.
02:57vu3rddhiredman: The main goal is to create a debian package of lein. But debian has more recent versions of ant etc. So I wanted to create a workspace where I can play with lein itself
03:20cais2002hi guys, for logging, is it recommended to use clojure.contrib.logging ?
03:31Lajlacais2002, not sure, but I recommend that you Worship His Shadow.
03:31Lajlacais2002, also, if I really asked you nicely and gave you a hug, would you eat my eyeball in front of me?
03:38raekcais2002: I haven't used c.c.logging myself, so I don't have any good pointers except for searching the google group
03:39raekmaybe it can get you at least one a little bit on the way
03:39raekhttp://groups.google.com/group/clojure/search?group=clojure&q=logging
03:40cais2002raek: thanks, I just used it and it is pretty intuitive to use
07:13sergey_miryanovhi clojurians!
07:14sergey_miryanovwhat heard about status of last-var-wins? it's very annoying to restart repl for each file reload :/
07:31zmyrgelany idea what is wrong as I get IllegalArgumentException when I try to run default conjure site
08:14aldebrnSo I can't add a docstring to defmulti's?
08:16rhudson? (doc defmulti) says you can
08:18aldebrnAha, sorry for the dumb question. Much appreciated rhudson
10:26sid3khello clojure!
10:37chouserhello sid3k!
10:43Rayneschouser: PING!
10:43chouserRaynes: hello
10:43RaynesThat is the 4th time I've pinged you in 4 days. :p
10:43Rayneschouser: Hold on, give me a second to remember what I wanted to whine about.
10:43chouserheh
10:45Rayneschouser: Found it. In the latest MEAP, section 8.1.4, first code example.
10:46RaynesThe example does this: (:use (clojure set xml))
10:46Raynes(:use [clojure.test :only (are is)])
10:46RaynesIs there a particular reason for that?
10:46RaynesIt could be (:use (clojure set xml) [clojure.test :only (are is)])
10:50chouserRaynes: right, either would be fine. The indentation is perhaps a little cleaner this way.
10:51chouserwe'll look at it.
10:51fogusRaynes: That specific example has an accompanying discussion that walks down the line explaining what each directive does. The separation sort of feel out of the discussion.
10:52chouserfwiw, you can report future things on the forum, rather than waiting for fogus or me to show up here
10:52RaynesI see. Do you demonstrate the single-use style anywhere else in the book?
10:52chouserhttp://www.manning-sandbox.com/thread.jspa?threadID=38170&tstart=0
10:52RaynesIf not, it's probably a good idea.
10:52RaynesI would, but it didn't really feel like a *report* and it certainly wasn't important.
10:52RaynesIt was really just a question about whether there was a specific reason for it.
10:52Raynes:)
10:53cais2002Raynes: still remember we talked about a replace-key functions the other day? I just realized that there is one pre-defineed function that does that
10:53cais2002-> (doc clojure.set/rename-keys)
10:53cais2002,(doc clojure.set/rename-keys)
10:53clojurebot"([map kmap]); Returns the map with the keys in kmap renamed to the vals in kmap"
10:53Raynescais2002: Oh, good. :)
10:54RaynesHrm.
10:54cais2002but the second param kmap has to be a real map
10:54RaynesWhere oh where did my sexpbot go.
10:54cemerickchouser: wasn't there a ticket open for moving clojure.contrib.lazy-xml/emit to clojure.xml?
10:55fogusRaynes: We added much more about namespaces that is not included in the latest MEAP update, so yes. Although I do not know when you will see it. :O
10:55RaynesMethinks Licenser's server restarted or something.
10:56chousercemerick: I've suggested it, but I'm not sure I've ever heard rhickey voice any support.
10:58RaynesOh, it just dropped on freenode. Odd. I really need to add reconnection support to irclj.
10:59Raynes-> (clojure-version)
10:59sexpbot=> "1.2.0-beta1"
10:59cemerickchouser: I remember there being concerns about more hosty dependencies getting into those "core" namespaces. clojure.java.xml coming soon, perhaps.
10:59BahmanHi all!
11:00RaynesBahman: Hello there!
11:00Raynes:)
11:01Scriptorhey Bahman
11:01chousercemerick: hm, perhaps. though the api provided by c.c.lazy-xml is fully wrapped, I think, so could be implemented on other hosts without API change.
11:01BahmanHi there Raynes and Scriptor!
11:05cemerickfogus: which changes? Last I see are from the 16th?
11:07foguscemerick: saw some ticket updates about clojure.xml/emit earlier today.
11:12slyrusi don't suppose I can use recur and a lazy-seq together can I?
11:13chouserslyrus: depends on how. :-)
11:16slyrusfair enough...
11:17chouser'range' for example uses both lazy-seq and loop/recur
11:18slyrusI see I can put the lazy-seq in the args of recur. I can't figure out how to get the lazy-seq around the recur call. not sure if that's even a good idea.
11:18slyrusthe function in question is my breadth-first-traversal routine, or the bft-recur variant anyway: http://github.com/slyrus/shortcut/blob/master/src/shortcut/graph.clj#L163
11:19chouseryou can't have a recur inside a lazy-seq form that jumps to something outside the lazy-seq form.
11:19chouseror that tries, because it won't work. :-)
11:19slyrusthat's what I thought :)
11:20slyrusnow I have to decide which is worse, not using recur or not returning a lazy-seq...
11:27chouserslyrus: if what you're trying to do makes sense, there's probably a way to arrange the code so you can use both.
11:28slyrusyeah, I can put the lazy-seq call in the args to recur. not sure if that makes sense though! I'm going to punt for the moment.
12:13lozhPut my first reasonably big chunk of clojure at http://gist.github.com/490689 would welcome any feedback on style/simplfication etc
12:16cemericklozh: the in-ns is superfluous (implied by ns). Put your imports in the ns declaration (e.g. (:import (java.awt Robot ...))).
12:17lozhthanks
12:17cemerickWithout getting into what you're actually doing, those are the only obvious things. :-)
12:22Rayneslozh: Also, you can supply a docstring to your ns rather than make all of the above comments.
12:23lozhAh, I was just copying clojure .core, didn't realise that, thanks
12:23RaynesYou don't have to. It's usually something libraries do. Just an idea. :D
12:24Rayneslozh: Here is an example: http://github.com/Raynes/clj-github/blob/master/src/clj_github/gists.clj
12:24edbond'lein deps' delete all in lib/ dir?
12:25lozhRaynes: I see what you mean, thanks
12:25edbondwhere is the safe place to put org.apache jars?
12:25Raynesedbond: In leiningen 1.2, I'm fairly certain Leiningen does an implicit clean beforehand.
12:25Raynesedbond: A maven repository.
12:25RaynesIf you're using Leiningen for dependency management, you shouldn't be using jars that aren't in a maven repository.
12:25RaynesIt kills the whole point.
12:26Raynesapache stuff is in maven central. If you run into some jar that you need, and it's open source, you can upload it to clojars if it isn't already in a maven repo.
12:27edbondRaynes: how to search for something in maven central?
12:29Rayneshttp://mvnrepository.com/ is a maven repository search engine.
12:29RaynesThere are others.
12:30edbondRaynes: thanks a lot
13:22jannewhat's the easiest way to map [1 2 3] into [{:foo 1} {:foo 2} {:foo 3}] ?
13:22KirinDaveProbably (map #({:foo %1}) [1 2 3])
13:23KirinDave,(map #({:foo %1}) [1 2 3])
13:23clojurebotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: PersistentArrayMap
13:23janneyeah, I tried that but it doesn't work
13:23Nikelandjelo,(map (fn [a] {:foo a}) [1 2 3])
13:23clojurebot({:foo 1} {:foo 2} {:foo 3})
13:23jannehmh
13:24KirinDaveWeird.
13:24jannewhat's wrong with that
13:24janneyeah, really weird
13:25hiredman,(macroexpand-1 '#({:foo %1}))
13:25clojurebot(fn* [p1__499900#] ({:foo p1__499900#}))
13:25KirinDaveAh
13:25KirinDaveThere's the problem. :)
13:25KirinDave#() isn't equipped.
13:30Nikelandjelo,(map #(hash-map :foo %) [1 2 3])
13:30clojurebot({:foo 1} {:foo 2} {:foo 3})
13:35fogus,(for [i [1 2 3]] {:foo i})
13:35clojurebot({:foo 1} {:foo 2} {:foo 3})
13:38cddrcan leiningen be used to build projects which rely on non-jvm languages?
14:18technomancycddr: well, it's turing-complete, so ...
14:18technomancybut I don't think anyone has done much of that so far.
14:50akhudekhm, I was going to take advantage of laziness of map, an almost got bit by chunked sequences
14:51akhudekit's not clear from the documentation that map will often grab chunks, and if you want true item at a time behaviour you need to pass in something like a list
14:51LauJensenakhudek: ouch
14:52LauJensenakhudek: And yea, the documentation isnt specific enough
15:30cemerickakhudek: that mattered to me recently as well -- (mapcat list some-chunked-seq) will ensure one-at-a-time behaviour, in case you hadn't determined that already.
15:32akhudekcemerick: yep, I discovered this. I just wanted to comment that it is important to have this documented at some point so people don't accidentally get tripped up.
15:43cemerickakhudek: I agree, though it's a tough documentation issue -- chunking behaviour is entirely automatic, and transparent in the overwhelmingly common use case (lazy seq processing). Anyway, see http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/ for what might come along in 1.3.
15:46akhudekthat looks promising!
15:46chouserit's also possible chunked seqs might just go away
15:46akhudekare they causing trouble elswhere?
15:47chousernot that I know of, but pods may allow better performance yet for similar pipelines
15:47akhudekah
15:48chouserI haven't heard that stated recently, so I maybe mis-remembering or things may have changed again.
16:01cemerickI've been under a rock. Pods are cells, right?
16:02TakeVAre there any Clojure libraries for hash generation, or do we just use the Java APIs for that?
16:02cemerickTakeV: what are you trying to get a hash for?
16:04TakeVcemerick: Playing around with password stuff. I know it's pretty bad form to keep the password stored, so I want to do a hash of it to compare.
16:05cemerickah
16:05chousercemerick: I think so, yeah.
16:05cemerickTakeV: MessageDigest is pretty straightforward to use.
16:05TakeVIs that in contrib?
16:06cemerickTakeV: no, it's a JRE library. java.security.MessageDigest
16:06cemericks/library/class
16:07TakeVAh, alright. Thanks. :)
16:09cemerickTakeV: Here's my (pre-protocols) hash-of multimethod. It's SHA1-only, just because that's what we use overwhelmingly.
16:09cemerickhttps://gist.github.com/83ce26f6ad06d5bda025
16:10cemerickman, that's some old code :-P
16:10TakeVSHA1 isn't bad. Could be worse. :P
16:11cemerickhrm, the MiscUtilities class is mine too -- replace that with (MessageDigest/getInstance "SHA1")
16:11TakeVSure.
16:12TakeVMan, I love github...
16:12cemerickTakeV: 'course, that'd be a single fn given io/input-stream. I'm probably not doing you any favors by pasting that.
16:13TakeVIt's enough to work off of. A nice seed.
16:19seancronHow can I start a thread that runs, while the rest of the code executes?
16:19mefesto(doto (Thread. f) (.start))
16:20mefestowhere 'f is the function you want to run in that thread
16:20mefestoor you can use a thread pool using Executors
16:21seancronHow would I use a thread pool?
16:21cemerickseancron: Read about agents and send/send-off. Starting new threads as mefesto is almost never necessary or desirable.
16:21cemericks/mefesto/mefesto suggests
16:21mefestooops, yeah, agents totally slipped my mind :-\
16:22seancronOkay. I'm trying to show a GUI while I make network connections.
16:22TakeVYeah, I was just about to ask if threads are really needed, given the existence of agents.
16:22cemerickseancron: take a look at c.c.http.agent
16:23cemerick(if you're doing http, that is)
16:23seancronI'm actually doing DNS right now
16:24cemerickseancron: then agents are the way to go, or maybe futures (though I suspect not)
16:24arkhwhat's wrong with the following?: (apply #(str %) ["one" "two" "three"])
16:24arkhI know I'm missing something basic :(
16:24mefestoarkh: just (apply str ["one" "two" "three"])
16:24opqdonut#(str %) takes only one argument
16:24opqdonutand what mefesto said
16:25arkhusing str in an anonymous function is a placeholder for what I'd really like to do. Am I passing three arguments to #(str %) with the above?
16:27mefestoarkh: yeah, apply will call the passed function with the collection as it's arguments
16:27technomancyagents are value-oriented. sometimes you need Threads that don't necessarily revolve around a single identity
16:27arkhmefesto: , opqdonut: ok - thank you
16:28TakeVtechnomancy: What about, say, separating game logic and drawing in a video game? Would threads be better suited for that than agents?
16:30duncanmany of you use the netbeans platform?
16:31technomancyTakeV: I think drawing is a good candidate for a background Thread as it's pretty side-effecty. "game logic" is a little too vague to make the call.
16:31TakeVtechnomancy: I see.
16:31arohnerTakeV: though you have to be careful with drawing in a separate thread. Many GUIs are picky about only doing drawing operations in a specific thread
16:33lozhI've not done much game programming, but the game loops I've seen normally manually interleave the update and the drawing, makes the locking easier, and both have to be pretty well time bounded for a smooth gameplay anyway
16:34ordnungswidrig1aikido
16:38arkhif I have a seqence of strings, what's a good way to print them out, one string per line, with spit?
16:38mefestoarkh: doseq ?
16:39mefesto(doseq [l lines] (println l))
16:39arkhmefesto: oh ... I didn't think to use println. That's java's isn't it?
16:40arkhmefesto: sorry and nvm (and thank you). A (doc println) says otherwise
16:40clojurebotdefmulti doc is ugly
16:50slyrus_not sure if this is a bug or a feature. but if I :use clojure.contrib.seq, I can't C-c C-k my clojure file without getting the following error: error: java.lang.IllegalStateException: partition-by already refers to: #'clojure.contrib.seq/partition-by in namespace: foo
16:50slyrus_clojure.contrib.graph, on the other hand, for example, is fine. must be something about the :refer-clojure :exclude in seq's ns form
16:51chouserpartition-by is defined in c.c.seq, but was promoted to clojure.core, so now it's in both places -- hence the error.
16:52chouseryou shouldn't really be doing :use without naming the specific vars you want anyway.
16:53slyrus_hmm... the fact that it compiles fine the first time through and breaks the second time makes me suspicious that this is the intended behavior.
16:54slyrus_and do you really mean I should call out every function I plan to use from an ns when I :use an ns? that seems a bit tedious.
16:59mefestoslyrus_: you can also 'require :as something so you don't have to name each var you need
17:02chouserslyrus_: I highly recommend against naked :use. Either alias the namespace with :as or call out each function with :only
17:02chouserof course that's just my opinion, but it would help with situations like this, as well as others.
17:09Nikelandjelochouser: It's inconvenient (for me) when exploring some clojure contrib libs in repl and don't know what I need :( Is there are a way to not load function, which already exist, to escape this error?
17:10chouserif it's a clojure.core function, that should only be a warning and you should be able to proceed.
17:11qbgNikelandjelo: There is an :exclude and :rename option for use
17:15djpowellhmm - I think clojure.java.shell has got messed up
17:17RaynesHeh. You know your language is getting popular when articles starting with single-digit numbers and assertions begin to pop up. http://twoguysarguing.wordpress.com/2010/07/26/7-rules-for-writing-clojure-programs/
17:20chouserheh
17:28slyrus_chouser: I assume you wouldn't apply the same recommendations to things in the same umm... project, right? do you really explicitly call out things used in foo.core by foo.baz and vice versa? or just do a :use?
17:29chouserslyrus_: perhaps I'm a bit pedantic, but if it's not defined in the same file, I use a namespace alias prefix or list every function in the :use :only
17:29slyrus_interesting. ok, thanks.
17:30chouserthat always makes it easy to find the definition of every word in your code, as well as keeping strict control of your own namespace.
17:38lpetitwoops, there's no 1.2-beta1 tag on git ?
17:44slyrus_chouser: ok, I think I can used to that.
17:44lozhDoes the slime-repl in emacs have something to refer to the previous result?
17:45qbgYou still have *1
17:46lozhthanks
17:49lozhHeh *1 is one of those things I just can't search for on google, any idea where it's documented?
17:49qbg,(doc *1)
17:49clojurebot"; bound in a repl thread to the most recent value printed"
17:50lozhOh, it's a clojure thing - thanks!
17:52slyrus_chouser: as long as we're being pedantic, why don't we force namespaces to :use clojure.core?
18:01somniumonce or twice I would've liked to be able to '(require [clojure.core :as core])
18:01chouserthat works
18:02somniumreally?
18:05somniumah, cool. this worked (ns ... (:refer-clojure :only []) (:require [clojure.core :as core]))
18:40nickikCan somebody help me with this: http://paste.lisp.org/display/112848
18:40nickikwhy is it not working?
18:40qbgYou should define the macro before use for one thing
18:41nickikevaluatet the macro first in my file
18:41nickikor repl
18:41RaynesClojure isn't like Haskell. You can't use a function before it's defined unless you forward declare it with (declare)
18:42qbg(hash-map rest) looks wrong
18:43qbg(apply hash-map rest) would work
18:43nickikyeah
18:43nickiki was thinking (into {} rest)
18:43qbgYou are also assuming something about the order of the seq returned by keys
18:44qbg(fn [a b] '(a b)) is probably not what you want
18:44nickikyou mean in the (func .....)
18:44qbgYes
18:44nickikit dont think it matters how they are orderd but i should change it for clarity
18:46nickikhow else can i make a list of list like this ((key value) (key value))
18:46qbg(seq {:a 1 :b 2})
18:46qbg,(seq {:a 1 :b 2})
18:46clojurebot([:a 1] [:b 2])
18:48tomojqbg: you mean we can't assume that keys and vals are in matching order?
18:48tomojthat would be strange
18:49qbg,(into {} (for [x (range 26)] [(keyword (str (char (+ (int \a) x)))) x]))
18:49clojurebot{:r 17, :z 25, :y 24, :x 23, :a 0, :c 2, :b 1, :f 5, :g 6, :d 3, :e 4, :l 11, :k 10, :j 9, :m 12, :i 8, :n 13, :h 7, :o 14, :v 21, :w 22, :t 19, :u 20, :q 16, :p 15, :s 18}
18:50nickiki changed it to a sorted-map
18:50qbg,(keys (into {} (for [x (range 26)] [(keyword (str (char (+ (int \a) x)))) x])))
18:50clojurebot(:r :z :y :x :a :c :b :f :g :d :e :l :k :j :m :i :n :h :o :v :w :t :u :q :p :s)
18:50qbgnickik: Wouldn't an array-map be better here?
18:51tomoj,(keys (into {} (for [x (range 26)] [(keyword (str (char (+ (int \a) x)))) x])))
18:51clojurebot(:r :z :y :x :a :c :b :f :g :d :e :l :k :j :m :i :n :h :o :v :w :t :u :q :p :s)
18:51tomojoops
18:51tomoj,(vals (into {} (for [x (range 26)] [(keyword (str (char (+ (int \a) x)))) x])))
18:51clojurebot(17 25 24 23 0 2 1 5 6 3 4 11 10 9 12 8 13 7 14 21 22 19 20 16 15 18)
18:51tomojwhew
18:51qbgkeys and vals will always match
18:52qbgThe order in which they are returned will not always be the same as the order they went into the map, of course
18:52qbg(which is what I was trying to point out)
18:53nickikif i do (let [body (sorted-map rest) func (map (fn [a b] '(a b)) (keys body) (vals body))]) should that be right too?
18:54tomoj,(let [m {:foo 1 :bar 2}] (map (fn [a b] '(a b)) (keys m) (vals m)))
18:54clojurebot((a b) (a b))
18:54tomoj,(let [m {:foo 1 :bar 2}] (seq m))
18:54clojurebot([:foo 1] [:bar 2])
18:54tomojmuch shorter, and it actually works, too! :D
18:55tomojif you really want lists, how would you do it, though?
18:55tomojmaybe (map (partial apply list) {:foo 1 :bar 2}) ?
18:56nickikah ok do it like this (fn [a b] '(~a ~b))
18:56tomoj(map #(apply list %&) m)
18:56nickikor (fn [a b] (into '() [a b]))
18:58brehautmassive brain failure: whats the inverse to empty?
18:58qbg,(hash-map [1 2 3] "a", :foo 2, "3" 6, 8 9, \a 2, '(1 4 3) 6, 'a 'b)
18:58clojurebot{\a 2, [1 2 3] "a", :foo 2, 8 9, a b, "3" 6, (1 4 3) 6}
18:58qbgbrehaut: seq
18:58brehautcheers
18:58qbg,(source empty?)
18:58clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
18:58qbg(empty? x) is (not (seq x))
18:58tomojoh, hmm
18:59qbg,(sorted-map [1 2 3] "a", :foo 2, "3" 6, 8 9, \a 2, '(1 4 3) 6, 'a 'b)
18:59clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.Keyword
18:59qbg,(array-map [1 2 3] "a", :foo 2, "3" 6, 8 9, \a 2, '(1 4 3) 6, 'a 'b)
18:59clojurebot{[1 2 3] "a", :foo 2, "3" 6, 8 9, \a 2, (1 4 3) 6, a b}
18:59nickik@brehaut (complement empty?)
18:59qbg,(doc empty?)
18:59nickikbut seq better
18:59clojurebot"([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"
19:00nickikif been doing that after someone mentions it in the mailinglist
19:00tomojjust (map #(apply list %1) {:foo 1 :bar 2}), not %&
19:04nickik@tomoj that is better thx
19:05tomojer, don't even need the 1
19:06nickikbetter is always posible :)
19:10tomojI feel like there should be a cooler way than #(apply list %)
19:11qbg,(map (partial apply list) {:foo 1 :bar 2})
19:11clojurebot((:foo 1) (:bar 2))
19:11hiredmanapply list is seq
19:12hiredman,(map seq {:foo 1 :bar 2})
19:12clojurebot((:foo 1) (:bar 2))
19:12tomojgreat :)
19:12hiredmanwhy are you doing that anyway?
19:12tomojI'm not, nickik is
19:13tomojmacro, so maybe a good reason?
19:14qbg,(list? `(5 ~2))
19:14clojurebotfalse
19:15hiredman,(doc list?)
19:15clojurebot"([x]); Returns true if x implements IPersistentList"
19:15hiredman,(class `(5 ~2))
19:15clojurebotclojure.lang.Cons
19:15technomancylist? is the black-sheep predicate.
19:15hiredman,(supers clojure.lang.Cons)
19:15clojurebot#{java.io.Serializable clojure.lang.Sequential clojure.lang.Seqable java.util.Collection clojure.lang.IObj java.lang.Object java.util.List clojure.lang.ISeq clojure.lang.ASeq clojure.lang.IPersistentCollection clojure.lang.Obj java.lang.Iterable clojure.lang.IMeta}
19:15hiredmannot a IPersistentList
19:16KirinDaveWait.
19:16KirinDaveWaaiiiitt a minute.
19:16KirinDavehttp://twoguysarguing.wordpress.com/2010/07/26/7-rules-for-writing-clojure-programs/
19:16KirinDaveRule 5 6 7
19:16qbgI've used sequential? before once I know something is not a vector to see if something is list like
19:16qbgThere should be a better way...
19:16hiredmanseq?
19:16clojurebot@ splices in a seq and foo# is a symbol, not a seq
19:16hiredman,(seq? (list 1 2))
19:16clojurebottrue
19:17hiredmanif it prints in parens it's a seq
19:17technomancyeven the queuefish?
19:17KirinDaveI can't believe that -> and ->> are going to be demonized now.
19:18hiredmanthe queuefish is ineffable
19:19tomojdemonized?
19:19tomojoh, I see, wow
19:20tomoj"Don’t be lazy" ?
19:20hiredmanpretty sure he doesn't mean it
19:20hiredman->> and -> are all about transformation
19:20sexpbot=> #<core$_GT_ clojure.core$_GT_@11286929>
19:20KirinDaveI guess that should be, "Don't do a lot of identical subfunctions when you really want a helper function
19:20tomojoh, I see
19:21KirinDavehiredman: "Don’t use -> or ->>" is a nasty pullquote tho.
19:21hiredman*shrug* someone's wrong on the internet
19:21KirinDaveAlso, “Transformation is not recursion.”
19:22tomoj"Don't use -> or ->>" is right after "Use -> and ->> to make one liners easier to read"
19:22nickikthe reason is that I build a function in a macro (cons 'fn .....)
19:22KirinDaveI wonder if it really is 2 guys arguing.
19:22tomojI think if you're calling things rules you should be somewhat careful about how you phrase them..
19:22nickikthe ........ are the key - value pairs
19:23nickikthe key are the args
19:23tomojso if two functions your macro would create happen to have the same arglist...?
19:23nickikso (fn ([n] (dosomething)) ([a b] (dosomething)))
19:24tomojmaybe that is not a concern for some reason for your macro?
19:25KirinDavefogus can't be serious about this.
19:25nickikits complicated to explain
19:27nickikihas nothing to do with fogus
19:27nickik*it
19:28tomojnickik: no one will ever do something like (def-contracted-fn foo :contract bar [a b] baz [a b] bing)? that's what I meant
19:28tomojoh you're just passing them to fn, so it doesn't matter :)
19:29nickikwhy not its better then define contracts outside and then do the (def somename (with-contrains your-function your-contract))
19:30nickikand you could use more then one contract for one function if you do :contract [contract-1 contract-2]
19:30nickikthe name def-contracted-fn is just temp
19:34tomojhuh
19:37nickikI just dont want to defin a contract then a function and then a nother def to connect them both
19:38tomojwere you not responding to what I said?
19:40slyrus_como se dice digit-char-p in clojurian?
19:41slyrus_,(int \3)
19:41clojurebot51
19:42nickik@tomoj only saw the second thing just now sry
19:42tomojnickik: no problem, was just confused
19:43tomojslyrus_: what would (int (char 3)) return?
19:43tomojor, if that returns 3, what would (char 51) return?
19:44slyrus_^c doesn't represent an integer, throw an error.
19:44slyrus_yeah, yeah...
19:44slyrus_presumably there's some unicode char <--> char-code mapping going on somewhere, no?
19:46mefesto,(map int (map char "123abc"))
19:46clojurebot(49 50 51 97 98 99)
19:47mefestoerr strings are char seqs so...
19:47mefesto,(map int "123abc")
19:47clojurebot(49 50 51 97 98 99)
19:47nickikthanks for the help. My first real macro works ... in some cases :)
19:48slyrus_,(int \a)
19:48clojurebot97
19:49slyrus_who says that (int \a) is 97? the clojure language spec? latin-1? presumably the way characters are converted to ints is documented somewhere.
19:49mefestoslyrus_: i think ascii and beyond
19:50somniumslyrus_: could you do something like (when (<= 48 (int c) 57) (- (int c) 48))? or (Integer/parseInt (str \3))
19:50slyrus_sure, I _could_. I'm used to having a nice handy digit-char-p lying around which I found much more attractive and readable than either of those, thank you...
19:51somniumslyrus_: there's always that handy `defn' in a pinch :)
19:51tomojslyrus_: do you care about the radix arg?
19:51slyrus_not at the moment
19:51tomoj#(.isDigit %) would work, I think
19:52tomojoh, no
19:52tomoj#(Character/isDigit %)
19:53mefestoslyrus_: fyi, http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters
19:53mefestoslyrus_: i think utf-8 is mostly backward compatible with that table
19:54somnium,(Character/digit \3 9)
19:54clojurebot3
19:55somnium,(Character/digit \a 9)
19:55clojurebot-1
19:55somniumslyrus_: warmer?
19:57slyrus_mefesto: I'm less interested in the ascii printable characters and more interested in knowing how clojure knows about that wikipedia page
19:57slyrus_or at least the mapping contained therein
19:57mefestoslyrus_: i think it's less clojure and more how java does things
19:57slyrus_does it just hand all of the string encoding stuff of to javaland?
19:57mefestojvm using utf-8 i believe
19:57mefesto*uses
19:58somniumhttp://java.sun.com/j2se/1.4.2/docs/api/java/lang/Character.html
19:58slyrus_thanks somnium
19:58arohnerslyrus: (int \a) is defined by the ascii spec, as implemented by Java
19:59slyrus_ok. I'll use CL for all of my EBCDIC coding requirements then :)
19:59mefesto"A String represents a string in the UTF-16 format in which supplementary characters are represented by surrogate pairs (see the section Unicode Character Representations in the Character class for more information)"
20:00mefestohttp://java.sun.com/javase/6/docs/api/java/lang/String.html
20:01technomancyI heard CL is _really_ good at EBCDIC
20:04slyrus_ok, thanks for the help everyone. the important point, for me, is that Character/digit will handle the encoding for the code point and do the right thing.
20:05slyrus_so Character/digit is the digit-char-p equivalent i was looking for
20:05slyrus_which is much nicer than, say, subtracting 48 from (int the-char).
20:13slyrus_,(chars "moose")
20:13clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to [C
20:16tomoj,((juxt identity seq) (.toCharArray "moose"))
20:16clojurebot[#<char[] [C@184dc10> (\m \o \o \s \e)]
20:16mefesto,(.toCharArray "moose")
20:16clojurebot#<char[] [C@1b995c2>
20:17slyrus_tomoj, mefesto: thanks, but the error message could be a little nicer :)
20:17mefestoslyrus_: must it be a character array? a string is a seq of chars
20:18slyrus_no, i was just surprised at that error, that's all
20:18slyrus_and, yes, strings being seqs of chars is indeed very nice :)
20:18tomojcould be nicer by saying "char array" instead of "[C"?
20:19slyrus_ah, that's what that means. thanks!
20:21arohner[C is java's .toString on an array
20:22arohnerpprint'ing it is nicer
20:22arohner,(clojure.pprint/pprint (into-array Character/TYPE [\a \b \c]))
20:22clojurebot[\a, \b, \c]
20:23hiredman[C is the jvm internal type of an array of characters
20:23hiredman[B is bytes
20:23hiredmanetc
20:24hiredman[Ljava/lang/Object; is objects
21:23reburgwhy doesn't #({% 1}) work, while (fn [a] {a 1}) does?
21:23cemerick#({% 1}) is the equivalent of (fn [a] ({a 1}))
21:24reburgcemerick: but (#{% 1} :foo) throws an exception
21:24reburgoh wait
21:24reburgi see what you typed now
21:24reburgcemerick: thank you!
21:25cemerickreburg: #(hash-map % 1) is what you want (though that's a little odd :-)
22:12Drakesontechnomancy: ping