#clojure log - Jan 04 2011

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:18 jfkw: \quit

0:22 auser: hah

1:44 amalloy: $source into-array

1:44 sexpbot: into-array is http://is.gd/k44VO

2:01 _na_ka_na_: how do I get clojure-contrib 1.3alpha4 from lein ?

2:38 LauJensen: Derander_: Did you solve your problem?

2:49 Derander_: LauJensen: no, but I haven't put any more work into it since then

2:49 I've gotten sidelined

2:49 I'll figure it out tomorrow

2:52 LauJensen: ok, it should be like amalloy said. You can inspect ClojureQLs own project.clj to see artifacts for mysql, postgres and sqlite

3:19 Derander_: LauJensen: good idea. thank you.

4:35 ejackson: morning all

4:54 LauJensen: Morning ejackson

4:57 ejackson: LauJensen: my apologies for not taking a look at ClojureQL yet. I opted to use redis instead of SQL for the current piece of work. I will use SQL at some point, but not just yet.

4:57 LauJensen: ejackson: I'll forgive you if you write a Redis compiler for ClojureQL (it has pluggable compilers)

4:58 ejackson: is that a fact....

4:58 very interesting indeed

4:58 ,(swap! edmunds-todo-list inc)

4:58 clojurebot: java.lang.Exception: Unable to resolve symbol: edmunds-todo-list in this context

4:58 ejackson: :)

5:00 actually clojurebot, the correct Exception is numeric overflow

5:04 Fossi: shameless plug: http://the-deadline.appspot.com

5:04 all clojure ;)

5:04 and also nice for keeping your todos

5:04 bobo_: Fossi: what did you use?

5:04 Fossi: as in?

5:05 a lot of coffee

5:05 ejackson: Fossi: nice !

5:06 LauJensen: bobo_: Theres a nice talk on Hack Fwd about the deadline

5:13 bobo_: Fossi: as in libraries for the web =)

5:13 LauJensen: ah il check

5:14 LauJensen: bobo_: I think they used all the wrong libraries, but their architecture idea was great

5:14 bobo_: :-p

5:17 Fossi: it's been changed a whole lot

5:17 bobo_: i dont think the site is for me. way to much stuff

5:18 im still to find a todolist that beats postit notes

5:18 Fossi: there are actually quite a few really simple ones

5:18 mids: LauJensen: what is Hack Fwd? (got an url?)

5:19 Fossi: hackfwd.com

5:19 mids: oh that just seemed to be some random site, guess I got to look deeper

5:20 Fossi: it's a vc-group, by lars hinrichs (xing founder)

5:20 they also have quite a few tech talks

5:20 mids: thanks

5:21 ah, http://hackfwd.com/companies#thedeadline

5:23 bobo_: cant find any talk there though?

5:25 Fossi: http://passionmeetsmomentum.com/

5:25 i think

5:26 LauJensen: Yea I think that was the name. Just stay clear of passionmeetsfashion.com :)

5:32 companion_cube: is there a way to change the way to compare objects in a set ?

5:33 ejackson: companion_cube: yes, a custom comparator function

5:35 companion_cube: if you use sorted-set-by you just pass in a comparator and it uses that to compare elements in the set

5:35 companion_cube: oh, ok, thanks

7:09 ejackson: when destructuring a map is there a way to use the :keys directive to pull out *all* the keys, rather than list them individually ?

7:11 mduerksen: ejackson: how would you know which keys are in your map?

7:12 when you want to use the keys, i mean

7:13 ejackson: its fixed. in this case the map is a bunch of parameters for another function, so I know at design time what's going to be there, and I'm just coding that using the keys of the map.

7:14 oh bollkcs

7:14 i see what you mean, the compiler won't know the symbols when it tries to compile the funciton

7:15 too much dynamics, i'm beginning to believe in miracles :)

7:16 mduerksen: ^^

7:19 ejackson: mduerksen: well, I know what the keys are, as I would need to in order to write {:keys k1 k2 k3}, so if I could magically write {:all-keys} I could then use call k1 k2 k3 in the code. However, the compiler wouldn't know where those vars/locals and couldn't work.

7:19 at least, that's what I think, i'm reliably wrong though.

