#clojure log - Apr 21 2013

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

0:15 murtaza52: I am using emacs with nrepl. I evaluated an expression and it returned an error. How do I get the full stack trace ?

0:15 ivan: (pst)

0:17 murtaza52: ivan: It returned just one line - user> (pst)

0:17 NullPointerException

0:17 nil

0:18 ivan: murtaza52: are you using lein 2.0.0? a newer version fixed https://github.com/technomancy/leiningen/issues/1025

0:22 murtaza52: ivan: yes I am, should I just do lein update

0:22 ivan: I think so

0:23 lein upgrade

0:54 saint_cypher: st50187

1:09 david_pidcock: jacfr04t

1:51 howdynihao: so can i bring this up, http://benchmarksgame.alioth.debian.org/u32q/benchmark.php?test=all&lang=clojure&lang2=scala&data=u32q ?

1:51 why slower, more memory usage, and shockingly more loc

1:53 bbloom: howdynihao: lines is not how the benchmarks game measures code

1:54 howdynihao: oh ok, well mostly i'm just curious if performance and memory optimizations is a big priority on the roadmap for clojure

1:55 bbloom: the benchmarks game is not indicative of real world performance

1:56 most of the problems are numerical in nature, which performs particularly poorly in the face of dynamism

1:56 so you wind up with lots of type hints, which drives the code size up, where scala can infer those type hints

2:11 callen: okay, so deploying clojure with gantry is a pleasure.

2:11 all hail the uberjars.

2:11 yogthos: lein ring uberjar is my god.

2:11 yogthos: callen: haha

2:12 it's pretty slick :)

2:13 bbloom: i never really understood the appeal of capistrano or fabric... bash always seemed easier AND simpler

2:22 ebaxt: ,(clojure.string/replace (pr-str ["foo", "bar"]) " " ", ")

2:22 clojurebot: "[\"foo\", \"bar\"]"

2:23 ebaxt: Is there a better way to print a vector with commas?

2:24 bbloom: not really. what do you need them for?

2:26 ebaxt: I'm creating a script tag on the server side in order for require.js to load a common config object.

2:26 bbloom: use a JSON serializer

2:27 ebaxt: thx, didn't think of that :)

2:30 callen: yogthos: but seriously man, deploying (uber) jars is way easier than deploying a python or ruby app.

2:30 yogthos: I'm not really managing the static assets properly though.

2:30 yogthos: agreed

2:30 callen: yogthos: ended up doing nginx proxy pass to jetty process.

2:30 yogthos: automated the deployment with gantry

2:30 yogthos: that's one way :)

2:30 callen: yogthos: you one of those tomcat pukes?

2:31 yogthos: eh I use glassfish mostly :)

2:31 but same thing

2:31 callen: yogthos: wtf, enterprise weirdo.

2:31 yogthos: lol

2:31 callen: yogthos: you look at gantry yet? How do you deploy? Do you automate?

2:31 yogthos: I just don't see the advantage of doing all the stuff by hand that it already handles for you :)

2:31 yeah you dump a war in its deploy folder and magic happens

2:32 so I just do lein ring uberwar instead :)

2:32 also wars avoid the problem of not being writable

2:32 callen: there's nothing "manual" about running a jetty process and proxying it with nginx.

2:32 yogthos: so you don't have to figure out how to handle resources separately

2:32 callen: ohhhh THAT'S why people use wars.

2:32 yogthos: same with gf :)

2:32 glassfish is very scriptable

2:33 callen: yogthos: I'm used to having to push static assets into a CDN, so WARs don't mean much to me.

2:33 that makes sense though./

2:34 yogthos: but seriously, how do you automate?

2:34 if I didn't use stuff like fabric or gantry I'd lose my mind.

2:34 yogthos: well at work I've got jenkins going

2:34 callen: for scripting the deploys.

2:34 yogthos: so I just commit and it does the rest

2:34 callen: I have too many projects to use CI for my stuff.

2:34 also I don't write tests for my clojure web apps.

2:34 because I'm a nihilist.

2:34 yogthos: it's kinda neat cause with jenkins you can setup deps between projects

2:34 callen: I do for libraries though.

2:35 yogthos: so if I deploy one it can trigger builds for all the upstream stuff

2:35 yeah I don't usually write a lot of tests for apps either

2:35 callen: yogthos: my problem is 0-60 friction. I need to be able to go from idea to "bang" as quickly as possible - not efficiently deploy a complicated SOA.

2:35 yogthos: I like functional tests for sanity mostly if I go refactoring

2:35 callen: also clojure monger needs a korma'ish dialect wrapper.

2:36 yogthos: I would really like a lightweight alternative to webdriver for that.

2:36 yogthos: well with glassfish or even tomcat, you leave that thing running

2:36 as soon as you build and dump a war in the deploy it watches that and reloads your app

