#clojure log - Mar 24 2013

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

1:06 chessguy: anybody awake? i'm pretty new to clojure, trying to get a silly data structure working. i'm sure it's way easier than i'm making it..

1:07 arrdem: go for it..

1:07 no rest for the wicked.. or those designing the impossible XP

1:07 chessguy: https://gist.github.com/arwagner/5230640

1:07 i'm pretty sure it can be done in about 5 lines. i'm getting a null reference exception right now

1:10 arrdem: chessguy: sorry it's past my bedtime and I have the attention span of a squirrel on meth. gimme a minute here.

1:10 chessguy: arrdem: no worries, i know it's terrible code

1:11 arrdem: chessguy: it actually isn'

1:11 t bad... just not something there's really a reason to do. hang on.

1:11 new emacs instance..

1:11 nrepl...

1:11 and code.

1:11 okay.

1:13 first thing.. I would write similar (map key) as similar (key map)

1:13 that way it's a little less confusing with clojure.core/map

1:13 but that's correct so it's not your error.

1:14 chessguy: hm, ok. i know that a lot of functions that operate on collections take the collection as the first argument

1:14 so i was trying to follow that

1:14 but i see your point

1:14 arrdem: I mean....

1:14 ,(extends? IFn {})

1:14 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: IFn in this context, compiling:(NO_SOURCE_PATH:0:0)>

1:14 arrdem: goddamnit clojurebot.

1:14 anyway {} is a function...

1:14 chessguy: yes

1:15 and so are its keys

1:15 tbaldridge: ,(ifn? {})

1:15 clojurebot: true

1:15 arrdem: (inc tbaldridge)

1:15 lazybot: ⇒ 2

1:15 tbaldridge: (fn? {})

1:15 ,(fn? {})

1:15 clojurebot: false

1:15 chessguy: ,(ifn? :foo)

1:15 clojurebot: true

1:15 chessguy: ,(fn? :foo)

1:15 clojurebot: false

1:16 tbaldridge: fn? is only true for clojure functions, trivia fact.

1:16 ,(fn? #())

1:16 clojurebot: true

1:16 chessguy: makes sense

1:17 tbaldridge: yeah, but it'll trip you up sometimes, so use ifn? most of the time. :-)

1:18 chessguy: so, arrdem, you were saying there's no reason to do this?

1:19 arrdem: chessguy: I mean it's a cute exercise in the language.. but we have {} as you clearly know

1:19 chessguy: yes...

1:19 arrdem: I'm legitimately curious why it's wrong.

1:19 chessguy: this is more than {}...

1:20 it's a partition

1:20 bbloom: every time i try to use a zipper, i find them to be more trouble than their worth :-/

1:20 chessguy: bbloom: i kinda feel that way too. played with them for a long time in haskell

1:20 bbloom: s/their/they're/

1:24 chessguy: am i missing something obvious?

1:24 arrdem: chessguy: not that I'm seeing off the bat

1:24 chessguy: arrdem: i mean in both the approach and the execution

1:26 arrdem: chessguy: so the approach seems fine...

1:26 trying to debug (contains?) plz hold

1:27 chessguy: oh i found it

1:27 (keys {}) is nil...

1:28 i was expecting it to be an empty vector

1:28 arrdem: oh that'd do it.

1:29 ,(contains? nil true)

1:29 clojurebot: false

1:29 arrdem: no...

1:30 chessguy: (vec (keys {}))

1:30 ,(vec (keys {}))

1:30 clojurebot: []

1:30 arrdem: OH

1:31 namespace.

1:31 chessguy: hm?

1:31 clojurebot: benchmarking is https://github.com/hugoduncan/criterium

1:31 arrdem: you define contains? and then expect it to operate recursively.

1:31 chessguy: oh geez

1:31 arrdem: you need to specify clojure.core/contains? on line 15 in contains?

1:31 chessguy: yeah

1:31 arrdem: ololol that was a cute bug

1:32 chessguy: yeah, that fixes it

1:33 arrdem: chessguy: it'd be interesting if you could adapt this to take N partition functions and allow for the nesting case cleanly

1:33 chessguy: arrdem: nesting case?

1:34 arrdem: like, make a tree out of it?

1:34 arrdem: yep!

1:34 chessguy: would be easy to define a BST i suppose

1:35 arrdem: so the first level uses function F, second G, third H and soforth.

1:35 which are not nessicaraly equivalent.

1:35 chessguy: hm, this still isn't quite right.

1:35 arrdem: not sure if it'd be usefull, but it'd be cute. a hashing with bucket implemetation as it were.

1:36 chessguy: arrdem: i feel like there has to be a more idiomatic way...

1:38 arrdem: working on a -> based version for my own entertainment..

1:38 chessguy: arrdem: there's a bit in this. if you pass in two items that hash to the same key, it fails

1:39 s/bit/bug/

1:39 man i'm tired...

1:44 arrdem: chessguy: a simpler contains-any-like? would just be (map ((:hash-function map) item))

1:44 because if true it'll be the sub-map and if false it'll be nil

1:44 and anything but nil I believe is truthy

1:44 chessguy: that makes my head hurt...

1:44 i really need to rename that field

1:45 arrdem: or just use .map..

1:45 chessguy: hm?

1:45 clojurebot: benchmarking is https://github.com/hugoduncan/criterium

1:45 chessguy: shutup, clojurebot

1:45 arrdem: ,(doc defrecord)

1:45 clojurebot: "([name [& fields] & opts+specs]); Alpha - subject to change (defrecord name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args*] body)* Dynamically generates compiled bytecode for class with the given name, in a package with the same name as the curr...

1:45 arrdem: yeah cool.

1:46 so your Hashtable compiles to a java class.

1:46 therefore you can use (.map instance)

1:46 as well as (:map instance)

1:46 and (. instance map)

1:46 chessguy: oh

1:46 meh. i just renamed it to data

1:47 still can't figure out why a second item with the same hash is overwriting instead of conj'ing

1:48 arrdem: ,(conj #{:foo} :bar)

1:48 clojurebot: #{:foo :bar}

1:48 arrdem: ,(conj nil :bar)

1:48 clojurebot: (:bar)

1:48 arrdem: ,(set (conj nil :bar))

1:48 clojurebot: #{:bar}

1:49 chessguy: that could replace my if statement, i suppose

1:50 arrdem: yep that's the idea

1:50 chessguy: still doesn't work...

1:51 here's the latest version: https://gist.github.com/arwagner/5230640

1:52 oh, i've still got some :map's in there

1:52 now it works

1:54 arrdem: I b0rked mine -_-

1:55 chessguy: ok, it's really time for bed now...

1:56 thanks!

1:59 arohner: in typed clojure, how do I "get rid of" a (U nil)?

2:00 nvm, user error

2:22 Raynes: arohner: The exception was between the chair and the keyboard?

2:22 arohner: Raynes: yes

2:22 Raynes: :p

2:22 arrdem: darn IO exceptions get me every time

2:22 arohner: though I also gave up, because the type for datomic.api/q is a bitch

2:23 I couldn't convince typed that (q '[:find ?e .. :where [?e ...]]) always returns a long

2:25 hrm, though if I sleep on it, I can probably make that happen

2:25 hrm, nvm, dealing with :in is going to be a problem

2:41 Raynes: arrdem: ImADamnedIdiotException

2:42 arrdem: Raynes: InsufficientCoffeeException

2:43 Raynes: arrdem: That's genius!

2:44 arrdem: so I'm working on a math library for rationals, irrationals, (Double is close enough to real) Irrationals, symbols and values with errors.

2:45 is it cheating to allow arithmatic operations to return "expressions" when they cannot be exactly computed due to types or the presence of symbols?

2:55 paddymahoney: so, when symbols are present, you probably want to return a lambda with those symbols bound? is that correct?

2:55 arrdem: paddymahoney: when I go to eval with binding yes... but I would like to keep it all symbolic for as long as possible.

2:57 tomoj: in pedestal, how do you deal with :input events?

2:57 Raynes: You use compojure.

2:57 ~rimshot

2:57 clojurebot: Badum, *tish*

2:57 paddymahoney: I see, so you probably need a function (free-vars symbolic-exp) => (listof symbol)

2:58 and then a wrap function...(wrap symbolic-body vars) => lambda vars symbolic-body

2:59 muhoo: TimMc: thanks!

2:59 Raynes: Not totally sure what you're trying to do.

3:00 arrdem: herm... should my eval take a bindings form or assume that all vals are def'd in the current namespace?

3:00 s/vals/symbols

3:00 Raynes: Oh, I thought he was asking a question, not you.

3:03 paddymahoney: arrdem: I would have one that takes a symbolic expression tree, and one that takes bindings, and then write the first in terms of the second after reconstructing a full abstract binding tree.

3:04 danneu: Raynes: i'm learning a lot reading your laser lib's source. it's easy to understand

3:04 arrdem: paddymahoney: herm I guess that'd work.

3:04 Raynes: Really? Nice. That's some of the most complicated stuff I've written. Give yourself a solid pat on the back, sir.

3:04 arrdem: lemme finish the quick demo I'm working on and see what you think.

3:04 paddymahoney: I'm interested! :)

3:05 * arrdem can't tell if that's saying a lot about Raynes's code or not.

3:05 arrdem: paddymahoney: fair warning the second system effect is in full swing as is sleep deprivation.

3:08 (* a (/ b c)) == (/ (* a b) c), yes?

3:10 Raynes: danneu: Simple and easy to understand was a goal, so I'm happy to hear that at least one person thinks I may have succeeded.

3:11 Not that people think I haven't succeeded. You're just the first person to comment on the code. ;)

