#clojure logs

2010-11-01

00:00rata_technomancy: IIRC you said me some days ago how to change the indentation of forms in swank-clojure and, IIRC again, it was with the define-clojure-indent elisp macro, but it doesn't work anymore
00:04phobbs,(seq? [])
00:04clojurebotfalse
00:05phobbs,(seq? '(1 2 3))
00:05clojurebottrue
00:11rata_ping?
00:11clojurebotPONG!
00:15ymasorywhat's the difference between the signatures "(a & b)" and "(a b*)"?
00:16qbgI think Clojure is making my ability to deal with state weaker; I cannot seem to convert a small program from using PersistentVectors to using byte arrays...
00:16qbgymasory: Not much
00:17qbgThe first one would appear in the arg vector of a function
00:18quizmehow do you do optional arguments gracefully ?
00:18quizmelike if I want to pass in an options map into a function
00:20qbgDo you want a literal options map or not?
00:20ymasoryqbg: how would the second one appear?
00:21qbgThe argument vector would be something like [required args & options]
00:22qbgAnd then inside you have (let [{:keys [values i care about] :defaults {:values 5 ...}} options] ...)
00:22qbgI mean :or instead of :defaults
00:22qbgAnd values instead of :values
00:23qbg(let [{:keys [values i care about] :or {values 5 ...}} options] ...)
00:24quizmeqbg hmmm
00:24qbg,((fn [& opts] (let [{:keys [a b] :or {a 1 b 2}} opts] [a b]) :a 4)
00:24clojurebotEOF while reading
00:24qbg,((fn [& opts] (let [{:keys [a b] :or {a 1 b 2}} opts] [a b])) :a 4)
00:24clojurebot[4 2]
00:24qbg,((fn [& opts] (let [{:keys [a b] :or {a 1 b 2}} opts] [a b])))
00:24clojurebot[1 2]
00:25quizmecool
00:25quizmethanks
00:34quizmeqbg: In your first example, where the user provided the option :a as 4, what if we wanted to multiply 4 by 2 first within the let block?
00:38qbgOnly if it is provided?
00:38_seanc_Any thoughts to as why I get this exception when running lein uberjar: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil (jar.clj:17) ?
00:43ymasorythanks
00:44rata_is there any place where to learn how use/import/require work? (besides doc)
00:45rata_I really don't understand why this doesn't work (or how to solve it) and am getting frustrated
00:51absurdoanybody know how to get more meaningful error messages with emacs+slime+swank-clojure? i'm not seeing line # information in stacktraces. it's very difficult to tell exactly where any exceptions are occurring when i eval code in the repl.
00:55quizmeqbg: yeah
01:01quizmeqbg: am i asking for too much?
01:12replacarata_: still there?
01:12rata_replaca: yes
01:12replacathere's not a really clear write-up that I've seen (except in the joy of clojure), but I'm happy to lay it out for you
01:13replacaare you using them inside the ns macro or on the command line?
01:14replaca(oh, and I assume by "how they work" you mean how to get them to do what you want, not how are they implemented inside the clojure system)
01:15rata_yes, I'm using them inside the ns macro
01:16rata_(both are interesting for me... if I need to learn the latter to solve the problem, then I'll try to learn it)
01:16rata_s/for/to/
01:16sexpbot<rata_> (both are interesting to me... if I need to learn the latter to solve the problem, then I'll try to learn it)
01:16replacaok, let's start with the simple stuff: import allows you to reference java classes and is not releated to clojure symbols at all (:import [java.util.Date])
01:16replaca(ah, you shouldn't need to know the impl)
01:17rata_not even related to defrecord?
01:17replacanope, defrecords get pulled in from clojure (I think? hmm, now I'm wondering about that)
01:18replacarequire will make sure a namespace is loaded, but doesn't pull the names into your current namespace
01:19replacaso (:require [clojure.zip]) lets you say things like (clojure.zip/branch? node)
01:20replacause does a require + it loads the names into your current namespace
01:20rata_yes... I wasn't sure it allow to do something like (require 'x) (x.Record. ...)
01:20replacaso (:use [clojure.zip]) lets you say (branch? node)
01:20rata_but it allows you to do so indeed
01:21replacaahh
01:21replacait's not x/Record. in that case? I haven't played with records much yet
01:22rata_:use doesn't let you use records... at least (use '[x :only (Record)]) doesn't work
01:22replacaand then you can refine them: (:use [clojure.zip :only [branch children]]) pulls just those two
01:23RaynesSomething weird that I noticed: &| (use '[clojure.contrib.json :as json]) |& &| (json/pprint-json nil) |&
01:23clojurebotIn Ordnung
01:23sexpbot (use '[clojure.contrib.json :as json]) ⟹ nil
01:23sexpbot (json/pprint-json nil) ⟹ nullnil
01:23RaynesIt's odd that you can use :as in use. It seems to kind of defeat the purpose.
01:23replacaand (require [clojure.zip :as zip]) lets you say (zip/branch? node)
01:24replacaRaynes: yeah, but I think you can then also say (pprint-json nil) there
01:24replacasince you've used it
01:24Raynes&(pprint-json nil)
01:24sexpbot⟹ nullnil
01:24RaynesOh.
01:24RaynesIt's still kind of odd.
01:24replacawell, it does a require first. But I tend to agree.
01:24clojurebotuse vs require is (:use [lib :only [a b c]) or (:require [lib :as alias]) -- (:use lib) is only for playing around
01:25RaynesBoy, he sure is talkative lately.
01:25replacarata_: so was require + defrecord where you were stuck?
01:26rata_it was :import
01:26rata_I was importing the classes generated by defrecord
01:26rata_probably that was what was wrong
01:27replacayeah, I *think* the thing there is that the classes created by defrecord don't exist in exactly the same way that regular java classes do, since they are generated on the fly when the clojure code is compiled.
01:28rdsrrata_ how about defining a simple "make" function which would create a record and return it
01:28replacaimport expects to use the classloader in the usual Java way
01:28rdsr"make" would be present in the same ns in which you have defined the record
01:28rata_I'll try first with require
01:29replacardsr: I don't think you need to do that. Just use require and don't get too distracted by the . at the end of the constructor function
01:29replacarata_: That is working for you, right?
01:29rdsrreplaca: hmm will try that
01:30rata_I must change things at some places yet
01:30LauJensenMorning guys
01:31rdsrmorning
01:32rata_morning LauJensen
01:37rata_writing c/handler-case instead of handler-case mess up the indentation :(
01:37rata_(and highlighting of the word)
01:40replacaHey LauJensen
01:41replacarata_ was asking about how to refer to a record defined in another namespace and I recommended require, but that's not working in my little test case. Can you enlighten us?
01:42LauJensenreplaca: Best not refer to the actual record unless you have a specific use-case. Insead call its factory functions
01:43replacathe constructor made by defrecord or a factory function you create yourself in the same namespace?
01:44replaca(I haven't used defrecord much yet, so I'm behind on its nuances)
01:53replacarata_: not to disagree with Lau's point (which I think is fundamentally correct), but you can do it. It's more complex than I would have thought and Alex Miller outlines how here: http://tech.puredanger.com/2010/06/30/using-records-from-a-different-namespace-in-clojure/
01:55rata_replaca: thanks :)
01:56rata_so I need require and import
01:56replacayup
01:56rata_or maybe it's easier to write a factory function and just require the ns
01:58replacarata_: I'm not sure it's actually easier (I tried Alex's solution and it's pretty easy), but as Lau suggests it's probably better style
01:59rata_ok :)
02:00replacaAs often happens in #clojure, I tried to explain something and ended up learning something instead :)
02:06replacatechnomancy: is lein repl an nrepl?
02:07rata_replaca: in this place one's learning all the time :)
02:08replacarata_: indeed!
02:09amalloyAny word on conj videos being posted?
02:09replacaamalloy: I haven't heard anything yet
02:10amalloyC'est la vie. In due time, I guess
02:11replacaamalloy: I hope so. I was there and there are a couple I'd like to see again
02:11replacaand allmost all of them deserve a wider audience
02:12amalloyHeh. I was away for the weekend and hoped I'd get a coming-home present
02:12replacaahh, well. As you say, in due time.
02:14amalloyIndeed
02:25amalloyWow, I didn't know about re-seq. That's much nicer than my hacked-up version
02:41amalloyRaynes: respond.clj doesn't look totally thread safe
02:46amalloyRaynes: swap! in respond.clj isn't used in a thread-safe way.
02:46vibrantamalloy; http://joyofclojure.com/ <- reading it now, opened my eyes on many things
02:47vibrantand it's like $17 after the discount so it's a sin not to grab a copy
02:48ubiijust started reading it tonight, good book so far
02:49amalloyGlad to hear it, vibrant. Did I recommend it?
02:50vibrantamalloy; i'm recommending it :)
03:19Raynes$mail amalloy Not entirely certain what you mean. I've never had a problem with it.
03:19sexpbotMessage saved.
03:23Raynes$mail amalloy In any case, if you really care, that particular atom should be disposable. You should be able to just throw the counter in the bot ref.
03:23sexpbotMessage saved.
04:04LauJensenrata_: Sorry I had to duck out. Looks like you got it sorted. FYI, you provide factory fns yourselves, which has at least 3 major benefits, 1) easier import, 2) var-args in constructor, 3) no need to change signature if you add a field to the record
04:08rata_LauJensen: I haven't sorted it out yet... it takes some time to change every :use to :require
04:08rata_(and I'm helping my sister at the same time)
04:18rata_LauJensen: it doesn't work... I don't know why
04:43rata_mmmm... the problem was unrelated to the import/require/use thing... I should go to sleep
04:44bobo_(require 'rata_.sleep)
04:50rata_anyway, it was a good thing to put all those :use and :import as :require... it's supposed to be better style :)
04:52rata_good night guys
04:58LauJensenHi bobo_, got back alright?
05:00rdsrHi folks, need some help on understanding macros....
05:00bobo_LauJensen: yes indeed! except noone replaced php while i was gone
05:01LauJensenaww thats a bummer, so you dont get to use your new clojure chops? :(
05:01rdsrwas reading through joy of clojure (macros chapter)
05:01rdsrbut can't really undertand their code
05:01rdsrhttp://gist.github.com/657857
05:02rdsrbasically I'm confused with forms like "'~'"
05:03bobo_LauJensen: no not yet, but ive started some evil plans to use incanter. Fits realy well
05:03raekhrm, that is actually not a macro, but it kind of works like one
05:04rdsrs/"'~'"/'~/
05:04sexpbot<rdsr> basically I'm confused with forms like '~
05:04raekrdsr: ` "syntax-quote" is a feature that lets you build quoted data structures
05:04raekinside it, ~ unquotes
05:04raek, (let [x 5] `(foo bar ~x))
05:04clojurebot(sandbox/foo sandbox/bar 5)
05:05rdsrraek, but what does it mean when you unquote something and quote it again
05:05rdsrlike in the above gist
05:06rdsrspecfically e.g. `('~ctx '~%))
05:06raekthe generated code will have whatever is in ctx quoted
05:07raekif ctx is foo and % is bar, the generated code will be ('foo 'bar)
05:08rdsrthanks raek, but why is that necessary?
05:08rdsrI mean ofcousrse its necessary, but I fail to understand why ? :P
05:11raekI'm not acquainted with what that code does...
05:12raekyou could try evaling the expression inside eval and see what code it generates
05:12cemerickLauJensen: did you hear back from jvanzyl?
05:12rdsrthanks raek, I'm trying to wrap my head around it :)
05:12LauJensencemerick: http://twitter.com/jvanzyl/status/29216397264
05:13cemerickok
05:13raekthis is not the most simple example of a macro
05:13raek(it isn't even macro)
05:15hoeckrdsr: the ('~ctx '~%) places the context-map in a list, leading to the following expression: ('{a 1} 'a), where {a 1} is the context-map ctx
05:15cemerickLauJensen: It looks like Antony was the last to touch the Clojure side of pmaven. I'd loop him into whatever discussions you, technomancy, and ninjudd want to have.
05:15rdsryes true, I think the chapter starts with syntax-quote, quote ..etc and hasn't introduce defmacro yet
05:15raekI see.
05:15LauJensencemerick: Antony who ?
05:16cemerickAntony Blakey; has corresponded on the ML before re: lein/pmaven structure. Also, the last to touch the clojure pmaven impl: http://github.com/sonatype/polyglot-maven/tree/master/pmaven-clojure/src/main/clojure/org/sonatype/maven/polyglot/clojure/dsl/
05:16hoeckrdsr: and because the map is expected to contain a mapping from symbols to values, it is quoted so that the symbols are not evaluated themselves
05:17LauJensencemerick: got an email addr?
05:17rdsrhoeck, thks for the explanation, makes things definitely cleearer, ...
05:18hoeckrdsr: if you call the fn with (contextual-eval '{a 1} '(- a)) it returns -1
05:18cemerickLauJensen: Antony Blakey <antony.blakey@gmail.com>, though I'd suggest finding his posts on the subject on the ML, which might be helpful as-is?
05:18LauJensenright, thanks
05:18LauJensencemerick: Did you notice a question for you in the latest round of emails?
05:18raek(contextual-eval {'a 1, 'b 2} '(+ a b)) expands to:
05:18raek(let [a ('{a 1, b 2} 'a) b ('{a 1, b 2} 'b)] (+ a b))
05:19hoeckrdsr: if you leave off the single-quote in the contextual-eval defintion `(~ctx '%) you will get an "unable to resolve symbol a" exception
05:19cemerickLauJensen: yes; will reply later today
05:19hoeckrdsr: hope that helps a bit :)
05:19LauJensengreat, thanks
05:19rdsrdefintely!
05:32fliebelGood morning(gmt+ … oh damn, daylight saving time, uuhm)
05:33LauJensenclojurebot: UGT?
05:33clojurebotugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html
05:36fliebelLauJensen: Good one… But it's also helpful to know in which timezone someone is to estimate their state of mind.
05:36LauJenseneh...ok
05:36esjmorning all
05:36esjand happy monday
05:37fliebelmorning esj
05:37LauJensenesj: morning! i estimate your state of mind to be nil
05:37LauJensenfliebel: oh you're right! its impossible with UGT :(
05:37clojurebotplease show us that ugt is not broken
05:38esjLauJensen: always with a kind word for a fellow traveller :)
05:38LauJensenThats right buddy, how are you doing? :)
05:38LauJensenesj: What I said was in response to this
05:38LauJensen<fliebel> LauJensen: Good one… But it's also helpful to know in which timezone
05:38LauJensen someone is to estimate their state of mind. [10:24]
05:38LauJensen
05:38esjI'm great ! I'm 100% free.
05:38LauJensenAh great - So now its time to get busy!
05:39esjExactly. I'm taking November as a 'sabattical' to recover my wits and energies.
05:39esjfirst job is to read 'the reasoned schemer'
05:40esjbut enough about me. How are you doing ?
05:42LauJensenAlso doing good. Conj Labs Frankfurt was fun and the DSL discussions gave me some new ideas for ClojureQL
05:42LauJensenAlso was nice to get to meet sthubner and bobo_ in RL
05:42fliebelLauJensen: London is next, right?
05:42LauJensenRight!
05:42esjI'm in !
05:43esjgonna be jetlagged out of my mind, but I'll try my best to keep up
05:43fliebelLauJensen: And then Amsterdam? :D
05:43sthubnerLauJensen: I second that!
05:43LauJensenfliebel: Quite possible. Its not settled yet, but I have no better ideas... Unless we should try something fancy like a south pacific island
05:44LauJensenesj: great. Just make sure you get some sleep on the plane and you should be fine. cgrand survived anyway :)
05:44esjand he had to battle striking Frenchies !
05:44LauJensentrue - They were no match for his DSL fu though
05:45fliebelHave any of you seen this one? http://github.com/honza/clitwi I like the idea, but not the execution. It'd be nice to make a streaming one with Aleph, but I can;t find anything to make oauth work.
05:45esjwhat a name...
05:45arbschtLauJensen: south pacific island? I know of one...
05:45TobiasRaedermorning everybody :)
05:45LauJensenfliebel: Twitter OAth is broken atm. Twitter changed the API sligty, the implementer of the protocol hasn't recovered yet
05:45esjmorphling: TobiasRaeder
05:45fliebelesj: Don't worry, it's just a terminal twitter client in Python.
05:46fliebelLauJensen: Huh? My Twitter client still seems to work.
05:47LauJensenfliebel: clj-oauth I mean
05:47LauJensenI wasn't prepared for Python questions in #clojure, sorry
05:47fliebelLauJensen: I wasn't asking about Python, was I? *confused look*
05:48LauJensenNow Im confused, back to coding
05:48fliebelLauJensen: While I might want to do such a thing, because people in #clojure seem to be very friendly compared to channels like #python and #macports :(
05:48zeroflag_whats the problem with twitter oauth?
05:49fliebelLauJensen: But if it was fixed, clj-oauth will work with aleph?
05:49LauJensenzeroflag_: The protocol now requires an expiration field in the header, which is reasonably close to current time. This isnt implemented yet
05:49LauJensenfliebel: I think so
05:49zeroflag_hmm
05:50zeroflag_i'm using oauthsignpost and i haven't experienced any problem
05:52fliebelzeroflag_: I need to sign Aleph requests, so something with Ring is required I think.
06:04zeroflag_actually oauth can cause a lot of trouble especially when you have to use it from an desktop application
06:04zeroflag_and it doesnt provide any extra security in case of an installed app
06:05zeroflag_i still don't understand why do they try to force it
06:16fliebelWhat do I do with a UnmodifiableMap?
06:17cemerickfliebel: anything you can do with a j.u.Map
06:18fliebelcemerick: Uh, okay… I can convert those to Clojure maps right?
06:18fliebelcemerick: Is it considered more Clojuric to convert hem, or to get values from them directly?
06:20cemerickfliebel: There's rarely any reason to convert them. e.g. (:foo some-map) and (get some-map "other key") both work just fine with all j.u.Maps
06:20cemerick(some-map :key) won't work, but that's not really idiomatic (in part because of this issue)
06:22fliebelright, thanks :)
06:32fliebeloh, what is the function to turn [[1 2 3] [1 2 3]] into [[1 1] [2 2] [3 3]]? I did some Python the other day, and they call that zip, but now I lost the Clojure term.
06:32jjidointerleave?
06:32raek,(map vector [1 2 3] [1 2 3])
06:32clojurebot([1 1] [2 2] [3 3])
06:44fliebelClassic problem: I need a custom jar on my path with lein or cake. Last time the solution was to fumble with maven, but I heard there is something new lein with a resources folder?
06:45raekresources/ itself is included in the classpath, so not any jars in it
06:46raekit is inteded for things that are not source files, but needs to be included in the jar of the project created with lein jar
06:46fliebelraek: Then it wasn;t resources, but something else intended for checkouts of other jars or… I can't remember
06:48raekwell, there's the "checkouts" feature, but that's for other lein/cake projects that are not available as jars yet
06:49raeklike unreleased or bleeding edge libs
06:50fliebelraek: Okay, so what do I do with this jar?
06:51LauJensenfliebel: You can put the jar file in your local maven repo using 'cake install' and add it as a dependency
06:52LauJensenIf you have the source, it might be better to add it as a subproject though, in which case cake will automatically handle everything for you
06:52fliebelLauJensen: I have the source. It's not Clojure though.
06:52LauJensenOk, then just go with the jar
07:08fliebelI'm playing with incanter, and I have a seq of results from frequencies. Like so: ({7 256} {7 204, 87 52} …) What would be the correct function to plot these?
08:04fliebelI'm doing a few map calls on a huge seq, but map is lazy. So I'm not actually looping over the seq a dozen times, am I? I'm a little worried about speed, because in Python it'd be orders of magnitude faster to do one loop with all the functions.
08:06LauJensenfliebel: You can test yourself. Map is chunked-lazy
08:06LauJensen&(let [s (map #(print % " ") (range 40))] (first s))
08:06sexpbot⟹ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 nil
08:07LauJensenafk
08:07fliebelLauJensen: Right, so this will require some (time (dotimes magic I guess.
08:22Chousukefliebel: you're only going over the seq once, really
08:22Chousukebut the thunking does add some overhead
08:23Chousukeif you can, it might be more efficient to combine the functions somehow and do a single map operation.
08:23fliebelChousuke: Thanks :) I'm fine as long as it's not dog-slow looping over the whole thing a dozen times.
08:24fliebelLauJensen: The "cake install <jar>" is not doing anything I think. Am I right in that it install my current project into the repo? What I need is some random jar in my project ;)
08:28LOPPI have a problem installing leiningen
08:28LOPPwhen I run it on win32 as lein self-install it says that I already have the jar, which is a ridiculous lie
08:41fliebelWhat is this supposed to mean? "Var incanter.core/$data is unbound." I didn't use that thing.
09:16tonylmorning
09:27fliebelhuh? get is failing me.
09:27fliebeluser=> f
09:27fliebel{7 101, 87 155}
09:27fliebeluser=> (get f 7)
09:27fliebelnil
09:29tonyl,(get {7 101 87 155} 7)
09:29clojurebot101
09:29@rhickeyfliebel: what clojure version?
09:30@rhickeyfliebel: (map class (keys f))
09:30fliebelrhickey: 1.2 I guess
09:30fliebelrhickey: they're bytes :(
09:30@rhickeythere you go
09:31fliebelrhickey: Good thinking! Thanks :) Now how do I get the items out of there?
09:32chouser(get f (byte 7))
09:32fliebelchouser: Great :) Works :)
09:32@rhickeychouser: hrm, that's more encouraging of using coercions for boxing, won't work in the future
09:33chouserrhickey: the boxing is secondary there, isn't it? The point is to coerce to a byte or Byte
09:34@rhickeychouser: coercions are only for interop overload resolution, a call to get isn't interop
09:35chouserhm
09:36@rhickey(class (int 7)) -> long on master
09:36@rhickeyer, Long
09:36chouserByte has no methods that take an int or long, so ... should be (get f (Byte/valueOf (byte 7))) ?
09:36@rhickeyor (Byte. (byte 7))
09:37@rhickeyor, don't use Bytes as keys, or, use 1.3+ where this key type problem is removed
09:37fliebelrhickey: I'm using a java lib which gives me a set of bytes and then I do frequencies which gives me a map with bytes as keys.
09:38@rhickeyfliebel: you can get out of bytes ASAP and then get something else as keys
09:38chouserI'm reading Steele's RABBIT compiler paper, and the differences in tradeoffs between running on top of JVM vs. on top of MacLISP are fascinating.
09:38@rhickeyfliebel: either way, key + lookup types must match pre 1.3
09:39@rhickeychouser: writing Lisps on Lisps is cheating, and far too easy
09:39fliebelrhickey: I understand that. I didn't realize they where bytes. So should I do (map int) on the whole bunch somewhere upstream?
09:40chouserhe seems to use a pretty minimal set of MacLISP features.
09:40@rhickeyfliebel: the point I was trying to make to chouser was that the coercions are not for forcing particular boxed types, so best not to use them that way
09:41chouserfliebel: probably not. more like (map #(Integer. (int %)) s)
09:42fliebelchouser: Why the seemingly double conversion?
09:42fliebel,(class (int 2))
09:42clojurebotjava.lang.Integer
09:42chouserfliebel: (int x) is to give you a primitive int for interop -- no long-term guarantee that when boxed you'll get an Integer
09:43chouserfliebel: so it's use there is just be guarantee a primitive int to pass to the Integer constructor, which will always give you an Integer.
09:43@rhickeyaargh, Silverlight, MS lock-in strategy failure #957
09:43chouserrhickey: yeah. were you invested?
09:44@rhickeychouser: oh, no, I'm not installing that!
09:45@rhickeyjust a PDC vid I wanted to check out, supposedly Hejlsberg mentioned Clojure
09:45@rhickeynot worth trashing my machine over
09:45chouserheh
09:52chouserfliebel: as rhickey said, (class (int 2)) on 1.3 currently returns java.lang.Long
09:53fliebelchouser: Why is that?
09:54tonylisn't there a long fn already?
09:54chouserIt's part of 1.3's rather comprehensive rethinking of Clojure number handling.
09:55chouserfor example whole number literals will be primitive longs, autoboxed to Longs
09:57looselytyped1fliebel: (I apologize for hijacking the conversation) - As chouser said, this has to do with Clojure 1.3 new approach to numbers (boxed and unboxed) - See http://david-mcneil.com/post/1393750407/clojure-conj-day-1-notes (the section "Rich Hickey - New Clojure Features")
09:58@rhickeylong is a primitive, you need it when you need a long argument for a method that takes a primitive. Long is an object. It is one of several objects that could hold, e.g. 42. There is no rule that says 42 is inherently a Long or Integer. So, when you care, as you do when trying to match Object typed keys prior to 1.3., you need to create the proper box type. Trying to get a particular box type by starting with a particular primitive type is
09:58@rhickeymistake
09:59fliebelrhickey: Thanks, that makes sense.
09:59@rhickeyIt ends up you will rarely care about the boxed types, and only do prior to 1.3. because there get follows Java's use of .equals. In 1.3+ get uses =
10:00@rhickeyMost interop requires particular primitive types, for which there are the int/long etc coercions
10:39djpowellrhickey: which was the silverlight video?
10:40@rhickeydjpowell: http://player.microsoftpdc.com/Session/bb7e628d-5c35-4098-9691-059612d8ebc4
10:42LauJensenIm not able to view Silverlight videos, am I missing something?
10:42nickikarch linux ftw
10:53chouserhttp://az8714.vo.msecnd.net/presentations/FT09-Hejlsberg.pptx -- slides for The Future of C# and Visual Basic by Anders Hejlsberg
10:53chouserbut I see no mention of Clojure there.
10:55LauJensenchouser: And you find that odd in a C# & Visual Basic slidedeck? :) The Conj must have worn you down
10:57@rhickeyhttp://twitter.com/pholdings/status/29269228642
10:59ubiiwatching the video now, and wow, that is a freaking colorful shirt
11:07chouseroh, that's not the talk that was linked to.
11:09chousermaybe here: http://videoak.microsoftpdc.com/vod/downloads/CLI_Low.mp4
11:21jc2(defn fn1 [n] (lazy-seq (conj (fn1 (inc n)) n)))
11:21jc2Gives me: (nth (fn1 0) 1000000)
11:21chouseryep. He essentially describes the desirability of transients, and someone else says "you should look at what's been happening with Clojure"
11:21jc2stack overflow
11:21jc2and: (defn fn2 [n] (lazy-seq (cons n (fn2 (inc n)))))
11:22jc2gives me: 1000000
11:22jc2I trying to definitively understand that.
11:24nickikchouser: hehe yeah he does
11:25tonyljc2: you are recursively calling the function infinitely
11:26tonylit is fine you you create it since it is lazy
11:26chouserrhickey: http://videoak.microsoftpdc.com/vod/downloads/CLI_Low.mp4 at 10:45
11:26tonylbut after you trying to access it, it loses its laziness
11:26jc2hmm
11:27jc2That's why fn1 doesn't work but fn2 does?
11:27nickikchouser: he sais clojure has parallel datastructers but thats not really true is it?
11:28chousernickik: depends on what he means, I suppose
11:29noidihas anyone here read Land of Lisp yet? http://landoflisp.com/
11:29chouserperhaps he's referring to forkjoin stuff on vectors, which I imagine would be very interesting to these guys.
11:29nickikno but orderd it
11:30tonyljc2: it is weird that the second one works, unless the n parameter is a collection
11:30raekthe second one should work fine
11:30raekI think conj forces the seq, but I'm not sure why
11:30nickikmaybe he just means taked about structural sharing
11:30raekmaybe it calls seq on the argument
11:30noidiI'm wondering if reading Land of Lisp would help with Clojure programming
11:30raek...which would force the laziness
11:31jc2raek: that's what I was thinking. I couldn't fund any docs about that.
11:31nickiknoidi: im sure it will.
11:31raekanyway, when constructing lazy sequences, cons is the fn you usually use
11:31noidinickik, I hope so, too
11:31tonyl,(source conj)
11:31clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
11:31tonyl~source conj
11:31raekso I would consider the second one to be perfectly ideomatic
11:32jc2ok. thank you very much raek. :)
11:32nickiknordi: the author sais that he tried bring a little of every lisp in the book not just CL. For example you implement lazy lists (like clojure has them)
11:32raekalthough, even more ideomatic would be to use one of the existing fns
11:32ubiiin the video, Anders says that Clojure's immutable collections are 2x to 3x slower than mutable collections in other languages, then later Herb asks how much do these parallel collections scale across say 24 cores and if this more than makes up the 2x to 3x loss
11:33raekjc2: range and iterate can probably be used insted, in your example
11:33noidiand then again, even if LoL doesn't teach anything directly applicable to Clojure, it teaches one to read Common Lisp, which would surely help to understand lots of other good resources on functional programming
11:33AWizzArdubii: it depends on how you measure. When you want to copy a 900 MB Hashmap each time a thread modifies it, it would be frickin slow.
11:34AWizzArdubii: and when you lock access each time, then only one thread will be working on it anyway, so your 24-core system will effectively be a single-core app.
11:35raeksince 1.2, range does also have a 0-arg version:
11:35raek,(take 10 (range))
11:35clojurebot(0 1 2 3 4 5 6 7 8 9)
11:35AWizzArdraek: oh, thx for this info, interesting
11:35jc2Yes I know. I had a much more complicated function I was working on that was using conj. I thought to switch to cons and all was well.
11:35noidiwith all the focus on language performance, one might think that most programmers work on AAA Xbox games :P
11:36jc2I was just trying to understand the underlying problem.
11:36noidior scientific computing
11:36raekI think you could say that conj is preferred, except when building lazy sequences
11:36AWizzArdubii: also think about this: if you make your data concurrency ready by putting it into an external DB (say, mysql), then guess what kind of data structure that uses on disk…
11:38raekjc2: also, if you're playing with lazy sequences (especially regarding when they are being realized), this might be interesting: http://gist.github.com/480608
11:39chouserso, conj on a lazy seq does call seq on the lazy seq, forcing that first step
11:40hiredman(or first 32)
11:40jc2raek: thanks again ;)
11:41jc2chouser: and cons does not right?
11:41chouserright, cons leaves the collection entirely alone
11:42ubiiAWizzArd: thx, was just curious about the correctness of the first statement and how much of performance might be regained by parallelizing it
11:42chouseranother reason finger tree's consl should be renamed conjl
11:42jc2thanks all, back to work.
11:45ubiiErik's (the moderator) shirt, is starting to give me a headache :)
11:45clojurebot'Sea, mhuise.
11:45fliebelHow can I give the Cake JVM more heap space?
11:46lrennfliebel: ~/.cake/config, add cake.java_opts
11:46nickik@ubii these shirts are just his thing. Try to watch his series "interduction to FP"
11:47lrennfliebel: http://github.com/ninjudd/cake scroll down to Custom JVM Options
11:48lrennfliebel: though I imagine you probably want to give your project JVM more mem, not cakes. All the same, look at the readme on the cake page.
11:48fliebellrenn: thanks
11:50ubiinickik: thx, I will check it out
11:53nickikubii: http://lambda-the-ultimate.org/node/3642
11:55ubiinickik: that one is much less painful on my eyes
12:16tonylI can
12:16AWizzArdubii: I don’t think that those immutable data structures have disadvantages for parallelism. They are just not efficient for some of their operations. So, this is affecting more the concurrency aspect.
12:20tonylwhat does non-promoting operators and bigint contagion?
12:20tonylare non-promoting operators only use for the specific types, like you can only add (+) a long with another long?
12:24jarpiain,(class (+ 1 Long/MAX_VALUE))
12:25clojurebotjava.math.BigInteger
12:25jarpiainin 1.3 that would throw an overflow exception instead of promoting to bigint
12:26tonylok, do in 1.3 it should the operators would only accept nums from the same type?
12:26tonyl*so
12:27jarpiainin 1.3 you could write (+ 1N Long/MAX_VALUE) where 1N is a bigint literal
12:27tonylgot it
12:27tonylcool
13:07nickikwhats the easies way to creat a xml from some clojure data i have?
13:09fliebelOuch, I had to quit my irc client because a Clojure app was taking up all my memory.
13:10fliebelIf I remove the take 100 it takes a whole lot more files and hangs at 2gb of memory.
13:10fliebelhttp://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj
13:12fliebelDoes anyone have an idea how to reduce memory usage?
13:13fliebelIt opens 5mb divided over 2000 binary files and operates on the bytes read.
13:15AWizzArdfliebel: I did not study your code, but on first sight it could have to do with fr looking at the head of a sequence.
13:15AWizzArdCan you not doseq through the file-seq?
13:17fliebelAWizzArd: I don't think file-seq is the problem, the resulting blocks are. Every file contains 16*16*128 blocks.
13:18AWizzArdfile-seq is not a problem, but fr pointing on the head of a seq of blocks
13:19fliebelAWizzArd: When is something "holding onto the head of a seq"?
13:21AWizzArdfliebel: when you have (let [x (map f data)] ...)
13:22AWizzArdThen x is pointing to the head of the seq. If f consumes much ram, then you force all data to be in ram at the same time.
13:22AWizzArdIf you would instead (doseq [x data] (f x) ...) then the used ram can be released after working on each element.
13:23Chousukeif the seq is realised while the local binding is in effect.
13:23AWizzArdthere you go
13:23AWizzArdChousuke can put it into elegant words :-)
13:24fliebel...
13:25LOPPdoes holding onto head of the seq consume any more memory than if I had a java list with same contents?
13:26AWizzArdnot really
13:26AWizzArdmaybe 150 bytes more compared to a java.util.ArrayList or whatever, but nothing substantial
13:26clojurebotnamespaces 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:27fliebelAWizzArd: What confuses me: "If f consumes much ram" but f is only the head, that doesn't consume much ram, does it?
13:27AWizzArdf could be a function that returns 700 megabyte hashmaps
13:28AWizzArdif data contains 100 elements then we would require nearly 70 gigs of ram for (count (map f data))
13:28fliebelAWizzArd: So how does it help to have 700mb of hashmaps in memory instead?
13:29AWizzArdfliebel: for example, i once implemented a parser for a data format that was similar to csv.
13:30AWizzArdI first had a (let [lines (map process-line (read-lines "file"))] ...) where file was around 3 gb in size.
13:30AWizzArdIn the body of the let I iterated over lines
13:30AWizzArdThat was not good, as this realized the whole file over time.
13:30chouserthat doesn't necessarily hold the head anymore
13:31AWizzArdin the body I had something like (doseq [line lines] ...)
13:32AWizzArdLater I updated my code to not hold the had of all lines of the file, and it was able to run in a 64 MB default Client JVM.
13:33fliebelAWizzArd: You mean you just did (doseq (read-lines… instead?
13:33AWizzArdyes, something similar
13:33AWizzArd(in fact I was using pmap instead of doseq)
13:34fliebelAWizzArd: Great, so now you have 3gb of lines in memory, right?
13:34AWizzArdIn some sense yes.
13:34AWizzArdNot at one moment.
13:34AWizzArdBut within the 9 minutes of processing I had all 3gb in ram.
13:35AWizzArdonly a few kb at any time
13:37fliebelAWizzArd: wait… I'm reading the docs more carefully now...
13:40fliebelAWizzArd: Are there other functions besides doseq that do not retain the head?
13:44AWizzArdfliebel: map does not necessarily do this
13:44AWizzArdonly when you explicitly store its head somewhere.
13:45AWizzArdAs in (let [head (map f data)] ...)
13:46AWizzArdIf you just have a (map f data), which would be kind of useless in a functional programming language, when f is side-effect-free (as it should), then in that case it is also fine.
13:46AWizzArdAlso (apply concat (map ...)) can be an indicator that mapcat is useful.
13:46chouser(let [xs (map #(vec (repeat 1e3 %)) (range))] (doseq [x xs] (prn (first x)))) ; no longer blows the heam
13:46chouserheap
13:55AWizzArdchouser: okay, I think I had something similar and in earlier versions of Clojure this was not so good.
13:55chouseryes
14:26amalloyis there a convenient built-in way of adding metadata to an object that might already have metadata, or do i have to merge the maps myself?
14:27chouseramalloy: vary-meta
14:27nickikim not sure but i think with-meta does that
14:27amalloynickik: it doesn't
14:27amalloybut apparently vary-meta does. nice
14:28raekhrm. interesting
14:29fliebelDoes reduce retain its head? If not, how can I doseq and still ret some results out of it?
14:30amalloyfliebel: reduce isn't lazy. i don't understand the question
14:31amalloyargh damn. i can't attach meta to an int, of course
14:31raekfliebel: reduce does not retain the head.
14:32fliebelraek: Thanks, I think it fits my case better than doseq.
14:32raekoh wait..
14:32raekhrm
14:32raekwell, I think it doesn't
14:32raekprobably beacause of the locals clearing thing
14:33raekusually, it's not the about whether a function retains the head, but rather whether the caller retains the head
14:33amalloyfliebel: what is your goal here?
14:34digashamalloy: you can attach metadata to int ,(meta 'int) ha ha
14:34fliebelamalloy: To get this thing to run within my 2gb of memory ;) http://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj
14:35fliebelAWizzArd just explained me that the thing retains its head and that I should probably use doseq, but doseq doesn't give me any data back, reduce does.
14:36fliebelraek: Can I test if it does?
14:37apgwozcan clojure symbols contain non ascii characters?
14:37raekhrm, I think concat forces the first cons of each seq you give it
14:37raekapgwoz: yes
14:37amalloyfliebel: your (blocks) function looks weird. the lazy-seq isn't doing anything lazy, is it?
14:37apgwozi thought so, does swank-clojure not support it?
14:38apgwozor, actually, i guess swank in general
14:38raekapgwoz: slime and swank-clojure use latin1 as the default encoding
14:38raekyou can configure that
14:38apgwozah, ok.
14:38technomancy=(
14:38fliebelamalloy: lazy-cat expands to concat-ing lazy-seqs, my goal here was not to read all those files at once.
14:38apgwozraek: i'll search for the config param. thanks
14:39apgwoztechnomancy: it's ok. it's not your fault!
14:40raekapgwoz: in .emacs: (custom-set-variables '(slime-net-coding-system (quote utf-8-unix)))
14:40apgwozraek: oh sweet. thanks
14:40ordnungswidrighi!
14:40amalloyfliebel: but...map is lazy already. it wasn't going to read them in all at once anyway, and wrapping (lazy-seq) around something with no recursion doesn't seem to buy you anything. are you worried about map chunking or something?
14:41raekexport JAVA_OPTS=-Dswank.encoding=UTF-8
14:41amalloyif so i'd suggest either turning off chunking for this segment of code, or using (delay) instead of (lazy-seq) to make it clear what the goal is
14:42raekapgwoz: I'm a bit uncertain about ^^, but you should set that java option in some way
14:42fliebelamalloy: but concat isn't… I'll look at it.
14:42apgwozraek: ok. is there a way to set that in the project.clj?
14:42apgwoz(for leiningen)
14:43amalloyfliebel: oh wow i missed the apply concat. just use &|(doc mapcat|&
14:43sexpbotjava.lang.Exception: EOF while reading
14:43amalloy&|(doc mapcat)|&
14:43sexpbotjava.lang.Exception: Unable to resolve symbol: | in this context
14:43fliebelamalloy: I've already done that offline.
14:43amalloybah. okay, i forget the syntax
14:43ordnungswidrigare there clojure libraries for generic optimization algorithms? I mean not depending on the problem domain?
14:44ordnungswidrigI think of branch-bound or genetic algorithms
14:44raekapgwoz: I would put that in .bashrc or something, since it's not something that's tied to the project itself
14:44mfexfliebel: how does the lazy-seq in blocks work?
14:44amalloyfliebel: concat is lazy
14:44apgwozraek: but, if the project is using unicode symbols, then it's project specific..
14:45apgwozi guess the option isn't necessarily used then though...
14:45raekapgwoz: this only affects the slime-swank connection
14:45raekapgwoz: clojure source files are always UTF-8
14:45raekslime defaults to latin1 for historical reasons, I guess
14:46technomancymore like hysterical reasons
14:46raektrue.
14:46apgwozraek: i know, but if i have swank-clojure in :dev-dependencies (yes, I know this is no longer necessary) it'd sort of make sense.
14:46apgwozeither way, i'll check and verify that this all works
14:46amalloyfliebel: but if your files are huge, then chunking (in both map and concat) may bite you
14:46apgwozraek: thanks
14:46raekapgwoz: well, other developers would have to look at the options in you project, and change their emacs settings to match it
14:47apgwozraek: i suppose...
14:48raekyou can also do: lein swank localhost 4005 ':encoding' '"UTF-8"'
14:48apgwozsort of related: this is also another reason that having an nREPL-mode for emacs make sense. modern defaults.
14:48apgwozraek: ah, perfect
14:48raekyech @ the quoting, though...
14:49technomancyI don't think you need to quote the keyword
14:50raekapgwoz: also, note that lein repl uses JLine, which has no support for UTF-8 *at all*, so don't use lein repl to see if things work
14:50chouserfliebel: do you know where in your code you're running out of memory?
14:50fliebelchouser: no
14:50apgwozraek: i noticed that
14:50technomancyraek: well it only falls back to jline if you don't have rlwrap
14:50raekah, I see
14:51chouserfliebel: you might try to figure that out -- leave things off the end, or print something in-between likely areas and see how far it gets
14:51apgwozraek: lein swank 4005 localhost :encoding '"UTF-8"' <-- you had the port and host backwards
14:51fliebelchouser: Isn;t there some kind of java tool to look at this?
14:51raekapgwoz: to test if the encoding is configured correctly: (seq "日本語") should yield a sequence of *three* characters
14:51apgwoz(unless i'm running an out of date lein)
14:52chouserfliebel: btw, (apply concat (map ...)) is (mapcat ...)
14:52raekhrm, right.
14:53apgwozraek: rock! it works.
14:53apgwozthanks again for all the help
14:53raekgreat!
14:53raeknp :)
14:53fliebelchouser: You're the third to say that, but thanks anyway :)
14:55mfexfliebel: does the blocks function work on its own?
14:56fliebelmfex: how do you mean? It works if i give it a file, and it still works if I use 100 files.
14:56raekah, with rlwrap installed, lein repl works perfectly with UTF-8
14:56mfexfliebel: ok
14:58fliebelchouser: it gets to the point where it's going to realize all the lazy seqs ;)
14:59alpheusIs there a way to get access to the variables used in pre and post conditions when the assertion fails?
15:00alpheusEven a printed representation of the values would be nice.
15:05sthuebnerLauJensen: did you get your head around the PMaven thing?
15:06LauJensensthuebner: I was busy reading on it just now actually
15:06chouseralpheus: get to them from where?
15:06sthuebnerI was studying it the other day to.
15:07fliebelI think I found the killing line: http://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj#L33 Taking the first item from this one realizes the whole thing, if I'm correct.
15:07sthuebnersince I'm not familiar with Leiningen, I'm not sure, if those two worlds are trying to achieve the exact same thing
15:07LauJensensthuebner: Let me put it this way. If technomancy heard you say that, he would likely kill you :)
15:07sthuebner:-)
15:08amalloyfliebel: i still think map chunking is the problem. have you checked that out?
15:08ordnungswidrigI think I asked some time ago but I got no answer, Any Ideas why "Fontifying *SLIME Compilation*... (regexps……………………………………………….)" takes longer than the compilation itself? (Aquamacs on OS X)
15:08sthuebnerso, to put it differently: PMaven is doing exactly one thing: describing the POM model in a different way
15:08sthuebnernot more, (maybe less ;-) )
15:09fliebelamalloy: I don't think 32 files will kill it, I can do 100 files just fine, and at 2000 files chunks of 32 aren't going to matter much.
15:09Deranderordnungswidrig: same issue in regular emacs on osx, btw.
15:09LauJensensthuebner: yea, minus the plugin story
15:09amalloyah. you can do 100 at a time? interesting
15:10ordnungswidrigDerander: it takes nearly a second
15:10amalloy(apply map vector some-seq) shouldn't realize the whole thing at once
15:10fliebelamalloy: Well, I can put a take 100 on the file-seq and it still works.
15:10alpheuschouser: when the java.lang.AssertionError is thrown, I'd like to be able to inspect the values in the slime debugger
15:11amalloyfliebel: can you map vector over 100 things? also, are you sure you want map vector rather than map vec?
15:11fliebelamalloy: well, I run that on a partition of 128, so taking the first seq of that takes the first item of *all* partitions.
15:11sthuebnerplugins in PMaven: only sofar as they are declared the usual way - just different syntax
15:12fliebelamalloy: Yea, very sure. What I'm doing there is picking every 128th item and then the next-every-128, so taking one takes all items 128 appart.
15:13amalloy&(doc rake-nth)
15:14sexpbotjava.lang.Exception: Unable to resolve var: rake-nth in this context
15:14amalloy&(doc take-nth)
15:14sexpbot⟹ "([n coll]); Returns a lazy seq of every nth item in coll."
15:14fliebel,(apply map vector (partition 3 [[1 2 3] [1 2 3] [1 2 3]]))
15:14clojurebot([[1 2 3]] [[1 2 3]] [[1 2 3]])
15:14amalloyfliebel: ^^?
15:14fliebelwait...
15:14fliebel(apply map vector (partition 3 [1 2 3 1 2 3 1 2 3]))
15:14fliebel,(apply map vector (partition 3 [1 2 3 1 2 3 1 2 3]))
15:14clojurebotInvalid number: 3 1
15:14fliebelgrrr
15:16amalloyfliebel: i see
15:16amalloy&(apply map vector (partition 3 [1 2 3 1 2 3 1 2 3]))
15:16sexpbotjava.lang.NumberFormatException: Invalid number: 3 1
15:17fliebelamalloy: yea, but that is not what I want. What I did is like 128 times take-nth 128, so 128 seqs of 1 2 3 will become 3 seqs with 128 items each.
15:17fliebelamalloy: So this takes all but the last 127 items when taking the first one. not very good.
15:18ordnungswidrigDerander: (setq font-lock-verbose nil)
15:23fliebelWhat is the difference between lazy-cat and concat?
15:26Deranderordnungswidrig: thanks
15:29chouserlazy-cat is a macro and so can postpone evaluating its arguments until their needed.
15:29mfexfliebel: do you have any test files somewhere or know where I can find world files?
15:29chouserconcat is a function, so all its args are evaluated eagerly, though each result isn't forced until needed.
15:30Ploujwait, clojure in cold fusion?
15:30Ploujwhat?
15:30clojurebotwhat is cells
15:31amalloyfliebel: for what it's worth, it might still be chunking that's the issue. with concat and map both chunking 32, you might be realizing 1024 elements at a time
15:31fliebelamalloy: Hrm, okay, what do I do about that?
15:33amalloyfliebel: wrap your map elements with delay? it looks like that's what your lazy-seq ends up doing, though, so i'm not sure delay would make a difference
15:34vibrantException in thread "main" java.lang.Exception: Can't use qualified name as parameter: coords/amt (coords.clj:18)
15:34vibrantwhat am i doing wrong? :)
15:34amalloyi guess the issue is that lazy-seq automatically derefs, while delay shouldn't automatically force
15:34chouservibrant: you've got a parameter in a macro named amt when it should be amt# or a gensym
15:35amalloyvibrant: you're using a macro like `(defn foo [args] stuff)
15:35amalloyshould be args#
15:35vibrantchouser; if i use amt# it doesn't work either
15:35vibranti want to use amt in the body passed to the macro
15:35ordnungswidrighow would I idiomaticaly generate all heads of a seq? i.e. (1) (1 2) (1 2 4) (1 2 4 8) for the seq (1 2 4 8)
15:35amalloyvibrant: gist or it didn't happen :)
15:35chouserbut you get a different error, or on a different line, right?
15:35fliebelNow I'm getting a classic java.lang.StackOverflowError :(
15:35fliebelThat's to much recursion, right?
15:36amalloyfliebel: yes
15:37vibrantamalloy; http://paste.lisp.org/display/116144
15:37vibrantnow it says it can't resolve symbol amt#
15:39LOPPok I have leiningen and emacs
15:39LOPPhow do i connect them
15:39chouser,(reductions conj [] [1 2 4 8])
15:39clojurebot([] [1] [1 2] [1 2 4] [1 2 4 8])
15:40amalloyvibrant: amt# is only accessible within the macro that declares it
15:40drewrLOPP: try `lein swank` then M-x slime-connect RET RET RET
15:40sdeobaldHas anyone here used ant FTP through lein/lancet? maven-ant-tasks doesn't seem to come with the ftp task and it's not immediately obvious how to include it.
15:41amalloythe body of real-to-gfx should be #(* real2gfs-ratio %)
15:41vibrantamalloy; yea i deducted that :) but how do i solve it then?
15:41tonylchouser: I keep forgetting reductions exist, thanks for the reminder of the day
15:41amalloyor something. i'm not sure what you're trying to do
15:41chousertonyl: np :-)
15:41vibrantamalloy; generating a bunch of functions which handle sequences by calling themselves on items from the sequences
15:42chouservibrant: probably best to pass in the name of the fn arg just like you do the name of the fn itself
15:42amalloyvibrant: or use clojure.walk? you're just walking a seq
15:42vibrantchouser; yea that's a last resort.
15:42chouser(defseqable-converter real-to-gfx [amt] (* real2gfx-ratio amt))
15:43chouservibrant: no, that's a clean macro. :-)
15:43vibranthehe
15:43vibrantchouser; ok i got your point :)
15:43ordnungswidrigre
15:43chouser,(reductions conj [] [1 2 4 8])
15:43clojurebot([] [1] [1 2] [1 2 4] [1 2 4 8])
15:43chouserordnungswidrig: ^^^
15:43LOPPdrewr: it says swank is not a task
15:43ordnungswidrigthanks
15:44amalloy&(clojure.walk/walk inc list [[1 2 3] [[6]] 1])
15:44sexpbotjava.lang.ClassNotFoundException: clojure.walk
15:44LOPPdrewr: I can use lein repl
15:44zakwilsonIs there a rough ETA for 1.3's release?
15:44LOPPbut that creates a whole repl
15:44klangLOPP: add :dev-dependencies [[swank-clojure "1.2.1"]] to project.clj
15:45djpowellwhat is the deal with jira. it says my username has been taken - is this cause it was ported over from assembla? if so is my password the same, or do i need to get it reset to something?
15:45drewrLOPP: what's :dev-dependencies have in project.clj?
15:46LOPPnone
15:46drewrlook at leiningen's project.clj for an example
15:46zakwilsonIs there a rough ETA for 1.3's release?
15:46drewrdjpowell: I had the system email me my auth info
15:47LOPP :dependencies [[org.clojure/clojure "1.2.0"]
15:47LOPP [org.clojure/clojure-contrib "1.2.0"]]
15:47LOPP :dev-dependencies [[swank-clojure "1.2.1"]]
15:47LOPP )
15:47djpowellthe self-service password reminder thing?
15:47djpowellthat didn't seem to work for me :(
15:47ordnungswidrigchouser: is there a overview of idtiomatic seq handling in clojure?
15:47LOPPI have added it
15:47drewrdjpowell: maybe you signed up originally with a different email address
15:47LOPPit still says swank is not a task
15:47drewrLOPP: you added it here too ;-)
15:47ordnungswidrigchouser: in haskell i would ask hoogle for a type signature
15:48klangLOPP:
15:48klangLOPP: run lein deps again
15:48djpowelldrewr: don't think so, cause I know what my assembla one is
15:49LOPPdoesn't work
15:49LOPPogh
15:49djpowellzakwilson: not heard an eta for 1.3. wonder if pods will be in it...
15:50LOPPlein deps projectname doesn't work, says wrong number of arguments
15:50zakwilsonI see I just double-posted. I'm having a large amount of latency here.
15:50fliebelCan anyone explain me how to solve a stack overflow error while I'm not actually calling functions recursively? Can a map within a reduce blow the stack?
15:50LauJensenLOPP: If you're building on Windows I strongly recommend using Cake: http://github.com/ninjudd/cake/wiki/cake-on-windows
15:50djpowelldrewr: ah found the jira email. my username is my email - oh i didn't expect that
15:51zakwilsonIt looks like 1.3 is going to have some nice forkjoin integration. I'm interested to see how much that speeds up a certain computation I'm running.
15:51LOPPisn't cake a bit complicated
15:51djpowelloh - jira usernames are centralised things? I thought it was just for the clojure site
15:52chouserordnungswidrig: the best I have to offer are the categorizations here: http://clojure.org/sequences#toc5
15:52LauJensenLOPP: Its a drop-in replace for lein on simple builds. They differ in tasks primarily, where cake is still simpler than lein imo
15:53vibranthumm..
15:53vibranti just found that (seq? [1]) returns false
15:53vibrant:)
15:53clojurebot@ splices in a seq and foo# is a symbol, not a seq
15:53amalloy&(coll? [1])
15:53sexpbot⟹ true
15:53LOPPoh I just needed to change the folder to the project one
15:54djpowellvibrant: yeah, collections are seq-able, but not themselves seqs.
15:54LauJensen&(seq? '(1))
15:54sexpbot⟹ true
15:54raek...with the exception of PersistentList, which is its own seq. </nitpicking>
15:54djpowell,(col? (seq [5]))
15:54clojurebotjava.lang.Exception: Unable to resolve symbol: col? in this context
15:54djpowell,(coll? (seq [5]))
15:54clojurebottrue
15:55djpowellah interesting
15:55djpowell,(supers (class (seq [5])))
15:55clojurebot#{clojure.lang.Seqable clojure.lang.IChunkedSeq clojure.lang.Sequential clojure.lang.Obj java.lang.Iterable clojure.lang.ISeq java.lang.Object java.util.List java.util.Collection clojure.lang.IMeta ....
15:55ordnungswidrigchouser: I see, I know the list but it's hard to find the idomatic way
15:56djpowell,(class (seq [5]))
15:56clojurebotclojure.lang.PersistentVector$ChunkedSeq
15:56ordnungswidrigchouser: last question (i hope): how can I flatten a seq of seqs but only for one level deep?
15:56chouserordnungswidrig: there's definitely some kind of rule-based filtering system going on in my head that I'd like to capture somehow at some point.
15:56chouserordnungswidrig: apply concat
15:56ordnungswidrig*doh* I always tried vector
15:58tonylchouser: that list would be an interesting post
15:59chouserI'd love to have a decision tree people could follow to find a small set of functions that are likely to be useful for any give seq-lib problem
15:59chousertonyl: which list?
15:59tonylthat kind of rule-based filtering system for dealing with seqs
15:59fliebelchouser: It's called namespaces, but no, lets just put every function in clojure.core.
15:59chouserbut all my attempts to capture anything more details than "the seq library" categories hasn't worked out.
16:00LOPPhm I get class not found exception in repl when attempting to (use ) the namespace of my lein project
16:00ordnungswidrigclojure.core is large
16:00fliebelordnungswidrig: 508 functions...
16:00chouserfliebel: but it's by no means cleanly partitionable. Even the large vague categories I came up with have overlaps.
16:00ordnungswidrigfliebel: there is still room :_)
16:01chouserbut when I'm trying to solve a problem like ordnungswidrig proposed, I quickly find myself choosing between just two or three functions. I don't know how to share the process I use to get to that point.
16:01chouserI do know of a couple useful questions, like: does an output value rely on previous values?
16:02fliebelchouser: So the actual problem is the "100 functions on one datatype" philosophy instead of "10 functions on 10 datatypes", like Python.
16:02chouserif it does, you can ignore almost everything except iterate, reduce, reductions, and loop/recur
16:02chouserfliebel: hm, possibly.
16:03fliebelchouser: In Python I just do a dir on the object I'm working with and get a dozen or so useful functions, plus ±100 in the stdlib.
16:03chouserbut of course ordnungswidrig's problem didn't clearly require previous state beyond what map-indexed can profive
16:04chouserfliebel: heh. ±100
16:04ordnungswidrigchouser: would you elaborate on your process for another example?
16:04chouserordnungswidrig: a specific example?
16:04chouserI actually had a map-indexed solution first before trying again with reductions.
16:05ordnungswidrigchouser: all subseqs of a seq? [1 2 3 4] -> [] [1] [1 2] [1 2 3] [1 2 3 4] [2] [2 3] [2 3 4] ...
16:05fliebelchouser: Does your method involve knowing 508 functions, or useful searching criteria?
16:05ordnungswidrigchouser: thats interessting, I thought of map-indexed first
16:06chouserordnungswidrig: I thought map-indexed seemed reasonable until I had a working solution. required ignoring fn args, inc, let for the input coll -- altogether too messy to be desirable.
16:07chouserso, we have a function that gives you the heads of a seq, just need to do that for each sub-seq, right? so map of one on the other might do it.
16:07fliebelchouser: I got it! If funcions can be in multiple namespaces at onec, then you could qualify them vaguely and still have something that works, so they are all in core, but only some inclojure.som-property. So it's mor elike tags than categories.
16:07chouserso, first we need tails of a seq. I know I've done this before...
16:07chouserfliebel: you want this mapped out in the code rather than just some doc-reference mechanism??
16:08ordnungswidrigfliebel: that sounds nast
16:08ordnungswidrigy
16:08fliebelchouser: Yea, I really think a core ns of 508 items sucks.
16:09chouserso, there will be as many tails as elems, which suggests reductions
16:09tonylI'm used to it
16:09ordnungswidrigchouser: I see
16:09tonylI program in PHP too :P
16:09chouserbut the first element of the return seq needs the whole seq, so that actually won't work at all
16:09fliebelwell, maybe a ns query language would do.
16:09tonylthere is a clojure.contrib.find-namespace ns
16:09chouserso that actually suggests something that has access to the whole input from the beginning, like iterate
16:10tonylthat gives some query functionalities
16:10chouserindeed, (iterate rest coll) gives what we want, but fails to stop, as it always does, so (take-while identity ...)
16:10LOPPI don't get it. When running "lein swank" what do I have to do, to have the project contents entered into the repl
16:11chouserer, seq
16:11noidiLOPP, (use 'your.app.some-ns)
16:11chouser,(map #(reductions conj [] %) (take-while seq (iterate rest [1 2 3 4])))
16:11clojurebot(([] [1] [1 2] [1 2 3] [1 2 3 4]) ([] [2] [2 3] [2 3 4]) ([] [3] [3 4]) ([] [4]))
16:12chousernow I check the problem description again and see if I'm close. :-)
16:12noidiLOPP, or what do you mean by have the project contents in the repl?
16:12fliebelIMPORT FROM clojure.core WHERE returns == seq && idempotent
16:12ordnungswidrigchouser: nice
16:12chouserso I have extra empty vectors and an extra level of nesting
16:13LOPPthank you
16:13chousermapcat solves the nesting. either think of it directly or do (apply concat (map ...)) and then recognize that is just mapcat
16:13LOPP(use 'project.core) worked
16:13LOPP(use [project.core :reload]) didn't
16:14chouser,(mapcat #(rest (reductions conj [] %)) (take-while seq (iterate rest [1 2 3 4])))
16:14clojurebot([1] [1 2] [1 2 3] [1 2 3 4] [2] [2 3] [2 3 4] [3] [3 4] [4])
16:14VinzentLOPP, (use ['project.core :reload])
16:14LOPP:)
16:14LOPPbtw
16:14jcromartieis there an idiomatic way to implement user-defined exceptions?
16:14chouserjcromartie: consider clojure.contrib.condition
16:14LOPPif I change the source files, how do I get the changes in
16:14noidiLOPP, when you change project.core, you can re-evaluate the file with C-c C-k
16:14jcromartiehm cool
16:14noidiLOPP, or a single form with C-c C-c
16:14jcromartieooh wow, that's way better than exceptions :) Lispy
16:15chouserordnungswidrig: so I guess if you really want the [] on the front, just cons it on.
16:15LOPPok
16:15LOPPthanks
16:15rata_hi
16:15noidichouser, is c.c.condition prefered over c.c.error-kit?
16:16ordnungswidrigchouser: that was insightful
16:16mfexfliebel: what do you want to plot with clomian? # of each type of block?
16:16fliebelmfex: Type of block per layer.
16:17chousernoidi: if you don't need continue or continue-with, absolutely. and maybe even then.
16:17fliebelmfex: But I'm blowing the stack somewhere around here: http://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj#L33
16:17mfexfliebel: a partition of 128 blocks is a layer?
16:18chouserordnungswidrig: really? I'm glad you thought so. seems like a mess to me.
16:18noidichouser, good to know, thanks. good think I just started using error-kit yesterday, so I can easily change to condition :)
16:18ordnungswidrigchouser: we can agree on "an insightful mess"
16:18fliebelmfex: no, they're stored in columns of 128, so I go through the columns and add the block to the correct layer.
16:18VinzentIs there plans to implement named routes in compojure?
16:19noidichouser, maybe error-kit's docstring should mention c.c.condition?
16:19chousernoidi: you did see error-kit's giant warning at the top?
16:19mabesI remember hearing something from technomancy that lein has javac built-in support now (i.e. lein-javac is not needed).. any idea if that is correct and how one would use it?
16:19noidiyes, I saw the giant warning, but I didn't know that there's something better and less giant warningy available :)
16:20mabesthe sample project.clj show how to use AOT but I don't know if that covers javac issues...
16:22chouserperhaps I do more back-tracking in my decision tree than I realized. I have even less idea how to capture that. :-P
16:23fliebelCan someone explain me why I'm getting a stack overflow here? http://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj#L33
16:23alpheusWow. Learned a lot of clojure in the 71 short lines of robert.hooke.
16:25noidichouser, that sounds like trying to figure out what keys you are pressing when coding in Vim or Emacs :)
16:25noidii.e. impossible
16:25mfexfleibel: I have a plot with the data from http://www.minecraftforum.net/viewtopic.php?f=1012&amp;t=31046, but I'm not sure that I understand what layers are
16:25chousernoidi: heh
16:26chousernoidi: and a similar go-to answer: read some docs, practice, repeat until satisfied. :-P
16:30noidiI like to think about that sort of fuzzy thought process as taking a lump of data, and sculpting the wanted data structure out of it by using the seq functions as tools
16:31noidiI constantly check the REPL and think "oh, I need to get that part sorted out" and add a function, "there, that looks better. and now I need to fix that thing..."
16:31bhenryfliebel: what is freqs getting passed?
16:31fliebelbhenry: a kick ass seq of bytes.
16:32rata_should I have accessor fuctions for my records? or is it good style to use the keywords directly?
16:33chouserrata_: keywords are best I think
16:33itistodayhow can i get emacs to run something prior to slime going up and running after doing 'slime-connect'? i'm experiencing an odd conflict with autopair that's pretty much hosing emacs, and i'd like to selectively disable it for slime. here's what I've tried so far: http://paste.pocoo.org/show/284523/
16:33rata_chouser: thanks :)
16:34chousernoidi: yeah, that sounds right. But i'm not randomly trying each of the 100+ seq-related functions randomly in that process.
16:34_seanc_What IDEs do you guys use for your Clojure work? I really like Textmate, but everything I read Clojure related seems to use Emacs. What's so cool that I'm missing out on?
16:34lancepantz_seanc_: most of us use emacs, some use java ides
16:34rata_I use emacs... swank-clojure is cool
16:35itistoday_seanc_: i use emacs, but if you don't want to use emacs i recommend IntelliJ IDEA with the laclojure plugin
16:35itistodayi should say, i'm 'trying' to use emacs ... if i can get this problem fixed...
16:35rata__seanc_: something I like a lot about swank-clojure is (swank.core/break)
16:36amalloy_seanc_: emacs is a fab lisp editor. super-customizable; understands lisp code to autoformat, autodoc, autocomplete; has a repl you can use without leaving the editor window...
16:36_seanc_What exactly is swank?
16:36lancepantz_seanc_: there is a pretty impressive textmate bundle for clojure as well http://github.com/swannodette/textmate-clojure
16:36rata__seanc_: http://hugoduncan.org/post/2010/swank_clojure_gets_a_break_with_the_local_environment.xhtml
16:37rata__seanc_: swank is like a emacs "plugin" for clojure
16:37_seanc_lancepantz: I have that bundle actually, I'm just wondering if I'm missing out on something more :)
16:37rata_it shows you fns arglist in the minibuffer (at the bottom of the window)
16:38rata_you can send a function to the repl to test it
16:38rata_or compile an entire file with just 3 keystrokes
16:39rata_in emacs you don't need the mouse at all, which is very handy for programming I think (you can use it though if you like)
16:40_seanc_rata_: Very cool, I'll have to read more into how to get Emacs up and running with Clojure on a mac
16:41amalloyrata_, _seanc_: you don't need the arrow keys either, which has been even more important for me, since i rarely use the mouse anyway
16:41_seanc_I'm trying to play with my first Compojure app and every tutorial seems only show how to compile and run in Emacs
16:41rata_amalloy: I haven't learned that yet... how do you move without the arrow keys?
16:42amalloyC-p,n,f,b are the basic ones
16:42rata__seanc_: have you looked at the emacs-starter-kit?
16:42amalloyrata_: use M- to move faster, in general
16:42_seanc_I did on github, but to be honest, I wasn't exactly sure I knew what I was looking at
16:42ubii_seanc_: you might want to check out Aquamacs - http://aquamacs.org/
16:42fliebelbhenry: Any helpful comments on the thing?
16:42amalloyM-v, C-M-v for page up, down
16:44amalloyer, C-v and M-v, that is
16:44bhenryfliebel. not really.
16:44rata_amalloy: those doesn't work on my emacs
16:45bhenryfliebel: is there simple code that will generate something that's suitable for blocks so i can play with just that function?
16:45amalloyrata_: are you using a mac or something?
16:45amalloynot that that should matter
16:45fliebelbhenry: One moment...
16:45rata_amalloy: no, I'm on archlinux
16:46rata_C-v pastes and M-v does nothing
16:47amalloysounds like cua mode. the traditional emacs cut/copy/paste are C-w, M-w, and C-y
16:47amalloyif you don't mind losing those you could askin in #emacs; i'm not an expert here
16:48amalloyor check out C-h t for the interactive tutorial, which might be smart enough to use your current keybindings
16:48fliebelbhenry: (take 1e3 (concat (repeat (shuffle (concat (range 0 100) (range 20 90)))))) make 1e3 some higher for heavier load.
16:50rata_amalloy: I use C-e, C-r and C-y for cut/copy/paste and C-w for deleting the last word
16:50rata_what's cua mode?
16:50itistodayah, setq-default worked, but setq did not for some reason
16:50amalloyrata_: http://www.emacswiki.org/CuaMode#toc1
16:51fliebelbhenry: No, I am wrong… wait
16:51bhenryhaha okay
16:52amalloyrata_: getting used to moving around with modifiers+letters was painful for a week or two, but once you get used to it it's much more efficient than the arrows because you don't have to find your place on the keyboard after moving around
16:53fliebelbhenry: (apply concat (take 1000 (repeat (shuffle (concat (range 0 100) (range 20 90)))) ))
16:53rata_amalloy: yes, I'd like to have my hands always near the "home row"
16:54rata_could it be cua mode the reason why C-_ doesn't work for undo?
16:55amalloyrata_: could be. you might also try C-/. you should ask in #emacs how to reset stuff to the "standards"; i can'
16:55amalloyt really help you there
16:55apgwozanyone know what font the clojure logo uses?
16:56fliebelbhenry: raising 1000 to 100000 gives the overflow.
16:56rata_I visited that channel some time ago but didn't like the chat there
16:57amalloyrata_: yeah, it's not as friendly as #clojure, but they're usually willing to help out in my experience. you could also look around on google, of course
16:58bhenryfliebel: i got outofmemory error not stackoverflow
16:58tonylfliebel: I used as a dummy data (vec (range 10000)) and the freqs fn works fine for me
16:58tonyli am going to try with your dummy data
16:58apgwozit it just Arial?
16:59fliebelbhenry: That is even weirder, but more logical.
16:59bhenrymaybe i changeed the wrong thing
17:00fliebelbhenry: Can I see the changes?
17:00bhenryi did.
17:00bhenryi changed the inner range 100 to 100000
17:00fliebelokay
17:02fliebelthis is as far as I can get without the error: (freqs (apply concat (take 34200 (repeat (shuffle (concat (range 0 10) (range 3 7)))) )))
17:02fliebeltonyl: I took that number of ranges, so you'd nee a few extra zeroes to get the expetion.
17:03chouseranyone here know "matchure"?
17:05chousernm
17:08tonylfliebel: when I get to a 1e6 is when I get the SO error
17:09thickeyapgwoz: Avenir
17:09tonylis that how many bytes you are trying to process
17:09apgwozthickey: ah, nice!
17:09clojurebotexcusez-moi
17:10fliebeltonyl: Yea, I guess so. It's about 4 mega bytes.
17:10tonyloh yeah mmm
17:11itistodayin the emacs slime repl, how do i go up in history?
17:11itistodayhitting the up arrow just causes the cursor to move up
17:11amalloyitistoday: M-P
17:11fliebeltonyl: I just can't see how a function that is not recursive ends up blowing the stack, after an insane amount of loops.
17:12itistodayamalloy: thanks! what about down?
17:12amalloyM-n, of course! p is usually the opposite of n :)
17:12itistodayamalloy: didn't know that... is that an emacs convention?
17:13amalloyitistoday: sorta. C-p<revious> and C-n<ext> move up and down lines
17:13joegalloEh, it shows up in readline, too. And some other places. Not really sure who started it.
17:13bobo_ctrl+up-arror works aswell
17:13tonylfliebel: I can't see the problem since you are holding 128 bytes at a time
17:13amalloyitistoday: and if you're looking for a specific thing in the history, you can type in the beginning of it before hitting M-p - it will scan through only history entries that match
17:13itistodayamalloy: cool thanks for the tip!
17:14fliebeltonyl: I bet it's some gotcha that keeps some sort of closure open or makes a recursive call every chunk, so that it takes an insane amount of bytes to overflow. I think some Clojure guru might say "oh, but you just nee to… because of…"
17:15jaleycan anyone tell me what, in practice, i might store in an atom vs a ref? i'm trying to figure out what the best thing to do with a session key is...
17:15tonylyeah i am thinking the same, I am guessing it has to be with using reduce with map, but I've done it before. maybe I am wrong
17:17tonylmaybe if you run the map fn in parallel
17:18fliebelgood point...
17:18tonylfliebel: I used pmap instead of map and it did finish with 1e6
17:18raekjaley: if you need it to be coordinated/transactional => ref, if you don't need it, but expose it to users that might => ref, else => atom
17:18tonylbut the duration time was 2.52 mins instead of 4 secs in my machine
17:18fliebeltonyl: It's cheating, but threads get their own stack.
17:18amalloytonyl, fliebel: what's the code that causes the problem? i took fliebel's latest (apply concat (take x ...)) and it works for up to x up to 4e6 for me
17:19fliebelamalloy: http://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj#L33
17:19amalloybut i used frequences from core instead of incanter's freqs, since i don't have invanter
17:19neotykpuredanger: http://clojure.org/community please add http://ams-clj.github.com/
17:19amalloyoh haha
17:19amalloyk
17:20tonyli used just a range 1e6 and the freqs fn gave mea SO error
17:20jaleyraek: thanks! so dosync is not required to call swap! on an atom?
17:20amalloyyeah, i didn't notice the defn of freqs there. trying again
17:20abedracemerick: you around?
17:20amalloyjaley: right. dosync is for refs exclusively
17:20joegallopuredanger: also, http://www.meetup.com/Clojure-PGH/ to community, too. :)
17:21itistodayhalp! http://paste.pocoo.org/show/284551/
17:21amalloytonyl, fliebel: i get a heap space error, not stack overflow
17:21jaleyamalloy: thanks. in that case i probably want a ref so that requests are not made while the session token is renewed
17:21tonylamalloy: what was your input?
17:21itistodaywhat am I doing wrong? isn't that how you destructure..? I ran C-c C-k to compile the thing too...
17:21amalloy(freqs (apply concat (take 3420000 (repeat (shuffle (concat (range 0 10) (range 3 7)))) )))
17:22amalloyitistoday: just delete the x
17:22itistodayamalloy: oh....
17:22itistodaylol
17:23itistodayhorray!
17:23puredangerneotyk: done
17:23itistodayhave any of you played myst?
17:23puredangerjoegallo: done
17:23fliebelamalloy: take of a few zeroes, I think you just used to big a seq for your memory rather than blowing the stack.
17:23neotykpuredanger: thank you!
17:23joegallopuredanger: rocking, thanks!
17:23amalloyfliebel: ah, i see
17:25fliebeltonyl, amalloy: Using pmap avoided the problem for me. It's now chumming along at 200mb of memory and 170% cpu. But I said avoid because threads get their own stack.
17:26tonylyeah, a bit of cheating, but I couldn't think of anything else. kind of new to this.
17:26fliebelI'm okay with it, I'd just like to know what happened.
17:28amalloyfliebel: i agree that's kinda weird - i don't see why stack should be a problem. you could make your code a fair bit less ugly by using update-in and fnil instead of this assoc/inc thing
17:29amalloy&(update-in {} [:not-there] (fnil inc 0))
17:29sexpbot⟹ {:not-there 1}
17:29fliebelamalloy: Thanks, I didn't know about fnil
17:29fliebelamalloy: That's what you get with a cor ns with 508 functions.
17:30amalloyfnil and juxt are applicable to a surprising number of problems
17:30jcromartiefliebel: wow really 508 functions?
17:30fliebelamalloy: I know about juxt, but never used it.
17:30fliebeljcromartie: yea
17:31amalloy&((juxt * +) 4 5)
17:31sexpbot⟹ [20 9]
17:32amalloyother useful juxts are:
17:32amalloy&((juxt quot rem) 100 7)
17:32amalloy&(map (juxt identity inc) (range 5))
17:32sexpbot⟹ [14 2]
17:32sexpbot⟹ ([0 1] [1 2] [2 3] [3 4] [4 5])
17:33fliebelamalloy: I was somehow under the impression juxt would divide the arguments over the functions...
17:34fliebelamalloy: Oh, fibonacci with juxt is going to be awesome :)
17:34amalloyfliebel: nah, juxt isn't much good for fibonacci
17:34amalloyhttp://rosettacode.org/wiki/Fibonacci_sequence#Clojure
17:36fliebelamalloy: Let's see...
17:36amalloyspeaking of which, i was timing the rosettacode implementation for various inputs, and i seemed to be getting N^2 behavior instead of N. anyone know why, or if i'm just crazy?
17:39fliebelamalloy: I think pmap is very inefficient for my problem, I'm only doing an assoc, and starting treads for that :P
17:39amalloyyes, pmap is going to waste a huge amount of time
17:40amalloylooking at the implementation of reduce, it does seem like it might actually overflow on large chunked sequences
17:42fliebelamalloy: so can I dechunk my list?
17:43defntime to investigate...
17:45clizzinIs there a way I can convert a vector of values into a series of those values so that hash-map will take them as arguments? e.g. if v is [1 2 3 4], i want to eventually get {1 2, 3 4}, but (hash-map [1 2 3 4]) isn't valid while (hash-map 1 2 3 4) is. thanks!
17:46defnfliebel: ive been working on something i call "Nutterson", which takes a bit of a different approach to templating :)
17:46fliebeldefn: cool :)
17:46defnit uses hiccup templates and helper functions inside the template
17:46amalloy&(apply hash-map [1 2 3 4])
17:46sexpbot⟹ {1 2, 3 4}
17:47amalloyfliebel: do you have JoC?
17:47clizzinamalloy: ah, that makes sense. thank you!
17:47fliebelamalloy: A what?
17:47amalloyjoy of clojure
17:47defnso template.clj looks like [(defn capitalize! [s] (.toUpperCase s)) [:html [:head [:title (capitalize! title)]] [:body body]]]
17:47fliebelamalloy: yea, but havn't read it yet.
17:47amalloysee chapter 12, search for seq1 if you have the pdf. he builds a de-chunking function
17:50fliebelamalloy: same thing is on his blog, but it looks hackish :(
17:50defnfliebel: ive enjoyed your contributions to the overtone mailing list btw
17:50defnovertone is a really cool piece of software
17:51fliebeldefn: Yea, it is :)
17:51defnmy girlfriend does not like it very much yet
17:51fliebeldefn: *grin* (:use [overtone headphones])
17:52defnhaha does that exist
17:53fliebeldefn: No, but you can try a hardware hack, like plugging 2 small speakers in your audio card and hanging them on your head ;)
17:53defnlol
17:53defnvery funny :)
17:59fliebeldefn: Is the new project on github yet?
18:01defnfliebel: no ive changed my mind a lot and haven't completely committed to that style of templating
18:02defni want to make it possible to use HTML, hiccup, enlive, or haml templating
18:02defnim just not sure how i want to organize it all -- still hammocking on it
18:02fliebeldefn: Cool, let me know when it's done :)
18:06fliebelwut? chunked-seq? returns false for everything I try.
18:08amalloy&(chunked-seq? (map identity (range 100)))
18:08sexpbot⟹ false
18:08amalloy&(chunked-seq? (seq (map identity (range 100))))
18:08sexpbot⟹ true
18:08amalloyfliebel: ^^
18:09fliebelinteresting...
18:09amalloybut i think chunking is supposed to be an "implementation detail"
18:09fliebelamalloy: yea, but I want to get rid of it for the reduce thing.
18:12fliebelamalloy: so I'm not using chunked seqs after all in my reduce, so that can't be the issue.
18:13amalloyfliebel: what? map always returns chunked seqs
18:13fliebel&(chunked-seq? (map identity (range 50)))
18:13sexpbot⟹ false
18:13fliebelamalloy: ^^
18:14amalloyand throw a (seq) around that
18:14amalloyreduce calls seq before it works on the datga
18:14fliebelamalloy: OKay, then I give up :(
18:21fliebelCompact reproduction of my problem:
18:21fliebel&(reduce #(map + %1 %2) (partition 5 (range 1e6)))
18:21sexpbotjava.lang.StackOverflowError
18:25raekcould it be a bug in the ChunkedSeq implementation of InternalReduce?
18:25amalloyfliebel: great. you've isolated the problem to something generic that seems like it "ought" to work. now you can post that to the google group or file a bug report
18:26nickikhas somebody made a clojure style for the latex listings package?
18:26fliebelgreat, but it's late over here, so I'll put it on the todo list for tomorrow.
18:28fliebelgood night! (UGT)
18:30raek,(letfn [(range2 [i n] (lazy-seq (when (< i n) (cons i (range2 (inc i) n)))))] (reduce #(map + %1 %2) (partition 5 (range2 0 1e5))))
18:30clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.StackOverflowError>
18:31raekseems to happen for non-chunked seqs too?
18:33jarpiain&(reduce #(doall (map + %1 %2)) (partition 5 (range 1e6)))
18:33sexpbot⟹ (99999500000 99999700000 99999900000 100000100000 100000300000)
18:36raekinteresting.
18:36jarpiainwithout forcing (map + ...) it builds a stack of lazy seqs (map + (map + ... %2) %2) and forcing that smashes the stack
18:38raekthis makes perfect sense.
18:41amalloyfor a given value of "sense", anyway
18:43raekat least, it explains why the stack overflow occurs
18:44amalloyyes
18:51tonylping?
18:51clojurebotPONG!
18:58tonyljarpiain: how is (reduce #(map + %1 %2) (partition 5 (range 1e6))) force the seq and with doall doesn't if doall retains the head?
18:59amalloytonyl: they both force it eventually. doall forces each map incrementally, whereas if you don't do that reduce builds up a huge recursive set of calls to resolve, and forces them all at once
19:02tonyloh alright, that shine some light to me trying to understand all the do* forms thanks
19:03arohnertonyl: in general, the important thing to remember is whether something holds a reference to the head of a lazy seq
19:03arohnerif something holds the head, the whole list *has* to stay in memory, where as if you do something that doesn't reference the head, the nodes can be GC'd when they're no longer referenced
19:04amalloyarohner: that's not really the relevant thing here, i think
19:04tonylI am trying to build a mental map of that.
19:04amalloydoall holding the head is in fact a disadvantage; the reason we need it is that it forces each element, not that it holds the head
19:05tonylso doall deals with returned values (which forces the elements) instead of resolving recursive calls
19:13amalloytonyl: that's how it looks to me. you could probably do the same thing without holding onto the sequence head, via some trickery like (first ((juxt first last) the-seq))
19:14amalloysince juxt is eager it should find the last elt of the seq without holding the head, and you'll be taking the first element rather than the seq itself, so it should be available for GC
19:16amalloy(and all my "shoulds" should probably be taken with a grain of salt. don't build nuclear power plants on this advice)
19:16tonylhehe i understand
19:17tonylamalloy: wow, thanks for the explanation. junx looks very interesting too.
19:18amalloytonyl: you should join the juxt fan club, founded by raek
19:19tonyldid he created that fn?
19:19amalloyhttp://github.com/Raynes/sexpbot/blob/master/src/sexpbot/plugins/seen.clj#L49
19:19raekheh, no... :) I just like it
19:19amalloyno; raek, technomancy, and i are always going on about how great it is
19:19tonylhehe
19:20amalloytonyl: juxt in action at the link above
19:21tonylthanks amalloy
19:21tonyli'll see how junx can help me in some of my code
19:21amalloyheh, junx. it'll only work if you spell it juxt tho
19:22tonyl:P true
19:26amalloy$whatis CA
19:26sexpbotCA = The Clojure contributors agreement: http://clojure.org/contributing
19:26amalloyoh cool, i'm finally on that list
19:32raekamalloy: congrats!
19:33amalloyraek: thanks!
19:34Kenjinhello
19:34nickikwith C x u i can make a undo in emacs
19:34nickikwhat if i want to make like 10 in a row
19:34nickikis there a faster way then C-x u C-x u C-x u ......
19:35amalloynickik: C-10 C-x u
19:35nickikah ok thx
19:35amalloynickik: also, usually C-/ and C-_ are faster ways to get at undo
19:36nickikthx, very usefull
19:37mrBliss``nickik: http://www.emacswiki.org/emacs/UndoTree
19:48amalloynickik: C-u <num> <cmd> will send cmd a numeric argument. C-<num> and M-<num> are shorthand for that; they probably always work, but i'm not a long-time emacs user
19:49nickikk
19:50nickiki'll have to keep that in mind
20:54amalloyRaynes: ping?
21:06tonylping?
21:06clojurebotPONG!
21:50tonylping?
21:50clojurebotPONG!
21:50tonylwhy?
21:50clojurebothttp://clojure.org/rationale
21:50tonylhow?
21:50clojurebotwith style and grace
21:50tonylwhat?
21:50clojurebotwhat is short for ,(doc ...)
21:50tonylwhat is source?
21:51tonylwhat source
21:51tonylwhat is source
22:20Raynesamalloy: Hey. I should be on quite a bit tomorrow. I have a new bed and a bookcase to put together tonight, so I'm not going to be around. Plus one bed to take down, a room to rearrange, and my back is already killing me. :(
22:20RaynesI'll talk to you probably tomorrow. <3
22:21amalloyRaynes: no worries. i was just looking for some ideas on implementing stuff
22:22Raynesamalloy: I have a few moments.
22:24amalloyi was trying to come up with a way for swap! to check a predicate and leave the old value if the predicate is false. easy enough; but i couldn't find a way to discover whether the swap had "failed"
22:24amalloyi tried attaching ::succeeded key to the value's meta, but since the value is a java.lang.Integer...
22:27amalloyi could include another, local atom and swap! it with true or false, but surely there's a way to do this without introducing more mutability
22:28amalloyRaynes: anyway, that's where i am now
22:28Raynesamalloy: Sorry, had to run off for a second.
22:29Raynesamalloy: You could just throw it in the ref and not even bother with the atoms.
22:30RaynesBut, I guess that doesn't really solve your problem.
22:31Raynes;)
22:31amalloyheh, no it doesn't
22:32RaynesAnyways, I'm going to run. I've got a back to finish breaking.
22:32Raynes;|
22:32amalloyg'night! lift with your knees!
22:49amalloyanyone else have a clever solution to this? i want to speculatively adjust an atom, leaving it alone if the new value doesn't satisfy some predicate. that i can do, but how can i find out, from outside the swap!, whether the atom changed or not?
22:53tonylI'm just learning about the stm, sorry can't help much
22:54hiredmanatoms don't use the stm
22:54hiredman,(doc add-watch)
22:54clojurebot"([reference key fn]); Alpha - subject to change. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Wh...
22:55tonylmm really, obviously need to learn more
23:28subusome help please
23:28subuI'm trying to install clojure-contrib in ubuntu
23:28subuis this the right place to ask for help?
23:29arohnersubu: yes, it is
23:29subuoh ok
23:29subuI cloned the git repo for clojure-contrib
23:30subuand then did 'mvn package'
23:30_seanc_If you create a project with lein new, how can you navigate to the lib directory when using file?
23:30subufollowing the instructions here http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html
23:30amalloysubu: are you using cake or lein, or just plain clojure?
23:30amalloyah. lein, sounds like
23:30subuplain clojure
23:30subuI think
23:31sububut I cannot find a target directory which is supposed to contain clojure-contrib.jar
23:31amalloythis page is somewhat out of date; it's not nearly as complex as all this
23:31tonylsubu: I followed this simple tutorial and works for me http://riddell.us/ClojureOnUbuntu.html
23:31subuoh ok
23:32tridd3llused to be in the target directory
23:32tonylnight
23:32tridd3llI wrote that tutorial... a while back though :-)
23:32subuhmmm ok
23:32subunow there is no target directory
23:32tridd3llthis was a newer one: http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html
23:33tridd3llbut this is all manual... there are other ways
23:33amalloysubu: you can download http://github.com/technomancy/leiningen/raw/master/bin/lein, and put it on your PATH. then lein self-install will download everything you need
23:33subuthanks alan, I'll do that
23:33tridd3lland I haven't used these techniques in a while
23:33subuok
23:37amalloyanyway, once lein is on your path, you should be able to start a project and get a repl:
23:37amalloy$ lein new myproj
23:37amalloy$ cd myproj && lein repl
23:39subucool, that works
23:41amalloyhey subu, how'd you know my first name? find me on the google group or something?
23:41subuhmm.. I played with Michael in New Orleans, and found you on google groups
23:42subuand asked him if you were alan@malloy.org
23:42amalloyhuh. are you the subu who plays in palo alto sometimes?
23:42subuyup
23:42amalloyaha
23:56TheBusbyamalloy: another Alan! I rarely run across anyone else with the same spelling.
23:56amalloyTheBusby: irish?
23:57amalloy(mine is)
23:57TheBusbyamalloy: no, my family has been in the US a long time.
23:57amalloyoh, so's mine. but the name and spelling are an influence of my irish ancestors
23:58TheBusbyahh, didn't realize that might be the case