#clojure logs

2012-05-28

00:04technomancyamalloy: CL's reader syntax for vectors implicitly quotes
00:04technomancyit's indescribably horrid.
00:15amalloyyes, that's how i remembered it, but i thought maybe my mind was just blocking out some even more painful memory
00:38OwenOuhi, i would like to know a way to improve this piece of code, (defn make-keyword [word]
00:38OwenOu (let [word (str/trim word)]
00:38OwenOu (->> (str/split word #"(\s+|-|_)")
00:38OwenOu (map str/lower-case)
00:38OwenOu (interpose \-)
00:38OwenOu str/join
00:38OwenOu keyword)))
00:38RaynesIt looks a lot better on refheap.com. :p
00:38OwenOudon't like the "let" to trim the word, but not sure how to pass word into "str/split"
00:38RaynesWhat is this code meant to do?
00:39Raynes(And seriously, if you don't mind, paste it on refheap.com)
00:39OwenOuRaynes: make a random string into keyword
00:39RaynesIs there a particular reason you can't just use 'keyword'?
00:39OwenOuhttps://www.refheap.com/paste/2893
00:40OwenOuRaynes: the string can be separated by space
00:40RaynesOne thing: ##(keyword "foo_bar") ; you can have underscores in keywords.
00:40lazybot⇒ :foo_bar
00:41OwenOubut how about "foo bar"?
00:41amalloyyou usually shouldn't be making random strings into keywords anyway
00:42amalloybut it's perfectly possible to just leave in the space: ##(keyword "pretty much any string can be a keyword")
00:42lazybot⇒ :pretty much any string can be a keyword
00:43OwenOuamalloy: i would like to convert the space to "-" and append the string
00:44RaynesWell, the point is that you probably don't need to.
00:44OwenOumy problem is if i make str/trim as the first function in ->>, i can't pass its result to str/split
00:44RaynesKeywords can have spaces in them. More importantly, why do you need keyword for this particular problem?
00:44Rayneskeywords*
00:45OwenOuRaynes: maybe not necessary a keyword, i just need to make it as the key for a map, it can be string
00:45OwenOubut the requirement is to replace all spaces with "-"
00:45OwenOusay "foo bar" -> "foo-bar"
00:46Raynes&(.replace "foo bar" " " "-")
00:46lazybot⇒ "foo-bar"
00:46OwenOuRaynes: but str/trim has to come first, otherwise " foo bar" -> "—foo-bar"
00:47RaynesNote that the existence of ->> does not necessarily mean it is a requirement.
00:47RaynesIf your code doesn't work right with it, it probably isn't the pattern it is designed for.
00:47OwenOudoes ->> only work for function that takes the previous result as the last argument?
00:48OwenOulike str/split, the argument i get for the previous result, e.g., str/trim, is not the last one, e.g., (str/split word #"\s+")
00:49OwenOuword is in the middle
00:50Raynes&(-> " foo bar baz_quux" clojure.string/trim (clojure.string/replace #"(\s+|-|_)" "-"))
00:51lazybot⇒ "foo-bar-baz-quux"
00:51RaynesOwenOu: ^
00:52Raynes&(-> " foo BAR baz_quux" .toLowerCase clojure.string/trim (clojure.string/replace #"(\s+|-|_)" "-"))
00:52lazybot⇒ "foo-bar-baz-quux"
00:52RaynesThat should do the same thing you wanted, right?
00:52RaynesI would just use the string rather than convert to a keyword though.
00:52OwenOuWhat's the difference between -> and ->>
00:53Raynes(-> foo (bar baz)) = (bar foo baz); (->> foo (bar baz)) = (bar baz foo)
00:53RaynesThe difference is that -> threads each form in as the second argument, while ->> threads it as the last.
00:54OwenOuRaynes: what if i need both?
00:54OwenOui guess i have to (-> ( ->> xxx) xxx)
00:55RaynesOr just don't use either of them.
00:55metellusthen neither will help on its own
00:55OwenOui guess i would need comp and partial in this case?
00:55RaynesYou don't *have* to use these things just because they exist. If they make one particular piece of code easier and cleaner to express, then use them. Otherwise don't.
00:55RaynesFor what case?
00:56RaynesThe code I just gave you should suffice, right?
01:02OwenOuRaynes: that's sufficient, still trying to understand the difference between -> and ->>
01:02OwenOuthanks
01:02coventryWhat does it generally mean when the repl just says "; Evaluation aborted" without providing a backtrace?
01:03Raynescoventry: Means you should type (pst *e)
01:03Raynes:p
01:04coventryThanks. Why does that happen? (I'm doing this in swank, in case it matters.)
01:04RaynesUsually swank opens up a buffer with the stacktrace.
01:04RaynesNot sure I've ever seen it not do that.
01:05OwenOuRaynes: can u help me to understand why it uses ->> here? https://www.refheap.com/paste/2894
01:05OwenOuthis is an example from the clojure programming book
01:06amalloyi used to always get stacktraces, and then eventually i did something (what?) and now like a quarter of the time, just ; Evaluation aborted
01:06coventryRaynes: I'm sure it's wrongheaded clojure code, but I have some which is reliably having that effect: http://pastebin.com/tiLTmJW9
01:07coventryIt's happening to me less frequently than that. Maybe a tenth of the time.
01:07amalloycoventry: whaaaaat is that code
01:08coventryThat is my ongoing attempt to solve 4clojure problem #69.
01:08amalloyhey, that was my guess!
01:09amalloyor at any rate it looks like an attempt to write merge-with
01:09coventryyep
01:10amalloywell, the first issue seems to be that you're using contains? wrong
01:10amalloy~contains
01:10clojurebotcontains? checks whether an indexed collection (set, map, vector) contains an object as a key. to search a sequence for a particular object, use the `some` function, which accepts a predicate. if you want to only match a certain object, you can use a set as the predicate: for example, (some #{5} (range)) finds the first occurrence of 5
01:10amalloylike, you're mapping over the values of mm, and then treating those as if they were keys in s/mm
01:11coventryOhhh, I'm such a dope. Thanks for the pointer.
02:47MalondronHi, I have a clolurescript question: I am not really familiar with javascript, but am using it for some simple things. Now I want to change to clojurescript. NowI have a problemthough: how do I access specific elements in an element containing a list(vector) of items ,e.g. the different option items in an select element? (.. form -select-name -options) gives me the list of options, but I cannot find out a way to get the [0] element. I
02:47Malondronthink I have tried every likely way now without luck.
02:49ivanmaybe `into` the Array into a vector first?
02:50ivansome CLJS users here might know better
03:00borkdudeMalondron what is the type of your collection?
03:01borkdudeMalondron don't know much about clojurescript, but if the collection is seqable, you can just call first on it: &&(first [1 2 3])
03:02amalloygood try, borkdude: ##(first [1 2 3])
03:02lazybot⇒ 1
03:03borkdudeamalloy I keep forgetting this notation ;)
03:05kmicu# # , & where is this notation specified? :)
03:05kmicuMalondron: Why not simply ,(nth '(1 2 3) 2)
03:16pepijndevosWhat constitutes a "conditional put" in datomic? Is that just compare-and-set! behavior?
03:17kmicupepijndevos: try in #datomic channel if you don't get answer here
03:17MalondronHi, I guess the problem is that I don't know what type of collenction I acttually get from the above code. The translated code is: form.select-name.options, which is fine. I just cannot get a .[0] to show up in the translation in any way. first does not work, -[0] does not work, 0 does not work :0 does not work, (options 0) does not work, etc.
03:18kmicuMalondron: but this is in js not cljs?
03:20MalondronWell, I am translating into javascript.
03:20borkdudeMalondron you can call type on it
03:20borkdude,(type [1 2 3])
03:20kmicuMalondron: but where you can't acces in js or cljs? :)
03:20clojurebotclojure.lang.PersistentVector
03:22kmicu// collection access is first class (def m {:foo 1        :bar 2}) (get m :foo) (def v ["red" "blue" "green"]) (nth v 0)
03:22kmicu// map access is a static// language feature var m = {  "foo": 1,  "bar": 2}; m["foo"];m.foo; // array access is a static// language feature var a = ["red", "blue", "green"];a[0];
04:01alex_baranoskydoes anyone have sagely wisdom on why some functions have :ns and :name metadata on them, but others don't?
04:01amalloyalex_baranosky: not many functions do. if you think they do, you're probably looking at the metadata on the var, not the function
04:03alex_baranosky,(meta integer?)
04:03clojurebotnil
04:05alex_baranosky&(meta integer?)
04:05lazybot⇒ nil
04:06alex_baranoskyahhhhh it is a 1.2 to 1.3 thing,
04:06alex_baranoskywe're still using 1.2 here
04:06alex_baranoskyif you wanted a the name a of a given function how would you go about getting it?
04:07amalloyyou can't
04:07alex_baranoskydang
04:07amalloyfunctions don't have names
04:07alex_baranoskythey do in 1.2
04:07alex_baranosky:)
04:07alex_baranoskyat least a lot of them do
04:07amalloymeh. def was broken
04:08amalloydid some weird shit with copying metadata from vars to functions, sometimes, for no real reason
04:08amalloyor that was defn, i guess? i dunno
04:08alex_baranoskyis there a way to achieve a similar result without needing to us a macro to snag the symbol , and other crap I don't want to stoop to?
04:08alex_baranoskybasically I want to accept any predicate for my function, and then printout "Your predicate 'foo?' filed…"
04:09amalloy&(let [named-first (with-meta first '{:name first})] (name (meta named-first))) ;; not very satisfying, huh?
04:09lazybotjava.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Named
04:09alex_baranoskyfailed*
04:09amalloy&(let [named-first (with-meta first '{:name first})] (:name (meta named-first)))
04:09lazybot⇒ first
04:09amalloyyour function has to be a macro
04:10amalloyand even then it won't work very well because what if they pass an anonymous function?
04:10alex_baranoskyanonymous functions are all bets off, but… I figured I'd live with that
04:10alex_baranoskyworth the tradeoff in simplicity
04:10amalloyit doesn't sound simpler. easier, maybe
04:11alex_baranoskyI could change my code to accept a predicate and a predicate-name, and then wrap a thin macro layer around it to get the name of the predicate symbol and pass it in
04:11MalondronWell, let's say I want to set the first option in a select element in a form. I want to write: (set! (first (.. form -select-name -options)) (js/Option. "New" "New")), but this fails as first does not work with the compiler (nor does nth, or any other reasonable "usual" clojure way to use collections). And the problem is not with set!; trying to access the value property fails as well, so I am not getting the first (or nth 0)
04:11Malondronelement. At least not in the form I want.
04:11alex_baranoskyit is easier and simpler
04:12alex_baranoskyadding a layer of macros just to get a predicate's name seems silly
04:12borkdudecan protocols be used to "alter" the toString of, let's say a ClasscastException?
04:12alex_baranosky(which is what I was suggesting it was simpler than)
04:12alex_baranoskyI think the answer to that is no
04:13alex_baranoskythanks smalloy for the info
04:13alex_baranoskynow I don't want to move to 1.4 ;)
04:15borkdudefor example, what's going wrong here? https://www.refheap.com/paste/2897
04:55MalondronActually, I just found out that aget/aset does what I want in this case.
05:41DvyjonesAny idea why this outputs question marks instead of the ticks it's supposed to output? https://gist.github.com/2818174
05:47kralnamaste
05:47rodnaphDvyjones: where are you viewing the output? font probably doesn't support those characters.
05:53mittchelWhy am I getting a nil when I do the following: (my-map :a) in this function: (defn my-map {:a "appel" :b "peer"})
05:53mittchelmaps are supposed to behave as functions, right?
05:56andyfingerhut({:a "appel" :b "peer"} :a) will do what you are expecting. So will ((my-map) :a) -- note the extra parens so that my-map is called with no args, and the return value of a map is then used as a function.
05:57andyfingerhutYou'll have to change it to (defn my-map [] ...) to specify the function takes no arguments, though.
05:57mittchelHm thanks.. probably an mistake in the course :P
05:57Dvyjonesrodnaph: In my console, and the font does support those characters.
05:58mittchelandyfingerhut: when I try that Im getting: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: user$my-map (NO_SOURCE_FILE:0)
05:58rodnaphDvyjones: are you going through the REPL?
05:59andyfingerhutwhen you try what?
06:00mittchel9
06:00mittchel((my-map) :a)
06:01andyfingerhutAfter changing the defn to (defn my-map [] {:a ...}) ?
06:01Dvyjonesrodnaph: Nope.
06:01mittchel(get my-map :a) returns nil too lol
06:01Dvyjonesrodnaph: Well, I tried importing that into the REPL, and that failed too.
06:01andyfingerhutAre you sure you don't want (def my-map {:a "appel", ...}) (note def not defn)
06:02andyfingerhutthat will define a var called my-map that you can use the way you are describing, rather than a function.
06:02mittchelYe
06:03mittchelthankyou :D
06:03andyfingerhut(def my-map {:a "appel" :b "peer"}) (my-map :a) => "appel"
06:03andyfingerhutnp
06:03rodnaphDvyjones: not sure then sorry mit. Try (println "CHAR") in various places (shell, repl) to see where the problem is.
06:27mittchel() are literals for lists right? Since (= '(3 4 5) (map (partial + 2) [1 2 3])) results in (3 4 5)
06:28borkdudemittchel '(1 2 3) equals to (list 1 2 3)
06:30mittchelYep I know cause ' makes sure that it doesn't see the 1 as a function with arguments 2 and 3.. but when I do the following in the repl: (map (partial +2) [1 2 3])) this gives me (3 4 5).. is this a map as a result or a list? Cause I thought () was the literal for a list:P
06:30borkdudemittchel it is a sequence
06:30RaynesIt is a seq.
06:30borkdude,(type (map (partial + 2) [1 2 3]))
06:30clojurebotclojure.lang.LazySeq
06:31borkdudemittchel a sequence is printed as (. . .)
06:31mittchelAlright, thanks..
06:31mittchelso basically a list can be seen as a sequence too?
06:31borkdudemittchel yes
06:32borkdude,(seq? (list 1 2 3))
06:32clojurebottrue
06:32lucianafaik, they just both print the same
06:32mittchelPff I'm always messing that up :P
06:32lucian,(seq? [1 2 3])
06:32clojurebotfalse
06:32lucian,(seq? (seq [1 2 3]))
06:32clojurebottrue
06:32lucianok, so i'm wrong
06:34mittchel,(seq [1 2 3])
06:34clojurebot(1 2 3)
06:34mittchel,([1 2 3])
06:34clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector>
06:34borkdude,[1 2 3]
06:34clojurebot[1 2 3]
06:34mittchel,[1 2 3]
06:34clojurebot[1 2 3]
06:34mittchelye hehe
06:34mittchelse you are actually right lucian.
06:36mittchel,(clojure.set/intersection #{1 2 3 4} #{3 4 5 6})
06:36clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set>
06:37borkdude&(clojure.set/intersection #{1 2 3 4} #{3 4 5 6})
06:37lazybot⇒ #{3 4}
06:37borkdudemittchel apparently, clojurebot has not required clojure.set
06:37mittcheltoo bad
06:37borkdudemittchel but you can also use lazybot with &
06:38mittchelWhat's the difference between those two?
06:38borkdudemittchel also you can evaluate an expression like this: ##(+ 1 2 3)
06:38lazybot⇒ 6
06:38borkdudemittchel they are two different bots
06:38mittchelahh
06:38borkdudemittchel http://www.unexpected-vortices.com/clojure/brief-beginners-guide/getting-help.html
06:39mittchelthats much easier
06:40borkdudemittchel lazybot was implemented by Raynes I believe
06:41mittchelIt comes in very handy
06:49leo2007I started swank-clojure in a terminal and connect to it from emacs.
06:50leo2007but I must provide emacs with the real IP address (i.e. not localhost or 127.0.0.1) otherwise it won't connect.
06:50leo2007ideas?
06:50leo2007I can connect to my CL swank server using localhost
07:52kilonanyone here used Quil with Clojure, wondering how mature really is
08:03soulmanhello
08:06mrphoebshi @soulman
08:06soulmani'm searching for a possibility to splice a list as flat function arguments
08:06mrphoebsuse apply
08:07soulmane.g. a list of elements as sub elements of an xml element
08:07soulman(element {} (<splice> (map element-list coll))
08:08soulman)
08:08mrphoebshmmm
08:11mrphoebs@soulman you want to flatten the list
08:11mrphoebs?
08:12soulmanbut it's still a list after flattening
08:20the-kennysoulman: You want something like (magic + (list 1 2 3))?
08:21soulmanyep
08:21PKHGraek: hello, you helped me yesterday, isn't it? got lein working too in Emacs (all on Vista) ;-)
08:21the-kennymagic is called apply ;)
08:21the-kenny,(apply + (list 1 2 3))
08:21clojurebot6
08:24pepijndevosWhat happens to a protocol when you AOT it?
08:26PKHGHallo, busy with clojure since yesterday a newbie :-) How do I do this: a bunch of *java files form webcompmath at sourceforge and is it possible to use those in clojure , a link explaining this maybe?
08:27soulmani need something like (magic xfn stuff [1 2 3]) where xfn is defined like (defn xfn stuff & content) but content is treated as a single argument when you give it a coll
08:27G0SUBsoulman, apply
08:27mrphobesHi PKHG
08:27G0SUB,(apply + 1 [2 3 4])
08:27clojurebot10
08:27soulmanlike data.xml element
08:28mrphobesClojure can import any complied java files as long as they are on the classpath
08:28soulman=> (doc element)
08:28soulman-------------------------
08:28soulmanclojure.data.xml/element
08:28soulman([tag & [attrs & content]])
08:29G0SUBsoulman, couldn't understand your problem.
08:35PKHGmrphobes: hmm you mean I have to compile my *.java into a jar and then ... how to define a classpath in clojure?
08:37mrphobesPKHG: this talks about how classpath with repl http://lpsherrill.blogspot.in/2009/05/clojure-classpath-made-easy.html
08:37PKHGthanks looking at your linkg ;-)
08:37mrphobesIf you are working on a project using 'lein' the simplest way would be to put your jars in the lib directory, but this is not the right way
08:38mrphobesThe right way is to include the jar as a dependency in lein
08:38mrphobesnp
08:40mrphobes@PKHG also look at this http://stackoverflow.com/questions/2121670/how-do-i-include-java-stuff-in-jar-files
08:40PKHGnext to read ;-)
08:44PKHGhmm yes I think now what to do with CLASSPATH ... THANKS!
08:44soulmanG0SUB: to state it as plain as possible, I want to create an xml element with a list of elements as content.
08:45G0SUBsoulman, doesn't "apply" work in your case?
08:45soulmanthe list of elements is created dynamically and the elements contain sub elements so flatten doesn't do the job. it flattens to much
08:46soulmanapply doesn't seam to do the job because of the tag name and the attributes of the element fn
08:47G0SUBsoulman, some example code would help.
08:57soulmanG0SUB:
08:57soulman(defn xml-element [el]
08:57soulman (element :b {}
08:57soulman (element :c {:name (:name el)})))
08:57soulman(defn xml-elements [coll]
08:57soulman (element :a {}
08:57soulman (map xml-element coll)))
08:57soulman(indent-str (xml-elements [{:name "Hello"} {:name "World"}]))
08:57soulman#<IllegalArgumentException java.lang.IllegalArgumentException: No implementation of method: :emit-element of protocol: #'clojure.data.xml/Emit found for class: clojure.lang.LazySeq>
09:00G0SUBsoulman, looking
09:00soulman(defn xml-elements [coll]
09:00soulman (apply element :a {}
09:00soulman (map xml-element coll)))
09:01G0SUBsoulman, can you paste all the code somewhere?
09:01G0SUBsoulman, refheap.com
09:01soulmanseems to work in this case ;-)
09:02soulman"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a>\n <b>\n <c name=\"Hello\"/>\n </b>\n <b>\n <c name=\"World\"/>\n </b>\n</a>\n"
09:02soulmanthat's what I like to see. ;-)
09:03G0SUBsoulman, paste the code and your comments on refheap.com and I will take a look.
09:03soulmanG0SUB: thanks for making me build a simple sample code. The problem seems to be lurking in some of my own code.
09:04G0SUBsoulman, that's what I thought.
09:04soulmanrubber ducking ;-)
09:04G0SUBsoulman, it's always better to find a minimum test case to track down problems.
09:07dan_bcripes, how much easier is it to install clojure these days than it used to be?
09:08soulmanG0SUB: sure, and select isn't broken ;-)
09:16tominatedHello
09:16tominatedcan anyone here help me with an issue I'm having with compojure?
09:18rodnaphdepends on what the issue is!
09:18tominatedhaha i'm getting an exception when browsing to a route
09:18tominatedI have it on github at https://github.com/tominated/twitface
09:19rodnaphwhat's the exception?
09:19tominatedclojure.lang.ArityException: Wrong number of args (3) passed to: PersistentArrayMap
09:19rodnaphsounds like you've missed the args [] from ur handler?
09:19rodnaphwhich route exactly?
09:20tominatedit happens whenever I use the routes included from the controller files, which are '/users/', '/posts/' and 'comments'
09:21rodnaphtominated: try taking the parenthesis off your index function. ie. (GET "/posts/" [] index)
09:22tominatedwill do
09:22rodnaphthey you might have to add the ring request object as a parameter to your handler, (defn index [req] ...)
09:23tominatedyeah that seems like the case
09:23tominatedit just had an exception saying there was too many arguments
09:25tominatedhmmmm odd
09:25tominatedthat goes back to the same exception
09:25tominated2012-05-28 23:20:37.605:WARN:oejs.AbstractHttpConnection:/posts/
09:25tominatedclojure.lang.ArityException: Wrong number of args (3) passed to: PersistentArrayMap
09:30rodnaphtominated: it's probably the way your adding the routes in core.clj then, i've not seen that syntax before and can't imagine how it works.
09:31tominatedI was roughly following the tutorial at https://devcenter.heroku.com/articles/clojure-web-application
09:31tominatedit may be because they use an old version of compojure
09:31tominatedthere were a few things I had to change because of outdated packages
09:35kilonanyone can show me instructions on how to install leiningen in windows ?
09:35tominatedrodnaph: I may just chuck all the routes in the core file
09:36rodnaphor import them by calling the controller functions eg. (my.controlls/routes)
09:38tominatedhow do you mean?
09:39coventryHow do I turn a list of chars into a string?
09:40coventryNever mind, I forgot to google first.
09:41tominatedok, it seems that the error changes when I add or remove the argument from the controller's index functions
09:42tominatedwhen I have it as (defn index [] ….) it says the following
09:42tominatedclojure.lang.ArityException: Wrong number of args (1) passed to: posts$index
09:43tominatedand when i have it as (defn index [request] …) is shows up this
09:43tominated2012-05-28 23:36:45.085:WARN:oejs.AbstractHttpConnection:/posts/
09:43tominatedclojure.lang.ArityException: Wrong number of args (3) passed to: PersistentArrayMap
09:43tominatedwait a second
09:45tominatedit seems like it may be my template that's screwing up
09:53tominatedOh you have got to be kidding me
09:54tominatedit was because I was using a now non-existent function
09:56tominatedrodnaph: thanks for all your help!
10:01pandeirois there something i can install to paste to refheap directly from emacs?
10:02tmciverpandeiro: yes, there is a refheap package.
10:03pandeirotmciver: available from marmalade? is it called refheap?
10:03tmciverpandeiro: yes, just do a search for 'refheap' after doing M-x package-list-packages
10:05pandeirohmmm, marmalade-repo.org is down i think
10:05pandeiroouch and package-list-packages is blocking
10:06tmciverah, yes, it is for me too.
10:08michaelr`is there a way to break execution at the repl?
10:09pandeirotmciver: finally went through but i don't see any refheap package
10:09pandeiromaybe that's stale, site still seems to be down
10:13pandeirook i typed it in by hand: https://www.refheap.com/paste/2898
10:15pandeiromichaelr`: i think C-c C-c does it no?
10:16tmciverpandeiro: yes, I do see the refheap package now. I have version 0.0.1.
10:16twhumeHi, I'm trying to flatten a sequence of sequences of sequences… but not completely. What I have is the sequence (((:istore 0 :istore 0) (:istore 0 :istore 1) (:istore 1 :istore 0) (:istore 1 :istore 1)) ((:ixor :ireturn))) and what I'd like is ((:istore 0 :istore 0) (:istore 0 :istore 1) (:istore 1 :istore 0) (:istore 1 :istore 1) (:ixor :ireturn)) … any ideas? (clojure n00b)
10:18Bronsa,(mapcat identity '(((a b) (c d)) ((e f))))
10:18clojurebot((a b) (c d) (e f))
10:19twhumeBronsa: aha, thank you. Is there any magic in that, or will a read through docs make it clear? ;)
10:19Bronsano magic
10:21Bronsa,(reduce concat '(((a b) (c d)) ((e f))))
10:21clojurebot((a b) (c d) (e f))
10:21pandeirotmciver: yeah my package list is out of date and marmalade is not responding... oh well... wanna help me with my macro? ;)
10:24tmciverpandeiro: I would but my macro experience is almost non-existent. :/
10:25_Azrael_Cbg
10:26_Azrael_Fuckkkkkkkk
10:27pandeirowow the slime repl remembers history from previous sessions...
10:42scottjdoes :jvm-opts ["-Xmx256M"] cap just the map, or also the lein process jvm? is there is there a separate option for that?
10:42scottjs/map/app/
10:44p_lscottj: I believe the app, because lein can't exactly change those options after launching (unless it relaunched itself, and lein is slow enough without doing that)
10:47rvgate How do i remove an entry within an atom using clojure?
10:48KIMAvcrpwhat is stored in your atom ?
10:49rvgateKIMAvcrp, currently the atom has: {"agrg" {:title "agrg", :authors "wrrk", :publisher "wadst"}, "bla" {:title "bla", :authors "Henk", :publisher "piet"}}
10:50rvgateand im trying to create a simple function (defn delete-book [title]
10:50lucianrvgate: you're probably looking for dissoc, to replace the atom's value with another
10:51lucianrvgate: something like (swap! book dissoc title)
10:53rvgatethank you lord \o/
10:53rvgatethats you lucian :P
10:53luciani'm glad it helped :)
10:54rvgatejust learning clojure, no offence, but the documentation is horrible :/
10:55pandeirorvgate: http://clojure.org/api ?
10:55rvgatepandeiro, there is documentation, yes... but some descriptions and examples are weird
10:56pandeirorvgate: do you use the repl?
10:56rvgateofcourse
10:56rodnaphi concur! the clojure docs assume a *lot* of knowledge. here's a great example of assuming a lot of stuff: http://clojure.org/macros
10:57pandeiroyou know (dir ...) (doc ...) etc?
10:58rvgateanother example: http://clojure.org/atoms, am i the only one that finds it weird that the example on that page seems inrelevant... i dont see why elapsed time has anything to do with atoms...
10:59mfexthe documentation on clojure.org is a reference, not a tutorial. for that a book is better
10:59gfredericksrvgate: the elasped time bit there is demonstrating that the naive fib algorithm is speeded up by memoization
10:59rvgategfredericks, and how is that relevant to atoms?
10:59gfredericksit's a bit indirect, but it relates because memoize is implemented with an atom
11:02pandeirorvgate: clojuredocs.org and clojure.org/cheatsheet <- the latter shows you the principal functions for dealing with atoms
11:04gfrederickssomebody could start a clojure-newb-docs project which, when included, replaces all the docstrings in clojure.core :)
11:08rvgatei think the docs should show simple examples, using clear variable names (not using x y z, m, ret, etc etc) so everything becomes more understandable :P but thats just me
11:14justintanyone know if there's a marmalade-repo mirror anywhere? it seems to be down
11:21rvgatelucian, sorry to bother you again, assoc inserts, dissoc deletes... but how do i update?
11:21lucianrvgate: assoc with the key you want
11:21rvgateseriously....
11:22lucianrvgate: assoc just returns a new map with that value at that key
11:22gfredericks,(assoc {:a 1 :b 3} :b 20)
11:22clojurebot{:a 1, :b 20}
11:27soulmanhi
11:28lucianrvgate: what other language are you more comfortable with?
11:30soulmanif i compile some code with clojure, referenced jar files get unzipped to *clojure.compile.path*. Is that correct?
11:31soulmanso they land in the resulting jar file which i build from *clojure.compile.path*?
11:34edwRunning in the SLIME REPL, (clojure.java.io/resource ".") returns a URL to my project's test directory. This puzzles me. Shouldn't it return a URL to the project root?
11:39wmealing_in the interest of anti wheel re-invention is there a jar which watches a directory and can load the files (kind of like a plugin loader ?)
11:39edwThere's watchtower on github.
11:39edwIt's crude but effective.
11:39mfexsoulman: no; referenced jars are not unzipped, perhaps you are looking for "lein uberjar" which packages a project and all its jar dependencies into one jar
11:40wmealing_edw, ok
11:40edwIt doesn't using any kqueue-like fancyness: it polls.
11:41wmealing_thats probably good enough for now
11:42edwSomething more sophisticated might require JNI: I don't think the JVM exposes any abstraction for kqueue or similar system facilities.
12:06bordatoueanyone facing problem installing leningen 2 installation on RHEL
12:06rvgatelucian, java and php mostly... (sorry, was having dinner)
12:06wmealing_more specifically ?
12:06PKHGhello, who can help a newbie? trying to use Java from clojure: here is my problem visible: http://www.petergragert.info/pmwiki/pmwiki.php/Clojure/Applet
12:07wmealing_bordatoue, that was for you.
12:07PKHGPeter thats me ;-)
12:07bordatouei followed the instruction specified in https://github.com/technomancy/leiningen
12:07PKHGbordatoue: what is RHEL?
12:08lucianrvgate: right, so in java you'd have Map.set(key, val). you can both add and "overwrite" keys with that. just like clojure's assoc
12:08bordatouedownloaded the script , changed the mode . but when I try to execute lein self-update , i get Exception in thread "main" java.lang.NoClassDefFoundError: java/util/concurrent/Callable
12:08bordatoue at clojure.main.<clinit>(main.java:19)
12:08wmealing_el6 ?
12:08soulmanmfex: no, I'm not building with lein but with 'java clojure.lang.Compile...'
12:08bordatoueRHEL -- red hat scrap
12:09wmealing_are you on version 6 ?
12:09bordatoueyes
12:09PKHGhmm sorry, installed yesterday on Vista with lein.bat ..
12:10wmealing_bordatoue, disclaimer, i work for red hat.
12:10bordatoueKernel version is 2.6.18-194.el5
12:10wmealing_i dont think the kernel verrsion has much to do with it.
12:10wmealing_i assume the file downloaded ?
12:10wmealing_ie, you saw a progress meter ?
12:11bordatouenothing happens it throws an exception stated above
12:12wmealing_ok, el6 current here, and not getting any issues
12:12wmealing_default install.
12:12bordatouedid you just downloaded the script and executed it
12:12wmealing_yes
12:12wmealing_i'll paste you
12:12bordatouei did not use any package manager
12:13wmealing_http://hastebin.com/fajudocaku.vhdl
12:13wmealing_neither did i
12:13wmealing_do you have wget or curl installed
12:14bordatouei do have wget installed
12:14PKHGhallo again, someone used a java applet from closure?
12:15bordatouei will try deleting all the files
12:16bordatoueyou don't seem to use --no-check-certificate option for wget , could that be th reason
12:17wmealing_i'm pretty sure it is
12:17wmealing_line 128
12:17coventryIs there such a thing as an anonymous macro? I'm working on a 4clojure problem where I think a macro would be useful, but the 4clojure evaluator doesn't allow defs.
12:18gfrederickscoventry: nothing available from 4clojure I don't think
12:18wmealing_but by all means, give it a go.
12:18gfredericksthe clojure.tools.macro package has tools for that
12:18coventrygfredericks: Thanks.
12:19wmealing_bordatoue, bash -x lein self-update
12:20wmealing_maybe you're mising something, and that should show the code-path its executing
12:20bordatoueokay
12:20wmealing_however, i dont think this is a rhel "problem", you're missing something that is required/assumed to be installed
12:20bordatouehttp://hastebin.com/cayutiweti.diff
12:22wmealing_what java are you running
12:22bordatouecurrent path is set to 1.4
12:23wmealing_i dont know what that means
12:23wmealing_i'm not running third party java
12:23wmealing_and i dont think that clojure works with the older jdks
12:23bordatouejava 4
12:23wmealing_(again, i dont write java)
12:23bordatouei can try changing it to jdk 6 or 7
12:24wmealing_java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.el6.x86_64
12:24wmealing_i'm using whatever ships with el6.
12:25bordatouewmealing_: thanks, it seems to work with jdk 6
12:26wmealing_yeah, i imagine that the util.concurrent stuff isnt in 1.4
12:26wmealing_just taking a punt
12:26wmealing_thanks for calling redhat support :P
12:27bordatoueshouldn't the script doing some checks before proceding
12:27wmealing_if you think so, lodge a bug
12:27wmealing_or a patch
12:31KIMAvcrphey #clojure
12:31wmealing_the developer is here frequently, but I do think that 1.4 perhaps is a little old.
12:32wmealing_bordatoue, https://github.com/technomancy/leiningen/issues
12:32KIMAvcrpafaik util.concurrent was introduced in java 5
12:33wmealing_there ya go
12:34bordatouei am trying to clojure with emacs , still haven't figured out how to get it working
12:35gfredericksbordatoue: I think all I've ever had to do is use the swank-clojure plugin
12:35gfredericksI'm not any good for troubleshooting though
12:36bordatouecould not start swank server
12:36bordatouewhat is that about
12:37bordatouecould you please provide a link to the steps you have followed, I seem to be picking an old outdated one
12:38gfrederickshttps://github.com/technomancy/swank-clojure
12:38KIMAvcrphttp://www.google.de/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CFMQFjAA&amp;url=http%3A%2F%2Fdev.clojure.org%2Fdisplay%2Fdoc%2FGetting%2BStarted%2Bwith%2BEmacs&amp;ei=HanDT8XkHcLdtAbFnITdCg&amp;usg=AFQjCNEBjHTq8rCVLevFYiWtsZXeBezzAw
12:40KIMAvcrpthis is the recommended setup. I followed this after reinstallation of ubuntu 2 days ago and it worked out of
12:40KIMAvcrpthe box
12:52wmealing_and i can assure you it works on standard rhel, nothing magical there.
12:55peregrine81Does clojure-ring have its own IRC channel?
12:56gfredericksperegrine81: not that I've heard of
12:57peregrine81Well I will ask here. I am trying to ring.middleware.reload but its not reloading my routes file on a new request, here is the core file. http://pastebin.com/cpvc981a
12:58peregrine81it never actually reloads any of my code on file change
12:58peregrine81or ever
12:59peregrine81docs for wrap-reload are pretty basic (http://mmcgrana.github.com/ring/ring.middleware.reload.html#var-wrap-reload). I tried setting directory to "src' directly I also checked to make sure the handler is truly wrapped.
13:00gfredericksperegrine81: so you're 100% sure that (= env "DEV") is true there, right?
13:01gfredericksoh I guess you just said that more or less
13:01peregrine81Yep I print the out the handler object and see this #<reload$wrap_reload$fn__231 ring.middleware.reload$wrap_reload$fn__231@6fbdea60>
13:01peregrine81so more or less yes
13:02gfredericksand you're running this with `lein run`?
13:02peregrine81I am running it with foreman and with the following command lein trampoline run -m gameapi.core
13:03peregrine81which drops the lein process
13:03gfredericksI'm not too familiar with reload. If nobody else has any suggestions, you could try pulling in the ring project with checkouts and debugging it directly
13:04peregrine81Well the code is pretty basic https://github.com/mmcgrana/ring/blob/master/ring-devel/src/ring/middleware/reload.clj
13:04peregrine81I'd just prefer not to need to reload the entire JVM everytime I change the code
13:05peregrine81its kinda slow :P
13:06gfrederickswelp if it were me I'd do the checkouts thing and have it log which ns's it's reloading each time
13:06gfredericksmight end up debugging that ns-tracker thing after that
13:06jt123anyone know if there's a marmalade-repo mirror out there? it seems to be down
13:07peregrine81could be a difference with OSX
13:39badjerhi, does anyone use noir and enlive together? I'm running into an issue there that seems like it would come up a lot
13:56r0adrunnerHi. I want to copy a directory from one place to another using clojure. How to do that?
13:57meiji11learn to copy a file and make a directory in clojure, and build up from there.
13:57meiji11that shouldn't be hard, I'm sure clojure can talk to the shell.
13:57meiji11the rest sounds like a good job for a finite state machine.
13:58meiji11in which case, I'd go with trampoline.
14:00r0adrunnerI was looking for an one-liner. but thanks anyway
14:05gf3ibdknox: https://github.com/ibdknox/noir-cljs/blob/master/src/noir/cljs/core.clj#L5-6
14:26gfredericksr0adrunner: the fs project might have a one-liner for you
14:31r0adrunnergfredericks: Yes.. there is a "copy-dir" function. thanks
15:21Bronsastill.
15:21Bronsaops, wrong chan
15:41jsabeaudryElegant way to transform "BU0.003W0.322L" into [0.003 0.322] ?
15:43gfredericks,(map read-string (re-seq #"[\.\d]+" "BU0.003W0.322L"))
15:43clojurebot(0.0030 0.322)
15:43gfredericksmay or may not work depending on what your input domain is
15:45jsabeaudrygfredericks, thanks that is very elegant
15:48gfredericks,(mapv read-string (re-seq #"[\.\d]+" "BU0.003W0.322L"))
15:48clojurebot[0.0030 0.322]
15:55pepijndevos&(doc mapv)
15:55lazybot⇒ "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a vector consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any ... https://www.refheap.com/paste/2901
15:56pepijndevos$source mapv
15:56lazybotmapv is http://is.gd/CvFceu
15:57borkdudehas anyone got the clojurebook near him/her, I've got a question about sorting
15:57borkdudeon page 107: "how does clojure turn a predicate (function) into a comparator (Java Comparator)?"
15:58borkdudebecause you can do smth like ##(sort < [6 5 4])
15:58lazybot⇒ (4 5 6)
15:58borkdudebut sort works with comparators which return -1,0 or 1… when I look at the source of sort, I see no transforming of the predicate into a comparator
15:59borkdudeso, where does this happen...?
16:00pepijndevosborkdude: interesting... I assume fn implements it or something?
16:01raek,(supers (class <))
16:02clojurebot#{java.lang.Runnable clojure.lang.IObj clojure.lang.IMeta clojure.lang.Fn java.util.concurrent.Callable ...}
16:02pepijndevosborkdude: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/AFunction.java#L18
16:02borkdudepepijndevos great tnx! wish the info was just given in the text, in a footnote or smth :)
16:03bordatouehi
16:04bordatoueis anyone having problem with marmalade-repo.org:80
16:04bordatoueit seems unreachable
16:05raekseems to be down from here (Sweden) too
16:05pepijndevosseems to be down for me too, but: http://www.downforeveryoneorjustme.com/marmalade-repo.org:80
16:05bordatoueis there any straight forward tutorial to install clojure with emacs i have spent about a week
16:05bordatouenearly about to give on this
16:06borkdudebordatoue I think on technomancy's blog
16:06pepijndevosborkdude: Come to the dark side, we have vim and cookies.
16:06pepijndevoserm, bordatoue
16:06raekbordatoue: the most straight forward way (IMO) uses marmalade :(
16:06bordatouebut marmalade an't working
16:06borkdudehaha
16:06bordatouei can't do a package-refresh
16:07bordatoueplease i am going crazy here
16:07raekbordatoue: you could donwload clojure-mode via git
16:07raekI have never seen marmalade down before
16:07borkdudeI'm not laughing about your problem… about technomancy leaving again after his name is mentioed..
16:07bordatouecan you please check if marmalade is down
16:07raekbordatoue: for how long has it been down?
16:07bordatoueall of today
16:08bordatoueits all way down, when i sit in from of my mac book
16:08raekbordatoue: do you know how to install emacs packages without package.el?
16:08bordatoueno
16:08bordatoueas such this is complicated enough
16:09bordatoueis there any proxy ip i need to use
16:09raekbordatoue: you only need one elisp package for clojure: clojure-mode.el
16:09pepijndevosIsn't there some easy emacs starter bundle including clojure you can get?
16:09raekbordatoue: it seems to be down from here too
16:09borkdudepepijndevos technomancy made smth like this, but it works through marmalade
16:09raekit's hopefully temporary
16:09borkdudeprobably on git as well
16:09pepijndevosborkdude: samaaron also has one for overtone livecoding, I think
16:09raekbordatoue: https://github.com/technomancy/clojure-mode
16:09bordatouehow long have you guys using this marmalade
16:10raekone to two years, maybe
16:10borkdudebordatoue only when I installed clojure stuff, a while ago
16:10bordatouethat long ,
16:10bordatouei just heard about it few days back
16:10bordatoueand when i tried it , its down
16:10raekbad luck :(
16:11bordatouei will summarise what i had done so far
16:11pepijndevoshttps://github.com/overtone/emacs-live
16:11bordatouei have installed lein
16:11raekbordatoue: download the clojure-mode.el file and put it in your ~/.emacs.d/ directory
16:11bordatoueusing lein i install swank-clojure
16:11raekmarmalade is convenient (usually), but you can install clojure-mode without it
16:11bordatoueso how does the repl get started
16:12raekbordatoue: ok, that good.
16:12raekbordatoue: you invoke M-x clojure-jack-in form Emacs
16:12raekwhich is provided by clojure-mode.el
16:12borkdudebordatoue raek you have to start it from a project though
16:13bordatouewhen i invoke M-x i get an error, saying could not start swank server
16:13bordatouedo you know the cause for it
16:13borkdudebordatoue did you cd to a project in emacs?
16:13bordatoueno
16:13borkdudebordatoue or open a file from a project that is (I guess)
16:13raekbordatoue: I have an idea. could you try "M-! lein"?
16:13bordatouelet me explain, i used lein new myProject
16:14bordatouethen opened project.clj file using emacs
16:14raekok, that's good
16:14bordatouethen typed M-x clojure-jack in
16:14bordatouethen it follows wit an error
16:14raekyou should be able to use clojure-jack-in from that buffer (once everything is working)
16:14borkdudebordatoue did you load clojure-mode.el already
16:14bordatoueit says it can not start swank server
16:14bordatoueshould i manually start the swank server
16:15raekbordatoue: I think emacs can't find lein. how did you put lein on the path?
16:15raekbordatoue: no need to do that
16:15borkdudebordatoue ok great, this means you don't have the swank plugin specified in the project
16:15bordatoueokay
16:15borkdudebordatoue or have you?
16:15bordatoueso i can add lein to my path, currently it is in /usr/bin directory
16:15raekbordatoue: can you try "M-! lein version"? does it return the lein version or an error?
16:15bordatouewhich is in my path
16:16bordatouewait
16:16raekif "M-! lein version" works, then this is not the problem
16:16KIMAvcrptry to run lein swank in your project directory. does it work ?
16:16borkduderaek I think you need to specify :plugins [[lein-swank "1.4.4"]]) in your project right?
16:17borkdudeat least with leiningen2 if it is not in your profiles.clj
16:17bordatouetoo much information,
16:17raekborkdude: if using lein2, yes (but ~/.lein/profiles.clj is a better place for it)
16:17bordatouelet me try one thing at a time
16:17bordatouehow do i check if emacs is able to see lein
16:17raekbordatoue: M-! lein version
16:18bordatoueokay i have got emacs.app
16:18raekyou could do "M-x shell-command RET lein version" instead
16:18bordatoueis it Alt+!
16:18raekyes
16:18raekwell
16:19raekalt on a PC keyboard
16:19raekdunno about mac
16:19borkdudealso max
16:19borkdudemac
16:19bordatoueokay
16:19borkdudealso called the option key (alternative, option, kind of similar words)
16:19bordatoue leiningen version 1.7.1 on java 1.6.029
16:19KIMAvcrptry to run lein swank
16:19raekok, good. your lein works and emacs can find it
16:20raekbordatoue: how did you install swank-clojure?
16:20bordatoueis it the version of leinigen required
16:20raekbordatoue: yes, it is the latest stable
16:20borkdudebordatoue it matters if you work with leiningen 1 or 2, you are using 1 so this info is useful
16:20bordatouei used lein plugin install swank ....
16:20bordatouei used lein plugin install swank ….
16:20bordatouesomething like that
16:20raekok, that's correct for lein 1.x
16:21raekbordatoue: do you get any errors if you run "lein swank" in a terminal in the project directory?
16:21bordatouei am not keen on leinigen 1.x i will to use any version to get it to work
16:21bordatouelet me try that
16:22bordatoueno , it seems to be downloading from the central repository
16:22bordatoueand finally it say connection opened on port 4005
16:22KIMAvcrpok thats good
16:22borkdudeah
16:22raekah, ok. precc control-c to kill it
16:23KIMAvcrpnow from emacs you can do m-x slime-connect
16:23raekclojure-jack-in should work now
16:23borkdudeclojure-jack-in does not force leiningen to download deps?
16:23raekapparently not...
16:23borkdudemaybe this is fixed in version 2..
16:23bordatouewell, clojure-jack-in is throwing errors
16:23raekstill?
16:23borkdudegtg
16:23raekbordatoue: can you post the error message somewhere?
16:24bordatoueokay
16:25bordatoueone more thing, it say cannot find project.clj
16:25gfrederickswell that's significant
16:25bordatoueshould i open project .clj and then use jack-in
16:25raekthat sounds odd
16:26bordatoueplease instruct me on what i need to do on emacs side
16:26eightywhat is the right way to check if something is a collection?
16:26TimMceighty: coll?
16:26raekbordatoue: the only important thing is that you run that command while visiting a file inside the project directory
16:26KIMAvcrp,(coll? [1 2 3])
16:26clojurebottrue
16:26bordatoueokay,
16:26bordatouelet me do that
16:26TimMceighty: Although nil can also function as one.
16:26eightyTimMc: nice! thanks man.
16:28bordatoueraek: and all others thanks, it worked
16:28raekbordatoue: happy hacking!
16:28bordatoueshould i always open the project.clj file and then execute jack-in command
16:28eightyTimMc: nil can only function as an empty collection, right?
16:28bordatouewhat would be the recommended way of doing this
16:29raekbordatoue: any file ine project is fine. I usually open a source file in src/...
16:29bordatouewhy can't i start a repl without visiting a project
16:29gfredericksthe repl runs in the context of a project
16:29bordatoueso is the repl project specific
16:30raekleiningen needs to know 1) what version of clojure to use 2) where your source files are and 3) what and where your dependencies are
16:30raekso you usually use projects for everything, including playing at the repl
16:30KIMAvcrpI'm beginning to port PAIP to clojure and finished chapter 2 http://kimavcrp.blogspot.de/ any recommendations about the style of the clojure code ?
16:31bordatouei have got a new entry in the project.clj :plugin [lein-swank "1.4.4"]
16:31raekbordatoue: yes, everything (but with a few exceptions) is project specific in lein
16:31raekfor example, you can run "lein repl" outside a project
16:31bordatouefrom emacs shell
16:32bordatoueor terminal
16:32raeka terminal
16:32raekbut you can't do that with clojure-jack-in
16:32KIMAvcrpyou can also set it the inferior lisp program with (setq inferior-lis-program "lein repl")
16:32raekbordatoue: that entry is for lein2. lein1 will ignore it. it replaces the "lein plugin install ..." command
16:32KIMAvcrpthen you can type M-x run-lisp to start a clojure repl everywhere
16:33bordatouethat is useful ,
16:34raekbordatoue: I always mention the slime/swank in a project approach first, since it is the most generally useful approach
16:34dgrnbrghello clojurians--if I want to make a simple page in clojure that runs various shell commands when I click on links, what's the simplest way to get there (recommended tutorial/api doc)? I have programmed Grails a while ago, and I'm very proficient with Clojure
16:34raekif you split your code into multiple files or need to use libraries you will need it
16:34bordatouemany thanks,
16:40bordatouei have another problem, this one mac specific . hash key is not working , alt+3 is disabled .
16:41bordatoueis there any other shortcuts for hash key in emacs
16:42jsabeaudrybordatoue, I guess that would depend on your keyboard configuration
16:45TimMceighty: Right, most or all of the collection fns treat nil as empty.
16:54KIMAvcrpI'm beginning to port PAIP to clojure and finished chapter 2
16:54KIMAvcrp http://kimavcrp.blogspot.de/ any recommendations about the style of
16:54KIMAvcrp the clojure code ?
17:03gfredericksdgrnbrg: I guess noir?
17:03dgrnbrggfredericks: thanks, I've been looking at it
17:04gfredericksdgrnbrg: without a more specific question that's the most I can say :)
17:04dgrnbrgI just need to expose a few shell commands through a website. The shell commands change the mode of the lighting in the room
17:06pbostromis there an equivalent to something like (resolve (symbol "foo")) in Clojurescript?
17:07gfrederickspbostrom: don't think that's possible
17:07KIMAvcrphardly without eval
17:08pbostromthanks
17:08gfrederickspbostrom: it's hacky but you could try introspecting the ns object
17:10pbostromthanks, I might read up on that, I'll probably just do something similarly hacky to do what I want
17:10emezeskedgrnbrg: I second the suggestion of noir, and add that you might like conch for shelling out: https://github.com/Raynes/conch
17:10dgrnbrgemezeske: thanks, I haven't heard of conch, i'll check it out
17:11RaynesGood. s_s
17:11emezeske:)
17:11michaelr525i used conch and it worked (tm)
17:11RaynesWoohoo!
17:12gfredericksthat raynes. always reining.
17:21coventryI'm using clojure-jack-in to start slime. What does it take to get the debugging features shown in http://www.youtube.com/watch?v=d_L51ID36w4? I get the sldb window, but there is no information about local variables or pointers to my source code (e.g. the line in the backtrace for my code is "2: NO_SOURCE_FILE:1 user/eval9816"
17:24michaelr525so anyone here uses the eclipse debugger with clojure?
17:24coventryHmm, no one's going to watch a youtube link, are they. It's not really relevant to the question. The main issue is that the backtrace in the sldb window is missing the functionality I described in the last sentence of my last message. Is this a common problem with a known fix?
17:26peregrine81Anyone here use lobos at all?
17:26raekcoventry: does that video use slime or ritz (a.k.a. slime-clj)?
17:27michaelr525peregrine81: wuz that?
17:27peregrine81sql migration library for clojure
17:27michaelr525oh
17:28johnmn3hello
17:28peregrine81cannot seem to get the lein repl to have src/lobos in the classpath
17:28coventryraek: it uses slime-clj.
17:28coventryShould I just move to that?
17:29raekcoventry: it's a different implementation. if you want to follow the video you need to use it.
17:29raekswank-clojure is more commonly used, though
17:30coventryOK, thanks.
17:30raekand it has debugging support too: https://github.com/technomancy/swank-clojure (section Debugger)
17:31raekhttp://georgejahad.com/clojure/swank-cdt.html
17:31amalloycoventry: ritz is definitely more full-featured. last time i tried i couldn't figure out how to install it, but that was like a year ago, so probably it's improved by now
17:32coventryYes, I found it easy to install. Thanks for the pointers, this is great.
17:36johnmn3any more documentation out there lately on how to go about implementing reducers?
17:37amalloyjohnmn3: i wrote a few of them, in a few different ways; i was getting feedback from rich until suddenly i stopped hearing back. so for some reducers i could tell you the definitely-right answer; for others i don't think a right answer exists yet
17:38johnmn3amalloy: yea, I was just reading your jira comments
17:39amalloyah. well, to be honest: i totally understand why rich wouldn't want defseq in core, but it's so useful and concise that when he decides not to take it i'll put it in some other library
17:39johnmn3how about docs on using the existing reducers functions? for the purposes of benchmarking and whatnot? how would I go about using r/map?
17:39michaelr525ritz looks interesting.. i never managed to get debugging support to work with swank-clojure..
17:40coventryThe example in the swank-cdt page raek linked works for me, but it still shows NO_SOURCE_FILE for the repl interaction and [No locals] for the local variables. It shows the debugging info for clojure core just fine, but it's my own code behaviour that I really want to inspect. How should I do this? The only way suggested in the swank-clojure readme is C-x C-e, which is what I've been using until now, and which has the same problem
17:40coventrywith the debugger.
17:40amalloyjohnmn3: just build clojure (mvn package), then java -jar the compiled jar
17:40amalloy(require '[clojure.core.reducers :as r]) (...play around...)
17:41amalloyor i think there's an already-built snapshot with reducers in it
17:41amalloycoventry: try C-c C-k to eval a whole file
17:41johnmn3amalloy: ah, any pointers on where to find that? I've never built clojure with mvn.. I've mostly been living in the lein world
17:42amalloyi dunno, the clojure snapshots repo, wherever that is
17:42amalloyoh wait, it's an alpha
17:42amalloyjust depend on "1.5.0-alpha1" in your project.clj
17:43coventryamalloy: Yay, that's going to make life a whole lot easier. Thanks.
17:56johnmn3amalloy: thanks. I'm up with it now.
18:19peregrine81Anyway to have a function return a var? for example (defn x [] (fn [y] y)) I want x to return a var to the fn that returns y
18:19peregrine81its a contrived example of course.
18:20peregrine81Ive seen macros that just create a (def name [y] y)
18:21peregrine81but I'd like to return an anonymous var so I can play nice with ring handlers
18:23kwertiiperegrine81: by "var" you mean you want a symbolic reference to the function, or are you talking about a Clojure Var (with a capital V)? and in either case, what do you mean by "anonymous var"?
18:24peregrine81Var, sorry
18:24peregrine81So I have a piece of code that returns me a function. I want to pass that into some ring middleware, but the specific ring middleware expects it to be a Var.
18:25kwertiiperegrine81: no way to just pass it an anonymous function?
18:25`rand`-AFK#', maybe?
18:26emezeskeperegrine81: What ring middleware are you using? It's totally broken if it's not okay with an anonymous handler...
18:26peregrine81neither of those worked. here is the bug repot I filed the ring-middleware https://github.com/mmcgrana/ring/issues/72#issuecomment-5971047
18:26`rand`I think there's a macro--justasec.
18:27peregrine81bishop/handler is defined here if interested https://github.com/tnr-global/bishop/blob/master/src/com/tnrglobal/bishop/core.clj#L118
18:27johnmn3is r/map parallelized?
18:27kwertiiperegrine81: (defn foo [] (def bar (whatever)) seems to work
18:28peregrine81kwertii: hmm so if I patched bishop to use def instead of fn.. Lemme give it a shot
18:28kwertiithough of course this is not exactly pure-functional
18:28weavejesterperegrine81: You shouldn't need to patch bishop at all
18:29weavejesterYou just need to make sure that when you reload the namespace, the adapter picks up the new handler.
18:30peregrine81I'm not sure how to do that...
18:30weavejesterperegrine81: Well, you just need to have your routes referenced as a var *somewhere*
18:30weavejesterperegrine81: You could also just use lein-ring
18:31weavejesterperegrine81: Your code is basically what "lein ring server" does anyway.
18:31peregrine81I figured
18:32peregrine81it would be nice if bishop/handler returned something that all the middlewares can use though
18:32peregrine81instead of creating a seperate var to define my routes and then my bishop/handlers
18:33peregrine81since I will only be using them when creating my app which only happens once
18:33weavejesterIt shouldn't be the purpose of arbitrary middleware to deal with Clojure namespace reloading.
18:34peregrine81is that the only middleware that expects a var?
18:34amalloyjohnmn3: yes, if the underlying collection supports folding
18:34johnmn3amalloy:
18:35johnmn3amalloy: ok
18:35amalloyyou can tell because (iirc) the definition of map contains (folder ...)
18:35johnmn3yea, for some reason my collection is: Object[]
18:35weavejesterwrap-reload doesn't expect a var - it's just you can't supply a value directly if you want it to change when the namespace reloads.
18:35johnmn3when it should be a Vector
18:35amalloywellll, an Object[] could be foldable, but i don't think anyone's made it be
18:36peregrine81weavejester gotcha
18:36weavejesterPlus, you don't supply the var to wrap-reload
18:36weavejesterYou supply it to run-jetty
18:36johnmn3ah.. but a reducer is returned
18:36johnmn3so you have to do something like (into [] ...
18:36weavejesterperegrine81: You could also use something like an anonymous function
18:37weavejesterperegrine81: Anything that avoids passing the value directly, because if you do, there's nothing to reload.
18:38peregrine81awesome thanks weavejester !
18:38peregrine81again
18:38OwenOuhi all, what's the clojure convention of naming file and method name, are words separated by "-" instead of "_"?
18:38weavejesterperegrine81: np - you might want to experiment at the REPL to see what works when you reload a namespace
18:38amalloyjohnmn3: that's how all the reducers work. (r/some-transform coll) returns a new reducer; the only way to "use" its contents is to reduce over it
18:39johnmn3amalloy: does (into [] ... reduce over it?
18:40amalloy~def into
18:40amalloyanyway, yes. into is reduce conj, basically
18:40johnmn3okay
18:40johnmn3and do you know what reducers default chunk size is?
18:44peregrine81weavejester: well the lein ring doesn't quite work either, when I point it towards the base-handler I created it loads fine the first time but no reloads, even if I set :auto-reload? true
18:46weavejesterperegrine81: I can't think why it wouldn't work. It should do.
18:47weavejesterperegrine81: If you can provide an example project where it doesn't work, I can look into it.
18:48peregrine81weavejester sure! It is in pretty terrible shape cause I am learning.
18:48johnmn3amalloy: looks like 512
18:49peregrine81weavejester I wasn't really ready to push it public yet, but why not https://github.com/jeregrine/gamesapi
18:50weavejesterperegrine81: Okay, I can't look at it tonight (UK time, so nearly midnight here), but I can try to look tomorrow.
18:50peregrine81weavejester perfect, hopefully I can clean it up by then. Thanks a ton!
18:53johnmn3well, I'm getting 14 seconds on my automaton with vanilla functions and 13 seconds with reducers, naively bolted on.
18:53johnmn3I think my algorithm is not tweaked for parallelization though
18:53johnmn310,000 cells wide, 1,000 iterations
18:56johnmn3interestingly, though, r version still appears to only rev 2 of my cores. win7, quad core i7
18:56peregrine81now I just gotta figure out why lobos hates me
18:57peregrine81clojure's learning curve for the language is fairly shallow. The learning curve for libraries, lirbary usage and java is deadly steep
18:57johnmn3my naive implemenation of the same with pmap seems to rev 6 out of 8 threads, but runs at 16 seconds
19:14johnmn3yea, reducers does not appear to be using my other cores
19:15johnmn3is there a way to get the java version from within the repl?
19:16johnmn3from the command line, java -version says "1.7.0_04-ea"
19:17johnmn3but, from the repl:
19:17johnmn3test=> jsr166y.ForkJoinPool.
19:17johnmn3CompilerException java.lang.ClassNotFoundException: jsr166y.ForkJoinPool., compiling:(NO_SOURCE_PATH:1)
19:18jblomoif clojure was compiled with java 6, it will try to use jsr166y
19:18johnmn3yea
19:18jblomothe decision is made at compile time, i believe
19:18johnmn3I wonder if when rich said:
19:18johnmn3+;;todo - dynamic java 7+ detection and use
19:18johnmn3he meant he was using java 6 and we needed to detect java 7
19:19johnmn3well that complicates things
19:19jblomono, i think it means when a program runs it should detect, 7 vs 6. right now, *when clojure is compiled* it decides
19:20jblomoare you compiling or using a snapshot?
19:20johnmn3right, so it's hardwired for java 6 with the jsr in the classpath, right now
19:24johnmn3I guess I could build a new lein project, paste in the reducers code, modify the fj bits to use java7, build with lein and install, and then add that to my projects dependencies...
19:29amalloyjohnmn3: you should probably just build your own copy of clojure.jar - that's what i did when i was working on them
19:31dnolenhmm, what would be a good type-hint name for return values which are guaranteed to not be host false-y?
19:32jblomojohnmn3: agreed. it is quite simple. git clone git://github.com/clojure/clojure.git, mvn install
19:37emezeskednolen: Have you considered things like AlwaysTruthy or NeverFalsey?
19:37emezeskednolen: I'm trying to find a synonym for one of those, no luck yet
19:39emezeskednolen: ^Axiomatic or ^Indubitable are my entries :)
19:40dnolenemezeske: heh, would like something short
19:40emezeskednolen: ^1
19:42jblomo^TrueDat
19:45dnolensadly ^object won't work, since 0 and "" are objects.
19:46dnolen^clj to denote CLJS value?
19:47amalloy^truthy and ^falsey?
19:48amalloysimple and plenty short
19:48johnmn3test=> (java.util.concurrent.ForkJoinPool.)
19:48johnmn3#<ForkJoinPool java.util.concurrent.ForkJoinPool@3a8dee36[Running, parallelism = 8, size = 0, active = 0, running = 0, steals = 0, tasks = 0, submissions = 0]>
19:48johnmn3still only pushes on 2 threads though
19:48dnolenamalloy: I don't see a use case for ^falsey.
19:49dnolenmaking ^truthy less compelling.
19:49johnmn3my pmap version pushes on six
19:50johnmn3but both parallel versions are slower than the non-par version. which may say more about my decomposition of the problem
19:50amalloydnolen: what are you planning to use this for? eliminating if-tests that depend on always-true functions?
19:51dnolenamalloy: eliminating truth tests
19:51dnolenamalloy: has nothing to do w/ always true functions - just hinting that we returning a sensible value that doesn't need to be tested.
19:52dnolenamalloy: we're not returning 0 or ""
19:53johnmn3I take it back.. the reducers version is a hair faster than the non-par version
19:53amalloyso instead of emitting `if (cljs.core.truth(x)) ...` you want to know when you can emit `if (x) ...`? that's a sensible thing to want but doesn't seem to line up with your first question so i'm making sure i'm following
19:54dnolenamalloy: yes that's what we want to eliminate
19:54amalloyjohnmn3: reducers are like 5-15 times faster in the few cases i've tested. if you're not noticing a huge speedup you're probably not actually using reducers very well
19:54johnmn3amalloy: that is probably the case
19:54dnolenamalloy: currently we can avoid that with ^boolean or ^seq which covers many cases.
19:55johnmn3gonna rethink the problem.. thanks for the help.. bbiab
19:55dnolenamalloy: but custom code which wants to really deliver host perf (like core.logic) needs something else - so we know we will only return sensible Clojure values - never 0 or ""
19:56dnolenamalloy: this applies to any host that allows 0 as a false-y value of course.
19:57amalloy^host-safe, ^testable, ^plain, ...
19:58dnolenamalloy: naming is hard
19:58amalloyindeed. that's why i'm spewing bad names and hoping you'll decide one is good
19:59amalloywhat about just ^if-safe - it's short-ish, and describes exactly the technical quality you're indicating
20:08mmarczykdnolen: hi! more fantastic improvements to cljs during EuroClojure, I see :-)
20:10dnolenmmarczyk: hullo!
20:10dnolenmmarczyk: yes got some new ideas :)
20:10mmarczykdnolen: :-)
20:13jblomowhat is the gvec.clj used for?
20:14mmarczykjblomo: vector-of
20:15mmarczykjblomo: vectors of primitives, that is
20:15dnolenmmarczyk: I think that ensuring that no ops are much more than > 2X slower than Clojure on the JVM for V8 is a realistic goal.
20:15jblomoah cool. i saw vectors of primitives, but didn't connect with that function. thanks
20:16mmarczykdnolen: that is amazing
20:17dnolenmmarczyk: yes, anything that takes longer than 100ms for 1000000 iterations in the benchmarks means we're not doing enough.
20:18emezeskednolen: That's a really aggressive goal. I love it!
20:19mmarczykdnolen: right -- must get our act together on those cases -- can't wait to do just that :-D
20:19mmarczykdnolen: so, do you have any particular roadmap in mind?
20:20dnolenmmarczyk: right now pondering higher order fn invocation.
20:20mmarczyk(incidentally, one thing I've wanted to do for a while -- cache hashing on records -- patch @ CLJS-281)
20:25dnolenmmarczyk: nice looking now.
20:28dnolenmmarczyk: applied
20:28mmarczykdnolen: cool, thanks :-)
20:30dnolenmmarczyk: chunked seqs are bizarrely slow ATM, so I created array-reduce - but I haven't integrated it yet with ChunkedCons or ChunkedSeq
20:31mmarczykdnolen: I'll look into it then
20:32dnolenmmarczyk: cool! thx
20:32dnolenmmarczyk: one of the largest bottelnecks was eliminated with INext
20:33dnolenmmarczyk: optional protocol for much faster iteration - since the logic of whether to return nil or () can be in the collection .
20:33mmarczykdnolen: looking at the INext patches now actually -- great stuff
20:37dnolenmmarczyk: oh forgot to mention the big problem really was that because next had so many nested tests Closure wasn't lifting fns.
20:39mmarczykdnolen: interesting
20:39mmarczykdnolen: hence CLJS-277, right?
20:40dnolenmmarczyk: yes, I don't think there are many cases but we should remove them and pay attention to introducing them - if it didn't lift/unwrap with simple optimizations then it won't at all.
20:40mmarczykdnolen: good to know
20:40dnolenmmarczyk: I was extra happy to remove coercive-not and coercive-=
20:41mmarczykdnolen: oh yeah!
20:41dnolenmmarczyk: also seq, next and rest are type-hinted now that means no pointless truth tests for common pattern.
20:41mmarczykdnolen: I seem to recall there was a place in the code where undefined use to come up in arrays
20:41mmarczykdnolen: but it doesn't now
20:41mmarczykdnolen: any idea as to what might have fixed that? (or am I misremembering sth?)
20:42dnolenmmarczyk: yes nil? was poorly defined.
20:42dnolenmmarczyk: nil? is the one place where we need coercive-=
20:42mmarczykdnolen: ah, I see
20:43dnolenmmarczyk: it used be based on identical? which caused the problems.
20:43mmarczykdnolen: makes sense
20:45mmarczykdnolen: re: 0e0aa7fdd -- is peek/pop slower than first/next now?
20:46dnolenmmarczyk: the issue was just that pop can return ().
20:46dnolenmmarczyk: switched to first/next to follow rhickey's version and avoid seq call.
20:47mmarczykdnolen: I see, thanks
22:17wolkefm Hello all - I'm picking up a new machine tomarrow (thinkpad t410) and going to buy one of the clojure books - I've minimal lisp experience and I would say that I'm an incredibly inexperienced programmer. What books would you recoomed knowing my intent is to develop a swing application?
22:17wolkefm*reccomend
22:21tmciverwolkefm: I didn't have much lisp experience when I started clojure and I read Halloway's 'Programming Clojure' which I think is an excellent book for a beginner. I have the first edition, which is now a little dated, but I recommend the second edition.
22:22tmciver'Clojure Programming' is a new book that is also excellent but I think might be a little fast-paced for someone with no lisp experience.
22:24wolkefmI might as well grab both I suppose. I've no job with nothing but time on my hands to make plenty of mistakes. I was also thinking about grabbing 'the joy of clojure'. I remember reading somewhere that it is 'the rabbit hole' or somthing to that effect
22:30ivanwolkefm: I really like Joy of Clojure but it is an advanced book with compressed explanations
22:40wolkefmNoted.
23:20johnmn3so, I'm trying to figure out how to split out work for parallel execution
23:21johnmn3and so I'm breaking work up in to managable chunks:
23:21johnmn3(defn chunk [coll size] ...)
23:21johnmn3(chunk [1 2 3 4 5 6] 3)
23:21johnmn3-> [[1 2 3][3 4 5][6 7 8]]
23:21johnmn3Can I get what I want with reducers? : (into [] (r/flatten (r/map #(map inc %) (chunk [1 2 3 4 5 6 7 8]] 3))))
23:33jblomoreducers will automatically split up the datastructure, so you shouldn't have to do it manually
23:33jblomoif you do want to split up a vector like that, take a look at partition
23:33jblomojohnmn3: ^
23:46johnmn3jblomo: thanks
23:47johnmn3what about: (into [] (flatten (pmap #(map inc %) (chunk [1 2 3 4 5 6 7 8]] 3))))
23:48johnmn3will pmap finish incing the whole collection faster for large collections?
23:49jblomopmap is semi lazy. it tries to stay ahead of the consumer while using all cores
23:49jblomohowever, there's a cost to coordinating across threads. pmap is only worth it if your function is relatively expensive
23:49johnmn3it appears that inc is too easy gets very little benefit from parallel
23:50jblomoprobably
23:50johnmn3I still don't get that though
23:51johnmn3cause if I make my coll 10,000 wide and my window 100 wide
23:51johnmn3my chunking window.
23:51johnmn3you'd think a larger chunk size -- 1000, for instance -- would make the job more epensive
23:51johnmn3expensive
23:52johnmn3so just increase the window and apply it to a larger data set and we should see savings, I'd think.
23:52johnmn3but I'm not seeing it.
23:54jblomoinc'ing 1000 integers is going to take like 50 usec
23:54jblomoto test it out, you may want to make a sleeper function
23:55jblomosomething that just sleeps for a 50 msec or something
23:55johnmn3inc'ing 20,000 integers with window of 100 takes 7 seconds
23:56johnmn3same parallel as non-parallel though. 7 seconds
23:56jblomohow are you running those tests?
23:56johnmn3that's twenty chunks though.
23:57johnmn3(defn pfn [afn arange awindow](into [] (flatten (pmap #(map afn %) (chunkify (range 1 arange) awindow)))))
23:58johnmn3(let [_ (time (pfn inc 20000 100))] (println "done"))
23:59johnmn3oh, chunkify is a little messy
23:59johnmn3where's the clojure pastebin?
23:59jblomowwnot sure. i usually just use github gists
23:59jblomobuti don't have chunkify