#clojure logs

2012-07-08

00:10S11001001ssutch: uh, those messages are because in one case you left off parens and the other you tried to call a disallowed function
00:10ssutchS11001001 yes i know
00:10ssutchit looks like i should just use pattern matching for what i was trying to do
00:10S11001001if you like
00:11S11001001multi-lambda only manages different arities, and the destructuring built-in to clojure isn't pattern matching, per se
00:11S11001001,(let [{:keys [x y z]} 42] (list x y z))
00:11clojurebot(nil nil nil)
00:12S11001001,(let [[x y z] 42] (list x y z))
00:12clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: Long>
00:12S11001001iow there is no report of whether a match "succeeded". A bad match can express itself in the form of nils in some places, or type-related exceptionsf
00:13ssutchi was trying to make a multi-lambda that would choose the right form based on keys passed in a map
00:13ssutchhttps://github.com/clojure/core.match/ does mostly what i was trying to do
00:13ssutch*does exactly what i was trying to do
00:14S11001001I have a lambda wrapper for core.match that mixes in arities: https://bazaar.launchpad.net/~scompall/+junk/clojure-stuff/view/head:/src/com/nocandysw/cloj_dummy/scala/tertiary.clj#L37
00:15michaelr`good morning!
00:15S11001001example use at https://bazaar.launchpad.net/~scompall/+junk/clojure-stuff/view/head:/src/com/nocandysw/cloj_dummy/scala/adt.clj#L80
00:17ssutchinteresting
00:21mindbenderS11001001: what's a lambda wrapper?
00:25ssutchmindbender wraps lambdas
00:29S11001001mindbender: lambda version of core.match/match, just a wrapper for it
00:56evildaemonIs there an error message translator?
01:01tremoloquestion about monads: the whole point is supposed to be function composition, right? how come all the clojure examples I see have long chains of "let" bindings and absolutely no visible composition?
01:01tremolothis includes all the examples from algo.monads
01:02tremoloi expect to see something like -> (f1 (f2 (f3 val))), but what I see instead is [a (f1) b (f2 a) c (f3 b)]
01:05S11001001tremolo: that's just sugar, rewritten to (m-bind (f1) (fn [a] (m-bind (f2 a) (fn [b] (m-bind (f3 b) (fn [c] ...))))))
01:08S11001001tremolo: it's clearer in haskell and scala, which use <- instead of = to signify that it's not really let
01:08tremoloyea, I guess I just find it a bit weird syntactical choice
01:09tremoloseems like something more like the thread macro would be clearer
01:09S11001001tremolo: for the identity monad, domonad is equivalent to let
01:09S11001001tremolo: typically it isn't quite so common to line up pure values and actions like that
01:10S11001001tremolo: I believe m-chain is provided for the cases where you do want that
01:10tremoloah, alright. didn't know about m-chain
01:10tremolothanks
01:12S11001001tremolo: it's worth browsing all of monads.clj; it's not that long, and there's lots of useful stuff in there if you want to take serious advantage of the library
01:12tremoloyep, good idea
01:12S11001001knowledge of its idiosyncratic interface is also quite useful
01:12S11001001with respect to the way with-monad and defmonadfn work, for example
01:29wingythe wrong fn is used here: http://clojuredocs.org/clojure_core/clojure.core/send-off
01:36TricksWhat is the best way to replace two items in a vector that are next to each other with new values. Say I have [1,2,3,4,5] and I want to replace 3 and 4 with 5 and 2 and I know that 3 and 4 are at index 2 and 3 and Ialso know the values I want to replace them with.
01:37amalloy&(assoc [1 2 3 4 5] 2 'a 3 'b)
01:37lazybot⇒ [1 2 a b 5]
01:37TricksThank you.
01:38amalloyonly for an actual vector, though, not some lazy-seq that you pretended was a vector for simplicity
03:41michaelr`what
03:41michaelr`why no dissoc-in in core?
04:00amalloymichaelr`: my guess? (a) it's easy to build yourself with update-in, and (b) unlike assoc-in, there are corner cases where it's not entirely clear what the right output should be and any choice in core would surprise you eventually
04:01amalloyeg: (dissoc-in {} [:a :b :c]). are you really happy with that returning {:a {:b {}}}? or {:a {:b nil}}?
04:04michaelr`hmm
04:08michaelr`,(update-in {:a {:b {:c 1}}} [:a :b] (fn [m] (dissoc m :c)))
04:08clojurebot{:a {:b {}}}
04:08michaelr`like that?
04:08michaelr`amalloy: ^^
04:11amalloymore or less. it's certainly better to do (update-in m [:a :b] dissoc :c)
04:12michaelr`oh cool
04:12michaelr`:)
04:12michaelr`,(update-in {:a {:b {:c 1}}} [:a :b] dissoc m :c)
04:12clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: m in this context, compiling:(NO_SOURCE_PATH:0)>
04:12michaelr`,(update-in {:a {:b {:c 1}}} [:a :b] dissoc :c)
04:12clojurebot{:a {:b {}}}
05:34wingyfrom what i have understood we can use clj data structures instead of json/xml
05:35wingydoes this mean that if a system is using clojure then it would be more beneficial for it if my restful API returned clj data instead of json?
05:35_uliseswingy: in principle I'd say yes; have you seen pinot? (related to the noir project)
05:36_uliseswingy: reason I mention pinot is because it does exactly that to transfer data from noir apps to the cljs frontend
05:36wingyi c
05:37wingybut when it comes to restful HTTP API .. i have never seen someone returning clj data structures
05:37wingybut i guess i could make that as an alternative for systems in clj .. i think they would appreciate that rather than having to deal with JSON?
05:37_uliseswingy: returning clj structures implies (unless you're willing to jump through several hoops) that you'll be reading them using cljs/clj I'd say
05:37wingyalso i think that would make a good promotion of clj. what do you think?
05:38wingyyeah .. for clients in clj
05:38_uliseswingy: it depends on what you're building; if it's a public API, then clj data structures would be a nice to have to clojure people, but if it was the standard you'd restrict yourself to that community
05:38_uliseswingy: JSON is more "universal" in that respect
05:40wingyi would provide both JSON and clj data structures
05:41_uliseswingy: again, don't know what you're building; if you expect quite an interest from the clojure community on your service then providing clj structures sounds like a good idea
05:42wingyyeah you always wanna do something for the clj community .. i think this would promote clj really well as well
05:42_uliseswingy: then by all means go for it
05:43wingyi was actually watching http://www.infoq.com/presentations/One-Parenthesis-to-Rule-them-All where he mentions clj data structure is far more superior than json .. and that it could be used as a wire protocol between end points
05:44_uliseswingy: sure, clj structures may be richer than json, but perhaps they're not the right solution in some domains
05:46wingyright
06:13ro_sthas anyone come up with an elegant way to share code between clojure and clojure script?
06:13ro_steg, 'model' code that doesn't depend on a particular execution environment such as the dom or access to a database
06:13ro_stone approach i found is https://github.com/lynaghk/cljx
06:37antiheroIs there a tutorial that takes me through building a simple application?
06:37_ulisesantihero: what sort of application? I'm sure there are plenty tutorials to get you started writing clojure
06:37antiheroHmm, not sure what I want to use it for yet, I do web stuff at the moment
06:38antiherosurprise me?
06:38_ulisesantihero: it may be easiest to start with noir (a web framework for clojure)
06:38antiherook
06:39antiheroI suppose I can learn clojure by trying to write stuff with noir and looking up the reference
06:39_ulisesantihero: however, if you know nothing about clojure, I'd start with something simpler
06:39hyPiRionIf you use Leiningen and Noir, then it's very simple to start off.
06:39_ulisesantihero: http://webnoir.org/
06:39hyPiRionSorry, I mean easy.
06:39_ulises+1
06:39antiheroI ghot Leiningen :)
06:39antiheroso I could use the irepl
06:39antiheroas that seems nice
06:40antiherois there a .tmTheme for the style on the noir website?
06:40hyPiRion.tmTheme?
06:41antiherolike textmate/sublime text highlighting theme
06:43antiheroJava pops out loads of stuff on startup, any ideas what "which: no rlwrap in (...)" is and how to avoid it? Also "Picked up _JAVA_OPTIONS: ..."
06:48hyPiRionantihero: I don't think so, but I'm not using sublime.
06:49antiherofair enough
06:53antiheroMy serve doesn'd seem to run :(
06:54antiheroI do lein run and it says it's listening
06:54antiherobut if I open the page, it just sits there loading
06:54antiheroI'm using openjdk7
07:07wmealingantihero, obvious question.. but firewall ?
07:07wmealingantihero, which ip are you connecting on ?
07:08antiheroOk, it seems to work now I'm using Oracle JDK/JRE
07:08antiheroweird
07:08wmealingno idea, ok
07:08antiheroall is local
07:11hyPiRionantihero: That's weird. I use open JDK and have no problems with it.
07:12antiheromaybe I have some config issues
07:12antiheroI get this error output
07:13wmealingopenjdk here too
07:13wmealingno problems, Fedora 16 and 17
07:13antiheroI'd prefer to use openJDK
07:13antiherohttp://bpaste.net/show/wveuzkheqH2CJH3Mqwbw/
07:13antiheroperhaps those errors could be causing?
07:14wmealinglooks ok
07:14wmealingrlwrap wont cause a listening problem
07:14wmealingand the awt settings wont either
07:14antiherois there any way to get rid of those errors anyway? They are annoying as hell
07:17wmealingdistro ?
07:24bosiewhy does htis code result in a NullPointerException? https://gist.github.com/3070583
07:24unnalibosie: you've got one-too many levels of ()
07:24unnali #((println %))
07:24unnalishould be
07:24unnali #(println %)
07:25unnaliright now it's executing (println %), which should work, but it yields nil
07:25unnalii.e.
07:25bosieah
07:25bosieright
07:25unnali((println "blah")) --> (nil) --> NPE
07:25bosieworking
07:25bosiei just overlooked it
07:25bosienew to the whole () game
07:26unnali:)!
07:26bosie;)
07:26unnali;D
07:39b6nHi, does anybody have some resources about how to use google closures soy templates together with clojurescript (cljsbuild)?
07:54penthiefAm being asked to accept an expired certificate on clojars.org at the moment. Just saying.
07:57michaelr525this whole certificate thing is ridiculous, anybody can buy a certificate. so the only thing it certificates is the money that has been paid for it :)
08:48bosieis there a way to actually get better error messages
08:51hyPiRionbosie: As of right now, nope.
08:51weavejesterbosie: Tools like clj-stacktrace can help
08:58gfredericksmichaelr525: that sounds simplistic
09:07michaelr525gfredericks: there is a bigger picture.. the certificate authorities make lot's of money.. hmm what else?
09:11weavejesterToday I learned that the order of dependencies in Leiningen matters… :/
09:14wingysometimes i just can't get the explanations people use to describe how clojure works .. they make things really hard to get :/
09:16kmicuwingy: can you give an example :)?
09:17wingyhttp://java.ociweb.com/mark/clojure/article.html
09:18wingy"The def macro binds a value to a symbol. It provides a mechanism to define metadata, :dynamic, which allows a thread-local value within the scope of a binding call. In other words, it allows re-definition of assigned value per execution thread and scope. If the Var is not re-assigned to a new value in a separate execution thread, the Var refers to the value of the root binding, if accessed from another
09:18wingythread."
09:19wingylucky me i read it in another book. but that is just one of many explanations not telling you much .. i can read it 10 times and still have a ?
09:24wingyi hope "clojure-tutorial-for-the-non-lisp-programmer" is better in explaining stuff .. so tired of reading materials that only make you frustrated
09:25wingyi realized not only does one have to choose a lang that makes sense .. one has to choose docs that make sense as well
09:27yynice
09:29kmicuwingy: it is more a personal thing or matter of taste, for me clojure source code is the best docs ;)
09:29wingykmicu: yeah .. source code is great
09:39TimMckmicu: As long as you aren't talking about msot of the Java impl of Clojure, sure.
09:40TimMcrhickey is apparently allergic to javadocs.
09:40TimMcor comments in general, I guess
09:40michaelr525yeah, comments are evil man ;)
09:41kmicuTimMc: Not my level :]
09:41TimMc"not my level" == "I mean the .clj impl"?
09:43kmicuTimMc: yes, but also I am more of cljs than clj
09:43TimMcAh, OK.
09:53kmicuTimMc: can you tell what you do that you need docs for clojure's *.java files? ;)
09:53TimMckmicu: A lot of clojure/core.clj fns delegate their implementations to RT.java, etc.
09:56TimMckmicu: Say, for instance, you wish to see what 'seq will accept and what will cause it to throw an exception: https://github.com/clojure/clojure/blob/1.3.x/src/jvm/clojure/lang/RT.java#L462
10:42michaelr525inline-block or float?
10:44bosiehttps://gist.github.com/3071242
10:44bosiehow would i do this with apply, rather than doseq
10:45bosiei tried it like this "#(apply #(do %) logger-fns)" but it says nested #() are not allowed
10:53hyPiRionbosie: Obviously, the % can be owned by either the inner or the outer anonymous fn.
10:55wmealingso if i wanted to profile some clojure code to find out where the cpu time is spent
10:55wmealingwhat is the best way to do that right now ?
10:56hyPiRionbosie: A shorter version of your code would be this: https://www.refheap.com/paste/3514
10:56wmealingnow i could use the whatever is new clojure.contrib.profile
10:56wmealingbut i'm wondering if there something more useful out there, right now
11:00duck1123there was a new logging library that has profiling. I've been meaning to try it
11:00duck1123https://github.com/ptaoussanis/timbre
11:02wmealingi'll look into it
11:03wmealingi'm doing some basic RMS calculations and the read from microphone loop chews quite a bit of CPU
11:03duck1123it was just announced the other day, and it looks intriguing
11:03wmealingi'm doing it wrong (obviously) now i need to find out where
11:03wmealinglooks clear
11:03wmealingthanks for the link
11:04duck1123I've also been thinking about trying to make use of https://github.com/etsy/statsd from clojure
11:04duck1123I like the idea of having control of my loggers at runtime
11:05duck1123I'm hoping it'll be more or less a drop-in replacement (ie replace all my :require calls)
11:05jghi all, so it seems the new lein uses [reply "0.1.0-beta8"] by default, the thing is - i cannot evaluate any expression with it! (return does not work!) what gives?
11:06jgor: how can i change the default repl used by lein?
11:07duck1123you might be able to use lein run if the repl you want to use has a main
11:08duck1123although it's odd that it doesn't work for you.
11:11_wingyi have read that clojure's tail call optimization is a hack using loop, recur. is there a plan to fix this?
11:12duck1123from what I heard, even if they could support it automatically, recur isn't going away
11:12pandeiroi want to be able to take a symbol representing a namespace and do something with all of its vars that have a certain metadata value - can anyone point me towards the functions i need?
11:12duck1123recur at least gives you the assurance that you are actually in the tail call
11:12jgduck1123: removed my .inputrc, repl started working again
11:12pandeiro_wingy: i don't understand that stuff but i remember reading it's due to a JVM limitation
11:12duck1123jg: cool.
11:13jgduck1123: it seems https://github.com/jline/jline2/issues/48 this was the problem
11:13duck1123IIRC java 7 has some support for TCO, but at this point, recur is a design desicion
11:16Licenser_wingy the reason for loop recur is not mainly javas limitations but to make sure that you KNOW when you get fast TCO and that you also notice when a change in your algorithm breaks it
11:16Licenserand not things get magically 10x slower or something
11:16Licenser_wingy the reason for loop recur is not mainly javas limitations but to make sure that you KNOW when you get fast TCO and that you also notice when a change in your algorithm breaks it (re)
11:16_wingypandeiro: im pretty new to that stuff as well. i think that it is referring to the memory leak when each loop creates a value that is saved in memory
11:17duck1123in clojure there's a memory leak with loop?
11:18tmciver_wingy: no memory 'leak'. Not using TCO consumes stack space.
11:19duck1123thankfully, most of the time you need loop/recur, you don't really need loop recur as there is a better higher-level abstraction
11:19pandeiroso am i correct in understanding only macros can take unquoted namespaces and work with them without evaluating?
11:19tmciver_wingy: TCO is a technique that allows recursion without consuming the stack.
11:20duck1123well, the macro sees that unquoted namespace as just symbols to manipulate, that's how it gets around it
11:21_wingytmciver: why not let us do recursion without loop/recur?
11:21tmciver_wingy: you can
11:22AimHereYou can, but it's better to use loop/recur if you can
11:22tmciver_wingy: but it consumes the stack
11:22Licenser_wingy you can also recur to a function head
11:22bosiehyPiRion: not "obviously" as that is an implementation question
11:23duck1123with recur, you're explicit about your intent. A small price to pay for how infrequent it comes up
11:24_wingyis there a way to do normal recursion without consuming stack space? and is someone working on it?
11:24_wingyjust curious
11:24bosiehyPiRion: your code doesn't seem to work for me
11:25bosiehyPiRion: cos i forgot the %
11:25bosienvm
11:26mstrlu_wingy: laziness ;)
11:30duck1123_wingy: https://groups.google.com/d/msg/clojure/4bSdsbperNE/tXdcmbiv4g0J
11:35_wingyduck1123: good read
11:45pandeirostill trying to figure out how to filter a seq of vars from a ns based on metadata values... any help? when i (map meta (vals (ns-publics 'the.namespace))) i get :ns :name :line and :file keys but not the metadata i attached
11:46the-kennypandeiro: How do you attach the metadata?
11:46pandeiroi'm just doing it at the repl when i def the vars
11:47pandeiro(def a1 ^{:a true} [1 2 3])
11:47the-kennyThis attaches the metadata to [1 2 3]
11:48the-kennyYou want (def ^{:a true} a1 [1 2 3] ) :)
11:48duck1123try (def ^{:a true} a1 [1 2 3])
11:48duck1123also just ^:a is a shortcut for that
11:50pandeirook when i was doing that i wasn't getting the metadata with (meta a1)
11:54pandeirowhy does (def ^{:a true} a1 [1 2 3]) and then (meta a1) return nil?
11:54pandeiroah i need var there, got it
11:55pandeiroamazing i've used clojure many months and still don't get namespaces and vars :-/
11:56duck1123It's a great design when you think about it and compare it to some other languages
12:09solussd_question: I have a ruby on rails rest api that needs to communicate with a clojure process on the same server. I'm currently using http webservice calls to communicate (one way) from rails to clojure (the rails process knows about the clojure webservices). Any suggestions for a faster serverside IPC approach between ruby/rails and clojure?
12:15jeremyheilersolussd_: you could use some sort of message queue like redis or something.
12:16solussd_jeremyheiler: possibly. I'll investigate
12:16solussd_thank
12:16bosiehttps://gist.github.com/3071575 ok, so why doesn't println print 2 lines?
12:16solussd_*s
12:16bosieand how would i go about debugging that?
12:17the-kennybosie: (println "foo" "bar") doesn't print two lines either, right?
12:17solussd_bosie: you're last expression looks like this : (println firstitem seconditem), so it'll print them on the same line followed by a newline
12:18bosiethe-kenny: true, it doesn't
12:18the-kennybosie: (apply println ["foo" "bar"]) is the same as (println "foo" "bar")
12:18bosiehm
12:18bosiethe-kenny: because?
12:18solussd_you want (doseq [item (take 2 seq)] (println item))
12:18the-kennyBecause apply works like this
12:18the-kenny:)
12:19bosiethe-kenny: but doesn't apply take the sequence and apply each item in the sequence to the function (first param)?
12:19the-kennyNo!
12:19the-kennyThat's map.
12:19solussd_apply takes a sequence and splices it in as more args to the function
12:19the-kenny(map inc [1 2 3]) -> [2 3 4]
12:19bosiesolussd_: right but doseq is for side effects only methods. so if i don't do println but something else i would have to change my doseq, no?
12:19solussd_e.g. (apply + 1 2 [3 4 5]) == (+ 1 2 3 4 5)
12:20solussd_bosie: printing is a side-effect
12:20solussd_yes
12:20solussd_just do the other thing right after the doseq. :)
12:21the-kennyor use for
12:22the-kenny,(for [i [1 2 3]] (+ i 42))
12:22clojurebot(43 44 45)
12:22the-kenny(map (partial + 42) [1 2 3])
12:22the-kenny,(map (partial + 42) [1 2 3])
12:22clojurebot(43 44 45)
12:22solussd_or just do this: (apply println (clojure.string/join "\n" (take 2 seq)))
12:22bosiesolussd_: wait what? why would i join
12:23bosiethe-kenny: reading up on for
12:23the-kennysolussd_: He's already reading lines from a file :D
12:23solussd_,(apply println (clojure.string/join "\n" ["first thing" "second thing"]))
12:23clojurebotf i r s t t h i n g
12:23clojurebot s e c o n d t h i n g
12:23the-kennybosie: Be careful! for is lazy, doseq isn't. So doseq is the choice for side effects
12:24Frozenlo`Who is the owner of clojars? The certificate expired...
12:24bosiethe-kenny: would doseq throw an exception if my method had no side effects? or is that "just" a common, unwritten rule amongst clojure programmers?
12:25the-kennydoseq is rather useless without side effects because it returns nil :)
12:25bosiek
12:25solussd_bosie: doseq just makes sure your seq is actually traversed
12:25bosiegood point
12:25the-kenny,(doseq [i (range 1000)] i)
12:25clojurebotnil
12:26bosieok, so line-seq returns a lazy sequence and for requires a vector for its binding
12:28the-kennyfor's syntax is the same as for doseq
12:29the-kennyfor is really useful for transforming seqs.
12:29the-kennyBut prefer map when it's more intuitive. (map count (line-seq ...)) is easier to read than (for [line (line-seq ...)] (count line))
12:30the-kenny(both return a new seq with the length of each line)
12:30bosiewoho
12:30bosiegot it together with doeq
12:31bosiethe-kenny: alright
12:31bosiea question about the implementation of the lazy seq eval
12:31bosiewouldn't (doseq [item (take 2 seq)] (println item)) this read the entire file?
12:31bosieand store the 2 lines in item?
12:31bosiesince i force it to with "take"?
12:32duck1123you take it, then force it
12:32bosieok
12:32bosieright. take returns a lazy seq again
12:32duck1123(take 2 (doall (for [item seq] (println item)))), however
12:34bosieduck1123: hm. reading doall sounds very similar to dosync. forcing the lazy seq to be evaluated fully
12:34bosieexcept doseq i mean
12:34bosiedoseq i mean
12:35bosiemaking sense of the documentation requires a PHD in lisp i guess ;)
12:35duck1123yeah I use doall and map quite frequently when I want to force them all but I want the return (I tend not to use for often)
12:36bosiehow does map force anything? according to the api it returns a lazy sequence itself?
12:36the-kennybosie: It does.
12:36the-kennydoall forces the realization of the lazy seq
12:36duck1123doall forces it
12:36bosiek
12:36bosiecan't remember the last time it took me this long to write a simple iteration over a list ;)
12:38the-kennyYou won't regret it. Clojure provides really powerful tools for that :)
12:38bosiethe-kenny: i looked into scala.
12:38bosiethe-kenny: since i am jvm bound ;)
12:38the-kennyfor is in reality more powerful than that as it provides full list comprehension
12:39the-kenny(Why do I keep typing 'lisp comprehension'?)
12:39bosiethe-kenny: probably your 28 years of lisp programming? ;)
12:39the-kennyI'm not even that old :p
12:39bosieyet
12:40bosie;)
12:40bosieClojure Programming (Emerick/Carper/Grand) is rather excellent, isn't it?
12:42the-kennyI haven't had a deep look at it, but I heard it's awesome
12:42wkellyI quite like it!
12:42bosiewkelly: you far you in?
12:43wkellybosie: I have browsed its entirety, and I have been actually reading chapters here and there as they become pertinent to my interests
12:43wkellyit is hard to say :/
12:43wkellyI've probably read about half of it in detail
12:43bosiealrighty
12:43bosieread about 80 pages and quite like it
12:44bosiejust had to ask if there was something better out there
12:44wkellyI have most of the rest. It seems to be the best for people without a big lisp background
12:45wkellyI like joy of clojure as well, but I had to back off and find something more down to earth first
12:45bosiedown to earth? ;)
12:45wkellyhaha
12:45wkellyjoy of clojure started off a bit over my head!
12:45wkelly:P
12:46bosiewkelly: good. then i made the right choice cos i never did FP/Lisp before (not counting ruby's FP stuff)
12:48duck1123ruby is a good prep for clojure I think
12:48mybuddymichaelduck1123: I agree.
12:48mybuddymichaelRuby has a lot of "Lisp-y" features.
12:48bosieduck1123: how so? #((apply juxt functions) ) blew my mind today. no idea how you would do that in rugy
12:49bosieruby
12:49duck1123I'm just saying on the types of language features, my experience with ruby helped in my learning of clojure
12:49bosiek
12:50duck1123my problem was I wanted to do coll.map { :key } in ruby, and it didn't work
12:51duck1123you can do juxt in ruby... I'm too out of practice now.
12:51duck1123my day job lately has been in perl and it's been making me cry
12:52bosieduck1123: where are you (city/country) if you don't mind me asking?
12:52duck1123I'm just outside Detroit, MI
12:53bosiek
12:54duck1123grr.. clj-webdriver and htmlunit are acting up for me today.
12:54bosieduck1123: i guess one can't switch to a clojure job in detroit? ;)
12:55duck1123Well, this was supposed to be a java job, but it's a java/perl shop and my project I was hired for was put on hold
12:55duck1123so I've been working in perl
12:55bosiei hate that
12:56duck1123I got to use a bit of clojure when I was trying to test out external api's (use what I know well)
12:57duck1123My last job I was starting the process of converting my large ruby application over to clojure, but many of the features never went live
12:58bosieduck1123: interesting, why would you switch to clojure?
12:59duck1123We were doing heavy data processing, and had limitations with concurrency
12:59duck1123plus I really wanted to use clojure :)
12:59bosielimitations… that was very friendly put ;)
13:00duck1123So I built a big admin interface to the ruby part, but I built it using my framework, so it got some nice features as part of it.
13:02duck1123I just yanked out the worker admin interface the other day and dropped it into my personal project. I need to figure out how to make it a component that can be placed into any app
13:02bosieand then you sell your personal project?
13:02duck1123my personal project is open source
13:03bosiecan you just open source work stuff like that?
13:03duck1123I got assurances from my boss
13:03duck1123most of the stuff is too specific that it's not usable
13:04duck1123but he was aware that I was contributing to the base libraries
13:04bosielink?
13:04clojurebotyour link is dead
13:05duck1123I'm building a microblogging application. I'm running a copy at renfer.name
13:05yonatanereading some github history is almost like porn
13:05_wingyprobably the best beginner's guide: http://moxleystratton.com/clojure/clojure-tutorial-for-the-non-lisp-programmer#sequences
13:05yonatanethe first commit, the evolution
13:06_wingyi finally get what a seq(uence) is
13:07bosie_wingy: saved
13:07_wingybosie: :)
13:09bosiethanks for all your help guys
13:09bosiegotta bounce. cu
13:09zdennisI've just installed clojure 1.4 and leiningen recently, I'm trying to figure out how to get access to clojure.math.combinatorics but I can't seem to figure out how
13:10zdennisdo I need to download off github and build myself?
13:10zdennisor is there a dependency I can add to my lein projects.yml?
13:11yonatanedon't you have a project.clj file?
13:11zdenniser.. oops
13:11zdennisyeah i have that
13:11zdennisproject.clj (not projects.yml,… typo theree)
13:11xeqizdennis: [org.clojure/math.combinatorics "0.0.3"]
13:12zdennisawesome, thank you @xeqi
13:14xeqizdennis: you can find most org.clojure stuff by searching central
13:14xeqihttp://search.maven.org/#search|ga|1|math.combinatorics
13:14zdennissweet i was just trying google how to find clojure packages
13:14xeqizdennis: alot of non-clojure core projects end up in clojars.org
13:15xeqi* non-(clojure core)
13:15xeqiso you can search there as well
13:17zdennisty
13:20yonatanewhat does "first cut implementation" means?
13:21zdennisI am making a combination of all possible points in two vectors (i.e.: [-1 0 1] and [-1 0 1]). I have a version that uses two functions to do this.
13:21zdennishttps://gist.github.com/3071882
13:21zdennisI have a inkling there is a better way to approach this in clojure
13:21zdennisany one have a moment to review my code and point me in a direction?
13:23zdennisI was hoping that clojure.math.combinatorics/combinations would be something of interest but I don't think it will help me out
13:23xeqi&(for [x [-1 0 1] y [-1 0 1]] [x y])
13:23lazybot⇒ ([-1 -1] [-1 0] [-1 1] [0 -1] [0 0] [0 1] [1 -1] [1 0] [1 1])
13:23amalloyalso i think combinatorics contains cartesian-product
13:25zdennisoh dang
13:25zdennis@xeqi that's pretty awesome
13:26zdennis&(clojure.math.combinatorics/cartesian-product [-1 0 1] [-1 0 1])
13:26lazybotjava.lang.ClassNotFoundException: clojure.math.combinatorics
13:26zdennisshucks… well in repl that seems to also work
13:28zdennisanother question… I have a namespace called drunken-cockroach.point. Inside of that namespace I have a min and max function (defined with defn)
13:29zdenniswhenever I load that code I always get: WARNING: min already refers to: #'clojure.core/min in namespace: point, being replaced by: #'point/min
13:29zdennis#'point/min
13:29zdennisshouldn't it not be conflicting since it's in its own namespace?
13:29zdennisis that warning telling me i am overriding globally available functions?
13:31metellusif you load it with use it will put the definitions into your current namespace
13:31metelluswith require it will not
13:33zdennisok
13:34zdennisthank you for your help @metellus @amalloy @xeqi I am slowly but surely triangulating knowledge around using clojure :)
13:48mcohenanyone know what the status of cake is these days?
13:48mcohenlooks like it isn't actively developed anymore
13:49nsxt_didn't cake join forces with lein?
13:50nsxt_https://groups.google.com/group/leiningen/browse_thread/thread/5a79d02198a91b91
13:51mcohenahh, i see. thank you
14:52penthiefAnyone know why I might be getting "No 'xpc' param provided to child iframe" when doing "user> (cljs.repl/repl (cljs.repl.browser/repl-env))" ?
15:03FrozenlockIs there a command to force leningen to re-download libraries?
15:04hyPiRionlein clean and then lein deps
15:04FrozenlockThanks!
15:04hyPiRionMy pleasure :)
15:06FrozenlockHmm didn't work... I think lein store the libraries in another folder and simply copy them back :(
15:07qubit[01]so the @ when used with futures means 'wait on this future' ?
15:08qubit[01]"Or, as usual, you can use the reader macro version" , what is 'a reader macro', and what are some other reader macro examples ?
15:10chmllrFrozenlock: you want to delete the maven cache, see the ~/.m2/ folder
15:11amalloyqubit[01]: 'x is a reader macro that's the same as (quote x)
15:11amalloy@x is (deref x)
15:11amalloy#(inc %) is (fn [x] (inc x)), and so on. those are all reader macros
15:11qubit[01]ahh, so its just a macro that manipulates what the ast ?
15:11qubit[01]not manipulates
15:12amalloywell, it's a reader macro - it gets applied before other macros; at read time, not compile time
15:12qubit[01]ahh gotcha
15:18Frozenlockchmllr: That worked! Thanks!
15:29bosiehas anyone remapped his/her keyboard specifically for clojure and if so, what?
15:44qubit[01]bosie: cool idea
15:44bosiequbit[01]: just figured that () should be homerow ;)
15:44qubit[01]id like to not have to push shift everytime I want a paren, think I'll do that now
15:44bosiequbit[01]: or are you mocking me?
15:44qubit[01]nope :)
15:45qubit[01]maybe I sacrifice my left shift, have shift (, and caps lock )
15:46qubit[01]hmm thats no good
15:46bosiequbit[01]: i was thinking along the same lines
15:46bosiecaps for (
15:46bosie; for )
15:46qubit[01]think I'll try it
15:47bosiebut i have no idea. i never remapped for a language, but since i am using vim i have been anal about homerow and remap almost every app ;)
15:56nickaugustI have an embedded h2 database in my application can I enable the built in web-console? anyone have experience doing this?
16:12qubit[01]bosie: ok I got it setup with xbindkeys
16:12bosiequbit[01]: ok
16:14qubit[01]here is my setup incase you wanted it https://gist.github.com/3072641
16:16bosiei am on osx
16:16bosiebut i will set it up tomorrow
16:18qubit[01]ahh , coolio
16:19bosieis it good?
16:20pandeiroany suggestions on how to conditionally construct hashmaps based on non-nil values?
16:21pandeirohmm, maybe just i'll just make the hashmap first then filter out the nils
16:22qubit[01]bosie: still getting used to it, hard not to go right to where it usually is, I ended up using Caps_Lock as (, and shift, caps as )
16:44qubit[01]how would I find where clj-record is with lein ?
16:44qubit[01]do know what I need to add as a dependency
16:44duck1123go to clojars and search there
16:45qubit[01]kk
16:45duck1123https://clojars.org/clj-record
17:03wingyi dont get this one .. so the rails guys gladly invited rich to enlighten them about how inferior ruby/rails/oop is? http://www.youtube.com/watch?v=rI8tNMsozo0&amp;feature=related
17:05gfrederickswingy: yeah I had a hard time with the idea that they didn't all fit my stereotype either
17:08wingygfredericks: irony?
17:10jsl_Speaking of Ruby, is there a Clojure REPL equivalent of '_' in ruby IRB to refer to the value the previous statement?
17:10dnolenjsl_: *1 *2 *3
17:11jsl_dnolen: thank you very much!
17:15qubit[01]https://gist.github.com/3072831 , what does -> do in this context ?
17:18tmciverqubit[01]: it's a threading macro: http://clojuredocs.org/clojure_core/clojure.core/-%3E
17:19qubit[01]cool!
17:20tmciverqubit[01]: Yes, it is!
17:20duck1123-> allows you to rewrite (a (b (c (d e)))) as (-> e d c b a)
17:33gfredericks,(macroexpand-all '(-> e d c b a))
17:33clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: macroexpand-all in this context, compiling:(NO_SOURCE_PATH:0)>
17:33gfredericks,(clojure.walk/macroexpand-all '(-> e d c b a))
17:33clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.walk>
17:33gfredericks&(clojure.walk/macroexpand-all '(-> e d c b a))
17:33lazybot⇒ (a (b (c (d e))))
17:34duck1123&*clojure-version*
17:34lazybot⇒ {:major 1, :minor 4, :incremental 0, :qualifier nil}
17:35duck1123did the expansion change between 1.3 and 1.4?
17:50TimMcqubit[01]: I prefer to call it a "stitching" macro to avoid concurrency connotations.
17:51TimMcduck1123: No, why?
17:53ToxicFrogTimMc: I just call it a pipe.
17:59RaynesI call it ->
17:59pandeirohyphen-greater-than?
18:00RaynesRight arrow.
18:00RaynesI call it theyshouldhavegivenitarealnameinsteadofastupidsymbolthateveryonecomesupwithadifferentnamefor
18:11TimMcRaynes: You can't spell that without "threadingmacro".
18:13TimMc&(map key (remove (comp pos? val) (merge-with - (frequencies "theyshouldhavegivenitarealnameinsteadofastupidsymbolthateveryonecomesupwithadifferentnamefor") (frequencies "threadingmacro"))))
18:13lazybot⇒ (\c \g)
18:13TimMcOops, I guess you don't need *all* of those letters.
18:13arohnerI alwasy thought the official name is "thread-first" and "thread-last" for ->>
18:14TimMcMaybe I should write >-, which stitches into the call position instead of the first-arg position.
18:14TimMcI am sure that would be super-useful.
18:17amalloyqubit[01]: i just swapped all the numbers and symbols so that 9 is shift-(
18:17hyPiRionTimMc: May be useful for nested structures.
18:17Raynesamalloy: You're broken.
18:17wmealing on another note, a friend calls it ker chunk.
18:17wmealingand the reverse chunk-ker
18:21TimMcamalloy: I'd do the same if I wasn't scared of X key mapping.
18:21TimMc*weren't
18:22amalloyTimMc: you want my .xmodmap?
18:22TimMcI think Ubuntu would halt and catch fire.
18:22amalloythat's a pretty crippling phobia
18:23TimMcUbuntu is pretty crippling.
18:23TimMcI feel like I'm damned if I do muck with settings and damned if I don't.
18:23wkellystop using ubuntu! :P
18:24RaynesI think you'll be okay without numbers switched with symbols, TimMc .
18:24yonataneIn clojure's source code, what is RestFn for?
18:24TimMcwkelly: Planning on it.
18:42amalloy&(ancestors (class (fn [])))
18:42lazybot⇒ #{clojure.lang.IObj java.lang.Runnable clojure.lang.IFn java.lang.Object java.io.Serializable clojure.lang.AFunction java.util.concurrent.Callable clojure.lang.IMeta clojure.lang.Fn java.util.Comparator clojure.lang.AFn}
18:42amalloy&(ancestors (class (fn [& args])))
18:42lazybot⇒ #{clojure.lang.IObj clojure.lang.RestFn java.lang.Runnable clojure.lang.IFn java.lang.Object java.io.Serializable clojure.lang.AFunction java.util.concurrent.Callable clojure.lang.IMeta clojure.lang.Fn java.util.Comparator clojure.lang.AFn}
18:43yonatane&(ancestors (class (fn [x])))
18:43lazybot⇒ #{clojure.lang.IObj java.lang.Runnable clojure.lang.IFn java.lang.Object java.io.Serializable clojure.lang.AFunction java.util.concurrent.Callable clojure.lang.IMeta clojure.lang.Fn java.util.Comparator clojure.lang.AFn}
18:43yonatane&(ancestors (class (fn [x & args])))
18:43lazybot⇒ #{clojure.lang.IObj clojure.lang.RestFn java.lang.Runnable clojure.lang.IFn java.lang.Object java.io.Serializable clojure.lang.AFunction java.util.concurrent.Callable clojure.lang.IMeta clojure.lang.Fn java.util.Comparator clojure.lang.AFn}
19:12yonataneWhat is RT.setValues for? I don't see any usages.
19:20timsgardnerhey, I'm a beginner at elisp, and was wondering if anyone has a .init snippet to disable slime-mode for .cljs files? thanks
19:26qubit[01]amalloy: oh nice, can I have your modmap ?
19:28amalloyhttps://gist.github.com/ccc1d89be6893ca6ef3f
19:31qubit[01]sweet trying it out
19:36yonataneDo you think partial could be enhanced to do this: (partial f _ _ arg _ arg2) ?
19:37yonatane#(f % %2 arg %3 arg2)
19:38amalloyyou just did it, congratulations!
19:38yonataneyeah, i wanted to compare
19:40yonatanewait, that's wrong
19:41yonatane#(apply f (conj [% %2 arg %3 arg2] %&))
19:41yonatanesomething like that
19:44yonataneSo yeah, the enhancement is useful i think
19:45Jayunit100I wonder if there is a good way that clojure can improve its stack traces so that they are shorter and more concise without hiding anything.
19:47nicholasfanyone know a redis client that can publish to a pub-sub channel?
19:48nicholasfnm found one. Couldnt on Friday
21:32locojay1hi is there a way to rename a project using leiningen. rename project.clj , namespaces... could do so bash sed script but if it already exists?
22:54isaacgggI am trying to call a vector of functions that each start an oscillator from the overtone framework when called, like so `(doall (map #(%) [(create-inst 400) (create-inst 50)]))`. This code returns each instrument in a list but I can only hear one- the last in the vector. Any clues as to why I don't hear each instrument?
23:13amalloyisaacggg: probably need to ask overtone folks about that. certainly all the functions are being called, but perhaps calling an overtone instrument stops the others, and you have to do something else to combine them
23:15brainproxywhat are the correspondences between graph databases like OrientDB and Neo4j and Datomic?
23:16ro_sthow many datomic peers do i need for a single-server setup? app+database on the same box
23:16ro_st1 or 2?
23:18isaacgggamalloy: thanks! I'll check with that crew
23:18technomancyisn't there an IRC channel for datomic?
23:19ro_stthere is. i've asked in there too :-)
23:19brainproxytechnomancy: oh, didn't realize that
23:31madsyHm.. in clojurescript it seems that converting from vectors to Float32Array doesn't work as intended.
23:31madsyBut array to Float32Array is fine.
23:31madsyAm I missing something, or do I really need the extra step?
23:33madsyLike: (let [foo [1 2 3]] (. someMethod someObject (new js/Float32Array (array foo))))
23:34madsyOk, I guess "array" is the only way to map between ClojureScript containers and js arrays. And Float32Array in js is compatible with normal js arrays
23:37ro_stprobably been reported already. clojars.org ssl is broken
23:38ToxicFrogSay I have a function that returns either a string or a vector of strings. I want to call another function on its result, unpacking the vector if there is one
23:39ro_st(if (seq? arg) (map fn arg) (fn arg))
23:39ToxicFrogIs there a better way to do this than something like (let [result (g)] (if (string? result) (f result) (apply f result)))?
23:39ToxicFrogro_st: I want apply, not map, but thanks
23:39ro_sti don't think so
23:40ro_stunless f in this context knows how to deal with both internally, which probably means the same code :-)
23:40ToxicFrogOk, thanks
23:41madsyToxicFrog: What is f? Your own function or an existing one?
23:42ToxicFrogf is provided by the caller of this library, so I have no guarantee it handles both
23:42madsyaha
23:42ToxicFrogSo I'd rather have a consistent callconv (either it's always passed a seq, possibly of one element, or it's always passed multiple arguments)
23:42madsyWell, you could make that a part of the usage policy
23:42madsyf must be a function with such-and-such overloaded entrypoints
23:42ToxicFrogYeah, but the code has to be somewhere, might as well put it in my library and make life easier for the users
23:43madsysure
23:43ToxicFrog(the actual output is from re-find, which returns either a string if there were no captures, or a vector of strings if there were; this kind of annoys me)
23:44madsy:)
23:45ro_st+1
23:45ro_stemacs plays hard to get but it's so worth it
23:46technomancyahem; the preferred terminology is "inc", dude
23:46ro_st-grin-
23:46ro_stor is that (grin)?
23:46ToxicFrogMy experience with emacs has been that I would probably have loved it ten years ago when I had enough free time that I didn't mind spending ages rummaging around in the guts to get things working
23:46ToxicFrogBut these days, not so much
23:46technomancypreferred nomenclature, rather
23:47ro_stToxicFrog: i swore non-stop for a week getting used to it.
23:47technomancymy lebowski-quoting is hindered by the fact that clojurebot doesn't respond to the apropos-dude command
23:47madsyHm, so I got webGL working with ClojureScript.
23:47ToxicFrogro_st: after a month of fiddling I had it about where JEdit was with twenty minutes of configuration.
23:47ToxicFrogAfter two months it was better.
23:48ToxicFrogAfter two and a half months it broke entirely.
23:48ro_stdid you keep your .emacs.d in git?
23:48ToxicFrogYes, but at that point I was just sick of the entire thing
23:48ToxicFrogIt's a great editor if you're willing to write your own edit
23:48ToxicFrog*editor
23:48ToxicFrogI'm not
23:48ro_sti guess it depends what you want
23:49madsyThink I'm going to abstract away the differences between js/WebGL and java/OpenGL
23:49ro_sti grabbed overtone/emacs-live, added magit, changed font and colours, and added stuff like linum and maxframe
23:49madsySo I can develop with my proper REPL instead of doing ass debug printing in the js console
23:49ibdknoxtechnomancy: quick question for you. I have my own version of clojure for this lein plugin and I need it to supplant the other versions of clojure that might be in someone's project
23:49ro_stmadsy: do you have a technique for sharing code between clj and cljs?
23:50ibdknoxtechnomancy: I do this locally by just building my own clojure and keeping it in the same group. But I can't do that if I want to give out my plugin
23:50ro_stmadsy: i'm about to embark on a cljs project but i'd -really- like to do all the model stuff in clj so i can use repl+midje-mode
23:51madsyro_st: Except for the fact that cljs code is a subset of clojure code, no.
23:52technomancyibdknox: yeah, in that case you need a separate group-id plus a top-level exclusion of the real org.clojure/clojure
23:52ibdknoxI didn't know there were top-level exclusions
23:52madsyro_st: You could keep yourself to the subset of functionality that exist in both clojure and cljs, and then have the platform-specific code hidden in a library/namespace
23:52technomancyit's just a hack; it's implemented by adding exclusions into each dependency before it reaches aether. but it gets the job done.
23:52ibdknoxtechnomancy: hah, learn something new every day :) Thanks
23:53technomancysure
23:53technomancyI've noodled a bit on the idea of mapping coordinates to source control trees to be able to track forks and non-linear version progression, but that's just been brainstorming so far.
23:53ro_stline dropped, madsy, did you say anything after 'subset of clojure' ?
23:54emezesketechnomancy: like some kind of version vector?
23:54madsyro_st: Yes. I said you could keep yourself to the subset of functionality that exist in both clojure and cljs, and then have the platform-specific code stashed in an external library.
23:55technomancyemezeske: no, some sort of separate data store that could map coordinates to repo/sha pairs and could compare repo/sha pairs
23:55technomancybut I don't think it would be that useful
23:55ro_stmadsy: one approach i found was github.com/lynaghk/cljx
23:55technomancyprobably not enough to justify the huge implementation effort anyway
23:56ro_sti'm talking about some automated way to have the same code available to both the server and the client via a simple :require statement
23:57madsyro_st: Looks useful. Though I wouldn't like to mix cljs and clj code in the same file
23:58madsyI have still nightmares of C++ #ifdef's
23:58madsy:)
23:59ro_sti guess i can just copy/paste code from clj to cljs, but this is lisp, damnit! there must be a way
23:59ro_stlisp is supposed to be the One -grin-