3:11 Except for amalloy, but he complains in general.

3:13 paddymahoney: arrdem: I don't think that is true.

3:13 amalloy: haven't read the backlog, but i'm sure Raynes has said something wrong recently

3:13 Raynes: lol

3:17 arrdem: paddymahoney: no that has to be true because it gives == (* a b (/ 1 c)) which _is_ true.

3:17 paddymahoney: ah I was confused. a*(b/c) == (a*b)/c.

3:17 * arrdem is glad that his algebra isn't failing at 2am

3:18 paddymahoney: paddymahoney is sad his is.

3:19 my prefix to infix parser is broken :(

3:45 * arrdem roudly curses interfaces and heads for be

3:45 arrdem: *bed

3:54 MikeSeth: hmmm

4:01 I have [:a :b :c] and a function [e p] where p is some value derived from e's position in the vector, what's the idiomatic way to loop over a list/vector extracting a value and its position?

4:04 arrdem: ,(group-by #(= (first %1) 3) (vector [1 2 3 5 4 6 7 8 3] (range 9))

4:04 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

4:04 arrdem: ,(group-by #(= (first %1) 3) (vector [1 2 3 5 4 6 7 8 3] (range 9)))

4:04 clojurebot: {false [[1 2 3 5 4 ...] (0 1 2 3 4 ...)]}

4:05 arrdem: (vector [1 2 3 5 4 6 7 8 3] (range 9))

4:05 ,(vector [1 2 3 5 4 6 7 8 3] (range 9))

4:05 clojurebot: [[1 2 3 5 4 ...] (0 1 2 3 4 ...)]

4:05 arrdem: ,(map vector [1 2 3 5 4 6 7 8 3] (range 9))

4:05 clojurebot: ([1 0] [2 1] [3 2] [5 3] [4 4] ...)

4:05 arrdem: ,(group-by #(= (first %1) 3) (map vector [1 2 3 5 4 6 7 8 3] (range 9)))

4:05 clojurebot: {false [[1 0] [2 1] [5 3] [4 4] [6 5] ...], true [[3 2] [3 8]]}

4:05 MikeSeth: aha

4:05 arrdem: hah. gross and not lazy but that's one way.

4:05 SegFaultAX: Ugh, no.

4:06 * arrdem realizes it's 3am and dies

4:06 arrdem: SegFaultAX: fix my shit. have fun :D

4:06 SegFaultAX: yogthos: I have to say I didn't like that list video you posted on proggit.

4:06 yogthos: I thought the speaker was awful. :/

4:07 MikeSeth: What are you really trying to do?

4:08 MikeSeth: SegFaultAX: terminal emulator has method to the effect of [x y str]

4:08 there's no way to move cursor relatively etc

4:08 so I have a list of strings each corresponding to a vertical screen position

4:09 SegFaultAX: MikeSeth: Ok, so what's the problem?

4:10 Raynes: SegFaultAX: Paul ingles?

4:10 Ingles, even

4:10 SegFaultAX: Raynes: Yea.

4:10 Raynes: Why don't you like him?

4:10 SegFaultAX: It's not him I don't like. The talk is terrible.

4:11 He spends the first 35 minutes haphazardly pasting a half dozen other talks and books together, without giving justice to any of them or the concepts therein.

4:11 Raynes: I see.

4:11 I haven't actually seen the talk.

4:12 I emailed Paul once so he is one of my closest friends and stuff.

4:12 SegFaultAX: Basically building up to, at about the 5 minutes left mark, saying "you should use Datomic" and then finally talking about how they used it at uSwitch or whatever.

4:12 Raynes: Or something.

4:12 SegFaultAX: Or something.

4:17 MikeSeth: Still looking for help?

4:53 danneu: Raynes: are you there?

4:56 Raynes: danneu: Yes.

4:58 danneu: Raynes: can laser.core/and be rewritten with every-pred: https://gist.github.com/danneu/d2177a9ca4be8d1190be

4:58 i found every-pred when looking in stdlib when i was trying to do the same thing

4:59 well ive gotta drive home. cya

5:02 Raynes: For those watching: the answer is yes, and I commented as such.

5:03 * Raynes goes to sleep.

5:46 rocco: is there anyone here who'd be willing to answer a question I have?

5:50 ivan: rocco: you picked the worst freenode time but maybe

5:50 (always just ask)

5:50 rocco: I'll keep that in mind for the future

5:50 I'd just like to know how instances of java classes are disposed when I run them in the repl

5:51 do I need to dispose them?

5:51 ivan: nope, the JVM's GC will kick in and garbage-collect them (unless they're still in your *1 *2 *3 REPL vars)

5:51 rocco: I don't like the idea of leaving garbage behind me so I'd just like to clarify for myself what happens

5:52 in the repl vars or otherwise referenced, right?

5:52 ivan: all you have to do is not leave any references to things you want garbage-collected

5:52 yes

5:52 rocco: ok

5:53 I worry about this when I create gui windows and such

5:53 I wonder what happens when I close them

5:53 but those are classes like any other really

5:54 ivan: these libraries generally do not have massive leaks, but if you want to make sure, you can attach jvisualvm to your process, trigger a GC, and look at how many instances there are of certain objects

5:55 rocco: I see

5:55 very useful

5:55 can you suggest other tools off the top of your head? I'm looking to equip my programmer shed :)

5:56 ivan: for memory leaks in particular?

5:58 rocco: I meant in regards to clojure in general but that may be too much..

5:59 ivan: recently I learned of java -XX:+PrintFlagsFinal and -XX:+PrintCompilation, those can be useful

5:59 https://gist.github.com/rednaxelafx/1165804 scroll down to know what the JVM spends all its time doing

6:01 but clojure instead of jvm? you probably already know nrepl.el

6:03 rocco: actually I didn't

6:03 ivan: see also http://www.clojure-doc.org/ and Joy of Clojure

6:03 rocco: I was playing with emacs environ some time back

6:03 now I'm looking to start experimenting again with clojure

6:05 I've read some joy of clojure

6:05 haven't finished it yet

6:06 what I read was great

6:07 so which is the preferred site currently - clojuredocs or clojure-doc

6:07 I'm trying to get a feeling for what has changed while I wasn't paying attention

6:08 ivan: clojuredocs is mostly abandoned and stuck on 1.3

6:10 rocco: good to know

6:12 ivan: it still has a lot of useful examples that have not been migrated yet

6:13 arkx: Migrated where? Does clojure-doc.org have API reference section somewhere?

6:14 ivan: I thought there was a plan to have one but now I read "CDS is not concerned with providing the API reference" https://github.com/clojuredocs/cds

6:14 arkx: Yeah. :|

6:23 modulus: Hi there. A couple of questions if anyone's around and wakeful.

6:24 i do (require 'clojure.set) (intersection #{} #{}) and the symbol intersection seems not to be defined, any clues why?

6:24 the require statement gives me a nice nil, no errors.

6:25 AimHere: clojure.set/intersection should work

6:25 modulus: oh damn, i tried clojure.set.intersection but of course it's a /

6:25 thanks

7:06 lpetit: hello

7:07 fractastical: Can anyone give me advice on frameworks to use for creating a REST API ?

7:07 I've looked at a few tutorials and also discovered liberator

7:07 sometimes hard to see how much certain libraries are being maintained

9:44 navgeet: Is there any way to get the environment in a function, not like it's available as &env in a macro.

10:41 edw: I'm tryinh to get nrepl's javadoc support working. Anyone know how to get the javadoc middleware installed? Is it a dev dependency in my project.clj file? A lein plugin?

10:52 ravster: question about liberator: do the post!, put!, get!, etc. actions only get called if its a POST, PUT, GET, etc request?

10:53 well, maybe not get!, but delete! ?

11:06 technomancy: edw: iirc it's part of ritz

11:07 edw: Ah. Don't feel like drinking that bowl of Kool-Aid just right now.

11:11 hugod: edw: should be as simple as the config shown in https://github.com/pallet/ritz/tree/develop/nrepl-middleware#usage

11:12 ravster: using undocumented apis is always so much fun. *sigh*

11:13 edw: Ah! Thanks, Hugo. I thought I was going to get sucked completely into Ritz. I'm always trying to limit the number of moving parts in anything I'm doing.

11:23 gfredericks: ha; clojure.org/special_forms suggests docstrings should be 1-3 lines

11:24 hyPiRion: gfredericks: But they can be very long.

11:25 gfredericks: the lines you mean? :)

11:25 hyPiRion: yeah :)

11:25 gfredericks: good ole clojure

11:26 edw: OK, so C-c C-j is working but it's opening a browser window with a search string containing "+javadoc"; any ideas?

11:36 Ah. I was under the impression that doing a C-c C-j with point over e.g. "Integer/parseInt" would do some magic and map that to java.lang.Integer.

11:37 A project for another weekend.

13:03 zakwilson: It seems like it might be of use for Korma to make itself aware of what columns are in a table and select-keys those from the map it's given for an insert/update.

13:39 chessguy: 'afternoon ya'all

13:39 satch5150: hi all - I have a problem, not sure if its the right place, but the problem revolved around clojure, so here goes, when I start an nrepl via eclipse, it runs on an ipv6 address (according to netstat) and so therefore attempts to connect to it from lein via console (outside eclipse) fails

13:41 I am not to up on ipv6 and I tried to connect via a ipv6 version of the localhost ip, but still fails

13:41 anyway, what can I do ?

13:43 anyone ?

13:44 zakwilson: This is probably the right place to ask the question, but the channel is slow this time of day. Be patient, and someone might answer in a couple hours.

13:44 satch5150: thanks

14:05 tomoj: satch5150: hmm the lein changelog for 2.0.0-preview10 says "Make repl listen on instead of localhost to address IPv6 issues."

14:10 satch5150: tomoj: I just turned off ipv6 on my linux machine, nrepl now listening on ipv4, but I still get a connection refused

14:11 using this to try to connect: lein repl :connect nrepl://localhost:43509

14:15 I don't think i'm having firewall issues, iptables reveals no rules, everything set to accept, and I don't 'think' selinux is installed

14:15 or activated I mean

14:17 indeed, selinux is disabled

14:17 what else could be causing this

14:17 ?

14:20 MikeSeth: SegFaultAX: sorry for bailing earlier

14:21 satch5150: just to recap: I am unable to connect to a nrepl that was started by eclipse using: lein repl :connect nrepl://localhost:43509 - the nrepl is listening on ipv4 now

14:23 I get a connection refused error, followed the names of java classes with line numbers where they all had trouble

14:28 MikeSeth: satch5150: can you connect with telnet?

14:28 satch5150: not even sure I have a telnet client :) - I'll see though

14:29 MikeSeth: satch5150: try a browser with http://...

14:30 satch5150: telnet connected

14:31 MikeSeth: satch5150: try lein repl 43509

14:31 w/o hostname

14:31 er, lein repl connect 43509

14:31 er, lein repl :connect 43509

14:32 satch5150: MikeSeth: that seems to work :)

