#clojure log - Mar 28 2010

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:27 bmason: DeusExPikachu: I don't think so... what would you want to configure that wouldn't be project specific?

0:29 DeusExPikachu: bmason, I want to use a different repository for all dependencies

0:29 as an example

0:29 s/dependencies/projects

0:29 including leiningen

0:30 bmason: do you have a lot of projects?

0:30 DeusExPikachu: the network has limited access to the outside world, would be better if I could create a repo on the intranet

0:31 bmason: one thing you can probably do... since the project file is just clojure code, you could probably reference a master file that contained a definition for your desired data structures

0:31 DeusExPikachu: doesn't even matter if I have a lot of projects, cause even using existing projects can pull in a lot of jars

0:31 bmason: gotcha

0:32 DeusExPikachu: I'm thinking actually just having a local fork of leiningen

0:32 bmason: yeah that's possible

0:32 DeusExPikachu: the code is really simple

0:32 <800 lines

0:33 bmason: hehe gotta love clojure

0:33 if you don't have a lot of projects though, why not just edit all the project.clj files to point where you want?

0:34 talios: DeusExPikachu: sounds like you want to run something like http://nexus.sonatype.org - Nexus is a repository manager

0:34 DeusExPikachu: bmason, many of those projects are not mine, and are managed by git

0:34 talios: caches upstream repos, use it locally

0:34 DeusExPikachu: talios, the repo needs to be private cause it has private code

0:35 bmason: ah I see... but you control the installation of leiningen

0:35 so you want to change its behavior

0:35 DeusExPikachu: bmason, right, many people will be using whatever version of leiningen I have up

0:35 talios: DeusExPikachu: yep - you dont need to make your instance of nexus public tho - have it preseeded with the outside world now and then then lock it down

0:36 DeusExPikachu: talios, that's true, similar to github

0:36 talios: I know maven has a setting to say "use this mirror" which I point to $work's nexus install, I assume leiningen has some form of mirror support as well

0:36 i hope

0:36 DeusExPikachu: yep, altho github is source, not released artifacts

0:37 and github isn't running on your network - unless you pay the big $$$

0:37 bmason: something else to consider...

0:37 you could set up a proxy that caches the packages

0:37 DeusExPikachu: talios, oh I was thinking nexus was a service

0:37 bmason: you can do this at a networking level and never have to mess with any of the software

0:38 talios: bmason: thats effectiely what nexus is/does - a proxy cache, but with intelligence/searching ( and you can deploy to as well )

0:38 DeusExPikachu: I have very limited control over what happens on the server

0:38 talios: but yeh - just set up a squid proxy

0:38 bmason: ah, I gotcha :)

0:38 talios: you'd just need to preseed the proxy/cache with upstream/required deps

0:38 DeusExPikachu: basically I got ssh access and thats it

0:38 every other port is blocked

0:39 I know maven supports sftp though

0:42 bmason: Impressive: http://nexus.sonatype.org/allyourartifacts.png

0:43 talios: that. is. cheesey.

0:45 bmason: from their FAQ

0:45 I thought it was funny :)

0:45 talios: indeed.

0:46 bmason: beats reading MSDN

0:46 talios: heh - and here I was thinking I sad to have to download 6gig of MIX10 videos!

0:46 ok, maybe I am. esp. as a java/clojure guy

0:47 alexyk: technomancy: is it still not possible to specify which version of clojure to run lein repl with?

0:48 bmason: MIX10?

0:48 talios: bmason: http://www.microsoft.com/events/mix/ - Microsoft developer conference that was on the other week

0:49 bmason: gotcha

0:49 yeah... I just can't get excited about silverlight

0:50 and a web conference sponsored by microsoft? seems kinda doomed

0:50 talios: bmason: theres actually some good sessions there, on jquery, and web security (shock to see that from MS!)

0:50 bmason: hmm

0:51 jquery is nice... I might be interested in that one

0:51 the more I'm reading about RESTful design though the more I really see things going that way

0:51 talios: AJAX != REST tho

0:51 bmason: and REST doesn't really seem to be a part of Microsoft's vision at all

0:51 right :)

0:52 talios: and sadly, the more I see of peoples REST APIs they more I see them failing

0:52 bmason: any particular reason?

0:52 * talios is currently working on a 'proof of concept' HATEOAS example in clojure

0:52 bmason: so am I

0:52 talios: oh really?

0:52 bmason: yeah

0:53 I just picked up a book that was released like 2 weeks ago...

0:53 here, I'll find a link

0:53 talios: rest cookbook?

0:53 bmason: yup

0:53 talios: need to get a copy of that

0:53 bmason: Subbu something

0:54 here we go: http://www.amazon.com/RESTful-Web-Services-Cookbook-Scalability/dp/0596801688/ref=sr_1_1?ie=UTF8&s=books&qid=1269751923&sr=8-1

0:54 * talios commits and pushes his code - mmm, need to update the README to the actual API

0:54 talios: http://github.com/talios/wellrested is my REST sandbox project

0:54 bmason: I was reading an article he wrote on infoq, I liked his explanation of HATEOAS

0:55 * talios needs to update the README and actually clean up some of that nasty, nasty, hack code ;)

0:55 bmason: haha

0:55 talios: it's still at the "lets explore what I want to do, API wise", now I need to clean it up

0:55 bmason: yeah, me too

0:56 talios: http://github.com/talios/wellrested/blob/master/src/main/clojure/com/theoryinpractise/wellrested/webapp.clj is the main code

0:56 bmason: I've been working on some multimethods to convert my resources to different formats

0:56 talios: cool

0:56 bmason: currently I'm defining my resources in XML and I can convert that to HTML based on the user agent

0:57 which is nice... I can hit my URL in a web browser and get a list of properties and links for a given resource

0:57 talios: cool

0:57 bmason: all formatted in an HTML table, with links to the document types and such

0:57 which in theory would work :)

0:58 talios: assuming you have something which can render your media types

0:58 bmason: meaning?

0:59 the resources themselves are defined pretty generally... and I don't plan to include pictures and video or other content types directly

0:59 talios: What's the content type of the resources you return? text/xml?

0:59 bmason: those would just be links

1:00 talios: The problem I've found with 99% of all REST frameworks is they lead you down the path of returning "application/json" or "test/xml" - which is just broken.

1:00 or accepting those

1:00 bmason: what's the broken part?

1:00 having a custom format or having a single format?

1:02 talios: the media type - if you have a resource say accepts a POST of "application/json" you have no idea what you can post to it, but it accepts "application/bmason-customer+json", you know that you can only post a document of that media type

1:02 other wise you could post {} [], which is valid JSON, but probably invalid data for your service ):

1:02 bmason: sure

1:03 talios: Similarly, if you receive content of "application/json" all you know is you have JSON, with no idea of how to render it

1:03 bmason: so the REST API's you've seen don't include custom definitions of their doc types?

1:03 talios: unless the client upfront 'knows' that it requested something specific, and got it

1:04 some do, but they also have documentation saying "to do XXX, POST to /foo/service/xhandler" - which is wrong. As that should be discoverable at runtime

1:04 bmason: right

1:05 talios: they seem to do either one side or the other right, but not both.

1:05 bmason: yeah, there's some basic principles that need to be followed in order to have a well defined contract with your clients :)

1:05 talios: And that defined contract is the media types, and link semantics

1:05 bmason: with a HATEOAS API you're essentially making the work flow a part of that contract

1:06 and it's imperative to define your document types as well