7:25 LauJensen: user> (defmacro destructured [m & body]

7:25 `(let [~@(interleave (map (comp symbol name) (keys m)) (vals m))]

7:25 (do ~@body)))

7:25 #'user/destructured

7:25 user> (destructured {:a 5 :b 10} (+ a b))

7:26 15


7:26 ejackson: its a hack, but its there :)

7:27 ejackson: LauJensen: nicely done, thanks :)

7:28 LauJensen: np

7:28 ejackson: really illustrative code actually.

7:30 LauJensen: It just occured to me, that it should simply be named let-map... :)

7:30 ejackson: that's exactly correct, it captures the semantics

7:31 with the usual confusion over the overloading of map

7:34 mfex: ejackson, note that the destructure macro is only different syntax for (let [a 1 b 2] ..) it will not work with (let [m {:a 1}] (destructure m (inc a))) etc.

7:40 ejackson: mfex: I see that (at the repl), and am trying to figure out why...

7:40 LauJensen: ejackson: because macros dont evaluate their arguments, so it just sees the literal symbol m, does not resolve it

7:40 ejackson: ~m ?

7:40 clojurebot: slime-install is an automated elisp install script at http://github.com/technomancy/emacs-starter-kit/blob/2b7678e9a331d243bf32cd8b591f826739dad2d9/starter-kit-lisp.el#-72

7:42 ejackson: sorry what I meant was, my first guess was exactly that, and was then confused by ~m didn't resolve it

7:44 but i get it now, thanks.

8:23 serp__: if I understand things correctly, when using multimethods the function to use is picked based on the result of a function passed to defmulti. I want to do select which function to use based on the result of a predicate applied to the arguments. something like (defn print-type [arg] (is-number? arg) (println "a number!")) (defn print-type (constantly true) (println "something other than a number!")) where the first thing af

8:24 (print-type 4) would then print "a number!" and (print-type "abc") wouldn't... is there something like this in clojure already, or am I approaching the problem in a weird way?

8:32 chouser: serp__: the main benefit of using a multimethod instead of an if or case is that it is "open"

8:32 that is, you can define several conrete functions now, but you or others can add more later

8:33 if your dispatch function is a predicate, there are only two possible concrete functions, one for true and one for false, so your set of functions is essentially closed anyway.

8:34 serp__: I want it to keep trying until it finds a true predicate

8:34 chouser: so, there's less reason to use a multimethod in that case, but I suppose that doesn't necessarily mean you shouldn't.

8:34 ah...

8:34 yeah, that's not how multimethods work.

8:35 bsteuber: serp__: probably you need to build your own dispatch facility then

8:35 with an atom holding a map from predicates to functions

8:35 chouser: but order is going to matter

8:36 serp__: there won't ever be two true predicates

8:36 bsteuber: ok so not a map

8:36 serp__: not even a default catch-all?

8:36 serp__: no

8:37 chouser: serp__: you're sure you can't map those predicates into values in a heirarchy? You can define your own heirarchies that are independant of Java classes.

8:38 serp__: hm... I don't know how multimethods and hierarchies are related

8:39 chouser: serp__: you provide a single dispatch function whose return value may be an item in a heirarchy, say ::Number or ::EnglishText

8:40 then you define methods, each of which handles one branch of the heirarchy, so either ::Number or, say, ::String

8:40 serp__: aha.. so the method for ::String will handle ::EnglishText, unless there is a method for ::EnglishText ?

8:40 chouser: if you declare that ::EnglishText is derived from ::String, then if your dispatch fn returns ::EnglishText, your ::String handler ... exactly.

8:40 serp__: (why two : btw?)

8:41 chouser: serp__: keywords in a heirarchy must be namespaced

8:41 two : gives you that for cheap

8:41 serp__: hmm

8:41 neat trick this hierarchy business

8:42 it will do fine :)

8:42 thanks

8:43 chouser: you can also tie your own namespaced keywords into the main heirarchy that includes Java classes, if that's at all helpful.

8:44 serp__: I am doing pure clojure for now

8:44 maybe one day I'm ready for mixing in java

8:46 chouser: ,(derive ::EnglishText java.lang.String)

8:46 clojurebot: java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.Named

8:46 chouser: oops, ignore that.

8:46 ,(derive java.lang.String ::Value)

8:46 clojurebot: nil

8:46 chouser: ,(isa? (class "hello") ::Value)

8:46 clojurebot: true

8:47 serp__: ,(derive java.lang.String :lala)

8:47 clojurebot: java.lang.AssertionError: Assert failed: (namespace parent)

8:47 chouser: serp__: two : please. :-)

8:47 or :serp/lala

8:47 serp__: ,(derive java.lang.String :serp/lala)

8:47 clojurebot: nil

8:47 serp__: hm

8:48 chouser: so now Strings are ::Values, :serp/lalas, and Objects, among other things.

8:48 serp__: :)

9:22 markskilbeck: Coming from PHP... I'd like to say thank-you.

9:22 So very much.

9:23 Programming has become enjoyable again.

9:24 chouser: I suppose most "non-main-stream" language communities are made up primarily of grateful refugees of other languages.

9:24 Anyway, welcome. :-)

9:24 LauJensen: great, one less PHP programmer out there, please accept our thanks as well markskilbeck :)

9:24 markskilbeck: \o/

9:25 Dranik: markskilbeck, do you develop web-sites with clojure?

9:30 rsenior: I was reading in a JSON doc this morning with contrib.json, where the key of a JSON map happend to be a URI, such as {"http://clojure/reader":1}. This gets turns into {:http://clojure/reader 1}, and calling (name :http://clojure/reader) just yields "reader"

9:30 I found this a little unexpected, though reading the rules for symbols it makes sense now

9:31 is there something that can/should be done to be smarter about this?

9:33 chouser: rsenior: good question. Clojure symbols and keywords are designed to allow their prefix part be partials URLs such as in your example.

9:34 rsenior: chouser: right, I was looking at the source and it looks like the goal is stripping out the ns prefix

9:34 chouser: for symbols, 'str' will rebuild the original string, but I'm not aware of a similar function for keywords

9:34 rsenior: that worked for keywords as well

9:34 however I had typically been using name to get the string representation of the keyword

9:35 chouser: but for keywords, 'str' will return a string that begins wth :

9:35 rsenior: oh right, I was thinking about a straight symbol

9:36 chouser: hm... since json keys don't generally use / to indicate a namespace in a key, perhaps the clojure json lib should explicitly build keywords with no namespace.

9:37 ,(name (keyword "" "http://foo/bar"))

9:37 clojurebot: "http://foo/bar"

9:38 rsenior: oh, so it's the combo of it having the namespace and the URL for the value

9:51 yeah, looks like calling keyword with a single string arg, that has a slash in that string causes this: "return new Symbol(nsname.substring(0, i).intern(), nsname.substring(i + 1).intern());"

9:51 meaning it's treating the left half of the url as the namespace

9:52 ,(namespace (keyword "http://foo/bar"))

9:52 clojurebot: "http://foo"

9:52 rsenior: ,(name (keyword "http://foo/bar"))

9:52 clojurebot: "bar"

9:54 chouser: exactly

9:55 rsenior: is this a bug report sort of thing? filed in contrib.json?

9:55 seems like it's a pretty easy fix

9:59 chouser: rsenior: I'd say it's probably worth an email to the maintainer. This is probably a situation he hadn't considered.

9:59 rsenior: alright, will do

10:22 ejackson: i'm sad not to be able to make a financial contribution to Clojure this year :(

10:22 lpetit: me too

10:28 StartsWithK: same here

10:29 chouser: these are for economic reasons?

10:30 lpetit: Maybe Rich's decision is irreversible, maybe not. In either case, I think he must hear testimonies like these.

10:30 fyuryu: lpetit: what decision?

10:31 chouser: oh, there's a ggroup thread

10:31 StartsWithK: we need a petition/pledge for this

10:31 lpetit: to stop requiring community funding for 2011, see If I'm less communicative now, it is only because I am trying to attain that level of focus once again.

10:31 argh, bad copy'paste

10:32 see http://clojure.org/funding

10:32 mikejs: if the development of clojure can be adequately funded w/o individual contributions then why reverse the decision?

10:37 lpetit: mikejs: those seem to be 2 orthogonal topics, wrt to the decision motivating http://clojure.org/funding

10:39 mikejs: what I mean is. Not every people has the ability/time etc. to "contribute" back to clojure (Rich) by sending patches, etc. Those people had the opportunity to show their commitment, faith, etc. via the funding effort.

10:39 ejackson: The last thing I want to do is second guess Rich - its his project, and his reasoning has been shown to impeccable. I'm just saddened that misunderstanding or mean-spiritedness on the part of some has caused what I thought of as a great funding model to be overturned.

10:40 lpetit: exactly

10:52 fyuryu: another reason to hate trolls...

10:53 lpetit: fyuryu: beware of "duck-trolling" too rapidly, though ;-) (it's not ruby, it's clojure :-D)

11:02 danlarkin: '

11:03 whoops

11:04 raek: ooh! an U+0027 APOSTROPHE! *yoink*

11:32 TobiasRaeder: hey :)

11:33 anyone ever used custom cake tasks that had some dependencies (as in some .jar file)?

11:38 stevep: sorry, lein here

11:55 lpetit: sorry, just POMU (Poor Old Maven User) here

11:55 s/Poor/Plain/ :-)

12:08 S11001001: shell & curl, who needs that fancy dep fetching stuff

12:27 ejackson: lpetit: s/Poor/Productive/ :)

12:36 stevep: http://tech.puredanger.com/2011/01/04/forkjoin-clojure/

13:03 markskilbeck: Do any of you guys have experience using nailgun & VimClojure?

13:05 Raynes: TobiasRaeder: There is a channel dedicated to cake over in #cake.clj. If you don't get any cake answers here, you'll probably get some answers in a little while there when activity is up.

13:05 TobiasRaeder: @Raynes alright, i will try that. thanks

13:10 Berengal_: Is there a nice way to define a way of combining records based on fields?

13:11 raek: what does "combining" mean in this case?

13:11 Berengal: raek: Adding them together, in a general sense

13:11 duncanm: a question about API design: is there a reason why merge and concat need to exist separately from conj?

13:12 Berengal: raek: Given two records, return a new one that's the "sum" of the input

13:13 mrBliss: Berengal: merge or merge-with

13:13 or into

13:13 Berengal: mrBliss: That assumes the data is homogenus.

13:14 mrBliss: Consider merging records with fields [:word-count :word-list]

13:15 It's no big deal writing the function myself. I just wondered if there was a builder-function for this already

13:16 Something like (reduce (merge-fields {:word-count +, :word-list concat} record-list)

13:17 Lost a paren there, after the map...

13:19 mrBliss: Berengal: I'll think you'll have to come up with a function. rename-keys or select-keys seem to be good functions to start from.

13:19 Berengal: mrBliss: Got it

13:19 mrBliss: (btw: rename-keys lives in clojure.set)

13:20 duncanm: mrBliss: in a similar topic, any ideas about conj/concat/merge?

13:21 automatically, i go to 'conj', but it's bit me a few times, took me a while to realize that i should be using merge or concat instead

13:27 mrBliss: duncanm: I don't quite understand your question. But I can say that what conj does, depends on the coll it is passed (vector, list or map). I use conj when I know how many elements I'm gonna add to a collection (1 to 3). I use into when I want to 'conj' 2 collections together. Merge is solely used for maps and records. I use concat to join multiple collections together, knowing that the order will be preserved (unlike into used with

13:27 lists). I hope this helps a bit :-)

13:28 mids: markskilbeck: tried it but didn't like it. I am back to using slime.vim

13:30 markskilbeck: mids: slime.vim was being a pain for me - it complained about not being able to open a file in /tmp/blahblah

13:30 Going to try vimclojure and see if it plays nice.

13:31 mids: markskilbeck: slime.vim or slimv.vim?

13:31 markskilbeck: slime.vim, mids.

13:31 mids: (I am using the one that just pipes stuff to screen

13:31 markskilbeck: mids: yeah, that'n.

13:31 kryft: I'm going to try emacs with vimpulse when I have the time.

13:33 markskilbeck: kryft: seems like emacs is the de facto and best tool to use for clojure dev, though I CANNOT be bothered learning how to use it.

13:35 mids: tbh since I started using an autotest loop I stopped using all the fancy stuff

13:36 kryft: markskilbeck: Well, with vimpulse you shouldn't have to. =)

13:36 scode: Which repository is clojure-maven-plugin supposed to be in?

13:36 It seems to be missing from central, but I thought it was there before. I just noticed because I cleaned out my ~/.m2/repository on purpose to make sure dependencies would resolve.

13:37 markskilbeck: kryft: I saw "emacs" and stopped reading ><

13:38 mids: scode: http://repo2.maven.org/maven2/com/theoryinpractise/clojure-maven-plugin/ still there?

13:38 scode: mids: Sorry, yes

13:38 I just realized...

13:38 I had -SNAPSHOT for historical reasons.

13:38 I presumably didn't realize that because I did a local 'mvn install'.

13:38 Sorry for the noise.

13:40 Raynes: markskilbeck: You're going to see a lot of "emacs" 'round these parts.

13:40 cemerick: markskilbeck: Many use the eclipse plugin, FWIW.

13:41 kryft: If vimpulse works well enough, emacs+vimpulse should be the best of both worlds: the cool modes and extensibility of emacs with the editing interface of vim.

13:42 programble: <markskilbeck> kryft: I saw "emacs" and stopped reading ><

13:42 that kind of attitude will get you nowhere in life

13:43 kryft: Erm, best for me, that is; I'm well aware of the hordes of people that would rather gnaw their hand off than use a vi-style editor. :)

13:43 Well, it got him to #clojure, so how bad can it be?

13:44 Raynes: Hehe.

13:44 markskilbeck: programble: my apologies for not being interested in emacs, right now. But I can only do so much.

13:45 programble: even if you aren't, ignoring anything pertaining to something you are not interested in will not get you far

13:45 * markskilbeck throws programble a beer

13:45 markskilbeck: It was a small sentence.

13:45 programble: that would be illegal

13:45 don't give alcohol to minors :P

13:46 * markskilbeck instead gives programble The Finger

13:46 programble: better

13:46 kryft: I think IRC counts as international waters.

13:47 chouser: virtual beers are legal for all ages

13:47 programble: dom96: you have a bad habit of doing that

13:47 dom96: huh?

13:49 amalloy: i would be willing to use vi if the alternative were gnawing off a hand

13:49 Raynes: amalloy: o/

13:49 dom96: amalloy: That statement offends me.

13:50 amalloy: Raynes: but when the alternative was spending two hours looking up how to configure tramp to use ssh+sudo, i chose that instead :P

13:50 Raynes: amalloy: Tramp is unnecessarily difficult to use, I think.

13:51 * devn continues to imagine how a full rails-like framework for clojure would look and behave

13:53 Luyt: Would it also try to redefine the language it's written in?

13:54 chouser: Luyt: you mean as rails does to ruby?

13:54 devn: Tramp isn't so bad...

13:54 Luyt: That's part of the language, is it not?

13:54 Raynes: devn: Have you ever tried to set it up so that you could edit files with root?

13:55 cemerick: devn: I've not had the same thoughts, simply because rails doesn't do much I'm interested in. *shrug*

13:55 devn: Raynes: :D hahaha oh right

13:55 I gave up on that

13:55 Luyt: A friend of mine who is into conspiracy theories, suggested that the ongoing monkeypatching of Ruby by the rails developers set some angry blood in Japan, that's why they refuse to open their process to the english-speaking world, and introduce unicode incompatibilities. I think he's a bit weird.

13:55 cemerick: There is a rails-inspired framework out there...

13:55 https://github.com/macourtney/Conjure maybe?

13:55 devn: cemerick: I've played with it

13:56 cemerick: hrm, hiccup, nevermind :-|

13:56 devn: I've been toying with the idea of building my own

13:56 chouser: I think there are lots of people who want something that could be named InstaCRUD

13:56 Luyt: I'd be a killer app ;-)

13:56 cemerick: devn: there's your name ^^ ;-P

13:57 devn: hahaha I will not be naming it InstaCRUD

13:57 chouser: I'm probably one of them

13:57 devn: but yeah chouser that's the idea

13:57 cemerick: If it could have a couch backend, that might be interesting.

13:58 chouser: cemerick: don't see why not

13:58 devn: I think it will come with time -- I'm already starting to see a number of people toying with ways of doing templating in Clojure

13:58 slim, haml-macro, hiccup, enlive, etc.

13:58 ring is well on its way, and so on

13:58 stevep: yeah, seen enlive mentioned a few places

13:59 haven't looked at it yet

13:59 cemerick: chouser: AFAICT, Rails ≈ CRUD ≈ RDBMS

13:59 devn: enlive is a brilliant piece of software but it certainly isn't for someone who just wants to get up and running and start doing stuff

13:59 cemerick: Just conceptually of course, not technically.

13:59 stevep: *nods*

14:01 devn: ive showed people insanely simple clojure code next to their ruby code and they are dumbfounded -- granted we don't want to pander to the LCD, but I think there needs to be more of a focus on making life easy (at least at first) for people who just want to build a little dynamic website

14:02 stevep: hiccup + ring get you pretty far

14:03 Luyt: But is it web scale? http://mongodb-is-web-scale.com/

14:05 chouser: cemerick: I simply mean that someone doing CRUD generally doesn't care if it's RDBMS underneath or not. Many of them use MySQL, after all.

14:35 ssideris: devn: was the insanely simple code written with enlive?

14:47 hiredman: http://clojure.org/funding god damn it lau

14:47 Raynes: I'll second that notion.

14:47 LauJensen: ?

14:48 Raynes: Isn't it obvious? You've destroyed the world. Cursed us all. Turned all that was good and holy to evil. Water to poison; etc. ;p

14:48 LauJensen: hiredman: Im not sure I can take credit for that :)

14:49 qbg: More fallout from LauGate

14:49 LauJensen: hehe

14:50 benreesman: hey can anyone point me in the right direction for the idiomatic way to get a lazy sequence that takes it's contents from a LinkedBlockingQueue?

14:50 qbg: I'd write a function that uses lazy-seq

14:50 chouser: benreesman: probably (repeatedly #(.take lbq))

14:50 qbg: Not sure if there is a better way

14:50 hiredman: there is no single way to do it, if you want the contents without blocking or removing stuff you can just call seq

14:51 benreesman: i want it to block

14:51 hiredman: then chouser's repeatedly will work

14:51 benreesman: excellent, thanks guys

14:51 qbg: (inc chouser)

14:51 sexpbot: ⟹ 3

15:00 devn: (some #(and (= (mod % 5) 0) (= (mod % 7) 0)) (range 1 100))

15:00 (1..100).detect {|i| i % 5 == 0 and i % 7 == 0 }

15:01 These don't work alike, perhaps I meant to use filter:?

15:01 chouser: rough count of syntax rules employed: 2, 5

15:02 qbg: chouser: ?

15:02 chouser: ,(some #(and (= (mod % 5) 0) (= (mod % 7) 0) %) (range 1 100))

15:02 clojurebot: 35

15:02 amalloy: qbg: not syntax-rules, but "rules of syntax" for ruby/clojure code just posted

15:03 qbg: Ah

15:03 chouser: qbg: to understand the clojure you need 2 rules, (foo x y) calls a function, #(mod % x) defines a function

15:04 for the ruby, () .. . {} |i|

15:05 qbg: ,(some #(= (mod % 5) (mod % 7) 0) (range 1 100))

15:05 clojurebot: true

15:05 chouser: of course that's only rough. both use whitespace, some non-alpha for equality, etc.

15:05 qbg: ,(some #(and (= (mod % 5) (mod % 7) 0) %) (range 1 100))

15:05 clojurebot: 35

15:05 chouser: devn: so either be explicit about what your fn returns, or use (first (filter ...))

15:08 amalloy: chouser: the first/filter idiom annoys me: i wish (some) behaved that way; surely it's a more common usage than the way it currently behaves, which i guess is (first (filter identity (map f coll)))

15:10 chouser: I think some is meant as a correlary to every? not-every? and not-any?, but with a bit more power

15:10 qbg: ,(first (filter #(apply = 0 (map (partial mod %) [5 7])) (range 1 100)))

15:10 clojurebot: 35

15:12 amalloy: chouser: ##(some even? (range)) reads like "some even integer", not "is there an even integer?"

15:12 sexpbot: ⟹ true

15:12 amalloy: i'd be happy to have a (some?) function that fits in with every? and family

15:12 chouser: I think it'd be called 'any?'

15:12 qbg: Maybe example is a good name for (first (filter ...))

15:13 amalloy: sure, any? is good. better to avoid overloading "some"

15:13 chouser: but surely there's not much value in having 'any?' or 'some?' when we have 'some'

15:14 ,(->> (range 1 100) (filter #(zero? (mod % 5))) (filter #(zero? (mod % 7))) first)

15:14 clojurebot: 35

15:15 devn: thanks -- i ended up just making it a filter and taking first

15:15 chouser: isn't there another way to say (iterate inc 0) ?

15:16 amalloy: chouser: if 'some' were redefined to be first/filter, then there might be a desire for 'any?': ##(first (filter #(instance? Boolean %) [1 false]))

15:16 sexpbot: ⟹ false

15:16 devn: ,(type (filter #(and (= (mod % 5) 0) (= (mod % 7) 0)) (range 1 100)))

15:16 clojurebot: clojure.lang.LazySeq

15:16 devn: Is there a function to return that it is a "vector"?

15:17 amalloy: devn: it's not a vector

15:17 devn: err im sorry that's not what i meant

15:17 qbg: ,(vec (range 10))

15:17 clojurebot: [0 1 2 3 4 5 6 7 8 9]

15:18 devn: qbg: yeah that's not my question -- im interested in having it tell me if it's a vector, a set, etc. instead of returning clojure.lang.LazySeq

15:18 is that possible with any of the core fns?

15:18 chouser: amalloy: I do find some ...dissonance? around 'some' and (first (filter identity ...)), but I'm don't really like most of the proposed solutions.

15:18 qbg: ,(vector? [1 2 3])

15:18 clojurebot: true

15:19 devn: again, that's not the question im asking

15:19 chouser: amalloy: I'd be happy if calling (filter foo) were like (filter identity foo)

15:19 but that's a small improvement

15:19 maybe we need a ffilter

15:19 I'd use that much more often than I use ffirst

15:20 amalloy: chouser: true that

15:20 devn: i want to ask whether "it" (where "it" could be [1 2 3], {:a 1}, or (1 2 3))

15:20 qbg: devn: A clojure.lang.LazySeq is a seq, not a vector nor a set

15:20 devn: so i'd like to have it return 'seq'

15:21 amalloy: devn: so you want some function f of a collection, so that (f (range)) is seq, and (f [10]) is vector?

15:21 chouser: devn: what would you like it to return when given a PersistentList, which is a seq but also a list and a stack?

15:22 devn: honestly im just looking for a "pretty" way of printing its type without all of the java.lang.Foo

15:22 I could write this, sure -- but I'm wondering if anything in core already does this

15:22 hiredman: the type is really some set of interfaces

15:23 amalloy: &(-> [] class .getName)?

15:23 sexpbot: ⟹ "clojure.lang.PersistentVector"

15:23 amalloy: hrm

15:23 hiredman: but the concrete jvm type name is a detail

15:24 devn: it's not the end of the world or anything, but I'm trying to mimic how Ruby acts when you say "foo".class? => String

15:24 I want to "sell" clojure to some friends of mine and am looking for a pretty way of displaying this

15:24 qbg: Is it really that different?

15:24 hiredman: that just because ruby doesn't have packages

15:24 devn: Rubyists hate things that even casually resemble java

15:24 qbg: ,(supers (type (range 10)))

15:24 clojurebot: #{clojure.lang.Seqable java.util.List clojure.lang.Sequential clojure.lang.IMeta java.io.Serializable java.lang.Iterable clojure.lang.Obj clojure.lang.ISeq java.lang.Object clojure.lang.IObj ...}

15:25 devn: I'm just trying to get rid of any hints of java where possible

15:26 S11001001: find-first in clojure.contrib.seq-utils

15:26 Raynes: devn: If they're that opposed to Java in any form, I seriously doubt your efforts will be rewarded. Clojure is a JVM language, and thus you don't really get away from Java.

15:26 mikejs: devn: they're going to have to get over that if they consider using clojure

15:27 Raynes: If they aren't willing to accept the JVM as a platform, then there isn't much hope for them.

15:27 chouser: ,(map #(symbol (.getSimpleName %)) (supers (type (range 10))))

15:27 clojurebot: (Seqable List Sequential IMeta Serializable Iterable Obj ISeq Object IObj ...)

15:27 chouser: that's a bit less messy, though it obscures some important details.

15:27 stevep: @Raynes +1

15:28 amalloy: (inc Raynes)

15:28 sexpbot: ⟹ 2

15:28 amalloy: stevep: ^ :)

15:28 * Raynes huggles sexpbot.

16:26 kjeldahl: Hm. ring.middleware.reload isn't found by cake. Anybody know what it's called these days?

16:27 raek: kjeldahl: ring/ring-devel "0.3.5"

16:34 kjeldahl: raek: Thanks. I suspect a dependency declaration wasn't needed.

16:45 BufferUnderpants: Hi.

16:46 I'm toying with lein-war and I'm wondering how would one put an arbitrary file in the resulting WEB-INF folder.

16:49 raek: BufferUnderpants: looks like everything in src/html/ ends up in / in the jar, so maybe you can put the stuff in src/html/WEB-INF/

16:49 (this is what I can tell from https://github.com/alienscience/leiningen-war)

16:49 BufferUnderpants: Yeah, some other helpful fellow suggested it on the #leiningen channel too, thanks

16:49 (how didn't I think of that)

17:47 rata_: hi

17:48 is there a fn like nth that takes the number first, then the coll?

17:49 tonyl: not that i know of. seems a bit unidiomatic. why?

17:50 raek: rata_: #(nth %2 %1) ;; <-- now there is :-)

17:51 rata_: tonyl: because (nth (big-expression) n) is less easier to read than (nth n (big-expression))

17:52 raek: this is why -> was invented

17:52 (-> (big-expression) (nth n))

17:53 rata_: raek: (#(nth n %) (big-expression)) and (-> (big-expression) (nth n)) are harder to read imo

17:53 amalloy: rata_: -> is very nice once you get used to it

17:53 rata_: I use it a lot, but here it's ugly

17:53 raek: well, regarding the first one, I agree

17:54 rata_: btw, it's a pity there's no third, fourth, etc

17:54 S11001001: named-nths.lisp

17:54 raek: I thought you needed to pass the fn to some other higher order fn that expects the args in the other order

17:54 I usually use destructuring in those cases

17:56 rata_: raek: yes, using destructuring gets better

18:06 ossareh: lo all

18:06 auser: ola

18:53 ossareh: reasonable? (defn within? [key coll] (not (empty? (drop-while #(not= key %) coll))))

18:53 I feel like this is already in core but I don't know what the name is likely to be.

18:54 amalloy: ossareh: (some) does this

18:54 &(some #{4} [1 2 3])

18:54 sexpbot: ⟹ nil

18:54 amalloy: &(some #{4} [1 2 3 4 5])

18:54 sexpbot: ⟹ 4

18:55 amalloy: (this takes advantage of the fact that sets act like predicates testing for their contents)

18:55 ossareh: ye, I actually use that elsewhere.

18:55 * ossareh wonders why he's not using it now.

18:56 ossareh: thanks amalloy

18:57 amalloy: welcome!

19:07 ossareh: (inc amalloy)

19:07 sexpbot: ⟹ 1

19:28 _Vi: Usual Clojure is for JVM and easily mixed with Java code. I also heard about .NET and JS versions. Will there be Clojure that can be easily mixed with Perl code? (e.g. clojure for Parrot VM)

19:29 qbg: _Vi once the Clojure complier is ported to Clojure and core data structures are rewritten in clojure, that sort of port will be easier

19:29 _Vi: qbg, Is it moving to that "self-hosted"-ness?

19:29 qbg: Some progress has been made

19:30 Protocols/types introduced in 1.2 will help with the data structures

19:30 The gvec stuff is already implemented using them

19:30 _Vi: In general, is it expected that there will be Clojure for many things (parrot, Qt, python) in future or clojure.net and clojure for JS will die out and it will be locked to JVM?

19:31 qbg: It'll be a while though before clojure is rewritten in terms of itself

19:32 _Vi: (It's good to write lispy things using convenient libraries and with possibility to just implement things in low-level language in case of problems with Clojure)

19:32 qbg: The downside of ports to other platforms is the lack of the ability to use java libs

19:33 _Vi: qbg, Compensated with ability to use that native things (.NET libraries, JS libraries, Qt libraries, etc.)

19:33 qbg: Sure, you could in theory have clojure on <your favorite vm>, but a lot of existing code won't transfer over that easily

19:33 _Vi: qbg, I think they should be as easy to use in clojure ports as Java libraries in common Clojure.

19:33 qbg: They depend on java though

19:34 _Vi: qbg, "<your favorite vm>", So don't wait for things like "Clojure4Qt", right?

19:35 qbg: Its going to be a while

19:35 Right now, a lot of Clojure is still written in Java

19:35 _Vi: (let [q (QWidget. nil)] (.add (QLabel. "qweqe")))...

19:36 qbg: I'm not sure how much of that will be easy to do on a non-JVM

19:36 or java-like vm

19:37 _Vi: s/or java-like vm/or non-java-like vm/?

19:37 qbg: Correct

19:37 hiredman: there alread was a js port, but it hasn't been kept up be cause clojure was developing so fast it was hard to keep pace with

19:38 qbg: Also, I can imagine running Clojure in a C++ native land to be very painful

19:38 _Vi: May be Clojure would inspire creating similar things (lispy, immutable, STM, easy native lib calls) for other frameworks.

19:40 qbg, I don't expect "Clojure++" to integrate that well with any C/C++ code, but expect it to integrate well with Qt and GObject things (which provides reflection and other things).

19:41 qbg: Good GC support and dynamic code loading should be there too

19:42 _Vi: qbg, There are GC for C code. Dynamic code loading? Should be possible (at least as saving temp lib and dlopen-ing it).

19:42 qbg: ECL does it, so in theory it isn't a problem

20:08 devn: so am I crazy or is using camelCaseForVarNamesCompleteInsanity?

20:10 I suppose my next question is: Would I be a huge jerk if I took someone's library and submitted a pull request with proper source formatting and renamed vars to be foo-bar instead of fooBar

20:11 qbg: camelCase = not good

20:11 lancepantz: this is known as github trolling

20:11 and yes, you should do it

20:19 devn: pull request coming

20:19 qbg: If code had blood, it would be everywhere right now

20:21 devn: i love clojure, but people with no aesthetic value tend to make awful messes

20:23 https://gist.github.com/765778 -- Check out this dandy...

20:24 qbg: Did that person come from Haskell?

20:26 devn: yes.

20:26 qbg: Knew it

20:26 devn: obviously a really smart guy, but this syntax is...not clojure

20:26 qbg: The let-bind and >>== gave it away

20:26 * devn decides to refactor the whole library and send him a bill

20:28 devn: actually, I just realized that this library I'm playing with was built off of another library he wrote that is likely bigger and even worse

20:29 qbg: What does this library do?

20:30 hiredman: looks like a parser

20:43 ossareh: qbg: what is the haskell give away?

20:43 ignore ^

20:44 devn: qbg: the >>=

20:44 err ossareh

20:44 I found another haskell give away: <|>

20:44 (defn <|> ...)

20:54 * devn is a jerk and shouldn't be talking trash

20:55 devn: it's just a little jolting to see someone write code where they don't even seem to be looking at examples of other people's code for guidance on style and idioms

20:55 qbg: Who wrote this?

20:55 KirinDave: devn: Not so unusual for lisp-haskell expats.

20:55 devn: CommonLisp folks do what they want, when they want. It's sort of a thing.

21:09 devn: qbg: It'd be rude to say

21:09 qbg: I hope they are not currently on this channel

21:10 devn: KirinDave: Yeah, that's not something I guess I'm very familiar with. It seems like all of the languages I've learned I always cared a great deal about style.

21:10 qbg: they aren't.

21:12 qbg: The patient has survived their first surgery; it can now rest before its next one

21:17 chett``: Programming Clojure refers to clojure.contrib.repl-utils/show to enumerate fields of Java Objects.

21:17 O can't find this method in clojure.contrib 1.2

21:18 qbg: Should still be there: http://clojure.github.com/clojure-contrib/repl-utils-api.html#clojure.contrib.repl-utils/show

21:24 amalloy: chett``: it's there. i had a lot of trouble finding it when i was new to clojure because i couldn't figure out the ns/use/require forms

21:24 you want (use '[clojure.contrib.repl-utils :only [show]]) for standalone, or within an ns form (:use [clojure.contrib.repl-utils :only [show]])

21:27 chett``: amalloy: thanks, I thought I had it covered by including it in the project dependencies

21:27 minor oversight

21:27 amalloy: chett``: that makes the library available, but you have to require it for use in a given source file

21:31 chett``: I also need to read an erc tutorial as my evil twin and his evil twin chett` and chett`` are in here too

21:31 amalloy: chett``: no, only chett`` is in #clojure

21:31 chett``: thanks

21:32 amalloy: but you probably need to read that tutorial just the same, since i bet you want chett :)