14:32 MikeSeth: satch5150: I dont think you're supposed to give it an URI

14:33 satch5150: MikeSeth: I am happy I have it working, but for arguments sake, what if I wanted to connect to a remote server ?

14:33 MikeSeth: satch5150: host:port

14:33 no nrepl:// prefix

14:33 satch5150: ah, I see

14:34 thanks again :)

14:34 MikeSeth: welcome

14:38 horseshoe: hi, oss.sonatype.org appears to be down and hence lein deps doesn't work, are there any workarounds ?

14:53 borkdude: why exactly doesn't have app-handler (wrap-resource "public") and war-handler does in noir.util.middleware?

15:03 mstang_: hello

15:03 I have a kind of conceptual question

15:05 I have a bunch of functions that all need a "session", so I keep passing it in, what is the recommended way to make a kind of "global" value available all th way down into functions

15:06 borkdude: mstang_ probably an atom or a ref

15:06 mstang_ unless you mean a browser session

15:07 mstang_ or you can pass all the "global" data from one function to the other as a parameter

15:07 mstang_: no, I am "wrapping" a third-party library and they make a connection to a server

15:08 something similar to a jdbc connection

15:09 borkdude I am concerned with limiting the library to a single "session" at a time

15:11 borkdude: mstang_ in clojure.jdbc a dynamic var *db* is used for that and any database operations can be done with with-open