2:36 callen: sorta how apache wsgi works.

2:36 little less tightly coupled, but similar.

2:37 I prefer lightweight generic stuff like proxy backends.

2:37 yogthos: yeah I played a bit with monger recently

2:37 callen: then I can swap things in and out no matter how they work.

2:37 yogthos: overall it's not bad

2:37 callen: yogthos: well I'm too fucking lazy to use postgres for speculative projects - soooo....

2:37 yogthos: hehe

2:37 callen: yogthos: I'd rather use rethinkdb but they don't have 2i or a clojure driver yet.

2:37 which I keep bugging them about. I may have to wrap their java one.

2:37 which is also alpha quality :\

2:38 yogthos: I'd stick with monger till that matures :P

2:38 callen: yogthos: if you need to do any fabric-esque dev-ops automation/scripted deploys take a look at gantry.

2:38 yogthos: noted

2:38 callen: monger is good, it's clojurewerkz, it's just somewhat low-level.

2:38 also I *really* don't like the default update/insert semantics, they're fucking dangerous and I have to wrap them in my models.clj

2:38 yogthos: a friend of mine is big on vagrant

2:39 I haven't really played with it though

2:39 callen: I don't like stateful VMs.

2:39 well, vagrant is stateful'ish

2:39 vagrant solves a totally different problem from gantry though.

2:39 gantry is for provisioning, deployment, automation, scripting

2:39 vagrant is for dev environments.

2:39 yogthos: gotcha

2:40 callen: yogthos: gantry is, "run this command on this host"

2:40 same as fabric,.

2:40 yogthos: yeah so I guess glassfish sort of does that with its remore scripting

2:41 callen: gantry is more general than that

2:41 it can manage n-hosts doing anything at all.

2:41 yogthos: oh no doubt

2:41 callen: gantry is a component of my "replace heroku" toolchain.

2:41 oh speaking of, I replaced my heroku app. my clojure app had something like 60% uptime with heroku

2:41 used mongohq and digitalocean to replace it.

2:42 yogthos: let me know how you like those guys

2:42 they certainly looks fantastic on pricing

2:42 callen: yogthos: I've had some minor issues with DO, but I like them better than Linode for a few reasons

2:42 one biggie is that they handle key propagation for you automatically *and* have an awesome API.

2:42 DO has an *amazing* API, it's nicer than fucking EC2.

2:43 you can instantiate machines from images or blank templates *very* easily.

2:43 yogthos: nice

2:45 callen: demerits of DO are: their network is public, not virtual private like Lindoe

2:45 also, their CPU is somewhat less powerful than Linode. Disk is way faster though.

2:45 yogthos: yeah ssd

2:45 callen: the SSDs tempt one to cheat persistence by having local state on the web workers :P

2:45 yogthos: and you get a nice amount of ram

2:45 callen: yeah that's the biggie really. helps with concurrency per worker.

2:46 DO machines would be ideal for logging or API servers

2:46 less great for CPU intensive workers.

2:46 yogthos: makes sense

2:54 murtaza52: I have a hashmap of data with the key a string description and value an integer weight.

2:54 {:a 1 :b 3 :c 7 :d 2 :e 5}

2:54 I need to transform the hash into a vector of vectors. Each internal vector in turn is a coll of map entries. The constraint being that all the weights in each internal vector should equal to 9.

2:54 [[[:a 1][:c 9]]

2:54 [[:b 3][:d 2] [:e 5]]]

2:54 How do I write a fn to do it ?

2:55 callen: murtaza52: it's just a map, it's not a hashing implementation.

2:55 actually, it is

2:55 I think they're HAMTs

2:56 anyway, they're just called maps (lol)

2:56 bbloom: callen: there are multiple concrete implementations

2:56 callen: bbloom: what is there other than HAMT?

2:56 bbloom: callen: 3 primary implementations: PeristentArrayMap, PersistentHashMap, and PersistentTreeMap

2:57 callen: the first is used for small maps, the second used in general, and the last is used for sorted maps

2:57 callen: bbloom: cool, thanks.

2:57 yogthos: ,(into [] {:a 1 :b 3 :c 7 :d 2 :e 5})

2:57 clojurebot: [[:a 1] [:c 7] [:b 3] [:d 2] [:e 5]]

2:58 yogthos: murtaza52: is that what you're looking for?

2:58 murtaza52: oh nm read the rest

3:19 asalaaak: hi mates

3:20 can someone help me to make a do expression with this: (int (+ ( / (* 3 -774) 3 ) 774 465))

3:25 can someone help me to make a do expression with this: (int (+ ( / (* 3 -774) 3 ) 774 465))

3:28 arcatan: asalaaak: what do you mean by do expression?

3:29 asalaaak: so it prints the numbers and

3:29 gives a println with the answer