21:38 cemerick: HTTP/REST/HATEOS fans: what response code best indicates a situation where content at some URI isn't available yet, but will be eventually? My best guess at the moment is a straight 300, with perhaps an indication of an expected ETA in the response body.

21:41 amalloy: cemerick: 307 looks right to me?

21:42 300 afaict implies that there are multiple near-equivalent copies of the same resource

21:42 cemerick: amalloy: except the requested URI is right, just not yet…

21:43 * cemerick wants 308 Wait or something.

21:43 hiredman: 418

21:43 amalloy: cemerick: it's a temporary redirect to the "nothing here yet" uri

21:45 hiredman: lol. i like 418

21:45 cemerick: 419 Godot

21:46 amalloy: hiredman: almost as entertaining as 500 The Bees They're In My Eyes

21:47 cemerick: here I am looking at the HTTP/1.1 RFC, but the perfect one was waiting for me in the webdav spec

21:47 102 Processing – This code indicates that the server has received and is processing the request, but no response is available yet.

21:47 amalloy: cemerick: that doesn't sound anything like what you want

21:48 cemerick: amalloy: that describes the situation exactly, actually

21:48 Maybe my initial description was poor…

21:48 amalloy: cemerick: 1xx (in http 1.1, anyway) is for "informational content" while the server is working on creating a real 200+ response

