#clojure logs

2011-10-19

00:03amalloyyeah, i don't think jark has really caught on
00:06scottjyeah, though I do use it for several scripts
00:07scottjcake (and jark) support #!
00:07amalloyscottj: what support is necessary?
00:09scottjamalloy: well b and c from your earlier comment
00:10ibdknoxhaha awesome: webnoir.org shows up on the first page of results for the word "noir"
00:10scottjnow we just need pinot up there
00:11ibdknox:)
00:11ibdknoxand Korma!
00:11ibdknoxlol
00:11tomojdoes jark come with caveats?
00:12scottjtomoj: I've seen occasional bugs but it was very actively developed for several months
00:13tomojI'm not thinking of bugs but, like, fundamental limitations or things that are just too hard right now
00:13tomojI just feel like I will be amazed if my picture of what it does is correct and it works great
00:18tomojhttps://gist.github.com/3ca5df25e8829660eadc hmm
00:21amalloytomoj: i love the classy "nil 2" in your jark -h
00:23tomojseems like stuff works though, just usage string is wonky I guess
00:49archaici just finished reading joy of clojure (first book on lisp i've read).. what book next, any advice? im deciding between on lisp, the reasoned schemer, sicp or another clojure book maybe?
00:49amalloyarchaic: i haven't read reasoned-schemer, but the other two are excellent
00:50amalloythough i thought RS was nth in a series and you'd want to start with little schemer or something
00:51hiredmanwrite some code, read some code
00:52alandipertarchaic: have you seen the clojure bookshelf? rich's amazon list
00:53archaicnope, looking for it now
00:53alandipertarchaic: http://www.amazon.com/Clojure-Bookshelf/lm/R3LG3ZBZS4GCTH
01:30sploophas anybody in here dorked around with gcj and clojure?
01:30hiredmandon't
01:31hiredmangcj is bad
01:31sploopyeah, i'm getting the sense that it's not going to work out from the groups
01:31amalloy(inc hiredman)
01:31lazybot⟹ 5
01:31sploopgoogle groups
01:31sploopi means
01:32splooptrying to avoid the vm startup cost for a smallish utility that's probably going to be run from the command-line or part of a script. looked at nailgun, but it's less than desirable for what i'm doing.
01:39sploopdanke
01:54mikera@sploop - JVMs are never going to be quick at starting up for short processes. But you might want to consider keeping a long running JVM or REPL instance and either a) running your script itself from the REPL or b) triggering the Clojure part of your code from the rest of script (e.g. a quick message piped to localhost:somerandomport)
01:57Raynesmikera: He is gone. Has been for neigh on 30 minutes now.
02:02mikerammmm my IRC client clearly needs message timestamps :-)
03:28todunTrying to filter string of certain characters that are not in the range I want. To this end I do this: http://pastebin.com/TVXWcDUd , is this the right approach?
03:29Blktgood morning everyone
03:43todunso in my previous question, an example will be like input = "I am \tab an \tab example" will return "I am an example"
03:43todunanother question. is there a way to put a named function within the body of a string?
03:45todunfor example, (def in-string (char 20) ) ; (print "I am inside a string in-string", when the result will becomes I am inside a string DC4..?
03:46todunI try a quote but that just returns the value unevaluated, I want to evaluate my result on printing the string for example. thanks.
03:48todun(To clarify: the same way you can put \newline into a string and have it execute is the effect I'm looking for. thanks.)
03:49thorwiltodun: defn is not lexically scoped, i.e each defn is at the top level, even when written inside another defn
03:49thorwilso it's pretty much useless and considered bad style
03:49Chousuketodun: you're treating "text" as if it were mutable
03:50Chousukethe first two filters in your function are completely ineffective
03:50todunthorwil: Chousuke I have an imperative background that doesn't want to shake.
03:50Chousukesince text doesn't change and the result of the filter is ignored
03:50todunChousuke: I suspected.
03:51Chousukebesudes, did you really intend (not enter?) :P that returns a boolean false
03:51Chousukewhat you need is (filter not-linefeed? text)
03:52todunoh. so (not= ...) doesn't work?
03:52Chousukebut actually the best way to do this sort of filtering is (remove #{\a \b \c} text)
03:53Chousuketodun: the second argument to filter must be a function or something that is callable as a function (like a set)
03:53Chousukewait, what, first argument aI mean
03:53Chousuke-a
03:53todunyes.
03:54todun,(doc filter)
03:54clojurebot"([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-effects."
03:54Chousukeremove is the opposite of filter
03:55Chousukeit basically does (filter (complement pred) coll) :P
03:55todunChousuke: exactly what I want.
03:56todunthe reason I have the last nested function is that I wanted to delete a range of stuff NOT in the range I was interested in.
03:56Chousukeit's not a nested function though. As thorwil said defn's are always top-level and so global. :)
03:57Chousukeif you want local functions you can use a plain let or letfn for some syntactic sugar
03:57Chousukeor just a straight anonymous function
03:57thorwilhttp://clojuredocs.org/clojure_core/1.3.0/clojure.core/letfn
03:57Chousukeeg. (filter (fn [x] (not= x something)) coll)
03:58todunthorwil: I tried letfn but didn't quite understand it.
03:58ChousukeThere's the shortcut form too :P lots of options
03:59todunthorwil: when you say top-level/global, what does that mean? I didn't imagine there were such in clojure(.ie. global stuff)?
03:59Chousuketop-level means not within any other form
03:59todunChousuke: I'm not quite sure how to use remove to handle a range of things I want to remove.
04:00todun, (remove #{\newline \tab} "this is
04:00todunquite interested\tab don't you think so\tab?")
04:00clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading string>
04:01Chousuke,(remove #(>= 1 % 5) [1 3 4 8 2 7 5])
04:01clojurebot(1 3 4 8 2 ...)
04:01todun, (remove #{\newline \tab} "this is \newlinequite interested\tab don't you think so\tab?")
04:01clojurebot(\t \h \i \s \space ...)
04:01Chousukewait, hm
04:01Chousukedurr
04:01todunI gave it a string, I want the string back.
04:01Chousuke,(remove #(<= 1 % 5) [1 3 4 8 2 7 5])
04:01clojurebot(8 7)
04:01todunso I try this:
04:02todun,(str apply (remove #{\newline \tab} "this is\newlinequite interested\tab don't you think so\tab?"))
04:02clojurebot"clojure.core$apply@c9153eclojure.lang.LazySeq@767a87e8"
04:02ChousukeI guess I should've upped the lower bound :P
04:02Chousukeyou mean apply str :P
04:03todunChousuke: but that bound will have to do something like the "nested" correct? function I had.
04:03toduncheck a range of chars
04:03todun,(apply str (remove #{\newline \tab} "this is\newlinequite interested\tab don't you think so\tab?"))
04:03clojurebot"this isewlinequite interestedab don't you think soab?"
04:03thorwiltodun: for def and defn and defmacro that use def internally, there is a single scope per namespace, no nesting
04:04Chousuketodun: oh, right, within strings the escapes are different
04:04Chousukebecause of java
04:04Chousukeso a newline is just \n
04:04todunha. I see.
04:04ejacksonmorning folks
04:04Chousukeand tab is \t
04:04todunChousuke: ideally, I would just like to define it using the (char 80) etc
04:04Chousukewhich explains the funky result
04:04todunoh ok.
04:05Chousukeyou can use octal codes for characters I think but I don't remember the syntax
04:06Chousukeor maybe it was just unicode. It's been a long time since I needed anything beyond the basics :P
04:06todunuhm ok.
04:07todun, ( apply str (filter (fn [x] (not= x (char 10))) "this is\nquite interested\tab don't you think so\t?") )
04:07clojurebot"this isquite interested\tab don't you think so\t?"
04:07Chousuketodun: anyway, for the range predicate you can use a higher-order function
04:07todunhow so?
04:08Chousukeeg, (defn within-range [low high] (fn [char] (<= low (int char) high))) (filter (within-range 5 10) somechars)
04:09amalloy,\012
04:09amalloy,\u000a
04:09clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unsupported character: \012>
04:09amalloyhm
04:09clojurebot\newline
04:10Chousuketodun: if you don't need a global function you can make within-range local with letfn
04:10Chousuke,(letfn [(test [x] (+ 5 x))] (test 6))
04:10clojurebot11
04:11todunis letfn like let in that the scope is limited?
04:11Chousukeletfn is just syntactic sugar for let, so yes
04:11hiredman*cough*
04:11Chousukeat least iirc :P
04:11Chousukebut whatever, close enough
04:12hiredman,(letfn [(foo [] (bar 1)) (bar [x] (inc x))] (foo))
04:12clojurebot2
04:12amalloyyes, it is conceptually sugar for let but realistically is a little more powerful
04:12todunuhm ok.
04:12ChousukeI guess the details aren't that important
04:13hiredman,(let [foo (fn [] (bar 1)) bar (fn [x] (inc x))] (foo))
04:13clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: bar in this context, compiling:(NO_SOURCE_PATH:0)>
04:14todun,\012
04:14clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unsupported character: \012>
04:14todun,\u00a
04:14clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Invalid unicode character: \u00a>
04:14Chousuke3 0s neede I guess
04:15amalloyChousuke: 4 digits, anyway
04:15todun,\u000a
04:15clojurebot\newline
04:15amalloyah, it's \oNNN: ##'\o012
04:15lazybot⇒ \newline
04:17todunI'm guessing this is unicode
04:18amalloy\u is
04:18amalloyoctal escapes only go as high as 255
04:18amalloy&\o377
04:18lazybot⇒ \ÿ
04:18amalloy&\o477
04:18lazybotjava.lang.Exception: Octal escape sequence must be in range [0, 377].
04:19todun,\o012
04:19clojurebot\newline
04:19todunamalloy: ok.
04:20todunchouser: in my situation though I want those three functions to be the basis of the filter. can I do like a cond on three predicates like I hoped and still filter the same text?
04:20todun^Chousuke
04:21todunchouser: I apologize for bothering you.
04:22Chousuketodun: you can combine the predicates. I think 1.3 has some new function for that but I forget what it's called
04:22amalloy,(doc any-pred) ; i think?
04:22clojurebotTitim gan éirí ort.
04:22Chousuketodun: welcome to functional programming. here we use composition :)
04:22amalloybut you don't really need it. you can just filter three times
04:23Chousukethat too but it's handy.
04:23amalloyChousuke: i'm definitely in favor of the predicate combinators
04:23amalloybut (->> coll (filter pred1) (filter pred2)) is simple enough
04:23ChousukeI guess
04:23Chousukethough now you need to explain ->> :P
04:23ChousukeI guess macroexpand will do
04:23amalloyindeed
04:24Chousuke,(macroexpand '(->> coll (filter pred1) (filter pred2))) ; see, it's magic
04:24clojurebot(filter pred2 (clojure.core/->> coll (filter pred1)))
04:24todunChousuke: thanks for the welcome.
04:24todunamalloy: but that's what I tried to do earlier.
04:24todunhttp://pastebin.com/TVXWcDUd
04:24amalloyyeah, but it's not what you actually did
04:24amalloywhich Chousuke explained, iirc
04:25Chousuketodun: you did it without the ->> macro which transform the "chain" into (filter pred2 (filter pred1 coll))
04:25Chousuke+s
04:26todunwoah. that's way over my pay grade.
04:26Chousuketodun: Clojure in particular offers lots of ways to do things and until you get used to things you will be confusd :P
04:26Chousuke... I'm typoing a lot today.
04:26todunthis is my 1 week clojure anniversary and I'm definitely confused.
04:26todunnp
04:26Chousukeyeah, 1 week isn't quite going to cut it. :)
04:27todunChousuke: your alternative does not need -->, how can I go about doing this?
04:27amalloyi love that clojure lets you write things in whatever order you want
04:27Chousukebut you'll get it eventually. The most important thing is to try to drop the assumptions you have from imperative programming
04:28Chousukeif you do something to an object in clojure, most of the time the state of the object itself does not change
04:28Chousukethat's the first hurdle.
04:28todunok
04:28Chousukeyou need to capture the result of the operation and operate further on that
04:28todunok.
04:29Chousukethere are of course exceptions (interop and, well, stateful code using the reference types) but that comes later
04:30toduncan't wait :P
04:30Chousukeyou can get far with just immutable things :P
04:30todunbut the how eludes me.
04:31Chousukeyou can use let to bind the result of a computation to a local identifier
04:31Chousukeor you can just chain things together
04:32Chousukeeg. (op-final (op2 somearg (op1 somedata))). read from right to left
04:32todunI'm actually trying that on your example now...let me run it by you to see if I'm approaching this correctly...
04:34Chousukethere are various macros and other things that help you to express such chaining more succinctly but it's still important to understand what ultimately happens
04:34todunyes. that's why I'm avoiding them for now. they don't help me lear squat..yet.
04:34todun*learn
04:35Chousukethe repl and macroexpand are your friends
04:35Chousukeif you don't know what something does just try it a few times in the repl with some simple input and see what happens
04:36Chousukesince things are immutable the chances that you would screw up the state of your program are effectively nil
04:37amalloyyeah, good point. the character-filtering function you were trying to write was too complicated for you to comprehend all at once, todun - you might have more success if you broke it up into a number of independent pieces in a repl
04:38todunChousuke: this is what I came up with when I tried composition http://pastebin.com/CAYXc1HZ
04:38Chousukeit helps to have a good IDE (or emacs, with SLIME) that lets you load code in the repl from a source file
04:38Chousuketodun: again, you're not giving filter functions as arguments
04:38amalloytodun: getting closer!
04:39amalloybut yes, filter needs functions, not just snippets of code
04:39todunChousuke: how so.
04:39amalloy&(= 1 2)
04:39lazybot⇒ false
04:39todunI thought that (= ...) was a function?
04:39amalloy&(fn [c] (= c 2))
04:39lazybot⇒ #<sandbox12207$eval14451$fn__14452 sandbox12207$eval14451$fn__14452@1d72a6c>
04:39Chousukeit's a function call
04:39Chousuke= is the function
04:39todunha. I see.
04:39Chousukethat you're calling
04:40Chousukeyou can wrap simple expressions with # to create a quick anonymous function. within that expression you can use % (%1), %2, %3 etc. to refer to arguments to the function
04:41Chousukeeg. #(not= % 5) is a quick anonymous function that compares its first argument to 5
04:41Chousukeit's just shorthand for (fn [x] (...)) which you can use when you need more than a single expression, or if you need to nest things
04:43Chousuke,(filter #(not= \a %) "testa") for example
04:43clojurebot(\t \e \s \t)
04:43todunmy new try: http://pastebin.com/ySw7Rpm2
04:44Chousukewhat's that pol a-char thing?
04:45todunoops. sorry. my ide doesn't let me have int
04:45todunhaha. that is int
04:45Chousukeyou want just (filter not-enter? (filter ...))
04:46Chousukethe first expression you give as an argument to filter *must* evaluate to a function of one argument
04:46Chousukewhich not-enter? is
04:47todunuhm..
04:47Chousukeand the second argument is a sequence you want to filter
04:48Chousukein this case, the return value from the previous filter
04:48Chousukeor inner, to be precise
04:48Chousukestrings are treatable as sequences of characters in clojure
04:49Chousukeso the innermost filter works with that
04:49todunok.
04:51Chousukealso move the defns outside the remove-characters definition. as it is, they're just distracting
04:52todunok. but they'll work inside it though, right?
04:52Chousukeyes, because they're global definitions
04:52Chousukewhen you get the filtering working you can add them to the letfn form
04:52Chousukebut let's take it one step at a time :p
04:52todunok.
04:54todunbut if I want just (filter not-enter? (filter ...))
04:55todunhow does not-enter? know what its args are?
04:55Chousukefilter calls it with one arg
04:55amalloyfilter calls it. but that's later; in the current scope you're passing not-enter? without calling it
04:56Chousukeyou're in effect passing a function as an argument to another function
04:56Chousukeanother thing that sounds outlandish if you've never used a language with first-class functions :P
04:57amalloybecause functions are first-class objects, just like other data types. consider the array in java {1, 2, 3}. when you pass it around as an array, how does it know what index you need? it doesn't: it's all of them at once until someone else indexes into it
04:57Chousukebut in clojure, functions are values just like 1, "foo", or 'bar :P
04:57todunso something liek this http://pastebin.com/sDqNNJBV ?
04:57todun*like
04:57Chousukeyes, exactly
04:58amalloytodun: looks like that should work
04:58Chousukethat gives you a character sequence as an answer
04:58Chousuketry it in the repl
04:58todunyeah. I have to do the (apply str...)
04:59todunhaha. I get nil
04:59todunsigh.
05:00amalloytodun: you might want to drop the not, in in-range
05:01todunbut I want things not in that range.
05:01todunhow can I manage this if I remove not ?
05:01Chousuketodun: try the function separately on input to see if it works
05:01Chousukeie. do just (filter not-correct? text)
05:02Chousukeor even just (in-range? somechar 32 126)
05:03todunok.
05:03todunnow I get only the tabs showing.
05:03amalloytodun: are you trying to *remove* characters between 32 and 128, or keep them?
05:03todunkeep them.
05:04todunalso key 10 & 13
05:04todunnot sure how to convert the ascii to unicide
05:04todun*unicode
05:05amalloyso you want to throw away all characters except \n, \t, and whatever's between 32-128? in that case you don't want three filters
05:06todunyes
05:06todunoh. why so?
05:06amalloywell, consider how the not-enter? filter will work. it will throw away anything but \n, right?
05:06amalloyso once you've done that, how will you "get back" the ones from 32-128?
05:07Chousukeshouldn't filter keep everything that's not-enter?
05:07raektodun: you can use 'int' and 'char' to convert from character to unicode code point number and vice versa
05:08raektodun: unicode code point numbers 0 through 127 are the same as ASCII
05:08todunraek: but I want to see the actual unicode so I can put it in a string literal
05:08todunamalloy: that makes sense.
05:09Chousukeactually shouldn't not-correct get rid of linefeeds newlines too?
05:09todunamalloy: what if I do not-correct? first
05:09todun?
05:09Chousukenot-correct is done first
05:09todunChousuke: I want to actually keep newlines and returns.
05:09amalloydoesn't matter what order you do; three filters won't work
05:09Chousukethe innermost filter executes first
05:09todunyes yes. because it's the deepest in the filtering.
05:10Chousukeoh... then you need to include the conditions within not-correct
05:10amalloyi'm trying to explain why in terms of boolean logic but i can't get it to make sense
05:10todunraek: I want the unicode code so when I put it into the string like so "\unicode", it will be executed by print or soemthing
05:10todun*something
05:10amalloyso instead, https://gist.github.com/1297800
05:10todunamalloy: ok.
05:11Chousukeamalloy: because not-correct returns false for newlines and linefeeds, they are already removed before the other filters are even executed
05:11amalloyChousuke, todun: the amount of "not" going on in his code confuses all three of us
05:11raekU+03BB is the lowercase lambda. as a string: "\u03BB", as a char: \u03BB, as code point number: 955
05:11Chousukeamalloy: yeah
05:12Chousuketodun: try to avoid nots in code, it clearly confuses things :P
05:12Chousukeif you want to keep things, use filter with a positive predicate, and for removing things, use remove with a positive predicate :P
05:12amalloywell. don't write (not (and (not a) (not b) (not c))) when you could write (or a b c), anyway
05:12raektodun: what do you mean? do you want to escape it? with what convention?
05:12todunalso, how do I use (str apply...) it seems to be giving me an object reference whenever I sue it.
05:13todunamalloy: Chousuke sorry for the confusion :(
05:14Chousuketodun: you want to apply the str function, not stringify the apply function :)
05:14todunraek: so "I want ascii char 5 here so I will use unicode here like so \unicode5...so that when I call print on this string, it does whatever \unicode5 is"
05:14todunraek: my interest is to write a test. henve my need for a string
05:14todun*hence
05:14todunChousuke: so (apply str....) ?
05:15Chousukeyeah
05:15todunamalloy: the boolean logic makes more sense. thanks.
05:15todunChousuke: ok. let me try that.
05:15raektodun: if you want a string with unicode character #5 in it, just use the \uXXXX syntax:
05:15Chousukestr takes n arguments, you have a sequence of characters you want to give it as arguments; apply allows you to fit the function to the sequence
05:15raek,"\u0005"
05:15clojurebot""
05:15Chousukeso (apply str charsequence)
05:16raek,(str (char 5))
05:16clojurebot""
05:16Chousuke(apply str [(char 5)])
05:16Chousuke,(apply str [(char 5)])
05:16clojurebot""
05:16todunraek: so in general I use the ascii hex number at the end?
05:16todunChousuke: ok thanks.
05:17claj_I'm in the latest clojurescript from git and on windows. When I've installed the jars, closure etc acc. to instructions, I got a script/repl.bat
05:17claj_When I do (require '[cljs.repl :as repl]) it says nil (=good).
05:18claj_When I do (require '[cljs.repl.rhino :as rhino]) it says ClassNotFoundException org.mozilla.javascript.Context java.net.URLClassLoader$1.run (:-1) (=bad)
05:18raektodun: yes. in \uXXXX, XXXX is the unicode code point in hex. for ascii letter YY in hex, you'd write \u00YY
05:19todunraek: thanks so much. googling was confusing me more on this point.
05:28claj_Ans to self: download rhino from http://www.mozilla.org/rhino/download.html, put js.jar in /lib folder, restart repl, good to go.
05:31raekclaj_: which jvm are you using?
05:32raekrhino is included in sun's/oracle's jvm
05:54todunany advice on where to begin when I want to do concurrency with clojure? thanks.
06:05ziltitodun: If you like screencasts this might be for you: http://vimeo.com/8672404
06:06todunzilti:thanks. screen-casts, allot(also elementary) sample-code, etc, whatever you know that is interesting to a concurrency and clojure newbie.
06:06todun^zilti thanks.
06:07archaictodun look at richs ant demo
06:07chridotodun: another good screencast http://blip.tv/clojure/david-liebke-from-concurrency-to-parallelism-4663526
06:08chridotodun: and of course http://blip.tv/clojure/clojure-concurrency-819147
06:08todunarchaic: ok. thanks.
06:08todunchrido: thanks.
06:40kzarDumb question, but I'm still getting the hang of macros. Does this look right of a is-not macro? (defmacro is-not [& args] `(apply (comp not is) args))
06:41claj_raek: I'm using JRE from Oracle/sun 1.6.0_23something, Server VM build 19 something. Should the js.jar be included by default?
06:41claj_It works like a charm now, anyway.
06:50claj_kzar: I think this one is good for macro-learning: http://www.learningclojure.com/2010/09/clojure-macro-tutorial-part-i-getting.html
06:51claj_I could not get your macro going (test them with macroexpand and macroexpand-1 to see the resulting sexpression generated by the macro)
06:51claj_but maybe my bad success was because I had not the correct name-space enabled.
06:59kzarclaj_: Think I got it http://paste.lisp.org/display/125389
07:00kzarclaj_: Thanks for the link
07:00kzarclaj_: (I cheated, did (clojure.repl/source is) to see how it worked and used that to make is-not.)
07:09claj_kzar: great! I always forget the reader-macros (`~) but the concept really ain't that hard. The results can be unexpected though.
07:37ziltiI'm trying to use "clojure-jack-in", but then I get the message "Process swank exited abnormally with code 1. That's not a task. Use "lein help" to list all tasks." What am I doing wrong?
07:39archaichmm only time i see that error is when i try clojure-jack-in and i already have a swank instance running
07:40ziltiIf I try "lein swank" on the command line it also says "That's not a task. Use "lein help" to list all tasks"
07:41tdrgabizilti: maybe an old lein?
07:42ziltitdrgabi: Leiningen 1.6.1
07:44tdrgabizilti: do you have swank-clojure installed?
07:46ziltitdrgabi: Yes
07:46ziltiI have it both in the project.clj as :build-dependencies and using "lein plugin install swank-clojure 1.3.3"
07:47tdrgabican you run this: ~/.lein/bin/swank-clojure ?
07:48zilti"Connection opened on null port 4005."
07:48clgvzilti: It has to be :dev-dependencies not "build"
07:49ziltiSorry, I meant :dev-dependencies, mistyped here
07:49tdrgabidoes lein help show swank as one of the tasks?
07:50ziltino
07:53archaicyou dont need swank-clojure anywhere in a project.clj file using clojure-jack-in from emacs.. can you eval (apropos "clojure-jack-in") in emacs *scratch*?
07:54ziltiCommand: (not documented)
07:55ziltiYou know, clojure-jack-in "works" in that it just displays that it's starting a swank server.
07:55ziltiand then in the *swank* buffer there's that error message
07:56archaichmmm rm -rf ~/.m2 ?
07:58ziltidoesn't help...
08:00archaiceval (list-processes) in emacs is swank there?
08:01ziltiis empty.
08:06ziltiOk have to go now. Bye
10:28DappD?
10:38pyr,(str (format "%c" \\))
10:38clojurebot"\\"
10:38pyris this right ?
10:39pyr,(str (format "%c" \a))
10:39clojurebot"a"
10:39pyri would have expected the first form to yield "\"
10:39TimMcpyr: It is escaping the output for printing.
10:40pyr'k
10:40TimMc,(println (format "%c" \\))
10:40clojurebot\
10:40pyrto keep homoiconic then, makes sense
10:40TimMc,(count (format "%c" \\))
10:40clojurebot1
10:40TimMc,(format "%c" \newline)
10:40clojurebot"\n"
10:40TimMcpyr: Also, no need for str here.
10:41pyryep
10:41bhenry1is there anyone who can help me with jdbc for sybase's advantage database server?
10:41bhenry1i have sybase's adsjdbc.jar, but can't make sense of it
10:53ljosHi - Is there a way to make macros capture variables in the input?
10:56S11001001ljos: yes, for several meanings of that. What are you doing?
10:57ljosS11001001, I've tried to do this but keep getting a fail: (defmacro test [& code] (let [i 1] ~code)) and afterwards running (test println i) .
10:58S11001001change i to ~'i
10:58ljosoh..
10:59S11001001hmm, I hear that do is special, let's see
10:59S11001001,(do (defmacro myenv [] (keys &env)) (let [i 1] (myenv)))
10:59clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
10:59S11001001hmm
11:00ljosThat doesn\t work.
11:00S11001001okay I also suggest (assert (not (contains? &env 'i))) in the macro so you can avoid accidentally shadowing a local i
11:00ljosoh.. forgot the '
11:00S11001001you're also missing ` before (let
11:00ljosI want to shadow.
11:00S11001001you want to bind, not necessarily shadow
11:01ljosAh.
11:01S11001001it's harder for a user to spot bugs caused by anaphora, but you can do so easily in the macro, and they can work around it by not using i for their own variable
11:01raekljos: you also need ~@code instead of ~code
11:02S11001001doesn't work if you need (test ...) forms to live inside (test ...) forms, though
11:02ljosI'm also wondering, is there a way to bind into an eval?
11:02raek(test a b c) would otherwise become (let [i 1] (a b c)) and not (let [i 1] a b c)
11:02raekljos: you pretty much have to generate an enclosing let form
11:03raekthe way the clojure compiler is implemented the expression eval evaluates cannot access locals accessible from the eval call
11:04ljosraek: But (let [i 0] (eval '(print i))) doesn't work..
11:04ljosAh.. so that was not the answer to the first question.
11:04ljossecond*
11:05raekljos: I was thinking about (let [expr '(print i)] (eval `(let [~'i 0] ~expr)))
11:06ljosOh.. yeah. Thanks to both of you!
11:07raekif you parameterize the value i should have, you might also want to do this: (let [expr '(print i), i-value (reverse [1 2 3])] (eval `(let [~'i (quote ~i-value)] ~expr)))
11:08raekthis will become (let [i (quote (3 2 1))] (print i)), and not (let [i (3 2 1)] (print i))
11:09raekyou have to be cautious with what's code and what's not
11:28ljosThat works out great, raek. Now I don't have to start over with the way I was thinking with my code :D
11:33TimMcbhenry: You'll probably have to be more specific.
11:33bhenryi can't find any examples
11:33bhenryTimMc: the examples i've found don't match up with the classes in the jars i was provided
12:02F3dNewbie here... Is it possible to use pattern matching (matchure?) for processing/transforming XMLs ?
12:09F3dAny opinion on matchure vs. core.match ?
12:11TimMcI don't know how to pronounce the former, so I'd probably use the latter.
12:13georgekhi, as someone who uses Windows and Emacs, is the emacs-starter-kit the current recommended way to get started? And is there a tutorial to look at to get started with that and lein?
12:13dnolenF3d: I develop both. Try both and see which works better for you. core.match is much more traditional on it's approach to matching syntax and it does provide as much sugar as matchure.
12:15todunhi all.
12:15dnolenF3d: I meant I'd try both. I develop core.match
12:16todunif I want to get into clojure macros as a beginner, any nice resources out there? screen-casts, good/simple tutorials etc are welcome. thanks.
12:16dnolenand I meant core.match provides less sugar.
12:17TimMcI was gonna say...
12:17TimMcdnolen: Who *does* develop matchure?
12:19chewbrancageorgek: I found this to be useful when I was setting up emacs: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs
12:21georgekthanks chewbranca, yes I'm looking at that now; I also just found this, http://underaboddhitree.blogspot.com/2011/10/using-emacs-and-leiningen-on-windows.html, published yesterday
12:22dnolenF3d: one advantage over matchure, core.match can deal w/ the presence of recur.
12:31chewbrancahttp://aichallenge.org/starter_packages.php
12:32chewbrancaclojure is mentioned this time, no starter package though (yet?)
12:32chewbrancalooks fun, ant colony domination
13:03srid-workhttp://stackoverflow.com/questions/7812635/
13:12llasram`chewbranca: Do you know, is there any sort of published timeline for the current (upcoming?) AI challenge? I don't see any dates or such on the site
13:15jodarowow
13:15jodaroi'm really happy with how easy some of my refactoring has been
13:15jodarojust an observation
13:15jodaroand now
13:16jodarofire drill time!
13:16jodarorad
13:16chewbrancallasram`: yeah I was looking around for a timeline as well but couldn't find one, I did see that they mentioned its all in beta right now, so I imagine a decent bit of time
13:16jodaroso much for productivity
13:16bbommaritoQuick question: Is there any known issues with Clojure on OpenJDK?
13:17technomancybbommarito: no, works fine
13:17bbommaritotechnomancy: Great, thanks. Been wanting to play with Clojure, but really don't want to install Oracle's java.
13:17technomancyclojurescript didn't work for a while, but ISTR that's been fixed
13:18dnolentechnomancy: it has.
13:20technomancycool
13:23srid-workis anyone using need to replace use/require in their clojure projects? https://github.com/stuartsierra/need
13:25dnolensrid-work: I would not use any Clojure library that hasn't had updates since April 2010
13:26srid-workits more of a tiny macro (that can be included in project tree) than a library :)
13:27srid-worki asked this in SO: seperate use and require forms seem to be unnecessary.
13:27srid-work.. and why they were created in first place (as opposed to designing a syntax like that of `need`)?
13:27technomancysrid-work: I'm a big fan of nstools for tidying up ns clauses
13:27dnolensrid-work: bringing a dependency for ns declarations seems gratuitous. better to lead the conversation on how ns form can be improved.
13:27dnolensrid-work: I think it can chalked up to "hey, we all make mistakes"
13:28technomancysrid-work: use and require are definitely not ideal or the last word in loading syntax
13:28technomancythey are just a whole ton better than load-file =)
13:28DerGuteMoritzhey guys, is there a specific reason to use a foo.core namespace in libraries? i.e. why not put the code directly into the foo namespace?
13:29dnolenDerGuteMoritz: there isn't any reason to foo.core ns. I've been reprimanded in the past for doing so in my libraries by users :)
13:29hiredman~single segment
13:29clojurebotamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
13:29srid-workdnolen: a human mistake? that explains it. :-) I remember seeing posts in clojure mailing list (mostly from stuart) proposing to improve the ns form.
13:29DerGuteMoritzdnolen: reprimated for using foo.core?
13:29dnolenDerGuteMoritz: oh yeah, single segment is bad, sorry thought you were referring to foo.bar.core instead of foo.bar
13:30srid-worknot sure what the decision was. I assumed that it was rejected .. hence my question (above) about the adoption of `need``
13:30DerGuteMoritzsingle segment?
13:31technomancyDerGuteMoritz: (ns foo) rather than (ns foo.core)
13:31dnolensrid-work: no, I think the ideas proposed weren't much of an improvement. For what it's worth, ClojureScript ns story is way better since it only support two forms. :use :only, :require, :require :as
13:31DerGuteMoritzso putting definitions into `foo' is not good and `foo.core' should be used instead while `foo.bar' is ok?
13:31technomancyDerGuteMoritz: that puts it in the default java package and makes interop nasty
13:31DerGuteMoritzah, so that's the reason
13:31technomancyDerGuteMoritz: if you have a descriptive two-segment name, there's no reason to use core
13:31technomancy.core just means "I can't think of a better two-segment name to use to avoid a single-segment name" =)
13:32DerGuteMoritzhm, well I only have a very small library that doesn't make sense to split up further
13:32DerGuteMoritzok then hehe
13:32DerGuteMoritzmaye it should be put in http://dev.clojure.org/display/design/Library+Coding+Standards?
13:32srid-workdnolen replacing use/require with a single form (need) is not an improvement? is the clojurescript ns story better because it lacks a :import (third form)?
13:32DerGuteMoritzif anyone here is registered for editing the wiki
13:33dnolensrid-work: combining into a single form doesn't seem like an improvement to me. I have to examine the need expr to know what's happening.
13:33DerGuteMoritzthanks for the information!
13:33technomancysrid-work: I think it depends on the scope of the project. it's probably not worth it in small libs, but if you have huge a huge application it may be worth it.
13:33technomancysrid-work: seriously check out nstools though
13:34technomancyit lets you define a standard template to base other ns forms on
13:34srid-worktechnomancy just checked nstools; doesn't seem to unify use/require, does it?
13:35technomancysrid-work: no, but it lets you specify all your common requires in one place and refer to it succinctly all around your codebase
13:35technomancysay you know you're going to need clojure.string, and http client, and a json parser in a bunch of namespaces
13:35technomancyyou can just add them to foo.base, and then in other nses you can do (ns foo.baz (:like foo.base))
13:37srid-worktechnomancy ok, and if you want to load a special-case library (eg: clojure.java.jdbc), you do that only in the required module but not the common namespace?
13:37srid-workor add clojure.java.jdbc to foo.base as well, not worrying about requiring it in other modules?
13:37srid-work(even though jdbc will be used only in one file)
13:38technomancysrid-work: I would keep the base as just all the common stuff
13:38seancorfieldtechnomancy: that's nice... i hadn't read about that before... link to nstools?
13:38technomancyclojurebot: nstools?
13:38clojurebotPardon?
13:38srid-work$g clojure nstools
13:38seancorfield(apologies if you posted it and i missed it)
13:38technomancyseancorfield: it's totally underappreciated
13:39technomancyclojurebot: nstools is a library to reduce repetition in your ns clauses: http://code.google.com/p/clj-nstools/
13:39clojurebotOk.
13:39technomancyseancorfield: there ya go
13:41seancorfieldthanx... looks like it might not work with clojure 1.3.0? (haven't tried - just saw contrib dependency)
13:41technomancyyeah, probably not; it's kind of old
13:42srid-worknstools example - http://code.google.com/p/clj-units/source/browse/src/units/si.clj
13:42technomancy(you can tell since it's hosted on google code)
13:42technomancyzzzzzing
13:42seancorfieldmaybe konrad and stuart could get together and see if some form of it could be added to clojure.tools.namespace? :)
13:45technomancyman. why do people treat the confluence comments section like the edit section? >=(
13:46technomancyI guess that's what you can expect when you prevent people from editing the wiki
13:47technomancyalso: why do people think it's a great idea to add a tutorial for the starter kit to the clojure wiki? wtf
13:47technomancyis there anyone around with privileges to delete wiki comments?
13:50amalloytechnomancy: presumably to punish you for being a terrible tutorial-writer
13:50technomancyamalloy: a better explanation than any I've been able to come up with
13:50pjstadigi don't buy it
13:51technomancyseancorfield: I think c.t.namespace is more about inspecting and investigating namespaces than declaring them.
13:51amalloytechnomancy: it's because i'm not distracted by having read any of your tutorials - my mind is open to the possibility they might be awful
13:51technomancyhaha
13:57technomancynever let facts cloud your judgement
14:00zackmariltechnomancy: just got swank-clojure to work for the first time. It's magical. Just wanted to say thank you
14:00technomancyzackmaril: sweeeeeeet
14:01zackmarilMos def. Now it's time to make a robot that sexts.
14:02zackmarilThanks again!
14:08devn"Now it's time to make a robot that sexts."
14:08devnWhy do I feel like someone has said this in this channel before?
14:09technomancydevn: because there used to be a sexpbot?
14:10amalloyno, there was someone who suggested that as a project on the ML
14:13devnhahaha, oh yeah! who was that?
14:13amalloy*shrug* probably zackmaril
14:27F3ddnolen: Thanks! about core.match (better late than never)
14:38mefestoA while ago Meikel Brandmeyer wrote, "memoize done right" in which he created a pluggable caching strategy. Is any of this part of a clojure contrib project? http://kotka.de/blog/2010/03/memoize_done_right.html
14:45drewrmefesto: latest incarnation is http://blog.fogus.me/2011/06/20/unk/
14:45drewrwhich is really https://github.com/fogus/unk
14:46sriddoes `lein run` support passing arguments to the interpreter. specifically, I want to pass `-Duser.home=$HOME`. "lein help run" doesn't tell if this can be done.
14:46mefestodrewr: thanks :)
14:48technomancysrid: "lein help run" does list "lein run [--] [ARGS...]"; is that unclear?
14:49technomancyoh, you mean args to the JVM itself?
14:49sridyup, and I found the solution from SO .. :jvm-opts in project.clj
14:49technomancyright, that's not mentioned in the help there because it's not specific to the run task
14:49sridlooks like it doesn't support env variables.
14:49technomancyright; it's just forg arguments
14:50technomancy*for
14:50sridoh, so no shell expansion happens.
14:50technomancyif you want environment variables you can use JVM_OPTS
14:50technomancysame effect; it just doesn't live in the project
14:51tolstoyAlso: VAR="whatever" HOME="/path/to/home" lein run
15:11bbommaritoNow the true challenge, getting Slime and Clojure working in EMacs.
15:12tolstoyThat really is a challenge, somehow. On the mac, with the recent "brew" version of emacs, most of the clojure stuff compiled with errors or warnings or something.
15:12paulfryzelbbommarito: i am new to the clojure community and also to "the emacs way of doing things". i was able to get Emacs 24 setup on OS X Lion + Slime/Swank the other night without much trouble at all
15:12paulfryzellet me know if you run into any roadblocks, maybe i could offer some help
15:12tolstoyWell, there you go. ;)
15:13paulfryzeli used http://emacsformacosx.com/builds → Emacs-pretest-24.0.90-universal-10.6.7.dmg
15:17tolstoySomehow my stock elpa was messed up, then I tried adding a repo for "marigold" (or whatever it is) and that was down. Gave up on Emacs until I've got more time.
15:17tolstoyA year or two ago it was a snap.
15:27bbommaritotolstoy: Marmelade.
15:27tolstoyYeah, that's it.
15:27bbommaritoI'm on a Linux box, and use Emacs 24, with el-get, and I would really love to use el-get for this, but my attempt to do that failed.
15:27tolstoyWhat's the best page for defmacro escape characters (given they're not the same as CLs)?
15:29tolstoyHm. Maybe cheatsheet.
15:29llasram`http://clojure.org/reader, the sub-section on "syntax-quote"?
15:32tolstoyllasram`: thanks!
15:32tolstoyWhen you use, say a# in a let clause at the beginning of a macro, do you just refer to it as a# throughout the macro? a# isn't generated anew each time?
15:32babilenHi all ... I seem to remember that I read a discussion of when to use () and when [] in (ns ...) somewhere. But I can't seem to find it. Are there coding guidelines, etc somewhere to be found?
15:33tolstoyGuess I can try macro-expand....
15:33babilentolstoy: yes, you would always use a# throughout the macro.
15:34llasram`"If a symbol is non-namespace-qualified and ends with '#' [...] [a]ll references to that symbol within a syntax-quoted expression resolve to the same generated symbol." - http://clojure.org/reader
15:35llasram`The official documentation knows all and sees all, despite being in bad need of some CSS lovin' :-)
15:35drewr"within a syntax-quoted expression" being the operative phrase
15:36drewrif you referred to it multiple times in a let outside of the syntax-quote it would be different each time
15:37hiredmanI don't believe # does anything outside of syntax quote
15:37llasram`Well, I don't think it has any meaning outside of syntax-quote, but yeah -- different in different syntax-quoted expressions
15:37llasram`,(foo# foo#)
15:37clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo# in this context, compiling:(NO_SOURCE_PATH:0)>
15:37llasram`,(`foo# `foo#)
15:37clojurebotnil
15:37hiredman,(macroexpand '(let [x# 1 x# 2] x#))
15:37clojurebot(let* [x# 1 x# 2] x#)
15:37llasram`(list `foo# `foo#)
15:38llasram`,(list `foo# `foo#)
15:38clojurebot(foo__106__auto__ foo__107__auto__)
15:38llasram`There we go
15:38llasram`I apparently need to take clojure bot off to a quite channel somewhere and practice my act a bit
15:40drewrhiredman: ah yes, you're right
15:41drewrdon't know why I was thinking that
15:41hiredmanwell, it would kind of make sense, except syntax quote is insane
15:42llasram`hiredman: How so?
15:42llasram`(insane, that is)
15:42babilenSo are there coding guidelines for (), [] usage in (ns ...) ? I stumbled over a short discussion once but can't find it again.
15:43hiredmanllasram`: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L762
15:43TimMc~8thlight
15:43clojurebotI don't understand.
15:43TimMcbah
15:43TimMcbabilen: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
15:43drewrbabilen: use [] except for () in :import
15:44llasram`hiredman: Ohhh, the reader impl for syntax-quote is insane? I can totally believe that
15:44drewrdon't know if that's official but my team uses it to great success
15:44hiredmanhttp://www.thelastcitadel.com/images/syntax.png is a rough diagram I made while trying to work out the flow control for syntax quote
15:45babilenTimMc: That looks like a good article, but isn't what I am looking for. But thank you very much.
15:45babilendrewr: Are there specific reasons?
15:45llasram`hiredman: wah! ok, insane :-)
15:46hiredman() lines up classes and packages well for imports
15:46drewrbabilen: what hiredman said
15:46hiredman[] lines up :only clauses well for uses
15:46babilen"lines up" ?
15:47hiredmanthe way it indents
15:47drewrin clojure-mode
15:47babilenaah!
15:47babilendrewr: I don't use clojure-mode but vimclojure -- Guess it might be the same though.
15:48drewrunsure
15:48babilenBut thank you -- I guess any standard is better than no standard. Are there other best-of-breed coding guidelines available?
15:48babilendrewr: I'll test it.
15:48llasram`My understanding of the Clojure convention was to use lists when there is intended to be an implication of code-execution, and vectors when there isn't
15:48llasram`So (ns (:require [..]) (:use [..] (:import [..])))
15:49llasram`(well, with the parens in the right places)
15:49llasram`Is there some reason not to use vectors with imports?
15:50hiredmanthey don't indent correctly
15:50hiredmanthe indentation you want for :import is like indentation for function calls
15:50hiredmane.g. arguments aligned vertically to the right of the operator
15:51hiredmanor classes aligned vertically to the right of the package
15:51llasram`Ohh, I see. I think for me the code ex vs not trumps me vs normalized auto-indentation
15:52llasram`clojure-mode has some backtracking indent stuff... I haven't looked into it closely, but maybe it could be taught that :import vectors indent like function application?
15:53hiredmancode ex?
15:53hiredmananyway forget I asked, I don't care
16:03tolstoySo… is it not good to remove items from a list you're iterating over in a doseq? I wouldn't even ask, but it seems to work!
16:05amalloytolstoy: whatever it is you think you're doing, you're probably not doing
16:05TimMchaha
16:05tolstoyWell, I've got an atom which maintains a list, and a thread that runs through it and removes "bad" items once in a while.
16:06tolstoyAnd by remove, I mean (swap! …).
16:06dnolentolstoy: why do that while iterating tho? instead of filter first then swapping the atom?
16:07tolstoydnolen: Cause I didn't think of it? ;)
16:07hiredmanwhy are you using an atom?
16:07tolstoySeveral threads of execution are manipulating it.
16:07ibdknoxyou probably should be doing that in a transaction
16:08tolstoyDoes deref give you an immutable copy of a list?
16:08TimMctolstoy: The main Clojure data structures are immutable.
16:08amalloytolstoy: every list is immutable
16:08tolstoyBasically, I have a bunch of socket-style resources I want to monitor. So it's just not cool immutable data structures.
16:08TimMcLists included.
16:09tolstoyAh, right. (remove fn @whatever) returns a new list. Got it. Knew I shouldn't've asked. :)
16:09amalloyatoms and refs simply hold mutable pointers to these immutable lists
16:09TimMctolstoy: But now you know!
16:10dnolentolstoy: I'm not a concurrency expert, but putting mutable things in immutable things is probably never a good idea.
16:10amalloytolstoy: fwiw, that remove is unlikely to be correct
16:10tolstoyHeh. Right. Understanding when reading is different than understanding when writing, at least for me. Practice!
16:10amalloyyou're likely to want (swap! whatever #(remove f %))
16:11tolstoyYep. That makes sense.
16:11TimMcdnolen: I've used refs of lists of GUI components.
16:12TimMcWhether you want to call GUI components "mutable" is another question, I suppose. They have setters, but their basic "value" doesn't change.
16:13dnolenTimMc: but what advantage is there to putting such things in refs? I'm honestly curious.
16:14TimMcI don't remember, come to think of it. :-/
16:16tolstoyamalloy: Well, your suggestions just killed my LOC count for the day. :)
16:17TimMcdnolen: I think it had something to do with two events possibly occurring concurrently, each of which had a handler that might modify the same part of the GUI. Then again, Swing only has a single thread for events...
16:17dnolenamalloy: mutable pointers is a bit of a simplification :) atoms and refs both have policies.
16:18amalloymutable pointers, with magic
16:26daniel___hi everyone
16:27daniel___i have a hash-map like this: {"a" 100, "b" 200, "c" 50} the numbers are probabilities and im trying to think of a way to select a value from the map based on this probability
16:29TimMcreductions with + across the keys might give you something to walk
16:29tolstoyfilter?
16:29clojurebotfilter is not map
16:31S11001001vals
16:31hiredman(let [m {"a" 100, "b" 200, "c" 50} total (apply + (vals m))] (first (shuffle (for [[k v] m itm (repeat (/ (* v 100) total) k)] itm))))
16:31hiredman,(let [m {"a" 100, "b" 200, "c" 50} total (apply + (vals m))] (first (shuffle (for [[k v] m itm (repeat (/ (* v 100) total) k)] itm))))
16:31clojurebot"b"
16:31TimMcdaniel___: ##(let [p '{a 100, b 200, c 50}, ks (keys p), cvs (reductions + 0 (vals p))] cvs)
16:31lazybot⇒ (0 100 300 350)
16:31hiredman,(let [m {"a" 100, "b" 200, "c" 50} total (apply + (vals m))] (first (shuffle (for [[k v] m itm (repeat (/ (* v 100) total) k)] itm))))
16:31clojurebot"a"
16:31hiredmanpossibly the slowest way to do it
16:32amalloyhah. not the most efficient way to do that
16:32TimMcdaniel___: Never mind, my method also requires sorting...
16:32jolyfor slowest, I was going to recommend picking a random key, incrementing a counter for it, and continuing the process until one counter exceeded the map value
16:33amalloyjoly: i think hiredman found something slower
16:33jolyI think you're right
16:34dnolen,(require '[clojure.set :as set)
16:34clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>
16:34daniel___i dont understand how you can compute these things so quickly :p
16:34dnolen,(require '[clojure.set :as set])
16:34clojurebotnil
16:34dnolen(set/map-invert {"a" 100 "b" 200 "c" 50})
16:34dnolen,(set/map-invert {"a" 100 "b" 200 "c" 50})
16:34clojurebot{50 "c", 200 "b", 100 "a"}
16:35hiredmanI have a bit of non-deterministic functionality, I've been trying to write a test for, doing similar things
16:35TimMcdnolen: Two probs might be =
16:35hiredmanalso comes up when writing markov chains
16:36amalloyyeah, incanter has an actually-efficient way to do this, which i used when writing a markov chainer
16:36amalloy$google clojure incanter roulette wheel
16:36lazybot[Overview - Incanter next API documentation] http://liebke.github.com/incanter/
16:36dnolenTimMc: ah yeah.
16:36hiredmaneach run is non-deterministic but it trends towards x
16:37hiredmanreal pain
16:37amalloyhttps://github.com/liebke/incanter/blob/0ab56c4c49d6b2cf4bf601dd4c6f5e481b06f788/modules/incanter-core/src/incanter/distributions.clj#L194
16:37gfredericksfinger trees could do it in log time, right?
16:39TimMcI think the incanter thing is basically what I was working towards.
16:39TimMcAccumulate a probability sum until it passes a random threshold.
16:41daniel___working my way through this incanter functions, trying to understand it
16:41daniel___thanks guys
16:48daniel___can someone explain loop [acc i] ?
16:48Apage43loop is a let you can recur to.
16:48Apage43if there's no recur inside, it behaves the same as let
16:48RaynesThat's the most genius explanation I've ever heard.
16:50raek(inc Apage43)
16:50lazybot⟹ 1
16:50jamiltronThis is probably my lack of understanding regarding java coming through, but is there some trick you have to do to qualify records across files?
16:50daniel___so (loop [acc 0, i 0] with recur 1 1) will recur with acc=1 and i=1...
16:50Apage43yup
16:51daniel___ok, thanks Apage43
16:51Apage43and of course you can only use (recur) in places where it's what the loop form would return
16:51jamiltronSo let's say I've defrecord'd a Person in person.clj. Now in core.clj I require person.clj as person - when I try calling (def me (person/Person. "stuff")) I get a "Unable to resolve classname" error.
16:52RaynesThat's because defrecord creates a class, which you'd need to import.
16:52RaynesIf you don't want to do that, defrecord creates a factory function for creating an instance. (->Person slots go here).
16:52RaynesNot sure if those factory functions were in 1.2 though.
16:53amalloyRaynes: no
16:53jamiltronI'm using 1.3 so that should work.
16:53Raynesamalloy: Wow. It took you exactly 4 seconds.
16:54Raynesamalloy: You must have "Raynes: no" bound to a shortcut or something.
16:54amalloyRaynes: no
16:54jamiltronHaha
16:54amalloysorry misclick
16:54amalloy:P
16:54Raynes;)
16:54jodaro no-bot
16:56daniel___,(macroexpand -->)
16:56clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: --> in this context, compiling:(NO_SOURCE_PATH:0)>
16:56jamiltronRaynes: Thanks, that factory function is just what I am looking for.
16:56daniel___,(macroexpand ->)
16:56clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/->, compiling:(NO_SOURCE_PATH:0)>
16:56daniel___,(macroexpand --> int double int)
16:57clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: --> in this context, compiling:(NO_SOURCE_PATH:0)>
16:57daniel___,(macroexpand -> int double int)
16:57clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/->, compiling:(NO_SOURCE_PATH:0)>
16:57Raynesjamiltron: There is another one, map->Person. It takes a map.
16:57daniel___what's the difference between -> and -->
16:57amalloydaniel___: someone is going to kill you in a moment. try /msging clojurebot, or asking a real question of humans
16:57Apage43isn't it ->> ?
16:57bhenry,(macroexpand (->> :a identity))
16:57TimMcdaniel___: macroexpand needs a single form
16:57clojurebot:a
16:57jamiltronRaynes: Huh, interesting.
16:57daniel___sorry
16:58raekdaniel___: "-->" is not something that is defined by Clojure
16:58daniel___,(macroexpand (-> int double int))
16:58clojurebot#<ClassCastException java.lang.ClassCastException: clojure.core$int cannot be cast to java.lang.Number>
16:58Apage43,(macroexpand (-> 1 inc inc))
16:58clojurebot3
16:58Apage43er
16:58TimMcdaniel___: /query clojurebot
16:58raekyou need to quote the expression you give to macroexpand
16:58raekit's a function
16:58amalloyApage43: you need to quote it, and you probably want macroexpand-all anyway
16:58bhenry,(macroexpand '(->> :a identity))
16:58clojurebot(identity :a)
16:58TimMc~macroexpand-all
16:58clojurebotexcusez-moi
16:59TimMcHmph, thought there was a factoid there.
16:59amalloy&(use '[clojure.walk :only [macroexpand-all]])
16:59lazybot⇒ nil
16:59amalloy&(macroexpand-all '(->> (range) (filter even?) (take 10)))
16:59lazybot⇒ (take 10 (filter even? (range)))
16:59raek-> lets you write (h (g (f x a b) c d) e f) as (-> x (f a b) (g c d) (h e f))
16:59amalloy&(macroexpand-all '(-> (range) (filter even?) (take 10)))
16:59lazybot⇒ (take (filter (range) even?) 10)
17:00TimMcraek: I think I prefer amalloy's example. :-)
17:00raekso the 'h' and its arguments 'e' and 'f' come close together in the code
17:05daniel___amalloy, why are they different?
17:05daniel___by what logic does -> put 10 at the end
17:07gfrederickseverything goes between the take and the 10
17:07gfredericksat each step the previous form gets inserted as the second element in the list
17:07gfredericks&(macroexpand-all '(-> (a) (b c d e) (f g) (h) (take 10)))
17:07lazybot⇒ (take (h (f (b (a) c d e) g)) 10)
17:07sritchiethink of each form replacing the commas of the following form: (-> (range) (filter ,,, even?) (take ,,, 10)))
17:08gfredericks"second element of the list" <~> "first argument of the function"
17:08TimMcdaniel___: -> means "thread each result in as the first argument of the next form"
17:08sritchieafter one expansion, you have: (-> (filter (range) even?) (take ,,, 10)))
17:08TimMcdaniel___: ->> is the same, but as "last argument"
17:08sritchieand after the second expansion: (take (filter (range) even?) 10)
17:09TimMcsritchie: You're using ->, which is incorrect for the functions involved...
17:10amalloyTimMc: the question was how 10 ends up last
17:10daniel___i see TimMc, thanks
17:11sritchieTimMc: good point, I just wanted to show the commas
17:11daniel___amalloy: i understand now... take is the function and -> passes it as the first argument (before 10)
17:11TimMcamalloy: Ah! I see.
17:12jodaroRaynes: woop! there's the recently on clojars notification.
17:12TimMcdaniel___: Bear in mind that -> and ->> don't actually "pass results around" -- they actually rearrange the code to produce the same result.
17:12Raynesjodaro: o/
17:12TimMc s/result./effect./
17:13daniel___TimMc: i understand that, it ends up the same once compiled
17:14amalloyme.panzoo/spaghetti sounds awesome if you say it aloud. i have to go look up what it does
17:14jodaroFinite State Machine
17:14jodaro
17:14Raynes$google panzoo spaghetti
17:14lazybot[jedahu/spaghetti - GitHub] https://github.com/jedahu/spaghetti
17:16daniel___({"'jB" 4530} {"m%g" 5622} {"SOE" 2090} {"X57" 5313} {"3L]" 3459}) im getting this, and it want the whole thing enclosed in one pair of {}
17:17amalloythat looks so mutable that it's almost...spaghetti code...*rimshot*
17:17daniel___(map #(hash-map % (fitness %)) population) is roughly what my code is to create the hash-map
17:17amalloy&(apply merge '({x 1} {y 2}))
17:17lazybot⇒ {y 2, x 1}
17:18jkkramer(into {} (map (just identity fitness) population))
17:18jkkramerjust=juxt
17:19daniel___jkkramer, whats just and identity?
17:19jkkramer,((juxt identity inc) 1)
17:19clojurebot[1 2]
17:20jkkramer,(identity 1)
17:20clojurebot1
17:20jkkramerdaniel___: makes sense?
17:21daniel___ok, why not just write 1? :/
17:21mdeboardlol
17:22jkkramerjust demonstrating what the function does
17:22daniel___wait ,(identity 2)
17:22jkkramerthe above is equivalent to (into {} (map #(vector % (fitness %)) population)
17:22daniel___,(identity 2)
17:22clojurebot2
17:23daniel___ok cheers
17:23jkkramerjuxt is a little hard to grok, but it's handy
17:23daniel___everything clojure is hard to grok
17:23amalloyclojurebot: juxt?
17:23clojurebotjuxt is usually the right answer
17:23daniel___at least for now
17:24amalloyclojurebot: juxt is a little hard to grok but it's the best thing ever
17:24clojurebot'Sea, mhuise.
17:24gfredericksclojurebot: grok is a little hard to juxt but it's the best thing ever
17:24clojurebotAlles klar
17:25daniel___lol
17:25daniel___What's 'Sea, mhuise?
17:26gfredericksif you pointed a gun to my head I'd guess portuguese
17:26amalloygfredericks: no way
17:26gfrederickswith very low confidence
17:26gfredericksamalloy: yes I would
17:26gfredericksuntil I'm better informed
17:26amalloynot anymore, now that someone's told you it's wrong
17:27gfredericksI guess that's true
17:27jkkramersounds like elfin or some other form of nerdspeak
17:27gfredericksdangit now I need to figure out what my second guess would have been
17:27jodarogaelic?
17:27jkkramerjodaro: google agrees
17:27amalloy$timer 4 0 0 clojurebot: forget grok |is| a little hard to juxt but it's the best thing ever
17:27lazybotTimer added.
17:27daniel___ok, i think i've got that function working
17:27jodarorad
17:27daniel___good time to call it a night
17:28amalloygfredericks: i'm hoping you'll have forgotten in four hours
17:28gfredericksamalloy: :-D
17:28babilenirish?
17:28daniel___,(repeat (print "nn all ") 5)
17:28clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NullPointerException>
17:28daniel___,(repeatedly (print "nn all ") 5)
17:28clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NullPointerException>
17:28daniel___damn u
17:28daniel___,(repeat 5 (print "nn all "))
17:28clojurebotnn all
17:29clojurebot(nil nil nil nil nil)
17:29daniel___,(repeatedly 5 (print "nn all "))
17:29clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NullPointerException>
17:29daniel___nvm
17:29babilenheh
17:29gfredericksdaniel___: gotta give it a function
17:30TimMcdaniel___: That worjks out to (let [x (print "nn all ")] (repeat 5 x)) ... and print returns nil
17:30daniel___,(repeat 5 #(print "nn all "))
17:30clojurebot(#<sandbox$eval27$fn__28 sandbox$eval27$fn__28@8de117> #<sandbox$eval27$fn__28 sandbox$eval27$fn__28@8de117> #<sandbox$eval27$fn__28 sandbox$eval27$fn__28@8de117> #<sandbox$eval27$fn__28 sandbox$eval27$fn__28@8de117> #<sandbox$eval27$fn__28 sandbox$eval27$fn__28@8de117>)
17:30daniel___yeah!
17:30daniel___just what i wanted
17:30gfredericksdaniel___: I meant for repeatedly
17:30daniel___,(repeatedly #(print "nn all ") 5)
17:30clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: sandbox$eval55$fn__56 cannot be cast to java.lang.Number>
17:30daniel___,(repeatedly 5 #(print "nn all "))
17:30clojurebot(nn all nn all nil nn all nil nn all nil nn all nil nil)
17:30daniel___got there in the end
17:30TimMcdaniel___: Please use lazybot or clojurebot in privmsg!
17:31gfredericksor get your own repl
17:32tolstoyCan't quite make it out from the cheat sheet, but is there a seq function like "filter" that returns two lists, everything that matches, and everything that doesn't match?
17:32TimMcseparate or some such
17:32amalloytolstoy: hint: as always, the answer is juxt
17:32TimMcamalloy: juxt it!
17:32TimMcdamn, beat me to it
17:33gfredericks,((juxt filter remove) even? (range 6))
17:33clojurebot[(0 2 4) (1 3 5)]
17:33TimMc(def separate (juxt filter remove))
17:33TimMc(clojure.contrib.seq/separate)
17:33tolstoyHah. That's a mouthful doc string on that.
17:34amalloyTimMc: you know what we do with people who recommend contrib...
17:34TimMcheh
17:35TimMcI'm partial to the first.
17:36pjstadigamalloy: thank them for pointing out functions that should have been migrated to new contrib instead of dropped?
17:36TimMcAnyway, that method does twice the necessary work.
17:37TimMcclojurebot: Where did contrib go?
17:37clojurebotwell... it's a long story: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
17:37amalloyTimMc: that's only sorta correct
17:38amalloypjstadig: ((juxt filter remove) f coll) is a lot simpler than (:use '[clojure.algo.seq :only [separate]]) (separate f coll) ;; pretending it got migrated to algo.seq
17:38jkkramerthe punishment for recommending a contrib function should be to port it to 1.3
17:38amalloy(inc jkkramer)
17:38lazybot⟹ 1
17:38technomancyjkkramer: yessss
17:39amalloyTimMc: you have little choice but to call filter and remove once each. you could arrange to call the predicate only once per item, but that would involve building a largeish number of lists, which is a waste of effort if the predicate is cheap
17:40amalloyan implementation that does call pred once per item is at https://github.com/flatland/useful/blob/develop/src/useful/seq.clj#L21 if it interests you, though
17:40Apage43separate just called filter and remove anyhow
17:42Raynes(juxt filter remove)
17:42RaynesOh.
17:42Raynesamalloy already did that. :<
17:43amalloyRaynes: it must really suck having a ten-minute latency to the irc server
17:43RaynesOr 10 minutes of scroll back that I didn't bother to read.
17:43amalloy(i don't have "Raynes: yes" on a hotkey, so i have to use snark)
17:47TimMcRaynes: Actually it calls filter and filter (complement f)
17:48TimMcamalloy: What about a loop/recur building two vectors?
17:48amalloyTimMc: not lazy
17:48TimMcaha
17:49amalloyyou can have laziness *or* "minimal work", but not both
17:49TimMcclojurebot: I am suddenly enlightened.
17:49clojurebotI don't understand.
17:50TimMcGood little zenbot.
17:50amalloyclojurebot: i don't understand is <reply> Suddenly, you are enlightened!
17:50clojurebotYou don't have to tell me twice.
17:50amalloyclojurebot is the best toy ever
17:51hiredmanit is true
17:52TimMcamalloy: So if you won't necessarily be consuming all the data, a lazy approach may be superior. But if you know you will consume everything, the loop/recur might be superior. (Assumes a predicate that actually does any real work.)
17:52amalloyTimMc: mostly true, but i don't think i totally agree
17:53amalloyperhaps the input collection is ten million elements, and i know i want to deal with them all
17:53amalloybut i don't need them all at once
17:53TimMcPoint.
17:53TimMcThere's more than one reason for laziness.
17:55amalloyTimMc: and if you're willing to do a lot of mutability, it should be possible to get minimal-work and something that's (mostly) lazy
17:57amalloyie, make the two resultant lazy seqs aware of each other, mutating each other and the input seq. if you try to read from the filter-seq, and the predicate fails, it mutably appends to the remove-seq
18:02amalloyi'm not sure i understand how ref-set interacts with transactions. is there anything actually broken about (dosync (ref-set r (f @r)))? of course an alter is better, but pretend the code is structured so that an alter is inconvenient - is this equivalent?
18:05archaicanyone use emacs evil-mode here? i need to integrate it with clojure-repl
18:06RaynesWe should not talk of the great mode-that-shall-not-be-named.
18:09sridhas anyone implemented capistrano-like tool on top of cake/lein?
18:09brehautRaynes: theres a hastur-mode ?
18:12technomancysrid: pallet is probably the best clojure deployment tool
18:13technomancywould that mean reinventing the concept of a task because you don't know how your build tool works? =)
18:16sridhmm. i'll use shell script for now .. just < 10 lines of scp, ssh, uberjar and nohup :)
18:17Apage43amalloy: they are requivalent from the way i read the source
18:17Apage43*equivalent
18:17mqsohCapistrano was just pissing me off!
18:19mqsohThis channel is very relevant to my life.
18:29TimMcamalloy: I wonder if there would be a nice way to design such a mutually-mutable lazyseq thingum.
18:30TimMcAs in, nice enough to casually use the API the way one uses lazy-seq.
18:30amalloyTimMc: probably not
18:30amalloyfor one, as i said it's only "mostly" lazy
18:31amalloyif your collection has a million items that fail the predicate, followed by one that doesn't, and you try to access the remove-seq, you'll have to keep the other million in memory in case you later try to access the filter-seq
18:31TimMcRight. :-/
18:45tolstoyJava-interop question: is there a clean way to match on the kind of exception I'm handed? (= (.getName (class ex)) "java.whatever.Exception"))?
18:46tolstoyHm. (= (class "adsadad") java.lang.String) works. Good enough I think.
18:47raektolstoy: also check out 'instance?'
18:47tolstoyAh, okay. Not having a good day finding these things. Thanks!
18:51gfrederickstolstoy: lazybot has a nice findfn feature
18:51gfredericks$findfn String "foo" true
18:51lazybot[clojure.core/instance? clojure.core/not= clojure.core/distinct?]
18:53amalloygfredericks: the unexpected answers are always the best
18:56TimMcIt would be nice for not= and distinct? to be blacklisted.
18:57TimMc$findfn 1 0
18:58lazybot[clojure.core/unchecked-dec clojure.core/rand-int clojure.core/dec]
18:58amalloyTimMc: i don't think they really come up that often
18:58amalloy$ findfn 0
18:58lazybot[clojure.core/+ clojure.core/release-pending-sends]
18:59amalloy&(doc release-pending-sends)
18:59lazybot⇒ "([]); Normally, actions sent directly or indirectly during another action are held until the action completes (changes the agent's state). This function can be used to dispatch any pending sent actions immediately. This has no impact on actions sent during a trans... https://gist.github.com/1299936
18:59amalloywell, you learn something new every day
18:59amalloy$findfn 1
18:59lazybot[clojure.core/*]
19:01gfredericks$findfn false
19:01lazybot[]
19:01gfrederickswhat would be a good name for (constantly false)?
19:01gfredericksmy first thought was "nope"
19:02gfredericks$findfn nil
19:02lazybot[clojure.core/cond clojure.core/dosync clojure.core/import clojure.core/prn clojure.core/refer-clojure clojure.core/print clojure.core/with-loading-context clojure.core/newline clojure.core/comment clojure.core/or clojure.core/load clojure.core/shutdown-agents cloj... https://gist.github.com/1299943
19:02gfredericksjackpot
19:21tolstoyDo agents get garbage collected?
19:22tolstoyNevermind: http://stackoverflow.com/questions/4609151/how-can-i-stop-a-specific-agent-in-clojure-when-are-their-states-garbage-collec
19:22chouserif they don't have any scheduled tasks, ys
19:22tolstoyOkay.
19:24amalloygfredericks: i sadly none of those are actually the same as (constantly nil), i suspect
19:25amalloythey're more like #(do nil), in that they require no args rather than ignoring their args
19:28gfredericksyep
19:28gfredericks$findfn ""
19:28lazybot[clojure.core/with-out-str clojure.core/print-str clojure.core/pr-str clojure.core/str clojure.contrib.string/as-str]
19:52technomancy`oh geez
19:52technomancy`joda-time 1.6 got deleted from maven central?
19:53technomancy`hm; search.maven.org claims it's still there
19:53technomancy`but it's not resolving
19:57duck1123is there a newer version, or is something funny going on?
19:57duck1123how long do they hold on to artifacts?
19:57technomancy`non-snapshots are supposed to stick around forever
20:22tolstoyIs there a place where you can stuff "classpath resources" in leiningen other than "lib"? (Such as property files, etc).
20:22technomancy`tolstoy: sure; property files should go in resources/
20:23tolstoyAh, okay. I did that. Seems that tools.logging + slf4j + logback isn't finding my logback.xml (like works automatically with Scala + SBT).
20:23technomancy`did you create the resources/ directory after launching the clojure process?
20:23tolstoyWho knows, could be some other issue. All this layering: sheesh.
20:24tolstoyNope.
20:24tolstoyCould be that it's on the class path just fine, though.
20:24technomancy`if (clojure.java.io/resource "logback.xml") returns something then it's on the classpath
20:25hiredmanwell, it's visible to some classloader somewhere
20:25technomancy`true
20:25hiredmanwow
20:25hiredmanyou can actually even pass in the classloader
20:26tolstoyWould using "trampoline" affect it?
20:26technomancy`tolstoy: lein trampoline or clojure.core/trampoline?
20:26tolstoylein trampoline.
20:26tolstoyIt does seem to affect it.
20:27technomancy`ah... interesting.
20:27tolstoyI use trampoline because I'm messing with a lot of long-running persistent thread stuff and want to see the shutdown hooks work.
20:28tolstoyWait! Hold on! I think "lein trampoline" is just fine.
20:30technomancy`whew
20:32tolstoyYeah! No kidding!
20:34technomancy`,(when (re-find #"Microsoft FrontPage" (slurp "http://shenlanguage.org&quot;)) (println "ಠ_ಠ"))
20:34clojurebot#<AccessControlException java.security.AccessControlException: access denied (java.net.SocketPermission shenlanguage.org:80 connect,resolve)>
20:34technomancy`dang it
20:35technomancy`well anyway, ಠ_ಠ
20:49amalloytechnomancy`: clojurebot is just looking out for you. don't look at frontpage sites
20:49amalloyit's for your own good. you'll understand when you're older
20:49technomancy`amalloy: it gets worse: <meta name="Originator" content="Microsoft Word 12">
20:50amalloytechnomancy`: placing a <font> tag inside a <style> tag is a nice touch
20:50amalloyer, an <a style="..."> tag
20:51gfrederickshow have I gone this long with clojure without consciously realizing that slurp works with urls?
20:51technomancy`gfredericks: it snuck in during 1.2
20:51gfredericksI feel like I've even read it in the docs a number of times
20:51gfredericksI'm appalled
20:51gfredericksno more learning programming languages for me
20:53gfredericksoh good ##(doc slurp) doesn't mention it at all
20:53lazybot⇒ "([f & opts]); Reads the file named by f using the encoding enc into a string and returns it."
20:53technomancy`I thought I opened a ticket for that
20:53technomancy`&(clojure-version)
20:53lazybot⇒ "1.2.0"
20:53technomancy`oh, right
20:54gfredericks,(clojure-version)
20:54clojurebot"1.3.0"
20:54gfredericks,(doc slurp)
20:54clojurebot"([f & opts]); Opens a reader on f and reads all its contents, returning a string. See clojure.java.io/reader for a complete list of supported arguments."
20:54gfredericksaah
20:55gfredericksit's nice to have diversely-versioned bots. Is lazybot lagging on purpose?
20:57gfredericksmaven compiles for java 1.3 by default? :/
20:58gfrederickseither that or my pom is haunted
21:01amalloygfredericks: no, Raynes is pretty close to getting lazybot on 1.3
21:03Raynesamalloy: It should be perfectly ready to go live.
21:03Raynesamalloy: We just need to be vigilant.
21:03amalloyyeah, i know. but it isn't actually live yet, so you're only pretty close
21:03RaynesI'll consider throwing it up later.
21:04amalloyi wish i could think of something funny to teach clojurebot related to that. foo is <Raynes> I'll consider throwing it up later
21:06gfrederickssomebody ought to put up an eval-only version of lazybot on 1.2. What would be a good name? fuddyduddybot?
21:06amalloyclojurebot: Raynes?
21:06clojurebotif it's not one thing it's another
21:06technomancy`amalloy: "Clojure 1.3: if swallowed, do not induce vomiting"?
21:06jodaroRaynes: http://www.joshrotenberg.com/wotd
21:06jodaroit works
21:08amalloythis is unacceptable. how are there #clojure regulars that clojurebot doesn't have a soundbyte for?
21:08gfredericksclojurebot: amalloy?
21:08clojurebotamalloy is <amalloy> just use juxt, it'll be great
21:11amalloy(inc clojurebot)
21:12gfredericks(dec lazybot)
21:13amalloygfredericks: weird, because his karma plugin claims to be loaded
21:13gfredericksjustification: [lazybot didn't respond] or [law of conservation of bot karma]
21:13archaicwhy would (iterate inc 0) be used over (range) ?
21:14gfredericksarchaic: to demonstrate iterate?
21:14gfredericksor because one forgot about range
21:14amalloygfredericks: more reasons than that, keep going
21:15gfrederickschunked seqs!
21:15amalloyyeah, that's the most likely
21:15archaicahh k
21:15gfredericks,(map type (range) (iterate inc 0))
21:15clojurebot#<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (2) passed to: core$type>
21:15gfredericksboo
21:15gfredericks,(map type [(range) (iterate inc 0)])
21:15clojurebot(clojure.lang.LazySeq clojure.lang.Cons)
21:15gfredericksyep, exactly not what I expected
21:15amalloy&(take 1 (map print (range)))
21:15lazybot⇒ (012345678910111213141516171819202122232425262728293031nil)
21:16amalloy&(take 1 (map print (iterate inc 0)))
21:16lazybot⇒ (0nil)
21:16brehautgfredericks: iterate already has the first value computed, so it doesnt define it lazily, the lazy-seq is not the outermost element
21:16brehauts/element/form/
21:17gfredericks,(type (rest (iterate inc 0)))
21:17clojurebotclojure.lang.LazySeq
21:17brehautgfredericks: the body of iterate is (cons x (lazy-seq (iterate f (f x)))))
21:17duck1123&(take 2 (map print (iterate inc 0)))
21:17lazybot⇒ (01nil nil)
21:18amalloybrehaut: there was a mailing list thread about that a week or two ago; i kinda wish iterate were all lazy anyway
21:19brehautamalloy: interesting
21:19amalloybecause 1.3 allows you to call (realized?) on a lazy seq
21:19brehautdev or normal list?
21:19brehautamalloy: ah of course
21:19amalloynormal i think
21:19amalloybut if you try it on a Cons, you just get a classcastexception
21:20brehautrealized? is for lazy things, futures and promises right?
21:20amalloyperhaps making Cons implement IPending by always returning true is a better solution, though
21:20amalloybrehaut: and delays, iirc
21:21brehautjust to double check, delays are lazy right?
21:21amalloyunclear on what this question means
21:21gfredericksit's either nonsensical or tautological
21:21amalloya delay is a cached thunk
21:21brehautyeah, so a delay falls into the category of lazy things?
21:21gfredericks,(realized? (delay "FOO"))
21:21clojurebotfalse
21:21amalloybrehaut: sure, if you say so. i don't think it much matters whether you say that's true or not
21:22gfredericks,(let [d (delay "FOO"), s (str @d)] (realized? d))
21:22clojurebottrue
21:23amalloyto me it seems different from laziness: sequences automatically force themselves whenever needed, whereas delays are objects you can pass around and have to explicitly force
21:24gfredericksamalloy: i.e., laziness can usually be forgotten about but delays are explicit?
21:24duck1123they're super-lazy
21:24brehautthats an interesting distinction
21:26duck1123Is there a way I can make my app finish up all of it's asynchronous tasks and logging before moving on to the next test?
21:26duck1123I'm using clojure.test and midje, if that helps
21:27amalloyduck1123: await on your agent, or deref your future?
21:27lazybotclojurebot forget grok |is| a little hard to juxt but it's the best thing ever
21:27duck1123amalloy: I think I might need to re-engineer things so that I can always track my triggers
21:28amalloyargh dangit lazybot. it's totally my fault that he drops the : in those messages
21:29amalloyduck1123: or just (Thread/sleep Integer/MAX_VALUE) to be extra-safe
21:29duck1123That might be a good quick and dirty solution, but it takes long enough to run my tests as it is
21:30duck1123My problem is the actions in my system launch triggers which in turn call other actions, so when I get an error, it's all mixed up with the output of other tests
21:32duck1123thankfully, I had the foresight to assign my executor service to a ref, so I might be able to make this work
22:35gfredericks(binding [future (something else)] ...)
22:56archaicjesus: In 1997, the Gartner Group reported that 80% of the world's business ran on COBOL with over 200 billion lines of code in existence and with an estimated 5 billion lines of new code annually
22:58brehautapocryphal: apparently when .net was very young and there was a lot of buzz about 'every language needs to run on this common runtime' the cobol people had a bit of a panic about how they were going to make cobol OO (because of course everything on .net needs to be OO), during the fuss someone discovered that there had been an object cobol spec for years
23:21Raynesamalloy: Guess what I did.
23:21amalloy&*clojure-version*
23:21lazybot⇒ {:major 1, :minor 2, :incremental 0, :qualifier ""}
23:21Raynesamalloy: I committed my API key in the README: https://github.com/Raynes/ororo
23:21RaynesI just got a notice that I went over my limit. Luckily, all I had to do was regenerate my key.
23:22RaynesBut hey, it's a real-world example, isn't it? ;)
23:22amalloyhaha that's so weird. who spams wunderground api requests?
23:22brehautRaynes: is that an xmen joke?
23:23amalloy(inc brehaut)
23:23RaynesThere were like 80 today, so people were probably just using it and playing with it. I doubt anybody purposely made it happen. They probably didn't know it was a limited private key.
23:24Raynesbrehaut: Yes.
23:24RaynesNot so much a joke as a homage?
23:27jodaroi did that with the first commit of wordnik
23:27jodarodeleted and recreated the rep
23:27jodaroo
23:28Raynesjodaro: At least it was the first commit.
23:28RaynesBut hey, all I had to do was generate a new one. No harm done.
23:29Raynesamalloy: Actually, it's 500 per day. Wow. Somebody must have seriously spammed the server.
23:29RaynesThere is an evil Clojure programmer in our midst. Beware.
23:30ibdknox_wasn't me... this time.
23:30jodarothats a lot of weather
23:30RaynesAnd I've found it.
23:30Raynesamalloy: https://github.com/Raynes/ororo/commit/cc4f7fcfec001f4099a191e3129c2cf0cbad820f#commitcomment-663108
23:31RaynesI knew he was evil. I could smell it in his emails.
23:33jodaroi think theres a rage comic in there somewhere
23:33jodaronew idea for library - get it working - commit api key to github - ffffuuuuuu
23:43aperiodicdoes anyone know whether it's possible to use a builder pattern API that employs static class methods in clojure?
23:44brehautaperiodic: are you asking if you can call static methods on java classes?
23:44aperiodicfrom the docs for the dot special form it seems that it might not be, but i'm not quite sure what's going on under the covers
23:44aperiodicbrehaut: no
23:45aperiodicbrehaut: the question is whether one can "thread" static method calls
23:45aperiodicbrehaut: the API in question is apache.commons.cli.OptionBuilder
23:46aperiodichttp://commons.apache.org/cli/api-release/org/apache/commons/cli/OptionBuilder.html
23:47brehautby 'thread' do you mean ->
23:47brehaut,(-> "123" Integer/parseInt) ; frinstance?
23:47clojurebot123
23:47aperiodicideally, yes
23:48aperiodicthe methods of the API all appear to be static class methods
23:48aperiodicso, e.g. (-> OptionBuilder (. withLongOpt "foo")) works as expected
23:50aperiodicbut (-> OptionBuilder (. withLongOpt "foo") (. withDescription "bar")) gives a "No matching method found" exception
23:50brehautyou may need to type hint some things
23:51brehautaperiodic: do you understand how threading works?
23:51brehautbecause i think you might actually want doto in this instance
23:52aperiodicheh, i think i was replicating doto with ->
23:53aperiodicthreading just iteratively inserts each form as the second member of the next form, right?
23:53brehautyeah
23:53brehautor the last with ->>
23:53brehautbased on that javadoc im a little surprised that what you tried above didnt work
23:55aperiodici think the issue is the identity of the result of the first static method call
23:58amalloyaperiodic: you have to write something like (-> (OptionBuilder/withLongOpt "foo") (OptionBuilder/withDescription "bar"))