15:11 mstang_ this way, the user of your library has to keep arround the session/connection himself and just feed it to with-open

15:13 mstang_: borkdude OK, I saw something similar with another SQL library

15:13 borkdude: mstang_ are you from NL btw? (your name sounds dutch)

15:14 mstang_: borkdude maybe a long time ago, via Germany, family immigrated from Germany, came with the name

15:14 borkdude: ah

15:15 mstang_: borkdude not sure where they got it ;-)

15:16 bordkdude always wondered, found it meant "bar"...

15:18 borkdude: mstang_ correct

15:19 mstang_: borkdude "steel bar" "tavern bar"?

15:19 borkdude: mstang_ more like the bar in "behind bars"

15:19 mstang_ so steel

15:24 yogthos|away I see in luminus that (route/resources "/") is added to app-routes but war-handler also adds a wrap-resource… how do they relate?

15:27 mstang_: borkdude what if I don't want to close the "session" but leave it open, or maybe I want to have a "session" pool

15:29 modulus: so say i have lists l1 and l2 and i want to make them into a hash map. is the most reasonable way to go about this (reduce conj (map hash-map l1 l2))?

15:29 borkdude: modulus probably zipmap

15:30 * modulus checks

15:30 borkdude: mstang_ I don't know. maybe keep them around in an atom or smth?

15:30 modulus: oh lol, that seems exactly what i need.

15:30 mstang_: borkdude smth?

15:30 borkdude: mstang_ something

15:30 mstang_: borkdude lol

15:31 a|i: there is so much inconsistancy in clojure emacs docs.

15:31 is this out od date? http://clojure-doc.org/articles/tutorials/emacs.html

15:32 does this work? https://github.com/overtone/emacs-live/tree/master/packs/live/clojure-pack/lib/clojure-mode

15:32 and what's this one? https://github.com/jochu/clojure-mode

15:33 jjttjj: that second one was updated 2 months ago so i would assume it does work?


15:33 and that third one says it's deprecated right at the top

15:33 a|i: jjttjj: the 2nd one doesn't work.

15:33 jjttjj: ah

15:34 a|i: al I wanna do is to open up a repl and evalue a file in it.

15:35 mstang_: a|i nrepl

15:36 a|i: mstang_: in emacs?

15:37 mstang_: a|i yes, it is on github, when installed into emacs, a control-c control-k will evaluate a buffer in nrepl

15:38 a|i https://gist.github.com/rkneufeld/5126926

15:39 a|i nrepl runs inside emacs

15:39 a|i: mstang_: how is this different to emacs-live? I thought emacs-live bundles all the useful clojure stuff in emacs.

15:40 mstang_: a|i sorry, don't know anything about emacs-live, the url I sent was from a Clojure West Conference talk

15:41 a|i: mstang_: thanks, I'll have a look into this now.

15:41 zackzackzack: Any ideas why leiningen might be hanging when I try to run the tests or repl?

15:41 mstang_: a|i last week, so I know it is current, nrepl gets you Clojure access, the rest is "just" learning emacs editing

15:43 zackzackzack: Oh. I see why it's hanging now. It's not. The jvm is starting up. Somehow drip got disabled. Odd.

15:47 a|i: mstang_: how is nrepl-jack-in connected to a specific project.clj?

15:49 mstang_: a|i not really, it starts a repl running and then you can "send" stuff to the repl to be evaluated, for instance from the end of an sexp you can control-x control-e and it will evaluate it

15:49 a|i: mstang_: then why does it say: 'Open an nREPL session. Intelligently loads project context if launched from any file within a Leiningen project.'

15:50 mstang_: a|i ah, my guess is if you do it from within a project, not my style of development...

15:50 a|i however, let me try...

15:54 a|i not sure if it did anything when I executed nrepl-jack-in

15:54 a|i: mstang_: did you try C-c M-j or M-x nrepl-jack-in ?

15:55 mstang_: a|j M-x nrepl-jack-in

15:55 a|i: mstang_: I did that with having a file open. but it doesn't connect to the repl.

15:55 C-c C-e doesn't output in repl.

15:56 mstang_: a|i no, in the status at the bottom

15:56 a|i messages

15:56 a|i: what's the pint of opening a repl then?

15:56 point*

15:57 mstang_: a|i well, if you open the messages buffer you can see it run

15:58 a|i: mstang_: ok, but what's th epoint of openning a repl?

15:58 mstang_: a|i C-c C-k to load the buffer

15:58 a|i: mstang_: C-c C-k outputs in status line, not repl.

15:59 mstang_: the repl namespace doesn't change from user, is that normal?

15:59 mstang_: a|i C-c M-n to switch the namespace

15:59 a|i yes it is normal

16:01 a|i: mstang_: does C-c C-k evaluate in repl and only output in the status line?

16:02 mstang_: a|i yes, you can switch to the nrepl and input commands there at the prompt, or you can "send" from your .clj buffer and have nrepl evaluate it

16:03 a|i nrepl is a running session, so you can edit and load from emacs, or you can switch to the *nrepl* buffer and type commands directly into the repl, but that is hard to edit

16:15 noprompt: Raynes: you around?

16:15 Raynes: noprompt: Theoretically.

16:16 noprompt: Raynes: how did you get started with emacs? i'd like to give it another shot but i'm a hardcore vimmer.

16:17 Raynes: Well, I didn't come to Emacs from Vim so I don't have any big secrets for success there.

16:18 noprompt: oh haha, for some reason i thought you used vim before.

16:18 Raynes: It's been so long I don't even remember following any tutorials or anything. Chances are I just googled things as I went, grabbed a cheatsheet...

16:18 I did.

16:18 I went from Emacs to Vim for a couple of months and then back to Emacs with evil-mode because I liked Vim but was sadpanda that I didn't have Emac's extensibility and plugins.

16:19 arrdem: Raynes: lol yeah I found your blog post ranting about not having elisp around a few days ago.

16:19 borkdude: yogthos|away I tried either compojure.route/resources and wrap-resource from ring with some file in public and they seem to work independently, so I'm kind of confused why they are both here