21:49 cemerick: amalloy: Right -- perfect. The content for the URI in question is being generated, but isn't available yet.

21:50 amalloy: cemerick: so you expect it to be available in a few seconds, not a few weeks?

21:50 cemerick: Yeah, seconds, minutes maybe, not hours or weeks.

21:50 amalloy: ah. then 1xx sounds fine

21:51 bridgethillyer: 102 implies actual processing is going on

21:51 ie by a CPU :)

21:52 amalloy: cemerick: or maybe 202?

21:52 cemerick: bridgethillyer: exactly right -- thing's in the oven, will be out shortly.

21:52 bridgethillyer: I think 404 is really the best option even though it would be cool to have something like what you suggest

21:52 amalloy: i'm not sure 102 is allowed for plain http

21:53 dale: Given a Reader in Clojure, is there a nice way to say "read N bytes into a String" other than just doing (.read ...) with a char[]?

21:56 cemerick: amalloy: doesn't 202 imply that that request is what started the processing?

21:56 amalloy: cemerick: it doesn't look that way to me from the rfc, but it's not clear

21:57 qbg: ,(let [sr (java.io.StringReader. "hello, world!")] (apply str (repeatedly 5 #(.read sr))))

21:57 clojurebot: "104101108108111"

21:57 qbg: ,(let [sr (java.io.StringReader. "hello, world!")] (apply str (repeatedly 5 #(char (.read sr)))))

21:57 clojurebot: "hello"

21:57 dale: Heh.

21:57 qbg: Not sure I'd recommend that...

21:58 dale: Agreed.

21:58 hiredman: better to use a bytearrayinputstream

21:58 qbg: (slurp (java.io.StringReader. "hello, world!"))

21:58 ,(slurp (java.io.StringReader. "hello, world!"))

21:58 clojurebot: "hello, world!"

21:58 qbg: Use that

21:58 If you want all of it

21:59 dale: qbg: I need to read N bytes, not the whole file.

22:00 hiredman: That only reads from a byte array though, right? I have an InputStream from a Socket.

22:01 hiredman: dale: was in response to StringReader

22:01 dale: OK.

22:02 hiredman: dale: inputstreams don't read chars regardless

22:03 in that case (byte-array n) is a great way to do what you want

22:04 dale: hiredman: Given s/want/have to do/, it is. Thanks. :)

22:05 I'm just chafing against java.io. I'll eventually get used to its regular beatings.

22:07 cemerick: amalloy: yikes, I see what 102 means by "prevents the client from timing out": curl sits and waits for a "real" response.

22:07 202 it is

22:07 hiredman: file and copy from clojure.java.io are great for that, but I can't speak for the quality of anything else in there

22:07 amalloy: cemerick: muahaha

22:08 hiredman: last time I tried to use a function from either there or contrib (back when it was in contrib) for reading a file into a byte array it did it via a Reader, very bad

22:08 dale: Readers are for characters, InputStreams for bytes, right?

22:09 amalloy: dale: yeah

22:09 hiredman: inputstreams for everything unless I need a reader

22:09 dale: clojure.java.io looks suspiciously like clojure.contrib.io looks suspiciously like clojure.contrib.duck-streams.

22:09 hiredman: correct

22:10 in the process of a lot of duck-streams stuff being promoted from contrib to clojure the namespace was renamed and juggled around

22:11 dale: I see.

22:14 amalloy: what's the clojure naming convention for type conversions? eg what to name a function that takes lisp-named-strings and turns them into lispLikeStrings?

22:14 hiredman: thats not a type conversion

22:14 String in, String out

22:14 amalloy: hiredman: yes, sorry

22:15 i figured it would follow the same convention since it's a translation of sorts

22:16 hiredman: I like a->b

22:43 devn: what is >== in Haskell? <|> ?

22:59 hiredman: >>= is bind

23:06 devn: hiredman: ah of course, thanks

23:26 clizzin: is there a difference between (require '[foo :as f]) and (use '[foo :as f]) ?

23:28 devn: clizzin: http://stackoverflow.com/questions/871997/use-vs-require-in-clojure

23:30 clizzin: devn: that doesn't cover if there's a difference when i have the :as keyword in my call to use

23:31 devn: clizzin: right you are. im not sure the answer to your question. i read a post that i could swear had some info on this exact problem but im having trouble finding it.

23:32 clizzin: devn: interesting, let me know if you find it

23:32 devn: clizzin: is there any reason in particular you're asking?

23:33 my wild guess here is that require is preferred

23:33 clizzin: devn: no, just curious. it does seem silly to have two ways of doing the exact same thing

23:33 devn: clizzin: im trying to imagine the use case myself :)

23:36 clizzin: you understand that use accepts extra opts right?

23:36 clizzin: devn: yeah, although the only ones i'm familiar with are :only and :exclude

23:37 devn: clizzin: there's also a :rename

23:38 clizzin: but i think it's probably best to look at hosw similar require and use are under the covers

23:39 clizzin: devn: gotcha. thanks for the info

23:39 devn: 'use is (defn use [& args] (apply load-libs :require :use args)

23:40 'require is (defn require [& args] (apply load-libs :require args))

23:48 clizzin: it seems like they're the same thing in that case, but in one case you have access to the extra options, but someone smarter than me will likely correct my mistake at any moment

23:51 clizzin: devn: cool thanks

23:53 dale: I suspect the difference between use and require there is that use will (refer) to foo, require will not?

23:53 And the fact that use accepts :as is probably just a side-effect of the fact that it's implemented as a superset of require's functionality?

23:54 devn: clizzin: heh, ill quit talking at you now, but skim the 1.2.0 source (or search) for load-one, load-all, load-lib, load-libs, require, use, defmacro ns, refer-clojure, and alias

23:54 dale: I guess (use '[foo :as f :only y]) might be useful to only bring y into scope while leaving the rest of the namespace accessible through f.

23:54 devn: dale: yeah it's a chisel where use is a machete

23:54 i think that you're explanation is correct

23:58 clizzin: dale, devn: pretty sure that's not what (use '[foo :as f :only y]) does; see http://clojuredocs.org/clojure_core/clojure.core/use#example_170 for a counterexample

23:59 actually, that's the code snippet that first alerted me to the fact that you can have :as with use

Logging service provided by n01se.net