#clojure log - Sep 10 2012

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

0:02 michaelr`: good morning

0:30 muhoo: i'm totally getting off on how fun it is to do data transformations in a huge (->> ) chain in clojure

0:33 michaelr`: muhoo: yeah me too :)

0:35 muhoo: do you ever have cases where you need to insert a func that needs the argument to be the first into a chain started as ->> or vice versa?

0:36 muhoo: yes! and the hack is to do (->> blah #(foo % bar)), or use swiss-arrows

0:36 clojurebot: 'Sea, mhuise.

0:36 michaelr`: muhoo: swiss-arrows?

0:36 muhoo: https://github.com/rplevy/swiss-arrows

0:37 michaelr`: btw, i usually try to avoid using #(), somehow it makes the code less readable for me

0:37 muhoo: yeah, it's not ideal, but i prefer #(..) to (fn [n] ...). less verbose.

0:39 Sgeo: muhoo, I think your hack should be (#(foo % bar))

0:39 muhoo: Sgeo: indeed, thanks.

0:42 michaelr`: now it looks really ugly

0:42 while swiss arrows looks really cool... :)

0:47 muhoo: yeah, (-<> (foo <> bar) (baz quux blah <>)) ... a lot cleaner

0:47 callen: okay, I want to use noir, but the plugin task was removed.

0:48 why is nothing in sync with the new lein, even the most popular web framework?

0:48 how do I add noir as a dependency to my project.clj myself without relying on the plugin?

0:48 muhoo: callen: [noir "1.3.0-beta8"]

0:49 or whatever beta is current, i think 9

0:49 michaelr`: muhoo: once you start speaking swiss it all becomes clear :) haha

0:49 callen: muhoo: I just got done getting my face kicked in because I was using a beta version of lein, why would I use the current beta of noir? what changed?

0:51 muhoo: callen: https://github.com/noir-clojure/noir/commits/master well, that's what changed

0:51 callen: cheshire appears to be one reason.

0:51 utf-8 fixes too.

0:51 good enough reasons for me.

1:05 frio: callen: what do you mean re the noir task? can't you just lein new noir mysite (in lein2)?

1:55 muhoo: happy happy joy joy (reduce #(update-in % [:city (:city %2)] conj (dissoc %2 :city)) {})

3:42 augustl: I have a list of maps, how do I get the index/position of the first map in the list that matches a given predicate?

3:44 this seems to work (.indexOf (map :the-key my-list) "foo")

3:46 michaelr`: ,(doc positions)

3:46 clojurebot: Pardon?

3:46 michaelr`: hmm

3:46 '(doc positions)

3:47 err

3:47 augustl: ^^^ :)

3:47 augustl: thanks :)

3:48 tomoj: where is that?

3:48 Raynes: &(doc positions)

3:48 lazybot: java.lang.RuntimeException: Unable to resolve var: positions in this context

3:48 Raynes: tomoj: In his head, I think.

3:49 tomoj: contrib.seq, but