4:07 murtaza52: I have a map of data with the key a string description and value an integer weight.

4:07 {:a 1 :b 3 :c 7 :d 2 :e 5}

4:07 I need to transform the hash into a vector of vectors. Each internal vector in turn is a coll of map entries. The constraint being that all the weights in each internal vector should equal to 9.

4:07 [[[:a 1][:c 9]]

4:07 [[:b 3][:d 2] [:e 5]]]

4:07 How do I write a fn to do it ?

4:13 jjido: murtaza52: transforming is easy, applying the constraint is not

4:14 also 1+9 = 10, not 9

4:48 amalloy: murtaza52: i think your weights problem is NP-hard

5:01 callen: amalloy: knapsack problem ain't it?

5:10 supersym: shoot

5:44 tgoossens: If I understand it correctly. identities/refs pointing to other refs in clojure is just not-done?

5:45 Like in java i had Board object that has a list of player objects

5:46 Because then your refs don't have a "value" anymore

6:11 Ember-: hmm, I wonder how I should bind a compojure route which contains *both* path parameters and request parameters

6:12 it doesn't seem to pass the request parameters

6:12 and yes, I have to appropriate middleware in place

6:12 to = the

6:12 Morgawr: mm.. what's the difference between ->> and ->? Is it just that ->> adds the item as first in the function and -> adds it as second?

6:13 Ember-: Morgawr: ->> adds as the last parameter, -> as the first

6:13 tgoossens: correct

6:13 Morgawr: alright, thanks :)

6:13 tgoossens: ,(-> [1 2 3] (filter even?))

6:13 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$even_QMARK_>

6:13 tgoossens: ,(->> [1 2 3] (filter even?))

6:13 clojurebot: (2)

6:14 Morgawr: ,(-> even? (filter [1 2 3]))

6:14 clojurebot: (2)

6:14 Morgawr: great :) I think I got it

6:14 tgoossens: :)

6:16 Ember-: I thought the binding thing I asked above would work like this:

6:17 (GET "/foo/:bar" {{bar :bar a :a} :params} (str "Hello" a"))

6:17 but unfortunately it doesn't seem to work

6:18 should match into /foo/something?a=foo for example

6:18 and yes, I typoed that example :)

6:18 but you get the picture

6:23 oh crap, I think I hit this https://github.com/weavejester/compojure/wiki/Common-Problems

6:23 "One example of this is if you had two sets of routes each with wrap-params wrapped around them in the same stack. Only the first routes would have the params."

6:24 just tried, bindings work as expected in the first route mapping

6:50 zilti: Is there an actively maintained clojurescript routing library?

7:10 Is there an actively maintained clojurescript routing library?

7:52 Glenjamin: Ember-: you should be able to do (GET "/foo/:bar" [bar a] (stuff))

7:53 see https://github.com/weavejester/compojure/wiki/Destructuring-Syntax#compojure-specific-destructuring

7:56 Ember-: yes, I know

7:57 was just trying to figure out what's going on

7:57 Glenjamin: ah ok

7:57 Ember-: and thus used the more exact destructuring version for parameter binding

7:57 and btw, managed to fix my problem

7:57 thanks anyway :)

7:57 Glenjamin: i tend to throw in [:as req] on the end, and then (prn req) for debugging :)

7:58 Ember-: not a bad idea

8:51 murtaza52: what are the scenarios where structs are advantageous over maps?

9:42 amaevis: Hi everyone. I had a question about how ensuring that a service starting or stopping is synchronized so you don't get 2 starting calls processing at once.

9:42 http://stackoverflow.com/questions/16131420/canonical-way-to-ensure-only-one-instance-of-a-service-is-running-starting-s

9:42 Is there a canonical way to do this in the community? Or better yet, an existing lib?