1:07 talios: *nod* whereas things like JAX-RS seem more about mount paths, and generic serialization of your objects to application/json

1:07 if they made it part of the contract that you had to define a custom media type, that would be helpful

1:07 bmason: yeah... really doesn't help

1:07 * talios makes room on his high horse for bmason

1:07 bmason: at some point the programmer has to know how to parse that

1:08 lol

1:08 oh I think the REST principles are wonderful

1:08 it's called not reinventing the wheel

1:08 talios: that being said - our REST API at work is still more at HTTP level 1

1:09 but we're evolving that

1:09 bmason: well, I work at a Microsoft shop

1:09 so my coworkers mostly think I'm crazy

1:09 all those open source shenanigans are doomed to failure, right?

1:09 talios: have you seen this table: http://nordsc.com/ext/classification_of_http_based_apis.html

1:10 bmason: thank you sir!

1:10 I had not

1:10 talios: was made up about 2-3 weeks ago

1:11 bmason: that... may be useful for convincing others

1:11 talios: You might find the http://tech.groups.yahoo.com/group/rest-discuss/ list a good read too

1:12 bmason: yeah I think I've found some of Subbu's posts on there

1:12 http://www.infoq.com/articles/subbu-allamaraju-rest

1:12 that's the article I read that really enlightened me about REST

1:13 talios: don't think i'ver seen that link yet :) cheers - it's an old one too

1:13 bmason: very clear explanations... when I saw he'd written a book I did not hesitate to buy :)

1:13 glogic: whoa

1:14 bmason: words immortalized by Neo

1:14 glogic: 203 nicks

1:14 i had no idea clojure was this popular

1:14 * talios runs off for a short bike ride before it gets dark

1:15 bmason: cya talios

1:15 nice talking!

1:15 glogic: i don't get it, is clojure supposed to be more CL or more scheme, it seems more like some ohter language than a lisp

1:15 talios: seeya - talk again sometime

1:15 _ato: glogic: neither, it is its own lisp

1:15 talios: I'd probably say its neither

1:15 bmason: clojure is functional programming made practical and approachable

1:16 talios: bmason: that sounds like a politically correct response :)

1:16 glogic: bmason: that sums it up though

1:16 talios: no i can start there tha'ts good

1:16 so what is it about clojure you like

1:16 i know that's general

1:16 i'm just curious

1:16 bmason: well I was trying to get into FP for some time

1:16 I tried Haskell and found it really arcane

1:17 glogic: i tried it recently and i didn't quiet get it i tried defun def define and never got anything defined only to find out like an hour later you have some custom syntax for what looks like a lambda

1:17 bmason: there's some big advantages to FP, and I really wanted to take part in that

1:17 glogic: bmason: haskell gah

1:17 bmason: i agree, i was just wondering what made clojure attractive

1:18 bmason: when a friend told me about Clojure I tried it out and was just amazed by how easy it was to pick up and how elegant the solutions were

1:18 glogic: the community seems to have grown very rapidly

1:18 bmason: consider the select syntax: (select predicate dataset)

1:19 you have simplicity, and flexibility