3:49 (->> coll (keep-indexed #(when (#{1} (:foo %2)) %))) ? :/

3:49 er, ignore the arrow, it had more parts originally :)

3:51 Raynes: I don't think that does what he wants.

3:51 He wants the index, not the map.

3:51 Oh

3:51 Blah

3:51 Never mind me.

3:52 michaelr`: sorry for senting you to contrib ;)

3:52 sending

4:05 mpan: yay "any language of your choice"

4:12 hyPiRion: mpan: "Any language of your choice" is in two of my four courses (three, but I don't consider Clj a language for parallel programming)

4:12 I love it - finally no need to set my hair on fire.

4:31 mpan: well, the other course is adamant about wanting java, standard library, no jars or other external dependencies

4:31 mostly for the sake of the well-being of the graders, I imagine

4:40 hyPiRion: Well, yeah.

4:40 Should be easy to validate the program.

4:43 clgv: mpan: what topic is the course about?

4:45 mpan: that particular one is one I don't think I'll be taking any more, just because I have more stuff than I need and the combined homework is going to get messy mid-semester

4:45 so 1/2 my remaining classes that expect programming have no language preferences

4:47 clgv: mpan: I have had a course where one language was fixed, but I did it in another language anyway, since there was no checked homework. only solutions in the given language were presented.

4:49 mpan: anyway, going to start another class assignment in clojure, I guess

4:49 last time, some weird thing with seqs and laziness came up, but overall it felt nice

4:49 pisketti: Is there a way to explicitly fail a test in clojure.test?

4:50 clgv: mpan: sometimes it's better to avoid lazy if you have no benefit of it ^^

4:50 pisketti: print-tap-fail just prints stuff but doesn't fail the test

4:50 clgv: pisketti: returning false? or do you want to fail from within another function?

4:50 pisketti: I'm looking for something like fail in JUnitr

4:51 yes

4:51 I have a test util function

4:51 or several actually

4:52 clgv: pisketti: would throwing any specific exception work for you?

4:52 pisketti: With certain condition I want the whole test to fail

4:52 clgv: I guess that would do it but I'm surprised if that's the way to go

4:52 I would assume there is a way to explictily fail a test

4:53 clgv: pisketti: I dont know if there is something built-in like that. but It would have to use an exception as well

4:54 pisketti: okay, thanks

4:56 clgv: pisketti: I checked the source. there seems to be no such function to fail on purpose

4:58 pisketti: but you yould write your function in a short-circuiting way: with `or` or `and`

6:12 naeg: Why can't I :use clojure.core.logic? There is no installation needed, is it? (Clojure 1.4)

6:12 http://bpaste.net/show/s8UWDqWrCyjvPY71e9GW/

6:15 Cheiron_: Hi, how to handle MessagePack in Clojure? any library?

6:17 clgv: naeg: afaik it is still an external lib that you have to add to your project.clj

6:20 naeg: clgv: thanks, it's working now

6:32 kral: namaste

6:32 algernon: naeg: you need a dependency in your project.clj

6:34 naeg: algernon: thanks, yeah, figured that out already ;)

7:15 can I do a simple equality test inside a run* in core.logic using just plain =?

7:22 llasram: naeg: I've only played around with core.logic a little, but my understanding is that you need to `project` to do any non-relational operations

7:24 naeg: llasram: I'm trying to check columns of a connect four game: http://bpaste.net/show/bFmSVQnwiRpuOP1Fgf5B/

7:24 but with l/== it results into () and with = it doesn't result in anything

7:27 a simple test suggests that l/== is the right one though: http://bpaste.net/show/iuXYzyfiXXHkApolsuL6/

7:28 clgv: naeg: correct me if I am wrong but l/== should be unification right?

7:28 llasram: This really is the blind leading the blind, but I don't think expressions constructed the way you have them work.

7:29 Right, what clgv is saying, if I understand properly

7:29 naeg: I think so too, but I can't use =

7:29 clgv: naeg: did you read any intro on core.logic?

7:30 llasram: I think what need to do is map each entry in the board to a fresh logic variable, then perform unification across those

7:30 naeg: clgv: yeah, magical island of kanren

7:30 xeqi: (inc llasram)

7:30 lazybot: ⇒ 2

7:31 naeg: I'm not getting that one llasram? I'm only checking columns now and since I know the x already, there are only 6 different y's

7:31 xeqi: see https://gist.github.com/3217582#L23 where vars represents the sudoku board

7:33 llasram: naeg: Ok, so not the whole board, but the entries of interest. You need to have a function-local representation where you first unify a set of logic variable w/ the current board state, then unify the potential solution with that logic variable state

7:34 But yeah, like the Sudoku solver xeqi linked to. I'm really just going off of the examples I've seen, and it may be possible to express in a different way

7:35 naeg: llasram: putting together a vector of all the elements in the column and check whether the sublist ["X" "X" "X" "X"] appears in it?

7:36 that would be exactly what i'm doing with the rows already

7:37 llasram: I'm having trouble expressing this apparently. Let me repl up an example

7:38 naeg: llasram: I might have trouble understanding it, an example would be highly appreciated

8:01 llasram: naeg: Whew. I have been meaning to get some more core.logic practice :-) https://www.refheap.com/paste/4980

8:02 I don't believe this is the best way of expressing it, but does at least appear to work

8:14 naeg: llasram: now I understand what you meant before :P

8:17 llasram: naeg: Oh, good, because I realize now it wasn't quite how I described it :-) The cKanren finite domain stuff takes care of the intermediate representation for you. It's quite nice

8:20 naeg: llasram: I'm just wondering whether all those l/+fd could be replaced with a map-indexed

8:21 but I guess not

8:25 ro_st: technomancy: ping

9:52 cshell: If conj is polymorphic on the type, why isn't it a protocol?

9:54 S11001001: cshell: conj came first

9:54 chouser: cshell: in ClojureScript it is.

9:54 cshell: Are they planning on changing it in 1.5?

9:56 S11001001: cshell: if so, it would be in jira

9:57 chouser: Clojure was built with Java interfaces at the core, Java implementations on top of that, and finally clojure functions and macro on top of that. So in Clojure, conj is an interface method, IPersistentCollection.cons

9:57 cshell: So, if we made a new datastructure via deftype, we'd have to mixin something from the IPersistentCollection interface?

9:58 chouser: In Clojure, protocols and deftypes were built on top of that whole stack.

9:58 In ClojureScript, Protocols and deftype are at the bottom, and everything is built up from there.

9:58 cshell: S11001001, chouser: thanks, all this is very helpful!

10:01 chouser: cshell: so yes, in Clojure implement IPersistentCollection. I don't think that'll change in the foreseeable future.

10:01 cshell: that makes sense

10:02 chouser: Now, if cljs gets a JVM bytecode back end, and someone ports the cljs compiler from Java+Clojure to pure cljs...

10:04 casion: is there a way to change how sets check for equality between elements?

10:05 cshell: create a new function?

10:05 S11001001: casion: only for your own types

10:08 casion: hmm. Well I guess I need to rethink this whole thing then

10:09 I wanted to throw some byte-arrays into a set to get a collection of unique items

10:25 S11001001: casion: put a type around byte array

10:27 casion: (incidentally, this is also how you'd solve the "add your own implicit whatever" problem in haskell)

10:43 naeg: how could I write a predicate that declares that the first given coordinate is ascending (both x and y +1) to the second coordinate? (core.logic)

10:43 I guess I still have a wrong understanding of l/==

10:53 mindbender1: piggieback lists [org.clojure/clojurescript "0.0-1450"] as a dependency but lein reports it's inability to locate it.

11:06 casion: S11001001: I was hoping to avoid converting/casting to another type, and then back when I want to use it

11:06 as I do need to pass that byte-array to a java method in the future

11:09 cark: that's not really conversion or casting, only wrapping, a O(1) operation

11:10 S11001001: konrad hinsen corrected the fetch-val function

11:10 S11001001: and i've beeen working on implementing lenses

11:11 S11001001: not a library yet, but i've gone as far as the state-m lenses

11:12 casion: cark: you mean doing something like (seq (byte-array [stuff])) is O(1) ?

11:13 cark: you asked how to change the way sets are checked for equalitye

11:13 -e

11:14 casion: I'm confused now :|

11:17 clgv: casion: calling `seq` is O(1). it's just wrapping the given argument into a seq-implementation if it can

11:17 cark: the thing is that i don't know which interface (or protocol?) you need to implement in order to change equality

11:17 S11001001: clgv: seq won't work, but a newtype wrapper with cheap unbox will

11:18 cark: unknown falls back on Object equals/hashCode

11:18 cark: so you would use a deftype

11:18 clgv: S11001001: what? what should it work for except what its docstring says?

11:19 S11001001: I just commented the O(1) question...

11:19 S11001001: clgv: (identical? some-byte-array (??? (seq some-byte-array))) => true

11:20 casion: I wanted to do something like ##(into #{} [(byte-array [(byte 1) (byte 2)]) (byte-array [(byte 1) (byte 2)])])

11:20 lazybot: ⇒ #{#<byte[] [B@4cf181> #<byte[] [B@183713c>}

11:20 casion: except the = that set seems to use doesn't work obviously

11:20 clgv: S11001001: I have no idea what you want to tell me with that.

11:21 S11001001: clgv: you can't reverse that seq call in constant time

11:21 cark: well then seqing the byte arrays should do the trick

11:21 casion: cark: it does, but it's slow, and then I have to convert back to byte-arrays later

11:21 clgv: S11001001: no. but he didnt ask for that. just for the seq call

11:22 S11001001: clgv: casion: as I do need to pass that byte-array to a java method in the future

11:22 casion: using a deftype will give you O(1) wrapping and O(1) unwrapping

11:22 cark: clgv: then your other option is to wrap the byte arrays in a type, and override the equality thing, i don't know which interface has it. Trouble is that you still will need to loops across your arrays

11:22 clgv: S11001001: thats probably somewhere before the question ^^

11:23 cark: casion: not clgv !

11:23 S11001001: cark: Object

11:23 cark: alright

11:23 chouser: naeg: I don't know if you can "do numbers" in core.logic

11:24 S11001001: IIRC you can even do it with defrecord

11:24 cark: chouser: numbers over a domain, the *fd functions i think

11:24 casion: I guess I could just make a new type and call java.utils.Arrays/equals for =

11:24 S11001001: casion: don't forget hashCode

11:25 cark: chouser: dnolen talks about that toward the end of his incomplete talk

11:25 casion: S11001001: didin't even know about it in the first place

11:26 I'm as new to java as I am to clojure

11:26 (or oop or functional programming for that matter)

11:27 S11001001: casion: http://findbugs.sourceforge.net/bugDescriptions.html#HE_EQUALS_NO_HASHCODE

11:28 casion: I see, so I need to make sure hashCode returns the same value for this type then, correct?

11:28 S11001001: s,the same,a consistent,

11:29 casion: ok, thank you

11:29 and thank you cark

11:29 cark: only repeating S11001001's views =P

11:29 casion: all help is appreciated :)

11:30 chouser: cark: oh interesting. Didn't notice logic.arithmetic

11:32 casion: chouser: I'm starting to use clojure-jna, do you know if there's a good way to distribute cross-platform apps when using it?

11:33 I have distributable libraries for the target platforms

11:35 chouser: casion: no. We built a thing to help with that for LonoCloud, but it requires almost constant tinkering, and every new native dep adds unexpected requirements. This is one area where the JVM ecosystem is a complete mess

11:38 casion: chouser: ok

11:38 at least clojure-jna has helped figure out dealing with jna from clojure

11:39 chouser: good, I'm glad. That's an old lib. I suppose I should release a version to clojars or something.

11:43 casion: I'm currently using it for generating tests against the de facto C library that I'm more or less replicating in clojure, and I thought maybe I should just wrap that lib instead...

11:43 but I think that's obviously a silly idea

11:48 arrdem: is it legal to write a let form where the definition of some symbol is recursive?

11:48 chouser: arrdem: nope. But you may be able to use letfn instead

11:49 arrdem: thanks chouser, I thought not.

11:49 samrat: so, is Clojurescript One the place to get started with Clojurescript? any other recommended resources for cljs?

11:53 technomancy: samrat: a lot of people seem to have trouble with it since it's a bit outdated

11:53 cljsbuild seems to be the way to go

11:54 chouser: are you using lein to build jars that contain native components?

11:55 chouser: technomancy: yes, I suppose we are.

11:55 samrat: technomancy: thanks, I've already installed lein-cljsbuild.

11:55 technomancy: chouser: so are you using the native/ convention that extracts the contents at runtime or do you roll your own thing for getting them on the filesystem?

11:56 samrat: but I was kinda looking for a tutorial, on cljs basics

12:03 chouser: technomancy: I haven't looked at it myself in a while, so I'm having trouble remembering. Looks like we've got a chunk of code commented "derived from leiningen"

12:03 but we are using the native/ convention

12:03 arrdem: okay that's it. Screw fnparse. What are your favorite non-abandonware clojure parser libs?

12:03 technomancy: chouser: just wondering because that's completely undocumented =\

12:04 chouser: oh, I think the deal may be that we're deploying uberjars to places where we don't have lein, so we had to do our own unpacking? Would that make sense?

12:05 technomancy: yeah, makes sense

12:05 that's actually fairly common; I think overtone and lwjgl now do that

12:06 chouser: so we're relying on the native/ convention for getting dev envs set up right, and letting lein do that for us, but we extract the native libs ourselves when we have to

12:06 technomancy: yeah

12:06 I should probably formally extract that

12:06 chouser: But then each native lib comes with a java lib that may or may not try to do the object loading itself

12:07 And that loading needs to be done exactly once per JVM, which gets tricky when containers give you different copies of the same namespace in a single JVM, etc etc

12:08 technomancy: or yeah, I could leave that problem alone and let someone tackle it who has actually used native dependencies and knows what they're talking about =)

12:13 mindbender1: how can I possibly work with extjs from clojurescript

12:37 nz-: mindbender1: i think it should be possible, if e

12:37 if extjs isn't doing anything too tricky

12:37 mindbender1: for example clojurescript works just fine with query

12:38 with jquery that is

12:38 mindbender1: nz-: their codebase really looks clean. where do I throw a thrid party library

12:39 *third

12:40 nz-: I suppose the advice here still holds: http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html

12:45 dgrnbrg: hey, what is the recommended way for making UIs with clojurescript?

12:46 should I just use goog.ui through the FFI, or are there other libraries I should look into?

12:53 nz-: mindbender1: I used the same guide. there may be some problems with extern files if you want to use <script src="javascript.file.somewhere.js"> style for referencing external libs

12:54 mindbender1: there are some tools that can generate externs file for you, but they many times fail if library is using some weird techniques.

12:54 mindbender1: nz-: please share

12:54 nz-: i am using this library: http://leaflet.cloudmade.com/

12:55 problems occur if you use google closure compiler with advanced compilation that does name munging

12:56 mindbender1: nz-: how did you get around all this

12:59 nz-: i made externs file like this https://github.com/jsyrjala/ruuvi-ui/blob/master/closure-js/externs/leaflet-externs.js, first it is generated by a tool, but then I noticed that many of the methods are missing, so I added them manually

13:00 leaflet is using some kind of inheritance thing that the tool didn't understand

13:03 SegFaultAX|work2: postgresql continues to amaze me every single day.

13:03 nz-: and this is only problem if you use advanced optimization. if you use simple or no optimization, everything works out of the box

13:05 edw: Anyone having problems with nrepl spontaneously throwing an exception when typing into the repl?

13:06 "Unable to resolve symbol if-let"...

13:06 mindbender1: nz-: thanks a lot for sharing. This would make work a lot easier

13:06 edw: In Emacs.

13:07 nz-: dgrnbrg: i don't know about recommended but I am using enfocus for templating and probably jquery for the rest (via jayq clojure wrapper)

13:08 technomancy: edw: yeah, I think that's fixed in master

13:09 edw: For nrepl?

13:10 dgrnbrg: nz-: i'll check out jayq

13:13 mindbender1: edw: I get that error attimes what I do is to quickly put the cursor into the emacs repl buffer and delete the line very quickly

13:14 Frozenlock: seancorfield: In your clj-time library, is it possible to try multiple built-in-formatters simultaneously? I would like to parse some strings of the form "2012-09-10T00:00:00.000-04:00" and others "2012-09-10" and "2012/09/10".

13:18 edw: mindbender1, technomancy: Do you know what the problem or issue was? I'm looking through nrepl.el's change history and I don't see anything on point. (Or is the change in nrepl proper?)

13:19 mindbender1: edw: I'm not really sure but it must be related to not properly handling some input but take technomancy's advice on faith

13:20 I've upgraded too and I've not seen the error since then

13:21 technomancy: I haven't been following the development closely so I don't know what was behind the error

13:21 edw: Are we talking, again, about nrepl or nrepl.el?

13:21 mindbender1: edw: it's nrepl.el

13:21 edw: Ah. OK. Thank you.

13:22 technomancy: something about having to keep an emacs var in sync with the clojure-side namespace

13:23 not a big fan of that approach =\

13:24 edw: The problem seems to appear wheneverI use symbols with funky names, specifically "-main", those that's completely anecdotal.

13:24 s/those/though/

13:35 dgrnbrg: nz-: when you use jayq with clojurescript, do you use jqueryui as well?

13:35 pjb3: 2 things in Clojure that I got bit by today because they didn't do what I thought they would

13:35 (= false) # => true

13:35 (:foo :bar) # => nil

13:36 both of those feel like they should result in an error to me

13:36 I mean, I guess I get that = means "are all of these things equal"

13:36 nz-: dgrnbrg: no, not yet atleast. i am using twitter bootstrap though for css/layout

13:36 pjb3: pair those together and you get

13:36 edw: pjb, I strongly disagree with the = thing, but I'm sort of "WTF?!" about the (:a :b) => true thing.

13:36 pjb3: (if = (:foo :bar) ...

13:36 oops :)

13:37 chouser: Also: (when = :foo :bar (prn "the same!"))

13:41 Sgeo: edw, what (:a :b) => true thing?

13:42 noidi: pjb3, `get` returns `nil` if it can't look up the given key in the given map (or if the "map" is not an associative data structure). keywords are functions that look themselves up in the map provided as an argument.

13:43 given that `:bar` is not an associative data structure, looking up `:foo` in `:bar` returns `nil`

13:43 edw: ,(:a :b)

13:43 clojurebot: nil

13:43 noidi: hence, (:foo :bar) ;= nil

13:43 edw: Err, I meant that.

13:43 pjb3: noidi: it's the (or is the "map" is not an associative data structure) part that I disagree with there

13:44 noidi: pjb3, I agree that it should throw an exception intead

13:44 pjb3: throwing an exception in that case makes more sense than returning nil

13:44 ,(:foo nil)

13:44 clojurebot: nil

13:44 pjb3: I guess that makes sense though

13:45 noidi: and in general I disagree with Clojure's policy of only dealing with happy paths and having undefined behavior (tm) for invalid inputs

13:47 I've read somewhere that the current Clojure runtime forgoes error checking in order not to slow down the happy paths

13:47 s/error checking/input validation/

13:47 and, IIRC, at least at some point Rich has had plans for a separate debug runtime that does more validation

13:48 konr_trab: Is there a "split-when"-like function, that would behave like (split-when #(> % 2) [1 2 3 2 3 2 1]) -> [[1 2] [3 2] [3 2 1]]?

13:50 joegallo_: ,(partition-by #(> % 2) [1 2 3 2 3 2 1])

13:50 clojurebot: ((1 2) (3) (2) (3) (2 1))

13:50 joegallo_: and then combine the results in twos

13:51 (is one approach, there's probably a better one, though)

13:54 xeqi: ,(partition-by #(= % 3) [1 2 3 2 3 2 1])

13:54 clojurebot: ((1 2) (3) (2) (3) (2 1))

13:54 xeqi: ah, right

14:05 seancorfield: note to cark S11001001 - I raised ALGOM-4 on clojure-dev and Konrad responded pretty quickly - happy now your issue is addressed? :)

14:07 djanatyn: I don't understand how swap! works with atoms

14:07 S11001001: seancorfield: not really, since I liked the old behavior, and would rather TMACRO-1 be fixed :/

14:08 bja: cloudsearch

14:08 cark: seancorfield: yes, thank you !

14:08 hyPiRion: ,(split-with #(= % 3) [1 2 3 2 3 2 1])

14:08 clojurebot: [() (1 2 3 2 3 ...)]

14:08 hyPiRion: ,(split-with #(not= % 3) [1 2 3 2 3 2 1])

14:08 clojurebot: [(1 2) (3 2 3 2 1)]

14:08 cark: and sorry to S11001001 =)

14:09 joegallo_: djanatyn: how so?

14:09 you don't know how the implementation makes it do what it does, or you don't understand why swap! might be a useful thing to do?

14:09 that is, please elaborate.

14:10 also, if there was a question you wanted to ask, then just ask it. ;)

14:13 djanatyn: joegallo_: sorry, had to take a break

14:14 joegallo_: so when you use the swap! function, it take the atom's value and does (apply f atom-value)

14:15 and then it assigns that to the atom, right?

14:15 joegallo_: kindof

14:15 djanatyn: well, say I did (def foo (atom [1 2 3]))

14:15 (swap! foo +)

14:15 joegallo_: (apply f atom-value ANY ARGS YOU PROVIDED)

14:15 djanatyn: (apply + [1 2 3]) is 6

14:15 joegallo_: think of it this way:

14:16 (def f (atom []))

14:16 xeqi: ,(let [x (atom [1 2 3])] (swap! x +) @x)

14:16 clojurebot: #<ClassCastException java.lang.ClassCastException: Cannot cast clojure.lang.PersistentVector to java.lang.Number>

14:16 seancorfield: S11001001: sign a CA, submit a patch :) at least if you have a signed CA you can join clojure-dev and at least raise the issue there to get feedback...

14:17 xeqi: ,(let [x (atom [1 2 3])] (swap! x (partial apply +)) @x)

14:17 clojurebot: 6

14:17 joegallo_: (swap! f conj 1)

14:17 it will (conj [] 1) -> [1] and makes that the new value of the atom.

14:17 cark: ,(let [x (atom [1 2 3])] (swap! x (partial apply +)) @x)

14:17 clojurebot: 6

14:17 djanatyn: oh, cool

14:18 oooooh! so I can do (swap! some-map-atom-thing assoc :foo nil)

14:19 joegallo_: bingo

14:19 djanatyn: that's useful!

14:19 joegallo_: that's why you want swap!

14:19 djanatyn: thanks for explaining it

14:19 joegallo_: np

14:25 pjb3: What's the easiest way to subtract one vec/seq from another?

14:26 gfredericks: ,(map - [1 2 3] [50 0 -6])

14:26 clojurebot: (-49 2 9)

14:27 Frozenlock: clojure.set/difference ?

14:27 casion: subtract in what way?

14:27 gfredericks: indeed

14:27 Hodapp: set difference and vector difference are very different things

14:27 gfredericks: what is vector difference? multiset difference?

14:28 pjb3: I mean get all the elements of a seq/vec that aren't in another

14:28 Hodapp: gfredericks: what you did is vector subtraction

14:28 pjb3: gfredericks: that looks good

14:28 gfredericks: Hodapp: oh you mean vector like math-vector

14:28 pjb3: er, not subtract though, I guess include?

14:29 Hodapp: pjb3: you need set difference, which I think is what Frozenlock gave

14:29 emezeske: pjb3: That sounds like a set union

14:29 casion: you want the union of 2 vectors?

14:29 Hodapp: union is something else

14:29 gfredericks: yeah but you have to convert them to sets first

14:29 pjb3: no, the difference

14:29 gfredericks: to use the set functions

14:29 ,(clojure.set/difference #{7 38 3 5 4 2} #{4 38})

14:29 pjb3: you don't *have* to convert them to sets

14:29 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set>

14:30 gfredericks: &(clojure.set/difference #{7 38 3 5 4 2} #{4 38})

14:30 lazybot: ⇒ #{2 3 5 7}

14:30 pjb3: but I guess that is the easiest way

14:30 gfredericks: &(clojure.set/difference [7 38 3 5 4 2] [4 38])

14:30 lazybot: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.IPersistentSet

14:30 gfredericks: pjb3: to use clojure.set I meant

14:30 emezeske: ,(keep #{1 2 3} [42 5 1 8 2 89 3])

14:30 clojurebot: (1 2 3)

14:30 casion: Hodapp: isn't set difference the complement of the union of sets?

14:30 emezeske: ,(keep #{1 2 3} [42 5 1 8 2 89])

14:30 clojurebot: (1 2)

14:31 emezeske: pjb3: ^

14:31 If you really don't want to convert to a set

14:32 aperiodic: casion: that's the symmetric difference

14:34 casion: assuming you meant intersection, not union

14:34 casion: aperiodic: I meant union

14:35 I'm researching it atm, I was pretty sure how I understood it was correct… but I wouldn't be surprised it it wasn't

14:37 XPherior: Can Noir's defpage take a docstring?

14:37 Having trouble making it parse.

14:37 muhoo: something bizarre has happened to my brain. stuff like (apply map vector (partition 3 (range 10))) is just rolling off my fingers without my thinking about it too much

14:37 Hodapp: casion: perhaps, but it's certainly not the same as union except maybe when the null set is involved

14:38 aperiodic: casion: oh. well, the complement of the union is just everything in the universe that's not in any of your sets. that doesn't have much to do with the difference between your sets.

14:39 muhoo: XPherior: i don't think so

14:40 XPherior: muhoo: Boooo :(

14:40 muhoo: XPherior: if you look at the code, it has a defn ~fn-name. there's a map there for metadata (::url, ::action, etc) , but docstring doesn't seem among them.

14:40 uvtc: muhoo: `(map vec (partition 3 (range 10)))`

14:40 muhoo: uvtc: even better, thanks :-)

14:40 XPherior: muhoo: Hum, okay. Thanks for the info. :)

14:41 muhoo: XPherior: my personal experience is, if you start banging into walls in noir, blow it off and just use straight compojure

14:41 casion: aperiodic: I think maybe I phrased myself wrong, I thought set difference was the union of A and the complement of B

14:42 XPherior: muhoo: Yeeeah, I want to. This was started in Noir by someone else.. Maybe I should just go ahead and do it anyway

14:44 muhoo: uvtc: though, what i was doing, was swapping rows and columns in the array, which (apply map vector) does

14:45 aperiodic: casion: are you sure you're not confusing union with intersection? it can be defined as the *intersection* of A and B's complement

14:46 casion: aperiodic: ah. I was mixing them up

14:53 nbeloglazov: What editor (not IDE, vim or emacs) for windows has clojure syntax higlighting?

14:54 And free

14:54 casion: sublimetext does

14:54 but it is not free

14:54 emezeske: maybe notepad++?

14:55 casion: and those are some weird requirements?

14:55 why can't you use anything else?

14:56 S11001001: nbeloglazov: install cygwin, x, gnome, gedit, maybe gedit has clojure

14:56 nbeloglazov: or maybe relax some of those constraints

14:56 Frozenlock: Not Vim or Emacs is a tight constraints.

14:56 nbeloglazov: I want it to be easy. Emacs and vim aren't easy. And IDE has too much stuff in them. I want just leiningen + editor.

14:57 casion: netbeans and intellij are pretty easy

14:57 and so is eclipse

14:57 (and emacs and vim OM)

14:57 imo*

14:57 nbeloglazov: casion: and what is not easy?

14:57 Hodapp: nbeloglazov: that's all I want too, but lein-tarsier was kind of a rough route.

14:57 uvtc: muhoo: Ah! Thanks for pointing that out! Passing `map` multiple coll's has it pass one from each into the func you gave it.

14:57 casion: you can just close all the side-bars in eclipse and treat it like a 'text editor' if you want

14:58 Hodapp: the Clojure support in IntelliJ IDEA still seems a bit buggy when Leiningen is added

14:58 casion: nbeloglazov: in this context, no idea.

14:58 muhoo: uvtc: yes, that's the magic that was delighting me. map takes several collections and threads them together. awesome.

15:00 casion: nbeloglazov: appears that jedit has clojure syntax highlighting

15:00 nbeloglazov: http://plugins.jedit.org/plugins/?Clojure

15:00 uvtc: casion, nbeloglazov : I tried jedit a while ago, but indentation didn't work as I'd hoped.

15:01 casion: you can treat emacsw32 like a 'normal text editor' if you so wished

15:01 nbeloglazov: I want to teach some clojure at my university. And thinking what environment will be best for windows users. I thought leiningen + editor. Easy to install and use, good for start. Every IDE comes with it's own plugins for clojure and I fear to get lost trying to handle all of them.

15:01 Thanks I'll check jedit

15:02 casion: nbeloglazov: why not just suggest eclipse? it works on the 3 major platforms nearly identically

15:02 chouser: nbeloglazov: you might consider lighttable

15:03 pandeiro: how do i get project-specific profiles to load when i am using nrepl in emacs?

15:03 muhoo: nbeloglazov: indeed, lighttable sounds ideal for that application

15:03 nbeloglazov: casion: I can't say why eclipse is better than intellij or netbeans :) Personally I'm intellij guy.

15:04 chouser: is it free? I remember some stuff about licensing on kickstarter

15:05 chouser: nbeloglazov: you can use it for free. I'm not sure if there are any constraints but I imagine the authors would be happy to support educational use if any extra permission were required.

15:05 uvtc: nbeloglazov: recent lightnable news http://www.chris-granger.com/2012/08/17/light-table-reaches-010/

15:07 nbeloglazov: I haven't played a lot with lighttable. Does it have integration with lein?

15:08 chouser: nbeloglazov: indeed lein is now built in

15:08 nbeloglazov: chouser: hm. Nice. I'll take a look right now. Thanks a lot

15:08 xeqi: pandeiro: you're going to need to use `lein with-profiles ... nrepl :headless` and M-x nrepl

15:09 pandeiro: xeqi: hm ok

15:09 is the idiomatic way to do it providing a {:user {:injections ... }} in the project.clj for each different project? easier than creating special keys in ~/.lein/profiles.clj and somehow loading them when firing up nrepl?

15:09 uvtc: nbeloglazov: If installing Emacs 24 on MSWindows isn't too bad, you might try Emacs. Here's a little Clojure + Emacs article I wrote which you might find useful: http://www.unexpected-vortices.com/clojure/10-minute-emacs-for-clojure.html (it's aimed at GNU/Linux users though).

15:12 ivan: La Clojure needs nREPL

15:12 nbeloglazov: uvtc: Thanks, I'll include it to list of available options. But going to make plain editor or lighttable as main option.

15:14 uvtc: nbeloglazov: You can use Emacs as a plain editor.

15:14 xeqi: pandeiro: what are you using in :injections? I wouldn't see much point in the :user profile in a project.clj vs just using the keys normally

15:16 pandeiro: xeqi: i just would like to cd to a project dir, open emacs, and nrepl-jack-in with it custom loading some ns's depending on the project

15:26 melipone: hello! how do I represent a complex number in clojure?

15:27 chouser: melipone: get a java lib that supports complex numbers, or if you want to roll your own use a vector of two numbers or a deftype

15:31 ordnungswidrig: slightly off topic: is anybody using emacs with multiple frames in a tiling wm?

15:31 muhoo: ordnungswidrig: i am. ion3

15:32 casion: ordnungswidrig: I do in dwm

15:32 xeqi: I do in xmonad

15:33 ordnungswidrig: muhoo: do you have special configuration like oneoneone?

15:33 to avoid new emacs windows and force new frames, global minibuffer or like that?

15:34 muhoo: ordnungswidrig: my .emacs has evolved over the past 8 years, i don't even remmeber what everythign in it does anymore :-) but i have (setq pop-up-windows nil) for sure

15:34 ordnungswidrig: *g*

15:35 muhoo: I wonder how you'd perform with emacs -q

15:36 muhoo: i would be completely helpless

15:36 many of my keybindings are non-standard

15:36 casion: I've taken special care to be -q compatible

15:36 muhoo: actually, if i'm on a machine where i don't have my .emacs around, i just use vim instead.

15:37 casion: though I'd probably trip up on my constant abuse of hippie-exand

15:37 * muhoo is bilingual

15:37 Sgeo: hippie-expand?

15:37 ordnungswidrig: muhoo: haha

15:37 casion: Sgeo: http://emacswiki.org/emacs/HippieExpand

15:37 uvtc: muhoo: Just curious, do you have a binding for scrolling the window up/down by one line? I use M-n/p for that. Surprised Emacs doesn't come ootb with keybindings for those.

15:37 ordnungswidrig: emacs users adopt to there random choice of emacs features and extensions

15:38 uvtc: you can bind the scroll-lock key to a minor mode that remaps C-n C-p :-)

15:38 muhoo: uvtc: i have scroll-up-command bount to <next> it seems, which is downarrow

15:38 ordnungswidrig: uvtc: finally a use for that key

15:39 uvtc: Not sure my keyboard has a "next" key ... hm...

15:39 muhoo: i dunno. my .emacs, .ion config, and .Xmodmap are so tangled and intertwingled, i'd be lost without all of them.

15:39 casion: not even the space cadet keyboard has a next key

15:39 uvtc: ordnungswidrig: I think I need my C-n/p. :)

15:39 ordnungswidrig: uvtc: no, only remap when scrolllock is activated :)

15:40 * ordnungswidrig has no scrolllock key, he notices

15:40 muhoo: sorry, not <next>, <down>

15:40 uvtc: ordnungswidrig: Hm. Sounds like you're going modal on us. :)

15:40 casion: uvtc: why would you want to scroll a line at a time?

15:40 ordnungswidrig: uvtc: minor-model, to be exact

15:40 muhoo: and, control+<down> appears to be <next>

15:40 casion: I can't say that I've ever had that desire, so I'm curious

15:40 uvtc: casion: I guess it's the artist in me; I like to frame what I'm working on just so. :)

15:41 ordnungswidrig: hmm, C-down is forward-paragraph, I did not know

15:41 muhoo: i think you could spend 30 years in emacs and still come across stuff you didn't know.e

15:42 uvtc: muhoo: Oh, I see. But then I'd have to move my hands off the home row to scroll the window around. :) Wouldn't want to have to resort to *that*... :)

15:42 muhoo: it's not an editor, it's a lifetime-long easter-egg-hunt

15:42 ordnungswidrig: isn't there a "did you know?" mode?

15:42 casion: uvtc: why don't you use C-l then?

15:42 recenters the buffer on the point

15:42 uvtc: casion: Oh, certainly. That too.

15:43 pandeiro: how can i make a ns (say foo.core) expose a few other ns' fns when it is used?

15:43 ordnungswidrig: pandeiro: you'd have to alias them into foo.core

15:43 muhoo: pandeiro: (ns foo.core (:use [something else :only [bar baz]])) ?

15:44 casion: oh neat, I didn't know C-l could take an argument

15:44 ordnungswidrig: the other day I tried to build a minor mode to pin buffers based on major mode or regex on name to a (emacs) window. is the anything like that, but that actually works?

15:44 pandeiro: muhoo: no i think aliasing is what i'm after

15:44 casion: that's useful

15:44 ordnungswidrig: casion: like center as 5th line from top?

15:44 casion: ordnungswidrig: yes

15:45 naeg: how can I apply a vector of functions (let's say [print println print]) on a vector of data in squence (e.g. ["hi" "richard" "regards"])?

15:45 pandeiro: i want to have a ns that i can 'use' just to load an assortment of different stuff into the current repl ns

15:45 ordnungswidrig: naeg: ,(doc for)

15:45 casion: naeg: juxt?

15:45 ordnungswidrig: &(doc doseq)

15:45 lazybot: ⇒ "Macro ([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."

15:46 muhoo: casion: https://www.refheap.com/paste/4991

15:47 naeg: ordnungswidrig: it's not possible with mapv, is it?

15:47 (or with map) - in fact want to return a vector at the end

15:48 casion: ,((apply juxt [:a :b]) {:a 1 :b 2 :c 3 :d 4})

15:48 clojurebot: [1 2]

15:52 muhoo: ,(select-keys {:a 1 :b 2 :c 3 :d 4} [:a :b])

15:52 clojurebot: {:b 2, :a 1}

15:53 muhoo: ,(-> {:a 1 :b 2 :c 3 :d 4} (select-keys [:a :b]) vals)

15:53 clojurebot: (2 1)

15:53 abalone: is there a clojurescript channel? or might i ask an easy question here?

15:53 gfredericks: ask!

15:54 abalone: i'd like to return two pieces of data from my cljs fn. like ["a" "b"]. how does js code refer to the first part and the second part?

15:55 gfredericks: you're dealing with the return value from raw javascript?

15:55 abalone: yeah.

15:55 raw js is the codemirror part

15:55 ivan: abalone: it'd be an Array in JavaScript with a [0] and [1]

15:55 abalone: myFn(args)[0] ?

15:55 gfredericks: easiest thing is to figure out how to return an array instead of a vector

15:55 I would not expect ivan's suggestion to work

15:55 abalone: it doesn't for me

15:56 ivan: right, I assumed you did the conversion already ;)

15:56 abalone: oh, how?

15:56 naeg: casion: juxt seems not to be what I want. I want: take first func of func-vector, apply to first data in dataset, take second ...

15:56 ivan: there's a cljs->js somewhere

15:56 muhoo: naeg: reduce?

15:56 jrajav: Is 4clojure.com an old site or is it just down right now?

15:56 broquaint: Just down right now, jrajav.

15:57 naeg: muhoo: nope, the function should change in sequence like the dataset - not always same func

15:57 I guess I have to do this with doseq

15:57 metellus: ,(map #(%1 %2) [inc dec] [1 1])

15:57 clojurebot: (2 0)

15:57 ivan: 4clojure Registrar: GODADDY.COM, LLC

15:57 jrajav: Just came back up :)

15:57 metellus: something like that?

15:57 naeg: metellus: seems right :o

15:58 metellus: I think there's something nicer than #(%1 %2) that you can use, though

15:58 naeg: tried around with map, but didn't get it to work, let's see

15:59 muhoo: naeg: ##(map #(%1 %2) [identity (partial str "foo-")] [2 "baz"])

15:59 lazybot: ⇒ (2 "foo-baz")

15:59 naeg: metellus: how do you mean nicer? I could use (fn [func data] (func data)) instead

15:59 muhoo: yeah, that's what he came up with now too, thanks

15:59 muhoo: clearer maybe ##(map #(%1 %2) [inc dec] [2 4])

15:59 lazybot: ⇒ (3 3)

15:59 metellus: naeg: I think there's an actual built-in function that does it, but I could be wrong

15:59 muhoo: metellus: doh, i was just a minute too late :-)

16:02 hyPiRion: ,(map reduce [inc dec] [0 1] (repeat nil))

16:02 clojurebot: (0 1)

16:02 muhoo: i think there's a function in useful that does it

16:02 hyPiRion: oops

16:03 abalone: ivan: you mean cljs-37 in jira?

16:04 hyPiRion: ,(map apply [inc dec] [1 2] (repeat nil))

16:04 clojurebot: (2 1)

16:04 hyPiRion: eventually, if you're not scared of it

16:04 (map (comp eval list) [inc dec] [1 2])

16:04 ivan: abalone: yeah. I think someone also might have an implementation in some CLJS library. I forgot which.

16:05 github search might find it

16:05 hyPiRion: ,(map trampoline [inc dec] [1 2])

16:05 clojurebot: (2 1)

16:05 hyPiRion: Well, maybe not idiomatic, but hey.

16:06 ivan: abalone: hmm, maybe just (array)

16:06 * ivan reads the implementation

16:07 gfredericks: array looks like it works on himera

16:08 gtrak: hyPiRion: lol...

16:09 what the heck is going on there?

16:09 hyPiRion: going on where?

16:09 gfredericks: ,(map trampoline [constantly dec] [1 2])

16:09 clojurebot: (1 1)

16:09 gtrak: the last two examples look like some serious obfuscation

16:09 hyPiRion: ,(map trampoline [comp apply] [+ -])

16:09 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (1) passed to: core$apply>

16:10 llasram: &(map deliver [inc dec] [0 1])

16:10 lazybot: ⇒ (1 0)

16:10 hyPiRion: ,(map trampoline [comp complement] [+ #([%]0)])

16:10 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox$eval426$fn>

16:11 hyPiRion: ahh.

16:11 gtrak: deliver is kind of an apply

16:12 llasram: Only as an implementation detail. Depending on that behavior is probably a way to end up crying later :-)

16:12 hyPiRion: ,(map trampoline [comp some-fn every-pred] [+ * -])

16:12 clojurebot: (0 nil true)

16:12 gtrak: except it will never change b/c it will break existing code ;-)

16:12 i guess it does say 'alpha'

16:13 hyPiRion: gtrak: Code will never break if you don't upgrade. :)

16:13 gtrak: any clojure 1.2 stalwarts in existence?

16:15 hyPiRion: I left 1.2 when I found out that ##(#{2} (denominator 1/2)) returned nil in 1.2 and lower.

16:15 lazybot: ⇒ 2

16:16 gtrak: oh, that's a little weird, I would've that that would work

16:16 since 1.2 had rationals and stuff

16:17 /s/that/thought/

16:18 hyPiRion: well, the issue was that the denominator was a bigint, while the element in the set was a Long

16:18 gtrak: ah, .hashCode

16:24 naeg: how can I make core.logic available in my repl? when there is no project.clj?

16:25 gtrak: naeg: lein2 supports some kind of default profile, but in lein1 I would just make a project for stuff like that, it's no big deal

16:27 naeg: glad I'm on arch ;)

16:30 gtrak: I'm not really a fan of package maintainers decisions on anything to do with java :-)

16:31 though recently I noticed ubuntu faking out a maven repo in its installation of dependency libs for java applications

16:31 naeg: gtrak: that's why I'm using openjdk 1.6 from the AUR and not jre 1.7 from official

16:31 gtrak: why not 1.7? it's quite a bit faster

16:32 technomancy: gtrak: is it a transparent caching proxy?

16:32 naeg: I have no idea why - but lighttable doesn't work with java 1.7 (for me)

16:32 gtrak: technomancy: I didn't dig into it really

16:32 technomancy: gtrak: that's what fedora is doing, and it sounds like an OK idea though the effort/payoff is really really low

16:32 naeg: reported it, but nobody seems to care about the issue

16:32 gtrak: technomancy: I googled and this came up: http://wiki.debian.org/Java/MavenRepoSpec

16:33 technomancy: ugh; yeah, mvn and apt are fundamentally incompatible; they have conflicting design goals

16:33 getting JVM libraries through apt is stupid unless it's just to support an application.

16:34 gtrak: technomancy: about 4 years ago I tried to use eclipse that way and never looked back.

16:34 ordnungswidrig: technomancy: i wasted many days some years ago, trying to even make maven itself go into debian.

16:34 gtrak: now anything java related except the jdk itself is a script in ~/bin

16:34 technomancy: ordnungswidrig: well that's different; it's an application.

16:35 ordnungswidrig: technomancy: indead, but it showed the deep madnes of maven. you could not compile it from sources. :-)

16:35 FTBFS

16:36 technomancy: ouch

16:36 ordnungswidrig: technomancy: leiningen would be easy, it's a shellscript :)

16:37 technomancy: not really; leiningen needs itself to build

16:37 https://github.com/technomancy/leiningen/issues/745 =(

16:37 llasram: Self-hosting is a feature!

16:37 ordnungswidrig: hmm, I'm not familiar with the currenct debian packaging requirements, I must confess.

16:37 gtrak: it's nice for it to be in the repo for people to try, but any serious user is going to do it manually probably

16:38 technomancy: gtrak: the existing deb for lein1 works wonderfully

16:38 ordnungswidrig: gtrak: there might be applications that need leiningen to be built from source.

16:38 gtrak: ordnungswidrig: :-) one can only hope

16:38 ordnungswidrig: that was my motivation for trying to package maven.

16:38 technomancy: I've heard horror stories about people trying to use the one in arch and macports though.

16:38 brew's a bit of a mess too

16:39 but the .deb is rock-solid

16:40 ordnungswidrig: technomancy: talk about maven or lein?

16:40 technomancy: ordnungswidrig: lein specifically, though I never had trouble with maven back in the day

16:41 ordnungswidrig: I used the curl method :)

16:43 technomancy: yeah, it's just one more hurdle for potential newcomers though

16:44 ordnungswidrig: especially on windows.

16:44 technomancy: of course if they're really interested they won't care, but for someone who's on the edge, the fact that they can't just use apt-get may just turn into, "Oh, but it does have Haskell; maybe I should try that instead..." =)

16:45 ordnungswidrig: sounds like a well tought decision.

16:45 gtrak: ha, maybe I'll just drop clojure and learn Haskell....

16:46 technomancy: well if it was just up to me I don't think I'd have the stamina to untangle the requirements for debian packaging, but luckily I have a helpful DD

16:46 ordnungswidrig: well, they opt for node.js, I suppose.

16:46 technomancy: gtrak: I know you've thought of it; don't lie =D

16:46 gtrak: too bad I actually have a job doing clojure!

16:47 technomancy: haskell programs boot in like zero milliseconds

16:47 gtrak: oh well... debian supports haskell way better

16:47 ordnungswidrig: haskell will be the first language ported onto a quantum computer.

16:48 Hodapp: bahahahaha quantum computer

16:48 ordnungswidrig: lisp will be second, as soon as somebody figures out how to entangle to cons cells

16:48 emezeske: gtrak: Why do you need debian to support clojure? Doesn't lein take care of that?

16:49 gtrak: emezeske: total sarcasm, sorry :-). I'm fine installing lein manually.

16:49 ordnungswidrig: emezeske: lein needs clojure as a dependency.

16:49 technomancy: emezeske: installing by hand is kind of crappy when you're used to a good package manager

16:49 even if it's not much work, it's the principle of the thing

16:49 gtrak: but that's because I've learned to expect anything java-related to be borked on a package-manager

16:50 technomancy: emezeske: "Same reason we don't wear animal skins or hunt the wooly mammoth! Because we're not savages." http://www.penny-arcade.com/comic/2005/06/06

16:50 thorbjornDX: hah, I just typed :wq into a repl

16:50 ordnungswidrig: gtrak: that is a good summary :)

16:50 emezeske: gtrak: Oh, heh

16:50 technomancy: lol

16:50 hyPiRion: thorbjornDX: Oh, just wait until you do C-x C-c to get out of chrome.

16:50 emezeske: technomancy: I did not notice gtrak's sarcasm -- I thought he wanted to manage like clojars jars via debian's packaging

16:50 metellus: thorbjornDX: it's valid clojure!

16:51 thorbjornDX: metellus: which is why I laughed :D

16:51 technomancy: oh heavens no

16:51 but applications, absolutely

16:51 gtrak: emezeske: I don't care either way, I'm not on JVM because it's desktop app story

16:52 it lost that fight a long time ago

16:54 SegFaultAX|work2: Is there a good way to start a stand-alone nailgun server outside of a clojure project?

16:55 muhoo: i vaguely remember hearing of a lein2 or nrepl/reply/something plugin that'll pprint all the output from every form in the nrepl?

16:55 denlab: 4clojure down ?

16:58 muhoo: where's the right place for that? i suppose i could hack up some elisp that throws (pprint ...) around every form it sends to the nrepl server, but not sure if that'd be the right thing

17:00 ordnungswidrig: muhoo: i think nrepl has something like middleware that could wrap the expr and pprint the result

17:01 technomancy: there's an example in `lein help sample` of such a middleware

17:09 TimMc: denlab: Their registrar is under DDoS right now, so I wouldn't be *too* surprised.

17:12 SegFaultAX|work2: Is it just me or has Hickey given the same basic talk about Datomic under like 3 or 4 different titles?

17:15 muhoo: technomancy: thanks

17:18 naeg: core.logic: am I getting insane or how can this be true: http://bpaste.net/show/JRAEZ5WKPcozJ3NNouAj/

17:18 gtrak: hey guys, when's ballpark date for clojure 1.5?

17:18 Raynes: 2050

17:18 gtrak: hmm....

17:19 Raynes: standard deviation?

17:20 how about, is there a way I can work around this issue in 1.4?: http://dev.clojure.org/jira/browse/CLJ-1034

17:20 muhoo: ah, :nrepl-middleware [my.nrepl.thing/wrap-amazingness ...

17:20 ordnungswidrig: naeg: nice

17:21 naeg: ordnungswidrig: Am I not insane? This should not be right at all, right?

17:22 ordnungswidrig: naeg: (l/+fd d 1 c) should not match on 3 / 1

17:22 naeg: ordnungswidrig: yeah, that's really strange. smells like I have to report an issue

17:22 ordnungswidrig: naeg: I'm no expert in core.logic, though. mabybe in the fd [1 3 4 5] is (= 3 ( 1 + 1))

17:25 naeg: ordnungswidrig: but that wouldn't make much sense imo

17:26 samuelj: Hey, i'm trying to get started with compojure and I get this error on lein compile:

17:26 Exception in thread "main" java.io.FileNotFoundException: Could not locate ring/middleware/head__init.class or ring/middleware/head.clj on classpath: , compiling:(route.clj:1)

17:26 I'll post my source in a pastie, i'd be so grateful for any help! Really very confused :s

17:27 ordnungswidrig: naeg: for a fd [:foo :bar :baz :qux] (= :baz (+ 1 :bar)) makes sense.

17:27 naeg: in a way

17:27 weavejester: samuelj: It's likely one of your dependencies is requiring an older version of Ring, and is overriding Compojure's

17:28 djanatyn: https://gist.github.com/3693973 -- I was having a lot of fun slacking off in class earlier today

17:28 naeg: ordnungswidrig: but +fd is for addition/subtraction, not "chosing the next/previous element of the fd"

17:28 samuelj: weavejester, thanks! How can I resolve it? My project.clj is here: http://pastebin.com/NKmpKDSm

17:28 djanatyn: I played around with records and made a little grid/entity thingy

17:28 weavejester: samuelj: Normal "soft" dependencies are resolved depth first - the closer the dependency to your project, the more priority it has.

17:28 djanatyn: it was nice to play with records

17:28 weavejester: samuelj: But occassionally there will be "hard" dependencies that specify an exact version - these can cause problems.

17:29 djanatyn: is there anything that I could change that you notice immediately, to make it more idiomatic clojure?

17:29 I didn't use protocols because I didn't really see the need to

17:29 samuelj: weavejester can I not specify versions and let lein resolve them?

17:29 djanatyn: I think that was possibly a bad idea

17:29 weavejester: samuelj: Oh, but in this case you've explicitly put the wrong version in your project file

17:30 samuelj: Compojure 1.1.3 depends on Ring 1.1.0 or above.

17:30 samuelj: ah ok! thanks :)

17:30 djanatyn: I already see some things I can change, like (empty? (filter #() .. )) to (some #() .. )

17:30 samuelj: so I'll check required versions in future :)

17:30 weavejester: samuelj: The latest version is 1.1.5. Your Ring dep in your project file overrides the one Compojure adds.

17:31 samuelj: lein deps :tree is a good way of checking deps

17:31 samuelj: sweet, thanks weavejester

17:34 Raynes: uvtc: Dejected. lol

17:34 Made me smile.

17:34 <3

17:34 uvtc: No sad docstrings.

17:34 :)

17:35 Raynes: I'll let technomancy be the mediator on that one. :p

17:35 It looks like he took most of my cute out anyways, so probably want to merge this too.

17:36 technomancy: I dunno, the no-jure thing was more like deranged yelling =)

17:37 deranged in a good way though

17:37 but I like the notion of being able to do `rgrep FIXME .` after generating a project

17:37 Raynes: FIXME: I don't do a whole lot

17:37 :P

17:37 Seriously though, I don't mind.

17:37 uvtc: :( docstring doesn't feel good about self.

17:37 Raynes: Whatever you think is best.

17:38 muhoo: i'd suggest prohibiting projectin names with "*-clj" or "clj-*"

17:38 uvtc: FIXME: you're going to love the docstring that gets written here!

17:38 technomancy: muhoo: strongly tempted =)

17:38 maybe at least emit a warning

17:39 Raynes: muhoo, technomancy: I'd support that.

17:39 clj-stopwiththefuckingnames

17:39 muhoo: a more useful, but perhaps too complected, warning would be if it checked clojars and github to see if the name was already taken.

17:39 technomancy: clj-namesarehard

17:40 uvtc: My understanding was that (A) Clojure libraries that wrap or otherwise provide access to an underlying Java library are often named "clj-foo", and (B) Clojure libraries that provide their own implementation of a known library are often named "foo-clj".

17:40 technomancy: I suspect that's more coincidence than intention

17:40 muhoo: more lik, there's no rationale, and clj- and -clj are just lacks of creativity

17:41 Raynes: If I can't think of a name I just ask technomancy.

17:41 ordnungswidrig: naeg: the examples specify the domain as (domain 1 2 3 4 5 6 7 8 9)

17:41 Raynes: He always gives me a name!

17:41 Speaking of...

17:41 scriptor: lein should come with a random name generator

17:41 uvtc: Good idea. I propose we name it clj-random-name-generator.

17:41 muhoo: scriptor: that was the next thing, point them to a list of literary characters. now we're getting *real* complected.

17:42 hyPiRion: uvtc: What java-library does it wrap?

17:42 uvtc: Or random-name-gen-clj

17:42 hyPiRion: I'd just call it adskdashe

17:42 that's random.

17:42 muhoo: i knew wa guy who was a sysadmin at disney, where they'd run around raiding new film development teams for character names whenver they got a new batch of servers in.

17:42 uvtc: hyPiRion: My joke seems to have flopped. :)

17:43 muhoo: uvtc: name-generatejure

17:43 naeg: ordnungswidrig: ...so? not getting it

17:43 hyPiRion: muhoo: turn of lein ironic first.

17:44 on*

17:44 naeg: ordnungswidrig: (apply l/domain [1 3 4 5]) = (l/domain 1 3 4 5)

17:44 ordnungswidrig: naeg: you defined it as (domain [1 3 4 56)

17:44 Moses: Hi, looking for help with this problem : http://pastebin.com/W2r1J38g

17:44 ordnungswidrig: I see.

17:45 muhoo: i have an intensly stupid question: how can i pull the raw ring request out from inside a compojure handler?

17:45 uvtc: muhoo: I've got the best Clojure-name-pun saved for just the right rainy day.

17:45 weavejester: muhoo: (GET "/" request …)

17:45 naeg: ordnungswidrig: (just doing this because there is actually a variable refering to a vec of numbers instead of [1 3 4 5])

17:45 hyPiRion: Moses: You're using ratios, while I guess Perl is using floats

17:45 weavejester: muhoo: Or (GET "/" {:as request} …)

17:46 muhoo: Or (GET "/" [:as request] ...)

17:46 ordnungswidrig: Moses: why using mapv where map will do? and add some type hints to force primitive types, not objects for numerics

17:46 muhoo: weavejester: thanks!

17:46 Moses: Thank you hyPiRion and ordnungswidrig

17:47 naeg: ordnungswidrig: but I'm really unsure too whether I misunderstood +fd or infd

17:47 closing the issue won't be that much of an effort though

17:48 hyPiRion: ,(time (double (reduce + (map / (range 5000) (range 1 5001)))))

17:48 clojurebot: "Elapsed time: 5271.078789 msecs"

17:48 4990.905491147016

17:48 hyPiRion: ,(time (double (reduce + (map / (map double (range 5000)) (map double (range 1 5001))))))

17:48 clojurebot: "Elapsed time: 169.688312 msecs"

17:48 4990.905491147009

17:49 gfredericks: off by 5e-12 or so

17:50 Moses: Thank you hyPiRion, got it handling 500k now

17:51 Mapping the values to doubles makes it very fast.

17:51 naeg: llasram: ping

17:51 hyPiRion: Moses: you're welcome :)

17:56 llasram: naeg: Hey, what's up?

17:57 naeg: llasram: hey, remember that code you wrote up for me today in core.logic? that's not the expected behaviour, is it? http://bpaste.net/show/4XK2kmdJGDq1iyV5OOXv/

17:57 llasram: I already reported an issue, but I'm unsure: http://dev.clojure.org/jira/browse/LOGIC-52

17:58 llasram: naeg: No, it really isn't. Huh, interesting. I'd actually played a little further, and found the same problem, but thought it only manifested when I was trying to be fancy and construct the sequence of +fd calls as goals in an `everyg`

17:58 I was going to wait until dnolen was around to ask about it

17:58 but it really does look like a bug

17:59 If you have the domain contain one valid sequence, it choose that. Two valid sequences, it choose those. If you have certain particular constructions of domains w/ no valid sequences, then it emits that invalid one

17:59 So yeah, I'm going with bug

18:00 naeg: llasram: ok, great

18:00 well, actually bad

18:01 llasram: But you could try to track down the bug and fix it, improving the software ecosystem for everyone!

18:01 Every bug is an opportunity

18:01 gfredericks: OSS is a gift economy

18:01 llasram: That's why I leave the bugs in code I write

18:01 naeg: llasram: I'm looking at the sourcecode of +fd, but I don't feel like I'm good enough in clojure already

18:01 still trying

18:02 cark: tho tracking a bug in such thing as logic requires quite a bit of expertise

18:02 i already struggle just using it =P

18:06 naeg: llasram: about that everyg - did you put all those calls to +fd into that?

18:08 Roxxi: For unit testing is there a lot of traction around Midje, or do most people just use clojure.test ?

18:09 samuelj: Hey, can anyone point me in the right direction with this? Just trying to get my head around clojure web dev using compojure. I wanted to be able to define several functions like 'test', and add them into my-routes, then pass that to the defroutes function. I get * a lot * of errors when I try :) http://pastebin.com/efrYdUKw

18:09 Any help is again greatly appreciated

18:09 just a nudge in the right direction!

18:09 weavejester: samuelj: Why did you quote the route?

18:10 samuelj: Because i didn't want it to evaluate?

18:10 llasram: naeg: Yeah. Unfortunately on other computer I lost my ssh tunnel to ATM

18:10 weavejester: samuelj: You do want it to evaluate :)

18:10 samuelj: Ah

18:10 weavejester: samuelj: GET returns a function

18:10 samuelj: It's basically equivalent to:

18:11 llasram: naeg: Gist is you can use `partition` to build pair-wise sets of the goal logic variables, then apply the step condition to each pair

18:11 weavejester: samuelj: (GET "/" [] …) ==> (fn [req] (if (matches-route? req [:get "/"]) …))

18:11 samuelj: ah ok!! awesome!

18:12 So if i unquote it, I'm getting clojure.lang.PersistentList cannot be cast to clojure.lang.IFn

18:12 weavejester: samuelj: You also don't need a ref, unless you want to dynamically change the routes at runtime.

18:12 samuelj: ok, so I can just def the list and then still call alter on it?

18:13 what i typed doesn't make sense

18:13 I mean, I can take out the ref, then still conj into it?

18:13 weavejester: samuelj: That's because (defroutes app my-routes) is equivalent to (def app (routes my-routes))

18:13 samuelj: The routes function takes many handler functions and combines them into one.

18:13 samuelj: So if there's only one route, then (routes x) == x

18:14 samuelj: If you want to update the routes dynamically, you'd need an atom or ref, but I don't know why you would

18:14 naeg: llasram: I just did it like that: (l/everyg (fn [[y x]] (l/+fd y 1 x)) [[b a] [c b] [d c]])

18:15 weavejester: samuelj: If you just want to put multiple routes into one, then you can use the 'routes' function

18:15 samuelj: So say x = (GET "/" [] …) and y is another route, then (routes x y) will return a new route that tries x first, then y, then nil if neither match.

18:16 llasram: naeg: A bit more manual, but yeah -- I'd think that would have the same effect

18:16 samuelj: ah ok, and this is a compojure function? not ring?

18:17 weavejester: samuelj: It's basically the same thing. The only difference is that in Compojure the routing functions can return nil. Otherwise they're the same as Ring handlers.

18:17 samuelj: Compojure treats a route returning nil as meaning "do not match"

18:18 samuelj: awesome, thanks for the help

18:19 weavejester: samuelj: So (routes (GET "/" [] "Hi") (ANY "*" [] "Not found")) will check the GET first, and then the ANY, which will always match/

18:19 samuelj: so in general, you define a series of routes with something like (def x (GET ?) and then maybe (def app (routes x y))

18:19 *defroutes

18:19 weavejester: samuelj: You don't need the x part, you could do it all inline

18:20 samuelj: Yeah, but i'm porting over an existing application and its quite larg

18:20 weavejester: samuelj: Like (def app (routes (GET "/" [] …) (POST "/" [] …) (GET "/:id" [id])))

18:20 samuelj: Okay, so you might want to split things up. Let's say you have some routes for dealing with products

18:21 samuelj: Give me a sec to make a gist :)

18:21 samuelj: sweet, thanks

18:24 naeg: btw llasram this is what I'm having so far: http://bpaste.net/show/Y8sNAXSPNGHS0EgOHPjq/

18:25 yeah, switched to partition and I'm still missing the whole check for diagonals to complete the check for the whole connect four field

18:25 stuck with diagonals here: http://stackoverflow.com/questions/12355352/predicate-to-declare-descending-ascending-coordinates-using-finite-domains

18:27 gtrak: dakrone: mind if I ask, what would you call this license used for Cheshire? It looks a bit like MIT. is something like 'Modified MIT license' ok for our documentation?

18:28 weavejester: samuelj: Nearly done...

18:28 gtrak: never mind, I see the README says MIT license

18:35 weavejester: samuelj: There: https://gist.github.com/3694454

18:38 samuelj: weavejester thank you so much dude! that's awesome help :)

18:38 weavejester: samuelj: Does that make more sense now?

18:41 samuelj: yeah it sure does

18:41 thanks a million!

18:41 xeqi: (inc weavejester)

18:41 lazybot: ⇒ 5

18:44 weavejester: Cool. Now, sleep for me :)

18:45 hyPiRion: ,(Thread/sleep 1000)

18:45 clojurebot: nil

18:46 samuelj: weavejester: but what If i want to create a function, say, add-route, that takes something like a GET function, and adds it to a list that is referenced in defroutes

18:46 Can I show you what I'm thinking?

18:47 weavejester: http://pastebin.com/GE7HZ7TW

18:47 oh right, just saw your sleep comment

18:47 no worries dude!

18:52 gtrak: samuelj: just glancing at the compojure code, you might have to hot-replace some of the code to make that happen, like adding around metadata

18:52 the functions get captured in a closure eventually, you'd want to expose that somehow

18:54 like add an atom to the metadata of the routes, and create functions that alter that

18:55 that's kinda what noir does with defpage: https://github.com/ibdknox/noir/blob/master/src/noir/core.clj

18:56 technomancy: can't say I'm a fan

18:56 declarative routes are the way to go

18:57 but yeah, if you wanted to do that, noir shows you how

18:58 gtrak: is noir doing 'imperative' routes?

18:58 samuelj: technomancy, what's so good about declarative routes?

19:01 ivan: can I get clojure-dev in my inbox without mailing a piece of paper?

19:05 gtrak: ivan, feeds? https://groups.google.com/group/clojure-dev/feeds?hl=en

19:05 ivan: ah, nice, thanks

19:10 thorbjornDX: okay, `lein vimclojure` is blowing my mind right now. And I've heard that slime will blow this out of the water

19:11 Raynes: We're trying to get people off of SLIME for Clojure in favor of nrepl.el.

19:11 It might, however, still blow it out of the water.

19:12 gtrak: Raynes: any hope for lein 1.7?

19:13 Raynes: gtrak: Don't think so, no.

19:14 gtrak: I would like some, I don't know when we'll get on 2. I just got off of a month ago.

19:14 thorbjornDX: Raynes: actually, I think that's what I was using in emacs, is that the "m-x clojure-jack-in" command?

19:14 Raynes: Nope, nrepl-jack-in

19:14 thorbjornDX: Raynes: ah, okay. I'll have to give it a shot

19:18 cark: what's a good way to do continuous testing with clojure 1.4 ?

19:18 gtrak: we do hudson with cmdline lein invocations

19:19 thorbjornDX: gtrak: you can just use 'lein test' or somesuch, right?

19:19 gtrak: for some values of 'good'

19:19 yea

19:19 frio: i'd also like an answer to cark's q if possible, but locally rather than with a build server

19:19 i really liked that scala's sbt had ~test

19:19 which detected changes, recompiled and re-ran the test suite locally

19:19 cark: i'm also looking at something local and fast

19:19 frio: does anyone know if there's anything similar :)?

19:19 thorbjornDX: gtrak: does it just give you a bunch of stacktraces? Or is there a way to get pretty output?

19:19 gtrak: there's a lein-autotest?

19:20 thorbjornDX: yup, stacktraces

19:20 I'm guessing the build result is keyed off the process exit errorlevel

19:20 thorbjornDX: gtrak: gotcha. cark: jenkins is pretty quick in my experience

19:20 gtrak: of course if I were starting from scratch I'd prefer jenkins to hudson

19:21 frio: so there is gtrak

19:21 thanks for that :D

19:21 thorbjornDX: gtrak: I'm pretty late to the game, what new features does jenkins buy you?

19:21 (personally that is)

19:21 frio: jenkins is just hudson thorbjornDX :)

19:21 gtrak: thorbjornDX: the whole dev team of hudson...

19:22 cark: looks like a whole beast, i was thinking lazy-test or lein-auto-expect, but maybe with clojure.test

19:22 gtrak: hudson is a dead project now

19:22 frio: but there was a Thing with oracle owning the trademarks and whatnot (which isn't a Thing anymore)

19:22 thorbjornDX: gtrak: gotcha.

19:23 gtrak: "Compare core commits: as of 9-March, Jenkins core has 307 commits from 30 contributors; Oracle Hudson has 136 commits by 4 contributors."

19:23 thorbjornDX: gtrak: not to mention plugin developers... ok :)

19:31 gtrak: lancepantz: umm, what would you say is the license for clj-yaml?

19:39 technomancy: gtrak: anything in particular keeping you on lein1?

19:40 gtrak: technomancy: yea, we have some custom plugins

19:41 technomancy: anything interesting? =)

19:41 gtrak: there's one that recursively AOT compiles dependencies and creates -compiled classifier jars in the local maven repo, and another that manages distribution packages, generating license docs, etc..

19:41 they do a bunch of stuff

19:42 technomancy: why do you need a plugin to compile dependencies?

19:42 the common complaint in Clojure is that you can't avoid that =)

19:42 oh, specifically to put them in separate jars?

19:42 gtrak: yea

19:43 hold on a sec, I have Nate's presentation that explains most of that stuff

19:43 technomancy: "distribution packages" meaning system-level stuff? are you running lein as root?

19:44 gtrak: nope, I mean as zip files to customers: https://github.com/youngnh/presentations/blob/master/clojure.mn/2012_sep/at_revelytix.md

19:44 specifically compiledeps

19:45 I'm not sure of the details because I didn't write it, but suffice it to say, it's complicated :-)

19:45 technomancy: so nothing too specific; these are only distributed with the project because you haven't gotten around to spinning them off into a separate plugin project?

19:47 gtrak: they are separate plugins, but they tend to not play well with version changes, I'm not sure exactly what's missing/conflicting in lein2, but I remember there was an issue I think with maven jars keeping us at, and we just recently were able to go to 1.7.

19:47 technomancy: ouch

19:47 you have some plexus conflict or something?

19:47 gtrak: yea

19:47 let me give it a go I guess :-)

19:47 technomancy: the worst =(

19:47 gtrak: I have lein2 installed

19:48 technomancy: ok, just curious since so far most people have reported the transition to be fairly painless

19:48 gtrak: yea, we're doing something weird, it's not your fault

19:48 technomancy: are you using this? https://github.com/technomancy/lein-licenses

19:48 xeqi: anyone know a way to limit the number of thread the jvm can spawn?

19:49 gtrak: technomancy: nah, I think it's custom, we also pull from a map if the license isn't present, so we can add them for all the dependencies, then I use hiccup to generate some html, I wrote that part ;-)

19:49 technomancy: cool

19:51 I can't help but think what you're doing would be much simpler if you just distributed an uberjar

19:51 then you can have all the class files in one place and don't have to mess with repackaging deps

19:52 gtrak: yea possibly, I don't quite understand all the rationale

19:52 technomancy: is there some weird business requirement preventing that?

19:52 gtrak: assuredly, I don't think we'd go through all that trouble to avoid it otherwise

19:52 technomancy: heh; from the presentation "No other project in the world seems to need this"

19:52 pretty much =)

19:53 have you seen lein-pedantic?

19:53 gtrak: nope

19:53 technomancy: it's pretty great for larger projects: https://github.com/xeqi/lein-pedantic

19:53 gtrak: oh neat

19:53 yes I could totally use that

19:53 xeqi: its lein2 only

19:53 btw

19:54 gtrak: godammit XD

19:54 technomancy: incentive to upgrade =)

19:54 xeqi: heh, it uses pomegranate underneath, which has some sorta plexus class conflict with lein1

19:54 if I remember right

19:54 gtrak: ok, first problem, it's not AOT-compiling my main class

19:55 ah wait, that's the source layout

19:55 devn: xeqi: so we need some sort of meta pedantic for lein?

19:55 ;)

19:55 gtrak: well it doesn't show our plugins at all in 'lein help', so that's an issue

19:56 samflores: guys, what's the "right" way to deploy an ring application?

19:56 gtrak: those were dev dependencies

19:56 samflores: a*

19:56 xeqi: samflores: clojars uses jetty behind an nginx frontend

19:57 samflores: that's what I was thinking to do :)

19:57 hiredman: I like to use the lein ring plugin to build a war, and jetty-runner

19:57 uberwar

19:57 gtrak: technomancy: it looks like it'll be pretty involved, how about I give it a go some other time and let you know?

19:57 xeqi: technomancy: was there something in the .md that lead to mentioning lein-pedantic?

19:58 devn: heh, I think it was used in maven-ant-tasks, which does the dependency resolution for lein1. I don't think its fixable

19:58 technomancy: gtrak: of course; no worries. I was just curious.

19:58 unlink: Is there something like when-let for maps?

19:58 gtrak: naha, me too, I haven't shaved the yak fully yet, I just suspect it will break

19:59 technomancy: gtrak: there's an upgrade guide on the wiki when you do

19:59 gtrak: cool man

19:59 yea, I'd love to use lein2 personally

19:59 unlink: (when-let [rec (select-keys m [:a :b :c])] ...)

20:00 Of course the condition always succeeds because empty maps are truthy.

20:00 technomancy: xeqi: I guess under "Lots and lots will hork your build"

20:00 aperiodic: unlink: you can just use destructuring: (when-let [{:keys [a b c]} m] ...)

20:00 xeqi: &(when-let [{:keys [a b c]} {:a 2}] a)

20:00 lazybot: ⇒ 2

20:00 xeqi: &(when-let [{:keys [a b c]} {:a 2}] [a b c])

20:00 lazybot: ⇒ [2 nil nil]

20:00 xeqi: &(when-let [{:keys [a b c]} {}] [a b c])

20:00 lazybot: ⇒ [nil nil nil]

20:01 gtrak: technomancy: I discovered the hard way that our 'lein printdeps' wouldn't necessarily attribute the declared version of the dependency to the declaring parent, but choose by phase of the moon what to put there :-)

20:02 crazy stuff like that

20:02 xeqi: version ranges can make that hard

20:02 technomancy: gtrak: yeah; that's built-in to lein2 now

20:02 unlink: aperiodic: I don't want to destructure, though. I just want to execute something that is side-effective when the select-keys yields a non-empty map.

20:02 technomancy: lein-pedantic adds a lot more visibility there

20:02 gtrak: I want it

20:07 technomancy: the motivation for compiledeps looked to be like this: http://dev.clojure.org/jira/browse/CLJ-322

20:09 technomancy: gtrak: huh. that issue has been open for ages; I don't have a lot of hope that it'll ever be fixed at this point

20:09 gtrak: so in the end we get AOT-compiled JARS for every dep, instead of just a bunch of class files

20:09 aperiodic: unlink: i don't think there's a builtin. you'd probably want to define something like (fn has-any-key? [& keys] (fn [m] ((apply some-fn keys) m))) and use that as your test (assuming all your keys are keywords)

20:13 unlink: What I want is isomorphic to (let [m (select-keys m ks)] (when (seq m) ...))

20:13 aperiodic: unlink: write a macro?

20:13 unlink: That's never the answer.

20:14 I think the better question is, why doesn't clojure.java.jdbc/update-values not accept an empty parameter list? (and do nothing)

20:14 metellus: ,(when-let [m (select-keys {:a 1} [:b])] true)

20:14 clojurebot: true

20:15 metellus: darn.

20:19 aperiodic: unlink: what's unsatisfying about defining (fn has-any-key? [m & ks] (seq (select-keys m ks)) and then writing (when (has-any-key? m :a :b :c) ...) ?

20:22 muhoo: is there somewhere a clearinghouse/wiki/directory/something with all the various ring middlewares available?

20:24 xeqi: muhoo: the "built-in" ones are listed at http://ring-clojure.github.com/ring/

20:40 unlink: aperiodic: I actually want the map resulting from the select-keys.

20:41 zenoli: chouser: Thanks, finally had a chance to look at your updates to https://gist.github.com/3687532 using the LinkedBlockingQueue. That's super slick.

20:45 gfredericks: emezeske: ping

20:46 zenoli: chouser: I'm going to give it a try with my code, looks like it's just what I'm looking for. If I'm understanding correctly, advance-most-recent continues running in its own thread, due to the future, every time the rest unblocks, and that keeps the queue from growing...that was the other piece that I was missing.

20:47 emezeske: gfredericks: pong

20:56 gfredericks: emezeske: I was poking for a hacky workaround to the *assert* issue; I tried setting it to false in user.clj, thinking that couldn't possibly not work, and yet it did not work; any ideas?

20:56 (i.e., with alter-var-root)

20:58 emezeske: gfredericks: I don't think there's even a hacky workaround

20:59 gfredericks: Since the compiler is run in a separate java process from leiningen itself

20:59 gfredericks: but clojure always loads the user.clj, I assumed

20:59 as long as it's on the classpath

20:59 I figured the issue must be I'm misguessing the classpath (I put it in src/user.clj)

21:00 emezeske: Hmm, I guess I don't know much about user.clj

21:00 gfredericks: but /src is definitely on the classpath for the compiler's process?

21:01 emezeske: Yes, unless you changed :source-path or something

21:01 gfredericks: ah ha

21:01 so the :source-paths option in lein2 is exhaustive?

21:01 emezeske: Well, it defaults to ["src"] I think

21:01 * gfredericks recompiles

21:04 gfredericks: sweet that did it

21:04 emezeske: thanks!

21:04 jcromartie: (eval (maths.core/compile-math '(2 * 6)))

21:05 getting somewhere

21:05 emezeske: gfredericks: Glad you got it working!

21:05 jcromartie: oh wait, Incanter does this

21:10 Khaoz: The clojure-mode to use with emacs is the one from here: https://github.com/technomancy/clojure-mode right ?

21:24 mpan: what does it mean to get: CompilerException java.lang.RuntimeException: Unable to resolve symbol: defn in this context, compiling:(NO_SOURCE_PATH:2) ?

21:25 it seems to happen occasionally at the repl

21:25 * gfredericks has never seen that in his life

21:25 mpan: like I was previously using stuff from core and it was OK

21:26 I can't reproduce it deterministically, but once it happens it sticks around until I get a new repl

21:27 xeqi: mpan: did you recently change namespaces?

21:27 muhoo: xeqi: thanks, i'd seen those. i was thinking mostly of third-party ones. found a few, but have no idea how many there are out in the wild.

21:28 mpan: uh, I recently evaluated some stuff from the IDE which indirectly changed namespaces

21:28 but I lost core in the process?

21:28 xeqi: muhoo: I don't know of a listing, and some are built in other libs. friend has some, lib-noir has some, but no global listing :/

21:29 gfredericks: mpan: (clojure.core/use 'clojure.core)?

21:29 tomoj: mpan: do you call in-ns?

21:29 xeqi: mpan: if it somehow moved to a namespace w/ in-ns(or somethign) and therefore didn't import clojure.core

21:29 mpan: gfredericks: thanks, I'll use that next time

21:29 gfredericks: mpan: also there is (clojure.core/refer-clojure)

21:29 mpan: tomoj, xeqi: I don't think I did that

21:29 gfredericks: which I think is equivalent...

21:29 mpan: not intentionally at least

21:30 tomoj: ns does (refer-clojure) so that shouldn't happen unless you create a new namespace without using ns

21:30 unless you have (:refer-clojure :only [+]) or something...

21:30 mpan: I suppose I'll wait until it reoccurs to test

21:30 thanks guys

21:30 xeqi: I've had it happen on nrepl 0.1.3, but usually it manifests as an autocomplete error

21:31 * nrepl.el

22:09 arrdem: I've got a working program which generates Clojure code, is there some library settings for pprinting code, or do I just have to mess with it?

22:09 * gfredericks wonders if you could pipe it to emacs

22:10 * arrdem is still in the deluded vim-using camp

22:10 gfredericks: arrdem: http://bjeanes.com/2012/09/pure-evil

22:11 xeqi: arrdem: you mean to change clojure.pprint/pprint ?

22:12 arrdem: xeqi: I know that clojure.pprint/code-dispatch will print a compiled Clojure fn

22:13 what I want to do is achieve a similar pprint for the un-eval'd list representation of a legal fn

22:13 meh... I guess I can just (map pprint)

22:13 xeqi: (pprint (quote ...)) ?

22:15 arrdem: nvm the standard pprint invocation is good enough. I was just looking at ways to tweak the formatting rules, not prevent evaluation of my gen'd code

22:30 nsxt: anyone successfully using cemerick's friend lib?

22:30 brehaut: ~anyone

22:30 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

22:30 brehaut: http://nelsonmorris.net/2012/09/01/using-friend-in-clojars.html

22:32 nsxt: i'm getting this stack trace when loading it as a dependency: https://www.refheap.com/paste/5e7034ed66be1bbeedf466b91

22:36 xeqi: nsxt: whats your project.clj look like?

22:37 or.. try https://github.com/xeqi/lein-pedantic to see if the wrong version of a lib is being used

22:38 nsxt: xeqi: sorry, should have posted that as well. https://www.refheap.com/paste/60fb868fbd1f0bb01ca3de56d

22:38 checking, thanks

22:39 xeqi: nsxt: let me know if it helps, always interested to hear usage

22:41 mpan: I'm trying to do something that in java would use abstract classes

22:41 should I use a type or a record?

22:41 nsxt: xeqi: thanks, lots returned by lein-pedantic, will report back when i've worked through them all

22:42 mpan: like I want multiple ways of performing a task according to the same signature

22:42 and I have a protocol for it

22:42 brehaut: mpan: neither let you inherit anything other than an interface

22:42 mpan: uh, I can put in the impl manually

22:43 brehaut: i hope you mean 'i can call a function'

22:43 mpan: er yea

22:43 maybe that was phrased a bit weird

22:44 like, I want to write a few functions which produce different instances of something that follows this protocol

22:44 brehaut: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/

22:45 mpan: awesome thanks

22:45 and when it says, "use a regular map", does that mean the contract should be written in natural language and human-enforced by the programmer?

22:46 brehaut: it means dont define a new type, just use a map instance

22:46 mpan: and uh, define multimethods?

22:47 brehaut: "will the type participate in clojure protocols or be associated with performance-sensitive code" -> No -> Use a regular map

22:47 that no is important

22:47 mpan: that leaves me with the other part of my goal, though

22:48 like the code that works with these don't know if f or g produced the one they are using

22:48 because f and g should follow the same contract

22:48 so how would I make it transparent to such use?

22:49 nsxt: xeqi: thanks for lein-pedantic... helped me sort out the dependency issue. from what i can tell, there's no way to specify a 'minimum' version of a dependency... i'm sure this has been brought up numerous times, is there any reason why it's not supported?

22:49 brehaut: mpan: sorry, sleep deprivation is making me it hard for me to follow.

22:49 mpan: uh, so like, I've got something that's a solver for certain sorts of problems

22:49 so f and g are, well java would call them "factories"

22:50 brehaut: so, functions

22:50 xeqi: nsxt: you can with version ranges, but they have other problems

22:50 mpan: and either one gives you solver, which should follow the same contract

22:50 yes, f and g are functions which return a function, and the returned function follows a certain contract

22:50 brehaut: ok

22:50 mpan: and I need it to be transparent to the code that uses the result whether it got its function from f or g

22:50 xeqi: nsxt: in general, the java ecosystem clojure reuses decided to do "soft"/recommended dependencies by default, so its just something to live with

22:51 nsxt: xeqi: is the recommended course of action, then, to explicitly state the exclusions, and then load the "dependency dependencies" yourself in the project.clj file?

22:51 brehaut: mpan: i dont understand what the difficulty is?

22:52 mpan: so, in java I would want a solver "object" of one of a number of concrete classes with the same interface that has several "methods"

22:52 as in, it should be bundled together

22:52 xeqi: pretty much, I hope thats what I'm hoping the lein-pedantic suggestions told you to do

22:52 mpan: should I use a map of fns?

22:52 brehaut: ok.

22:52 you can do

22:53 or you can define a record for each type of solver and implement a protocol

22:53 mpan: is there one that's recommended usually?

22:53 brehaut: if the groups of functions are static, probably protocols

22:54 mpan: uh well, they take a game state and some extra args, and return a new game state, approximately

22:54 brehaut: so make the records take gamestate, and each of the protocol methods return a new gamestate

22:55 mpan: is there a general recommendation whether to do this with a map or a record? I'm not sure whether it would help me to make a separate protocol

22:55 originally, I made one but I'm not sure if it is necessary

22:55 brehaut: if you only have one record type, its probably not necessary

22:56 mpan: all right, thank you very much!!

22:56 owenjones: (defpage "/todos/" []

22:56 (todos-page))

22:56 (defpage "/todos.json" []

22:57 (resp/json (todo/all)))

22:57 hello all, Im trying to learn noir I assume there's a better way to do this?

22:57 brehaut: mpan: you can use operations like assoc and update-in on records to get new records back, so its pretty trivial to make protocol implementations that return new records

22:57 nsxt: xeqi: yeah, sort of... https://www.refheap.com/paste/5f1dada786fc717c0d9794562 this offers an either/or recommendation, which is great. my question was aimed at the :exclusions keyword in particular, and whether it's considered "good practice" to disregard the versions specified by a dependency and override them with one of your own

22:57 brehaut: owenjones: for future reference, use a paste service like gist.github.com or refheap.com

22:58 mpan: also, there is a mention of "performance-sensitive"

22:58 how/to what extent would using a record change performance?

22:59 brehaut: mpan: calls to protocol functions have inline caches at the callsite to make them faster than a pure dynamic call

22:59 nsxt: xeqi: for example, if i wanted to use cheshire 4.0.2 as a dependency in my project.clj - would i just comb through each of the other dependencies and :exclude cheshire from them?

22:59 xeqi: nsxt: in general, the top level dependencies should win, so you shouldn't have to

22:59 brehaut: mpan: it makes protocols comparable to normal function calls, rather than a lot slower like you might get by indirecting through a map

22:59 or in comparison to multimethods

23:00 xeqi: however, there are a few times that doesn't happen, and then its useful

23:00 nsxt: xeqi: alright, thanks. will keep lein-pedantic around then :)

23:00 mpan: so if this is my inner loop of my game state evaluator, I should use a protocol?

23:00 brehaut: if its polymorphic yes probably

23:00 mpan: less so a game and more so a simulation, but I suppose the two are similar in the abstract

23:01 uh, yes, my main goal is to implement multiple concrete "solution concepts"

23:01 all right, thank you!

23:03 brehaut: mpan: i hope i havent said too much craziness

23:03 mpan: additionally, should I be type-hinting my inner loop?

23:03 it needs to run ~10-100k iterations

23:03 brehaut: only once you know you need to

23:03 mpan: when would I find out?

23:03 brehaut: (enable *warn-on-reflection*)

23:03 mpan: and do that after I have initial correctness?

23:04 brehaut: do it when you have determiend its running to slowly and its correct

23:04 mpan: thank you

23:04 yes, correctness is my first goal

Logging service provided by n01se.net