10:55 Morgawr: I have a question.. I have an atom which contains a hashmap (let's say {:x 0 :y 0}, like a set of coordinates), now I have a collection of symbol + value (like [[:y 4][:y 3][:x 5][:y 3]]) and I want to swap! with assoc on that atom for each key-value pair from that collection

10:55 what would be the best way to do so?

10:56 so far I have a simple function which is a wrapper around swap! (with better syntax imo) which works like this:

10:56 (defn remap-state [state sym value] (swap! state #(assoc % sym value)))

10:56 I want to call "remap-state" on the atom and the collection, I was thinking about using a map but it doesn't seem to be working properly

11:00 IamDrowsy: what about making a map out of the collection (with into {}) and merge them (instead of assoc)?

11:00 Morgawr: can you provide an example? I'm still a newbie with clojure so I'm not familiar with all the functions

11:02 IamDrowsy: mh... wait.. do you need every state in between? in your example your atom would look like this {:x 5 :y 3} in the end..

11:02 do you need the state {:x 5 :y 4} for reactions?

11:03 Morgawr: I just need the last state

11:03 the resulting one after all the swap!

11:04 IamDrowsy: so you can just produce the last state without swaping with:

11:04 ,(into {} [[:y 4] [:y 3] [:x 5] [:y 3])

11:04 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>

11:04 IamDrowsy: ,(into {} [[:y 4] [:y 3] [:x 5] [:y 3]])

11:04 clojurebot: {:y 3, :x 5}

11:05 IamDrowsy: and merge the old state and the new values

11:05 Morgawr: with assoc?

11:05 IamDrowsy: no with merge

11:05 ,(doc merge)

11:05 clojurebot: "([& maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping from the latter (left-to-right) will be the mapping in the result."

11:06 Morgawr: ah derp, great!

11:06 that's exactly what I needed, thanks a lot IamDrowsy

11:06 IamDrowsy: np :)

11:37 TimMc: murtaza52: Structs are deprecated -- use maps or records instead.

11:37 murtaza52: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/

11:53 murtaza52: TimMc: thanks for the link!

12:08 mye: I'm looking for a function that produces an #inst (rfc3339) timestamp that works in clojure and clojurescript.

12:09 anyone had this problem before? Could I make a macro that expands differently in clojure and clojurescript?

12:13 asalaaak: (defn myfun [x y & others] (println (int (* x y))) (println "others: " others)))

12:14 hey mates i want to

12:14 get the sum of the others

12:14 but cant get it work

12:14 can someone help me please

12:14 (defn myfun [x y & others]

12:14 (println (int (* x y)))

12:14 (println "others: " others)))

12:14 i have this

12:15 IamDrowsy: ,(reduce + [1 2 3 4 5 6])

12:15 clojurebot: 21

12:16 IamDrowsy: oh

12:16 or

12:16 ,(apply + [1 2 3 4 5 6 ])

12:16 clojurebot: 21

12:17 asalaaak: youre amazing mate

12:17 thank you very much

12:25 klrr: HAI!

12:55 bttf: does anyone have experience using sqlKorma in here

12:59 im having issues.. https://gist.github.com/bttf/a80a95289d5ed8dcd889

13:23 mynomoto: bttf: It's saying that the db is encripted or not a db. Did you create the db with a password?

13:27 bttf: mynomoto: i saw that but unless sqlite encrypts by default its not encrypted or passworded or anything

13:28 i did a sqlite dal.db and did some creates and some inserts, thats it

13:39 if anyone could help that would make my day

14:00 mynomoto: bttf: I tried to replicate what you did but got other errors. If I were you I would try h2 instead of sqlite.

14:01 bttf: oh .. okay ill check it out, thanks

14:28 Okasu: bttf: Yeah, h2 works just fine with korma, one quirk you need to know though.

14:29 You need to upcase tablenames with h2 and korma otherwise you'll fail at select.

14:33 https://github.com/mynomoto/sqlkorma/commit/f24f917901adea0e7992f51fcdc06eca4ba30b92 Heh, it's already included in docs.

14:40 gfredericks: ,'$17.99

14:41 clojurebot: $17.99

14:41 gfredericks: ^ a macro that takes advantage of that would be kind of sweet

14:42 (with-dollaric-literals ...)

14:42 tgoossens: ,'€20

14:42 clojurebot: ?20

14:42 tgoossens: ;(

14:45 mynomoto: Okasu: Yeah, but maybe should be the default in the h2 helper. It's not clear in the docs that things will go wrong if you don't set :fields upper-case.

14:47 noncom_: hi i have two questions

14:48 1) when running a project with 'lein', not all printlns print to the console, how to fix this?

14:48 gfredericks: lein trampoline might help

14:49 I think it normally works fine for me though :/

14:49 so it might well be something weirder

14:49 noncom_: specifically, only printlns on the highest levels printlns (probably during assembling) but anything that is in-app ,it does not print...

14:51 i try trampoline now, wait

14:51 gfredericks: I'm doubting that will work based on your subsequent details

14:51 but may as well try I guess

14:51 it might be that some library you're using is changing *out*?

14:51 noncom_: oh, i use lein ring server to run the app

14:52 idk if it hanges *out* but it used to be ok some time before

14:52 gfredericks: you could debug by replacing one of the printlns with (.println System/out ...)

14:52 if that works fine then you know the issue is *out* and can try to figure out how that gets changed

14:53 maybe some piece of middleware you're using? though I'm not familiar with any such thing

14:53 I can hypothetically imagine middleware that diverts *out* to the logfile for some reason

14:55 ucb_home: evening

14:56 noncom_: looks like no such middleware... ok i tried what you said, i wrote (.println System/out " SYS OUT!! ") and it says "java.lang.IllegalArgumentException: No matching method found: println for class java.io.PrintStream"

14:56 ucb_home: I'm having trouble checking whether an item in a list is an instance of clojure.lang.Fn (inside a macro). https://gist.github.com/5430614

14:56 if anybody could point out where I'm going wrong that'd be great.

14:58 noncom_: this is weird, no?

14:59 ordnungswidrig: ucb_home: what about (fn? form)

14:59 amalloy: ucb_home: the macro will never receive a Fn: it gets source-code forms, which you typed in

14:59 ordnungswidrig: amalloy: you're right

14:59 ucb_home: amalloy: yeah, so I toyed with resolve but still didn't manage to get anywhere

15:00 ordnungswidrig: ucb_home: what it your intended use case?

15:00 ucb_home: amalloy: but then that gives me a var

15:00 ordnungswidrig: ucb_home: you could inspect the var. But can you give an example how you would like to use the macro?

15:01 noncom_: but in eclipse it prints to the console (not to the repl)

15:01 ucb_home: ordnungswidrig: hrmph, I'd need a bit of context, but basically this is the intended output. for (p-source (inc 1)) I'd want (each inc (1)) and for (p-source '(1 2 3)) I'd want (map immediately '(1 2 3))

15:02 ordnungswidrig: I thought about inspecting the var; the point of this macro is to emit different code depending on whether the first item in the form is a function or a value.

15:02 ordnungswidrig: (each ...) is a function similar to pmap btw

15:02 ordnungswidrig: ucb_home: why not (p-source #(inc 1)) vs. (p-source [1 2 3]))

15:03 ucb_home: i.e. pass a function as a function and pass a value as a value

15:03 noncom_: ,(.println System/out)

15:03 clojurebot: nil

15:03 ucb_home: ordnungswidrig: good question. I probably need to rethink this through anyway :/

15:04 I also now realise that checking for Fn is not ideal since most data structures also implement Fn; and keywords too

15:04 ordnungswidrig: ucb_home: I think you have one level of abstract to much :)

15:04 ucb_home: you can also define a wrapper type that hold the fn and check for that.

15:04 ucb_home: ordnungswidrig: yeah, possibly :/

15:05 in more general terms, do you guys feel that a version of -> and ->> that did multi-threading behind the scenes would be useful?

15:05 noncom_: ,(.println System/out "test")

15:05 clojurebot: nil

15:05 ucb_home: is there such a thing already and I'm trying to re-invent the wheel?

15:05 noncom_: at least it gives no exception

15:09 gfredericks: noncom_: that's really weird because the PrintStream class definitely has a println method

15:09 ordnungswidrig: ucb_home: how should multithreading with -> work? Every step depends on the output of the prvious one?

15:09 gfredericks: noncom_: you're not somehow passing zero or two or more arguments?

15:10 ucb_home: have you seen the parallelized threading macros in the swiss-arrows library?

15:10 ucb_home: ordnungswidrig: that's precisely what I'm trying to define and work on. I have a tiny proof of concept here https://github.com/ulises/gok/ which is probably wrong, incomplete and useless. It uses futures and promises. The way it works is by imposing some sort of structure to the flow.

15:10 gfredericks: I have not!

15:10 gfredericks: ucb_home: now you will have!

15:10 ucb_home: gfredericks: checking. Thanks!

15:13 noncom_: gfredericks: you're right, in the app i was passing 2 args. well, i tried that, and it's the same - it prints to eclipse console, but not the CMD when run with 'lein ring server'

15:14 gfredericks: noncom_: if you're using eclipse then I have no idea what arbitrarily weird things might be going on

15:14 ucb_home: oh, I see, the parallel versions are using futures too. That's encouraging at least.

15:14 gfredericks: running with `lein ring server` means not using eclipse at all?

15:14 noncom_: yes

15:14 jjttjj: i have a vector of maps, and a seperate vector of values that correspond to those maps that i need to merge together, is there a better way to do that then (map #(conj %1 [:extra-value %2]) my-maps extra-values)


15:15 bigger example here: https://www.refheap.com/paste/13814

15:15 noncom_: eclipse does nothing extra to the project

15:15 gfredericks: jjttjj: well assoc is a little cleaner than conj there

15:15 noncom_: lein sould just work as it worked but it doesn't (

15:15 ehhh..

15:15 gfredericks: jjttjj: but I can't imagine a more succinct version besides that

15:16 jjttjj: gfredericks: cool, thanks!

15:19 ucb_home: thanks for the comments; cheers now.

15:28 arrdem: if I only partially extend a protocol onto a type does it not default to the java.lang.Object impl? what I'm seeing in the repl suggests it doesn't.

15:33 gfredericks: yeah I believe it crashes

15:33 on calling a missing function

15:33 arrdem: looks like if you extend it to nil you can hack around it..

15:34 gfredericks: O_O

15:34 arrdem: lol

15:34 gfredericks: you're saying if a type has only some of the functions in the protocol implemented, for the other ones it will call the implementation for nil?

15:35 arrdem: no no

15:35 in my specific case the nil implementation matters

15:35 because I recur onto the meta map of an object if all else fails

15:35 so my error was that I didn't handle a nil meta map

15:36 Clojure was "doing the right thing" and calling Object it looks like

15:40 luisgabriel: hi, can someone give me a clue about why I'm getting a really bad performance with this code https://gist.github.com/luisgabriel/5430769 ? The function process-content returns an occurrence list (word/positions pairs) of a given text

15:43 octagon: hello, where can i find up-to-date docs about the clojure reader? http://clojure.org/reader appears to be incorrect.

15:45 ordnungswidrig: luisgabriel: is-valid split the string into a sequence. I suppose this makes it slow. Using a regex to filter the string for valid characters should be slower.

15:45 luisgabriel: ah, faster, I mean.

15:46 arrdem: octagon: what's wrong with the official page on the reader?

15:46 octagon: arrdem: "Symbols: Symbols begin with a non-numeric character and can contain alphanumeric characters and *, +, !, -, _, and ? (other characters will be allowed eventually, but not all macro characters have been determined). ..."

15:47 arrdem: consider: (defn clj->js ...)

15:48 luisgabriel: ordnungswidrig: hmm, I'll try to use a regex. thanks

15:48 octagon: arrdem: bizarrely, the javadoc for java.util.regex.Pattern states that \w is [a-zA-Z_0-9], but matches characters such as '/' or '>'

15:49 arrdem: octagon: while the reader will take -> as a valid symbol (see clojure.core/->) my point is just that the official docs at clojure.org are the best you're gonna get short of reading the code on github.

15:50 clojure-doc.org is intended to be a high level overview of the Clojure ecosystem (I believe)

15:50 and clojuredocs.org is out of date

15:50 * arrdem is 95% sure that clojuredoc.org is also a thing

15:51 amalloy: &(re-find #"\w" "/")

15:51 lazybot: ⇒ nil

15:51 octagon: arrdem: php.net lets users add comments, which is how they keep their docs up to date. just sayin

15:51 amalloy: octagon: so no, of course \w matches exactly what the javadoc says it matches

15:51 ordnungswidrig: octagon: that's a scaring feature :-)

15:52 arrdem: octagon: php.net also has some of the most evil snippets I've ever seen in the comments. just sayin

15:53 octagon: all trolling asside you're right, the main page should list < and > as valid symbol characters

15:53 also & I think..

15:53 ,'&foo

15:53 clojurebot: &foo

15:53 octagon: arrdem: the reason is i'm working on writing an editor that needs to be able to parse at a lower level than the clojure reader

15:54 arrdem: because the clojure reader doesn't preserve all the information in the source file

15:54 arrdem: like #_(...) for example, or some things can't be reverse-engineered, like syntax-quoted things

15:55 tgoossens: how would you model the following in clojure? In java for example i can have a class that has a field 'friend' which references to another Person object". ? because if i follow the idea of the "value" of an "identity". Then in clojure refs that refers to other refs make no sense

15:56 noncom_: all is fine. i fixed it

15:56 xeqi: octagon: have you seen sjacket?

15:56 noncom_: turned out that another account on the computer had an app running on the same port, and ring simply sat there silently without reporting anything and looking as if it runs the server, but it did not since the port was occupied already

15:57 gfredericks: tgoossens: you can use IDs if that makes sense for what you're doing

15:57 or nested objects?

15:57 I guess for friends IDs make more sense

15:57 tgoossens: but (now i'm coming from an oo point of view)

15:57 isn't it a bit silly that i have to

15:57 1) define an ID

15:57 2) have an identity

15:58 gfredericks: what does 'have an identity' mean?

15:58 tgoossens: that it can be uniquely identified even if the value would be the same

15:58 gfredericks: maybe you should describe what you're doing at a higher level

15:58 tgoossens: ,(= (ref 1) (ref 1))

15:58 clojurebot: false

15:59 gfredericks: doesn't giving everything an :id accomplish "having an identity"?

15:59 if :id is part of the value then it can't be equal to anything else

15:59 tgoossens: Yes. But then you want to have it shared between threads

16:00 gfredericks: how are multiple threads using these objects?

16:00 octagon: xeqi: we looked at sjacket a while ago, but i don't remember why it didn't do what we needed

16:00 tgoossens: *it might be shared

16:01 i'm just wondering btw not making an actual application at the moment

16:01 octagon: xeqi: does sjacket preserve all the info in the source? like when you have a number literal, if it's in hex or whatever

16:03 xeqi: octagon: I'm not sure, I just know its used as part of reply for figuring out when to send a complete expression to the server. I'd been hearing decent things about it

16:06 gfredericks: tgoossens: yeah abstract questions make it harder to figure out where our disconnect is. I think people tend to treat the data as values, as if it came from a database. In a database, you have :id keys and foreign keys and it's not a big issue

16:07 I do multithreaded stuff all the time and I've never even needed refs, so it's probably the case that whatever you're worried about isn't likely to come up in practice

16:07 * gfredericks rambles

16:12 tgoossens: hmmm

16:12 amalloy: i mostly use refs for things where i *could* use atoms but it's more convenient with refs

16:13 * arrdem has yet to have a legitimate use for either, but has used both wrong many times

16:13 gfredericks: clojure: you come for the refs, but you stay for the data structures

16:13 arrdem: s/datastructures/map literal/g

16:14 gfredericks: or the macros

16:14 you can stay for the macros too

16:17 concurrency support is the bait in clojure's trap to turn people into functional programmers

16:19 arrdem: clojurebot: concurrency is concurrency support is the bait in clojure's trap to turn people into functional programmers

16:19 clojurebot: Ik begrijp

16:19 arrdem: -_-

16:19 ~cons

16:19 clojurebot: litany against cons is "I must not cons. Cons is the perf-killer. Cons is the little death that brings total obliteration. I will face my cons and permit it to pass over me and through me, and when it has gone past I will turn my GC to see its path. And where it has gone there will be nothing; only I will remain."

16:20 arrdem: clojurebot: foo is bar

16:20 clojurebot: Ack. Ack.

16:21 arrdem: ~foo

16:21 clojurebot: foo is bar

16:23 gfredericks: ~bar

16:23 clojurebot: bar is foo

16:24 gfredericks: ~perf-killer

16:24 clojurebot: It's greek to me.

16:24 * arrdem failed at bending the bot to his will

16:25 arrdem: ~concurrency

16:25 clojurebot: concurrency is remeber concurrency

16:25 arrdem: gfredericks: I done f'd

16:25 octagon:

16:25 clojurebot: excusez-moi

16:25 gfredericks: ~concurrency

16:25 clojurebot: concurrency is concurrency support is the bait in clojure's trap to turn people into functional programmers

16:26 gfredericks: arrdem: ^

16:26 arrdem: (inc gfredericks) ;; for fixing my mess

16:26 lazybot: ⇒ 20

16:26 gfredericks: didn't fix nothing, just showed you it wasn't broken

16:27 arrdem: wait did I misspell it?

16:27 gfredericks: what'd I do wrong? I can't tell.

16:29 Okasu: ~concurrency

16:29 clojurebot: concurrency is concurrency support is the bait in clojure's trap to turn people into functional programmers

16:29 Okasu: ~concurrency

16:29 clojurebot: concurrency is "concurrency support is the bait in clojure's trap to turn people into functional programmers"

16:29 Okasu: ~concurrency

16:29 clojurebot: concurrency is concurrency support is the bait in clojure's trap to turn people into functional programmers

16:31 gfredericks: clojurebot: forget concurrency is concurrency support is the bait in clojure's trap to turn people into functional programmers

16:31 clojurebot: Ik begrijp

16:31 gfredericks: clojurebot: concurrency is <reply> concurrency support is the bait in clojure's trap to turn people into functional programmers

16:31 clojurebot: Ack. Ack.

16:31 gfredericks: ~concurrency

16:31 clojurebot: concurrency is forget concurrency

16:31 gfredericks: ~concurrency

16:31 clojurebot: concurrency support is the bait in clojure's trap to turn people into functional programmers

16:32 hiredman: ~botsnack

16:32 clojurebot: botsnack is scoobysnack

16:32 gfredericks: arrdem: is that what you wanted it to do?

16:32 arrdem: gfredericks: heh yeah that's what I was looking for

16:32 ~botsmack

16:32 clojurebot: clojurebot evades successfully!

16:35 xeqi: ~botstack

16:35 clojurebot: /me puts lazybot on his head and gropes blindly for a third bot to complete the stack.

16:36 arrdem: one day I will write a third bot and the botstack will be complete

16:42 Morgawr: hello, I have a collection (a hashmap) of key-values, I need to iterate over each pair and apply a function with side-effects. What's the best way to do this? At the moment I am using a map and forcing it to evaluate.. is there an appropriate construct for this case? I do not care about the returned value

16:43 xeqi: &(doseq [[k v] {:x 1 :y 2}] (println k v))

16:43 lazybot: ⇒ :y 2 :x 1 nil

16:43 arrdem: xeqi: STOP BEATING ME TO THE PUNCH

16:43 * arrdem pouts

16:44 Morgawr: xeqi: great, thanks!

16:46 tyler_: is there a function that given a value and quantity, returns a vector with n elments of value v ?

16:46 arrdem: tyler_: (repeat)

16:46 ,(repeat 3 3)

16:46 clojurebot: (3 3 3)

16:46 tyler_: (inc arrdem)

16:46 lazybot: ⇒ 3

16:47 tyler_: ta

16:47 xeqi: noooooo! I just looked away for a moment

16:47 * arrdem does the karma dance

16:47 arrdem: (inc xeqi) ;; the other guy missed you

16:47 lazybot: ⇒ 8

16:48 tyler_: um one question though, why is inc side affecting? ;)

16:49 octagon: (inc tyler_)

16:49 lazybot: ⇒ 1

16:50 arrdem: tyler_: we've had the inc! argument a few times and we've just never patched the bot XP

16:51 tyler_: why not (swap! tyler_ inc)

16:52 octagon: (dec octagon)

16:52 lazybot: You can't adjust your own karma.

16:52 rasmusto: tpope: ping

16:52 arrdem: (defmacro inc! [username] (update-in lazybot [:karma username] inc))

16:53 tyler_: woo i need to read docs on update-in i don't really grok that yet

16:59 rasmusto: tyler_: you give it a vector of keys into a nested hash-map, and a function that you want to use on the element that the keys get you to, and it updates it

16:59 ivan: is there a min-range somewhere that I should use instead of (range n Double/POSITIVE_INFINITY)?

16:59 amalloy: ivan: (iterate inc n)

16:59 ivan: ah, thanks

17:00 arrdem: amalloy: ooh nice one

17:00 tyler_: (inc amalloy)

17:00 lazybot: ⇒ 51

17:00 gfredericks: though not chunked so maybe slower

17:00 tyler_: heh chunky is faster

17:02 gfredericks: ,(let [a (atom 0)] (second (map (fn [_] (swap! a inc)) (range 50))) @a)

17:02 clojurebot: 32

17:02 jasonjck_: hm I thought all clj seq related functions were chunked

17:02 that's confusing

17:02 gfredericks: ,(let [a (atom 0)] (second (map (fn [_] (swap! a inc)) (filter identity (range 50)))) @a)

17:02 clojurebot: 32

17:17 n_b: Futures work off the unbounded thread pool, right?

17:17 s/the/an

17:24 arrdem: technomancy: if I use (slurp "VERSION") in my project.clj will lein deal?

17:33 technomancy: arrdem: one way to find out

17:34 arrdem: technomancy: doing so now :p

17:34 technomancy: lein died in a fire

17:35 technomancy: oh no

17:35 ivan: can I disable buffering on a FileWriter without subclassing it? does this already exist somewhere?

17:35 technomancy: arrdem: inside or outside defproject?

17:36 arrdem: technomancy: my b

17:36 there was another syntax error, it wasn't my slurp

17:40 (apply str (replace {\newline ""} (slurp "VERSION"))) seems to be working

18:11 tyler_: do many people move to north carolina from the bay area because of the clojure community?

18:11 ive contemplated it

18:17 ivan: gen-class or java source are the only things that will let me call the superclass, right?

19:41 &(max '(1 2 3))

19:41 lazybot: ⇒ (1 2 3)

19:43 gfredericks: &(max 1 2 3)

19:43 lazybot: ⇒ 3

19:43 ivan: &(max '(1 2 3) '(1 2 4))

19:43 lazybot: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Number

19:44 gfredericks: &(apply max (concat '(1 2 3) '(1 2 4)))

19:44 lazybot: ⇒ 4

20:15 hyPiRion: ,(reduce max (map (partial reduce max) ['(1 2 3) '(1 2 4)]))

20:15 clojurebot: 4

20:59 yedi: how can i get lein beanstalk to ignore files or folders

21:32 capcrunch: anyone uses clj-native ?

22:39 stian_: Total newbie question: given two lists of file names and access times, and wanting to compare to see which files have changed, what is the best data structure to store it (set of sets? hash?) and what is the idiomatic Clojure way of finding the filenames of the files that have changed (i.e. where time1 is not like time2)? Thanks!

22:44 xeqi: stian_: sounds like you have two maps (from filename to access time). Then for each file in the list compare the values

22:45 bbloom: unless the question is how to do that efficiently, and then it's a different question

22:52 stian_: xeqi: yes exactly… how do you compare the two? (as I said, I'm really a newbie). In Ruby I would use a.each {|x, y| if oldval[x] != y} etc, but I want to write idiomatic code. list comprehension with for, or map, or merge and distinct, or ?

22:58 xeqi: &(let [m1 {:x 1 :y 2} m2 {:x 2 :y 2}] (remove #(= (m1 %) (m2 %)) (keys m1)))

22:58 lazybot: ⇒ (:x)

22:58 xeqi: assuming the keys are the same

23:41 nicholas: eix

23:43 cnsnnts: exit

Logging service provided by n01se.net