#clojure log - Aug 13 2012

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

0:26 djanatyn: when using defrecord, is there a way to explicitly specify what type you want things to be?

0:27 like, if you want a collection of some sort, or a string or a number

0:27 McMartin: You can extend the type or inline it like it were reify

0:27 I don't believe you can pick an actual class to extend from without using proxy, though

0:28 djanatyn: *nod*

0:28 clojure's records are a lot like Haskell's

0:30 McMartin: Clojure has the best immutable datatypes I've seen outside of Haskell, yeah

0:36 djanatyn: umm, another question!

0:36 I'm using hiccup.core and trying to make a bunch of p elements

0:37 I have a list of strings, foo. I want to return [:p bar] for each bar in foo

0:38 I tried (map #(:p %) '("one" "two" "three")) but it returns (nil nil nil) since it tries to eval (:p "one") (:p "two") and (:p "three"), which are all nil

0:39 Cr8: that #(:p %) is equivalent to (fn [x] (:p x)), or it tries to lookup the key :p in each string as if it were a map

0:40 jeremyheiler: Maybe (map #(vector :p %) ["one" "two" "three"])

0:40 Cr8: you can use (map (fn [x] [:p x]) ...

0:40 qmx: is amotoen the best peg-parser in clojure land? any other recommendations?

0:40 Cr8: jeremyheiler's suggestion also will work

0:41 or even (map (partial vector :p) ...

0:41 jeremyheiler: ,(map #(vector :p %) ["one" "two" "three"])

0:41 clojurebot: ([:p "one"] [:p "two"] [:p "three"])

0:41 djanatyn: Cr8: thanks!

1:03 gah. I feel so dirty. it's really weird using functional programming concepts without the strictness of haskell's type system

1:03 I really like clojure, though. this is cool!

1:03 I just kinda feel like my code is going to explode

1:04 McMartin: Don't forget that evaluation is *usually* eager in Clojure >_>

1:04 * McMartin has only been stung by that five or six times

1:06 djanatyn: ...am I really supposed to use (spit) and (slurp) for IO?

1:06 Or is there an alternative that's more idiomatic?

1:07 jeremyheiler: clojure.java.io are the wrappers around the standard java io classes.

1:08 spit and slurp use that underneath.

1:19 amalloy: djanatyn: btw, i generally advocate the use of 'for in many situations where some would use 'map. for example, (for [p '[one two three]] [:p p])

1:21 and no, spit and slurp are hardly the only options. they're pretty lightweight, where you don't mind forcing everything into a string for a while. for large tasks, something more like reader and writer

1:26 djanatyn: *nod*

1:26 * djanatyn is writing a tiny little blog in clojure

1:27 djanatyn: http://sprunge.us/aLaY?cl

1:29 or alternatively http://dpaste.org/2JxDa/ without common lisp syntax highlighting

1:46 lambda-stu: djanatyn: i'd use a map rather than a record for posts. see http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/

1:50 djanatyn: lambda-stu: thanks!

2:18 harja: 3

2:18 oops.

2:33 Bahman_Mourning: I have this weird problem with lein...

2:34 When I do clojure-jack-in the REPL starts fine...

2:34 no errors whatsoever.

2:34 But none of my namespaces are available...I have to compile them manually to be accessible from REPL.

2:36 Any hints?

2:39 DaoWen: Bahman_Mourning: is lein starting in the right directory?

2:39 you should be able to check by running (System/getProperty "user.dir")

2:40 Bahman_Mourning: DaoWen: By "right directory" you mean the one that contains project.clj? If that's the case, yes.

2:43 DaoWen: Bahman_Mourning: what do you mean by "manually compile" ?

2:43 Bahman_Mourning: DaoWen: I have to use C-c C-k or C-c C-r

2:44 DaoWen: what happens if you run (use 'your.name.space)

2:44 ?

2:44 (before manually compiling it)

2:45 Bahman_Mourning: Let me check...

2:46 DaoWen: (use) returns nil as expected but then the symbols are not accessible again.

2:47 DaoWen: that's confusing... it doesn't throw an error, but you can't access any of the vars.

2:47 Bahman_Mourning: Exactly.

2:48 DaoWen: Does it help if I put my project.clj on pastebin?

2:48 DaoWen: Bahman_Mourning: I don't use emacs, so I don't really know what the problem is

2:49 Bahman_Mourning: DaoWen: Ah...thank you anyway.

2:49 DaoWen: that might help someone else help you—but most everyone else are probably asleep

2:49 Bahman_Mourning: DaoWen: One thing. If I start “lein repl” from the command line it shows a normal behaviour...my namespaces are accessible.

2:50 But “lein swank” and clojure-jack-in don't work.

2:51 don't work = don't work as expected :-)

2:52 DaoWen: yeah, I was thinking swank might have been starting up in the wrong directory—that was my best guess. I really don't understand how calling (use '...) could return successfully but not have any of the symbols available.

2:53 Bahman_Mourning: good luck!

2:53 Bahman_Mourning: DaoWen: Thanks again for your time.

3:12 I used “[lein-swank "1.4.4"]” in my :plugins section...

3:13 But when I check the classpath of the running swank-clojure, there is only “.m2/repository/swank-clojure/swank-clojure/1.4.0/swank-clojure-1.4.0.jar”

3:15 DaoWen: Bahman_Mourning: have you tried running lein deps?

3:16 Bahman_Mourning: DaoWen: Zillions of times :-)

3:17 DaoWen: haha

3:17 yeah, I'm not going to be of any help here

3:40 djanatyn: Is there a 'map that throws out the results and evaluates solely for side-effects?

3:40 DaoWen: djanatyn: try doseq

3:41 djanatyn: kind of like mapM_ in haskell

3:41 DaoWen: djanatyn: doseq is more like for, but I think it will do what you want

3:41 http://clojuredocs.org/clojure_core/clojure.core/doseq

3:42 djanatyn: yes, it does, and it actually makes it more concise. thank you!

3:43 DaoWen: djanatyn: glad I could help!

4:21 djanatyn: How would I have clojure sort through dates? Can I just use the sort function, or do I have to manually specify how to sort dates?

4:21 I was going to use either the date-clj or clj-time libraries on clojars.

4:28 hyPiRion: djanatyn: clj-time is nice

4:44 AustinYun: i wonder, is there anything i can do that other people might actually find useful :p

4:49 ro_st: can you make coffee? -grin-

4:54 jyc: does anyone here use counterclockwise and know how to terminate a REPL (sorry if this is the wrong channel)

5:00 * AustinYun doesn't use ccw

5:01 AustinYun: does ctrl+D not work?

5:05 mduerksen: jyc: do you mean how to interrupt a running evaluation in the repl, or really killing the repl itself?

5:06 jyc: mduerksen: killing the REPL - otherwise it seems running again just piles up processes

5:09 clgv: jyc: got to console view and click the red square

5:10 *go

5:10 ro_st: i don't suppose anyone knows how to teach Chrome to show the mimetype application/clojure as plaintext?

5:11 jyc: clgv: awesome, thanks so much. is there a keyboard shortcut for that?

5:12 clgv: jyc: I don't know - you can search for it in perferences -> keys

5:14 Raynes: AustinYun: Did you ever take a look at that example I showed you?

5:15 AustinYun: yup

5:15 haven't really poked around yet though, although it was quite short

5:18 hm, i don't understand the control bit

5:19 oh wait

5:25 man how does that work

5:25 it's liek magic

5:25 it behaves incorrectly where (abs n) == the array length but

5:26 DaoWen: ro_st: try this https://chrome.google.com/webstore/detail/cgjalgdhmbpaacnnejmodfinclbdgaci?hl=en-US

5:26 let us know how it works

5:28 AustinYun: Raynes: ok i honestly don't know what's going on lol

5:28 except if you for example, do (add-one [1 1 1 1] 1 1) you get [2 2 1 1] which is wrong

5:28 ro_st: thanks DaoWen. will do

5:29 AustinYun: seems to just be off by 1 in the number of times it will increment

5:29 ro_st: anyone using fetch?

5:30 i want to use it but i'm not using noir

5:30 DaoWen: AustinYun: are you still working on that double-reverse array increment problem?

5:30 AustinYun: er i wasn't really, but raynes sent me a solution

5:31 which is 11 lines, which is less than half of mine

5:31 DaoWen: refheap.com/paste/4252

5:38 DaoWen: AustinYun: I don't think that's doing the same thing as the problem you described

5:40 AustinYun: the problem said to increment up to N occurrences of the number, but that code looks like it just searches N slots in the vector and increments any occurrences of the target value that appear

5:40 AustinYun: i've got it open in a repl right now

5:40 and i believe you're right

5:41 it tricked me into thinking it worked because for the example array [1 4 1 5 1]

5:41 and the example params, it works

5:41 but that's just because of the odd off-by-one behavior lol

5:43 DaoWen: AustinYun: I didn't actually try running it -- I just read the code :-p

5:43 AustinYun: i couldn't read the code so i had to run it lolol

5:43 * AustinYun is sadly a nub

5:43 AustinYun: also don't know what "update-in" does, except it seems to be a built-in

5:45 DaoWen: check the docs: http://clojuredocs.org/clojure_core/clojure.core/update-in

5:46 update-in is usually used for nested structures... in this case I think assoc would have worked just fine instead.

5:50 hyPiRion: Consider update-in as assocs within assocs.

5:50 ,(update-in {:a {:b 3}} [:a :b] 5)

5:50 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

5:50 hyPiRion: woo

5:51 ,(update-in {:a {:b 3}} [:a :b] + 5)

5:51 clojurebot: {:a {:b 8}}

5:51 nbeloglazov: ,(assoc-in {:a {:b 3}} [:a :b] 5)

5:51 clojurebot: {:a {:b 5}}

5:55 jyc: just curious, where in the clojure documentation does it say that & makes a function with variable arguments?

5:56 AustinYun: in defn; it's not super explicit about it

5:56 DaoWen: http://clojure.org/special_forms#Special Forms--(let [bindings* ] exprs*)

5:56 ah--that shouldn't be split

5:57 jyc: cool, thanks!

5:57 DaoWen: member:jyc: that whole thing is a URL

5:57 nbeloglazov: Why doesn't clojurebot support javadoc function?

5:57 DaoWen: wow, my pasting is sucking.

5:57 jyc: DaoWen: yep, copied it over

5:57 will be fun to read through all of this, heh

5:57 DaoWen: jyc: search for "& followed by" on that page

5:57 clojure-newcomer: hey guys, anyone know how I can get the request uri using Noir ?

5:58 jyc: DaoWen: thanks again

5:58 AustinYun: wait, then what does the [params* ] mean?

5:59 DaoWen: AustinYun: that's grammer-speak

5:59 the * is a kleene-star

5:59 nbeloglazov: Also does clojurebot have command to show clojuredocs url for given function?

5:59 DaoWen: it just means "one or ore"

5:59 "one or more"

5:59 wow

6:00 no, it means "zero or more"

6:00 I'm going to leave now :-p

6:00 bye

6:00 AustinYun: ok so i was conflating the "zero or more" part with the part where you can specify positional parameters and a "rest" param

6:03 hyPiRion: Huh

6:04 ,(let [] (+ 1 2 3))

6:04 clojurebot: 6

6:04 hyPiRion: Interesting.

6:07 AustinYun: ,(let [] (inc))

6:07 clojurebot: #<CompilerException clojure.lang.ArityException: Wrong number of args (0) passed to: core$inc, compiling:(NO_SOURCE_PATH:0)>

6:07 AustinYun: <_<

6:07 hyPiRion: AustinYun: heh.

6:08 ,(let [])

6:08 clojurebot: nil

6:09 AustinYun: ah

6:09 actually that makes sense

6:10 since (let []) just defines a lexical scope for the expression afterward to run in, right?

6:10 hyPiRion: Yeah

6:10 It's interesting that the lexical scope can be empty though, I didn't know that.

6:11 AustinYun: so (let [] expr) is just (expr) in a blank scope -- i guess if you had problems with namespace pollution or something it might be useful?

6:11 wonder if it'll automatically shadow other vars to be undefined

6:11 probably not, that makes no sense

6:11 hyPiRion: AustinYun: Nah, (let [] expr) is expr in a blank scope.

6:11 AustinYun: 3:10 AM and i'm more of an idiot than usual

6:12 hyPiRion: I cannot see any reason for this to be useful, lol.

6:12 AustinYun: ,(let []) is interesting though

6:12 clojurebot: nil

6:12 AustinYun: ,()

6:12 clojurebot: ()

6:12 AustinYun: hm

6:12 hyPiRion: oh, here's an interesting one

6:12 ,(= (class ()) (class '(1)))

6:12 clojurebot: false

6:12 AustinYun: ,(class ())

6:12 clojurebot: clojure.lang.PersistentList$EmptyList

6:12 hyPiRion: ,(class ())

6:12 clojurebot: clojure.lang.PersistentList$EmptyList

6:13 AustinYun: lol

6:13 hyPiRion: hehe

6:13 nbeloglazov: ,(type ())

6:13 clojurebot: clojure.lang.PersistentList$EmptyList

6:13 AustinYun: ok so EmptyList is its own type

6:13 hyPiRion: I don't think () has any metadata.

6:13 ,(meta ())

6:13 clojurebot: nil

6:13 AustinYun: ,(class '(1))

6:13 clojurebot: clojure.lang.PersistentList

6:14 hyPiRion: There are many strange things in Clojure.

6:14 ,(case 1 2)

6:14 clojurebot: 2

6:14 AustinYun: ,(and () true)

6:14 clojurebot: true

6:15 AustinYun: common lisp () is like the only false value right?

6:16 hyPiRion: yeah

6:16 well, there's t and nil, which roughly translates to true and nil.

6:17 Everything's true unless it's nil in Common lisp.

6:17 AustinYun: ,(class [])

6:17 clojurebot: clojure.lang.PersistentVector

6:17 nbeloglazov: :)

6:17 AustinYun: not PersistentVector$EmptyVector huh

6:18 Toheii: , (= (class (list ())) (class '(1)))

6:18 clojurebot: true

6:18 AustinYun: ,(class {})

6:18 clojurebot: clojure.lang.PersistentArrayMap

6:18 hyPiRion: (()) is a list with one element though.

6:18 ,(list ())

6:18 clojurebot: (())

6:18 hyPiRion: vs ##(list)

6:18 lazybot: ⇒ ()

6:18 hyPiRion: ,(class (list))

6:18 clojurebot: clojure.lang.PersistentList$EmptyList

6:19 AustinYun: yup

6:19 Toheii: You can only get the EmptyList type with (quote ()) or '() then right?

6:19 AustinYun: ,(range 0)

6:19 clojurebot: ()

6:19 AustinYun: ,(class (range 0))

6:19 clojurebot: clojure.lang.LazySeq

6:19 AustinYun: <_< crap

6:21 ,(class (pop (1)))

6:21 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

6:21 hyPiRion: ,(let [id (memoize identity) alist (id (java.util.ArrayList.)) vect (id [])] (.add alist 1) vect)

6:21 clojurebot: #<ArrayList [1]>

6:21 AustinYun: ...

6:21 ,(class (pop '(1)))

6:21 clojurebot: clojure.lang.PersistentList$EmptyList

6:21 AustinYun: there we go

6:21 clgv: $javadoc java.util.Date

6:21 lazybot: http://docs.oracle.com/javase/6/docs/api/java/util/Date.html

6:22 clgv: nbeloglazov: ^^

6:22 $clojuredocs println

6:22 nbeloglazov: $javadoc Thread

6:22 lazybot: http://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html

6:22 clgv: ok, thats not built-in

6:22 AustinYun: maybe

6:23 $clojuredoc println

6:23 * AustinYun facepalm

6:23 nbeloglazov: clgv: thanks

6:25 Qerub: Is there a nicer substitute for the expression #(%1 %2)?

6:26 nbeloglazov: Qerub: try apply

6:26 hyPiRion: Qerub: Clojure has no funcall equivalent.

6:26 AustinYun: (fn [x y] (apply x y)) ? or something

6:27 nbeloglazov: (apply println 1)

6:27 ,(apply println 1)

6:27 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>

6:27 hyPiRion: that'll crash

6:27 nbeloglazov: Yep

6:28 AustinYun: ,(apply println '1)

6:28 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>

6:28 Bronsa: (deliver inc 1)

6:28 ,(deliver inc 1)

6:28 clojurebot: 2

6:28 AustinYun: ,(apply println '(1))

6:28 clojurebot: 1

6:28 hyPiRion: ,(let [funcall (fn [f & args] (apply x args))] (funcall println 1))

6:28 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0)>

6:28 Qerub: ,(apply println 1 [])

6:28 clojurebot: 1

6:28 hyPiRion: ,(let [funcall (fn [f & args] (apply f args))] (funcall println 1))

6:28 clojurebot: 1

6:29 AustinYun: difference between javascript call and apply

6:29 hyPiRion: Bronsa: How does that work? I though deliver took a promise, not a fn

6:30 nbeloglazov: ,(doc deliver)

6:30 clojurebot: "([promise val]); Alpha - subject to change. Delivers the supplied value to the promise, releasing any pending derefs. A subsequent call to deliver on a promise will throw an exception."

6:31 hyPiRion: Oh man. That's just mean and dangerous.

6:31 ,(source deliver)

6:31 clojurebot: Source not found

6:31 nbeloglazov: source deliver

6:31 hyPiRion: It's basicall

6:31 (defn deliver [promise val) (promise val))

6:32 clgv: hyPiRion: the `source` function needs access to the source files. probably the bot is aot compiled

6:32 $source deliver

6:32 lazybot: deliver is http://is.gd/mWYXsL

6:32 clgv: hmm that function seems to have an outdated database

6:32 Qerub: nbeloglazov, hyPiRion: I guess not then. Thanks for discussing!

6:32 AustinYun: ,(deliver + 1 2 3)

6:32 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core$deliver>

6:32 Qerub: Does this look crazy to you? (defn f [x] (condp #(%1 %2) x, number? do-something, symbol? do-something-else, …))

6:33 I'd like to avoid the repetition in (cond (number? x) do-something, (symbol? x) do-something-else, …).

6:34 AustinYun: defmulti?

6:34 clojurebot: defmulti doc is python

6:34 AustinYun: O_o

6:34 hyPiRion: Qerub: Hmm, can you dispatch on type or class?

6:34 (condp class x ...)

6:34 AustinYun: why is defmulti doc python

6:35 hyPiRion: AustinYun: I believe clojurebot is growing more and more sentient by each day. Bugs included.

6:35 Qerub: hyPiRion: I suppose i could use `instance?` (to cover inheritance).

6:36 AustinYun: anyway, it doesn't look THAT crazy, except you might want to make a multi-method that dispatches on the type of x

6:36 hyPiRion: Qerub: sounds good.

6:37 howard: If you are looking for a Clojure document database engine implementation, please check this out: Aurinko, a very compact yet powerful networked document database engine. https://github.com/HouzuoGuo/Aurinko

6:39 hyPiRion: Qerub: I haven't really dispatched that much on classes, but if it grows large, I'd use multimethods or protocols.

6:41 Qerub: hyPiRion: Yeah, I understand why. In this case with few branches and no need for extensibility a simple cond works well.

6:41 hyPiRion: Thanks!

6:42 AustinYun: howard: interesting, you just release?

6:42 howard: it's a pet project i've been working on, to practice using Clojure

6:48 hyPiRion: howard: Interesting. A quick tips: For Github, it's better to have .md-files as doc

6:48 howard: thank you

6:48 will do soon

6:48 me still learning to use github :P

6:50 Cr8: I almost wrote something like this last week :D I might use this

6:50 hyPiRion: I haven't got enough time to look at the source AND understand it, but the specs look very nice for being 700 loc.

6:52 ro_st: btw, cljs <> clj remoting with fetch is ludicrously simple AND easy

6:52 especially when using enfocus and pubsub to declaratively bind it all together

6:53 the world is rewarding me for the hours of jquery + php ajax i haven't done -grin-

6:53 howard: im planning to give it a skip list index so it'll do range query much faster

6:54 Cr8: howard: what is it now, just a linear thing?

6:54 howard: it only has a hash index at the moment

6:54 Cr8: ah

6:54 reminds me of bitcask

6:54 howard: hash lookup is very fast, as advertised, it easily does 6000+ lookups a second

6:55 it supports range queries, however they're not optimized

6:55 range queries need to scan collection, and that performance is about 160 milliseconds per 1k documents

6:56 Cr8: yeah, I saw that

6:56 howard: correct.. 80 milliseconds 1k documents

6:56 Cr8: hm, could you make a log structured skip list

6:57 they always seemed more fit for an in-memory thing to me

6:57 howard: in-memory...?

6:57 Cr8: as opposed to on-disk

6:57 howard: you mean skip list suits in-memory db better?

6:58 Cr8: i mean skip lists themselves work better in memory

6:58 hyPiRion: I think he means having the skip list in memory.

6:58 howard: i see..

6:58 hyPiRion: zing.

6:58 Cr8: than being stored on disk

6:58 howard: um..

6:58 my guess b+tree index will be 300+ lines of clojure

6:58 skip list may be 200+

6:59 ^_^

6:59 Cr8: Ex: LevelDB uses skiplists for its in memory index for the current items in the batch to be written to disk, but on-disk it uses b-trees

6:59 howard: i see. thank you

6:59 so btree index rather than skip list...

7:00 Cr8: for on-disk indexes, anyway, i think it is more workable

7:00 howard: :D

7:01 * Cr8 created the current disk storage engine used in Couchbase 2

7:03 Cr8: but its all log structured which limits the types of data structures I can use on disk. you could probably do skip lists and the like more easily if you were okay with clobbering pointers in-place, but you risk corruption that way

7:03 howard: yeah...

7:04 Cr8: in the case of a write only being half done when something blows up

7:04 howard: i need to study how those dbs handle index write failure

7:04 wmealing_1: java.lang.IllegalStateException: -main already refers to: #'feedparser-clj.core/-main in namespace: blah.core

7:05 as blah is my application, does that mean that feedparser-clj's main overrides mine (or trying to compete)

7:05 hyPiRion: wmealing_1: I suspect you use (:use feedparser-clj.core) or something

7:05 wmealing_1: should a library have a core ?

7:05 yep

7:05 i am

7:05 rich is coming to brisbane next fri.. am definitely going to

7:05 see him

7:06 hyPiRion: To not include the -main function in it, you can do (:use [feedparser-clj.core :exclude [-main]])

7:06 I think that should solve your problem.

7:06 howard: brisbane :D

7:06 im in melbourne

7:07 wmealing_1: howard: i'm sorry about the weather.

7:07 howard: me too

7:07 hahahaha

7:07 i caught cold last week

7:07 many people did too

7:08 (time (doseq [v (range 10000)]))

7:08 ,(time (doseq [v (range 10000)]))

7:08 clojurebot: "Elapsed time: 119.989013 msecs"

7:08 howard: ,(time (doseq [v (range 10000)]))

7:08 clojurebot: "Elapsed time: 10.492108 msecs"

7:08 howard: ,(time (doseq [v (range 10000)]))

7:08 clojurebot: "Elapsed time: 10.695053 msecs"

7:09 hyPiRion: Let's see even more magic

7:09 howard: , (time (doseq [v (range 10000)] (read-string "{}")))

7:09 clojurebot: "Elapsed time: 108.588635 msecs"

7:09 howard: , (time (doseq [v (range 10000)] (read-string "{}")))

7:09 clojurebot: "Elapsed time: 21.022111 msecs"

7:09 howard: , (time (doseq [v (range 10000)] (read-string "{}")))

7:09 clojurebot: "Elapsed time: 4.465608 msecs"

7:09 howard: , (time (doseq [v (range 10000)] (load-string "{}")))

7:09 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

7:09 howard: boo

7:09 Cr8: hahaha

7:09 hyPiRion: ,(time (doall (map inc (range 10000))))

7:09 clojurebot: "Elapsed time: 38.136212 msecs"

7:09 (1 2 3 4 5 ...)

7:10 hyPiRion: ,(time (map inc (range 10000)))

7:10 clojurebot: "Elapsed time: 0.052606 msecs"

7:10 (1 2 3 4 5 ...)

7:10 Cr8: ,(time (mapv inc (range 10000)))

7:10 clojurebot: "Elapsed time: 47.154055 msecs"

7:10 [1 2 3 4 5 ...]

7:10 wmealing_1: howard: why dont you come to brisbane for it ?

7:10 howard: i wish i could..

7:11 meh, i wish my company could pay for me to go to qld

7:11 hahah

7:11 what days is Rich gonna be in Brisbane?

7:12 wmealing_1: Friday, i think

7:12 let me check

7:12 howard: yesterday, i put this project to public using name "ClojureDB", because it stores documents in clojure syntax, interacts with clients using clojure syntax

7:12 then Rich told me to think of another name

7:13 so I thought, Aurinko sounds good in English, and has good meaning in Finnish

7:13 hyPiRion: howard: You're Finnish?

7:14 howard: i wish i was

7:14 nope :(

7:14 i love northern European countries

7:14 as much as I love Australia

7:14 Cr8: I suppose using "Clojure" in a project name is problematic

7:15 howard: yeah i agree... it was my bad

7:15 wmealing_1: ah

7:15 howard: i'm incorrecet

7:15 howard: http://www.bfpg.org/events/77110852/

7:16 howard: woow

7:16 <3

7:17 wmealing_1: hyPiRion: thanks

7:18 howard: they should add "clojure" into "we're about"

7:22 good night guys

7:52 [1]Abraham: how to use regular expr in clojurescript

7:58 ro_st: same way you do in clojure

7:58 ,(doc re-find)

7:58 clojurebot: "([m] [re s]); Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find(). Uses re-groups to return the groups."

7:59 ro_st: ,(re-find #"\s+" "string with some stuff in it")

7:59 clojurebot: " "

7:59 ro_st: etc

8:07 nvy: ,(doc def)

8:07 clojurebot: Gabh mo leithsc?al?

8:09 ro_st: oh….kay, then

8:15 hyPiRion: What in the world.

8:15 ,(doc def)

8:15 clojurebot: Pardon?

8:15 hyPiRion: ,(doc str)

8:15 clojurebot: "([] [x] [x & ys]); With no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty string. With more than one arg, returns the concatenation of the str values of the args."

8:15 hyPiRion: ,(doc foobar)

8:15 clojurebot: Gabh mo leithsc?al?

8:16 ro_st: probably couldn't put a doc on def because you need def to do it

8:16 hyPiRion: I can doc my def though

8:16 ro_st: show-off :-)

8:16 hyPiRion: ,(doc doc)

8:16 clojurebot: "([name]); Prints documentation for a var or special form given its name"

8:17 ro_st: &(doc def)

8:17 lazybot: java.lang.SecurityException: You tripped the alarm! def is bad!

8:17 hyPiRion: I mean, there shouldn't be any issues with it :p

8:17 ro_st: -shrug-

8:18 hyPiRion: &(doc (symbol "def"))

8:18 lazybot: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol

8:52 cshell: is there any core function for generating n distinct random integers?

8:54 naeg: ,(repeatedly 10 #(rand-int 50))

8:54 clojurebot: (7 23 27 15 47 ...)

8:55 naeg: cshell: where 10 is n (number of random numbers) and 50 is the range of those random numbers

8:55 cshell: right, but I can get collisions with that

8:55 naeg: oh, misunderstood you

8:55 cshell: thanks though :)

8:56 naeg: don't know about a distinct way, would probably write it based on this

8:56 cshell: that's what I was thinking

8:56 using a set or something

8:56 naeg: first thing that came to my mind too, but I'm farely new to clojure

8:57 cshell: yeah, me too

8:58 naeg: cshell: show me your solution please when you finished it, coming up with one too j4f

8:58 cshell: cool, no problem

9:01 clgv: cshell: well, build a random permutation and take the first n numbers

9:02 cshell: ##(->> (range 50) shuffle (take 10))

9:02 lazybot: ⇒ (22 10 31 23 9 41 18 42 49 26)

9:02 cshell: nice, very clever!

9:03 thanks clgv!

9:03 naeg: clgv: isn't there a chance that this won't come up with 10 distinct random numbers?

9:03 clgv: but maybe not that efficient if the range is much larger than the count of numbers you select

9:04 naeg: nope

9:04 cshell: yeah, i'll have 150k items and i only want 4 of them :)

9:05 naeg: oh, I just understood shuffle now

9:05 cshell: maybe I just shuffle the collection and take 4?

9:05 clgv: cshell: then better do ##(->> (repeatedly #(rand-int 150000)) distinct (take 10))

9:05 lazybot: ⇒ (102321 125971 111906 91551 73671 147131 132563 33939 67226 98262)

9:06 clgv: the probability for conflicts is pretty small for that ratio

9:06 so for k=10 this procedure will be almost O(k)

9:06 cshell: but with what you just pasted there won't be conflicts, because of distinct right?

9:07 Chousuke: clgv: with a true RNG it could run forever though :P

9:07 clgv: yes. but it could run long for bigger ratios of k/n

9:07 Fossi: yay, bogosort :>

9:07 cshell: got it

9:07 thanks clgv!

9:07 clgv: Chousuke: why should that happen?

9:07 Chousuke: clgv: you might get an infinite sequence of the same number

9:07 clgv: Chousuke: with probability zero? :P

9:08 *almost zero ;)

9:08 Chousuke: then again, you might also win the lottery every week from random dropped lottery tickets you find on the street

9:09 clgv: cshell: you can try both and see what works best for those numbers. 150k might be small enough for the shuffle

9:09 Phoshi: Hey, everyone. I'm trying to give clojure a shot, but I'm coming up with some issues uh, embarrasingly early. I can get a repl up and that's fine, but everything I'm looking at is like, "if you don't use lein you're going to die a horrible death" so I figured sure why not. Only problem is I flat out can't get it to work, it's just sitting there not doing anything. java starts and uses an impressive amount of RAM, but it just waits and hangs until I ki

9:10 clgv: #(->> (range 150000) shuffle (take 10) time)

9:10 lol or not ;)

9:10 ups

9:10 &(->> (range 150000) shuffle (take 10) time)

9:10 lazybot: ⇒ "Elapsed time: 288.844763 msecs" (73580 109567 38332 56366 7726 100338 57580 82006 48682 114910)

9:10 clgv: looks not to bad. but that depends how fast you need it

9:10 ##(->> (repeatedly #(rand-int 150000)) distinct (take 10) time)

9:10 lazybot: ⇒ "Elapsed time: 263.035961 msecs" (1788 16291 138268 53065 111626 49964 110403 27401 8766 144423)

9:11 clgv: ##(->> (repeatedly #(rand-int 150000)) distinct (take 10) time)

9:11 lazybot: ⇒ "Elapsed time: 221.680642 msecs" (48531 47565 32250 21249 79697 92471 85817 20564 98392 38251)

9:11 Chousuke: hm, why is that so slow

9:12 clgv: probably, one should make a real benchmark

9:12 cshell: maybe it's slow cause it's generating 150k random numbers

9:13 or is it lazy?

9:13 clgv: yeah range, distinct and take are lazy

9:14 metajack: just generating random numbers without distinct takes about 170ms for me

9:14 cshell: but won't distinct for evaluation for all 150k random numbers?

9:14 metajack: oh sorry. misread that. 0.177 ms not 0.177 s.

9:14 cshell: or does it just wrap it lazily?

9:15 clgv: (time (dotimes [_ 100] (->> (range 150000) shuffle (take 10) doall))) => "Elapsed time: 2629.182387 msecs"

9:15 (time (dotimes [_ 100] (->> (repeatedly #(rand-int 150000)) distinct (take 10) doall))) => "Elapsed time: 16.077269 msecs"

9:16 cshell: interesting

9:16 this is a good discustsion.

9:17 metajack: distinct is lazy. it walks the sequence keeping a set of things it's seen and skipping anything it sees again

9:17 clgv: cshell: if you make k bigger relative to n the second will get slower

9:17 cshell: makes sense

9:18 clgv: at 50% you get with (time (dotimes [_ 100] (->> (repeatedly #(rand-int 150000)) distinct (take 75000) doall))) => "Elapsed time: 13357.610222 msecs"

9:19 magopian: guys, what does it mean when an integer has a appended N

9:19 like 1N

9:19 does it make it a long?

9:20 clgv: bigint afaik

9:20 &(type 1N)

9:20 lazybot: ⇒ clojure.lang.BigInt

9:21 magopian: oh ok

9:21 and is there a way to coerce function parameters to BigInt ?

9:21 oh, bigint ;)

9:25 clgv: magopian: you might skipt coercing but using +' which autopromotes to BigInt if it would overflow otherwise ##(doc +')

9:25 lazybot: ⇒ "([] [x] [x y] [x y & more]); Returns the sum of nums. (+) returns 0. Supports arbitrary precision. See also: +"

9:26 magopian: clgv: thanks a lot !

9:26 i'll dig into that

9:26 clgv: see ##(+ Long/MAX_VALUE +1)

9:26 lazybot: java.lang.ArithmeticException: integer overflow

9:26 clgv: and ##(+' Long/MAX_VALUE 1)

9:26 lazybot: ⇒ 9223372036854775808N

9:27 wmealing_1: can someone suggest a library to strip all html formatting from a html string, i kind of just want the raw text, not the escaped data

9:28 metajack: wmealing_: I use enlive for that.

9:29 wmealing_1: what part of enlive ?

9:29 metajack: there's a function called texts which does it

9:29 wmealing_1: thanks, will look into it

9:30 metajack: something like (->> s (StringReader.) html/html-resource html/texts (apply str))

9:51 wmealing_1: that looks not too bad

10:13 ro_st: ohpauleez :-) -remote requires -browser which tries to use localStorage. if you update -browser to first check for localStorage before using it, it should be goo

10:13 good*

10:14 ohpauleez: browser was updated not to use local storage - https://github.com/shoreleave/shoreleave-browser/commit/cf3350b598625c35cbf7ecbaddb67c146e3a6cf3

10:15 that's why I wanted to see the exception you were getting

10:15 if I missed a line somewhere or if you had a stale jar

10:17 ro_st: comin' up

10:19 oh that's not fair! now it seems to be working :-|

10:21 ok. i'm a narna. it's compiling and running now

10:23 wmealing_1: happens ot the best of us

10:23 ohpauleez: ro_st: Cool, totally keep me posted and then update the ticket however you need to. I promise you fast turn around :)

10:23 beat me to it! Thanks!

10:24 ro_st: ok. so i'm not using noir. i've already converted fetch's noir backend to not use noir, but i see you use a namespace loader for your noir remote backend as well

10:25 ohpauleez: yeah - lynaghk also suggested I make it non-noir specific. If you send me some patches I'll do my yes to integrate them and refactor out noir

10:25 ro_st: well, i switched to compojure for the routing part :-)

10:25 paste inbound

10:25 ohpauleez: Shoreleave is extremely opinionated

10:25 cool, thanks!

10:26 (not because I think it should be, but because it was built around real projects)

10:26 ro_st: i'm down with that, it's just that the api for the js app is focussed on just doing that, so i don't need a whole web framework

10:26 ohpauleez: totally

10:27 ro_st: https://www.refheap.com/paste/4314

10:27 so, i can get this far converting sl-r's backend, but i'm not sure about the NS loading

10:28 it might make sense to provide access to remotes as a ring middleware instead of as an app handler?

10:28 treehug: how would i approach the problem of getting swank to display repl return values in formats other than text? i do a lot of image processing in clojure and would like for example, an image to be displayed rather than #<PlanarImage ….>

10:29 ohpauleez: Ahh, right, these changes are easier. Creating the ns loading isn't that hard, I just have to re-create a single noir function

10:29 ro_st: That was Kevin's idea as well, remotes as middleware

10:30 ro_st: ah i see

10:30 ohpauleez: I think in the long run, that's the way to go, but I don't know how I'd port all the pieces to work there yet (something I need to sit and think about for a little bit)

10:31 ro_st: ok, i'm going to reimplement your noir backend in my own namespace, stealing load-views-ns from noir

10:31 ohpauleez: cool, that should work for now. I'll work on a middleware replacement for 0.2.2 release

10:31 ro_st: nice

10:32 ohpauleez: awesome, thanks a ton!

10:32 ro_st: i'm reallllly enjoying enfocus+pubsub+remotes. so declarative

10:32 ohpauleez: extremely declarative. I'm also a big fan of that combo

10:32 You can hook something up SO fast

10:32 pandeiro: ro_st: ohpauleez: anywhere i can see an example of that?

10:33 i haven't played with enfocus since it was in the earliest stages

10:33 and i am just looking at shoreleave now

10:33 ohpauleez: pandeiro: There's an unfinished demo. If you take the path of ro_st You have to suffer through it :) https://github.com/shoreleave/demo-shoreleave-solr

10:34 ro_st: i actually think you'd be better served not working with the demo. no offence, ohpauleez :-)

10:34 ohpauleez: absolutely none taken :)

10:35 ro_st: heck, let me make one. gimme 10

10:35 ohpauleez: behold the power of an open and capable community!

10:35 * ohpauleez loves open source and the Clojure community

10:35 pandeiro: ohpauleez: hear hear!

10:35 ro_st: cheers, would love to have a gander

10:37 ohpauleez: pandeiro: between using client only request (either CORS or JSONP), Clojure as a data format to do http-rpc, a capable pubsub system, and a nice way to handle the dom - CLJS *is* the killer app

10:38 Shoreleave has the added bonus that I've done most of the grunt work for you (security, cookies, history, etc)

10:38 but it has not been officially announced because it's not officially done :)

10:39 ro_st: i'll add cljsbuild crossovers and show both the cljs app and the backend remote using fns in the same ns

10:40 ohpauleez: ro_st: Also, if this is true, all of Shoreleave's busses will be faster: https://gist.github.com/3335154

10:43 ro_st: is it done, yet ? :-D

10:44 ohpauleez: ro_st: haha

10:47 nvy: dude wat

10:47 scriptor: just a net split

10:48 bja: oudsearch

10:48 nvy: all right

10:48 pandeiro: ro_st: ohpauleez: awesome, very exciting stuff. b/c i am mostly targeting chromium, i end up writing a lot of small wrappers over the HTML5 API. but something more robust would be welcome for sure. then there is the state machine/reactive programming/mvc/insert-paradigm-here question of how to organize UI event code...

10:49 ohpauleez: pandeiro: There are a lot of opinions about the reactive stuff

10:51 ro_st: i still need to learn concepts behind the reactive stuff

10:51 ohpauleez: Personally I think you can cover almost all the real practical ground with enfocus+pubsub. If you need something like computed observables, lynaghk's relax is awesome: https://github.com/lynaghk/reflex

10:52 pandeiro: pubsub is just fine-grained event listeners/handlers, yes?

10:52 ohpauleez: Yeah, it's an event system, but it lets you declare full flows

10:52 you can subscribe a function to a dom event, and functions can subscribe to other functions

10:53 atoms can participate too

10:53 pandeiro: nice

10:53 ohpauleez: and you can broadcast using strings, ints, or keywords

10:54 pandeiro: so a simple data-binding flow would be retrieve data=>store in atom=>update dom=>onchange event=>update atom=>update server ?

10:54 that could be done declaratively?

10:55 ohpauleez: You can do whatever you want. Typically the entrance for me is a dom event. Along the way I might hit a remote sever, and then end of my flow is usually a dom update

10:55 but yes, you bind it declaratively

10:55 you write functions like you normally would

10:55 then all data flow and binding is done by the bus, you just have to plug it together

10:56 clgv: ohpauleez: trying your demo app^^

10:56 ohpauleez: clgv: It doesn't do anything, it's not done yet. But you can use it as a reference for how to use pieces of Shoreleave

10:56 as ro_st said, it's not a good example haha

10:57 clgv: oh damn. have to do this in a month again then ;)

10:57 ro_st: gimme 10 more

10:57 ohpauleez: I really need to finish some stuff up, cut the 0.2.2 release, and announce it on the mailing list

10:57 ro_st: You're the man! Excited to see it (clgv ^^)

10:58 dnolen: fun core.logic post http://dosync.posterous.com/know-your-bounds

10:58 clgv: ohpauleez: well seems to do some user interaction at least ^^

11:00 ohpauleez: dnolen: That's awesome. I read the reference post this morning. Great follow-up

11:00 also nice to see bounded-listo added

11:03 clgv: I still dont like the "o" suffix - is there no better naming choice?

11:04 clojure-newcomer: hey guys, I want to organise my cljs app a bit, I don't want everything in main.cljs I want other cljs files made available too, any best practice I can follow ?

11:04 ohpauleez: clojure-newcomer: whatever works best for your app

11:04 clojure-newcomer: right now when I try to bind anything outside of main.cljs in my cljs-binding template it screws up

11:04 ohpauleez: use main.cljs to tie it all together and set on-load stuff

11:05 VickyIyer: Hello All (zipmap [:x :y :z] (repeatedly (partial rand-int 10))) can someone explain the function call to partial as I am unable to understand it?

11:05 clojure-newcomer: ohpauleez: should I be using require or use to grab stuff from other cljs files ?

11:05 unsure why my cljs-binding template can only find stuff in main.cljs

11:06 ohpauleez: clojure-newcomer: Sometimes I use render.cljs for all the functions that render something in the dom. I typically avoid "model.cljs" and instead name them the first class category of the data they're responsible for holding and offering a data abstraction layer (DAL) for

11:06 hyPiRion: VickyIyer: (partial rand-int 10) returns a function which takes in any amount of arguments, and adds them as the tail.

11:06 ohpauleez: clojure-newcomer: Always prefer require to use

11:06 hyPiRion: When called with no arguments, it will be the same as doing (rand-int 10)

11:07 clojure-newcomer: ohpauleez: thanks, I will

11:07 scriptor: VickyIyer: in this case, repeatedly takes a function without arguments

11:07 ohpauleez: clgv: http://stackoverflow.com/questions/9164051/why-do-minikanren-names-always-end-with-o?rq=1

11:07 scriptor: if you just pass it (rand-int 10) that won't work, because that won't return a function

11:07 clojure-newcomer: it seems use needs me to be explicit about every element in an ns, which is painful

11:07 VickyIyer: (zipmap [:x :y :z] (repeatedly (partial rand-int 10))) question is why this doe snot work (zipmap [:x :y :z] (repeatedly (rand-int 10)))

11:07 scriptor: VickyIyer: calling (partial rand-int 10) returns a function which calls (rand-int 10) every time

11:08 hyPiRion: Basically, (partial rand-int 10) is the same as (fn [] (rand-int 10)), or #(rand-int 10) for short.

11:08 scriptor: VickyIyer: just mentioned it above, repeatedly takes a function

11:08 VickyIyer: ok got it now thanks for the explanation

11:08 scriptor: VickyIyer: (rand-int 10) does not return a function, but by wrapping it in partial it conveniently becomes a function

11:09 casion: why cant you just do (zipmap [:x :y :z] (repeatedly #(rand-int 10)))

11:09 why is partial necessary?

11:09 VickyIyer: that is really cool, I have not seen this in language I have worked in

11:10 clgv: ohpauleez: then I vote for "*-o" or "*_o" - that latter is subscript in latex insted of superscript ;)

11:11 ohpauleez: clgv: Or we could modify our editors and any function that ends in o gets printed as a superscript

11:11 clgv: ohpauleez: humm, why not bla° ?

11:11 ohpauleez: clgv: you could do that, since Java is utf16

11:12 but you'd need to have (def bla° blao)

11:12 clgv: ohpauleez: but sadly all the builtin stuff has the "o" suffix.

11:12 ohpauleez: it's like coffee, tea, and beer

11:12 the first time you have it, you think, "This is stupid, it's so bitter. I'm never going to drink this again"

11:12 but you drink it three, four… five times more

11:13 scriptor: casion: might've just been someone's personal preference

11:13 ohpauleez: and bam, you start enjoying oit

11:13 it

11:13 casion: ohpauleez: nah, some people always hate it

11:13 clgv: it really reads strange "all-connected-to-allo". probably a good name but why should all be connected to allo? ;)

11:13 casion: Scriptor: seems strange to me, I'd imagine #() would be far more readable and obvious

11:13 and silghtly faster?

11:14 ohpauleez: casion: My example is indeed leaky (no pun intended)

11:16 scriptor: casion: huh, it's apparently in the clojure book

11:16 http://books.google.com/books?id=nZTvSa4KqfQC&pg=PA34&lpg=PA34&dq=(zipmap+%5B:x+:y+:z%5D+(repeatedly+(partial+rand-int+10)))&source=bl&ots=0V-nGO3Qtd&sig=0-K6I38Jd4yuUuekDA3P9dzB77w&hl=en&sa=X&ei=xBkpUN6kDZS36QGq3oHQBg&ved=0CFwQ6AEwAQ#v=onepage&q=(zipmap%20%5B%3Ax%20%3Ay%20%3Az%5D%20(repeatedly%20(partial%20rand-int%2010)))&f=false

11:17 casion: Scriptor: how odd, I learned that #() would make more sense from that book lol

11:18 ohpauleez: this question came up a few days ago too

11:18 now I know where it's coming from

11:18 haha

11:19 scriptor: cemerick: any reason why partial is preferred instead of #() in this? (zipmap [:x :y :z] (repeatedly #(rand-int 10))) (page 34 from yo' book)

11:19 ohpauleez: someone was on a partial kick, the only reason

11:19 casion: ohpauleez: I have all sorts of notes on my kindle amounting to 'ask cemerick why it's this instead of this after you've finished the book'

11:19 ohpauleez: (completely a guess, no data to support that)

11:20 casion: 117 notes lol

11:20 I'm assuming I'll figure most of them out on my own

11:20 scriptor: yea, depending on your background I guess some people prefer more alphanumeric characters

11:20 ohpauleez: but I find I do that more in clojure than in any other language - I start using some idiom, then accidentally use it where something else is more appropriate

11:20 or more concise or more readable

11:21 casion: I'd still think that even (fn [] (rand-int 10)) would be more readable

11:21 scriptor: casion: I agree, it's basically a thunk

11:21 ohpauleez: #(rand-int 10) for me personally

11:21 but really only in the case where I'm using a hof

11:22 casion: I prefer #() as well

11:22 when I see partial, I assume there's other args coming in somewhere

11:22 scriptor: exactly

11:22 ohpauleez: same

11:23 maacl: I am trying to fix a broken method in a Java lib using proxy, but I need access to a protected field to do it. Is this possible?

11:23 nbeloglazov: Frustrating think with partial (for me) is that it's too long. It's shorter to use #( ).

11:23 ro_st: ohpauleez: the remote macro is expanding to the wrong namespace for some reason

11:23 casion: the partial bit isn't listed in the errata

11:23 ckirkendall: ro_st: I pushed out alpha2 of enfocus. I would love if you could give it a spin.

11:23 ohpauleez: ro_st: There's a .client. in there?

11:23 ro_st: yes!

11:24 ckirkendall: oooh, what's new?

11:24 ohpauleez: ckirkendall: I will also do the same on all of my apps

11:24 ro_st: ckirkendall: i'm busy whacking together an example of enfocus and shoreleave's pubsub and remotes right now

11:24 ckirkendall: ro_st: not much from the snapshot.

11:24 ohpauleez: ro_st: I think that's an old jar problem too, but let me check

11:24 ckirkendall: ro_st: sweet!

11:26 ohpauleez: ro_st: An old jar - https://github.com/shoreleave/shoreleave-remote/commit/572265c85aaf0aea591724ff59d3c07087120c68

11:28 ro_st: I redeployed the jar just to be safe

11:28 ro_st: a deps run should fix it?

11:28 what version of remotes?

11:28 0.2.1 or 0.2.2-SNAPSHOT?

11:28 clgv: is that safe to use ##:keyword.with.dots

11:28 ohpauleez: 0.2.2-SNAPSHOT

11:28 clgv: ,:keyword.with.dots

11:28 clojurebot: :keyword.with.dots

11:29 ro_st: so close

11:29 build build build!

11:29 ohpauleez: ,:you(can)also.do-this

11:29 clojurebot: :you

11:29 ohpauleez: whoa, fixed?

11:29 ro_st: i was on 0.2.1

11:30 ohpauleez: ro_st: I seriously can't thank you enough for pulling something together

11:30 and working through all the pains of sl

11:31 nbeloglazov: maacl: did you try (. this fieldName) inside proxy method?

11:31 ro_st: weird. getting a npe in goog.string.urlDecode deep inside the csrf stuff

11:32 my pleasure. this is fun

11:32 clgv: &:keyword.with.dots

11:32 lazybot: ⇒ :keyword.with.dots

11:32 hyPiRion: Even better is probably the %-symbol

11:32 maacl: nbeloglazov: Nope, but I will now

11:32 ohpauleez: ro_st: Weird, I've never seen that. Is this with or without CSRF middleware?

11:32 hyPiRion: ,'(:%%name)

11:32 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Invalid token: :>

11:33 ro_st: both

11:33 dgrnbrg: Hello clojurians! I have some leiningen profile information (that includes an unquote-spliced bit of code) that I want to have included in every leiningen project for my team. Is there a way to specify a plugin-dependency and have it always modify the project.clj before running?

11:33 Or do I need to say something like "lein with-my-stuff task args" and make a with-my-stuff plugin?

11:34 clojure-newcomer: hmmm, using a mix of noir-cljs, cljs-binding… my cljs-binding template can only bind to stuff in main.cljs, unsure how to split out functionality to other cljs files and still have the html elements bind successfully, any ideas ?

11:35 nDuff: dgrnbrg: Hrm. If you don't get a response here, you might try #leiningen

11:35 ro_st: clojure-newcomer: stay posted. got some nice sample code on the way

11:36 dgrnbrg: nDuff: thanks

11:36 clojure-newcomer: ro-st: a fellow cljs-binding user ?

11:36 ro_st: naw. a demo of enfocus, shoreleave-pubsub and shoreleave-remote and clsbuild's crossovers

11:37 clojure-newcomer: ro_st: are you suggesting it all be so awesome I will just want to use that instead ? :-)

11:37 ro_st: i might be

11:37 -grin-

11:37 ckirkendall: :)

11:37 clojure-newcomer: ro_st: god knows I need something to make me more productive :-( really struggling with this

11:38 is there an eta ? :-)

11:38 gtrak: weavejester: in lein-ring uberwar it seems like you shouldn't need to specify a ring-handler if you're using a premade web.xml, yes? If I leave it out I get a nullpointer exception.

11:38 ro_st: as soon as i get past a null bug

11:38 ckirkendall: clojure-newcomer: what exactly are you strugling with

11:39 clojure-newcomer: ckirkendall: my cljs-binding template (html in this case) will only successfully bind with elements defined in main.cljs

11:39 it seems I am unable to split functionality out to separate files and still bind

11:39 even if I reference by namespace in my template

11:39 I think there is magic going on under the hood which I don't understand

11:40 probably noir-cljs governing the magic

11:41 weavejester: gtrak: That's probably right… it's likely a bug. Custom web.xml files are quite rare.

11:42 gtrak: yea... I'm doing some wacky stuff

11:44 ckirkendall: clojure-newcomer: I am not familure with cljs-bindings, but if you are looking for a very simple app that handles similar stuff check this out: https://github.com/ckirkendall/The-Great-Todo

11:45 clojure-newcomer: ckirkendall: will do, thanks for the pointer

11:45 ro_st: weavejester! thank you for compojure.

11:45 ckirkendall: its a very simple app that uses fetch and noir in backend and enfocus on the front

11:45 weavejester: ro_st: You're welcome :)

11:45 nbeloglazov: Where do static resources (css, js, images) go in ring applications? To the root of *.war file or inside WEB-INF/classes so they can be retrieved by .findResource method?

11:46 weavejester: nbeloglazov: Lein-Ring puts them in WEB-INF/classes so that they can be referenced by clojure.java.io/resource etc.

11:47 nbeloglazov: It's not ideal, but it's better than having two places for resources

11:48 nbeloglazov: weavejester: thank you

12:08 ro_st: not working right now, but it's still worth reading the code: https://github.com/robert-stuttaford/demo-enfocus-pubsub-remote/

12:09 if anyone is keen, i'm wide open to Issues and pull requests and whatnot

12:09 be nice to have a go-to boilerplate for new folks interested in clj+cljs apps

12:10 ckirkendall: ro_st: will take a look

12:10 ro_st: nice :-)

12:10 gotta go. meatspace calls

12:13 clojure-newcomer: ro_st: nice one

12:14 will have a look soon as I make some progress with this :-)

12:17 cemerick: casion, Scriptor: as you suspected, totally a personal readability preference

12:30 technomancy: dgrnbrg: project middleware can give you what you're looking for

12:31 dgrnbrg: right now you'd have to specify the middleware in each project, but there's an open issue for that: https://github.com/technomancy/leiningen/issues/401

12:32 clojure-newcomer: hmm, in using cljs-binding and noir-cljs I'm getting 'Uncaught ReferenceError: binding is not defined my app.client.somens.myfunc' when I put the function in some.cljs…. but it works when I put it in main.cljs… any ideas ? I can confirm some.cljs is being merged into bootstrap.js

12:45 ckirkendall: clojure-newcomer: can you put together a gist of main and some.

12:56 clojure-newcomer: ckirkendall: here is the link: http://pastebin.com/wLXtScRu

12:57 ckirkendall: you know going through this exercise has made me realise, I have no 'use' or 'require' in my app.client.somens… so probably some automatic binding stuff is not happening...

12:59 ckirkendall: haha, that was the problem

13:00 ckirkendall: :)

13:00 clojure-newcomer: ckirkendall: thanks for making me step through the problem, had a 3 in the morning coding session and guess I am more stupid than normal because of it

13:00 ckirkendall: clojure-newcomer: at 3 in the morning everyone is.

13:01 clojure-newcomer: ckirkendall: right better go make up for hours of lost productivity now cya

13:29 brainproxy: in a macro I need to so something like ... #'templates/~template

13:29 but that's not the right way to put #'templates/ and ~template togethre

13:29 cgray: technomancy: I've almost got my lein plugin working (based off of lein-scalac), but when I do "lein help", it complains that the equivalent of scala.tools.ant.Scalac isn't found...

13:30 ckirkendall: brainproxy: ~(symbol (str "templates/" (name templates)))

13:31 raek: ,(namespace (str "templates/" "foo"))

13:31 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Named>

13:31 raek: ,(namespace (symbol (str "templates/" "foo")))

13:31 clojurebot: "templates"

13:31 brainproxy: ckirkendall: thanks

13:31 raek: huh, I didn't know that the symbol function parsed its argument

13:32 I would write (symbol "templates" "foo")

13:32 ,(namespace (symbol "templates" "foo"))

13:32 clojurebot: "templates"

13:32 ckirkendall: ,(name (symbol "templates" "foo"))

13:32 clojurebot: "foo"

13:33 abev: how to regular expr in cljs

13:33 ckirkendall: ,(namespace (symbol "templates" "foo"))

13:33 clojurebot: "templates"

13:33 ckirkendall: raek: nice

13:36 abev: detailed documentation for clojurescript where it is available?

13:58 loliveira: could somebody help me with enlive?

13:59 emezeske: ~anyone

13:59 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

13:59 loliveira: ok

14:07 ckirkendall: loliveira: what issue are you struggling with.

14:09 loliveira: i'm trying to get the same selector result in enlive as i'm geting using jquery selector. Using jquery, I can obtain all children but using envile no children are selected. link to url and query: https://gist.github.com/3342793

14:15 ckirkendall: i'am getting different results from enlive and jquery.

14:20 ckirkendall: loliveira: can you give me the selector

14:20 arrdem: is there a function for getting the entire inheritance tree for an object?

14:20 Qerub: ,(supers String)

14:21 clojurebot: #{java.lang.Object java.lang.CharSequence java.lang.Comparable java.io.Serializable}

14:21 amalloy: &(ancestors java.util.ArrayList)

14:21 lazybot: ⇒ #{java.lang.Cloneable java.util.AbstractCollection java.lang.Object java.io.Serializable java.util.Collection java.lang.Iterable java.util.RandomAccess java.util.AbstractList java.util.List}

14:21 ckirkendall: loliveira: sorry just saw the gist

14:21 it seems jquery is wrong in this case

14:21 you are refrencing and id so not sure how it could return more than one object.

14:22 hiredman: I imagine jquery returns a single object, with some kind of .each that walks over the children

14:23 ckirkendall: hiredman: that would make sense

14:23 hiredman: and it would explain the confusion

14:23 arrdem: amalloy Qerub: ancestors supports (derive) while supers is just Java inheritance?

14:24 amalloy: well yes, but also ancestors returns interfaces

14:24 ckirkendall: loliveira: can you post the html you are trying to match

14:25 Gnosis-: how can I use UTF-8 for converting between bytes sequences and character sequences?

14:25 arrdem: amalloy: thanks

14:28 loliveira: ckirkendall: http://www.correiobraziliense.com.br/app/noticia/brasil/2012/08/13/interna_brasil,316708/governo-vai-se-antecipar-aos-desastres-naturais-diz-presidente.shtml

14:29 chouser: Gnosis-: & (String. (.getBytes "Hello" "UTF-8") "UTF-8")

14:29 ,(String. (.getBytes "Hello" "UTF-8") "UTF-8")

14:29 clojurebot: "Hello"

14:30 loliveira: ckirkendall: do you know what do i have to do to get span#items_noticias's children?

14:30 Gnosis-: chouser: thanks! so does .getBytes return a byte array?

14:31 S11001001: Gnosis-: what dev environment are you using?

14:32 Gnosis-: jvm

14:35 ckirkendall: #items_noticias > *

14:36 S11001001: Gnosis-: on top of that

14:36 ckirkendall: loliveira: you don't need the span because the id is unique

14:38 loliveira: ckirkendall: didn't work: (enlive/select content [:div.column00 :span#items_noticia :> :*])))

14:40 scriptor: ckirkendall: a lot of browsers don't enforce the uniqueness

14:41 loliveira: didn't work too: (enlive/select content [:div.column00 :#items_noticia :> :*])))

14:57 Gnosis-: S11001001: on top of the jvm? I use a repl!

14:57 DaoWen: what exactly does vec do?

14:57 I thought it would be a no-op if you passed it a vector (just passing it back), but it doesn't look like that's the case

14:58 S11001001: vec makes clojure.core hilarious

14:58 xeqi: &(doc vec)

14:58 lazybot: ⇒ "([coll]); Creates a new vector containing the contents of coll."

14:58 amalloy: S11001001: ?

14:58 DaoWen: it looks like it takes a collection, turns it into an *array*, and then *lazily* turns that array into a vector

14:59 amalloy: DaoWen: no, it copies to a new vector. kinda weird, but there's at least a justification, if not a reason

14:59 DaoWen: (that's what I got out of the source listing—but it was making a lot of Java calls so I'm not sure)

14:59 S11001001: ,(let [o (to-array [1,2,3]) v (vec o)] [(seq v) (do (aset o 0 42) (seq v))])

14:59 clojurebot: [(42 2 3) (42 2 3)]

14:59 amalloy: oh ouch

15:00 Cr8: oh what

15:00 the vector is backed by the array?

15:00 DaoWen: what just happened?

15:00 S11001001: I think next release will have docstring update to mention this

15:00 ckirkendall: loliveira: take the :* off the end

15:00 S11001001: Cr8: truth

15:00 Cr8: gnarly

15:00 ckirkendall: if enlive implemented the selector syntax correctly :> means children

15:01 Gnosis-: S11001001: it doesn't seem like to-array can handle types other than Object...

15:01 ckirkendall: If not it is probably a bug

15:01 S11001001: Gnosis-: there are other funs for that

15:01 DaoWen: I think The Joy of Clojure mentioned that, but in the context of seq, not vec

15:02 it makes sense for seq, but that's a bit weird since vec is supposed to return a copy...

15:03 S11001001: actually the difference is that the seq case is referentially transparent with respect to accesses to the seq itself

15:03 ckirkendall: loliveira: also on the uniqueness becareful because many browsers if two items with the same id exist you cannot select on that id at all.

15:03 DaoWen: amalloy: what was the justification you were talking about? (or did you already mention it and I missed it?)

15:03 S11001001: either the 3rd element of a seq will be 42 or it will be 84, or whatever, but it won't change

15:04 amalloy: DaoWen: (subvec some-huge-vector 0 1) creates a one-element vector that holds a pointer to the whole huge one, preventing gc. (vec the-subvec) copies just those elements into a new vector, letting the big one get GCed

15:04 so you can imagine wanting this behavior from vec, although in most cases you don't

15:06 loliveira: ckirkendal: i removed and got the folloing exception: 2012-08-13 16:03:01,869 TRACE crawler.db: load-crawler - migration loaded: {:clj nil, :cron_expression "0/5 * * * * ?", :table_name "correiobraziliense.rss_politica"}

15:06 2012-08-13 16:03:01,869 TRACE crawler.migrations: loading namespace: crawler.models.crawlers.correiobraziliense.rss_politica from fs

15:06 ((Exception in thread "main" java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

15:06 DaoWen: amalloy: that makes sense. you need to have a way to clean up after subvec.

15:06 amalloy: DaoWen: yes, but you already have one anyway: (vec (seq the-subvec))

15:07 DaoWen: good point.

15:07 so, it's kind of pointless then?

15:07 amalloy: so, i dunno. in summary: vec is kinda silly

15:07 loliveira: ckirkendall: i will report it as a bug. thanks soo much.

15:07 amalloy: some of the code in there is definitely very old, and probably from rich's original draft ideas - not everything was brilliant

15:08 technomancy: amalloy: heresy!

15:09 ckirkendall: loliveira: try this: #id :> (any-node)

15:09 DaoWen: ok, thanks for the explanation

15:09 ckirkendall: loliveira: enlive syntax requires a selector after the :>

15:10 technomancy: PSA: .substring is subject to the same memory leak issues as subvec

15:10 so watch out

15:10 amalloy: technomancy: maybe rich's ideas were in fact all brilliant, but occasionally his evil twin with a goatee snuck in and coded something

15:11 pjstadig: technomancy: huh?

15:11 .substring says it return a 'new' string

15:11 amalloy: pjstadig: it does, backed by the old array

15:11 pjstadig: but maybe that's just playing with terms

15:13 ckirkendall: loliveira: sorry its not any-node its just (any)

15:14 kenneth: hey there -- is there a way to get the path to the project root with clojure / lein?

15:14 technomancy: kenneth: from what context?

15:14 like in a plugin or in the project code itself?

15:14 kenneth: in the code itself

15:15 technomancy: kenneth: if the code is launched by Leiningen itself then (System/getProperty "user.dir") will do the trick

15:15 but that might not work from an IDE, even one that supports Leiningen

15:16 in general relying on that kind of thing is mildly sketchy as it's an implementation detail, and it's good practice to write code that works the same whether it's running from leiningen or an uberjar.

15:21 arrdem: does Clojure have a good "dispatch on keyword" function or do I need to go dig out the dlambda macro?

15:21 technomancy: (comp :mykey first list)

15:21 ro_st: ohpauleez: here for a minute. any luck?

15:21 ohpauleez: I am

15:21 technomancy: assuming you want a keyword from the first arg, which is a map

15:21 ohpauleez: ro_st: ^

15:21 ro_st: -curious-

15:22 loliveira: ckirkendall: i tried (enlive/select content [:#items_noticia :> enlive/any]))) and it returned ()

15:22 antares_: arrdem: what you are looking for is multimethods

15:23 loliveira: ckirkendall: (enlive/select content [:#items_noticia :> enlive/any-node]))) returned ("\n ")

15:23 arrdem: antares_: really? defmulti's the best choice here? meh...

15:23 antares_: arrdem: how exactly is it meh?

15:24 loliveira: ckirkendall: i can't call any-node (any-node) or any (any) they aren't functions.

15:24 amalloy: it sounds like arrdem probably wants a lambda that acts like an object, dispatching on its first arg as a "message"?

15:24 antares_: arrdem: it will dispatch on any function you want. Use keywords equality or even keywords as functions. What else do you need?

15:24 arrdem: just more verbose than I feel is required. nothing wrong with it ho.

15:24 amalloy: i wouldn't recommend a defmulti for a lambda-like thing

15:24 arrdem: *tho

15:24 amalloy: (though, in generally, i wouldn't recommend using a lambda to fake an object either)

15:24 arrdem: yeah. what amalloy said.

15:24 technomancy: defmulti complects def and multi =(

15:25 arrdem: I think that (case) will do what I want... brb trying science

15:25 technomancy: core.match maybe

15:25 arrdem: yup. case'll do it

15:26 ,(let [a :foo] (case a :foo (println "YES")))

15:26 clojurebot: YES

15:32 ckirkendall: loliveira: I can't think of a way around it if :> :* doesn't work

15:33 arrdem: amalloy: what is this "faking an object" of which you speak?

15:33 amalloy: this discussion gives me the impression enlive is some kind of emoticon-oriented library

15:34 (fn [message & args] (case message :foo (...) :bar (...))) is the classic scheme/whatever way to create something that's basically an object

15:35 that you invoke "methods" on by calling (the-object :foo whatever)

15:35 arrdem: ah. yes I remember this from SIoCP

15:36 amalloy: clojure would generally encourage you to just define public foo and bar functions, which take in whatever non-function data your lambda was capturing

15:42 ckirkendall: loliveira: you might have luck on the enlive user group https://groups.google.com/forum/?fromgroups#!forum/enlive-clj

15:42 loliveira: ckirkendall: thank you!

15:42 ckirkendall: have a nice day. =)

15:51 Gnosis-: if I want a lazy seq of the bytes in a file, is there a standard way to do this?

15:57 arrdem: Gnosis-: a quick google doesn't turn up a stard library approach... your best bet is probably Java's buffered reader with a monad or some kind of continuation.

15:58 treehug: in clojure, is there a way two write float literals? i.e. rather than writing (float 3.5)

15:59 amalloy: Gnosis-: you were asking about converting bytes to characters earlier. are you sure you want bytes, not characters?

15:59 Gnosis-: amalloy: well, right now, I'm working on parsing a binary file, so I definitely want bytes. The UTF-8 question is related to another Clojure project :)

15:59 amalloy: (also, monads and continuations are both totally bonkers for reading from a file)

16:00 Gnosis-: amalloy: I thought monads were a Haskell thing... how can they exist in Clojure too? (I don't really understand what monads are btw)R

16:00 arrdem: amalloy: yes... but if you __really__ wanted to only ever read K bytes of a file at a time

16:02 amalloy: still total nonsense, arrdem

16:02 emezeske: Gnosis-: Monads are a general concept, you can implement them in any language you want

16:02 Gnosis-: emezeske: ah, okay. Like I said, I don't understand monads at all...

16:03 emezeske: Gnosis-: I agree with amalloy on monads being bonkers for what you're trying to do :)

16:03 amalloy: Gnosis-: see clojure.java.io/input-stream and java.io.InputStream/read

16:04 arrdem: amalloy: ah. I forgot about Java's readers packaging cursor position... I was thinking in terms of having a C-style "read K bytes" and needing to manually retain the cursor.

16:05 amalloy: in that context monads would make a little sense. i guess you'd want a state monad containing the current cursor position? still seems like tremendous overkill

16:16 dgrnbrg: I having terrible problems with a :use-ed namespace

16:16 I know use is bad, but I'd really like to understand this issue

16:16 I am running clojure in a jvm with all kinds of weird stuff, using a patched leiningen

16:17 and i have a namespace that adapts a bunch of legacy java code into clojure

16:17 and when I require that namespace, everything works

16:17 and when I use that namespace, everything still works

16:17 except that when I use it, the jvm never exits

16:17 the code has the exact same functionality in both cases, except that the require-based one has the namespace prefixes

16:18 but for some reason it causes the jvm to never exit when I use the namespace, but not when I require it.

16:19 emezeske: Perhaps when you :use it, it brings a name into your namespace that shadows a clojure.core name?

16:20 And then maybe you e.g. call some function, expecting the clojure.core implementation, and get the implementation from this other namespace

16:20 Leading to unexpected behavior

16:22 Raynes: emezeske: http://dev.clojure.org/jira/browse/CLJS-355

16:22 emezeske: Other than that (which is unrelated to lein-cljsbuild), node works fine with lein-cljsbuild.

16:23 emezeske: Raynes: Awesome!

16:23 Raynes: Every time I try to use cljs targeting node, I end up finding a disappointingly debilitating bug. It is depressing.

16:23 emezeske: Yeah... I guess not that many people are doing it?

16:23 Raynes: That surprises me.

16:23 The survey seemed to indicate otherwise.

16:23 dgrnbrg: emezeske: i don't get any shadowing warnings

16:24 lynaghk: Is there any way to check if any of the vars destructured within a let are nil?

16:24 dgrnbrg: i am afraid that perhaps :use causes symbols that I use in def forms to be loaded, which triggers a poorly written static initializer

16:24 Raynes: emezeske: I don't know why people aren't more interested in it. It's the only implementation of Clojure with anything resembling completion that doesn't take long to start up.

16:24 emezeske: I don't think there is another good option for Clojure + fast startup speed.

16:24 dgrnbrg: but it seems like :use wouldn't cause different behavior w/ the classloader than :require

16:24 emezeske: Raynes: Yeah, it definitely has startup speed.

16:24 Raynes: In fact, it seemed to be one of the selling points Rich made when he announced cljs.

16:24 drewr: Raynes: I agree; that was my main hope for cljs

16:24 Raynes: A story for command-line scripting with Clojure.

16:25 drewr: I have hopes for cljs-lua

16:25 emezeske: dgrnbrg: What does the classloader have to do with anything?

16:25 amalloy: lynaghk: eh?

16:25 lynaghk: amalloy: I want to do content-based pubsub. Someone should be able to subscribe to messages that match a certain form that's a valid destructuring

16:26 e.g., (subscribe! {{a :a} :stuff} ...)

16:26 dgrnbrg: emezeske: perhaps the hanging is due to some class getting loaded by the :use that isn't loaded by the :require, which creates a non-daemon thread that hangs the process

16:26 since it's possible to put code into a static initilaizer

16:26 lynaghk: and then whenever someone publishes a message with content like {:stuff {:a 1 :b 2} :foo 5}, that fn will get called.

16:26 djanatyn: ...is cKanren related to Clojure?

16:27 emezeske: dgrnbrg: Uh.. I think you might be over-thinking it. Both use and require load the namespace, they just differ in how it's referred

16:27 Raynes: Nope.

16:27 emezeske: dgrnbrg: Good luck tracking down the problem!

16:27 lynaghk: amalloy: I was hoping to leverage core.match to do this, but it'll match all maps and just destructure their keys to nil.

16:27 dgrnbrg: emezeske: do you know the details of their difference?

16:28 because somehow that difference is the source of my bug

16:28 and i'm adapting millions of lines of legacy java, and i've seen some iffy things in static initializers already ;)

16:29 dnolen_: Raynes: I think people are using CLJS w/ Node.js but from the JIRA tickets, it's seems like a fraction of the users.

16:29 Raynes: dnolen_: Yeah. :(

16:29 amalloy: lynaghk: you could probably start by calling ##(doc destructure) on the destructuring form

16:29 lazybot: ⇒ "([bindings]); "

16:29 Raynes: dnolen_: Speaking of which, did you see that ticket I mentioned a moment ago? bbloom mentioned he wanted you to take a look at it.

16:30 dnolen_: Raynes: yeah just saw it but I'd have to take a closer look.

16:30 emezeske: dgrnbrg: Yeah, the difference is just that use ends up refer-ing to all the public vars of the ns: http://clojuredocs.org/clojure_core/clojure.core/refer

16:30 lynaghk: amalloy: yeah, I was looking at that.

16:30 dnolen_: djanatyn: cKanren is a variant of miniKanren which is a Scheme system. core.logic is an implementation of miniKanren / cKanren.

16:30 Raynes: If it is what we think it is, it's a pretty nasty one that I'm surprised no one else has run into.

16:31 amalloy: and then, i dunno, have your macro thing do a let-bind itself with their same destructuring form, and check whether any of the not-gensymmed names are non-nil. it's not a perfectly correct solution, but it probably comes close

16:32 hiredman: lynaghk: seems like a large departure from typical pub/sub messagebus stuff

16:32 dgrnbrg: emezeske: i know that's the party line, but it's wrong :)

16:33 because it works if i :require and :use the namespace

16:33 sorory, :require and :refer

16:33 but not if i :use

16:33 hiredman: I know most messagebuses have some kind filter mechanism, but I've never seen those used, typically you publish to different queues and just subscribe to the queues

16:33 dnolen_: Raynes: not sure when I'll have time to dig into that one at least this week, pretty busy. Any detective work / solution strategy you could add to the ticket would be helpful.

16:33 lynaghk: hiredman: yeah, I'm only just toying with the idea after I started juggling a lot of regexs to do redis-like string-based pubsub (e.g., subscribe to "/some/*" or "some/specific/stuff")

16:34 Raynes: dnolen_: No hurry. Just wanted to make sure that it's on your radar

16:34 hiredman: lynaghk: why not just use postal.js?

16:34 dgrnbrg: What exactly is the difference between :use and :require/:refer?

16:34 lynaghk: hiredman: aside from performance, can you think of any disadvantages?

16:34 djanatyn: I've had a really positive experience with clojure so far, and there'll be a 48 hour game jam in 11 days that I'm participating in.

16:35 emezeske: dgrnbrg: I think you need to ask the source code: https://github.com/richhickey/clojure/blob/a1eff35124b923ef8539a35e7a292813ba54a0e0/src/clj/clojure/core.clj#L4859

16:35 hiredman: lynaghk: I think having N queues with different content is simpler than picking apart N different message types from one queue

16:35 djanatyn: Would it be better to use Clojure, or Clojurescript?

16:35 TimMc: dgrnbrg: Have you tried using a VM inspector to find out what threads are still active?

16:35 djanatyn: Clojurescript, embedded in a browser, would be ideal, but I'm not sure how mature it is.

16:35 hiredman: lynaghk: sorry, I sort of assumed you are thinking about this from a clojurescript prospective

16:35 win 15

16:35 lynaghk: hiredman: yeah, I am = )

16:35 djanatyn: I've already got a working Clojure setup. Would it be possible to make a game in 48 hours with either of those?

16:35 And if I use clojurescript, would I be using regular JS game libraries, pure canvas, or clojurescript game libraries?

16:36 dnolen_: djanatyn: do you have a lot of Clojure experience?

16:36 lynaghk: hiredman: So are you against any kind of wildcard matching in pubsub?

16:36 hiredman: lynaghk: against is a strong word

16:36 djanatyn: dnolen_: no, but I have lots of haskell experience and some experience with common lisp

16:36 so learning clojure hasn't been very difficult

16:36 lynaghk: hiredman: I haven't worked with either enough to have a really firm opinion---I was just thinking that if you're going to do wildcard matching it should be on the data instead of some half-baked string concatenation

16:37 hiredman: lynaghk: I think wild cards over queues are simpler than writing patterns that and up and match more than one message type

16:38 dnolen_: djanatyn: CLJS is powerful but the usability is pretty rough if you don't have a lot of patience. yoklov has done some cool game work w/ it. CLJS can interop w/ JS ok. game dev in CLJ seems pretty feasible to me as well.

16:38 lynaghk: hiredman: I guess that's the thing---I'm implicitly defining message "types" based on their attributes rather than according to some pre-defined segregation / schema.

16:38 dgrnbrg: TimMc: i'll give that a shot

16:39 yoklov: djanatyn: game in 48 hours in clojure is doable, you doing a jam?

16:39 hiredman: *shrug*

16:39 yoklov: clojurescript also.

16:39 djanatyn: yoklov: yep! ludum dare.

16:40 yoklov: sweet!

16:40 lynaghk: hiredman: yep. I'm the kind of guy who needs to prototype and try things out for a bit first. I've done some plain queue pubsub, so I just want to try the opposite extreme.

16:42 nbeloglazov: $(doc ..)

16:42 ,(doc ..)

16:42 clojurebot: "([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on the result, etc. For instance: (.. System (getProperties) (get \"os.name\")) expands to: (. (. System (getProperties)) (get \"os.name\")) but is easier to write, read, and understand."

16:42 djanatyn: hmm. cljs looks cool, but I would really like to use SLIME, if possible

16:43 yoklov: djanatyn: to be honest though, immutability doesn't give you a whole heck of a lot in terms of developing a game, and if you aren't careful it's extremely easy to run into perf. issues (obviously, keep persistent data structures away from your rendering code). On the other hand, ludum dare is short enough that you probably won't really run into issues wrt that before it's over.

16:44 clojure's more fun than most other languages though, so you should go for it.

16:44 solussd: so, every once in awhile I want to use a 'struct'. why are they considered obsolete? Is there nothing they're better for than records? I mean, at very least they're actually functions. :/

16:46 McMartin: No, they're raw objects.

16:47 So are records, but records also do the right thing for you with the obnoxious boilerplate functions.

16:47 amalloy: McMartin: are you talking about deftype? solussd was asking about structs

16:48 solussd: I'm talking about structs, created with create-struct, or defined with defstruct

16:48 (defstruct person :name :age) (struct person "solussd" 104)

16:49 dnolen_: solussd: defrecord creates ctor fns. Personally I find that you almost always want to write your own anyway, usually only a couple of lines of code.

16:50 solussd: yeah, I use structs mostly to declare the keys in a map somewhere so it's obvious what keys are expected when passing a map to some of my functions. It's nice when they're actually maps and not records which only mostly act like maps

16:52 lynaghk: dnolen_: think it's possible to figure out if any core.match destructured locals are nil? I'm poking around the source but nothing stands out. My issue is that I want to match map subsets, but :only is too restrictive.

16:53 dnolen_: lynaghk: hugod (I think?) has brought this up before. definitely something I'm interested in looking at when I have time.

16:54 lynaghk: dnolen_: okay, cool.

16:55 dnolen_: you would be open to a contribution on this topic, then?

16:55 dnolen_: lynaghk: sadly core.match pattern manipulation is not that clear, a lot of pattern matrix manipulation - perhaps a better way to do that but I haven't thought of anything yet.

16:55 lynaghk: yes.

16:55 lynaghk: I think there may even be ticket for it.

16:55 existing ticket

16:58 roma1n_p: Hi everyone, I have a c2/singult question: I cannot seem to add a class attribute to an SVG text (although adding a class to a rect works). Why is that?

17:02 lynaghk: roma1n_p: should work fine if its a valid CSS class.

17:02 dnolen_: it looks like there's an existing patch: http://dev.clojure.org/jira/browse/MATCH-52

17:06 dnolen_: lynaghk: oh heh, JIRA is so annoying. I should go over Jason Jackson

17:06 roma1n_p: lynaghk: I put a snippet at http://pastebin.com/sT44yYvk

17:06 dnolen_: 's patches.

17:07 roma1n_p: lynaghk: I suppose "deviceText" is a valid CSS class, although I know squat about CSS :)

17:07 dnolen_: lynaghk: will look at it soon, thanks for bringing it up

17:07 lynaghk: dnolen_: awesome, thanks David. Let me know if you need any help; I'm hoping to get rolling on some stuff based around that functionality asap (if possible)

17:08 roma1n_p: yeah, deviceText is a fine CSS class. Are you using c2 0.2.1-SNAPSHOT?

17:08 roma1n_p: lynaghk: nope, 0.2.1

17:08 lynaghk: roma1n_p: also, just FYI, you don't need to put numbers into quotes in the attribute vals.

17:09 dnolen_: lynaghk: if it looks ok, I'll cut another alpha to help you along.

17:09 lynaghk: dnolen_: I owe you some beers.

17:09 roma1n_p: lynaghk: OK, thanks for the attribute infos! Should I move to -SNAPSHOT then?

17:09 dnolen_: lynaghk: one thing that would help me out, just verifying that the patch works as expected for you.

17:09 lynaghk: roma1n_p: there is no 0.2.1 yet, just the snapshot.

17:10 roma1n_p: lynaghk: so I was using snapshots already I suppose...?

17:10 lynaghk: dnolen_: sure. I'm going to have lunch right now but I'll try applying it to master and get back to you this evening PST

17:10 dnolen_: lynaghk: thx

17:10 lynaghk: roma1n_p: what's in your project.clj?

17:11 roma1n_p: lynaghk: sorry I got confused, I was on 0.2.0 (0.2.1 was the lein-cljsbuild version :P )

17:11 lynaghk: roma1n_p: ah. Give 0.2.1-SNAPSHOT a try; it uses the latest Singult snapshot too

17:13 roma1n_p: also re: your c2 issue on the outdated examples, aperiodic is updating them here: https://github.com/aperiodic/c2-cljs-examples

17:14 roma1n_p: lynaghk: no, 0.2.1-SNAPSHOT did not change results unfortunately

17:14 lynaghk: roma1n_p: you might need to "lein cljsbuild clean" first.

17:17 roma1n_p: lynaghk: still no luck after a cljsbuild. Would you like a minimal test case?

17:17 lynaghk: roma1n_p: yeah, that + an issue on the Singult repo would be awesome

17:17 roma1n_p: thanks for reporting this.

17:17 roma1n_p: lynaghk: thanks for C2 :)

17:18 lynaghk: roma1n_p: waaaiiiitt

17:18 what's alias?

17:18 in your example. The attribute map is the third item in the hiccup vector. It needs to be the second.

17:19 roma1n_p: lynaghk: yup, that was it

17:19 lynaghk: /me embarassed

17:19 lynaghk: phew. I should have noticed that earlier. I need a sandwich.

17:19 roma1n_p: lynaghk: thanks!

17:20 lynaghk: roma1n_p: also, you can use the shortcut dot and hash on the element symbol for class and id

17:20 [:text.deviceText#my-text ...]

17:20 roma1n_p: lynaghk: ah, good to know

17:20 lynaghk: You typically only need to put the class in the attribute map if you're calculating it dynamically or some such.

17:29 gfredericks: wasn't there a some-pred in core?

17:29 sandbox`: hi everyone, how do you go about running a specific test in clojure? for example, i have a bunch of deftest definitions in a file, and i only want to run one of them through lein

17:31 Guest13977: Per "Programming Clojure", 2e, p.73, I entered (import `(java.io File)) into the REPL. It gave me a NO_SOURCE_FILE nastygram. Is this a config issue or what?

17:31 aperiodic: gfredericks: you mean some-fn & every-pred?

17:32 rod__: hey all - can anyone help with this error i'm getting trying to start a simple compojure application please? thanks - https://www.refheap.com/paste/4324

17:33 ooops, sorry, got my clojure & compojure channels muddled up! :)

17:34 Raynes: It's fine to ask Compojure questions here too.

17:35 gfredericks: aperiodic: yep that was it; lazybot didn't find it for some reason :/

17:35 rod__: ah cool, well if anyone has any pointers i'm all ears.

17:35 gfredericks: $findfn nil? true? false? true true

17:35 lazybot: [clojure.core/not= clojure.core/dosync clojure.core/sync clojure.core/with-loading-context clojure.core/distinct? clojure.core/case clojure.core/and clojure.core/locking clojure.core/io! clojure.core/when]

17:36 gfredericks: oh nm I was abusing the bot

17:36 amalloy: gfredericks: i don't think there's any args you could pass to findfn that would make it return some-fn or every-pred

17:36 gfredericks: amalloy: right

17:48 technomancy: sandbox`: deftest results in a defn behind the scenes

17:48 so just call (my-deftest-name)

17:48 * technomancy realizes he missed a "so call me maybe" joke opportunity

17:48 * technomancy is ok with that factn

17:48 technomancy: fact

17:50 jyc: I have a question about ccw (sorry if it's the wrong place) for anyone who uses it - is it expected that running a leiningen project doesn't run the -main function?

17:50 xeqi: rod__: sounds like you have a bad jar in you're ~/.m2. I'd recommend rm -r ~/.m2/repository and rerunning lein deps

17:50 rod__: ok - thanks both - will nuke it and try again.

17:55 djanatyn: hmm. how do I use or over a list of boolen values?

17:55 I can't use 'reduce, I can't use 'apply, and (or [false false true]) just returns [false false true]

17:56 amalloy: &(doc some)

17:56 lazybot: ⇒ "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"

17:56 nbeloglazov: ,(some identity [false false true])

17:56 clojurebot: true

17:56 djanatyn: amalloy: thank you :)

18:02 TimMc: Guest13977: That should be ', not `.

18:03 ,(macroexpand-1 '(import '(java.io File)))

18:03 clojurebot: (do (clojure.core/import* "java.io.File"))

18:03 TimMc: ,(macroexpand-1 '(import `(java.io File)))

18:03 clojurebot: (do (clojure.core/import* "clojure.core/seq.(clojure.core/concat (clojure.core/list (quote java.io)) (clojure.core/list (quote sandbox/File)))"))

18:14 djanatyn: man, core.logic is really cool!

18:18 dnolen_: djanatyn: it's fun stuff

18:18 * McMartin looks it up

18:18 McMartin: Oh, fun indeed

18:18 * McMartin never really got his head around that mode of programming.

18:39 Cr8: wasn't there some nifty function for looking up some key path in a tree of maps that I can't remember the name of, like, I had a map {:a {:b {:c 1}}} and I pass it [:a :b :c]

18:41 Raynes: &(get-in {:a {:b {:c 1}}} [:a :b :c])

18:41 lazybot: ⇒ 1

18:41 djanatyn: are there any good libraries for drawing graphs?

18:41 brainproxy: trying to defn inside a defmacro and getting errors like "No matching ctor found for class..."

18:41 djanatyn: I wanted to try the travelling salesman problem with a little graphic

18:41 brainproxy: having a hard time tracking down what's causing the problem...

18:43 Raynes: djanatyn: https://github.com/pallix/lacij Maybe?

18:44 brainproxy: Could you post the code and the full trace?

18:44 djanatyn: that's perfect! thanks. you guys are really helpful.

18:44 Raynes: djanatyn: I'll send you a bill

18:45 amalloy: $findfn {:a {:b {:c 1}}} [:a :b :c] 1 ;; Cr8

18:45 lazybot: [clojure.core/get-in]

18:45 Raynes: amalloy: ur so cool and trendy

18:45 brainproxy: Raynes: this is the main part of it: http://cljbin.com/paste/50298280e4b013f51ca863ff

18:45 Cr8: <#

18:45 *<3

18:45 brainproxy: ignore the trace cljbin gives

18:45 Raynes: I refuse pastes on cljbin.

18:46 gf3: Raynes: WAT

18:46 Raynes: It is not the right religion.

18:46 Bahahaha

18:46 gf3: OMG RUDE FACE

18:46 Raynes: You haven't said a word in like a month.

18:46 brainproxy: lolz, okay, what to use instead

18:46 Raynes: And the first time I say something about cljbin.

18:46 brainproxy: I was kidding. it's a running joke between gf3 and I because we both have a Clojure pastebin.

18:46 gf3: brainproxy: Raynes has a competing pastebin

18:47 gtrak: it even uses clojail

18:47 brainproxy: oh, right, now I remember something about that

18:48 anyway, it's weird, in the defmacro if I use def instead of defn, e.g. (def ~name ~xf)

18:49 then all is well

18:49 but that's not quite what I want, I need to wrap some more stuff around ~xf, and so I want to use defn instead, but am getting the ctor error

18:53 Raynes: brainproxy: What does xf look like?

18:53 Show me what the output of xform looks like.

18:54 brainproxy: xform returns a function

18:54 xf is that function

18:55 more specifically, xform returns the function returned by enlive's snippet* macro

18:55 Raynes: A function object or a form that would create a function when executed?

18:56 Macros work with code -- things that can be printed.

18:56 You can't embed a function object in a macro like that.

18:56 printed and read back*

18:57 brainproxy: You probably want to syntax quote the whole thing and make it expand to the form that creates the function that the function wraps, if that makes sense.

18:57 Also, be careful when I talk about macros.

18:57 I have a knack at not understanding what people are trying to do at all.

19:00 brainproxy: Raynes: it's okay, will review

19:00 thanks for taking a look

19:00 arrdem: okay. before I call it for the day, is there a way to list all loaded classes? I'm trying to find all chindren of a given class.

19:01 hiredman: nope

19:01 arrdem: good. just what I expected to hear.

19:01 Gnosis-: is there a way to change the output base that prn uses for numbers?

19:01 i.e., print numbers as 0x1234, etc.

19:03 emezeske: Gnosis-: If you can use something other than prn, format might be good: http://clojuredocs.org/clojure_core/clojure.core/format

19:04 amalloy: emezeske: i imagine he wants to print a big ol' data structure that contains some numbers, not just a single number

19:04 Gnosis-: right

19:05 Cr8: you could walk it and transform the numbers to hex before printing

19:05 Raynes: You can redefine the method that prn uses to print numbers.

19:05 *shrug*

19:05 Gnosis-: hmm, okay...

19:05 amalloy: warning though, Raynes's ideas are always bad

19:05 Gnosis-: Raynes: it would be cool if prn read metadata to see what base to use for printing a number :)

19:06 amalloy: Gnosis-: numbers don't have metadata

19:06 Gnosis-: oh :(

19:06 Raynes: amalloy: Is this idea bad?

19:06 I mean, we've done similar things before.

19:06 Man, there I go using clojail as an example of 'good' again.

19:06 amalloy: it's pretty bad, yeah, because that's a global behavior you're changing

19:07 Raynes: Well, it really depends on what he is doing.

19:07 Cr8: ,(postwalk (fn [i] (if (number? i) (format "0x%x" i) i)) {:a :b :c {:d 1 :e 2 :c {:a 4}}})

19:07 emezeske: Gnosis-: Out of sheer curiousity, why does the base matter for you? Usually I think of pr as a serializer for read-string

19:07 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: postwalk in this context, compiling:(NO_SOURCE_PATH:0)>

19:07 Cr8: ,(clojure.walk/postwalk (fn [i] (if (number? i) (format "0x%x" i) i)) {:a :b :c {:d 1 :e 2 :c {:a 4}}})

19:07 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.walk>

19:07 Cr8: bah

19:07 Raynes: amalloy: He could always wrap his numbers in a new type and print them differently.

19:07 Cr8: output is: {:a :b, :c {:c {:a "0x4"}, :d "0x1", :e "0x2"}}

19:07 * Raynes dons his tophat and dances around.

19:08 emezeske: Cr8: Those aren't numbers, though, those are strings with representations of numbers

19:08 Cr8: true

19:08 Gnosis-: emezeske: well, because I'm using a map to represent structures inside a binary file, and it's much more "normal" to see the numeric fields as hex instead of decimal

19:09 also vectors

19:09 Cr8: thanks

19:09 Cr8: could wrap it in a class that prn's as hex if you really don't want the quotes

19:11 actually not really with prn, you couldn't as it tries to output something reader friendly

19:13 brainproxy: Raynes: you were right ... when I stopped trying to "embed" the fn object it worked

19:13 Raynes: That's a fiorst.

19:13 first, even

19:31 cemerick: Is there any way to get the version of ClojureScript at runtime, similar to *clojure-version*?

19:33 hrm, I guess git rev numbers would be all there is…

19:51 Frozenlock: Clojurescript is hurting my puny little head. Any tutorial for it?

20:49 emezeske: Frozenlock: How far have you gotten so far in cljs? Do you have a build environment set up?

20:49 Frozenlock: yes and no...

20:50 I can compile (and autocompile at each modification), autoreload my webpage... but I don't have a working repl :(

20:50 emezeske: Are you using lein-cljsbuild, or something else?

20:50 Frozenlock: lein-cljsbuild

20:51 emezeske: Which repl are you trying to get set up? repl-listen?

20:51 Frozenlock: Yes.

20:51 :repl-listen-port 9000

20:51 :repl-launch-commands

20:51 {"my-launch" ["chromium-browser" "" "http://localhost:8888"]}

20:51 And then: lein trampoline cljsbuild repl-launch my-launch

20:52 emezeske: What's that empty arg between chromium-browser and http...?

20:52 Frozenlock: it was "-jconsole" for firefox

20:52 emezeske: You should probably remove that altogether

20:52 Have you added the little repl-related code segment to your cljs code?

20:53 Frozenlock: I will go with "no" :P

20:53 emezeske: Okay, that's the step you're missing I think

20:53 Take a look at this:

20:53 https://github.com/emezeske/lein-cljsbuild/blob/master/example-projects/advanced/src-cljs/example/repl.cljs

20:54 Your clojurescript code has to explicitly connect to the REPL session

20:54 When you run "repl-launch", the clojurescript repl listens on localhost:9000

20:54 Then once your clojurescript is loaded, it needs to connect to that port to receive code to execute in the browser

20:56 Frozenlock: Can I still keep my port 8888 for the server? server (8888) --> browser | browser (9000) ---> REPL?

20:56 emezeske: Yes, the port your http server listens on is totally orthogonal to the repl stuff

20:58 Frozenlock: I think I'm missing the next step too... How can I check if it worked? My REPL will be in the same window as my lein trampoline command?

21:01 wmealing_1: now if only someone could hook up http://www.ymacs.org/demo/ to clojurescript...

21:05 Frozenlock: "ClojureScript:cljs.user> Created new window in existing browser session." And then nothing

21:22 nkoza2: where clojure.contrib.core/dissoc-in go? (I'm using clojure 1.4)

21:23 Frozenlock: Omg I got it!

21:23 bbloom: nkoza2: can't you juse use update-in and dissoc ?

21:23 Frozenlock: Life without a REPL isn't worth living.

21:24 bbloom: Frozenlock: agreed. I have added project.clj to my local versions of all the java code at work, so I can have my REPL :-)

21:24 nkoza2: bbloom: I want to remove all the path if dissoc returns an empty map, I think dissoc-in was better

21:25 Frozenlock: Next step is to bring back the REPL in Emacs (perhaps slime). But I don't want it to mess with the java REPL....

21:27 bbloom: nkoza2: ah ok. i found it: it's core.incubator

21:27 here:

21:27 https://github.com/clojure/core.incubator/

21:27 nkoza2: bbloom: thanks!

21:27 bbloom: contrib got reorganized, and i guess that the "incubator" is where stuff goes if it's being considered for inclusion into core proper

21:27 nkoza2: weird something as simple as dissoc-in is considered beta

21:28 bbloom: nkoza2: it's not that it's beta, it's that it's behavior is ambiguous

21:28 nkoza2: why is ambiguous?

21:28 bbloom: nkoza2: assoc-in has only one possible behavior, and that's mkdir -p style creation of empty maps down the line

21:29 but dissoc-in could be update-in//dissoc or recursive deletion of empty maps

21:29 amalloy: nkoza2: what does (dissoc-in {:a {:b 1}} [:a :b]) return?

21:29 bbloom: the former doesn't mirror assoc-in

21:29 but the later is potentially dangerous b/c what do you do with the root map if that's empty? do you get an empty map? or do you get nil?

21:30 so you have to treat the root node different from interior nodes different from leaf nodes

21:30 it wasn't clear if dissoc-in was generally useful or not

21:31 but it seems like it will make it's way into core eventually, consider the behavior turns out to be sane in practice

21:31 where it's common to have interior nodes that are both 1) important not to be removed and 2) not empty

21:31 Frozenlock: `(run-lisp "lein trampoline cljsbuild repl-launch my-launch")' I feel like I'm getting near :)

21:32 bbloom: nkoza2: make sense?

21:35 nkoza2: amalloy: it returns {}

21:35 amalloy: nkoza2: the point is it would be reasonable for it to return {:a {}} instead. that's why it's not in core

21:36 nkoza2: bbloom: thanks for the explanation

21:40 bbloom: nkoza2: my pleasure. that one made me scratch my head the first time i saw it too. I decided "ok, these clojure guys are pretty smart, there must be a reason" and reflected on it for a bit until it became obvious!

21:41 nkoza2: bbloom: probably the best is to add an argument to dissoc-in to specify the behaviour, or split it in two functions

21:41 bbloom: nkoza2: well, in general, you really want update-in dissoc

21:42 or you want "dissoc recursively up to a point and then stop" b/c you don't want to uncreate your root node or one level of book keeping nodes

21:43 hence it not being in core

21:43 kenneth: hey if i've created an uberjar

21:43 bbloom: and it being really easy to write if you need it! not everything needs to be in core

21:43 kenneth: how do i execute that jar

21:43 bbloom: the bar is very high

21:43 kenneth: i mean, how do i execute a clojure / lein main in that jar

21:44 i can run by doing `lein run -m some.namespace` -- what's the uberjar equivalent?

21:44 wmealing_1: java -jar filename.jar ?

21:44 eggsby: kenneth: you need to specify in your namespace a (:gen-class) as well as a lein :main directive in your project.clj that refers to that ns, that ns also must have a -main method

21:44 try 'lein new app somename' to check out the general structure of apps like that

21:45 kenneth: eggsby: i've got the gen-class, i don't have a :main however

21:45 i'd like to specify which ns to run as a cli on the jar, if that's at all possible

21:46 wmealing_1: eggsby: you're psychic

21:46 kenneth: something like java -jar my.jar -m some.ns

21:46 wmealing_1: kenneth: make "lein run" work first.. then it will run whatever is the default "main" is with the uberjar

21:48 kenneth: https://github.com/wmealing/soundlevel/blob/master/project.clj <-- see :main specified here.

21:48 see main setup in "soundlevel/core.clj" here https://github.com/wmealing/soundlevel/blob/master/src/soundlevel/core.clj

21:49 kenneth: wmealing_1: right, i get that. should i just make a main ns that executes another ns' -main, then?

21:49 if i want to be able to select the ns at execute time

21:50 wmealing_1: dont do that.

21:50 i mean

21:50 if you need to execute another ns's -main

21:50 it might be best just to put it in yours then

21:51 ie, dont complicate it more than it needs to be.

21:52 kenneth: wmealing_1: well, my use case is this: i have multiple ns (cb.broker, cb.something-else) that all get compiled into the same jar

21:52 wmealing_1: ok, with you so far.

21:52 cmcbride_: does anyone know why this code doesnt work?

21:52 (read-string (pr-str (byte-array (map byte [1 2 3]))))

21:52 I get an

21:52 wmealing_1: kenneth: i assume that cb.broke cb.something have their own -main function

21:52 cmcbride_: Unreadable form exception

21:52 kenneth: and i'd like to be able to execute one of these executable ns (ie. has gen-class and -main) with a cli option

21:52 right

21:53 so i'd like to do something like java -jar my.jar -main cb.broker, and java -jar my.jar -main cb.something

21:53 or something to that effect

21:54 wmealing_1: if i was to do it, i'd probably do this

21:54 Frozenlock: Now that I've successfully connected to a cljscript REPL... is there a swank for cljscript? :)

21:54 wmealing_1: in your namespaces main, parse the command line, import the correct "-main" as something else, then run it

21:54 Frozenlock: good going

21:55 Frozenlock: wmealing_1: Little by little, I'm learning

21:55 wmealing_1: and use them as that name

21:55 does that make sense kenneth ?

21:55 kenneth: that makes sense

21:56 now i need to figure out how to parse cli

21:56 wmealing_1: plenty of options :)

21:56 xeqi: &(pr-str (byte-array (map byte [1 2 3]))

21:56 lazybot: java.lang.RuntimeException: EOF while reading, starting at line 1

21:56 xeqi: &(pr-str (byte-array (map byte [1 2 3])))

21:56 lazybot: ⇒ "#<byte[] [B@874230>"

21:58 cmcbride_: &(read-string (pr-str (byte-array (map byte [1 2 3]))))

21:58 lazybot: java.lang.RuntimeException: Unreadable form

21:58 Frozenlock: technomancy: Can swank.clj somehow be used with cljs?

21:58 xeqi: cmcbride_: java strings like that are not readable

21:58 Frozenlock: cemerick is working on a way to have cljs run on nrepl

21:58 but its still very very cutting edge

21:58 cmcbride_: so if I wanted to serialize a byte array to send via http, how would I do it?

21:59 Frozenlock: xeqi: Yes, but I'm mainly interested in docstrings and autocomplete, which isn't in nREPL yet if I understand correctly.

22:06 kenneth: ok so how do i get CLI arguments in clojure

22:06 i don't' get that

22:06 Iceland_jack: *command-line-args* ?

22:07 seancorfield: or use tools.cli from contrib

22:08 fenton: why does this function print 0 and not 1? http://pastie.org/4470454

22:08 kenneth: right using tools.cli still wants you to supply it a vector of cli options, which i just learnt from Iceland_jack you get at *command-line-args*

22:08 seancorfield: tools.cli is nice because it pre-parses everything and handles positional and keyword arguments, defaults, aliases and so on

22:08 kenneth: so i think i'm good now :)

22:08 seancorfield: ok

22:09 fenton: trying to get atoms to work :(

22:09 seancorfield: your -main function has the command line arguments kenneth

22:10 cmcbride_: has anyone has success sending protobufs over http in clojure?

22:10 seancorfield: if you have (defn -main [& args] ...)

22:10 kenneth: oh, wait, it does seancorfield ?

22:10 xeqi: fenton: for is lazy, try ##(doc doseq)

22:10 lazybot: ⇒ "Macro ([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."

22:10 seancorfield: then you do (tools.cli/cli args ...) to get your options map

22:10 fenton: thanx xeqi

22:10 kenneth: gotcha

22:11 wmealing_1: fenton: when i read your name, i can't help but think of the dog.

22:11 kenneth: other question, how do you pass arguements when doing a lein run, so that they don't get interpreted as lein arguments

22:11 fenton: wmealing_1: there's a dog?

22:11 seancorfield: it makes me think of ice cream! fenton's ice cream rocks :)

22:11 wmealing_1: you havn't heard !? one second

22:11 http://fenton.firebrandstore.com/

22:11 and http://www.youtube.com/watch?v=3GRSbr0EYYU

22:12 fenton: lol...i remember someone sending me that video before!!! I'll have to order one of those t-shirts!!!

22:12 xeqi: cmcbride_: I know #flatland people made https://github.com/flatland/clojure-protobuf ; not sure how they use if

22:13 Frozenlock: I'm still a little confused about the clojure/cljs relation. Shouldn't this provide me with a function metadata? (let [fun "map"] (meta (ns-resolve 'clojure.core (symbol fun))))

22:14 cmcbride_: xeqi: yea Im using that but I cant figure out how to send them over over http

22:14 thanks though

22:14 cemerick: Frozenlock: nREPL is lower-level than code completion. Stuff like that can readily be made available as via nREPL middleware though, and in such a way that a single nREPL client will be able to talk to e.g. Clojure or cljs or clojure-py or … without changes.

22:15 Frozenlock: o_0

22:19 kenneth: does this make sense? https://gist.github.com/a0d614879581cc06c481

22:22 amalloy: cmcbride_: sending them over http? that's nothing to do with protobuf; just send them however you send any binary data over http

22:24 xeqi: kenneth: I wouldn't expect the (the-ns/-main) part to work

22:25 does it?

22:25 amalloy: no way. nor the line above it either

22:26 also, kenneth, that function you're trying to write already exists. it's in clojure.main

22:28 djanatyn: I'm having a lot of trouble building a list of all possible orders a list of things can take :|

22:29 seancorfield: would math.combinatorics help djanatyn ?

22:29 xeqi: djanatyn: math.combinatorics/permutations ?

22:30 amalloy: indeed, permutations, but it's a good function to be able to write yourself too

22:30 Gnosis-: noob question: how do I reload files while in the Leiningen REPL?

22:31 bbloom: `(doc load-file)

22:31 er i mean:

22:31 ,(doc load-file)

22:31 clojurebot: "([name]); Sequentially read and evaluate the set of forms contained in the file."

22:31 djanatyn: seancorfield: that would be cheating :)

22:31 I mean, I'm having limited success

22:32 bbloom: *shrug* i dunno, i never evaluate more than a single top-level form at a time during development

22:33 cmcbride_: amalloy: thats the part I cant figure out

22:33 Gnosis-: bbloom: so when you update your files, how do you see your changes in the REPL? do you exit and start up again?

22:33 Frozenlock: What's the general opinion about using jQuery in cljs? (jayq)

22:33 bbloom: Gnosis-: I evaluate individual forms as i change them

22:33 djanatyn: ,(let [list '(1 2 3 4 5) ] (map (fn [first] (cons first (remove #(identical? first %) list))) list))

22:33 clojurebot: ((1 2 3 4 5) (2 1 3 4 5) (3 1 2 4 5) (4 1 2 3 5) (5 1 2 3 4))

22:33 bbloom: Gnosis-: if I change a function, i press a key combination in my vim to send that top-level form to the repl.

22:34 Gnosis-: oh

22:34 bbloom: Gnosis-: and if I delete a function, i use:

22:34 `(doc ns-unmap)

22:34 cmcbride_: amalloy: Im using http async client and when I send binary data it doesnt seem to come out the same on the other side

22:34 bbloom: by hand in the repl

22:34 damn i suck at clojurebot today:

22:34 ,(doc ns-unmap)

22:34 clojurebot: "([ns sym]); Removes the mappings for the symbol from the namespace."

22:34 bbloom: but i'm a vim-guy, the swank people may look down upon my primitive mechanism :-)

22:35 Frozenlock: cemerick: I just discovered your podcasts and I really enjoy! Thanks for that!

22:36 amalloy: djanatyn: you'll want a recursive solution. so, just break it up into the two steps. what's the base case, ie all permutations of an empty list; and, given a list of size N, can you reduce the size of the problem to N-1?

22:37 what you pasted is basically a solution (although not a very good one IMO) to the recursive case, except you didn't recurse down to further permute the rest of the list

22:38 djanatyn: *nod*

22:38 that's the farthest I've gotten

22:39 Gnosis-: why doesn't this work?

22:39 ,(<= \0 \3 \9)

22:39 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number>

22:39 i_s: anyone know of a good clojure thing for sanitizing SQL?

22:40 cemerick: Frozenlock: groovy :-)

22:40 amalloy: characters aren't numbers

22:41 Gnosis-: well, what I mean is, why can't <= work on characters, since it makes sense for one to be less than another

22:43 kenneth: amalloy: it is?

22:44 Frozenlock: Omg I just changed a webpage background using my repl. \o/

22:44 (small goals)

22:44 kenneth: amalloy: not too sure how to use that

22:45 jbarrios: hi!

22:45 amalloy: java -cp whatever:paths:here clojure.main -m my.ns

22:46 xeqi: Gnosis-: outta curiousity, whats the ordering for \♥ \❤ \❥ \❣ \❦ \❧ ?

22:47 kenneth: oh awesome amalloy that's what i needed to know! :)

22:47 i didn't think it was possible, i asked easier

22:48 amalloy: i think it got added in 1.3? not sure

22:50 actually, i guess it's been around forever but got...improved, somehow, at some point? not very helpful information here

22:52 kenneth: jesus, what an unsightly command :p -- java -cp jvm-1.0.0-SNAPSHOT-standalone.jar:/usr/local/share/java/zmq.jar:/usr/share/java/zmq.jar -Djava.library.path=/usr/local/lib:/usr/lib:/usr/lib64:/usr/local/lib64 clojure.main -m cb.broker

22:55 xeqi: and you're not even setting -Xmx

23:05 Gnosis-: kenneth: shell script!

23:07 treehug: i_s: can't think of a portable way, but most jdbc drivers provide an escape function you can use directly. if it's for parameters, you're far better off binding instead of escaping

23:07 Gnosis-: xeqi: whatever the order of the Unicode code points is :)

23:11 djanatyn: umm, what are the car and cdr equivalents in clojure?

23:11 Gnosis-: first and next, I htink

23:11 could be first and rest

23:12 i_s: treehug: thanks. looks like mine (clojure.java.jdbc) is already doing it.

23:13 Frozenlock: What about cdddar :p

23:18 Gnosis-: Frozenlock: (def cdddar #(nth % 3)) :P

23:19 Frozenlock: Not as sexy

23:20 Gnosis-: You can always write your own Lisp in C

23:20 struct cons { void *car; void *cdr;};

23:20 Frozenlock: BAM! Lisp :p

23:20 Gnosis-: damn straight

23:21 Frozenlock: if you copy-paste that into ##lisp, everyone will twitch at once

23:21 tell them you found it in the SBCL source code

23:22 Frozenlock: Why would they twitch? If I recall right that's more or less how cons is defined...

23:22 cemerick: huh, I haven't been in #lisp in *years*. Interesting that there's only 380 ppl. there at the moment.

23:23 Gnosis-: Frozenlock: they want to pretend there's no C involved

23:23 I dunno, maybe not

23:24 Frozenlock: I can understand, I don't want to admit there's some java under clojure :P

23:25 Raynes: cemerick: That

23:25 sentence will end momentarily.

23:25 That's because all the cool people are in here.

23:26 cemerick: Roughly, yes. :-)

23:27 Gnosis-: cemerick: I have some pretty harsh criticism of your Clojure book

23:27 I'm not sure you want to hear it... :)

23:27 Raynes: Oh boy.

23:27 Critics, man.

23:27 Almost makes me never want to pick my own book back up. I can't wait to hear what people would say about my writing style.

23:28 My answer to that is "Did you learn Clojure? Then shut up."

23:28 :p

23:28 Gnosis-: cemerick: there's nothing in there about file I/O

23:28 Raynes: Can't cover everything.

23:28 Gnosis-: actually, aside from that, it's an excellent book

23:28 Raynes: file I/O seems pretty basic, though

23:29 Raynes: I'll admit it is a tiny bit strange to cover web dev but not that.

23:29 But it's easy to overlook things when you're operating at such a low level.

23:30 Anyways, (line-seq (clojure.java.io/reader "myfile"))

23:30 Gnosis-: you mean high?

23:30 Raynes: No, I meant low.

23:30 When you're writing a book, you'

23:30 Damn enter key being close to the apostrophe key.

23:31 When you write a book, you dig into small pieces at once. Little individual things.

23:31 Gnosis-: oh

23:31 djanatyn: ...hmm. okay, so I've made *some* progress but now this is a mess.

23:31 Raynes: You tend to build it from the middle out.

23:31 It's hard to look at what you've written and say "Oops, I forgot x."

23:32 cemerick: Gnosis-: Fair point. File I/O is boring as hell though. Important, but boring.

23:32 Raynes: If x isn't macros or multimethods, anyways.

23:32 But hey, he is the writer. I'm the semi-writer-hopeful-guy.

23:32 cemerick: It's like detailing how Java strings are unicode and so aren't screwed up like ruby strings or something.

23:32 tolstoy: cemerick: Oooo, a new (to me) Clojure book? I might just buy it for ammo about Dependency Injection. (Folks loves them some Guice where I work.)

23:33 Raynes: The cool thing about co-authors is that he can just blame it on cgrand or something.

23:33 cemerick: The people that need file I/O will go look it up. :-)

23:33 tolstoy: cemerick: Ammo I'll keep to myself, of course.

23:33 * cemerick facepalms re: Guice :-)

23:34 Gnosis-: actually, Java strings kind of are screwed up since they can't handle Unicode above 0xffff

23:34 meh

23:34 cemerick: Are there any languages that *do* handle those ranges well?

23:35 Gnosis-: any language with 4-byte characters

23:35 cemerick: Right, I'm wondering if there are any.

23:35 Gnosis-: I think C's wchar_t on some platforms...?

23:35 cemerick: Well, that's awesome. :-P

23:35 Raynes: I think he is trying to understand your standards for 'screwed up'.

23:35 Because by your standards, perhaps everything is screwed up.

23:35 Gnosis-: okay, I guess they are good enough for almost everything

23:36 cemerick: Raynes: Screwed up is equating byte arrays with strings, and then put on a jazz-hands show using a pile of ill-conceived functions.

23:37 Raynes: cemerick: Erlang.

23:37 wmealing_1: oh that was low.

23:37 cemerick: Oh? Sad.

23:37 Raynes: Tell me about it. :(

23:37 cemerick: And here I thought it might be fun to tinker with someday.

23:37 wmealing_1: it is

23:38 Raynes: I had nothing but hell with byte strings in Elixir.

23:38 wmealing_1: what trickery were you doing ?

23:38 cemerick: wmealing_1: Perhaps, but I can't bring myself to invest in a runtime that doesn't have reasonable strings.

23:40 wmealing_1: I guess I do less string manipulation than most.. never found it difficult.

23:40 cemerick: Not to say the JVM is a hands-down winner. All of the options Python provided for strings was very pleasant.

23:40 s/was/were

23:44 amalloy: djanatyn: still working on permutations?

23:48 if so, gist what you've figured out and i'll see if i can help you get it working

23:49 Frozenlock: In cljs, does one use a library like in clojure? Say: (use 'jayq.core) ?

23:53 djanatyn: amalloy: yes

23:54 xeqi: Frozenlock: I usually use :require or :require-macros, but I would expect :use to work

23:56 djanatyn: amalloy: https://gist.github.com/3346147

23:57 TimMc: cemerick: In Erlang, strings aren't even a separate thing, they are just (cons?) lists of integers.

23:58 cemerick: TimMc: Noted.

23:58 TimMc: You can apparently also do UTF-8 strings as binary objects, but some libraries use one and some the other.

23:59 amalloy: huh, 4clojure hasn't asked a permutations question? crazy

Logging service provided by n01se.net