#clojure logs

2011-08-15

00:03leo2007is there something like macrolet for clojure?
00:03amalloyleo2007: in c.c.macro-utils, which i think is now org.clojure/tools.macro or something
00:03leo2007thanks
00:09fmeyerexit
00:32Drakesonis it possible to `require' relative to the current namespace, similar to python's "from .submodule import Things" ?
00:32amalloyno
00:34Drakesonbut would such a feature make sense?
00:40DrakesonI mean, would it be possible to modify #'clojure.core/load-lib to support this feature?
00:42amalloyit's certainly possible. bet you ten dollars a patch wouldn't be accepted, though
01:03jsoftIn java its got what looks like some kind of typcast, ie NameClasspair foo = (NameClassPair) blah.next(). How do I do the typecast in clojure?
01:04amalloyyou don't have to
01:05jsoftHmm.
01:20jsoft:(
01:20jsoftArgh
01:20jsoftWhy does my brain not get along with java.
01:35chewbrancaanyone successfully following a CouchDB _changes feed with the clutch clojar?
01:39chewbrancaI'm running into the same issue as here: https://groups.google.com/forum/#!topic/clojure-clutch/vqkzG1aqpUw
01:58PupenoHow do you add a second library, both with :as, to the require part of ns?
02:00Pupenofound it.
03:02dsantiagoHow do you set a property in leiningen in a file so that it's available with System/getProperty?
04:34lnostdalmaybe i should just compile emacs 24 from source myself .. no one else is seeing leaks using the build from http://emacs.naquadah.org/ ? (natty)
07:14joshc_Does anyone know why when I'm using defn and defining a docstring, the doc command works but there does appear to be any doc metadata on the function?
07:22morphlingjoshc_: try (meta #'your-function) instead of (meta your-function)
07:24joshc_That worked, thanks. I'm trying to use Marginalia, but it seems to be unable to detect any of my docstrings.
07:24morphlingsomething with meta data on the function and not the var, I think, but I'm not sure, better ask again when someone more knowlegable is around
07:26joshc_Thanks, will do
07:28algernonmarginalia has some troubles detecting docstrings at times. from what I've gathered so far, it might have to do something with clojure 1.3 (but then, I've been using clojure for like two and a half weeks so far, on and off :P)
07:33joshc_I'm running 1.2.1 and for some reason when I run marginalia against itself, it works no problem, but will only detect regular comments when run against my code
07:41manutterI would have thought Marginalia would extract the docstrings directly from the source rather than from function meta
07:41manutterAre your docstrings formatted the same way as Marginalia's as far as line breaks in the source code, etc?
07:43kencauseyhttp://groups.google.com/group/marginalia-clj/browse_thread/thread/23a424ed9fbedb4a
07:43kencauseyrelated?
07:43algernon(and my issue is related to the above link, I filed issue #55)
07:45joshc_I tried all three styles of line breaks, and tried copying in a function from the marginalia source, still didn't work
07:46algernonit's probably not the formatting of the function itself, that breaks marginalia.
07:47algernonIn my case at least, it wasn't. I trimmed down my (ns) and marginalia began to work.
07:48joshc_algernon I think we have the same problem (issue 55) I have a bunch of requires in my code
07:49algernonjoshc_: try removing them and see if that unbreaks marginalia. If nothing else, we'll know that it's the same underlying issue then
07:49joshc_Will do
07:52joshc_algernon: I cleaned out my ns and everything worked
08:05joshc_algernon: I added a comment to issue #55
09:12PPPaultest
09:32TimMcPPPaul: Your test worked.
09:32PPPaulawesome!
09:34TimMc"Thank you for experimenting with Wikipedia. Your test worked, and it has been reverted or removed. Please use the sandbox for any other tests you may want to do. Take a look at the welcome page to learn more about contributing to our encyclopedia."
09:34TimMc^ what I think of whenever someone writes "test"
10:22kephalenamespace question, i am refactoring what was a single file into separate files, but i would like 'use to bind symbols from the separate file to the original name (for backwards compatibility), how does one do this?
10:24manutterdo you actually need/want separate namespaces? If you're just breaking up the files for easier maintenance, you can use (in-ns) to load the symbols directly into their old namespace
10:25zmarilIf I were using noir and mongo, how should I set up the database? I have very little prior experience with backend and the MVC model is new to me
10:25manutterif you want separate namespaces though, I don't see why you can't use/refer them from the original file
10:25kephalewell, i kind of do want the namespaces separated, in-ns is the best alternative
10:25manutterzmaril: what do you mean by set up the db?
10:26manutterkephale: (use) should be ok as long as the separated-out file isn't using or requiring the original file
10:26zmarilmanutter: Like I see how to create a new db with mongo, but I am unsure of where to create it and how to pass it around in a functional way.
10:26manutteror is that what the problem is
10:27kephalewell, use isn't binding the symbols from the new smaller NSs the way i am looking for, use case:
10:27manutterzmaril: ok, that's not too hard. Create a namespace for your db, and make a create-db function that does all the initial setup and returns some kind of db object that you can pass around
10:28kephale(ns foo) had (defn botmaker [] …) now botmaker was moved to (ns foo.bots), now calling (use 'foo) does not provide botmaker
10:28zmarilLet me give that a shot then
10:28kephalegiven (ns foo (:use [foo.bots]))
10:28manutterzmaril: you can probably find some tutorial examples if you google around
10:29zmarilmanutter: most of them are single page things about how to get up and running on herkou
10:29manutterkephale: wonder if you would have better luck calling an explicit (refer 'foo.bots.botmaker)?
10:30kephalemanutter: well thats what i was thinking, but some of the NS's have a looot of things defined
10:30raekkephale: you are pretty much stuck with either using (load-file) + (in-ns) or releasing a new major version...
10:30manutterkephale: I'm kinda out of my depth here, so I'm groping around for ideas
10:30kephalei was thinking about a hack that looked for all symbols in a namespace and aliased them
10:31manutterkephale: that's kind of the way I was leaning (in my blissful ignorance)
10:31kephalemanutter & raek: ah, ok, i might putter at that aliasing hack
10:31raekkephale: there is a macro called 'immigrate' in contrib, but it doesn't really work that well
10:31kephaleraek: oh cool!
10:32kephaleit just has to work well enough : P
10:32raekif backwards compability is essential, using load-file to "include" additional files into the namespace is probably the best idea
10:32raekbinding won't work reliably, since you have to vars for the same value (only one of them will be rebound)
10:33kephalewell, that makes it a bit harder to become forwards compatible, since all future code should really switch to use/require on the new namespaces
10:33manutterzmaril: the one-page examples are probably not a bad start, but if your app gets more complicated then separating out the db stuff will be easier to maintain
10:33kephalewith the opening 'ns call and all
10:33manutterzmaril: the basic approach should remain the same though
10:34raekwell, new major version is what I would recommend
10:34kephaleraek: heh, i'd love to… unfortunately its not my call
10:35kephalebut immigrate (which seems to be require + a loop of interning) does look like it might hold me over, i'll poke around
10:35raekcompojure used immigrate initially, but stopped later, IIRC
10:36raekload-file + in-ns will allow you to structure the implementation better, but doesn't expose the "new API"
10:38kephaleooo immigrate seems to be working like a charm thus far
10:38duck1123_There's also potemkin, but that works on a var by var basis
10:39kephalewell, i'm hoping i can just leave this "depricated" file that used to have everything, and just use it for the immigrate call, then anything new can be written with the new API
10:39duck1123_but provided you pass it a var, it works with 1.3
10:40kephalepotemkin looks like it wraps intern?
10:40leo2007How to configure lein to run the latest snapshot of clojure?
10:41raekheh, then any problems that might be caused by 'immigrate' will only affect the users of the old API...
10:41duck1123_leo2007: just edit your project.clj and ref the vewer version
10:41raekan incentive to upgrade
10:41leo2007duck1123_: thanks.
10:42kephaleraek: yeah, perfect : P
10:43leo2007duck1123_: where is clojure installed by lein?
10:43duck1123_It's in your mvn repo ~/.m2
10:44manutterleo2007: or, depending what you mean by "installed," in your project's lib/ directory
10:44duck1123_lein just uses maven's dependency resolution under the hood, which makes it handy
10:45duck1123_manutter: Good point, as a Maven user, I tend to forget about lib/
10:45raekleo2007: they are downloaded to the local maven repo in ~/.m2 . the ones you use in your particular project are copied over to the lib/ directory. (in the future, they might be symlinks instead)
10:46raekso you have one environment per project. (but the jars are cached in your local repo)
10:46leo2007raek: thanks.
10:46mattmitchellwhat's the best way to select non-empty values from a map... kinda like select-keys except selecting only non-blanks ?
10:47raekmattmitchell: one way is to use the (into (empty m) (processing-function m)) pattern, where processing-function might be filter, for instance
10:48leo2007what's the version for clojure upstream from git repo?
10:48raekthe filter predicate would receive one argument which is a vector (a map entry, actually) of the form [key value]
10:48leo2007I need it so that lein can pull it in
10:48duck1123_(into {} (filter (fn [[k v]] (identity v)) {:m 1 :n nil}))
10:48mattmitchellraek: cool let me try that out
10:50raekduck1123_: you could replace (identity v) with just v there... >/(
10:50raek*:-)
10:50mattmitchellvery cool, thanks
10:50duck1123_good point.
10:50raekgah. accidentally switched keyboard layout in the middle of the smiley...
10:51duck1123_I guess that comment about "if you type (identity you don't know what you're doing" applies
10:51raek,(into {} (filter val {:m 1 :n nil}))
10:51clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
10:51raek,filter
10:51clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
10:51duck1123_clojurebot is still messed up
10:52manutteroh, sadness
10:52raek,((resolve (symbol "ns-unmap")) *ns* 'resolve)
10:52clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
10:52manutter~bot-bandaid
10:52clojurebotHuh?
10:52manutterwell, I tried.
10:53Hodapp:(
10:53raekanyway... (into {} (filter val {:m 1 :n nil})) => {:m 1}
10:56raekleo2007: the latest beta version of clojure is [org.clojure/clojure "1.3.0-beta1"]
10:57raekI think the nightly build version is "1.3.0-master-SNAPSHOT"
11:03PPPaulis there a simple way to to see if 2 arrays share a certain value somewhere in them?
11:04PPPaularrays = seq
11:04duck1123_first question, is there anyway you can represent them as sets?
11:06lucianPPPaul: i think you could make them sets and intersect them, as duck1123 suggests
11:06duck1123_if you know what the value is, you could test that they each contain the value
11:07PPPaulactually, the values i'm looking for are in a seq too
11:07PPPauli guess i want to test if 3 seqs have the same values
11:08duck1123_Then I would definitely looking into making them sets
11:08PPPaulok
11:08PPPauli haven't played with sets yet]
11:09duck1123_Lots of fun stuff http://clojuredocs.org/clojure_core/clojure.set
11:11PPPaul:D
11:13raek(let [a (set [1 3 2]), b #{1 2 3}, c #{3 2 1}] (= a b c)) => true
11:13manutter,(println "test")
11:13clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
11:14manutter##(println "test")
11:14lazybot⇒ test nil
11:15PPPaulthanks a lot!
11:33timvisherhey all
11:34timvisheri'm looking for reading i can do on functional code smells.
11:34timvisheranyone have any suggestions?
11:34wastrelwhat does it mean functional code smells
11:35timvishercode smells in the sense of Fowler's Refactoring
11:35timvisherhopefully that wasn't a reference to Silence of the Lambs. :)
11:36timvisherwastrel: are you familiar with Fowler's book?
11:36wastrelno
11:37timvisherah
11:38timvisherwell, code smells are just things in code (structure, method length, variable names, coupling, etc.) that, when done in a certain way, should 'look ugly' or 'smell bad' to you when you see them and encourage you to refactor
11:38timvishera simple example that is cross-cutting accross all languages and idioms would be methods or functions that do many things. You probably want every function to do only one thing, do it well, and be tested for that
11:39timvisherso that when you compose it later on, you can easily understand what you're doing
11:39timvisherhowever, a lot of the smells in fowler's book are more geered toward OO, i was wondering if anything like that had been done for functional
11:39timvisherejackson: sorry to hear it! ;)
11:40ejacksoni regard it as I do cheese
11:40timvisherhah
12:01dnolendamn
12:02dnolen,(subvec [1 2 3] 1)
12:02clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
12:02dnolen&(subvec [1 2 3] 1)
12:02lazybot⇒ [2 3]
12:02dnolenno more rest on vectors for me.
12:03chouseroh? why's that?
12:03dnolensubvec 1 does the same thing while preserving the vector type (yes, i was being a little over the top :)
12:04chouseryeah, subvec is really nice.
12:05dnolenugh, http://blog.dhananjaynene.com/2011/08/cperformance-comparison-languages-styles-and-vms-java-scala-python-erlang-clojure-ruby-groovy-javascript/
12:06dnolenpeople who don't know the language they're benchmark should not benchmark
12:08upwardindexDoes clojure run on openjdk?
12:08st3fandnolen: looks like they forgot to compile the clojure code
12:10dnolenst3fan: no those numbers are accurate for that kind of code.
12:10dnolencalling count on range is *LINEAR*
12:10upwardindexdnolen: I think the key part of the article is "I can’t write the fastest possible code across all this languages."
12:10chouserugh. wasn't always.
12:10st3fandnolen: oh oops. i did not look at the code.
12:10dnolenupwardindex: "I don't know Clojure so I'm going to write some crap"
12:11st3fanwell, correct his code and ask to run the bench again :)
12:11upwardindexdnolen: I found this to be generally more accurate: http://shootout.alioth.debian.org/
12:12dnolenupwardindex: you don' t need to tell me, I consider myself a minor Clojure perf expert :)
12:39lucianupwardindex: except it's extremely biased
12:39lucianand mostly useless
12:40upwardindexlucian: biased towards what?
12:40lucianupwardindex: towards numeric processing code
12:40lucianit has extremely small synthetic benchmarks
12:41dnolenlucian: numeric processing is good indicator of the performance of much higher level benchmarks
12:41lucianit's very hard to benchmark worth-while things between languages (like a template language compiler)
12:41dnolenyou can't implement Clojure in Clojure without very, very good numeric perf
12:41luciandnolen: sure you can
12:41upwardindexlucian: true, however i found it matches my experience with the 2-3 languages im most proficient with
12:41luciandnolen: i think it's not a good indicator at all, although it may be useful
12:41dnolenlucian: you can and lose performance, Clojure is performance oriented.
12:42luciandnolen: my point is that the benchmark tests something almost entirely irrelevant to what mosts of us actually do
12:42dnolenlucian: because you benefit from it.
12:42dnolenlucian: but someone needs to do the work that you benefit from
12:43luciandnolen: really, read the code on those benchmarks for several languages. you'll change your opinion
12:43dnolenlucian: I have, and I do stuff like that all the time.
12:57timvisheranyone know if anything's been written about common lisp/functional anti-patterns and smells?
12:57timvishersomething along the lines of the first few chapters of Fowler's Refactoring?
12:58ejacksontimvisher: the next Clojure book, authored by you.... ?
12:58timvisherlol
12:58timvishera bunch of people just told me the same thing at lunch
13:02timvisheri'm actually thinking i'm just going to have to work my way through MM. fogus and houser's book again
13:05ejacksonyeah, i guess you're looking for (map not (extract-practices joy-of-clojure))
13:07timvisherejackson: basically. :)
13:08timvisherin a completely unrelated turn of events, anyone watch any of my VimGolf in Emacs videos?
13:14jfieldswjat
13:15jfieldssorry...
13:16jfieldswhat's the easiest way to convert {"bob" {"accounts" {"NGM1" {"lynx-available" true, "account" "acct"}}, "default-account" "xyz"}, "joe" {"accounts" {"NGM1" {"lynx-available" true, "account" "acct"}}, "default-account" "asd"}} to {"bob" {:accounts {"NGM1" {:lynx-available true, :account "acct"}}, :default-account "xyz"}, "joe" {:accounts {"NGM1" {:lynx-available true, :account "acct"}}, :default-account "asd"}}
13:16jfieldsnote the 2nd and 4th level keys are keywords in the version I'm looking for.
13:26TimMcjfields: You want all the non-top keys to go string -> keyword?
13:26TimMcsome kind of tree-walk inside an (into {} (map ...))
13:26jfieldsno, unfortunately, only the keys at depth 1 and 3.
13:27jfieldsyeah... I'm looking through the source of clojure.walk now... thanks. =)
13:27lobotomyhmm, would get-in work?
13:49jfieldsmy solution, feedback welcome: http://www.pastie.org/2376311
13:53amalloyi'd call it depths instead of indexes
13:58amalloyand probably pull the duplication of (hv v) outside of the (if) so you don't have to repeat it. neat little corecursive solution, though
13:59amalloyduck1123_: if it makes you feel better, clojure.core has (identity in it too
13:59amalloy&(macroexpand '(.getClass Class))
13:59lazybot⇒ (. (clojure.core/identity Class) getClass)
14:14jfieldsamalloy, thanks for the feedback.
14:50gtrak`is there a way to do some custom global lein config that overrides what's in a project.clj? for instance, I want to ignore a certain dev-dependency (so I don't have to ask everyone else to change it)
14:52gtrak`I see there's a ~/.lein/init.clj file I can stuff code in
14:53ejacksongtrak: i know that can be used to store your binary repository credentials and lein will fetch them from there
14:54gtrak`I'd like to globally override a version of a dev-dependency just for my box... maybe there's some api call to hook into?
14:55amalloyinteresting. is there any clear reason that (for [x (range 10) :when (even? x)]) is illegal? specifically, it requires a body instead of allowing an implicit nil like (fn) does
14:56amalloyi found myself wanting to use for just to count a sequence, and nil would have been fine
15:01TimMcWait, what are you trying to do?
15:02raekgtrak`: maybe you could install a new custom version of the dependency locally
15:03raekor install it as a plugin
15:03amalloyTimMc: me or gtrak?
15:03raekwhich dependency is it?
15:03gtrak`lein swank
15:03TimMcamalloy: You. You want (nil...) ?
15:03amalloyTimMc: (count (for [x some-seq, y some-seq, :when (some-condition x y)] ...))
15:03TimMcso you can (count..) it?
15:03TimMcah
15:04amalloyi don't care about the elements, i just want to see how many pass a condition
15:04amalloyand was a bit annoyed to have to put in a body, is all
15:04raekdon't know a way to add the :excludes option globally
15:04gtrak`everyone else uses lein 1.5, I use 1.6, which is broken on swank-clojure 1.2, I'd like to workaround it automatically for myself instead of fiddling with project dependencies or asking them to change
15:04ibdknoxamalloy: why not filter?
15:05amalloyibdknox: because (for) does the nice nested-iteration of xs,ys
15:05ibdknoxamalloy: gotcha
15:07raekgtrak`: so you want something like :excludes but global?
15:08oichI am new to clojure. On http://webnoir.org the getting started and tutorial pages show running the web server and then show some lisp code, but don't say where (what file? what path?) to put the code. do you know where?
15:08gtrak`yes, generically, it'd be cool to intercept the map created in a project.clj that lein uses and munge it up a bit
15:08ibdknoxwe need to just convince everyone to remove lein-swank from their project dependencies
15:08ibdknoxand use the wonderful lein plugin install to do it locally for themselves
15:09amalloy(inc ibdknox)
15:09lazybot⟹ 1
15:09amalloyor the global cake project, which is what i do
15:09ibdknoxor that :)
15:09gtrak`raek, I want to write a bit of code that says, if dev-dependencies has swank-clojure, then override its version..
15:09ibdknoxgtrak: the simple solution would be to remove the jar from lib
15:10amalloygtrak`: why are you still using swank-clojure 1.2?
15:10amalloymake everyone upgrade, problem solved?
15:11gtrak`sure
15:11gtrak`still surprised I can't do it with some code
15:14raekgtrak`: if your project depends on for example intancter, you can exclude its swank-clojure dependency: [incanter "1.2.3" :exclusions [swank-clojure]]
15:15raekyou have to do this for every library that pulls in the bad dependency, though
15:15gtrak`right, that's not really what I'm talking about though, would like to override it globally without touching the project.clj
15:16ibdknoxWe should log issues against all the libs that have swank-clojure as a dep
15:16gtrak`or having to remember to run some command each time, etc..
15:16ibdknoxjust to start removing this problem entirely
15:18upwardindexI'm trying to do "lein deps" with [ring/ring‑core "0.3.9"] in my project and I errors POM for 'ring:ring‑core:pom:0.3.9:compile' is invalid. Any idea what I'm doing wrong?
15:19gtrak`I think I would have to mess with the defproject macro to do it
15:20upwardindexhttp://clojars.org/repo/ring/ring-core/0.3.9/ seems to exist and everything
15:20gtrak`ah, this should be simple, I think I can provide a function in a var that filters the project, any chance they would pull in something like that?
15:31sleepynateupwardindex: is there a conflicting dependency, by chance? i know frequently i've had to move back from 1.2.1 to 1.2.0 to satisfy a lot of deps
15:31upwardindexsleepynate: That might be it, i'll try reverting to 1.2.0
15:32sleepynateupwardindex: especially contrib. the website says contrib is still 1.2 :)
15:32upwardindexsleepynate: Unfortunately, no difference on 1.2.0
15:34upwardindexsleepynate: I'm doing a lein search ring to see if it can find it
15:37sleepynateupwardindex: the version on clojars is 0.3.11
15:39upwardindexsleepynate: Same thing with 0.3.11, something very basic must be broken with my setup
15:39upwardindexIs there a way to test a clojure/leiningen installation?
15:40upwardindexTo make sure that everything is working as it should?
15:41upwardindexAh one thing I wasn't sure about: Is OpenJDK fine or should I use another VM?
15:41sleepynatei use openjdk generally without issue
15:42sleepynatethe easy way to test is to create a new blank project with "lein new derp", then add contrib as a dependency, and lein deps
15:43sleepynateif those download and compile properly, clojure itself and leiningen should be functioning properly
15:43upwardindexsleepynate: exactly what I did except instead of adding contrib I added ring/ring-core
15:43MasseRupwardindex: Otherwise openjdk seems to work, but clojurescript is unusable with it (and while it is so, I refrain from clojurescript)
15:43upwardindexill try with contrib
15:44sleepynateoh yea. i should add that i've never touched clojurescript yet
15:44sleepynateso if that's what you're shooting for i have no idea
15:45sleepynatehttps://github.com/weavejester <-- this fellow is in charge of packaging ring-core among a number of others. perhaps he knows more (assuming your standard setup is working)
15:46upwardindexsleepynate: Yay, clojure-contrib works!
15:49xandrewsis there a way to list an agent's watch functions?
15:49sleepynatefwiw, ring/ring-core builds find for me against org.clojure/clojure 1.2.1
15:50sleepynatejava version "1.6.0_22"
15:50sleepynateOpenJDK Runtime Environment (IcedTea6 1.10.2) (6b22-1.10.2-0ubuntu1~11.04.1)
15:51sleepynate0.3.9 and 0.3.11
15:51raekupwardindex: maybe you could try deleting everything in ~/.m2
15:51upwardindexraek: I'll try that right away
15:52sleepynateyea. that will force maven to fetch everything anew
15:56upwardindexraek: same behavior, let me paste the output I'm not too familiar with maven maybe something will catch your eye
15:58upwardindexHere is the output i get http://pastebin.com/XbyRhHWX
15:59upwardindexAnd that is on: Leiningen 1.6.1 on Java 1.6.0_22 OpenJDK Client VM
15:59sleepynateyea this totally looks like a dependency thing
16:00sleepynateyou only have org.clojure/clojure and ring/ring-core ?
16:00sleepynatein project.clj?
16:00upwardindexsleepynate: no I have clojure-contrib also
16:00upwardindexsleepynate: that I added earlier to test
16:01upwardindexsleepynate: should I paste my project.clj?
16:01sleepynatecan't hurt
16:03upwardindexhttp://pastebin.com/NVRD5R89
16:04sleepynatethat builds for me
16:05upwardindexsomething must be wrong with my environment
16:06sleepynaterm project/libs/*.jar
16:06sleepynatethen rm ~/.m2/repository/*
16:06sleepynatethen lein deps
16:06sleepynateif that doesn't work, no idea :)
16:07sleepynate(though i'm by no means an expert)
16:08upwardindexah there is no "libs" folder in my project folder, could that be the problem?
16:08sleepynatelib, sorry
16:09amalloy&(doc when-first) is a neat function that i always forget exists. just mentioning it here as a sort of public service announcement
16:09lazybot⇒ "Macro ([bindings & body]); bindings => x xs Same as (when (seq xs) (let [x (first xs)] body))"
16:09upwardindexsleepynate: same no lib folder, do i have to create it?
16:09sleepynateupwardindex: shouldn't
16:10sleepynateleiningen should create it
16:10sleepynatei assume you're on linux?
16:11amalloyah, irc, one of the few places where "i assume you're on linux" isn't some sort of weird joke
16:11upwardindexsleepynate: yes, kubuntu
16:12upwardindexnever thought going through the clojure tutorials would be so hard
16:12amalloyupwardindex: have you tried 4clojure.com? it'll let you get started learning without having to install stuff
16:13sleepynateamalloy: well, he mentioned he was using openjdk :)
16:14upwardindexamalloy: no, looks like a nice set of exercises, however it will only delay the inevitable :D
16:14xandrewsif anyone was interested in how to list watch fns of an agent, this will do the trick: (.getWatches a)
16:14sleepynateupwardindex: what's your java -version ? and what version of kubuntu ?
16:14amalloyupwardindex: you can be our 1,001st user. just missed the chance to be #1000, i guess
16:15upwardindexjava version "1.6.0_22"
16:15upwardindexOpenJDK Runtime Environment (IcedTea6 1.10.2) (6b22-1.10.2-0ubuntu1~11.04.1)
16:15upwardindexOpenJDK Client VM (build 20.0-b11, mixed mode, sharing)
16:15sleepynatehuh
16:15sleepynatesame as me
16:17sleepynateamalloy: this is fun. it's like the thing those ruby dudes do
16:17amalloysleepynate: what is? debugging someone's openjdk, or starting on 4clojure?
16:17sleepynate4clojure
16:18sleepynatec'mon, the ruby guys don't know how to debug a stack trace ;) </playful>
16:18dsantiagoIs there some place you can stick a Java properties file to have it automatically be loaded and have its properties available via System/getProperty?
16:18amalloyyeah, it's genuinely a good learning tool for all levels of experience. i've been humbled by a number of really-cool tweeted solutions
16:19dsantiagoI thought this was possible, but I can't seem to google up any docs for that.
16:19sleepynateamalloy: love when that happens :D
16:20sleepynateamalloy: i will play more later. good work and thanks for the community asset
16:27sjlAnyone know if Slimv has an issue tracker or mailing list somewhere?
16:28upwardindexring/ring-core doesnt work but ring/ring-jetty-adapter does. Closing in on the problem....
16:33upwardindexWow, something is definitely broken, I can lein deps [ring "0.3.11"] which in turn requires ring/ring-core but not ring/ring-core directly
16:33upwardindexAm I going crazy or what?
16:36amalloyupwardindex: well, that version of ring is depending on ring-core 0.3.11, not 0.3.9
16:36amalloyand while 0.3.9 appears to exist, i can imagine it might be broken
16:36upwardindexamalloy: thats the thing i only switched to 0.3.9 because 0.3.11 was not working
16:36upwardindexamalloy: but not the issue seems to be resolved
16:37upwardindexamalloy: not sure what the solution has been
16:38upwardindexsleepynate: thanks for your help the issue is finally resolved, not exactly sure why or how...
16:58eskatremquick question: what is the clojure equivalent of for(int i=0;i<10;i++) { for(int j=0;j<10;j++) { //do stuff}} ?
16:59lobotomy,(for [i (range 2) j (range 3)] [i j])
16:59clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
16:59lobotomyhmm, what
17:00lobotomy&(for [i (range 2) j (range 3)] [i j])
17:00lazybot⇒ ([0 0] [0 1] [0 2] [1 0] [1 1] [1 2])
17:00amalloylobotomy: clojurebot has been on a bender for about 24 hours now
17:00eskatremthanks lobo
17:01TimMceskatrem: "do stuff"?
17:01amalloyeskatrem: lobotomy is right as long as you realize he means "// return stuff", not "//do stuff"
17:01TimMcor compute stuff?
17:01amalloyTimMc: cooperative ninja?
17:01TimMc:-)
17:02lobotomywhat's the proper way to do stuff then? doseq?
17:02lobotomye.g. if there's print or whatever
17:02amalloyyes. better, of course is to try not to do stuff
17:03schlechtis there an idiomatic way to make the following less clunky? "(- {:key map1} {:key map2})"
17:03amalloy&(let [stuff-not-done (for [x (range 10)] (println x))] 10) ;; doesn't print anything
17:03lazybot⇒ 10
17:03schlechtI'm looking at something like (- map1 map2 key)
17:03amalloyschlecht: that will throw an exception anyway
17:04eskatremsorry, what's the & ford?
17:04amalloydo you mean to use ( instead of {
17:04eskatrem*does
17:04eskatremdont know how I typed "ford"
17:04schlechtamalloy: oups
17:04schlechtamalloy: yes, but that was not my problem
17:04amalloyeskatrem: your left hand was one letter too far right :P
17:05eskatremamalloy: hmm true :s
17:05schlechtamalloy: I mean something like: (- {:a 1 :b 2} {:a 1 :b 3} :b) == -1
17:06dnolen,(apply - (map :key [{:key 10} {:key 5}]))
17:06clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
17:06dnolen&(apply - (map :key [{:key 10} {:key 5}]))
17:06lazybot⇒ 5
17:07dnolen&(reduce - (map :b [{:b 10 :a 9} {:b 5 :a 3}]))
17:07lazybot⇒ 5
17:08schlechtdnolen: hey, kinda obvious once you think about it :-) Thanks
17:10TimMceskatrem: The & is so the bot will pay attention.
17:11eskatremTimMc: Ok, I was wondering if it was a clojure command of some kind...
18:14sleepynateeskatrem: you can put your "do stuff" in that last square brackets
18:15sleepynatewell, you don't need the squre brackets unless you want vectors
18:16sleepynate&(for [i (range 3) j (range 3) k (range 3)] (+ i j k))
18:16lazybot⇒ (0 1 2 1 2 3 2 3 4 1 2 3 2 3 4 3 4 5 2 3 4 3 4 5 4 5 6)
18:17sleepynate&(apply - (for [i (range 3) j (range 3) k (range 3)] (+ i j k)))
18:17lazybot⇒ -81
18:17sleepynateetc
18:18eskatremsleepynate sorry, I am not an english native speaker. square bracker is [ ] ?
18:18sleepynateyea
18:18sleepynatethat would be if you wanted vectors
18:19eskatremok so basically its
18:20eskatrem(for [i (range 2) j (range 3) k (range 4)] (;do stuff))
18:20sleepynate(for [implicit let statement] (do this) )
18:20sleepynateright
18:20ShreeMulayHello everyone! Quick question: If I want to build restful services in clojure, what are the recommendations? Got links?
18:21tremolohttps://github.com/mmcgrana/ring
18:21ibdknoxShreeMulay: http://www.webnoir.org
18:21eskatremand if I want to put several stuff inside my loop its gonna be
18:21eskatrem(for [i (range 2) j (range 3) k (range 4)] (do (stuff1) (stuff2)))
18:22eskatrem?
18:23ShreeMulaychecking out Noir -> I'ven't come across this before (that I remember)...
18:23sleepynateyes, but the return will always be a list of the last result returned from your do
18:23sleepynateerm
18:23ibdknoxShreeMulay: it's built on top of Ring and Compojure
18:24ShreeMulay@ibdknox sweet!
18:24ibdknoxShreeMulay: and should you need any help, I'm the author :)
18:24amalloysleepynate: whoa what, implicit let statement? fors bindings are pretty different from a let
18:25amalloyeskatrem: do not attempt to perform any side effects in a (for); as i said earlier it will just make you sad later
18:25ShreeMulayibdknox: thanks!
18:25eskatremamalloy: yes you said it yersterday, but...
18:25amalloyShreeMulay: there's also http://github.com/flatland/wakeful
18:26amalloyuse a doseq if what you want is side effects
18:26ShreeMulayibdknox: Does it do html5 and support including javascript easily?
18:26eskatremMan, it's hard to get a grisp on clojure, I could do those euler problems so easily in a non functional language, but with clojure ... :'-(
18:27ibdknoxShreeMulay: it's a full service webstack. To my knowledge it can do anything the web can do.
18:27tremoloShreeMulay: I suggest looking into hiccup and ClojureScript also
18:27ibdknoxtremolo: Noir uses hiccup by default :)
18:27amalloyit's hard to imagine an http server that somehow forbade html5 in its output
18:27tremoloidbknox: Ahh, cool. Didn't know that
18:28ibdknoxamalloy: pfft, who wants html5? ;)
18:28ShreeMulayhiccup's cool!
18:29amalloy(defn output [input] (apply str (remove #{\5} input))) ;; first draft of html5 un-support
18:30ibdknoxfor all your retro-web needs! On the roadmap is support the blink tag and doubling your margins in all browsers...
18:30amalloy(assoc-in resp [:headers "Content-Type"] "ISO 8859")
18:30ibdknoxoh man
18:31ibdknoxamalloy: I can't tell you how long I fought with character encoding shit back in the day when we were writing PHP websites
18:31eskatremamalloy: yes, *somehow* I can use def inside a doseq more easily
18:31tremoloidbknox: how about auto generation of "under construction" animated gifs?
18:31amalloyibdknox: i did the same, back in the day when i was working at a php shop
18:32ibdknoxtremolo: I'll accept a patch as long as it actually has a pickaxe in it somewhere. ;)
18:32tremolohaha
18:33amalloyi still get emails from them with "you<big mess>ve got new messages!" or whatever
18:33ibdknoxhahaha
18:34ibdknoxthe worst part about it is we were working on a site that dealt with wines... all those special characters and multiple database formats each with a different encoding...
18:34ibdknoxsuch a disaster
18:34amalloyjeez
18:34ibdknoxthat was my last project with that company ;)
18:36sleepynateamalloy: sorry i know nothing about the inner workings of the for macro... just that it works like a let
18:36eskatremhere is my code for the 4th euler problem: https://gist.github.com/1148056 it works but I'd like to know if my code is "proper clojure" or just some random crap that happens to return a result, can someone have a quick look?
18:36ibdknoxsleepynate: there are lots of things you can do in a for that you can't do in a let
18:36amalloysleepynate: it has the same *structure* as a let (plus some special features like :when)
18:36ibdknoxsleepynate: like :when
18:38sleepynateok
18:38sleepynatei'm coming from clisp :)
18:38amalloyeskatrem: https://gist.github.com/1148071
18:39amalloyany time you find yourself writing (do___) or (def) inside a function, stop and think *really hard* about whether you need to
18:39sleepynateamalloy: juxt is like haskell's flip?
18:39amalloy&((juxt inc dec) 1)
18:39lazybot⇒ [2 0]
18:39amalloy(ie, no)
18:40ordnungswidrigsleepynate: (jux inc dec) => (fn [x] [(inc x) (dec x)])
18:40eskatremamalloy: for the second time your neat code is like a slap in my face
18:40ibdknoxjuxt is awesome
18:40ibdknoxunderutilized I thikn
18:40ibdknoxthink*
18:40amalloyibdknox: i use it enough to average out for everyone
18:40sleepynateordnungswidrig: ahh ok
18:41ibdknoxhaha
18:41ibdknoxoutliers ftw
18:41ShreeMulaywhat about netty vs jetty vs mongrel2? any thoughts anyone?
18:41sleepynateamalloy: so that's largest palindrome you gist'd ?
18:41amalloysleepynate: yeah
18:41sleepynateok cool. thanks
18:41ibdknoxnetty for persistent connections, jetty for anything else, I can't comment on mongrel
18:42amalloyeskatrem: maybe a language thing, but it sounds like you find my code insulting rather than helpful
18:43ibdknoxlol
18:43sleepynatehaha
18:43ordnungswidrig*g*
18:43ibdknoxI think it's a language thing ;)
18:43eskatremamalloy: not at all, I mean: your code is so neat in comparison mine seems stupid, it makes me feel how much I have to learn
18:43ShreeMulayibdknox: would you expand on "persistent connections"?
18:43amalloyk, just checking
18:43eskatremactually I am really admirative
18:44ordnungswidrigeskatrem: just keep practicing. thinking functional is an ongoing journey.
18:44eskatremand, OK, I dont know what juxt is...
18:44ibdknoxShreeMulay: if you need to have websockets or long polling
18:44ibdknoxShreeMulay: where you keep an open socket, you want netty because it's nonblocking io
18:44amalloyeskatrem: well, it's arguable whether juxt makes my code actually more readable; i was going for "short to write"
18:45ibdknoxShreeMulay: Jetty would force you to have a thread for every single connection, which is very limiting
18:45eskatremquick question, do you think I should write a blog about "noob point of view: my discovery of clojure and functional programming"
18:45ibdknoxShreeMulay: Jetty will outperform Netty in normal http traffic though
18:46ordnungswidrigeskatrem: do it.
18:46jamiltroneskatrem: yes please
18:46eskatreminside a for, :let is equivalent to "(let ... " in lisp?
18:46ordnungswidrignext blog will be "semi-noob point of view: how to teach point-free-style from point-less-style"
18:46ShreeMulayibdknox: as I understand it, it would be easy to switch from jettty to netty and vice versa via simple line changes, right? I'm planning on building restful services that would allow mobile apps to access backend data (I thinks)...
18:46sleepynateahh i see. hyperpolyglot says clj's (for) is like scheme's for*/list
18:47eskatremyeah actually it's good, it will force myself not to give up
18:47sleepynateordnungswidrig: ooh, you vicious ;)
18:47ordnungswidrigclojure's for smells like common lipsps loop
18:47ordnungswidrigsleepynate: *g*
18:47sleepynateordnungswidrig: yes and no
18:47eskatremwhat's point-free-style?
18:47amalloyordnungswidrig: yes, it's closest to loop. the difference is that loop is heavily imperative and for is heavily functional
18:47ibdknoxShreeMulay: Ring's abstraction makes that relatively painless, though I've never tried to run noir on top of aleph, it *should* work
18:48ibdknoxShreeMulay: aleph is built on top of netty and provides a generic asynchronous net library
18:48ibdknoxShreeMulay: Noir uses Jetty by default
18:48sleepynateamalloy: yea, my instinct for clisp's "loof for" is control monad
18:48amalloyeskatrem: i advise not to worry about point-free style. it is a siren song to distract people like me from using let statements
18:49amalloysleepynate: i don't know enough haskell to understand that
18:49ShreeMulayibdknox: how do we send these private messages in irc?
18:49sleepynateamalloy: basically what you said
18:49amalloyShreeMulay: /msg ibdknox you're my hero
18:49sleepynateamalloy: and why i say "yes and no" to ordnungswidrig's "code smell" comment
18:52ibdknoxamalloy: lol
18:52ibdknoxoh the boost to the ego
18:52ibdknoxlol
18:53amalloyibdknox: you have to get used to the adulation, with noir and brepl
18:53ibdknoxhaha
18:53ibdknoxamalloy: I'm more excited about Pinot to be honest
18:54ShreeMulaywhat's brepl?
18:55amalloyman, i remember when i was new to clojure, i scoffed at (for...) as pointless sugar over map
18:55amalloynow everything i write has a (for) in it
18:56sleepynate(= __ true)
18:56sleepynatedo it. DO EET!
18:56amalloy(apply > (for [x (range 1000)] (- x)))
18:57amalloy&(apply > (for [x (range 1000)] (- x)))
18:57lazybot⇒ true
18:57ibdknoxShreeMulay: it's a browser connected repl for ClojureScript
18:57sleepynate\o/
18:57amalloy*chuckle*
18:57ShreeMulaydoes aleph require netty?
18:58ibdknoxyes
18:58ShreeMulay:P
19:02amalloyincidentally, what do people think about adding some euler problems to 4clojure? it's a bit tricky because we tell you the answer and ask for code, whereas euler asks for the answer
19:03mdeboardeh.
19:04ibdknoxamalloy: euler problems are much more math-centric I think
19:04eskatremwhat's 4clojure?
19:04mdeboardI agree with ibdknox
19:04ibdknoxeskatrem: http://www.4clojure.com/
19:05amalloyanyway, eskatrem, i think what would help you most at the moment is a mastery of (let) and/or (loop). you're doing all these (def)s in places where they're just evil
19:05eskatremI remember when I was 17 or so I wrote in basic a program to break down a integer into a product of prime numbers. it took me 1 hour, and now I am struggling with the same in clojure
19:06ibdknoxeskatrem: this is a different way of thinking
19:06ibdknoxyou should try 4clojure
19:06eskatremNow I get that a def inside a loop is bad, but I dont see why
19:06amalloyeskatrem: it's a side effect: you're telling the computer *how* to do something instead of *what* to do
19:07eskatremhmmm
19:07eskatremI need to ponder that, amalloy
19:07tufflaxamalloy about adding project euler problems to 4clojure: how would that work exactly? I don't get it
19:08eskatrem4clojure is cool I think
19:09duck1123ibdknox: do you know what it was about pinot that causes the "can't recur here"? Giving it another shot today
19:09ibdknoxan older version of clojurescript has a problem with my macros
19:09amalloytufflax: well, problem 4 could be something like "given a min, max, and filtering function, return the largest palindrome number which satisfies the filter and is a product of two numbers between min and max"
19:10duck1123Ok, cause I re-enabled the middleware again, and that's what I'm getting
19:11eskatremhow long have you guys been programming in functional programming?
19:11amalloyfor example, my gist works out to something like "create the products of all 3-digit numbers, and find me the largest number which satisfies the following criteria", while yours is more like "set i to 0; set j to 0; set tmp to i*j; check if it's a palindrome and is larger than our largest palindrome; if so reset our largest palindrome. now set j to 1...."
19:12ibdknoxduck1123: it's hard for me to reason about your setup
19:12ibdknoxduck1123: one thing to try would be just create a noir project and see if it even works there
19:12ibdknoxif not, it'll be easier for me to figure out why
19:13duck1123I got errors on OSX with that sample project, but it passed after an explicit clean
19:13duck1123Haven't tried it on Ubuntu yet
19:14ibdknoxyeah i had to clean a couple of my projects too
19:14amalloymutability is contagious in that way; because you handle things like (def) yourself, you can't use the built-in (max) to compute the maximum, and instead have to maintain it yourself
19:15tufflaxamalloy so you would try do steer people towards functional programming by modifying the problem just a litte bit?
19:15amalloytufflax: no, it's just there should be multiple test cases, where euler tends to have a single problem and a single answer
19:15tufflaxoh right
19:17eskatrem4clojure is getting hard... and then it becomes so tempting to use the repl
19:17amalloyeskatrem: please, use the repl! it's good for you
19:18eskatremhmm, if the question if (= __ (conj '(2 3 4) 1)), I can just enter to the repl (con '(2 3 4) 1) to see what it produces
19:18amalloyso? you've succeeded, by learning what that form evaluates to
19:18amalloynobody demands that you "figure it out"
19:19jhultenits only cheating if you don't learn anything
19:19amalloy(inc jhulten)
19:19lazybot⟹ 1
19:19eskatremhmm ok
19:19sleepynatejhulten: which is why i scripted a bot in clojure to automatically answer the questions for me :o
19:19sleepynatewait...
19:19sleepynateshit.
19:19duck1123That's one of the nice things about functional programming, it's easy to just run a fn, no heavy objects to set up to get it to run
19:19eskatrem&(conj '(2 3 4) 1)
19:19lazybot⇒ (1 2 3 4)
19:19Raynesamalloy: Integrate try-clojure into 4clojure.
19:19amalloyRaynes: do it yourself, in cljs
19:19ibdknoxlol
19:20jhultensleepynate: If you managed that, you probably solved all the hard ones already.
19:20ibdknoxgood luck :-p
19:20amalloyibdknox: it'll be a breeze with brepl, amirite?
19:20tufflaxHm, I kinda like project euler where they only require an answer. some problems can be done completely by hand, that's one reason. But also sometimes your code is just a mess after you have experimented. I just like that getting the answer is the only thing that matters. But anyway, I don't really see the point of making pe problems into 4c problems unless you really want more problems.
19:20Raynesamalloy: Seriously, it probably wouldn't be that difficult. Might be a good project for Carin.
19:20ibdknoxamalloy: easy as pie. :D
19:20eskatremhmm not cool, the stuff returned bu lazybot makes 4clojure return an error
19:22amalloy##(1 2 3 4) is not the same as ##'(1 2 3 4)
19:22lazybot (1 2 3 4) java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
19:22lazybot (quote (1 2 3 4)) ⇒ (1 2 3 4)
19:23eskatremoh I get it
19:24sleepynate#(..) creates a macro?
19:24tufflaxno a function
19:24eskatremactually I knew the first one but I failed the second one all along, and 4clojure didnt tell me my answer for the first one was right
19:24sleepynatenvm reading :)
19:24amalloyeskatrem: it should turn the light green for each test you pass
19:26eskatremamalloy: the question I was trying to solve (solved now) has two sub questions, when I put the first answer right and the second one wrong it doesnt make the first light green
19:31eskatremis a *set* automatically sorted?
19:31ibdknoxno
19:32eskatrembut a set is not ordered then?
19:32tufflaxno... should it be? :P
19:33tufflaxthere are sorted sets
19:33tufflax,(sorted-set 12 6 1 2)
19:33clojurebot#{1 2 6 12}
19:36eskatrem, (= #{1 2 3} #{3 2 1})
19:36clojurebottrue
19:36amalloyhey, someone woke up clojurebot
19:37eskatremso when clojure compares a set, it doesnt take into account the order
19:37eskatremamalloy (ooops)
19:37amalloyeskatrem: there *is* no order
19:37amalloyi mean, yes, internally they are necessarily stored in some order
19:38amalloybut as an API, sets don't have an order
19:38amalloy&#{3 2 1}
19:38lazybot⇒ #{1 2 3}
19:39eskatremok, so *as a convention* clojure orders a set to show it, but that's all?
19:39amalloyno, it only gets ordered by coincidence
19:39amalloy&(set (range 35))
19:39lazybot⇒ #{0 32 1 33 2 34 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}
19:43amalloyeskatrem: small integers happen to come out sorted, but that's just luck
19:43eskatrem,#{0.3 -1 2.5 0.1}
19:43clojurebot#{-1 0.3 2.5 0.1}
19:44eskatremok, double values are not coming out sorted
19:44Raynes&(sorted-set 3 2 4 1023 30)
19:44lazybot⇒ #{2 3 4 30 1023}
19:45eskatrem,(= (sorted-set 0.3 1.2 0.1) #{0.3 1.2 0.1})
19:45clojurebottrue
20:01eskatremGuys, 4clojure is coool!!
20:01amalloy*laugh* glad you like it
20:01amalloysource is at http://github.com/dbyrne/4clojure if you're interested
20:02eskatremi bookmark that link
20:03eskatrema lady made that! I am impressed
20:05tremoloxb
20:05amalloyeskatrem: new to github? she's the most recent committer, but it's not a one-person project
20:05tremolohah, emacs fail... sorry about that
20:06amalloyhttps://github.com/dbyrne/4clojure/contributors
20:07eskatremsurprising to find two of the top contributors here...
20:09tufflaxit is? :p
20:10eskatremgood work guys, I find myself impressed by my progress
20:11eskatremhere is my code for Nth:
20:11eskatrem(fn [x n] (loop [y x, i 0]
20:11eskatrem (cond (= i n) (first y)
20:11eskatrem :else (recur (rest y) (inc i)))))
20:11eskatrem(ok, I copied it from a sample code amalloy gave me yesterday)
20:12amalloyhey, i didn't write nth for you. now you know how loop works, so you wrote a good implementation of nth
20:13eskatremyeah, but I feel I blantantly copied the loop mechanism from your code
20:13st3fanwhy cond instead of if?
20:13eskatremstill I am proud of my nth
20:13amalloyst3fan: probably because he copied the loop from an example i gave that had three branches :)
20:13eskatremst3fan: because amalloy did so in a code he sent me yesterdasy
20:14st3fan:-)
20:14amalloystealing is a tradition of open source. help yourself to my stuff
20:14st3fanwhere do you live?
20:14eskatremuk
20:14st3fani'll come and pick up your pc ok? :)
20:14tufflaxlol
20:14eskatremgonna go to sleep soon actually
20:15amalloyhar har
20:17amalloyst3fan: when i open-source my computer itself, you'll be the first person i call
20:19st3fanwith your open source phone?
20:20eskatremthat's neat, my count function is timing out...
20:20st3fani have some code too that hangs the thread
20:20st3fanfor no obvious reason
20:21amalloyyour end condition is probably broken, because you're using rest and never seqing the result
20:22eskatrem(fn [x] (loop [y x, i 0]
20:22eskatrem (cond (= y nil) i
20:22eskatrem :else (recur (rest y) (inc i))
20:22eskatrem)))
20:22eskatremthat's my code, I guess (= y nil) must be somehow screwed uo
20:22eskatremup
20:22amalloy&(rest [])
20:22lazybot⇒ ()
20:22amalloy&(= nil ())
20:22lazybot⇒ false
20:23amalloy&(= nil (seq ()))
20:23lazybot⇒ true
20:23eskatremohhh
20:23st3faneskatrem: oh don't but those closing braces there please
20:23st3fanbaaaaaaad style
20:23amalloyst3fan: it's true, but there are only so many things you can focus on at a time
20:23eskatremyou mean, a bunch of closing brackets in the same time is bad?
20:24amalloyi figure he'll eventually see enough code with parens right that he'll figure it out
20:24st3fanok
20:24amalloyeskatrem: just the opposite. a line that contains only closing brackets is bad
20:25eskatremhmm I thought closing brackets where like } in C, in C it's cool to have a line containing }, AFAIK
20:26tufflaxbut, at least as far as i'm concerned, i don't want my code to remind me of c or anything like it
20:26amalloy*chuckle*
20:32eskatremwhen I submit an answer, is my code stored somewhere?
20:39st3fani'm working on a little dsl for web services
20:39st3fanto do APIs very similar to Amazon Web Services
20:41mdeboardeskatrem: no, just whether you solved it or not
20:41eskatremalright, thank you
20:43amalloymdeboard, eskatrem: untrue. we save your most-recent correct solution
20:44eskatremooh, neat
20:44amalloyeskatrem: try going back to a problem you've already solved - your answer is there
20:45sritchieis there some way to catch an exception thrown for an undefined var?
20:46sritchieI'm trying to add a prepend-tasks hook in project.clj for native-deps, but native-deps requires deps to be run first
20:47amalloysritchie: those happen at compile time, don't they? you can't really catch them because they happen before your code runs
20:48amalloyinstead you probably want to do like (when-let [my-var (resolve 'my-var-name)] ...)
20:50sritchieit works with eval, though I'm not sure that's the best form:
20:50sritchie(try (eval `(do (require 'leiningen.native-deps) (append-tasks #'deps leiningen.native-deps/native-deps))))
20:50sritchiewith an appropriate catch statement
20:51amalloysritchie: eval definitely looks wrong. does a resolve-based solution not work?
20:52sritchieamalloy: hmm, had trouble with it before, since I still needed to send the value of the var I obtain into append-tasks
20:53sritchiethough that's probably easy -- I'm blanking on the way to get at a value, given a var
20:53amalloy@
20:53sritchieah
20:53amalloya one-character solution to all your problems - who could ask for more
20:54sritchiehaha, it's quite a panacea
20:54sritchietrying it out now
20:55sritchieyup, all's well… definitely beats eval
20:55sritchieamalloy: thanks a lot
21:03livingstonI wrote a bunch of tests with clojure.test and now realize the work equally well for another set of my code, it seems dumb to cut and paste when the only thing that changes is a *star* variable...
21:03livingstonany good way to reference a set of tests and run them twice in different binding scopes?
21:05eskatremI finished the 1st page of 4clojure. I am going to bed now. thanks everybody!
21:05lucianlivingston: why not factor out a fn that takes that variable as an argument?
21:07livingstonI could seemed odd of even have to repeat the tests if I could help it. then I'd have (deftest foo-test (is (foo A))) in one file and (deftest foo-test (is (foo B))) in another
21:11lucianlivingston: i'd make a (defn is-foo ...) to import in both test files
21:12livingstonlucian: I could imbed the "is" too it doesn't need to be inside deftest?
21:12lucianlivingston: don't really know
21:13livingstonthe problem here is remembering to update both files ... I'll probably just macro around it... just was hoping for something slicker.
21:13lucianlivingston: wouldn't a fn be enough? does it really need a macro?
21:14luciandepends on the context of is i guess
21:14livingstonif I want them to register as a lot of different tests so it's easier to tease out where the failure is. I should look at clojure.test documentation more..
21:15livingstonis doesn't need to be in deftest
21:24technomancylivingston: deftest generates function
21:24technomancy*functions
21:25technomancyif you (deftest my-foo-test) you can just call (my-foo-test) from another test
21:25hiredman~ping
21:25clojurebotPONG!
21:25amalloydeftest is absurdly macro-heavy. an (is) that's not inside a deftest won't work
21:26technomancyamalloy: not actually true
21:26technomancymaybe you're thinking of thrown? outside an is?
21:27technomancybecause that one's annoying
21:28amalloytechnomancy: i don't think you're right. `is` is a symbol that's parsed specially by the deftest macro, not a macro/function that's actually defined
21:28amalloyalso, i just checked and i'm wrong about that
21:28amalloyso never mind, technomancy
21:28technomancy,(ns-resolve (doto 'clojure.test require) 'is)
21:28clojurebot#'clojure.test/is
21:28technomancyyay doto abuse
21:29amalloy$sed technomancy s/abuse/magic
21:29lazybot<technomancy> yay doto magic
21:29technomancyamalloy: thrown? is like that
21:29amalloy*nod*
21:29amalloyi must have gotten them confused in my head somewhere
21:29cemerickBots with sed. I'm going to go stock up on canned goods.
21:30amalloycemerick: is that a sign of the apocalypse?
21:31cemerickamalloy: Close enough for me! :-D
21:33livingstonsorry spaced out for a second...
21:34livingstonI could call all the test from the second file but then I would still have to make sure I keep them synchronized.
21:35amalloy(ns a) (defn run-all-the-damn-tests [] (...)) (ns b (:require a)) (a/run-all-the-damn-tests)
21:35livingstonbasically what I have is two implementation of an API. I'd like to write all the API tests once, and then have both implementations check themselves against it.
21:36livingstonso I found run-tests that allows me to call tests in another namespace... I think I can bind over my *star-var* and then call that, I was just about to test that.
21:36cemerickBugger, nil-safe threading ops should be in core by now.
21:38livingstonideally I'd like the tests defined in the API test-namespace, but not run (how could they there's no implementation there) and then run for each of the implementations.
21:39livingstonpwd
21:39livingston^ wrong window
21:40amalloylivingston: c'mon, correcting it is no fun. you want to give someone a chance to jump in there with "#clojure"
21:40livingstonsorry didn't realize that was protocol
21:40st3fanany compojure experts here? i have troubes getting a basic route to work
21:41amalloy~anyone
21:41clojurebotPlease do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.
21:41livingstonamalloy: lazybot or some bot should have yelled at me.
21:41livingstonlol, like that
21:41st3fani have this route: (GET "/ws" {params :params} (dispatch-action params))) .. i can call it with /ws?action=Foo but params is always an empty map
21:46amalloyst3fan: (a) there's a #compojure room, but i don't know how much traffic it gets; (b) do you have a middleware in place that will parse out the params for you?
21:47st3fanyeah i guess that is what i need
21:48amalloyif you don't have something like wrap-params intervening, nobody's going to put anything in that :params map
21:49amalloyalso (c) i can never remember the compojure syntax for (GET) stuff, so there might be something wrong with your {params :params} binding too
21:52ShreeMulayAnyone around that can help me solve a 4clojure problem? @ http://www.4clojure.com/problem/19#prob-title
21:53ShreeMulayI can't use "last" so I'm at a loss, eh...
21:53jeremyheilerWhat have you tried?
21:53ShreeMulaylast
21:53ShreeMulaythey don't want me using that, though...
21:54ShreeMulayand I really don't know enough, to be able to think of what next to try unfortunately... :(
21:55jeremyheiler$((peek [1 2 3]))
21:56jeremyheilerdamn. what's the clojurebot syntax?
21:56jeremyheilerfor running code
21:56amalloy,
21:56clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
21:56amalloyor & for lazybot
21:57jeremyheiler,((peek [1 2 3]))
21:57clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
21:57livingstondo namespace names with hyphens get munged to underscore too? e.g. does foo.foo-core.bar-code become foo/foo_core/bar_code.clj ?
21:57amalloyShreeMulay: the point is to reimplement last yourself
21:57jeremyheiler,(peek [1 2 3])
21:57clojurebot3
21:57amalloylivingston: yes
21:57amalloybecause they're java package names
21:58jeremyheilerShree: As you can see, peeking on a vector gives you last
21:58livingstonamalloy: thanks. great, time to mess with what in subversion...
21:58jeremyheilerhowever
21:58jeremyheiler,(peek '(1 2 3))
21:58clojurebot1
21:58jeremyheilerThe same thing on a list doesn't work
21:58jeremyheilerthis is because lists are designed for adding/removing from the front, where vectors were designed for adding/removing from the back.
21:58jeremyheilerPlay with that thought for a bit
22:00jeremyheiler,(peek (vec '(1 2 3)))
22:00clojurebot3
22:00jeremyheilerIt's not good code, but it works
22:01amalloymeh. i'd classify that more as a "trick" than a solution to the problem - being able to implement `last` yourself is valuable
22:01amalloynot that i'm against tricks
22:01jeremyheilerYes, I agree
22:02jeremyheilerI was more-or-less playing golf with 4clojure lol
22:02ruggeriAny advice for newbies on defrecord? It's a shame print-dup doesn't produce something that can be you can call read-string on.
22:03ruggeriThere's this defrecord2 guy
22:03amalloyruggeri: it does in 1.3
22:03ruggeriOh snap
22:03ruggeriThanks; will check it out now
22:03amalloyjeremyheiler: the shortest solution for problem 19 is 8 characters long, and it's hysterical. any guesses?
22:05cemerickEveryone just uses snapshots, alphas, and betas anyway; Clojure should follow the path of chrome, version up to Ω-SNAPSHOT, and everyone can just ride HEAD. :-P
22:06jeremyheilerhmmm
22:07ruggeriyeah, records being second-class was about to super-depress me
22:07amalloyruggeri: that said, "newbie" and "record" don't belong in the same sentence
22:08amalloythey're an advanced feature, however appealing they look when you're coming from an OOP background
22:08ruggeriwhy do you say so? I want to implement me some multimethods
22:08amalloyruggeri: so write some multimethods; you don't need protocols for that
22:08amalloy(or records)
22:08ruggeribut what's my dispatch function? I would call something like class or type, right?
22:09cemerickrecords are a proper replacement of structs, which are reasonable for any "level" of usage, IMO.
22:09ShreeMulaypeek is interesting - but can't figure out how to "reimplement last" cause, I frankly don't know enough clojure - haven't used it enough...
22:09amalloy(defmulti pluralize count) (defmethod pluralize 1 [objs] (str "1 thing: " (first objs)))
22:10amalloy(defmulti pluralize 0 [_] "No things at all!") ;;etc
22:11ruggeriFair enough; but what if I have two different dog objects, and they bark differently?
22:11ShreeMulaypeek works for the vector... somehow, I've got to create a function... Is "peek" gonna' be part of the function I need to put together, guys?
22:11ShreeMulayon problem #19?
22:12jeremyheilerIt's not
22:12ruggeriI want (bark big-dog) ; -> growl
22:12ruggeri(bark lil-dog) ; -> yip-yip
22:12jeremyheilerShreeMulay: Look up how to use recur
22:13amalloyruggeri: *shrug* you can make a record for that, and define a protocol for barking. or you can use a plain map, and a dispatch function that looks up the :kind-of-dog key in the map. or you can do any number of things
22:13jeremyheileramalloy: I give lol
22:13amalloyjeremyheiler: rand-nth, and hitting the submit button ~40 times
22:14jeremyheilerhahaha
22:16ruggeriamalloy: yeah, definitely could manage a canonical mapping of dogs to bark behaviors
22:16st3fanhmm Clojure in Action has an compojure example that import compojure using (ns foo (:use compojure)) but when I try that I get an import error
22:17ruggeriamalloy: I'll start there; it'd be a pain for one-place to centralize every type of dog in existence for a huge project, but good idea to keep things simple maybe
22:17amalloyi think that the concept of "but someday i might have a thousand different kinds of dogs!" is overemphasized in OO code
22:18ruggeriamalloy: I hear you; makes sense
22:18amalloyi'm a fan of splitting things up when they need to be; i'm addicted to defmulti and i write protocols when they make sense
22:18amalloybut they're not the sorts of things that give you a feel for how the language is different from (say) java
22:19amalloydo some sequence manipulation, recursion, and function composition. those are things that you don't get much of in java
22:19livingstonamalloy: I think that the concept that everything needs a class is over emphasized, why have one function and some configuration when you could have the land of 1000 classes
22:20amalloyanyway, i'm headed home. ta-ta
22:20ruggeriamalloy: night
22:20livingstonlater
22:21jeremyheilerlater
22:24ShreeMulayKILL
22:24ShreeMulayQUIT
22:42pcavshow do people do reading files from the classpath?
22:49technomancypcavs: clojure.java.io/resource
22:49pcavstechnomancy: thanks
22:50technomancysure
22:55st3fanis there a better way to update nested maps than nested assoc calls?
22:58cemerickst3fan: assoc-in and update-in
22:58st3fanthanks
23:00st3fanoh assoc-in is nice
23:04cemerickst3fan: they work with any 'associative' as well…not just maps
23:04cemerick,(update-in [5 6 {:a [\b \c \d]} 7] [2 :a 1] str)
23:04clojurebot[5 6 {:a [\b "c" \d]} 7]
23:08st3fanyeah very cool
23:08st3fanhow do i test if a condition is true for each element in a vector?
23:09amalloy&(doc every?)
23:09lazybot⇒ "([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."
23:09st3fanargh i was looking for each? :-/
23:13livingstonstupid question, what's fncall in clojure ie. I have a list of functions I just want to map through them and call them.
23:13livingston(map (fn [x] (x)) functions) seems dumb
23:13amalloy$findfn even? [2 4 6] true
23:13lazybot[clojure.core/not= clojure.core/some clojure.core/distinct? clojure.core/every?]
23:13amalloylivingston: (
23:13amalloyoh, i see
23:14amalloyyes, i wish invoke would make it into core also. it doesn't really exist
23:14livingstonso there's nothing?
23:14amalloylivingston: fwiw, #(%) is the shortest way to write it :P
23:15livingstonI really despise that % syntax, I find it lending itself to too much confusion
23:15amalloybut (fn [f & args] (apply f args)) is a useful thing to have defined somewhere. i call it invoke because of IFn.invoke, but i guess funcall is more traditional
23:16amalloyst3fan: you caught the use of $findfn for your benefit, right?
23:16livingstonI don't need apply, they are thunks, with no arguments
23:17livingstonin common-lisp is LISP2 so you need a fncall there was no (foo) to call the function in foo like you can in LISP1
23:18livingstonis there anyway to deftest in a namespace but not have it called with clojure:test and only have the functions there to call with another namespace?
23:19amalloylivingston: i'm aware. if you look at it, you'll see i just wrote funcall
23:20amalloy&(let [funcall (fn [f & args] (apply f args))] [(funcall +) (funcall + 1 2)])
23:20lazybot⇒ [0 3]
23:20amalloyie, it works for thunks or with args
23:21cemerickJust adding a single-arg arity to apply would be equivalent, no?
23:22amalloycemerick: not equivalent to my definition, no, because (apply + 1 2) wouldn't work
23:22amalloyperhaps equivalent to what livingston needs at the moment
23:22livingstonyeah. it's equivalent, except for the list cons-ing
23:24livingston... all this work just to call some tests twice *sigh* 4 hours in...
23:28amalloyhey livingston, can you point me at some public, preferably not-totally-trivial code you've written? i had the idea recently to look at how ye olde lispers write clojure
23:29livingstonum, hum I don't know that I have any - but I am in the process of preparing a large library of code for dealing with RDF.
23:31livingstonamalloy: I'm not exactly an old lisper but I was trained by them and programmed my entire dissertation in it.
23:32livingstonthe biggest thing that's kicking me in the pants is dynamic not lexical scope. there are a ton of cool tricks with lexical scope that get fubared by lazy-list / deferred evaluation in dynamic scope
23:34amalloylivingston: CL has the same scope rules as clojure, doesn't it? it's just that clojure has a lot more lazy bits
23:35cemerickHow is the CL world doing these days in general? Anyone keep tabs on it?
23:35livingstonamalloy: no dynamic vs. lexical scope for special variables that can be bound ove is a huge difference
23:35livingstoncemerick: it's fine. AI people still use it as always.
23:35amalloylivingston: but clojure's lexical variables are the same as CL's, and clojure's vars are the same as CL's specials, i thought
23:35livingstonevery time you buy a plane ticket there's lisp under the hood ;)
23:36cemerickyeah, but every time I swipe my credit card, an AS/400 gets its wings. Not really a good barometer, perhaps. :-)
23:36cemerickI wonder about its vector more than anything else. Growing, shrinking, etc.
23:36cemerickI would think that the heat around Clojure and other FPLs must help.
23:37amalloycemerick: functional? CL isn't exactly functional
23:37livingstonlol
23:38livingstonCL is plenty functional when coded well, although there are the people that call it hybrid or whatever.
23:38cemerickExactly, no — but before state was a big concern, Lisps were always considered functional in the functions-are-first-class-values sense.
23:40amalloyi was just reading that in let-over-lambda, actually
23:40cemerickThis floated by in the transom a few days ago; I'm not sure whether to interpret the results as positive or negative overall, tho. http://www.indiegogo.com/SBCL-Threading-Improvements-1
23:42livingstonyou have to remember that CL was standardized before file-systems/sockets/threads had any major standardization, consequently those things have been ideosyncratic in lisps
23:42dnolencemerick: why negative?
23:43livingstonbut there are generally libraries that will present a layer over your specific implementation
23:43cemericklivingston: Right, I'm mostly looking at community participation / size / engagement / commitment.
23:44livingstondepends on what's necessary for you to define a community.
23:44cemerickdnolen: I can see it both ways. (a) it's clearly a vital community ready to step up and support key contributions with hard cash vs. (b) The premier open source CL impl can garner "only" $9K to solve probably its most long-standing and most-griped-about problem?
23:45grant_man, how do you debug errors that have no source code line?
23:45grant_any tips or tricks aside from weeping and gnashing your teeth?
23:46dnolengrant_: what dev environment?
23:46grant_emacs, swank, clojure 1.3beta (i updated to see if it would make a difference... it didnt :( )
23:46livingstonsymbolic AI guys like it. (and I'm one) do I care that few games, websites, or mcdonalds ordering systems are written in it, not really. frankly if those guys all had their way everything would look like java, and we know what kind of fun that is ;)
23:46dnolengrant_: are you evaling fn's one at time or the whole file?
23:46grant_whole file
23:46grant_i stepped through evalling each one and they all evalled fine
23:47dnolengrant_: what is the exception?
23:47cemericklivingston: Willingness to lay out cash seems like a pretty unassailable metric of engagement. Fundraisers like that are one manifestation, another might be attendance figures at yearly confs, etc.
23:47amalloygrant_: that's not a whole file at once; that's one-at-a-time, over-and-over
23:47grant_clojure.lang.Cons cannot be cast to clojure.lang.IFn
23:47grant_i'm saying i did both that and whole-file evaluation
23:47amalloyokay
23:47dnolen&((cons 1 nil) 1)
23:47lazybotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
23:47livingstonSBCL is a popular open source lisp true. But Franz makes the Allegro compiler and they are doing quite nicely as a company.
23:48dnolen&((cons 1 ()) 1)
23:48lazybotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IFn
23:48dnolengrant_: ^
23:48grant_right
23:48grant_so i should be on the loop out for extra parens
23:48livingstonwith their lisp they created AllegroGraph which is as a far as I know one of the best of breed triple/quad stores (RDF/OWL etc.)
23:48amalloygrant_: or something quoted where it shouldn't be
23:49grant_but is there is a faster way to narrow this down besides manual inspection?
23:49amalloygrant_: read the stacktrace to see which of your functions are in it
23:49cemericklivingston: right — maybe all the real users of CL in industry are on Allegro and Lispworks. If they released sales figures, that'd make these sorts of judgements a lot easier… ;-)
23:49dnolengrant_: if there's no source line after C-c C-k it's happening during compilation so very certain to be a syntax error.
23:49amalloyand see if there are any clojure.lang.Compiler methods - if so it's a problem with macroexpansion
23:49grant_a syntax error??
23:49cemerickThe fellow who wrote AllegroGraph lives a few miles from me. Very nice guy.
23:50grant_my only function appearing in the trace is my top-level main fn
23:50grant_oh yeah, i do see a Compiler method
23:51livingstoncemerick: I think there are several "fellows" including the CEO of Franz who work on it.
23:51pcavshas anyone played around with noir?
23:52livingstoncemerick: the people that use Franz lay out cash, the licenses are not cheap.
23:52amalloy&(let 1 2)
23:52lazybotjava.lang.IllegalArgumentException: let requires a vector for its binding
23:52cemericklivingston: IIRC, he was the tech lead, anyway. *shrug*
23:52amalloythat one would be at compile-time as well
23:52cemerickmemory fades, too :-P
23:52livingstoncemerick: he's a nice guy too, John, right?
23:54cemericklivingston: Gary King is the one I know.
23:54cemerickMan, it's been a while since I talked to him, too. :-(
23:54livingstonalso a nice guy, I've worked with him some too.
23:56grant_amalloy, dnolen: thanks guys, that helped!
23:56dnolengrant_: what was it?