1:19 glogic: (select string? '("hang" on))

1:19 ?

1:20 bmason: (select string? #{"hang" :on})

1:20 glogic: hey what's the deal with this (def sym [arg1...argn+1] ...)

1:20 talios: ,(select string? #{"hang" :on})

1:20 clojurebot: java.lang.RuntimeException: java.lang.ClassCastException: clojure.core$string_QMARK___4262 cannot be cast to java.lang.Number

1:20 glogic: doh

1:20 talios: interesting

1:20 bmason: doh!

1:20 glogic: so what' this mean #{} syntactically

1:20 talios: set

1:21 glogic: so i'm assuming #{"hang" :on :on} is not valid?

1:21 _mst: ,(clojure.set/select string? #{"hang" :on})

1:21 clojurebot: #{"hang"}

1:21 glogic: oh damit i could have done #{"halcyon" :on :on}

1:21 bmason: ,(#{:foo :bar :baz} :foo)

1:21 clojurebot: :foo

1:21 _ato: ,select

1:21 clojurebot: #<finite_distributions$fn__6788$select__6817 clojure.contrib.probabilities.finite_distributions$fn__6788$select__6817@520fa4>

1:22 bmason: ,(#{:foo :bar :baz} :bam)

1:22 clojurebot: nil

1:22 _ato: heh, different select is imported into the bot's namespace

1:22 glogic: oh damit i could have done ,#{"halcyon" :on :on}

1:22 talios: doh

1:22 glogic: ,#{"halcyon" :on :on}

1:22 clojurebot: #{"halcyon" :on}

1:22 bmason: oh, that explains some things

1:22 glogic: oh neat

1:22 nice tha'ts what i'd expect

1:22 ,#{"halcyon" :on :on :on}

1:22 clojurebot: #{"halcyon" :on}

1:22 glogic: oh hot

1:22 _ato: haha

1:22 glogic: tha'ts a bit of magic isn't it

1:23 bmason: so... anyway

1:23 * talios <3 clojurebot

1:23 talios: anyway - off for a bit

1:23 bmason: Stuart Holloway's book uses an example of sets where each item is a hash

1:23 glogic: btw wha'ts lambda

1:23 bmason: so you're basically dealing with a table structure at that point

1:23 glogic: 'lambda

1:23 ?

1:23 _ato: ,((fn [x] x) 2)

1:23 clojurebot: 2

1:24 bmason: and the select works like you'd expect it to in SQL

1:24 glogic: wha'ts fn?

1:24 _ato: lambda

1:24 bmason: except your WHERE clause is the predicate

1:24 glogic: hrrm

1:24 bmason: lambda calculus is the branch of math that functional programming is based on

1:24 glogic: ,(def thing fn [x] x)

1:24 clojurebot: DENIED

1:24 glogic: (define thing (lambda (x) x))

1:25 bmason: it's different from the Von Neuman architecture that almost all computer hardware today is based on

1:25 _ato: (def thing (fn [x] x))

1:25 bmason: (and most programming for that matter)

1:25 _ato: or (defn thing [x] x)

1:25 but the bot won't let you do define stuff

1:25 bmason: that may be more general than you were asking for though :)

1:27 glogic: ,(set! xx (fn [] fn))

1:27 clojurebot: java.lang.Exception: Unable to resolve symbol: xx in this context

1:27 glogic: ok wow tha'ts implemented well

1:29 bmason: also that would be (def thing (fn [x] x))

1:29 oh sorry

1:29 chat wasn't scrolling :)

1:30 glogic: bmason: i was testing to see if xx has to exist before set! was called

1:30 bmason: and it does

1:31 _ato: ,(set! inc dec)

1:31 clojurebot: java.lang.IllegalStateException: Can't change/establish root binding of: inc with set

1:31 _ato: set! in fact only works on thread-local vars

1:31 glogic: _ato: so i just can't set lambda

1:32 _ato: yeah, and since fn is macro you'd have to actually define a lambda macro

1:32 glogic: wow

1:32 so basicaly i won't be crashing clojurebot today

1:33 at least not like that lol

1:33 _ato: heh, yeah clojurebot is battle-tested in that regard

1:33 glogic: hah

1:33 i know somoene who can make it go boomo

1:33 _ato: it's been sitting in the channel for a couple years taking all the abuse we throw at it ;-)

1:34 talios: ,(System/exit 0)

1:34 clojurebot: java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.0)

1:34 talios: :)

1:34 glogic: ok so

1:34 clojure is this very strange dialect of lisp that everyone seems to be ridiciulously engrossed in

1:34 and apparently quite the phenomena

1:35 bmason: glogic: what got you interested?

1:35 glogic: boredom mostly

1:35 spent a month on prolog

1:35 spent an hour on python before i wanted to throw the computer through the window

1:36 bmason: oh?

1:36 glogic: i swear that language si some kind of sick joke

1:36 bmason: I never got into python either... we had to do some python for a physics class

1:36 glogic: intended to destroy the hands of bad typists

1:36 bmason: yeah, I'm not fond of whitespace based syntax

1:37 if that's what you're referring to :)

1:37 glogic: y

1:37 yes

1:37 bmason: lisp syntax looked really arcane to me at first, but the benefits became quickly apparent

1:38 and paredit mode in emacs makes it a breeze

1:38 glogic: lack of syntax is where it's at

1:38 bmason: yup yup

1:38 glogic: and clearly everyone in here agrees or you wouldn't have spent all this time on a new dialect of lisp

1:38 bmason: throw the eccentricities out

1:38 let's get down to data structures

1:38 glogic: well you half agree

1:38 since i've seen intense amounts of syntactic sugaring

1:38 bmason: :-D

1:39 clojure looks a lot prettier than most CL I've seen

1:40 and I think that's part of what makes it approachable to the non-lisp community

1:40 glogic: yeah

1:41 i realized that most humans actually require a certain level of complexity, it's like, having more to grab on to helps somehow

1:41 it's very very strange people that don't

1:41 hang out in #porlog you'll see what i mean

1:42 #prolog* even

1:42 bmason: yeah, I think in particular giving different syntax to the types of collections was a really good step

1:44 the reader macros are nice, but the collection types being immediately noticeable is far more important IMO

1:44 that gives the code a sense of character

1:45 anyhow, I'm gonna call it a night

1:45 glogic: same

1:45 thx

1:45 bmason: enjoy your clojure :)

1:45 likewise

1:48 defn: ,:a#

1:48 clojurebot: :a#

1:48 defn: is that a valid map key?

1:49 ,{:a# 128}

1:49 clojurebot: {:a# 128}

1:49 defn: i mean -- is there any reason not to use it?

1:49 _ato: it's similar to autogensym, but should be okay as its keyword not a symbol, I guss

1:50 defn: okay cool -- it's nice to be able to use something that looks like a sharp when doing music stuff

1:57 how does one take (1 2 3 4), and create a map where the values are [a b c d], like: {a 1 b 2 c 3 d 4}

1:57 err rather "where the keys are [a b c d]"

1:58 _ato: ,(zipmap [:a :b :c :d] (iter inc 0))

1:58 clojurebot: java.lang.Exception: Unable to resolve symbol: iter in this context

1:58 _ato: ,(zipmap [:a :b :c :d] (iterate inc 0))

1:58 clojurebot: {:d 3, :c 2, :b 1, :a 0}

1:58 defn: ah yes, zipmap

1:59 thanks _ato

2:06 _ato: one more for you -- how do you create an infinite repeated vector from a single vector, like [1 2 3 4] => [1 2 3 4 1 2 3 4 1 2 3 4]

2:07 _ato: cycle

2:07 ,(take 10 (cycle [1 2 3 4]))

2:07 clojurebot: (1 2 3 4 1 2 3 4 1 2)

2:07 defn: haha, agh!

2:07 how do you remember all of these

2:07 i havent used cycle in so long... i need to do some more project euler

2:08 _ato: dunno how I remember them, guess I've just used them enough that they've stuck ;-)

2:10 defn: ,(let [keys (cycle [:a :a# :b :c])] (zipmap keys (range 3 13)))

2:10 clojurebot: {:c 10, :b 9, :a# 12, :a 11}

2:14 defn: ,(let [keys (cycle [:a :a# :b :c])] (zipmap keys (range 21 109)))

2:14 clojurebot: {:c 108, :b 107, :a# 106, :a 105}

2:14 defn: hm, why does that happen i wonder

2:19 _ato: ,(zipmap [:a :b :c] [1 2 3 4])

2:19 clojurebot: {:c 3, :b 2, :a 1}

2:19 _ato: ,(zipmap [:a :b :c] (range 21 109))

2:19 clojurebot: {:c 23, :b 22, :a 21}

2:20 _ato: oh right

2:20 you cycled the keys

2:20 so its going to pick up the last values

2:20 ,(zipmap [:a :a :a] [1 2 3])

2:20 clojurebot: {:a 3}

2:23 defn: _ato: i was originally thinking repeatedly take (count [x y z]) [x y z]

2:23 but that gave me ([x y z] [x y z]) so i needed a flatten which just seems wrong

2:27 talios: 'lo defn

2:31 defn: hi talios

2:32 talios: how goes the hacking?

2:34 talios: not so much code hacking today, been playing with vagrant/chef foo :) and found a bug in the clojure/maven plugin :(

2:42 vIkSiT: hello all

2:43 could anyone point me to some docs about AOT compilation?

2:43 something that talks about steps involved - I'm trying to figure out a higher level picture than just (compile 'class.name.lib)

2:43 (for instance - paths)

2:43 defn: http://www.youtube.com/watch?v=UVbwRAtzyDU

2:43 woops wrong window -- sorry

2:44 talios: finding bugs is never any fun :)

2:44 talios: defn: esp. ones you thought you'd fixed :(

2:45 defn: aww :(

2:45 talios: thankfully I've been lazy and never really made a big announcement of that last release :)

2:46 vIkSiT: how higher level than http://clojure.org/compilation do you want?

2:47 vIkSiT: talios, well - I've got the sample program. now - where does one enter the (compile 'class) statement?

2:47 and which paths is it with respect to?

2:48 talios: you'd enter the (compile...) commands in the REPL. and it writes the .class files to the directory you mention in the system property when you start that REPL

2:49 I never liked the "compile from the REPL" thing tho, which is what led to the maven plugin ( and I guess leiningen )

2:49 vIkSiT: aah I see

2:49 talios: http://zef.me/2470/building-clojure-projects-with-leiningen is a good intro to lein

2:49 vIkSiT: well yes, I was just trying the REPL compilation. But no matter what I do, it doesn't find the clj path on the CP

2:50 yes I'm familiar with lein. I guess I was trying to do the equivalent of "javac foo.java; java foo" without resolving to build systems

2:50 talios: right.

2:50 how are you starting the repl?

2:51 vIkSiT: using the clj script from http://mark.reid.name/sap/setting-up-clojure.html

2:52 * talios looks

2:53 talios: mmm, looks like that'll look for .clj files in your current directory

2:53 vIkSiT: yes, it also supports the .clojure file in the dir to add classpaths

2:54 so I added /long/path/to/hello.clj to .clojure, and I run the repl using clj

2:54 and end up with a java IO exception

2:54 (on compile)

2:55 _ato: try adding /long/path/to/ to .clojure instead of /long/path/to/hello.clj

2:56 talios: you wouldn't mention a .clj file in .clojure tho, as thats classpath's, if hello.clj was in the "hello" namespace, you'd add /long/path/to

2:56 bah, like _ato just said :)

2:56 _ato: classpath should consist of directories and jars, not individual source files

2:56 vIkSiT: oh right. let me check

2:59 hmm now my setup looks like this:

2:59 http://paste.lisp.org/display/96978

2:59 I call clj from /dir1

2:59 er that should be /dir1* in .clojure in the paste

2:59 talios: since your NS is clojure.examples.hello

3:00 vIkSiT: right?

3:00 talios: since your NS is clojure.examples.hello you'd want to have just /dir1 in .clojure

3:00 vIkSiT: I've tried that as well.

3:00 talios: as it takes the the NS, replaces the .'s for path separators

3:01 whats the behaviour that you see when you try to (compile)?

3:03 vIkSiT: java.io.IOException: No such file or directory (hello.clj:1)

3:03 talios: and for verification - how are you compiling? whats the actual line you're using?

3:03 clojurebot: thanks; that was delicious. (nom nom nom)

3:03 vIkSiT: sec

3:04 (compile 'clojure.examples.hello)

3:05 does the trailing slash in .clojure matter, btw?

3:05 talios: it shouldn't...

3:06 vIkSiT: see : http://paste.lisp.org/display/96978#1

3:08 talios: are you on linux or the like?

3:09 vIkSiT: OS X

3:09 talios: ok thats goodo.

3:09 if you run: ps aux | grep java

3:10 find the entry that mentions clojure ( you could just grep for clojure I guess ) - whats the actuall command line its running?

3:10 do this whilst the repl is running

3:11 _ato: try making a directory: .../dir1/classes

3:11 and add it to your .clojure as well

3:11 talios: ah yes!

3:11 _ato: I think $PWD/classes is the default value for clojure.build.path

3:11 vIkSiT: hmm, I did check the ps output. Looks like java is running fine, the CP is set fine

3:11 I'm using jline.consolerunner, which seems to be running fine

3:11 okay

3:12 * talios just looked up his maven plugin code - you also need a -Dclojure.compile.path=/some/path/to/write/to

3:12 talios: interesting - I don't see that mentioned on the clojure.org page about compilation anymore

3:12 vIkSiT: okay, this is interesting.

3:12 Looks like the classes directory got filled up with the right classes

3:13 _ato: err yeah... clojure.compile.path, not clojure.build.path

3:14 * talios forgot it had a default actually

3:14 vIkSiT: okay, so looks like I'm running fine with the classes option. I guess I can stick to the default for now

3:15 from the doc, "A loader classfile will produced in my/domain/lib__init.class, under *compile-path*, which must be in the classpath"

3:15 but that doesn't mention anything about it being $PWD/classes

3:16 talios: one annoying thing I discovered about the compiler today - if you (compile) a namespace, the compiler outputs all namespaces to the classes dir, not just those in the namespaces you specified)

3:16 so any namespaces (use)'d also get written to disk

3:16 vIkSiT: http://paste.lisp.org/display/96978#2

3:17 I still don't get a lib__init.class though

3:18 hello__init.class still doesn't exist.

3:19 ok, adding /dir1/classes to .clojure helps

3:19 whew. finally!

3:20 thanks talios , _ato

3:41 talios: amusing - I just spotted vIkSiT's blog on AOT ;-) http://www.viksit.com/content/clojure-aot-compilation-tutorial

4:48 nice - someone's patch pmaven-clojure with support to make it use leiningen syntax.

6:11 LauJensen: Hey crew

6:24 esj: Hello Mr Lau

7:05 etate: hey Lau

7:10 vy: Aren't there any list-files [http://paste.lisp.org/+22TV] in contrib or in core?

7:11 LauJensen: vy (file-seq (File. "/home/"))

7:11 gives you all files and directories in /home/

7:12 (-> (File. "/home/") file-seq (filter #(.isFile %))) gives you only files

7:12 oops, ->>

7:12 vy: Damn! How did I missed that function. Thanks.

8:05 gstamp: I noticed with slime that some errors go to the swank server console and some are reported within emacs itself. Anyone know why that might be?

8:08 _ato: gstamp: generally output on a different thread to the one slime is running your command in will go to stdout/err of the swank process

8:09 gstamp: hrrm. okay, thanks. that could be it.

8:10 LauJensen: Finally got Emacs to open URLs in a new Chrome tab!! wee :)

8:24 gstamp: another swank question... are the backtraces supposed to be clickable. they highlight as I move my mouse over them so it _looks_ like they should be but clicking on them only gives the message 'synchronous lisp evaluation aborted'.

8:30 hoeck: gstamp: the common-lisp slime implementations show some additional information when clicking on stacktraces, e.g. local variables and their contents

8:32 gstamp: hoeck: okay so I guess it's not implemented then. sounds like it would be a nice feature to have. slime must make for a great common-lisp development environment.

8:32 hoeck: gstamp: but swank-clojure has no access to locals in exception stackframes

8:32 gstamp: its even possible, the jvm comes with its own (java) debuginterface, JDI

8:33 gstamp: gstamp: fair amount of work to implement I'd imagine

8:33 hoeck: and it comes even better, you can connect to the debug interface from a running clojure repl to debug itself, catch Exceptions as they are thrown, stop thread execution etc.

8:34 the biggest problem is the proper slime integration, and getting correct line and source-file locations

8:42 LauJensen: hoeck: So many hours would be saved if Clojure just kept record of what is was evaluating when something borks, so that you got the exception and the form which blew up - But I have hopes that swank-break will improve this functionality substantially

8:44 hoeck: swank-break?

8:44 a new debugger effort?

8:50 LauJensen: hoeck: The ability to insert break-points directly in Emacs

8:50 WITH locals inspection

8:50 :)

8:52 hoeck: through JDI?

8:52 who does this? does he need help?

8:55 LauJensen: Hugo Duncan is working on it - I've also asked if they (he and technomancy) needed any help

9:00 hoeck: good to hear, thanks for the info Lau

9:03 LauJensen: np

9:03 hoeck: LauJensen: btw, do you know how that discussion about the new names for deftype turned out?

10:03 hugod: LauJensen: hi, did you give swank-break a try?

10:04 hoeck: if you want to give it a try, swank-break is a branch in technomancy's swank-clojure repository on github

10:10 hoeck: hugod: thanks, will try it

10:13 LauJensen: hugod: Didn't test it, just got an email from phil explaining what had been done so far

10:15 hugod: LauJensen: the more feedback we get, the more confident we can be on merging it...

10:15 LauJensen: sorry for yesterdays confusion - hope everything got sorted out your end

10:16 LauJensen: hugod: the reason I haven't picked it up was because I sent phil an email asking for a few details and offering my help, he hasn't gotten back to me yet

10:17 hugod: I'm also playing with jpda/jdi locally, but that would be a much bigger change

10:55 _invis: Hi everyone. Could you help me with labrepl ? "All the solutions above take all the numbers in range, and then exclude the ones we don't want. Go the other way and implement a solution that builds up the sequence of numbers we do want." They speak about (filter (something) (range number)). How can I make seq without filter and range ?

10:56 for example. seq with numbres are multiply of 7

10:57 Chousuke: you can construct lazy seqs manually of course, using lazy-seq

10:57 or you can use the iterate function

10:57 _invis: Why all in clojure is lazy seq ?

10:58 Chousuke: everything isn't. but most stuff is

10:58 because lazy seqs are very convenient

10:58 cp2: if you're lazy

10:58 :)

10:58 _invis: :)

10:58 ok, thanks

10:58 Chousuke: a programmer's virtue

12:10 _invis: is there any macro like 'concat' which delete same sense ?

12:10 '(concat [1 2 3] [6 4 1])

12:10 ,(concat [1 2 3] [6 4 1])

12:10 clojurebot: (1 2 3 6 4 1)

12:11 _invis: i need seq without last 1

12:11 The-Kenny: ,(butlast [1 2 3 6 4 1])

12:11 clojurebot: (1 2 3 6 4)

12:11 _invis: is there any macro like 'concat' which delete same sense ?

12:12 ,(concat [1 2 3] [6 1 4])

12:12 clojurebot: (1 2 3 6 1 4)

12:12 The-Kenny: I'm not sure if (set) keeps ordering, but maybe (vec (set [1 2 3 1])) works

12:12 ,(vec (set [1 2 3 1]))

12:12 clojurebot: [1 2 3]

12:12 The-Kenny: ,(vec (set [1 2 1 3 1 3 42]))

12:12 clojurebot: [1 2 3 42]

12:13 _invis: hm

12:13 thanks

12:27 Look guys http://gist.github.com/346845. Could you tell me why this set is not sorted ??

12:30 Chousuke: order of items in sets is random

12:31 or rather, unspecified

12:32 _invis: But if it 20 in my-seq

12:32 (set (concat (my-seq 0 3) (my-seq 0 5)))

12:32 #{0 3 5 6 9 10 12 15 18}

12:33 Chousuke: that's a coincidence

12:33 you want sorted-set

12:33 _invis: no i dont wont :)

12:33 just wonder

12:33 why set sort sometimes and sometimes not

12:34 Chousuke: the set works by hashing

12:34 sometimes, the hash order happens to correspond to sorting order

12:34 but that's not guaranteed

12:34 _invis: Thank you.

13:10 Licenser: hmm there was that db entirely written in clojure, I don't remember the name so :(

13:10 dnolen: Licenser: fleetdb

13:13 Licenser: dnolen: THANK YOU!

13:28 brian__: hi, I'm looking for online documentation for duckstreams

13:30 LauJensen: brian__: I think the source is your best bet

13:30 brian__: ok, i was headed there

13:44 alexyk: so, is lein repl still inpacable of launching a specific version of clojure repl?

13:52 bsteuber: alexylc: it launches the clojure version you have in lib

13:52 alexyk: I mean, sorry :)

13:53 alexyk: bsteuber: for repl, not true. It launches 1.1.0 while I have 1.1.0-master-SNAPSHOT in lib

13:54 for swank, it respects version, for repl, didn't...

14:35 bsteuber: alexyk: oh, really! thx for pointing it out to me, then :)

15:33 laynor: hi, can someone recommend an editor/ide for clojure?

15:34 I'm used to emacs and slime, btw

15:34 dsop: hmm and I don't get clojure-mode to run under emacs

15:34 emacs tells me that it cannot find the file clojure-mode

15:35 laynor: going to try that now, I'll let you know if I get it working

15:36 also, what's the status of the clr port? I'd like .net better than the jvm

15:42 raek: dsop: do you have a (add-to-list 'load-path "/path/to/clojure-mode") in your .emacs?

15:43 laynor: emacs, slime and swank-clojure are great for clojure

15:44 and since you already have experience with the two first, things should be pretty straight forward for you

15:44 dsop: raek: yes it works now, had to figure out somet stuff here

15:47 candeller: hi, got a newbie question regarding anonymous functions: lets say i define one with the shorter syntax ( #( + %1 %2) 1 2) #=> 3 - works fine, i can refer to the args via %, but what when I write it this way: ( (fn [a b] + a b) 1 2) #=> 2, it doesnt see the first arg. What to do?

15:48 dnolen: ((fn [a b] (+ a b) 1 2) is the way to write it

15:48 candeller: 6

15:48 ^

15:49 ((fn [a b] (+ a b)) 1 2) rather

15:49 ,((fn [a b] (+ a b)) 1 2)

15:49 clojurebot: 3

15:49 candeller: dnolen: ahh thanks

15:52 laynor: raek: so there is slime integration for clojure? that's great! do I also get debugger integration and inspector?

15:55 The-Kenny: laynor: inspector yes, debugging not really

15:55 raek: http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html

15:56 this was the guide I used when getting started

15:57 this can be usefull too: http://technomancy.us/126

15:59 laynor: raek: I'm on windows, not using linux anymore really :)

16:01 raek: ah, ok... is ELPA available on windows?

16:02 if so, you should be able to get swank-clojure from ELPA

16:02 phren0logy: I'm pretty sure elpa is on windows. I saw somebody was using clojure-box, plus emacs starter kit.

16:03 laynor: it seems clojure-install is working

16:04 but it downloads everything lol

16:12 raek: how do i start slime with clojure then?

16:13 vy: What's the computation and memory complexity of the set union in Clojure?

16:13 raek: M-x slime when in clojure-mode, I think

16:14 vy: raek: I mean in terms of big-O notation.

16:14 The-Kenny: laynor: Either M-x swank-clojure-project (for leiningen/maven projects) or M-x slime (for an inferior repl in emacs)

16:17 raek: vy: dont know, but here's the source: http://github.com/richhickey/clojure/blob/76e7c4317dc3eac80c4908ac5e5fb885e302b2a4/src/clj/clojure/set.clj#L19

16:18 for two sets it looks like it is O(n) * conj

16:19 I think (conj set val) is log32(n)/near-constant-time for hash-sets

16:19 laynor: The-Kenny, raek: M-x slime while in clojure mode starts sbcl. Can't I have both lisps configured? :/

16:20 The-Kenny: laynor: You can. Try M-x slime with a prefix argument (C-u M-x slime)

16:21 laynor: Two small utility functions: http://gist.github.com/347006 :)

16:21 raek: vy: so I guess set union is practically O(n) or technically O(nlog32 n)

16:23 this would be the computation complexity

16:23 the memory complexity is a bit more complicated due to the structural sharing of the sets

16:24 caljunior: just wanted to drop in to say that Clojure is the only language I don't mind hacking in on a Sunday night. Any other language would feel like work. *thanks again Rich*

16:26 laynor: The-Kenny: thanks a lot, I still didn't get it working, I probably did something the wrong way, so I'm going to reinstall everything again with elpa.

16:27 The-Kenny: laynor: My recommendation is using lein-projects for everything. It's so much easier than fiddling around with classpaths for M-x slime etc

16:27 laynor: what's lein-projects?

16:27 The-Kenny: (I keep a 'test'-project if I want to try something fast)

16:28 laynor: Leiningen is a build tool for clojure, wrote by technomancy: http://github.com/technomancy/leiningen

16:29 It's easy, just do "lein new foo; cd foo" and you have a production-ready project. lein can also generate jars, start a repl etc. etc.

16:29 (If you add swank-clojure to the deps, you can also just run M-x swank-clojure-project in Emacs to start a slime-repl)

16:30 with classpaths etc. set right for this project

16:30 laynor: does it work in windows?

16:30 The-Kenny: hm... I'm not sure, propably not

16:30 I don't have any experiences with windows, sorry

16:33 laynor: going to try it on cygwin

16:37 phren0logy: AHHH. Sorry, Cygwin gives me a rash. You could also make a VM and set that up just for clojure.

16:38 laynor: phren0logy: my disk is full and the desktop machine is broken lol

16:47 phren0logy: laynor: did cygwin kick you off?

16:51 laynor: phren0logy: yeah, while updating

16:51 lol

16:52 phren0logy: See? I feel like every time I try to solve a problem with cygwin, I have two problems. But maybe that's just my ineptitude.

16:54 laynor: phren0logy: I don't really like cygwin either.. but sometimes is the least ugly solution

16:54 or the only one

16:54 :/

16:54 phren0logy: laynor: yeah, you just gotta do what works

16:55 laynor: a virtual machine wouldn't be that bad, but it's boring to setup

16:55 and no disk space at the moment

16:56 I just got an error from lein "could not find main class clojure.main" -_-'

16:57 phren0logy: laynor: If you get the space, check out vagrant - http://vagrantup.com/

16:57 laynor: it sets up VMs the easy way

16:58 laynor: I'll give it a try

16:58 god

16:58 I really hate the jvm

16:59 it seems I don't have clojure in my classpath

16:59 or ...

17:02 boojum: ,(reduce #(apply assoc %1 %2) {} '([:a 1] [:b 2] [:c 3])) ; must be a better way?

17:02 clojurebot: {:c 3, :b 2, :a 1}

17:08 leifw: I found parallel.clj while looking for things like preduce and pfilter, the one based on ForkJoin

17:08 it says it's DEPRECATED, but I can't find a replacement

17:09 is there one?

17:17 vy: Why does it warn that "call to divide can't be resolved." on (defn- score [cur tmp] (/ (int cur) (int tmp)))

17:17 What else should I do?

17:35 chouser: vy: there is no divide for int,int

17:35 (show clojure.lang.Numbers "divide")

17:37 leifw: there's a par branch of clojure that has newer stuff.

17:56 defn: ,:

17:56 clojurebot: Invalid token: :

17:56 defn: ,:-)

17:56 clojurebot: :-

17:57 joshua-choi: How can I write a function flatten-1 so that it flattens a sequence by one level? That is, (= (flatten-1 [1 2 [3 4 [5 6] 7]) [1 2 3 4 [5 6] 7])).

17:57 defn: joshua-choi: good question -- there was some talk on the list about flatten awhile back fwiw

17:59 Raynes: joshua-choi: There is a 'flatten' function in contrib.

18:00 In seq/seq-utils

18:00 defn: it's in seq-utils

18:00 * defn nods -- but it's not a flatten-1 like he's asking

18:00 defn: i think someone may have written a flatten-1 in the list

18:01 Raynes: defn: I'm aware. flatten might be a good starting point for flatten-1

18:02 defn: http://groups.google.com/group/clojure/msg/385098fabfcaad9b

18:02 joshua-choi: Raynes: I did look at contrib.seq/flatten's source, but it uses filter in a way so that I don't see how to restrict the recursion to one level.

18:03 defn: joshua-choi: yeah i think you're gonna wanna do something with tree-seq

18:03 ,(doc tree-seq)

18:03 clojurebot: "([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree."

18:03 joshua-choi: Hmm, tree-seq always was unfamiliar to me

18:04 It seems so useful, but I've never...truly comprehended it

18:04 I'll take a look at it, thanks

18:04 defn: joshua-choi: ill work on it and see if i can beat you to the punch :)

18:06 joshua-choi: i can give you a couple tree-seq examples hopefully here

18:07 leifw: joshua-choi: what's wrong with (def flatten (partial apply concat)) ?

18:07 joshua-choi: defn: Well, I understand what it mechanically does well enough...but I'm not yet smart enough to understand when to use it

18:07 leifw: oh they're heterogeneous never mind

18:08 chouser: thanks, I'll check that out

18:11 _ato: not sure tree-seq is going to help you as it can't tell the depth, although I guss you can tag it somehow

18:11 ,(mapcat #(if (coll? %) % [%]) [1 2 [3 4 [5 6] 7]])

18:11 clojurebot: (1 2 3 4 [5 6] 7)

18:12 wooby: joshua-choi, perhaps what you're interested in is a breadth-first walk?

18:13 _ato: maybe sequential? would be a better test than coll? to match flatten

18:13 joshua-choi: _ato: sequential? is what Hickey suggested in defn's link earlier

18:14 wooby: How would you do that, then?

18:14 Hmm

18:14 wooby: joshua-choi, http://gist.github.com/345785

18:14 defn: wow i suck at clojure ^^

18:14 wooby: joshua-choi, bfs-seq being the lazy breadth first walk

18:15 _ato: ,(mapcat #(if (sequential? %) % [%]) [1 2 [3 4 [5 6] 7]])

18:15 clojurebot: (1 2 3 4 [5 6] 7)

18:15 wooby: friend and i were walking on breadth first file walking

18:16 phren0logy: iiiiiiiiiiiiiiiiiiiiiiiii

18:16 Raynes: oooooooooooooooooooooo

18:18 joshua-choi: _ato: Would using #(if (sequential? %) % (list %)) be more efficient than #(if (sequential? %) % [%])?

18:19 phren0logy: bgi

18:19 bi

18:19 defn: ,(tree-seq seq? seq [[1 2 [3]] [4]]]

18:19 clojurebot: Unmatched delimiter: ]

18:19 _ato: maybe slightly

18:19 defn: ,(tree-seq seq? seq [[1 2 [3]] [4]]])

18:19 clojurebot: Unmatched delimiter: ]

18:20 phren0logy: gb

18:20 defn: ,(tree-seq seq? seq [[1 2 [3]] [4]])

18:20 clojurebot: ([[1 2 [3]] [4]])

18:20 defn: ,(tree-seq vector? seq [[1 2 [3]] [4]])

18:20 clojurebot: ([[1 2 [3]] [4]] [1 2 [3]] 1 2 [3] 3 [4] 4)

18:53 defn: what is the difference between sequential? and seq?

18:53 I see the diff. in the doc says ISeq versus Sequential

18:53 but what does that mean in practice

19:26 chouser: defn: a seq implements first and rest -- 'seq?' returns true for all seqs.

19:27 defn: a sequential is a collection that holds things in a definite order or sequence -- 'sequential?' returns true for a subset of all sequentials.

19:36 joshua-choi: How does proxy-super work? According to proxy's documentation, its methods do not have access to their super-methods.

19:45 chouser: proxy-super temporarily removes the derived class's method implementation, then calls the method so it "falls through" to the base class. It is not thread-safe.

19:49 joshua-choi: I see.

19:49 Another question: how would you call a method's supermethod in a function acting as a method in a gen-class namespace?

19:56 chouser: use :exposes-methods

20:10 joshua-choi: chouser: Wonderful. Thank you.

20:21 erikcw1: I'm trying to figure out how to add a github repo as a dependency in a lein project.clj file. I'm trying to automatically pull from here: http://github.com/kriyative/cynojure (it has a build.xml file, but doesn't have a project.clj file)

20:34 talios: erikcw1: I don't think lein handles source dependencies, only .jar artifact deps from a maven like repository

20:34 source deps could be cool tho

20:34 I'm not a lein guy tho so I could be wrong

20:38 tomoj: does maven already have something for src deps?

20:38 in the worst case, you can write your own project.clj

20:38 and 'lein install' into your local maven repo

20:38 or push to clojars under your personal clojars group :/

20:39 if it really only depends on clojure-contrib, neither of those should be too difficult

20:39 you can also build the jar however they want and install the jar itself into your local maven with no project.clj

20:39 http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

20:46 alexyk: is there a fn which does both filter and remove at once?

20:47 tomoj: hmm

20:47 you mean, pass two predicates?

20:49 if not, I think you're looking for empty :)

20:53 talios: tomoj: maven has -source.jar artifacts which get published along with releases, and can be pulled down, but that's mostly for single step debugging etc.

20:53 tomoj: not sure "download source dep and build"

21:04 alexyk: tomoj: I mean partition at once

21:06 ah, separate from seq-utils

21:06 dakrone: alexyk: you could use partition-by also

21:44 shales: Having trouble trying to use a DelayQueue. I'm creating the objects to add to the queue with (proxy [Delayed] ...). Implementing the getDelay method is easy enough. It closes over the target time which is in a let surrounding the proxy call. However, I can't figure out the compareTo method.

21:44 Somehow I need to get the target time of another Delayed proxy that is passed in

21:44 chouser: ah, yes.

21:44 shales: I tried adding a getTargetTime method to the proxy, but am getting exceptions

21:44 chouser: you can't add new methods with proxy

21:45 shales: figured as much.

21:45 chouser: you don't happen to be on post-1.1 do you?

21:46 shales: I am. I've been looking at deftype but am a bit confused

21:46 tried proxy first because it seemed simpler

21:46 chouser: yes

21:46 is Delayed an interface?

21:47 shales: yes

21:47 chouser: ok, so I'd recommend using reify instad of proxy -- syntax is very close to the same.

21:48 Then you can create a new protocol: (defprotocol MyDelayed (getTargetTime [obj]))

21:49 then your reify can implement that as well.

21:51 shales: ok, thanks for help. I'll give that a shot

21:51 actually one more thing. How do reify and deftype compare. Are they similar?

21:52 chouser: reify is more like proxy -- a way to implement interfaces taking advantage of closures

21:53 cemerick: chouser: how goes it, Mr. Houser? :-)

21:54 chouser: deftype is more like defstruct -- associates a type name with a set of map keys.

21:54 cemerick: not bad. :-) how are you?

21:56 cemerick: chouser: Well. Working on squeezing as much as I can out of deftype. Time for optimization finally came.

21:56 alexyk: is there a multi-set, i.e. counting set?

21:59 can #(..#(..)..) be nested?

22:00 chouser: alexyk: nope, #() cannot be nested.

22:00 alexyk: ok

22:01 so I guess I have to implement multi-set with a map elem=>counts and update-in?

22:01 chouser: ah. sure.

22:04 cemerick: yeah, deftype should help. It's fast. ;-)

22:05 cemerick: chouser: Indeed. I've got these crazy spatial data structures I wrote 18 months ago that have been plugging away using straight maps, some structs here and there, etc. Yikes.

22:06 They're getting better, finally.

22:12 alexyk: is there a simple way to subtract maps by keys?

22:12 chouser: subtract? like update-in dec, or dissoc?

22:13 alexyk: chouser: like set difference, dissoc all other map's keys

22:16 somnium: ,(apply dissoc {:a 'a :b 'b :c 'c :d 'd} (keys {:a 'x :c 'y}))

22:16 clojurebot: {:b b, :d d}

22:17 alexyk: ah, it takes many! ok

22:17 chouser: heh. I just wrote that myself, but with reduce.

22:17 ,(reduce dissoc {:a 1 :b 2 :c 3} (keys {:b 2 :c 1 :d 0}))

22:17 (reduce dissoc {:a 1 :b 2 :c 3} (keys {:b 2 :c 1 :d 0}))

22:17 clojurebot: {:a 1}

22:17 chouser: oops, sorry.

22:18 defn: ,(reduce dissoc {:langston "hughes"} (keys {:joplin "misourri"}))

22:18 clojurebot: {:langston "hughes"}

22:19 somnium: reduce seems to have the upper hand in popularity

22:19 defn: i dont see why it wouldn't -- i had heard so much about mapreduce and such before i found clojure

22:20 http://en.wikipedia.org/wiki/MapReduce

22:22 tomoj: MapReduce is a bit different than map and reduce though, right?

22:23 chouser: well, it's distributed. :-)

22:24 tomoj: is that the only difference?

22:29 mabes: It is easy to map/reduce on a small scale. It becomes difficult once you have to scale it. So MapReduce is not only distributed but it is redundant in that when workers fail (as they will once you are using many machines) the job continues without a problem.

22:30 tomoj: I see

22:31 mabes: there are a ton of rinky-dink map-reduce frameworks that sure enough do map and reduce, but they skirt the hard part of the problem...

22:31 s/there/their/

22:36 defn: rinky-dink is such a great phrase

22:42 tomoj: https://gist.github.com/8d3f0b775d3e2f0b4042

22:42 what do you think of this?

22:42 I feel like monads might help with this kind of thing

22:42 the monadic values are functions and you can fmap boolean operations over them

22:45 maybe it's better to stick to pointful

22:45 #() is not bad

22:45 defn: #(some-fn %1 %2) is such a fantastic syntax

22:46 tomoj: in this case the domain is unary functions anyway so we don't even need numbers

22:46 defn: helps you think about it

22:56 tylere: Is the programming clojure sample code broken? Something isn't working right... after I (require 'examples.introduction), using the provided repl script...

22:56 user=> (take 10 examples.introduction/fibs)

22:56 java.lang.ClassNotFoundException: examples.introduction (NO_SOURCE_FILE:8)

22:58 tomoj: hmm

22:58 try (require 'examples.introduction) in the repl

22:58 what's it say?

22:58 tylere: nil

22:58 tomoj: that's right

22:59 now maybe try (ns-publics 'examples.introduction)

22:59 tylere: java.lang.Exception: No namespace: examples.introduction found (NO_SOURCE_FILE:0)

22:59 tomoj: odd

22:59 I don't have the code

23:00 tylere: http://github.com/stuarthalloway/programming-clojure if you're curious

23:00 tomoj: and you're using bin/repl.sh?

23:00 tylere: yes

23:02 tomoj: it seems like the .class files for the examples aren't in classes

23:02 and also like repl.sh only puts classes on the classpath, not the example sources

23:02 why, then, (require 'examples.introduction) doesn't throw an error, I don't know

23:02 tylere: yea, that's what's kinda bugging me

23:03 tomoj: oh, hmm

23:03 it looks like repl.sh adds . to the classpath

23:04 you're running bin/repl.sh from the root of the programming-clojure clone?

23:04 tylere: yes

23:04 anywere else and it doesn't run

23:04 because it can't load the libs

23:04 tomoj: yeah, that makes sense

23:05 and examples/introduction.clj is there and has (ns examples.introduction) ... hmm

23:06 I'll clone and see if it works for me

23:06 tylere: lemme try that too...I mean, I don't think I've touched anything in there but...

23:07 tomoj: it works fine for me

23:07 tylere: ok

23:07 tomoj: git clone ...programming-clojure.git

23:07 then in the root bin/repl.sh, (require 'examples.introduction) returns nil

23:07 tylere: ok, it's working for me now

23:07 tomoj: and (take 10 examples.introduction/fibs) returns (0 1 1 2 ...)

23:07 tylere: very odd

23:07 tomoj: hmm

23:07 maybe check 'git status' on the other clone?

23:08 see if it's the same rev and everything I mean?

23:08 tylere: I deleted it ;(

23:08 tomoj: ah, oh well, glad it works now, have fun :)

23:08 tylere: yep, thanks

23:08 tomoj: one note: defining fibs that way is Bad

23:08 it's useful for demogogic purposes I suppose

23:09 err

23:09 tylere: Clojure looks really interesting to me...did some CL a few years ago, though it was neat, but no libs for much of anything useful

23:09 tomoj: whatever the word is

23:09 yes, I love the fact that we get tons of libs for free

23:09 somnium: the demeagogy of bad fibs

23:09 tomoj: pedagogic I meant :)

23:09 tylere: (and where there were libs, they were always implementatin specific, not standardized)

23:10 tomoj: tylere: but, if you care, lazy seqs like that should be defined as functions, so you'd do (take 10 (examples.introduction/fibs)) instead

23:10 otherwise, fibs will "hold its head", and if you try to take the millionth fib or something far down the line, you run out of memory

23:10 tylere: heh

23:11 tomoj: but it's fun to see that you can define vars that seem to point to infinite sequences :)

23:11 tylere: yea

23:12 it's kinda funny...I've done (some) CL, a decent bit of ML, a bit of haskell, so stuff like that isn't *that* odd to me, but I know almost no java

23:12 so learning the api might take a while

23:12 tomoj: yeah

23:12 tylere: did a bit of scala too...but that was so much to learn it was overwhelming

23:12 tomoj: clojure's java interop is nice but learning enough of the java ecosystem can be a problem

23:12 tylere: the scala book is (no lie) almost 1000 pages

23:13 tomoj: leiningen helps I think

23:13 tylere: yea, ant and maven scare me..

23:13 defn: yeah i wanted to learn clojure without learning java

23:13 tomoj: then as long as you can read javadocs..

23:13 defn: and yeah, ant and maven are scary thing

23:13 tylere: yea, I've got that...not that I have anything TO build yet

23:13 tomoj: luckily I was forced to learn java in school

23:13 defn: things*

23:13 tomoj: you can do a lot with pure clojure, but eventually you will probably want to use some java stuff

23:13 defn: i learned some java years ago in high school, but my school used C++

23:13 people who are learning clojure are smart enough to handle some of Java

23:14 i came from ruby to clojure

23:14 tomoj: yeah, and you probably don't need to _write_ any java

23:14 just learn enough to create objects and call their methods, I think, as well as how to include a java project in your deps

23:14 tylere: Python has long been my tool of choice, although most of what I do for work is in PHP (stabs eyes)

23:14 defn: yeah just the way you interact with java -- that is sort of weird at first -- learning how to read docs was really all i had to do

23:14 once i got the hang of -> .. and . i was fine

23:15 tylere: i am forced to do PHP for work also -- but our production box has java and im trying to sneak some clojure in :)

23:15 tylere: heh

23:16 defn: rich had a funny interview recently where a guy asked him "so how do you justify this to the enterprise"

23:16 tylere: My job is to maintain a large drupal site

23:16 tomoj: we're using drupal but I managed to sneak clojure into our backend plans :)

23:16 defn: and rich is like "you just tell them it's a java library!" ;)

23:16 tylere: tomoj: !

23:16 defn: "it's a .jar!"

23:16 etc.

23:16 tylere: tomoj: Similar here, but replace clojure with python...it's what I use for all import routines and the like

23:16 tomoj: ah, interesting

23:17 I hadn't really considered clojure for managing drupal

23:19 defn: ive grown a lot more comfortable with clojure lately -- i really wasnt familiar with what it meant to distribute a java application, how to manage dependencies, etc.

23:19 but it has all started to come together

23:20 dsop: same here

23:20 defn: it was kind of a revelation when i realized i could just hand everyone a jar

23:20 dsop: jepp

23:20 and it's particularly challenging but in the same time enlighting if you try to mix clojure scala and java in one app :)

23:20 defn: with ruby it was always like "gem install xyz", etc. etc.

23:21 of course you could bundle all of that, but then the person receiving the thing had to have ruby

23:21 dsop: oh c was more like: ah yes you need a million dependencies in the right version if not you will not notice but the program will break, someday and then it'll dump

23:21 defn: the other thing with java, a thing which i now realize is why the enterprise likes java is...

23:22 i can distribute a working application, and it will work for at least 5 years

23:22 dsop: defn: well and you have bunch of real classy libraries

23:23 defn: the one thing im totally uncomfortable with at this point is using profilers and trying to incrementally improve performance

23:23 i have a big problem with some code right now that i could have probably just handled with perl, python, or unix utils that is slow in java

23:24 that is disappointing -- so id like to improve its performance, but im clueless

23:24 dsop: is it slow in java or is it slow in clojure?

23:24 defn: clojure sorry

23:25 dsop: well in that case profiling might help, I don't know much about performance critical things in clojure

23:25 defn: http://gist.github.com/347339

23:25 dsop: defn: but as stuart always says: try to fix your algorithms before you microoptimize

23:25 defn: dsop: yeah i think im there

23:26 #(assoc! %1 %2 (inc (get %1 %2 0)))

23:26 that's the problem at this point

23:27 talios: 'lo defn , tomoj

23:27 defn: i get a huge list of IPs, and then i want to count the number of occurrences for each unique IP dsop

23:27 AFAICT there's not an algorithm that's going to help

23:27 talios: I hope thats not a list of torrent users :)

23:27 defn: what i need to do is chunk it and use reftypes

23:27 talios: lol me too!

23:28 but i feel like chunking + reftypes seems like it's overkill, like i might be missing something more obvious, something easier

23:28 Raynes: Is there a core function that does nothing but discard it's input?

23:28 * talios looks at the clock - oo, almost hometime already!

23:28 sramsay: stuck newbie asks . . .

23:29 dsop: defn: sorry I don't know

23:29 sramsay: suppose i have (1 2) and (5 3 4 2 3)

23:29 want to return only the latter that are in the former.

23:30 filter with for? can't get it to work.

23:31 Raynes: ,(filter #{1 2} '(5 3 4 2 3))

23:31 clojurebot: (2)

23:31 Raynes: A set is good for this.

23:31 ,(filter #{1 2} '(1 5 3 4 2 3))

23:31 clojurebot: (1 2)

23:31 sramsay: How does that work? sets can act as functions?

23:32 Raynes: Yep. It tests to see if it's argument is in the set, and returns nil if it isn't.

23:32 Otherwise, it returns the argument, I believe.

23:32 sramsay: Wow. That is so much more beautiful than what I was doing ;)

23:33 Raynes: ,(#{1 2} 1)

23:33 clojurebot: 1

23:33 Raynes: Anything not false or nil is true, so it works out perfectly. :)

23:33 sramsay: thanks. that is awesome, Raynes.

23:33 Raynes: No problem.

23:37 tomoj: talios: hey, my boss liked hearing about your vagrant/clojure idea

23:39 joshua-choi: I have a non-Clojure IRC question, since I'm very benighted about IRC. :( Is it possible to connect to two Freenode rooms with different names?

23:40 Raynes: joshua-choi: Maybe with two IRC clients.

23:40 joshua-choi: Raynes: :(

23:40 Raynes: I don't think so.

23:40 Is one allowed to be online twice with the same hostmask?

23:41 I guess so, because I end up having to ghost myself all the time.

23:41 joshua-choi: What are hostmasks and ghosting?

23:41 Raynes: Yeah, of course. My bot. Heh.

23:41 joshua-choi: /msg nickserv ghost <nick> <password>

23:41 In case you drop, but your nickname does not.

23:42 (@216-164-114-53.c3-0.tlg-ubr3.atw-tlg.pa.cable.rcn.com) = hostmask

23:42 I believe.

23:44 joshua-choi: I guess if it's not possible, I might as well change my Freenode username. Ah, well.

23:55 alexyk: is there a single write-up summarizing the new goodness in 1.2?

Logging service provided by n01se.net