16:20 noprompt: alrighty. i got evil-mode going. guess i'll just have to suck it up and figure out the rest. :)

16:20 Raynes: noprompt: You've got to be willing to take a productivity hit for a week or two while you learn.

16:21 arrdem: noprompt: that and I recommend trying emacs sans evil-mode before you use evil.

16:21 Raynes: You're going to be much slower until you get some muscle memory developed for stuff that evil-mode doesn't cover, but for the most part everything is googleable.

16:21 chessguy: don't suppose anyone's interested in doing a little pair programming. i'm playing around a little with a tiny rules engine, for fun and to help me learn clojure

16:21 Raynes: I'm not sure where I stand on evil-vs-no-evil.

16:22 arrdem: Raynes: it's a personality thing.

16:22 I can handle key chords and was using them in vim before I started emacs-ing

16:22 Raynes: I have no information one way or the other (for I did not conduct studies) saying that people are more likely to learn Emacs with or without starting with evil-mode, since I started using it while I already knew Emacs.

16:22 noprompt: Raynes: yeah, i was aware there'd be a performance hit. i'll take the advice though and drop evil-mode for now.

16:23 btw, how's that starter kit?

16:23 Raynes: In that case, you should drop to about 3 MPH for a while.

16:23 arrdem: noprompt: supposedly it's good but haven't tried it.

16:23 Raynes: evil-mode would have given you about 5MPH. ;P

16:23 noprompt: Raynes: that's what it was like when i first started learning vim.

16:23 Raynes: But I'm quite satisfied with your confidence, sir.

16:24 I've used bits and pieces of the starter kit, and generally trust technomancy to not mess up Emacs stuff.

16:24 *shrug*

16:24 There is also emacs-live, but it looks horrible.

16:25 arrdem: it's abandonware and you'll have to patch a line but the sublime package is a nice wrapper over some stuff...

16:25 give's you control-c and control-p to copy/paste to system clipboard

16:25 among other things.

16:25 Raynes: Wait, you guys don't use OS X?

16:26 I didn't realize there were people left that didn't.

16:26 arrdem: I'm running Arch Linux on all my boxes.

16:26 Raynes: You poor thing.

16:26 arrdem: lol

16:26 * Raynes uses discrimination level 20

16:26 arrdem: !dice

16:26 hum...

16:26 ~dice

16:26 clojurebot: Huh?

16:26 Raynes: $dice maybe? :(

16:26 noprompt: i use os x.

16:27 Raynes: noprompt: Then if you use Emacs from homebrew or emacsformacosx.com you'll yet cmd+c and cmd+p for copying and pasting out of the box.

16:27 tbaldridge: Raynes: there were waaay more Linux users at Clojure/West than at the Conj

16:27 noprompt: the thing that kills me is the meta key.

16:28 i had to remap capslock to meta.

16:28 tbaldridge: Conj was about 10% mac. Clojure/West was about 30-40%

16:28 Raynes: wat

16:28 arrdem: TBH I'm working on a Samsung Series 9 atm... so mod the fact that I'm running a minimal xwindows compositor basically means that I'm as close to a mac as I can get without buying one.

16:28 Raynes: noprompt: Remap capslock to control, dude.

16:29 noprompt: i would be my muscle memory for control is pretty there already.

16:29 fwiw, i actually tried to remap caps lock to control

16:29 Raynes: I used to be really adamant about not changing ctrls location.

16:29 But then work sent me a laptop with it pre-swapped for control and I was too lazy to change it.

16:29 Never looked back.

16:31 noprompt: i'm planning to get a type matrix pretty soon so the problem may not be a real issue http://typematrix.com/

16:32 been wanting to get my hands on one for a while now

16:35 arohner: tbaldridge: I would have guessed C/W was 70% mac

16:35 noprompt: Raynes: do you use the gui version of emacs or terminal?

16:35 Raynes: noprompt: GUI, for this isn't 1995.

16:36 noprompt: lmfao

16:36 arrdem: despite being the resident Arch pants on head retard I also use the gui

16:36 and why would you buy that... get a gaming mechanical and remap it.

16:37 noprompt: the typematrix?

16:37 * arrdem loves his clicky Corsair k90

16:37 noprompt: because i like the layout

16:37 Raynes: I use a das.

16:37 noprompt: i'd like to get a data hand but that's like 1K$

16:37 Raynes: People at work come by to watch me type. Some bring popcorn.

16:38 noprompt: Raynes: the best thing about the das is that punchy sound.

16:38 Raynes: They have recorded albums of my das instrumentals.

16:39 noprompt: gives a new meaning to the phrase "keyboard solo"

16:40 arrdem: haha

16:40 noprompt: Raynes: you should do a serious recording, and put a picture of yourself on the album cover dressed up as bach

16:40 Raynes: lol

16:41 scottj: noprompt: seen truly ergonomic? I've used typematrix and te and prefer te. (though I prefer choc mini to both)

16:42 btw remapping capslock to control AND escape is nice

16:43 noprompt: scottj: the te looks interesting. it has the vertical layout i like.

16:44 the placement of : and / might kill me a little

16:45 scottj: what's nice about the choc mini? looks pretty standard to me.

16:46 scottj: noprompt: yeah I like standard :) relatively short spacebar and pgup/pgdn are close. and fns directly above and lined up with # keys.

16:46 arrdem: thanks for mentioning the TE, that looks cool!

16:47 scottj: noprompt: the change of placement on TE is VERY annoying

16:47 arrdem: abet a significant shift in key layour.

16:47 *layout

16:47 noprompt: what would really be awesome if there was keyboard which let you physically reconfigure the keyboard some how

16:47 instead of doing it via software

16:48 scottj: http://stevelosh.com/blog/2012/10/a-modern-space-cadet/ is where I got the capslock=control and escape idea, xcape is what I use on linux

16:48 noprompt: you move a key to a different location but it still sends the original signal

16:48 scottj: noprompt: I think kinesis advantage supports that, at least on the thumb keys

16:48 arrdem: noprompt: there are a few of those...

16:48 or at least I saw one years ago.

16:48 noprompt: really?

16:48 oh man i would love that

16:48 arrdem: yeah all the keys were done in software so the board was fully reconfigurable.

16:49 it was pretty wacky.

16:50 noprompt: http://www.ergodex.com/mainpage.htm

16:51 noprompt: whoa. that's wild.

16:51 technomancy: Raynes: am I too late to make a D&D joke on your "not sure where you stand on evil" comment?

16:51 arrdem: and it's at least a four year old product too...

16:52 Raynes: technomancy: Never.

16:53 technomancy: Raynes: you should get your alignment checked

16:53 noprompt: technomancy: nice

16:53 Raynes: Dun dun dun

16:58 noprompt: arrdem: have you seen the wads keyboard?

16:58 or rather, heard anything good about them?

16:58 arrdem: noprompt: neg

16:58 oh this isn't mwo. nil.

17:00 noprompt: spell check ruined that, wasd

