#clojure logs

2012-08-13

00:26djanatynwhen using defrecord, is there a way to explicitly specify what type you want things to be?
00:27djanatynlike, if you want a collection of some sort, or a string or a number
00:27McMartinYou can extend the type or inline it like it were reify
00:27McMartinI don't believe you can pick an actual class to extend from without using proxy, though
00:28djanatyn*nod*
00:28djanatynclojure's records are a lot like Haskell's
00:30McMartinClojure has the best immutable datatypes I've seen outside of Haskell, yeah
00:36djanatynumm, another question!
00:36djanatynI'm using hiccup.core and trying to make a bunch of p elements
00:37djanatynI have a list of strings, foo. I want to return [:p bar] for each bar in foo
00:38djanatynI 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
00:39Cr8that #(: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
00:40jeremyheilerMaybe (map #(vector :p %) ["one" "two" "three"])
00:40Cr8you can use (map (fn [x] [:p x]) ...
00:40qmxis amotoen the best peg-parser in clojure land? any other recommendations?
00:40Cr8jeremyheiler's suggestion also will work
00:41Cr8or even (map (partial vector :p) ...
00:41jeremyheiler,(map #(vector :p %) ["one" "two" "three"])
00:41clojurebot([:p "one"] [:p "two"] [:p "three"])
00:41djanatynCr8: thanks!
01:03djanatyngah. I feel so dirty. it's really weird using functional programming concepts without the strictness of haskell's type system
01:03djanatynI really like clojure, though. this is cool!
01:03djanatynI just kinda feel like my code is going to explode
01:04McMartinDon't forget that evaluation is *usually* eager in Clojure >_>
01:06djanatyn...am I really supposed to use (spit) and (slurp) for IO?
01:06djanatynOr is there an alternative that's more idiomatic?
01:07jeremyheilerclojure.java.io are the wrappers around the standard java io classes.
01:08jeremyheilerspit and slurp use that underneath.
01:19amalloydjanatyn: 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])
01:21amalloyand 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
01:26djanatyn*nod*
01:27djanatynhttp://sprunge.us/aLaY?cl
01:29djanatynor alternatively http://dpaste.org/2JxDa/ without common lisp syntax highlighting
01:46lambda-studjanatyn: 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/
01:50djanatynlambda-stu: thanks!
02:18harja3
02:18harjaoops.
02:33Bahman_MourningI have this weird problem with lein...
02:34Bahman_MourningWhen I do clojure-jack-in the REPL starts fine...
02:34Bahman_Mourningno errors whatsoever.
02:34Bahman_MourningBut none of my namespaces are available...I have to compile them manually to be accessible from REPL.
02:36Bahman_MourningAny hints?
02:39DaoWenBahman_Mourning: is lein starting in the right directory?
02:39DaoWenyou should be able to check by running (System/getProperty "user.dir")
02:40Bahman_MourningDaoWen: By "right directory" you mean the one that contains project.clj? If that's the case, yes.
02:43DaoWenBahman_Mourning: what do you mean by "manually compile" ?
02:43Bahman_MourningDaoWen: I have to use C-c C-k or C-c C-r
02:44DaoWenwhat happens if you run (use 'your.name.space)
02:44DaoWen?
02:44DaoWen(before manually compiling it)
02:45Bahman_MourningLet me check...
02:46Bahman_MourningDaoWen: (use) returns nil as expected but then the symbols are not accessible again.
02:47DaoWenthat's confusing... it doesn't throw an error, but you can't access any of the vars.
02:47Bahman_MourningExactly.
02:48Bahman_MourningDaoWen: Does it help if I put my project.clj on pastebin?
02:48DaoWenBahman_Mourning: I don't use emacs, so I don't really know what the problem is
02:49Bahman_MourningDaoWen: Ah...thank you anyway.
02:49DaoWenthat might help someone else help you—but most everyone else are probably asleep
02:49Bahman_MourningDaoWen: One thing. If I start “lein repl” from the command line it shows a normal behaviour...my namespaces are accessible.
02:50Bahman_MourningBut “lein swank” and clojure-jack-in don't work.
02:51Bahman_Mourningdon't work = don't work as expected :-)
02:52DaoWenyeah, 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.
02:53DaoWenBahman_Mourning: good luck!
02:53Bahman_MourningDaoWen: Thanks again for your time.
03:12Bahman_MourningI used “[lein-swank "1.4.4"]” in my :plugins section...
03:13Bahman_MourningBut 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”
03:15DaoWenBahman_Mourning: have you tried running lein deps?
03:16Bahman_MourningDaoWen: Zillions of times :-)
03:17DaoWenhaha
03:17DaoWenyeah, I'm not going to be of any help here
03:40djanatynIs there a 'map that throws out the results and evaluates solely for side-effects?
03:40DaoWendjanatyn: try doseq
03:41djanatynkind of like mapM_ in haskell
03:41DaoWendjanatyn: doseq is more like for, but I think it will do what you want
03:41DaoWenhttp://clojuredocs.org/clojure_core/clojure.core/doseq
03:42djanatynyes, it does, and it actually makes it more concise. thank you!
03:43DaoWendjanatyn: glad I could help!
04:21djanatynHow 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?
04:21djanatynI was going to use either the date-clj or clj-time libraries on clojars.
04:28hyPiRiondjanatyn: clj-time is nice
04:44AustinYuni wonder, is there anything i can do that other people might actually find useful :p
04:49ro_stcan you make coffee? -grin-
04:54jycdoes anyone here use counterclockwise and know how to terminate a REPL (sorry if this is the wrong channel)
05:01AustinYundoes ctrl+D not work?
05:05mduerksenjyc: do you mean how to interrupt a running evaluation in the repl, or really killing the repl itself?
05:06jycmduerksen: killing the REPL - otherwise it seems running again just piles up processes
05:09clgvjyc: got to console view and click the red square
05:10clgv*go
05:10ro_sti don't suppose anyone knows how to teach Chrome to show the mimetype application/clojure as plaintext?
05:11jycclgv: awesome, thanks so much. is there a keyboard shortcut for that?
05:12clgvjyc: I don't know - you can search for it in perferences -> keys
05:14RaynesAustinYun: Did you ever take a look at that example I showed you?
05:15AustinYunyup
05:15AustinYunhaven't really poked around yet though, although it was quite short
05:18AustinYunhm, i don't understand the control bit
05:19AustinYunoh wait
05:25AustinYunman how does that work
05:25AustinYunit's liek magic
05:25AustinYunit behaves incorrectly where (abs n) == the array length but
05:26DaoWenro_st: try this https://chrome.google.com/webstore/detail/cgjalgdhmbpaacnnejmodfinclbdgaci?hl=en-US
05:26DaoWenlet us know how it works
05:28AustinYunRaynes: ok i honestly don't know what's going on lol
05:28AustinYunexcept if you for example, do (add-one [1 1 1 1] 1 1) you get [2 2 1 1] which is wrong
05:28ro_stthanks DaoWen. will do
05:29AustinYunseems to just be off by 1 in the number of times it will increment
05:29ro_stanyone using fetch?
05:30ro_sti want to use it but i'm not using noir
05:30DaoWenAustinYun: are you still working on that double-reverse array increment problem?
05:30AustinYuner i wasn't really, but raynes sent me a solution
05:31AustinYunwhich is 11 lines, which is less than half of mine
05:31AustinYunDaoWen: refheap.com/paste/4252
05:38DaoWenAustinYun: I don't think that's doing the same thing as the problem you described
05:40DaoWenAustinYun: 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
05:40AustinYuni've got it open in a repl right now
05:40AustinYunand i believe you're right
05:41AustinYunit tricked me into thinking it worked because for the example array [1 4 1 5 1]
05:41AustinYunand the example params, it works
05:41AustinYunbut that's just because of the odd off-by-one behavior lol
05:43DaoWenAustinYun: I didn't actually try running it -- I just read the code :-p
05:43AustinYuni couldn't read the code so i had to run it lolol
05:43AustinYunalso don't know what "update-in" does, except it seems to be a built-in
05:45DaoWencheck the docs: http://clojuredocs.org/clojure_core/clojure.core/update-in
05:46DaoWenupdate-in is usually used for nested structures... in this case I think assoc would have worked just fine instead.
05:50hyPiRionConsider update-in as assocs within assocs.
05:50hyPiRion,(update-in {:a {:b 3}} [:a :b] 5)
05:50clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
05:50hyPiRionwoo
05:51hyPiRion,(update-in {:a {:b 3}} [:a :b] + 5)
05:51clojurebot{:a {:b 8}}
05:51nbeloglazov,(assoc-in {:a {:b 3}} [:a :b] 5)
05:51clojurebot{:a {:b 5}}
05:55jycjust curious, where in the clojure documentation does it say that & makes a function with variable arguments?
05:56AustinYunin defn; it's not super explicit about it
05:56DaoWenhttp://clojure.org/special_forms#Special Forms--(let [bindings* ] exprs*)
05:56DaoWenah--that shouldn't be split
05:57jyccool, thanks!
05:57DaoWenmember:jyc: that whole thing is a URL
05:57nbeloglazovWhy doesn't clojurebot support javadoc function?
05:57DaoWenwow, my pasting is sucking.
05:57jycDaoWen: yep, copied it over
05:57jycwill be fun to read through all of this, heh
05:57DaoWenjyc: search for "& followed by" on that page
05:57clojure-newcomerhey guys, anyone know how I can get the request uri using Noir ?
05:58jycDaoWen: thanks again
05:58AustinYunwait, then what does the [params* ] mean?
05:59DaoWenAustinYun: that's grammer-speak
05:59DaoWenthe * is a kleene-star
05:59nbeloglazovAlso does clojurebot have command to show clojuredocs url for given function?
05:59DaoWenit just means "one or ore"
05:59DaoWen"one or more"
05:59DaoWenwow
06:00DaoWenno, it means "zero or more"
06:00DaoWenI'm going to leave now :-p
06:00DaoWenbye
06:00AustinYunok so i was conflating the "zero or more" part with the part where you can specify positional parameters and a "rest" param
06:03hyPiRionHuh
06:04hyPiRion,(let [] (+ 1 2 3))
06:04clojurebot6
06:04hyPiRionInteresting.
06:07AustinYun,(let [] (inc))
06:07clojurebot#<CompilerException clojure.lang.ArityException: Wrong number of args (0) passed to: core$inc, compiling:(NO_SOURCE_PATH:0)>
06:07AustinYun<_<
06:07hyPiRionAustinYun: heh.
06:08hyPiRion,(let [])
06:08clojurebotnil
06:09AustinYunah
06:09AustinYunactually that makes sense
06:10AustinYunsince (let []) just defines a lexical scope for the expression afterward to run in, right?
06:10hyPiRionYeah
06:10hyPiRionIt's interesting that the lexical scope can be empty though, I didn't know that.
06:11AustinYunso (let [] expr) is just (expr) in a blank scope -- i guess if you had problems with namespace pollution or something it might be useful?
06:11AustinYunwonder if it'll automatically shadow other vars to be undefined
06:11AustinYunprobably not, that makes no sense
06:11hyPiRionAustinYun: Nah, (let [] expr) is expr in a blank scope.
06:11AustinYun3:10 AM and i'm more of an idiot than usual
06:12hyPiRionI cannot see any reason for this to be useful, lol.
06:12AustinYun,(let []) is interesting though
06:12clojurebotnil
06:12AustinYun,()
06:12clojurebot()
06:12AustinYunhm
06:12hyPiRionoh, here's an interesting one
06:12hyPiRion,(= (class ()) (class '(1)))
06:12clojurebotfalse
06:12AustinYun,(class ())
06:12clojurebotclojure.lang.PersistentList$EmptyList
06:12hyPiRion,(class ())
06:12clojurebotclojure.lang.PersistentList$EmptyList
06:13AustinYunlol
06:13hyPiRionhehe
06:13nbeloglazov,(type ())
06:13clojurebotclojure.lang.PersistentList$EmptyList
06:13AustinYunok so EmptyList is its own type
06:13hyPiRionI don't think () has any metadata.
06:13hyPiRion,(meta ())
06:13clojurebotnil
06:13AustinYun,(class '(1))
06:13clojurebotclojure.lang.PersistentList
06:14hyPiRionThere are many strange things in Clojure.
06:14hyPiRion,(case 1 2)
06:14clojurebot2
06:14AustinYun,(and () true)
06:14clojurebottrue
06:15AustinYuncommon lisp () is like the only false value right?
06:16hyPiRionyeah
06:16hyPiRionwell, there's t and nil, which roughly translates to true and nil.
06:17hyPiRionEverything's true unless it's nil in Common lisp.
06:17AustinYun,(class [])
06:17clojurebotclojure.lang.PersistentVector
06:17nbeloglazov:)
06:17AustinYunnot PersistentVector$EmptyVector huh
06:18Toheii, (= (class (list ())) (class '(1)))
06:18clojurebottrue
06:18AustinYun,(class {})
06:18clojurebotclojure.lang.PersistentArrayMap
06:18hyPiRion(()) is a list with one element though.
06:18hyPiRion,(list ())
06:18clojurebot(())
06:18hyPiRionvs ##(list)
06:18lazybot⇒ ()
06:18hyPiRion,(class (list))
06:18clojurebotclojure.lang.PersistentList$EmptyList
06:19AustinYunyup
06:19ToheiiYou can only get the EmptyList type with (quote ()) or '() then right?
06:19AustinYun,(range 0)
06:19clojurebot()
06:19AustinYun,(class (range 0))
06:19clojurebotclojure.lang.LazySeq
06:19AustinYun<_< crap
06:21AustinYun,(class (pop (1)))
06:21clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
06:21hyPiRion,(let [id (memoize identity) alist (id (java.util.ArrayList.)) vect (id [])] (.add alist 1) vect)
06:21clojurebot#<ArrayList [1]>
06:21AustinYun...
06:21AustinYun,(class (pop '(1)))
06:21clojurebotclojure.lang.PersistentList$EmptyList
06:21AustinYunthere we go
06:21clgv$javadoc java.util.Date
06:21lazybothttp://docs.oracle.com/javase/6/docs/api/java/util/Date.html
06:22clgvnbeloglazov: ^^
06:22clgv$clojuredocs println
06:22nbeloglazov$javadoc Thread
06:22lazybothttp://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html
06:22clgvok, thats not built-in
06:22AustinYunmaybe
06:23AustinYun$clojuredoc println
06:23nbeloglazovclgv: thanks
06:25QerubIs there a nicer substitute for the expression #(%1 %2)?
06:26nbeloglazovQerub: try apply
06:26hyPiRionQerub: Clojure has no funcall equivalent.
06:26AustinYun(fn [x y] (apply x y)) ? or something
06:27nbeloglazov(apply println 1)
06:27nbeloglazov,(apply println 1)
06:27clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
06:27hyPiRionthat'll crash
06:27nbeloglazovYep
06:28AustinYun,(apply println '1)
06:28clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
06:28Bronsa(deliver inc 1)
06:28Bronsa,(deliver inc 1)
06:28clojurebot2
06:28AustinYun,(apply println '(1))
06:28clojurebot1
06:28hyPiRion,(let [funcall (fn [f & args] (apply x args))] (funcall println 1))
06:28clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0)>
06:28Qerub,(apply println 1 [])
06:28clojurebot1
06:28hyPiRion,(let [funcall (fn [f & args] (apply f args))] (funcall println 1))
06:28clojurebot1
06:29AustinYundifference between javascript call and apply
06:29hyPiRionBronsa: How does that work? I though deliver took a promise, not a fn
06:30nbeloglazov,(doc deliver)
06:30clojurebot"([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."
06:31hyPiRionOh man. That's just mean and dangerous.
06:31hyPiRion,(source deliver)
06:31clojurebotSource not found
06:31nbeloglazovsource deliver
06:31hyPiRionIt's basicall
06:31hyPiRion(defn deliver [promise val) (promise val))
06:32clgv hyPiRion: the `source` function needs access to the source files. probably the bot is aot compiled
06:32clgv$source deliver
06:32lazybotdeliver is http://is.gd/mWYXsL
06:32clgvhmm that function seems to have an outdated database
06:32Qerubnbeloglazov, hyPiRion: I guess not then. Thanks for discussing!
06:32AustinYun,(deliver + 1 2 3)
06:32clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core$deliver>
06:32QerubDoes this look crazy to you? (defn f [x] (condp #(%1 %2) x, number? do-something, symbol? do-something-else, …))
06:33QerubI'd like to avoid the repetition in (cond (number? x) do-something, (symbol? x) do-something-else, …).
06:34AustinYundefmulti?
06:34clojurebotdefmulti doc is python
06:34AustinYunO_o
06:34hyPiRionQerub: Hmm, can you dispatch on type or class?
06:34hyPiRion(condp class x ...)
06:34AustinYunwhy is defmulti doc python
06:35hyPiRionAustinYun: I believe clojurebot is growing more and more sentient by each day. Bugs included.
06:35QerubhyPiRion: I suppose i could use `instance?` (to cover inheritance).
06:36AustinYunanyway, it doesn't look THAT crazy, except you might want to make a multi-method that dispatches on the type of x
06:36hyPiRionQerub: sounds good.
06:37howardIf 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
06:39hyPiRionQerub: I haven't really dispatched that much on classes, but if it grows large, I'd use multimethods or protocols.
06:41QerubhyPiRion: Yeah, I understand why. In this case with few branches and no need for extensibility a simple cond works well.
06:41QerubhyPiRion: Thanks!
06:42AustinYunhoward: interesting, you just release?
06:42howardit's a pet project i've been working on, to practice using Clojure
06:48hyPiRionhoward: Interesting. A quick tips: For Github, it's better to have .md-files as doc
06:48howardthank you
06:48howardwill do soon
06:48howardme still learning to use github :P
06:50Cr8I almost wrote something like this last week :D I might use this
06:50hyPiRionI haven't got enough time to look at the source AND understand it, but the specs look very nice for being 700 loc.
06:52ro_stbtw, cljs <> clj remoting with fetch is ludicrously simple AND easy
06:52ro_stespecially when using enfocus and pubsub to declaratively bind it all together
06:53ro_stthe world is rewarding me for the hours of jquery + php ajax i haven't done -grin-
06:53howardim planning to give it a skip list index so it'll do range query much faster
06:54Cr8howard: what is it now, just a linear thing?
06:54howardit only has a hash index at the moment
06:54Cr8ah
06:54Cr8reminds me of bitcask
06:54howardhash lookup is very fast, as advertised, it easily does 6000+ lookups a second
06:55howardit supports range queries, however they're not optimized
06:55howardrange queries need to scan collection, and that performance is about 160 milliseconds per 1k documents
06:56Cr8yeah, I saw that
06:56howardcorrect.. 80 milliseconds 1k documents
06:56Cr8hm, could you make a log structured skip list
06:57Cr8they always seemed more fit for an in-memory thing to me
06:57howardin-memory...?
06:57Cr8as opposed to on-disk
06:57howardyou mean skip list suits in-memory db better?
06:58Cr8i mean skip lists themselves work better in memory
06:58hyPiRionI think he means having the skip list in memory.
06:58howardi see..
06:58hyPiRionzing.
06:58Cr8than being stored on disk
06:58howardum..
06:58howardmy guess b+tree index will be 300+ lines of clojure
06:58howardskip list may be 200+
06:59howard^_^
06:59Cr8Ex: 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
06:59howardi see. thank you
06:59howardso btree index rather than skip list...
07:00Cr8for on-disk indexes, anyway, i think it is more workable
07:00howard:D
07:03Cr8but 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
07:03howardyeah...
07:04Cr8in the case of a write only being half done when something blows up
07:04howardi need to study how those dbs handle index write failure
07:04wmealing_1java.lang.IllegalStateException: -main already refers to: #'feedparser-clj.core/-main in namespace: blah.core
07:05wmealing_1as blah is my application, does that mean that feedparser-clj's main overrides mine (or trying to compete)
07:05hyPiRionwmealing_1: I suspect you use (:use feedparser-clj.core) or something
07:05wmealing_1should a library have a core ?
07:05wmealing_1yep
07:05wmealing_1i am
07:05wmealing_1rich is coming to brisbane next fri.. am definitely going to
07:05wmealing_1see him
07:06hyPiRionTo not include the -main function in it, you can do (:use [feedparser-clj.core :exclude [-main]])
07:06hyPiRionI think that should solve your problem.
07:06howardbrisbane :D
07:06howardim in melbourne
07:07wmealing_1howard: i'm sorry about the weather.
07:07howardme too
07:07howardhahahaha
07:07howardi caught cold last week
07:07howardmany people did too
07:08howard(time (doseq [v (range 10000)]))
07:08howard,(time (doseq [v (range 10000)]))
07:08clojurebot"Elapsed time: 119.989013 msecs"
07:08howard,(time (doseq [v (range 10000)]))
07:08clojurebot"Elapsed time: 10.492108 msecs"
07:08howard,(time (doseq [v (range 10000)]))
07:08clojurebot"Elapsed time: 10.695053 msecs"
07:09hyPiRionLet's see even more magic
07:09howard, (time (doseq [v (range 10000)] (read-string "{}")))
07:09clojurebot"Elapsed time: 108.588635 msecs"
07:09howard, (time (doseq [v (range 10000)] (read-string "{}")))
07:09clojurebot"Elapsed time: 21.022111 msecs"
07:09howard, (time (doseq [v (range 10000)] (read-string "{}")))
07:09clojurebot"Elapsed time: 4.465608 msecs"
07:09howard, (time (doseq [v (range 10000)] (load-string "{}")))
07:09clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
07:09howardboo
07:09Cr8hahaha
07:09hyPiRion,(time (doall (map inc (range 10000))))
07:09clojurebot"Elapsed time: 38.136212 msecs"
07:09clojurebot(1 2 3 4 5 ...)
07:10hyPiRion,(time (map inc (range 10000)))
07:10clojurebot"Elapsed time: 0.052606 msecs"
07:10clojurebot(1 2 3 4 5 ...)
07:10Cr8,(time (mapv inc (range 10000)))
07:10clojurebot"Elapsed time: 47.154055 msecs"
07:10clojurebot[1 2 3 4 5 ...]
07:10wmealing_1howard: why dont you come to brisbane for it ?
07:10howardi wish i could..
07:11howardmeh, i wish my company could pay for me to go to qld
07:11howardhahah
07:11howardwhat days is Rich gonna be in Brisbane?
07:12wmealing_1Friday, i think
07:12wmealing_1let me check
07:12howardyesterday, i put this project to public using name "ClojureDB", because it stores documents in clojure syntax, interacts with clients using clojure syntax
07:12howardthen Rich told me to think of another name
07:13howardso I thought, Aurinko sounds good in English, and has good meaning in Finnish
07:13hyPiRionhoward: You're Finnish?
07:14howardi wish i was
07:14howardnope :(
07:14howardi love northern European countries
07:14howardas much as I love Australia
07:14Cr8I suppose using "Clojure" in a project name is problematic
07:15howardyeah i agree... it was my bad
07:15wmealing_1ah
07:15wmealing_1howard: i'm incorrecet
07:15wmealing_1howard: http://www.bfpg.org/events/77110852/
07:16howardwoow
07:16howard<3
07:17wmealing_1hyPiRion: thanks
07:18howardthey should add "clojure" into "we're about"
07:22howardgood night guys
07:52[1]Abrahamhow to use regular expr in clojurescript
07:58ro_stsame way you do in clojure
07:58ro_st,(doc re-find)
07:58clojurebot"([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."
07:59ro_st,(re-find #"\s+" "string with some stuff in it")
07:59clojurebot" "
07:59ro_stetc
08:07nvy,(doc def)
08:07clojurebotGabh mo leithsc?al?
08:09ro_stoh….kay, then
08:15hyPiRionWhat in the world.
08:15hyPiRion,(doc def)
08:15clojurebotPardon?
08:15hyPiRion,(doc str)
08:15clojurebot"([] [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."
08:15hyPiRion,(doc foobar)
08:15clojurebotGabh mo leithsc?al?
08:16ro_stprobably couldn't put a doc on def because you need def to do it
08:16hyPiRionI can doc my def though
08:16ro_stshow-off :-)
08:16hyPiRion,(doc doc)
08:16clojurebot"([name]); Prints documentation for a var or special form given its name"
08:17ro_st&(doc def)
08:17lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
08:17hyPiRionI mean, there shouldn't be any issues with it :p
08:17ro_st-shrug-
08:18hyPiRion&(doc (symbol "def"))
08:18lazybotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
08:52cshellis there any core function for generating n distinct random integers?
08:54naeg,(repeatedly 10 #(rand-int 50))
08:54clojurebot(7 23 27 15 47 ...)
08:55naegcshell: where 10 is n (number of random numbers) and 50 is the range of those random numbers
08:55cshellright, but I can get collisions with that
08:55naegoh, misunderstood you
08:55cshellthanks though :)
08:56naegdon't know about a distinct way, would probably write it based on this
08:56cshellthat's what I was thinking
08:56cshellusing a set or something
08:56naegfirst thing that came to my mind too, but I'm farely new to clojure
08:57cshellyeah, me too
08:58naegcshell: show me your solution please when you finished it, coming up with one too j4f
08:58cshellcool, no problem
09:01clgvcshell: well, build a random permutation and take the first n numbers
09:02clgvcshell: ##(->> (range 50) shuffle (take 10))
09:02lazybot⇒ (22 10 31 23 9 41 18 42 49 26)
09:02cshellnice, very clever!
09:03cshellthanks clgv!
09:03naegclgv: isn't there a chance that this won't come up with 10 distinct random numbers?
09:03clgvbut maybe not that efficient if the range is much larger than the count of numbers you select
09:04clgvnaeg: nope
09:04cshellyeah, i'll have 150k items and i only want 4 of them :)
09:05naegoh, I just understood shuffle now
09:05cshellmaybe I just shuffle the collection and take 4?
09:05clgvcshell: then better do ##(->> (repeatedly #(rand-int 150000)) distinct (take 10))
09:05lazybot⇒ (102321 125971 111906 91551 73671 147131 132563 33939 67226 98262)
09:06clgvthe probability for conflicts is pretty small for that ratio
09:06clgvso for k=10 this procedure will be almost O(k)
09:06cshellbut with what you just pasted there won't be conflicts, because of distinct right?
09:07Chousukeclgv: with a true RNG it could run forever though :P
09:07clgvyes. but it could run long for bigger ratios of k/n
09:07Fossiyay, bogosort :>
09:07cshellgot it
09:07cshellthanks clgv!
09:07clgvChousuke: why should that happen?
09:07Chousukeclgv: you might get an infinite sequence of the same number
09:07clgvChousuke: with probability zero? :P
09:08clgv*almost zero ;)
09:08Chousukethen again, you might also win the lottery every week from random dropped lottery tickets you find on the street
09:09clgvcshell: you can try both and see what works best for those numbers. 150k might be small enough for the shuffle
09:09PhoshiHey, 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
09:10clgv#(->> (range 150000) shuffle (take 10) time)
09:10clgvlol or not ;)
09:10clgvups
09:10clgv&(->> (range 150000) shuffle (take 10) time)
09:10lazybot⇒ "Elapsed time: 288.844763 msecs" (73580 109567 38332 56366 7726 100338 57580 82006 48682 114910)
09:10clgvlooks not to bad. but that depends how fast you need it
09:10clgv##(->> (repeatedly #(rand-int 150000)) distinct (take 10) time)
09:10lazybot⇒ "Elapsed time: 263.035961 msecs" (1788 16291 138268 53065 111626 49964 110403 27401 8766 144423)
09:11clgv##(->> (repeatedly #(rand-int 150000)) distinct (take 10) time)
09:11lazybot⇒ "Elapsed time: 221.680642 msecs" (48531 47565 32250 21249 79697 92471 85817 20564 98392 38251)
09:11Chousukehm, why is that so slow
09:12clgvprobably, one should make a real benchmark
09:12cshellmaybe it's slow cause it's generating 150k random numbers
09:13cshellor is it lazy?
09:13clgvyeah range, distinct and take are lazy
09:14metajackjust generating random numbers without distinct takes about 170ms for me
09:14cshellbut won't distinct for evaluation for all 150k random numbers?
09:14metajackoh sorry. misread that. 0.177 ms not 0.177 s.
09:14cshellor does it just wrap it lazily?
09:15clgv(time (dotimes [_ 100] (->> (range 150000) shuffle (take 10) doall))) => "Elapsed time: 2629.182387 msecs"
09:15clgv(time (dotimes [_ 100] (->> (repeatedly #(rand-int 150000)) distinct (take 10) doall))) => "Elapsed time: 16.077269 msecs"
09:16cshellinteresting
09:16cshellthis is a good discustsion.
09:17metajackdistinct is lazy. it walks the sequence keeping a set of things it's seen and skipping anything it sees again
09:17clgvcshell: if you make k bigger relative to n the second will get slower
09:17cshellmakes sense
09:18clgvat 50% you get with (time (dotimes [_ 100] (->> (repeatedly #(rand-int 150000)) distinct (take 75000) doall))) => "Elapsed time: 13357.610222 msecs"
09:19magopianguys, what does it mean when an integer has a appended N
09:19magopianlike 1N
09:19magopiandoes it make it a long?
09:20clgvbigint afaik
09:20clgv&(type 1N)
09:20lazybot⇒ clojure.lang.BigInt
09:21magopianoh ok
09:21magopianand is there a way to coerce function parameters to BigInt ?
09:21magopianoh, bigint ;)
09:25clgvmagopian: you might skipt coercing but using +' which autopromotes to BigInt if it would overflow otherwise ##(doc +')
09:25lazybot⇒ "([] [x] [x y] [x y & more]); Returns the sum of nums. (+) returns 0. Supports arbitrary precision. See also: +"
09:26magopianclgv: thanks a lot !
09:26magopiani'll dig into that
09:26clgvsee ##(+ Long/MAX_VALUE +1)
09:26lazybotjava.lang.ArithmeticException: integer overflow
09:26clgvand ##(+' Long/MAX_VALUE 1)
09:26lazybot⇒ 9223372036854775808N
09:27wmealing_1can 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
09:28metajackwmealing_: I use enlive for that.
09:29wmealing_1what part of enlive ?
09:29metajackthere's a function called texts which does it
09:29wmealing_1thanks, will look into it
09:30metajacksomething like (->> s (StringReader.) html/html-resource html/texts (apply str))
09:51wmealing_1that looks not too bad
10:13ro_stohpauleez :-) -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:13ro_stgood*
10:14ohpauleezbrowser was updated not to use local storage - https://github.com/shoreleave/shoreleave-browser/commit/cf3350b598625c35cbf7ecbaddb67c146e3a6cf3
10:15ohpauleezthat's why I wanted to see the exception you were getting
10:15ohpauleezif I missed a line somewhere or if you had a stale jar
10:17ro_stcomin' up
10:19ro_stoh that's not fair! now it seems to be working :-|
10:21ro_stok. i'm a narna. it's compiling and running now
10:23wmealing_1happens ot the best of us
10:23ohpauleezro_st: Cool, totally keep me posted and then update the ticket however you need to. I promise you fast turn around :)
10:23ohpauleezbeat me to it! Thanks!
10:24ro_stok. 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:25ohpauleezyeah - 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:25ro_stwell, i switched to compojure for the routing part :-)
10:25ro_stpaste inbound
10:25ohpauleezShoreleave is extremely opinionated
10:25ohpauleezcool, thanks!
10:26ohpauleez(not because I think it should be, but because it was built around real projects)
10:26ro_sti'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:26ohpauleeztotally
10:27ro_sthttps://www.refheap.com/paste/4314
10:27ro_stso, i can get this far converting sl-r's backend, but i'm not sure about the NS loading
10:28ro_stit might make sense to provide access to remotes as a ring middleware instead of as an app handler?
10:28treehughow 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:29ohpauleezAhh, right, these changes are easier. Creating the ns loading isn't that hard, I just have to re-create a single noir function
10:29ohpauleezro_st: That was Kevin's idea as well, remotes as middleware
10:30ro_stah i see
10:30ohpauleezI 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:31ro_stok, i'm going to reimplement your noir backend in my own namespace, stealing load-views-ns from noir
10:31ohpauleezcool, that should work for now. I'll work on a middleware replacement for 0.2.2 release
10:31ro_stnice
10:32ohpauleezawesome, thanks a ton!
10:32ro_sti'm reallllly enjoying enfocus+pubsub+remotes. so declarative
10:32ohpauleezextremely declarative. I'm also a big fan of that combo
10:32ohpauleezYou can hook something up SO fast
10:32pandeiroro_st: ohpauleez: anywhere i can see an example of that?
10:33pandeiroi haven't played with enfocus since it was in the earliest stages
10:33pandeiroand i am just looking at shoreleave now
10:33ohpauleezpandeiro: 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:34ro_sti actually think you'd be better served not working with the demo. no offence, ohpauleez :-)
10:34ohpauleezabsolutely none taken :)
10:35ro_stheck, let me make one. gimme 10
10:35ohpauleezbehold the power of an open and capable community!
10:35pandeiroohpauleez: hear hear!
10:35pandeiroro_st: cheers, would love to have a gander
10:37ohpauleezpandeiro: 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:38ohpauleezShoreleave has the added bonus that I've done most of the grunt work for you (security, cookies, history, etc)
10:38ohpauleezbut it has not been officially announced because it's not officially done :)
10:39ro_sti'll add cljsbuild crossovers and show both the cljs app and the backend remote using fns in the same ns
10:40ohpauleezro_st: Also, if this is true, all of Shoreleave's busses will be faster: https://gist.github.com/3335154
10:43ro_stis it done, yet ? :-D
10:44ohpauleezro_st: haha
10:47nvydude wat
10:47scriptorjust a net split
10:48bjaoudsearch
10:48nvyall right
10:48pandeiroro_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:49ohpauleezpandeiro: There are a lot of opinions about the reactive stuff
10:51ro_sti still need to learn concepts behind the reactive stuff
10:51ohpauleezPersonally 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:52pandeiropubsub is just fine-grained event listeners/handlers, yes?
10:52ohpauleezYeah, it's an event system, but it lets you declare full flows
10:52ohpauleezyou can subscribe a function to a dom event, and functions can subscribe to other functions
10:53ohpauleezatoms can participate too
10:53pandeironice
10:53ohpauleezand you can broadcast using strings, ints, or keywords
10:54pandeiroso a simple data-binding flow would be retrieve data=>store in atom=>update dom=>onchange event=>update atom=>update server ?
10:54pandeirothat could be done declaratively?
10:55ohpauleezYou 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:55ohpauleezbut yes, you bind it declaratively
10:55ohpauleezyou write functions like you normally would
10:55ohpauleezthen all data flow and binding is done by the bus, you just have to plug it together
10:56clgvohpauleez: trying your demo app^^
10:56ohpauleezclgv: 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:56ohpauleezas ro_st said, it's not a good example haha
10:57clgvoh damn. have to do this in a month again then ;)
10:57ro_stgimme 10 more
10:57ohpauleezI really need to finish some stuff up, cut the 0.2.2 release, and announce it on the mailing list
10:57ohpauleezro_st: You're the man! Excited to see it (clgv ^^)
10:58dnolenfun core.logic post http://dosync.posterous.com/know-your-bounds
10:58clgvohpauleez: well seems to do some user interaction at least ^^
11:00ohpauleezdnolen: That's awesome. I read the reference post this morning. Great follow-up
11:00ohpauleezalso nice to see bounded-listo added
11:03clgvI still dont like the "o" suffix - is there no better naming choice?
11:04clojure-newcomerhey 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:04ohpauleezclojure-newcomer: whatever works best for your app
11:04clojure-newcomerright now when I try to bind anything outside of main.cljs in my cljs-binding template it screws up
11:04ohpauleezuse main.cljs to tie it all together and set on-load stuff
11:05VickyIyerHello 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:05clojure-newcomerohpauleez: should I be using require or use to grab stuff from other cljs files ?
11:05clojure-newcomerunsure why my cljs-binding template can only find stuff in main.cljs
11:06ohpauleezclojure-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:06hyPiRionVickyIyer: (partial rand-int 10) returns a function which takes in any amount of arguments, and adds them as the tail.
11:06ohpauleezclojure-newcomer: Always prefer require to use
11:06hyPiRionWhen called with no arguments, it will be the same as doing (rand-int 10)
11:07clojure-newcomerohpauleez: thanks, I will
11:07scriptorVickyIyer: in this case, repeatedly takes a function without arguments
11:07ohpauleezclgv: http://stackoverflow.com/questions/9164051/why-do-minikanren-names-always-end-with-o?rq=1
11:07scriptorif you just pass it (rand-int 10) that won't work, because that won't return a function
11:07clojure-newcomerit seems use needs me to be explicit about every element in an ns, which is painful
11:07VickyIyer(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:07scriptorVickyIyer: calling (partial rand-int 10) returns a function which calls (rand-int 10) every time
11:08hyPiRionBasically, (partial rand-int 10) is the same as (fn [] (rand-int 10)), or #(rand-int 10) for short.
11:08scriptorVickyIyer: just mentioned it above, repeatedly takes a function
11:08VickyIyerok got it now thanks for the explanation
11:08scriptorVickyIyer: (rand-int 10) does not return a function, but by wrapping it in partial it conveniently becomes a function
11:09casionwhy cant you just do (zipmap [:x :y :z] (repeatedly #(rand-int 10)))
11:09casionwhy is partial necessary?
11:09VickyIyerthat is really cool, I have not seen this in language I have worked in
11:10clgvohpauleez: then I vote for "*-o" or "*_o" - that latter is subscript in latex insted of superscript ;)
11:11ohpauleezclgv: Or we could modify our editors and any function that ends in o gets printed as a superscript
11:11clgvohpauleez: humm, why not bla° ?
11:11ohpauleezclgv: you could do that, since Java is utf16
11:12ohpauleezbut you'd need to have (def bla° blao)
11:12clgvohpauleez: but sadly all the builtin stuff has the "o" suffix.
11:12ohpauleezit's like coffee, tea, and beer
11:12ohpauleezthe first time you have it, you think, "This is stupid, it's so bitter. I'm never going to drink this again"
11:12ohpauleezbut you drink it three, four… five times more
11:13scriptorcasion: might've just been someone's personal preference
11:13ohpauleezand bam, you start enjoying oit
11:13ohpauleezit
11:13casionohpauleez: nah, some people always hate it
11:13clgvit really reads strange "all-connected-to-allo". probably a good name but why should all be connected to allo? ;)
11:13casionScriptor: seems strange to me, I'd imagine #() would be far more readable and obvious
11:13casionand silghtly faster?
11:14ohpauleezcasion: My example is indeed leaky (no pun intended)
11:16scriptorcasion: huh, it's apparently in the clojure book
11:16scriptorhttp://books.google.com/books?id=nZTvSa4KqfQC&amp;pg=PA34&amp;lpg=PA34&amp;dq=(zipmap+%5B:x+:y+:z%5D+(repeatedly+(partial+rand-int+10)))&amp;source=bl&amp;ots=0V-nGO3Qtd&amp;sig=0-K6I38Jd4yuUuekDA3P9dzB77w&amp;hl=en&amp;sa=X&amp;ei=xBkpUN6kDZS36QGq3oHQBg&amp;ved=0CFwQ6AEwAQ#v=onepage&amp;q=(zipmap%20%5B%3Ax%20%3Ay%20%3Az%5D%20(repeatedly%20(partial%20rand-int%2010)))&amp;f=false
11:17casionScriptor: how odd, I learned that #() would make more sense from that book lol
11:18ohpauleezthis question came up a few days ago too
11:18ohpauleeznow I know where it's coming from
11:18ohpauleezhaha
11:19scriptorcemerick: any reason why partial is preferred instead of #() in this? (zipmap [:x :y :z] (repeatedly #(rand-int 10))) (page 34 from yo' book)
11:19ohpauleezsomeone was on a partial kick, the only reason
11:19casionohpauleez: 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:19ohpauleez(completely a guess, no data to support that)
11:20casion117 notes lol
11:20casionI'm assuming I'll figure most of them out on my own
11:20scriptoryea, depending on your background I guess some people prefer more alphanumeric characters
11:20ohpauleezbut 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:20ohpauleezor more concise or more readable
11:21casionI'd still think that even (fn [] (rand-int 10)) would be more readable
11:21scriptorcasion: I agree, it's basically a thunk
11:21ohpauleez#(rand-int 10) for me personally
11:21ohpauleezbut really only in the case where I'm using a hof
11:22casionI prefer #() as well
11:22casionwhen I see partial, I assume there's other args coming in somewhere
11:22scriptorexactly
11:22ohpauleezsame
11:23maaclI 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:23nbeloglazovFrustrating think with partial (for me) is that it's too long. It's shorter to use #( ).
11:23ro_stohpauleez: the remote macro is expanding to the wrong namespace for some reason
11:23casionthe partial bit isn't listed in the errata
11:23ckirkendallro_st: I pushed out alpha2 of enfocus. I would love if you could give it a spin.
11:23ohpauleezro_st: There's a .client. in there?
11:23ro_styes!
11:24ro_stckirkendall: oooh, what's new?
11:24ohpauleezckirkendall: I will also do the same on all of my apps
11:24ro_stckirkendall: i'm busy whacking together an example of enfocus and shoreleave's pubsub and remotes right now
11:24ckirkendallro_st: not much from the snapshot.
11:24ohpauleezro_st: I think that's an old jar problem too, but let me check
11:24ckirkendallro_st: sweet!
11:26ohpauleezro_st: An old jar - https://github.com/shoreleave/shoreleave-remote/commit/572265c85aaf0aea591724ff59d3c07087120c68
11:28ohpauleezro_st: I redeployed the jar just to be safe
11:28ro_sta deps run should fix it?
11:28ro_stwhat version of remotes?
11:28ro_st0.2.1 or 0.2.2-SNAPSHOT?
11:28clgvis that safe to use ##:keyword.with.dots
11:28ohpauleez0.2.2-SNAPSHOT
11:28clgv,:keyword.with.dots
11:28clojurebot:keyword.with.dots
11:29ro_stso close
11:29ro_stbuild build build!
11:29ohpauleez,:you(can)also.do-this
11:29clojurebot:you
11:29ohpauleezwhoa, fixed?
11:29ro_sti was on 0.2.1
11:30ohpauleezro_st: I seriously can't thank you enough for pulling something together
11:30ohpauleezand working through all the pains of sl
11:31nbeloglazovmaacl: did you try (. this fieldName) inside proxy method?
11:31ro_stweird. getting a npe in goog.string.urlDecode deep inside the csrf stuff
11:32ro_stmy pleasure. this is fun
11:32clgv&:keyword.with.dots
11:32lazybot⇒ :keyword.with.dots
11:32hyPiRionEven better is probably the %-symbol
11:32maaclnbeloglazov: Nope, but I will now
11:32ohpauleezro_st: Weird, I've never seen that. Is this with or without CSRF middleware?
11:32hyPiRion,'(:%%name)
11:32clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Invalid token: :>
11:33ro_stboth
11:33dgrnbrgHello 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:33dgrnbrgOr do I need to say something like "lein with-my-stuff task args" and make a with-my-stuff plugin?
11:34clojure-newcomerhmmm, 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:35nDuffdgrnbrg: Hrm. If you don't get a response here, you might try #leiningen
11:35ro_stclojure-newcomer: stay posted. got some nice sample code on the way
11:36dgrnbrgnDuff: thanks
11:36clojure-newcomerro-st: a fellow cljs-binding user ?
11:36ro_stnaw. a demo of enfocus, shoreleave-pubsub and shoreleave-remote and clsbuild's crossovers
11:37clojure-newcomerro_st: are you suggesting it all be so awesome I will just want to use that instead ? :-)
11:37ro_sti might be
11:37ro_st-grin-
11:37ckirkendall:)
11:37clojure-newcomerro_st: god knows I need something to make me more productive :-( really struggling with this
11:38clojure-newcomeris there an eta ? :-)
11:38gtrakweavejester: 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:38ro_stas soon as i get past a null bug
11:38ckirkendallclojure-newcomer: what exactly are you strugling with
11:39clojure-newcomerckirkendall: my cljs-binding template (html in this case) will only successfully bind with elements defined in main.cljs
11:39clojure-newcomerit seems I am unable to split functionality out to separate files and still bind
11:39clojure-newcomereven if I reference by namespace in my template
11:39clojure-newcomerI think there is magic going on under the hood which I don't understand
11:40clojure-newcomerprobably noir-cljs governing the magic
11:41weavejestergtrak: That's probably right… it's likely a bug. Custom web.xml files are quite rare.
11:42gtrakyea... I'm doing some wacky stuff
11:44ckirkendallclojure-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:45clojure-newcomerckirkendall: will do, thanks for the pointer
11:45ro_stweavejester! thank you for compojure.
11:45ckirkendallits a very simple app that uses fetch and noir in backend and enfocus on the front
11:45weavejesterro_st: You're welcome :)
11:45nbeloglazovWhere 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:46weavejesternbeloglazov: Lein-Ring puts them in WEB-INF/classes so that they can be referenced by clojure.java.io/resource etc.
11:47weavejesternbeloglazov: It's not ideal, but it's better than having two places for resources
11:48nbeloglazovweavejester: thank you
12:08ro_stnot working right now, but it's still worth reading the code: https://github.com/robert-stuttaford/demo-enfocus-pubsub-remote/
12:09ro_stif anyone is keen, i'm wide open to Issues and pull requests and whatnot
12:09ro_stbe nice to have a go-to boilerplate for new folks interested in clj+cljs apps
12:10ckirkendallro_st: will take a look
12:10ro_stnice :-)
12:10ro_stgotta go. meatspace calls
12:13clojure-newcomerro_st: nice one
12:14clojure-newcomerwill have a look soon as I make some progress with this :-)
12:17cemerickcasion, Scriptor: as you suspected, totally a personal readability preference
12:30technomancydgrnbrg: project middleware can give you what you're looking for
12:31technomancydgrnbrg: 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:32clojure-newcomerhmm, 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:45ckirkendallclojure-newcomer: can you put together a gist of main and some.
12:56clojure-newcomerckirkendall: here is the link: http://pastebin.com/wLXtScRu
12:57clojure-newcomerckirkendall: 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:59clojure-newcomerckirkendall: haha, that was the problem
13:00ckirkendall:)
13:00clojure-newcomerckirkendall: 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:00ckirkendallclojure-newcomer: at 3 in the morning everyone is.
13:01clojure-newcomerckirkendall: right better go make up for hours of lost productivity now cya
13:29brainproxyin a macro I need to so something like ... #'templates/~template
13:29brainproxybut that's not the right way to put #'templates/ and ~template togethre
13:29cgraytechnomancy: 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:30ckirkendallbrainproxy: ~(symbol (str "templates/" (name templates)))
13:31raek,(namespace (str "templates/" "foo"))
13:31clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Named>
13:31raek,(namespace (symbol (str "templates/" "foo")))
13:31clojurebot"templates"
13:31brainproxyckirkendall: thanks
13:31raekhuh, I didn't know that the symbol function parsed its argument
13:32raekI would write (symbol "templates" "foo")
13:32raek,(namespace (symbol "templates" "foo"))
13:32clojurebot"templates"
13:32ckirkendall,(name (symbol "templates" "foo"))
13:32clojurebot"foo"
13:33abevhow to regular expr in cljs
13:33ckirkendall,(namespace (symbol "templates" "foo"))
13:33clojurebot"templates"
13:33ckirkendallraek: nice
13:36abevdetailed documentation for clojurescript where it is available?
13:58loliveiracould somebody help me with enlive?
13:59emezeske~anyone
13:59clojurebotJust 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:59loliveiraok
14:07ckirkendallloliveira: what issue are you struggling with.
14:09loliveirai'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:15loliveirackirkendall: i'am getting different results from enlive and jquery.
14:20ckirkendallloliveira: can you give me the selector
14:20arrdemis there a function for getting the entire inheritance tree for an object?
14:20Qerub,(supers String)
14:21clojurebot#{java.lang.Object java.lang.CharSequence java.lang.Comparable java.io.Serializable}
14:21amalloy&(ancestors java.util.ArrayList)
14:21lazybot⇒ #{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:21ckirkendallloliveira: sorry just saw the gist
14:21ckirkendallit seems jquery is wrong in this case
14:21ckirkendallyou are refrencing and id so not sure how it could return more than one object.
14:22hiredmanI imagine jquery returns a single object, with some kind of .each that walks over the children
14:23ckirkendallhiredman: that would make sense
14:23hiredmanand it would explain the confusion
14:23arrdemamalloy Qerub: ancestors supports (derive) while supers is just Java inheritance?
14:24amalloywell yes, but also ancestors returns interfaces
14:24ckirkendallloliveira: can you post the html you are trying to match
14:25Gnosis-how can I use UTF-8 for converting between bytes sequences and character sequences?
14:25arrdemamalloy: thanks
14:28loliveirackirkendall: 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:29chouserGnosis-: & (String. (.getBytes "Hello" "UTF-8") "UTF-8")
14:29chouser,(String. (.getBytes "Hello" "UTF-8") "UTF-8")
14:29clojurebot"Hello"
14:30loliveirackirkendall: do you know what do i have to do to get span#items_noticias's children?
14:30Gnosis-chouser: thanks! so does .getBytes return a byte array?
14:31S11001001Gnosis-: what dev environment are you using?
14:32Gnosis-jvm
14:35ckirkendall#items_noticias > *
14:36S11001001Gnosis-: on top of that
14:36ckirkendallloliveira: you don't need the span because the id is unique
14:38loliveirackirkendall: didn't work: (enlive/select content [:div.column00 :span#items_noticia :> :*])))
14:40scriptorckirkendall: a lot of browsers don't enforce the uniqueness
14:41loliveiradidn't work too: (enlive/select content [:div.column00 :#items_noticia :> :*])))
14:57Gnosis-S11001001: on top of the jvm? I use a repl!
14:57DaoWenwhat exactly does vec do?
14:57DaoWenI 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:58S11001001vec makes clojure.core hilarious
14:58xeqi&(doc vec)
14:58lazybot⇒ "([coll]); Creates a new vector containing the contents of coll."
14:58amalloyS11001001: ?
14:58DaoWenit looks like it takes a collection, turns it into an *array*, and then *lazily* turns that array into a vector
14:59amalloyDaoWen: no, it copies to a new vector. kinda weird, but there's at least a justification, if not a reason
14:59DaoWen(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:59S11001001,(let [o (to-array [1,2,3]) v (vec o)] [(seq v) (do (aset o 0 42) (seq v))])
14:59clojurebot[(42 2 3) (42 2 3)]
14:59amalloyoh ouch
15:00Cr8oh what
15:00Cr8the vector is backed by the array?
15:00DaoWenwhat just happened?
15:00S11001001I think next release will have docstring update to mention this
15:00ckirkendallloliveira: take the :* off the end
15:00S11001001Cr8: truth
15:00Cr8gnarly
15:00ckirkendallif enlive implemented the selector syntax correctly :> means children
15:01Gnosis-S11001001: it doesn't seem like to-array can handle types other than Object...
15:01ckirkendallIf not it is probably a bug
15:01S11001001Gnosis-: there are other funs for that
15:01DaoWenI think The Joy of Clojure mentioned that, but in the context of seq, not vec
15:02DaoWenit makes sense for seq, but that's a bit weird since vec is supposed to return a copy...
15:03S11001001actually the difference is that the seq case is referentially transparent with respect to accesses to the seq itself
15:03ckirkendallloliveira: 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:03DaoWenamalloy: what was the justification you were talking about? (or did you already mention it and I missed it?)
15:03S11001001either the 3rd element of a seq will be 42 or it will be 84, or whatever, but it won't change
15:04amalloyDaoWen: (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:04amalloyso you can imagine wanting this behavior from vec, although in most cases you don't
15:06loliveirackirkendal: 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:06loliveira2012-08-13 16:03:01,869 TRACE crawler.migrations: loading namespace: crawler.models.crawlers.correiobraziliense.rss_politica from fs
15:06loliveira((Exception in thread "main" java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
15:06DaoWenamalloy: that makes sense. you need to have a way to clean up after subvec.
15:06amalloyDaoWen: yes, but you already have one anyway: (vec (seq the-subvec))
15:07DaoWengood point.
15:07DaoWenso, it's kind of pointless then?
15:07amalloyso, i dunno. in summary: vec is kinda silly
15:07loliveirackirkendall: i will report it as a bug. thanks soo much.
15:07amalloysome of the code in there is definitely very old, and probably from rich's original draft ideas - not everything was brilliant
15:08technomancyamalloy: heresy!
15:09ckirkendallloliveira: try this: #id :> (any-node)
15:09DaoWenok, thanks for the explanation
15:09ckirkendallloliveira: enlive syntax requires a selector after the :>
15:10technomancyPSA: .substring is subject to the same memory leak issues as subvec
15:10technomancyso watch out
15:10amalloytechnomancy: maybe rich's ideas were in fact all brilliant, but occasionally his evil twin with a goatee snuck in and coded something
15:11pjstadigtechnomancy: huh?
15:11pjstadig.substring says it return a 'new' string
15:11amalloypjstadig: it does, backed by the old array
15:11pjstadigbut maybe that's just playing with terms
15:13ckirkendallloliveira: sorry its not any-node its just (any)
15:14kennethhey there -- is there a way to get the path to the project root with clojure / lein?
15:14technomancykenneth: from what context?
15:14technomancylike in a plugin or in the project code itself?
15:14kennethin the code itself
15:15technomancykenneth: if the code is launched by Leiningen itself then (System/getProperty "user.dir") will do the trick
15:15technomancybut that might not work from an IDE, even one that supports Leiningen
15:16technomancyin 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:21arrdemdoes Clojure have a good "dispatch on keyword" function or do I need to go dig out the dlambda macro?
15:21technomancy(comp :mykey first list)
15:21ro_stohpauleez: here for a minute. any luck?
15:21ohpauleezI am
15:21technomancyassuming you want a keyword from the first arg, which is a map
15:21ohpauleezro_st: ^
15:21ro_st-curious-
15:22loliveirackirkendall: i tried (enlive/select content [:#items_noticia :> enlive/any]))) and it returned ()
15:22antares_arrdem: what you are looking for is multimethods
15:23loliveirackirkendall: (enlive/select content [:#items_noticia :> enlive/any-node]))) returned ("\n ")
15:23arrdemantares_: really? defmulti's the best choice here? meh...
15:23antares_arrdem: how exactly is it meh?
15:24loliveirackirkendall: i can't call any-node (any-node) or any (any) they aren't functions.
15:24amalloyit sounds like arrdem probably wants a lambda that acts like an object, dispatching on its first arg as a "message"?
15:24antares_arrdem: it will dispatch on any function you want. Use keywords equality or even keywords as functions. What else do you need?
15:24arrdemjust more verbose than I feel is required. nothing wrong with it ho.
15:24amalloyi wouldn't recommend a defmulti for a lambda-like thing
15:24arrdem*tho
15:24amalloy(though, in generally, i wouldn't recommend using a lambda to fake an object either)
15:24arrdemyeah. what amalloy said.
15:24technomancydefmulti complects def and multi =(
15:25arrdemI think that (case) will do what I want... brb trying science
15:25technomancycore.match maybe
15:25arrdemyup. case'll do it
15:26arrdem,(let [a :foo] (case a :foo (println "YES")))
15:26clojurebotYES
15:32ckirkendallloliveira: I can't think of a way around it if :> :* doesn't work
15:33arrdemamalloy: what is this "faking an object" of which you speak?
15:33amalloythis discussion gives me the impression enlive is some kind of emoticon-oriented library
15:34amalloy(fn [message & args] (case message :foo (...) :bar (...))) is the classic scheme/whatever way to create something that's basically an object
15:35amalloythat you invoke "methods" on by calling (the-object :foo whatever)
15:35arrdemah. yes I remember this from SIoCP
15:36amalloyclojure would generally encourage you to just define public foo and bar functions, which take in whatever non-function data your lambda was capturing
15:42ckirkendallloliveira: you might have luck on the enlive user group https://groups.google.com/forum/?fromgroups#!forum/enlive-clj
15:42loliveirackirkendall: thank you!
15:42loliveirackirkendall: have a nice day. =)
15:51Gnosis-if I want a lazy seq of the bytes in a file, is there a standard way to do this?
15:57arrdemGnosis-: 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:58treehugin clojure, is there a way two write float literals? i.e. rather than writing (float 3.5)
15:59amalloyGnosis-: you were asking about converting bytes to characters earlier. are you sure you want bytes, not characters?
15:59Gnosis-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:59amalloy(also, monads and continuations are both totally bonkers for reading from a file)
16:00Gnosis-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:00arrdemamalloy: yes... but if you __really__ wanted to only ever read K bytes of a file at a time
16:02amalloystill total nonsense, arrdem
16:02emezeskeGnosis-: Monads are a general concept, you can implement them in any language you want
16:02Gnosis-emezeske: ah, okay. Like I said, I don't understand monads at all...
16:03emezeskeGnosis-: I agree with amalloy on monads being bonkers for what you're trying to do :)
16:03amalloyGnosis-: see clojure.java.io/input-stream and java.io.InputStream/read
16:04arrdemamalloy: 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:05amalloyin 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:16dgrnbrgI having terrible problems with a :use-ed namespace
16:16dgrnbrgI know use is bad, but I'd really like to understand this issue
16:16dgrnbrgI am running clojure in a jvm with all kinds of weird stuff, using a patched leiningen
16:17dgrnbrgand i have a namespace that adapts a bunch of legacy java code into clojure
16:17dgrnbrgand when I require that namespace, everything works
16:17dgrnbrgand when I use that namespace, everything still works
16:17dgrnbrgexcept that when I use it, the jvm never exits
16:17dgrnbrgthe code has the exact same functionality in both cases, except that the require-based one has the namespace prefixes
16:18dgrnbrgbut for some reason it causes the jvm to never exit when I use the namespace, but not when I require it.
16:19emezeskePerhaps when you :use it, it brings a name into your namespace that shadows a clojure.core name?
16:20emezeskeAnd then maybe you e.g. call some function, expecting the clojure.core implementation, and get the implementation from this other namespace
16:20emezeskeLeading to unexpected behavior
16:22Raynesemezeske: http://dev.clojure.org/jira/browse/CLJS-355
16:22Raynesemezeske: Other than that (which is unrelated to lein-cljsbuild), node works fine with lein-cljsbuild.
16:23emezeskeRaynes: Awesome!
16:23RaynesEvery time I try to use cljs targeting node, I end up finding a disappointingly debilitating bug. It is depressing.
16:23emezeskeYeah... I guess not that many people are doing it?
16:23RaynesThat surprises me.
16:23RaynesThe survey seemed to indicate otherwise.
16:23dgrnbrgemezeske: i don't get any shadowing warnings
16:24lynaghkIs there any way to check if any of the vars destructured within a let are nil?
16:24dgrnbrgi am afraid that perhaps :use causes symbols that I use in def forms to be loaded, which triggers a poorly written static initializer
16:24Raynesemezeske: 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:24Raynesemezeske: I don't think there is another good option for Clojure + fast startup speed.
16:24dgrnbrgbut it seems like :use wouldn't cause different behavior w/ the classloader than :require
16:24emezeskeRaynes: Yeah, it definitely has startup speed.
16:24RaynesIn fact, it seemed to be one of the selling points Rich made when he announced cljs.
16:24drewrRaynes: I agree; that was my main hope for cljs
16:24RaynesA story for command-line scripting with Clojure.
16:25drewrI have hopes for cljs-lua
16:25emezeskedgrnbrg: What does the classloader have to do with anything?
16:25amalloylynaghk: eh?
16:25lynaghkamalloy: 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:26lynaghke.g., (subscribe! {{a :a} :stuff} ...)
16:26dgrnbrgemezeske: 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:26dgrnbrgsince it's possible to put code into a static initilaizer
16:26lynaghkand then whenever someone publishes a message with content like {:stuff {:a 1 :b 2} :foo 5}, that fn will get called.
16:26djanatyn...is cKanren related to Clojure?
16:27emezeskedgrnbrg: 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:27RaynesNope.
16:27emezeskedgrnbrg: Good luck tracking down the problem!
16:27lynaghkamalloy: I was hoping to leverage core.match to do this, but it'll match all maps and just destructure their keys to nil.
16:27dgrnbrgemezeske: do you know the details of their difference?
16:28dgrnbrgbecause somehow that difference is the source of my bug
16:28dgrnbrgand i'm adapting millions of lines of legacy java, and i've seen some iffy things in static initializers already ;)
16:29dnolen_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:29Raynesdnolen_: Yeah. :(
16:29amalloylynaghk: you could probably start by calling ##(doc destructure) on the destructuring form
16:29lazybot⇒ "([bindings]); "
16:29Raynesdnolen_: 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:30dnolen_Raynes: yeah just saw it but I'd have to take a closer look.
16:30emezeskedgrnbrg: 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:30lynaghkamalloy: yeah, I was looking at that.
16:30dnolen_djanatyn: cKanren is a variant of miniKanren which is a Scheme system. core.logic is an implementation of miniKanren / cKanren.
16:30RaynesIf it is what we think it is, it's a pretty nasty one that I'm surprised no one else has run into.
16:31amalloyand 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:32hiredmanlynaghk: seems like a large departure from typical pub/sub messagebus stuff
16:32dgrnbrgemezeske: i know that's the party line, but it's wrong :)
16:33dgrnbrgbecause it works if i :require and :use the namespace
16:33dgrnbrgsorory, :require and :refer
16:33dgrnbrgbut not if i :use
16:33hiredmanI 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:33dnolen_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:33lynaghkhiredman: 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:34Raynesdnolen_: No hurry. Just wanted to make sure that it's on your radar
16:34hiredmanlynaghk: why not just use postal.js?
16:34dgrnbrgWhat exactly is the difference between :use and :require/:refer?
16:34lynaghkhiredman: aside from performance, can you think of any disadvantages?
16:34djanatynI'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:35emezeskedgrnbrg: I think you need to ask the source code: https://github.com/richhickey/clojure/blob/a1eff35124b923ef8539a35e7a292813ba54a0e0/src/clj/clojure/core.clj#L4859
16:35hiredmanlynaghk: I think having N queues with different content is simpler than picking apart N different message types from one queue
16:35djanatynWould it be better to use Clojure, or Clojurescript?
16:35TimMcdgrnbrg: Have you tried using a VM inspector to find out what threads are still active?
16:35djanatynClojurescript, embedded in a browser, would be ideal, but I'm not sure how mature it is.
16:35hiredmanlynaghk: sorry, I sort of assumed you are thinking about this from a clojurescript prospective
16:35hiredmanwin 15
16:35lynaghkhiredman: yeah, I am = )
16:35djanatynI've already got a working Clojure setup. Would it be possible to make a game in 48 hours with either of those?
16:35djanatynAnd if I use clojurescript, would I be using regular JS game libraries, pure canvas, or clojurescript game libraries?
16:36dnolen_djanatyn: do you have a lot of Clojure experience?
16:36lynaghkhiredman: So are you against any kind of wildcard matching in pubsub?
16:36hiredmanlynaghk: against is a strong word
16:36djanatyndnolen_: no, but I have lots of haskell experience and some experience with common lisp
16:36djanatynso learning clojure hasn't been very difficult
16:36lynaghkhiredman: 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:37hiredmanlynaghk: I think wild cards over queues are simpler than writing patterns that and up and match more than one message type
16:38dnolen_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:38lynaghkhiredman: 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:38dgrnbrgTimMc: i'll give that a shot
16:39yoklovdjanatyn: game in 48 hours in clojure is doable, you doing a jam?
16:39hiredman*shrug*
16:39yoklovclojurescript also.
16:39djanatynyoklov: yep! ludum dare.
16:40yoklovsweet!
16:40lynaghkhiredman: 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:42nbeloglazov$(doc ..)
16:42nbeloglazov,(doc ..)
16:42clojurebot"([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:42djanatynhmm. cljs looks cool, but I would really like to use SLIME, if possible
16:43yoklovdjanatyn: 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:44yoklovclojure's more fun than most other languages though, so you should go for it.
16:44solussdso, 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:46McMartinNo, they're raw objects.
16:47McMartinSo are records, but records also do the right thing for you with the obnoxious boilerplate functions.
16:47amalloyMcMartin: are you talking about deftype? solussd was asking about structs
16:48solussdI'm talking about structs, created with create-struct, or defined with defstruct
16:48solussd(defstruct person :name :age) (struct person "solussd" 104)
16:49dnolen_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:50solussdyeah, 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:52lynaghkdnolen_: 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:53dnolen_lynaghk: hugod (I think?) has brought this up before. definitely something I'm interested in looking at when I have time.
16:54lynaghkdnolen_: okay, cool.
16:55lynaghkdnolen_: you would be open to a contribution on this topic, then?
16:55dnolen_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:55dnolen_lynaghk: yes.
16:55dnolen_lynaghk: I think there may even be ticket for it.
16:55dnolen_existing ticket
16:58roma1n_pHi 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:02lynaghkroma1n_p: should work fine if its a valid CSS class.
17:02lynaghkdnolen_: it looks like there's an existing patch: http://dev.clojure.org/jira/browse/MATCH-52
17:06dnolen_lynaghk: oh heh, JIRA is so annoying. I should go over Jason Jackson
17:06roma1n_plynaghk: I put a snippet at http://pastebin.com/sT44yYvk
17:06dnolen_'s patches.
17:07roma1n_plynaghk: I suppose "deviceText" is a valid CSS class, although I know squat about CSS :)
17:07dnolen_lynaghk: will look at it soon, thanks for bringing it up
17:07lynaghkdnolen_: 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:08lynaghkroma1n_p: yeah, deviceText is a fine CSS class. Are you using c2 0.2.1-SNAPSHOT?
17:08roma1n_plynaghk: nope, 0.2.1
17:08lynaghkroma1n_p: also, just FYI, you don't need to put numbers into quotes in the attribute vals.
17:09dnolen_lynaghk: if it looks ok, I'll cut another alpha to help you along.
17:09lynaghkdnolen_: I owe you some beers.
17:09roma1n_plynaghk: OK, thanks for the attribute infos! Should I move to -SNAPSHOT then?
17:09dnolen_lynaghk: one thing that would help me out, just verifying that the patch works as expected for you.
17:09lynaghkroma1n_p: there is no 0.2.1 yet, just the snapshot.
17:10roma1n_plynaghk: so I was using snapshots already I suppose...?
17:10lynaghkdnolen_: 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:10dnolen_lynaghk: thx
17:10lynaghkroma1n_p: what's in your project.clj?
17:11roma1n_plynaghk: sorry I got confused, I was on 0.2.0 (0.2.1 was the lein-cljsbuild version :P )
17:11lynaghkroma1n_p: ah. Give 0.2.1-SNAPSHOT a try; it uses the latest Singult snapshot too
17:13lynaghkroma1n_p: also re: your c2 issue on the outdated examples, aperiodic is updating them here: https://github.com/aperiodic/c2-cljs-examples
17:14roma1n_plynaghk: no, 0.2.1-SNAPSHOT did not change results unfortunately
17:14lynaghkroma1n_p: you might need to "lein cljsbuild clean" first.
17:17roma1n_plynaghk: still no luck after a cljsbuild. Would you like a minimal test case?
17:17lynaghkroma1n_p: yeah, that + an issue on the Singult repo would be awesome
17:17lynaghkroma1n_p: thanks for reporting this.
17:17roma1n_plynaghk: thanks for C2 :)
17:18lynaghkroma1n_p: waaaiiiitt
17:18lynaghkwhat's alias?
17:18lynaghkin your example. The attribute map is the third item in the hiccup vector. It needs to be the second.
17:19roma1n_plynaghk: yup, that was it
17:19roma1n_plynaghk: /me embarassed
17:19lynaghkphew. I should have noticed that earlier. I need a sandwich.
17:19roma1n_plynaghk: thanks!
17:20lynaghkroma1n_p: also, you can use the shortcut dot and hash on the element symbol for class and id
17:20lynaghk[:text.deviceText#my-text ...]
17:20roma1n_plynaghk: ah, good to know
17:20lynaghkYou typically only need to put the class in the attribute map if you're calculating it dynamically or some such.
17:29gfrederickswasn't there a some-pred in core?
17:29sandbox`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:31Guest13977Per "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:31aperiodicgfredericks: you mean some-fn & every-pred?
17:32rod__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:33rod__ooops, sorry, got my clojure & compojure channels muddled up! :)
17:34RaynesIt's fine to ask Compojure questions here too.
17:35gfredericksaperiodic: yep that was it; lazybot didn't find it for some reason :/
17:35rod__ah cool, well if anyone has any pointers i'm all ears.
17:35gfredericks$findfn nil? true? false? true true
17:35lazybot[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:36gfredericksoh nm I was abusing the bot
17:36amalloygfredericks: i don't think there's any args you could pass to findfn that would make it return some-fn or every-pred
17:36gfredericksamalloy: right
17:48technomancysandbox`: deftest results in a defn behind the scenes
17:48technomancyso just call (my-deftest-name)
17:48technomancyfact
17:50jycI 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:50xeqirod__: sounds like you have a bad jar in you're ~/.m2. I'd recommend rm -r ~/.m2/repository and rerunning lein deps
17:50rod__ok - thanks both - will nuke it and try again.
17:55djanatynhmm. how do I use or over a list of boolen values?
17:55djanatynI can't use 'reduce, I can't use 'apply, and (or [false false true]) just returns [false false true]
17:56amalloy&(doc some)
17:56lazybot⇒ "([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:56nbeloglazov,(some identity [false false true])
17:56clojurebottrue
17:56djanatynamalloy: thank you :)
18:02TimMcGuest13977: That should be ', not `.
18:03TimMc,(macroexpand-1 '(import '(java.io File)))
18:03clojurebot(do (clojure.core/import* "java.io.File"))
18:03TimMc,(macroexpand-1 '(import `(java.io File)))
18:03clojurebot(do (clojure.core/import* "clojure.core/seq.(clojure.core/concat (clojure.core/list (quote java.io)) (clojure.core/list (quote sandbox/File)))"))
18:14djanatynman, core.logic is really cool!
18:18dnolen_djanatyn: it's fun stuff
18:18McMartinOh, fun indeed
18:39Cr8wasn'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:41Raynes&(get-in {:a {:b {:c 1}}} [:a :b :c])
18:41lazybot⇒ 1
18:41djanatynare there any good libraries for drawing graphs?
18:41brainproxytrying to defn inside a defmacro and getting errors like "No matching ctor found for class..."
18:41djanatynI wanted to try the travelling salesman problem with a little graphic
18:41brainproxyhaving a hard time tracking down what's causing the problem...
18:43Raynesdjanatyn: https://github.com/pallix/lacij Maybe?
18:44Raynesbrainproxy: Could you post the code and the full trace?
18:44djanatynthat's perfect! thanks. you guys are really helpful.
18:44Raynesdjanatyn: I'll send you a bill
18:45amalloy$findfn {:a {:b {:c 1}}} [:a :b :c] 1 ;; Cr8
18:45lazybot[clojure.core/get-in]
18:45Raynesamalloy: ur so cool and trendy
18:45brainproxyRaynes: this is the main part of it: http://cljbin.com/paste/50298280e4b013f51ca863ff
18:45Cr8<#
18:45Cr8*<3
18:45brainproxyignore the trace cljbin gives
18:45RaynesI refuse pastes on cljbin.
18:46gf3Raynes: WAT
18:46RaynesIt is not the right religion.
18:46RaynesBahahaha
18:46gf3OMG RUDE FACE
18:46RaynesYou haven't said a word in like a month.
18:46brainproxylolz, okay, what to use instead
18:46RaynesAnd the first time I say something about cljbin.
18:46Raynesbrainproxy: I was kidding. it's a running joke between gf3 and I because we both have a Clojure pastebin.
18:46gf3brainproxy: Raynes has a competing pastebin
18:47gtrakit even uses clojail
18:47brainproxyoh, right, now I remember something about that
18:48brainproxyanyway, it's weird, in the defmacro if I use def instead of defn, e.g. (def ~name ~xf)
18:49brainproxythen all is well
18:49brainproxybut 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:53Raynesbrainproxy: What does xf look like?
18:53RaynesShow me what the output of xform looks like.
18:54brainproxyxform returns a function
18:54brainproxyxf is that function
18:55brainproxymore specifically, xform returns the function returned by enlive's snippet* macro
18:55RaynesA function object or a form that would create a function when executed?
18:56RaynesMacros work with code -- things that can be printed.
18:56RaynesYou can't embed a function object in a macro like that.
18:56Raynesprinted and read back*
18:57Raynesbrainproxy: 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:57RaynesAlso, be careful when I talk about macros.
18:57RaynesI have a knack at not understanding what people are trying to do at all.
19:00brainproxyRaynes: it's okay, will review
19:00brainproxythanks for taking a look
19:00arrdemokay. 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:01hiredmannope
19:01arrdemgood. just what I expected to hear.
19:01Gnosis-is there a way to change the output base that prn uses for numbers?
19:01Gnosis-i.e., print numbers as 0x1234, etc.
19:03emezeskeGnosis-: If you can use something other than prn, format might be good: http://clojuredocs.org/clojure_core/clojure.core/format
19:04amalloyemezeske: i imagine he wants to print a big ol' data structure that contains some numbers, not just a single number
19:04Gnosis-right
19:05Cr8you could walk it and transform the numbers to hex before printing
19:05RaynesYou can redefine the method that prn uses to print numbers.
19:05Raynes*shrug*
19:05Gnosis-hmm, okay...
19:05amalloywarning though, Raynes's ideas are always bad
19:05Gnosis-Raynes: it would be cool if prn read metadata to see what base to use for printing a number :)
19:06amalloyGnosis-: numbers don't have metadata
19:06Gnosis-oh :(
19:06Raynesamalloy: Is this idea bad?
19:06RaynesI mean, we've done similar things before.
19:06RaynesMan, there I go using clojail as an example of 'good' again.
19:06amalloyit's pretty bad, yeah, because that's a global behavior you're changing
19:07RaynesWell, it really depends on what he is doing.
19:07Cr8,(postwalk (fn [i] (if (number? i) (format "0x%x" i) i)) {:a :b :c {:d 1 :e 2 :c {:a 4}}})
19:07emezeskeGnosis-: Out of sheer curiousity, why does the base matter for you? Usually I think of pr as a serializer for read-string
19:07clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: postwalk in this context, compiling:(NO_SOURCE_PATH:0)>
19:07Cr8,(clojure.walk/postwalk (fn [i] (if (number? i) (format "0x%x" i) i)) {:a :b :c {:d 1 :e 2 :c {:a 4}}})
19:07clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.walk>
19:07Cr8bah
19:07Raynesamalloy: He could always wrap his numbers in a new type and print them differently.
19:07Cr8output is: {:a :b, :c {:c {:a "0x4"}, :d "0x1", :e "0x2"}}
19:08emezeskeCr8: Those aren't numbers, though, those are strings with representations of numbers
19:08Cr8true
19:08Gnosis-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:09Gnosis-also vectors
19:09Gnosis-Cr8: thanks
19:09Cr8could wrap it in a class that prn's as hex if you really don't want the quotes
19:11Cr8actually not really with prn, you couldn't as it tries to output something reader friendly
19:13brainproxyRaynes: you were right ... when I stopped trying to "embed" the fn object it worked
19:13RaynesThat's a fiorst.
19:13Raynesfirst, even
19:31cemerickIs there any way to get the version of ClojureScript at runtime, similar to *clojure-version*?
19:33cemerickhrm, I guess git rev numbers would be all there is…
19:51FrozenlockClojurescript is hurting my puny little head. Any tutorial for it?
20:49emezeskeFrozenlock: How far have you gotten so far in cljs? Do you have a build environment set up?
20:49Frozenlockyes and no...
20:50FrozenlockI can compile (and autocompile at each modification), autoreload my webpage... but I don't have a working repl :(
20:50emezeskeAre you using lein-cljsbuild, or something else?
20:50Frozenlocklein-cljsbuild
20:51emezeskeWhich repl are you trying to get set up? repl-listen?
20:51FrozenlockYes.
20:51Frozenlock:repl-listen-port 9000
20:51Frozenlock :repl-launch-commands
20:51Frozenlock {"my-launch" ["chromium-browser" "" "http://localhost:8888&quot;]}
20:51FrozenlockAnd then: lein trampoline cljsbuild repl-launch my-launch
20:52emezeskeWhat's that empty arg between chromium-browser and http...?
20:52Frozenlockit was "-jconsole" for firefox
20:52emezeskeYou should probably remove that altogether
20:52emezeskeHave you added the little repl-related code segment to your cljs code?
20:53FrozenlockI will go with "no" :P
20:53emezeskeOkay, that's the step you're missing I think
20:53emezeskeTake a look at this:
20:53emezeskehttps://github.com/emezeske/lein-cljsbuild/blob/master/example-projects/advanced/src-cljs/example/repl.cljs
20:54emezeskeYour clojurescript code has to explicitly connect to the REPL session
20:54emezeskeWhen you run "repl-launch", the clojurescript repl listens on localhost:9000
20:54emezeskeThen once your clojurescript is loaded, it needs to connect to that port to receive code to execute in the browser
20:56FrozenlockCan I still keep my port 8888 for the server? server (8888) --> browser | browser (9000) ---> REPL?
20:56emezeskeYes, the port your http server listens on is totally orthogonal to the repl stuff
20:58FrozenlockI 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:01wmealing_1now if only someone could hook up http://www.ymacs.org/demo/ to clojurescript...
21:05Frozenlock"ClojureScript:cljs.user> Created new window in existing browser session." And then nothing
21:22nkoza2where clojure.contrib.core/dissoc-in go? (I'm using clojure 1.4)
21:23FrozenlockOmg I got it!
21:23bbloomnkoza2: can't you juse use update-in and dissoc ?
21:23FrozenlockLife without a REPL isn't worth living.
21:24bbloomFrozenlock: agreed. I have added project.clj to my local versions of all the java code at work, so I can have my REPL :-)
21:24nkoza2bbloom: I want to remove all the path if dissoc returns an empty map, I think dissoc-in was better
21:25FrozenlockNext step is to bring back the REPL in Emacs (perhaps slime). But I don't want it to mess with the java REPL....
21:27bbloomnkoza2: ah ok. i found it: it's core.incubator
21:27bbloomhere:
21:27bbloomhttps://github.com/clojure/core.incubator/
21:27nkoza2bbloom: thanks!
21:27bbloomcontrib got reorganized, and i guess that the "incubator" is where stuff goes if it's being considered for inclusion into core proper
21:27nkoza2weird something as simple as dissoc-in is considered beta
21:28bbloomnkoza2: it's not that it's beta, it's that it's behavior is ambiguous
21:28nkoza2why is ambiguous?
21:28bbloomnkoza2: assoc-in has only one possible behavior, and that's mkdir -p style creation of empty maps down the line
21:29bbloombut dissoc-in could be update-in//dissoc or recursive deletion of empty maps
21:29amalloynkoza2: what does (dissoc-in {:a {:b 1}} [:a :b]) return?
21:29bbloomthe former doesn't mirror assoc-in
21:29bbloombut 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:30bbloomso you have to treat the root node different from interior nodes different from leaf nodes
21:30bbloomit wasn't clear if dissoc-in was generally useful or not
21:31bbloombut it seems like it will make it's way into core eventually, consider the behavior turns out to be sane in practice
21:31bbloomwhere it's common to have interior nodes that are both 1) important not to be removed and 2) not empty
21:31Frozenlock`(run-lisp "lein trampoline cljsbuild repl-launch my-launch")' I feel like I'm getting near :)
21:32bbloomnkoza2: make sense?
21:35nkoza2amalloy: it returns {}
21:35amalloynkoza2: the point is it would be reasonable for it to return {:a {}} instead. that's why it's not in core
21:36nkoza2bbloom: thanks for the explanation
21:40bbloomnkoza2: 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:41nkoza2bbloom: probably the best is to add an argument to dissoc-in to specify the behaviour, or split it in two functions
21:41bbloomnkoza2: well, in general, you really want update-in dissoc
21:42bbloomor 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:43bbloomhence it not being in core
21:43kennethhey if i've created an uberjar
21:43bbloomand it being really easy to write if you need it! not everything needs to be in core
21:43kennethhow do i execute that jar
21:43bbloomthe bar is very high
21:43kennethi mean, how do i execute a clojure / lein main in that jar
21:44kennethi can run by doing `lein run -m some.namespace` -- what's the uberjar equivalent?
21:44wmealing_1java -jar filename.jar ?
21:44eggsbykenneth: 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:44eggsbytry 'lein new app somename' to check out the general structure of apps like that
21:45kennetheggsby: i've got the gen-class, i don't have a :main however
21:45kennethi'd like to specify which ns to run as a cli on the jar, if that's at all possible
21:46wmealing_1eggsby: you're psychic
21:46kennethsomething like java -jar my.jar -m some.ns
21:46wmealing_1kenneth: make "lein run" work first.. then it will run whatever is the default "main" is with the uberjar
21:48wmealing_1kenneth: https://github.com/wmealing/soundlevel/blob/master/project.clj <-- see :main specified here.
21:48wmealing_1see main setup in "soundlevel/core.clj" here https://github.com/wmealing/soundlevel/blob/master/src/soundlevel/core.clj
21:49kennethwmealing_1: right, i get that. should i just make a main ns that executes another ns' -main, then?
21:49kennethif i want to be able to select the ns at execute time
21:50wmealing_1dont do that.
21:50wmealing_1i mean
21:50wmealing_1if you need to execute another ns's -main
21:50wmealing_1it might be best just to put it in yours then
21:51wmealing_1ie, dont complicate it more than it needs to be.
21:52kennethwmealing_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:52wmealing_1ok, with you so far.
21:52cmcbride_does anyone know why this code doesnt work?
21:52cmcbride_(read-string (pr-str (byte-array (map byte [1 2 3]))))
21:52cmcbride_I get an
21:52wmealing_1kenneth: i assume that cb.broke cb.something have their own -main function
21:52cmcbride_Unreadable form exception
21:52kennethand i'd like to be able to execute one of these executable ns (ie. has gen-class and -main) with a cli option
21:52kennethright
21:53kennethso i'd like to do something like java -jar my.jar -main cb.broker, and java -jar my.jar -main cb.something
21:53kennethor something to that effect
21:54wmealing_1if i was to do it, i'd probably do this
21:54FrozenlockNow that I've successfully connected to a cljscript REPL... is there a swank for cljscript? :)
21:54wmealing_1in your namespaces main, parse the command line, import the correct "-main" as something else, then run it
21:54wmealing_1Frozenlock: good going
21:55Frozenlockwmealing_1: Little by little, I'm learning
21:55wmealing_1and use them as that name
21:55wmealing_1does that make sense kenneth ?
21:55kenneththat makes sense
21:56kennethnow i need to figure out how to parse cli
21:56wmealing_1plenty of options :)
21:56xeqi&(pr-str (byte-array (map byte [1 2 3]))
21:56lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
21:56xeqi&(pr-str (byte-array (map byte [1 2 3])))
21:56lazybot⇒ "#<byte[] [B@874230>"
21:58cmcbride_&(read-string (pr-str (byte-array (map byte [1 2 3]))))
21:58lazybotjava.lang.RuntimeException: Unreadable form
21:58Frozenlocktechnomancy: Can swank.clj somehow be used with cljs?
21:58xeqicmcbride_: java strings like that are not readable
21:58xeqiFrozenlock: cemerick is working on a way to have cljs run on nrepl
21:58xeqibut its still very very cutting edge
21:58cmcbride_so if I wanted to serialize a byte array to send via http, how would I do it?
21:59Frozenlockxeqi: Yes, but I'm mainly interested in docstrings and autocomplete, which isn't in nREPL yet if I understand correctly.
22:06kennethok so how do i get CLI arguments in clojure
22:06kennethi don't' get that
22:06Iceland_jack*command-line-args* ?
22:07seancorfieldor use tools.cli from contrib
22:08fentonwhy does this function print 0 and not 1? http://pastie.org/4470454
22:08kennethright 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:08seancorfieldtools.cli is nice because it pre-parses everything and handles positional and keyword arguments, defaults, aliases and so on
22:08kennethso i think i'm good now :)
22:08seancorfieldok
22:09fentontrying to get atoms to work :(
22:09seancorfieldyour -main function has the command line arguments kenneth
22:10cmcbride_has anyone has success sending protobufs over http in clojure?
22:10seancorfieldif you have (defn -main [& args] ...)
22:10kennethoh, wait, it does seancorfield ?
22:10xeqifenton: for is lazy, try ##(doc doseq)
22:10lazybot⇒ "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:10seancorfieldthen you do (tools.cli/cli args ...) to get your options map
22:10fentonthanx xeqi
22:10kennethgotcha
22:11wmealing_1fenton: when i read your name, i can't help but think of the dog.
22:11kennethother question, how do you pass arguements when doing a lein run, so that they don't get interpreted as lein arguments
22:11fentonwmealing_1: there's a dog?
22:11seancorfieldit makes me think of ice cream! fenton's ice cream rocks :)
22:11wmealing_1you havn't heard !? one second
22:11wmealing_1http://fenton.firebrandstore.com/
22:11wmealing_1and http://www.youtube.com/watch?v=3GRSbr0EYYU
22:12fentonlol...i remember someone sending me that video before!!! I'll have to order one of those t-shirts!!!
22:12xeqicmcbride_: I know #flatland people made https://github.com/flatland/clojure-protobuf ; not sure how they use if
22:13FrozenlockI'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:14cmcbride_xeqi: yea Im using that but I cant figure out how to send them over over http
22:14cmcbride_thanks though
22:14cemerickFrozenlock: 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:15Frozenlocko_0
22:19kennethdoes this make sense? https://gist.github.com/a0d614879581cc06c481
22:22amalloycmcbride_: sending them over http? that's nothing to do with protobuf; just send them however you send any binary data over http
22:24xeqikenneth: I wouldn't expect the (the-ns/-main) part to work
22:25xeqidoes it?
22:25amalloyno way. nor the line above it either
22:26amalloyalso, kenneth, that function you're trying to write already exists. it's in clojure.main
22:28djanatynI'm having a lot of trouble building a list of all possible orders a list of things can take :|
22:29seancorfieldwould math.combinatorics help djanatyn ?
22:29xeqidjanatyn: math.combinatorics/permutations ?
22:30amalloyindeed, permutations, but it's a good function to be able to write yourself too
22:30Gnosis-noob question: how do I reload files while in the Leiningen REPL?
22:31bbloom`(doc load-file)
22:31bbloomer i mean:
22:31bbloom,(doc load-file)
22:31clojurebot"([name]); Sequentially read and evaluate the set of forms contained in the file."
22:31djanatynseancorfield: that would be cheating :)
22:31djanatynI mean, I'm having limited success
22:32bbloom*shrug* i dunno, i never evaluate more than a single top-level form at a time during development
22:33cmcbride_amalloy: thats the part I cant figure out
22:33Gnosis-bbloom: so when you update your files, how do you see your changes in the REPL? do you exit and start up again?
22:33FrozenlockWhat's the general opinion about using jQuery in cljs? (jayq)
22:33bbloomGnosis-: I evaluate individual forms as i change them
22:33djanatyn,(let [list '(1 2 3 4 5) ] (map (fn [first] (cons first (remove #(identical? first %) list))) list))
22:33clojurebot((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:33bbloomGnosis-: if I change a function, i press a key combination in my vim to send that top-level form to the repl.
22:34Gnosis-oh
22:34bbloomGnosis-: and if I delete a function, i use:
22:34bbloom`(doc ns-unmap)
22:34cmcbride_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:34bbloomby hand in the repl
22:34bbloomdamn i suck at clojurebot today:
22:34bbloom,(doc ns-unmap)
22:34clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
22:34bbloombut i'm a vim-guy, the swank people may look down upon my primitive mechanism :-)
22:35Frozenlockcemerick: I just discovered your podcasts and I really enjoy! Thanks for that!
22:36amalloydjanatyn: 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:37amalloywhat 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:38djanatyn*nod*
22:38djanatynthat's the farthest I've gotten
22:39Gnosis-why doesn't this work?
22:39Gnosis-,(<= \0 \3 \9)
22:39clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number>
22:39i_sanyone know of a good clojure thing for sanitizing SQL?
22:40cemerickFrozenlock: groovy :-)
22:40amalloycharacters aren't numbers
22:41Gnosis-well, what I mean is, why can't <= work on characters, since it makes sense for one to be less than another
22:43kennethamalloy: it is?
22:44FrozenlockOmg I just changed a webpage background using my repl. \o/
22:44Frozenlock(small goals)
22:44kennethamalloy: not too sure how to use that
22:45kennethjbarrios: hi!
22:45amalloyjava -cp whatever:paths:here clojure.main -m my.ns
22:46xeqiGnosis-: outta curiousity, whats the ordering for \♥ \❤ \❥ \❣ \❦ \❧ ?
22:47kennethoh awesome amalloy that's what i needed to know! :)
22:47kennethi didn't think it was possible, i asked easier
22:48amalloyi think it got added in 1.3? not sure
22:50amalloyactually, i guess it's been around forever but got...improved, somehow, at some point? not very helpful information here
22:52kennethjesus, 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:55xeqiand you're not even setting -Xmx
23:05Gnosis-kenneth: shell script!
23:07treehugi_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:07Gnosis-xeqi: whatever the order of the Unicode code points is :)
23:11djanatynumm, what are the car and cdr equivalents in clojure?
23:11Gnosis-first and next, I htink
23:11Gnosis-could be first and rest
23:12i_streehug: thanks. looks like mine (clojure.java.jdbc) is already doing it.
23:13FrozenlockWhat about cdddar :p
23:18Gnosis-Frozenlock: (def cdddar #(nth % 3)) :P
23:19FrozenlockNot as sexy
23:20Gnosis-You can always write your own Lisp in C
23:20Gnosis-struct cons { void *car; void *cdr;};
23:20FrozenlockBAM! Lisp :p
23:20Gnosis-damn straight
23:21Gnosis-Frozenlock: if you copy-paste that into ##lisp, everyone will twitch at once
23:21Gnosis-tell them you found it in the SBCL source code
23:22FrozenlockWhy would they twitch? If I recall right that's more or less how cons is defined...
23:22cemerickhuh, I haven't been in #lisp in *years*. Interesting that there's only 380 ppl. there at the moment.
23:23Gnosis-Frozenlock: they want to pretend there's no C involved
23:23Gnosis-I dunno, maybe not
23:24FrozenlockI can understand, I don't want to admit there's some java under clojure :P
23:25Raynescemerick: That
23:25Raynessentence will end momentarily.
23:25RaynesThat's because all the cool people are in here.
23:26cemerickRoughly, yes. :-)
23:27Gnosis-cemerick: I have some pretty harsh criticism of your Clojure book
23:27Gnosis-I'm not sure you want to hear it... :)
23:27RaynesOh boy.
23:27RaynesCritics, man.
23:27RaynesAlmost 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:28RaynesMy answer to that is "Did you learn Clojure? Then shut up."
23:28Raynes:p
23:28Gnosis-cemerick: there's nothing in there about file I/O
23:28RaynesCan't cover everything.
23:28Gnosis-actually, aside from that, it's an excellent book
23:28Gnosis-Raynes: file I/O seems pretty basic, though
23:29RaynesI'll admit it is a tiny bit strange to cover web dev but not that.
23:29RaynesBut it's easy to overlook things when you're operating at such a low level.
23:30RaynesAnyways, (line-seq (clojure.java.io/reader "myfile"))
23:30Gnosis-you mean high?
23:30RaynesNo, I meant low.
23:30RaynesWhen you're writing a book, you'
23:30RaynesDamn enter key being close to the apostrophe key.
23:31RaynesWhen you write a book, you dig into small pieces at once. Little individual things.
23:31Gnosis-oh
23:31djanatyn...hmm. okay, so I've made *some* progress but now this is a mess.
23:31RaynesYou tend to build it from the middle out.
23:31RaynesIt's hard to look at what you've written and say "Oops, I forgot x."
23:32cemerickGnosis-: Fair point. File I/O is boring as hell though. Important, but boring.
23:32RaynesIf x isn't macros or multimethods, anyways.
23:32RaynesBut hey, he is the writer. I'm the semi-writer-hopeful-guy.
23:32cemerickIt's like detailing how Java strings are unicode and so aren't screwed up like ruby strings or something.
23:32tolstoycemerick: 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:33RaynesThe cool thing about co-authors is that he can just blame it on cgrand or something.
23:33cemerickThe people that need file I/O will go look it up. :-)
23:33tolstoycemerick: Ammo I'll keep to myself, of course.
23:34Gnosis-actually, Java strings kind of are screwed up since they can't handle Unicode above 0xffff
23:34Gnosis-meh
23:34cemerickAre there any languages that *do* handle those ranges well?
23:35Gnosis-any language with 4-byte characters
23:35cemerickRight, I'm wondering if there are any.
23:35Gnosis-I think C's wchar_t on some platforms...?
23:35cemerickWell, that's awesome. :-P
23:35RaynesI think he is trying to understand your standards for 'screwed up'.
23:35RaynesBecause by your standards, perhaps everything is screwed up.
23:35Gnosis-okay, I guess they are good enough for almost everything
23:36cemerickRaynes: Screwed up is equating byte arrays with strings, and then put on a jazz-hands show using a pile of ill-conceived functions.
23:37Raynescemerick: Erlang.
23:37wmealing_1oh that was low.
23:37cemerickOh? Sad.
23:37RaynesTell me about it. :(
23:37cemerickAnd here I thought it might be fun to tinker with someday.
23:37wmealing_1it is
23:38RaynesI had nothing but hell with byte strings in Elixir.
23:38wmealing_1what trickery were you doing ?
23:38cemerickwmealing_1: Perhaps, but I can't bring myself to invest in a runtime that doesn't have reasonable strings.
23:40wmealing_1I guess I do less string manipulation than most.. never found it difficult.
23:40cemerickNot to say the JVM is a hands-down winner. All of the options Python provided for strings was very pleasant.
23:40cemericks/was/were
23:44amalloydjanatyn: still working on permutations?
23:48amalloyif so, gist what you've figured out and i'll see if i can help you get it working
23:49FrozenlockIn cljs, does one use a library like in clojure? Say: (use 'jayq.core) ?
23:53djanatynamalloy: yes
23:54xeqiFrozenlock: I usually use :require or :require-macros, but I would expect :use to work
23:56djanatynamalloy: https://gist.github.com/3346147
23:57TimMccemerick: In Erlang, strings aren't even a separate thing, they are just (cons?) lists of integers.
23:58cemerickTimMc: Noted.
23:58TimMcYou can apparently also do UTF-8 strings as binary objects, but some libraries use one and some the other.
23:59amalloyhuh, 4clojure hasn't asked a permutations question? crazy