17:02 arrdem: noprompt: good grief that's an overkill mech keyboard

17:02 change the font of your keycaps ffs...

17:02 *you can

17:02 Raynes: I want a wingding keyboard.

17:02 noprompt: hehe, yeah a bit over the top, eh?

17:03 Raynes: comic sans?

17:09 borkdude: lpetit is "load file in REPL" in ccw supposed to spawn a repl, without me having to press "Run"?

17:09 lpetit: borkdude: yes

17:12 borkdude: lpetit and if I want to close a repl because I want to start a fresh one, which view/window do I kill? console, repl, both?

17:13 lpetit: borkdude: you close the repl, this will also close the associated console

17:13 borkdude: lpetit I updated to the newest ccw and "load file in REPL" doesn't start a repl, also the closing doesn't work as you described

17:14 lpetit: borkdude: that's an unfortunate regression.

17:16 borkdude: lpetit I just upgraded from 0.12.1 to 0.12.2 to see if that was the problem, no luck. Eclipse version : 4.2.2.M20blabla

17:17 lpetit: borkdude: will not have time to look at it right now, already fighting with a regression in Leiningen 2.1.1 API. Can you please file an issue, I'll fix it in 0.12.3 later this week.

17:19 borkdude: lpetit ok

17:19 lpetit: borkdude: thx

17:19 noprompt: scottj: did you say you can remap caps lock to both esc and cntrl?

17:19 scottj: noprompt: yep

17:19 noprompt: how?

17:19 clojurebot: with style and grace

17:19 scottj: noprompt: what os?

17:20 technomancy: clojurebot: botsnack

17:20 noprompt: os x

17:20 clojurebot: Thanks! Can I have chocolate next time

17:20 scottj: $google steve losh cadet keyboard

17:20 noprompt: http://stevelosh.com/blog/2012/10/a-modern-space-cadet/

17:22 borkdude: lpetit hmm, it might be that my project is somehow broken. it works in another project in the same workspace

17:22 lpetit: borkdude: try to "Leiningen > Reset project"

17:22 noprompt: scottj: thanks

17:37 borkdude: Raynes what is the common way to test code that normally uses the stateful sessions from lib-noir?

17:38 Raynes: Psh, like I test my websites.

17:38 borkdude: Raynes I remember in noir there was something like with-noir … blabla

17:38 Raynes: borkdude: You can use binding to bind the unbound variable things. There might be something in lib-noir. yogthos would know more.

17:39 yogthos: moi? :)

17:40 I don't think there's anything special for testing stateful sessions, using binding would probably be the easiest

17:41 borkdude: Raynes ah yes, binding

17:41 xeqi: borkdude: you could use my kerodon library if you want to test the full routes

17:41 borkdude: xeqi I will look at that… sounds interesting

17:42 technomancy: kerodon is cool

17:43 yogthos: very fancy :)

17:44 borkdude: (binding [noir.session/*noir-session* (atom {})] works

17:45 kerodon looks very interesting though. :-)

17:45 xeqi: just depends on the level you want to test at

17:46 yogthos: borkdude: with-redefs can be handy too

17:46 if you have something that goes to db for example, you could redef it with something that spits out some test data

17:53 borkdude: yogthos yeah, that's very handy.

17:57 noprompt: scottj: oh man, this is definitely an improvement

17:57 i think i can start learning emacs now

17:59 borkdude: gnight

18:03 pellis: hello

18:10 I'm wondering if anyone is doing async IO with clojure

18:12 ravster: is liberator known to fiddle with ring-session?

18:14 brehaut: pellis: https://github.com/ztellman/aleph

18:14 amalloy: i would have linked to lamina rather than aleph, but it's all the same i suppose

18:15 brehaut: pellis: if you mean 'are people in clojure writing callback soups', the not so much

18:15 oh true. sorry

18:16 pellis:  hm, not sure I prefer callback soup.

18:16 perhaps it is best if I give some context

18:17 u have a clojure (compojure) based API that i've build for processing articles (article = text + images). it will then classify the article into one of several groups

18:18 so a workflow would be: 1. download HTML (IO), 2. do text processing (CPU) 3. download images (IO), 4. process images via external tools (IO), 5. merge everything (CPU)

18:19 brehaut: pellis: so you want background workers?

18:19 pellis: well not so much. everything works well right now - i'm using maps and pmaps and clojure is very nice to me

18:19 the API was designed for server-to-server communication, so the traffic isn't really web-scale

18:20 right now I have a critical requirement, to push it towards "web scale" by letting users directly hit this API

18:21 in this case, I'm not sure I can waste so much resources on about threads where there's so much IO around

18:21 so my knee-jerk reaction was to start implementing everything in an evented framework. node.js and event machine came up, I picked node.js

18:22 but now I'm pretty much sad about 2 things. 1 - this takes me away from clojure 2 - I have java algorithms I have to port to javascript (yuck)

18:22 brehaut: well, pmap frinstance is capped at available processors + 2

18:23 pellis: so my next reaction - wrap all the Java stuff with Clojure and Netty and offer the functionality for my (now new) node.js service via some kind of RPC

18:23 all this kind of made me realize that if there's a convenient async framework for clojure, i could implement network IO and such within clojure itself

18:26 technomancy: pellis: sounds like a job for message queues

18:26 pellis: technomancy, though, i didn't mentioned this all should be real time

18:26 technomancy: oh, ok

18:26 pellis: or, at least synchronous (client hangs and waits for answer)

18:27 right now it takes around 0.7s for a call and there's a lot to improve (premature optimization)

18:29 so basically i'm stuck with finding a way to call Java code through node.js or find an evented framework for clojure

18:34 amalloy: pellis: that'd be aleph/lamina for sure. nothing else in clojure comes close for evented networking

18:34 zakwilson: It seems to me that futures might provide a good alternative to event-based techniques to get good responsiveness from that sort of application in Clojure.

18:34 pellis: great, so I'll be sure to check lamina out

18:47 Scruffy: Hello.

18:48 zakwilson: It's my impression that futures use a thread pool and work queues such that resource consumption at "web scale" wouldn't really be a problem relative to an event-driven style. In any case, it would be trivial to test relative to rewriting code for an event framework.

18:50 rhickeybot: killuminati

18:51 pellis: zakwilson, isn't futures just a form of delayed execution?

18:52 zakwilson: pellis: no. Futures begin work as soon as there's a thread available (note: this may not be a completely accurate representation of their implementation from a technical perspective).

18:55 In fact, pmap is pretty much just (map deref (map (future (f a-seq))))

18:56 pellis: zakwilson, thats interesting.. ill have to read about it

18:57 zakwilson: pellis: Most of the workflow you're describing above is sequential though, so I'm not sure how much gain there's going to be with either events or futures.

18:58 pellis: zakwilson, well, i'm running several algorithms on the same data, and then merging their result. these can run in parallel

18:59 zakwilson: If you have code that looks like (let [x (do-io-bound-thing) y (do-cpu-bound-thing-not-dependant-on-x)] (do-stuff-with-x-and-y)), you can parallelize it trivially with (let [x (future (do-io-bound-thing)) y (future (do-cpu-bound-thing-not-dependant-on-x))] (do-stuff-with @x @y))

18:59 pellis: and I figured letting the OS handle the IO in the case of evented, will be better than blocked out threads

19:00 zakwilson: And if you have CPU-bound things that aren't already parallel, you can parallelize them the same way.

19:01 It might well be better, but if you have an easy way to load-test it, you can try futures trivially. Unrelated: I'm doing text classification in Clojure too.

19:05 pellis: zakwilson, yup, i'll keep that in mind

19:07 zakwilson: And I have an HTTP API or two, and it involves fetching data over the web, and it has (a small number of) users, and it uses futures to do that. I don't know that it's the best way to do things, but I know it's *a* way.

19:09 pellis: yep, i'll have to give it a go at least. either that or i'll wrap the actual algorithm with an RPC and call it from node.js

19:25 number35: hi all

19:25 i would like to know if its possible to interleave two sequences with using only map and reduce

19:28 zakwilson: I'm pretty sure it's not.

19:32 dnolen: ,(reduce concat (map vector [1 2 3] ["one" "two" "three"]))

19:32 clojurebot: (1 "one" 2 "two" 3 ...)

19:32 dnolen: ##(reduce concat (map vector [1 2 3] ["one" "two" "three"]))

19:32 number35: ^

19:33 rplaca: number35: you can do it with mapcat by itself

19:33 ##(mapcat #(vector %1 %2) [:a :b :c] [1 2 3])

19:33 number35: thank you

19:33 rplaca: ,(mapcat #(vector %1 %2) [:a :b :c] [1 2 3])

19:33 clojurebot: (:a 1 :b 2 :c ...)

19:33 rplaca: which amounts to the same thing

19:36 dnolen: number35: though unless you're solving puzzles, probably better to use interleave

19:38 zakwilson: Using concat or vector is not doing it using only map and reduce.

19:40 dnolen: zakwilson: is there *anything* you can do w/ *only* map and reduce? ;)

19:41 zakwilson: dnolen: I don't think so, because they both require a function as an argument. I think the question may have been poorly phrased.

19:45 "can I make interleave using map, reduce, other built-in functions, function literals and data constructors?" is a very different question. The answer to that is "sure, easily, but interleave is in clojure.core, so why would you want to?".

19:56 hyPiRion: rplaca: You could just use ##(mapcat vector [:a :b :c] [1 2 3])

19:56 except lazybot is dead?

19:56 rplaca: hyPiRion: yes, good point!

19:57 hyPiRion: Raynes ^

19:57 Oh, but Raynes is offline too. Hmm.

19:57 rplaca: #(foo %1 %2) is always a code smell :)

19:58 lazybot doesn't really exist. Raynes just answers by hand :)

19:58 hyPiRion: ah, and Raynes lost power now.

19:58 viable solution

20:02 zakwilson: I'm inclined to think lazybot is just unreliable because the last commit to irclj is "Less scary README.". Prior to that, README said "Usage: don't"

20:38 bbloom: LOL: http://www.haskell.org/haskellwiki/Monad_tutorials_timeline

20:38 rplaca: the graph there is the best part!

20:38 bbloom: rplaca: oh yeah, the graph made my laugh pretty hard

20:38 rplaca: with a curve like that, I think I'll invest

20:38 of course, past results are no guarantee of future performance

20:38 bbloom: i dunno, if my experience extrapolating wildly has taught me anything, it's the fact that 10 years from now, that graph will surely loop so far up that it flips back around and heads back towards the Y axix

20:39 akhudek: they need a graph like this: http://www.vayapotra.es/wordpress/wp-content/uploads/2009/02/2rmqi6o.gif

20:40 bbloom: nice.

20:49 ambrosebs: How do I pprint a record so it shows the ctor name?

20:53 rplaca: ambrosebs: you don't, without writing your own dispatch

20:54 that seems to be a highly requested feature, so I'm planning to add a feature for that in the standard dispatch table

20:56 bbloom: fipp works on records, but not on lots of other stuff, heh

20:57 ambrosebs: give it a try & i'm happy to take patches to cover more things. should be pretty easy to add stuff

20:57 ambrosebs: I'll have a look.

20:57 bbloom: and thanks to octagon, somebody else on planet earth has tried it and so i was able to hammer out a bug or two

20:58 brighid: I'm having trouble reading a configuration file. I'm basing what I'm trying on this Stack Overflow answer: http://stackoverflow.com/a/7781443/ -- I have a Leiningen project set up, and within that /src/my_project/foo.clj and /src/my_project/bar.conf. But I keep getting "FileNotFoundException bar.conf (No such file or directory)" errors.

20:59 What's the right way to say "please give me the contents of this file in my project"?

21:00 gfredericks: (clojure.java.io/resource "my_project/bar.conf")

21:00 I recommend putting it in /resources instead of /src though

21:00 bbloom: (doc clojure.java.io/resource)

21:00 clojurebot: "([n] [n loader]); Returns the URL for a named resource. Use the context class loader if no loader is specified."

21:00 gfredericks: but that coud should work either way

21:00 brighid: gfredericks: actually that's probably a good idea, thanks.

21:00 (the "put it in /resources" idea)

21:01 gfredericks: :) it's what it's for

21:03 i_s: does anyone know why (vals {}) => nil and not an empty seq?

21:03 gfredericks: nil is sort of an empty seq

21:03 ,[(seq? nil) (empty? nil)]

21:03 clojurebot: [false true]

21:04 gfredericks: ,(map seq [[] [1] [1 2]])

21:04 clojurebot: (nil (1) (1 2))

21:04 i_s: hm, ok that helps

21:04 hyPiRion: gfredericks: oh man, you lost a great opportunity there

21:04 Hmm, was it

21:04 gfredericks: will I ever get it back?

21:04 hyPiRion: ~amalloy

21:04 clojurebot: amalloy is <amalloy> just use juxt, it'll be great

21:04 hyPiRion: yeah, that was it

21:04 ,((juxt seq? empty?) nil)

21:04 clojurebot: [false true]

21:04 bbloom: i_s: it's to facilitate "nil punning" where it is often desirable to treat empty sequences as falsey

21:05 gfredericks: yes, juxt is the best way to explain unrelated concepts :P

21:05 hyPiRion: but but but

21:05 JUXT!

21:05 i_s: i see

21:05 bbloom: i_s: ##(if-let [v (vals {})] v :no-vals)

21:05 gfredericks: ~juxt

21:05 clojurebot: juxt is usually the right answer

21:05 bbloom: ,(if-let [v (vals {})] v :no-vals)

21:05 clojurebot: :no-vals

21:05 gfredericks: &(doc vals)

21:05 * gfredericks is curious if the documentation of vals says anything about nil vs ()

21:06 gfredericks: ,(doc vals)

21:06 clojurebot: "([map]); Returns a sequence of the map's values."

21:06 gfredericks: well for all we know it's an implementation detail

21:06 ,(list)

21:06 clojurebot: ()

21:06 bbloom: also fun:

21:06 gfredericks: ,(list*)

21:06 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core$list-STAR->

21:06 bbloom: ,()

21:06 clojurebot: ()

21:07 bbloom: which weirded me out the first time i saw it

21:07 gfredericks: ,'()

21:07 clojurebot: ()

21:08 gfredericks: ,''()

21:08 clojurebot: (quote ())

21:08 gfredericks: ,(list* ())

21:08 clojurebot: nil

21:10 gfredericks: clojure: it's what you make of it.

21:11 bbloom: turing machines: it's what you make of them.

21:11 gfredericks: you make busy beavers out of them

21:12 brighid: gfredericks: (clojure.java.io/resource "bar.conf") returns nil - what might I be doing wrong there?

21:13 gfredericks: is there a parent directory you're forgetting?

21:13 you had one earlier

21:14 i_s: with the nil punning argument though, why doesn't (filter odd? [2 4 6]) => nil instead of ()

21:14 bbloom: brighid: that fn just delegates to the getResource method of the current class loader

21:14 i_s: seems inconsistent

21:14 gfredericks: i_s: it's lazy

21:14 bbloom: brighid: all info that applies to getResource also applies to clojure

21:14 gfredericks: lazy seq functions can't return nil

21:14 bbloom: for example http://stackoverflow.com/questions/12103371/how-to-use-getclass-getresource-method

21:14 i_s: hm touche

21:15 gfredericks: i_s: ideally they would but it's not feasible without giving up some laziness

21:15 i_s: right

21:15 bbloom: ,(seq (filter odd? [2 4 6]))

21:15 clojurebot: nil

21:15 gfredericks: the seq function is often used like ^that when you want to force the empty seq to nil

21:15 brighid: bbloom: Clojure is my introduction to Java, so I don't have an existing knowledge of "info that applies to getResource" :(

21:16 gfredericks: (when (seq ...) ...)

21:16 bbloom: brighid: i'm just telling you what to google for :-)

21:16 brighid: bbloom: Oh okay. Cheers.

21:16 gfredericks: brighid: if you're using leiningen you can try `lein classpath` to double-check what's included in your classpath

21:16 bbloom: brighid: also, you can try in your REPL (source clojure.java.io/resource) and then work backwards from there

21:17 brighid: Oh hey, #'source looks handy, thank you.

21:17 hyPiRion: The best is most likely

21:17 ,(list? (list* (for [a [1]] a)))

21:17 oh clojurebot, you so lazy

21:17 ,(list? (list* (for [a [1]] a)))

21:17 :'(

21:17 clojurebot: false

21:17 false

21:18 hiredman: ,(contains? (set (ancestors (class ()))) clojure.lang.Counted)

21:18 clojurebot: true

21:23 george_mcfly: why is it that when i pass a vector to drop-last, it gives me back a list ? shouldn't it return whatever collection type it receives ?

21:23 (= '(1 2 3) (drop-last [1 2 3 4]))

21:24 bbloom: george_mcfly: no, clojure's sequence functions are generally lazy

21:24 vectors have known size

21:24 if you want to get a vector, you need to strictly evaluate, which you can do with vec or into []

21:24 ,(vec (drop-last [1 2 3 4]))

21:24 clojurebot: [1 2 3]

21:24 bbloom: but realize what this is doing: it's copying each element into a NEW VECTOR

21:25 that's an O(1) operation

21:25 er i mean O(N)

21:25 if you want O(1), and you do, you can get that with pop:

21:25 ,(pop [1 2 3 4])

21:25 clojurebot: [1 2 3]

21:25 george_mcfly: cool

21:25 bbloom: since that's O(1), you're sure to get a vector back b/c the size i statically known and no copying or anything has to happen

21:25 george_mcfly: i'll have to read up on strictly evaluating

21:26 right

21:26 neat trick

21:26 almost too simple to call a trick really heh

21:26 bbloom: heh

21:26 if you're coming from Scala, you might be used to the CanBuildFrom thing. maybe?

21:26 george_mcfly: i'm not but good info nonetheless

21:28 bbloom: anyway, the point is that clojure provides data structures with runtime tuned for various needs, so use the right data structure! and whenever you need to do something O(N) no matter what, laziness kicks in and you get a seq

21:28 ,(pop '(1 2 3))

21:28 clojurebot: (2 3)

21:28 bbloom: ,(pop '[1 2 3])

21:28 clojurebot: [1 2]

21:28 bbloom: ,(conj '(1 2 3) 4)

21:28 clojurebot: (4 1 2 3)

21:28 bbloom: ,(conj '[1 2 3] 4)

21:28 clojurebot: [1 2 3 4]

21:29 bbloom: lists are built from the front, vectors from the rear b/c of their internal structure and performance guarentees

21:29 brighid: Okay this still isn't working, and I don't think I gave enough information the first time about what my problem was. Here's what I'm currently trying: https://gist.github.com/brighid/5234382 That gives me the contents of the file that I want, but it needs an absolute filesystem path. How can I go from that to a relative-to-my-project path?

21:34 xeqi_: brighid: try (io/resource "bar.conf")

21:36 brighid: xeqi: In place of the io/reader call?

21:36 bbloom: brighid: as an argument to it

21:37 xeqi: I think in replacement of the path

21:38 though I've rarely needed a pushbackreader, so there might be a different spot depending on how you are using it

21:38 gfredericks: if (io/resource "bar.conf") returns nil at the repl then I think something is wrong

21:39 xeqi: if you made the resources/ dir after starting the repl you might need to restart it

21:40 gfredericks: ah ha; good thought

21:40 brighid: Good point. *restarts nrepl*

21:41 (io/resource "bar.conf") => #<URL file:/Users/brighid/Dropbox/clojure/...> \o/

21:42 gfredericks: hoo-ray

21:43 brighid: Okay, this version works: https://gist.github.com/brighid/5234382

21:43 Thank you folks. :) I didn't get *where* to use #'io/resource at first, also I think that the REPL indeed hadn't seen the file.

21:44 gfredericks: presumably leiningen doesn't see the point in adding non-existent directories to the classpath

21:45 brighid: gfredericks: a reasonable enough decisions.

21:51 hyPiRion: blech, why bother DDoSing Freenode?

21:52 headshot: why bother ddosing anything?

21:53 gfredericks: D-DOS: for when you can't get enough DOS

21:53 * gfredericks hasn't heard anybody talk about DOS in like years or something

21:55 gfredericks: oh wow I forgot it had a logo with bubble letters

22:22 maxb2: nick maxb_

23:09 wei_: in a compojure app: where's the best place to call to connect to my db so that lein ring server connects to the db?

23:14 akhudek: wei_: I always just use a main that does initialization of this sort then runs the server via the ring jetty adapter

23:14 wei_: i see. that's what I settled on just now

23:15 akhudek: though connection pooling would avoid that as the pool will initiate connections as needed

23:15 think korma has connection pooling built in

23:15 no doubt there is a way to add it easily for clojure.jdbc too

Logging service provided by n01se.net