#clojure logs

2013-03-24

01:06chessguyanybody 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..
01:07arrdemgo for it..
01:07arrdemno rest for the wicked.. or those designing the impossible XP
01:07chessguyhttps://gist.github.com/arwagner/5230640
01:07chessguyi'm pretty sure it can be done in about 5 lines. i'm getting a null reference exception right now
01:10arrdemchessguy: sorry it's past my bedtime and I have the attention span of a squirrel on meth. gimme a minute here.
01:10chessguyarrdem: no worries, i know it's terrible code
01:11arrdemchessguy: it actually isn'
01:11arrdemt bad... just not something there's really a reason to do. hang on.
01:11arrdemnew emacs instance..
01:11arrdemnrepl...
01:11arrdemand code.
01:11arrdemokay.
01:13arrdemfirst thing.. I would write similar (map key) as similar (key map)
01:13arrdemthat way it's a little less confusing with clojure.core/map
01:13arrdembut that's correct so it's not your error.
01:14chessguyhm, ok. i know that a lot of functions that operate on collections take the collection as the first argument
01:14chessguyso i was trying to follow that
01:14chessguybut i see your point
01:14arrdemI mean....
01:14arrdem,(extends? IFn {})
01:14clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: IFn in this context, compiling:(NO_SOURCE_PATH:0:0)>
01:14arrdemgoddamnit clojurebot.
01:14arrdemanyway {} is a function...
01:14chessguyyes
01:15chessguyand so are its keys
01:15tbaldridge,(ifn? {})
01:15clojurebottrue
01:15arrdem(inc tbaldridge)
01:15lazybot⇒ 2
01:15tbaldridge(fn? {})
01:15tbaldridge,(fn? {})
01:15clojurebotfalse
01:15chessguy,(ifn? :foo)
01:15clojurebottrue
01:15chessguy,(fn? :foo)
01:15clojurebotfalse
01:16tbaldridgefn? is only true for clojure functions, trivia fact.
01:16tbaldridge,(fn? #())
01:16clojurebottrue
01:16chessguymakes sense
01:17tbaldridgeyeah, but it'll trip you up sometimes, so use ifn? most of the time. :-)
01:18chessguyso, arrdem, you were saying there's no reason to do this?
01:19arrdemchessguy: I mean it's a cute exercise in the language.. but we have {} as you clearly know
01:19chessguyyes...
01:19arrdemI'm legitimately curious why it's wrong.
01:19chessguythis is more than {}...
01:20chessguyit's a partition
01:20bbloomevery time i try to use a zipper, i find them to be more trouble than their worth :-/
01:20chessguybbloom: i kinda feel that way too. played with them for a long time in haskell
01:20bblooms/their/they're/
01:24chessguyam i missing something obvious?
01:24arrdemchessguy: not that I'm seeing off the bat
01:24chessguyarrdem: i mean in both the approach and the execution
01:26arrdemchessguy: so the approach seems fine...
01:26arrdemtrying to debug (contains?) plz hold
01:27chessguyoh i found it
01:27chessguy(keys {}) is nil...
01:28chessguyi was expecting it to be an empty vector
01:28arrdemoh that'd do it.
01:29arrdem,(contains? nil true)
01:29clojurebotfalse
01:29arrdemno...
01:30chessguy(vec (keys {}))
01:30chessguy,(vec (keys {}))
01:30clojurebot[]
01:30arrdemOH
01:31arrdemnamespace.
01:31chessguyhm?
01:31clojurebotbenchmarking is https://github.com/hugoduncan/criterium
01:31arrdemyou define contains? and then expect it to operate recursively.
01:31chessguyoh geez
01:31arrdemyou need to specify clojure.core/contains? on line 15 in contains?
01:31chessguyyeah
01:31arrdemololol that was a cute bug
01:32chessguyyeah, that fixes it
01:33arrdemchessguy: it'd be interesting if you could adapt this to take N partition functions and allow for the nesting case cleanly
01:33chessguyarrdem: nesting case?
01:34chessguyarrdem: like, make a tree out of it?
01:34arrdemyep!
01:34chessguywould be easy to define a BST i suppose
01:35arrdemso the first level uses function F, second G, third H and soforth.
01:35arrdemwhich are not nessicaraly equivalent.
01:35chessguyhm, this still isn't quite right.
01:35arrdemnot sure if it'd be usefull, but it'd be cute. a hashing with bucket implemetation as it were.
01:36chessguyarrdem: i feel like there has to be a more idiomatic way...
01:38arrdemworking on a -> based version for my own entertainment..
01:38chessguyarrdem: there's a bit in this. if you pass in two items that hash to the same key, it fails
01:39chessguys/bit/bug/
01:39chessguyman i'm tired...
01:44arrdemchessguy: a simpler contains-any-like? would just be (map ((:hash-function map) item))
01:44arrdembecause if true it'll be the sub-map and if false it'll be nil
01:44arrdemand anything but nil I believe is truthy
01:44chessguythat makes my head hurt...
01:44chessguyi really need to rename that field
01:45arrdemor just use .map..
01:45chessguyhm?
01:45clojurebotbenchmarking is https://github.com/hugoduncan/criterium
01:45chessguyshutup, clojurebot
01:45arrdem,(doc defrecord)
01:45clojurebot"([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...
01:45arrdemyeah cool.
01:46arrdemso your Hashtable compiles to a java class.
01:46arrdemtherefore you can use (.map instance)
01:46arrdemas well as (:map instance)
01:46arrdemand (. instance map)
01:46chessguyoh
01:46chessguymeh. i just renamed it to data
01:47chessguystill can't figure out why a second item with the same hash is overwriting instead of conj'ing
01:48arrdem,(conj #{:foo} :bar)
01:48clojurebot#{:foo :bar}
01:48arrdem,(conj nil :bar)
01:48clojurebot(:bar)
01:48arrdem,(set (conj nil :bar))
01:48clojurebot#{:bar}
01:49chessguythat could replace my if statement, i suppose
01:50arrdemyep that's the idea
01:50chessguystill doesn't work...
01:51chessguyhere's the latest version: https://gist.github.com/arwagner/5230640
01:52chessguyoh, i've still got some :map's in there
01:52chessguynow it works
01:54arrdemI b0rked mine -_-
01:55chessguyok, it's really time for bed now...
01:56chessguythanks!
01:59arohnerin typed clojure, how do I "get rid of" a (U nil)?
02:00arohnernvm, user error
02:22Raynesarohner: The exception was between the chair and the keyboard?
02:22arohnerRaynes: yes
02:22Raynes:p
02:22arrdemdarn IO exceptions get me every time
02:22arohnerthough I also gave up, because the type for datomic.api/q is a bitch
02:23arohnerI couldn't convince typed that (q '[:find ?e .. :where [?e ...]]) always returns a long
02:25arohnerhrm, though if I sleep on it, I can probably make that happen
02:25arohnerhrm, nvm, dealing with :in is going to be a problem
02:41Raynesarrdem: ImADamnedIdiotException
02:42arrdemRaynes: InsufficientCoffeeException
02:43Raynesarrdem: That's genius!
02:44arrdemso I'm working on a math library for rationals, irrationals, (Double is close enough to real) Irrationals, symbols and values with errors.
02:45arrdemis it cheating to allow arithmatic operations to return "expressions" when they cannot be exactly computed due to types or the presence of symbols?
02:55paddymahoneyso, when symbols are present, you probably want to return a lambda with those symbols bound? is that correct?
02:55arrdempaddymahoney: when I go to eval with binding yes... but I would like to keep it all symbolic for as long as possible.
02:57tomojin pedestal, how do you deal with :input events?
02:57RaynesYou use compojure.
02:57Raynes~rimshot
02:57clojurebotBadum, *tish*
02:57paddymahoneyI see, so you probably need a function (free-vars symbolic-exp) => (listof symbol)
02:58paddymahoneyand then a wrap function...(wrap symbolic-body vars) => lambda vars symbolic-body
02:59muhooTimMc: thanks!
02:59RaynesNot totally sure what you're trying to do.
03:00arrdemherm... should my eval take a bindings form or assume that all vals are def'd in the current namespace?
03:00arrdems/vals/symbols
03:00RaynesOh, I thought he was asking a question, not you.
03:03paddymahoneyarrdem: 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.
03:04danneuRaynes: i'm learning a lot reading your laser lib's source. it's easy to understand
03:04arrdempaddymahoney: herm I guess that'd work.
03:04RaynesReally? Nice. That's some of the most complicated stuff I've written. Give yourself a solid pat on the back, sir.
03:04arrdemlemme finish the quick demo I'm working on and see what you think.
03:04paddymahoneyI'm interested! :)
03:05arrdempaddymahoney: fair warning the second system effect is in full swing as is sleep deprivation.
03:08arrdem(* a (/ b c)) == (/ (* a b) c), yes?
03:10Raynesdanneu: Simple and easy to understand was a goal, so I'm happy to hear that at least one person thinks I may have succeeded.
03:11RaynesNot that people think I haven't succeeded. You're just the first person to comment on the code. ;)
03:11RaynesExcept for amalloy, but he complains in general.
03:13paddymahoneyarrdem: I don't think that is true.
03:13amalloyhaven't read the backlog, but i'm sure Raynes has said something wrong recently
03:13Rayneslol
03:17arrdempaddymahoney: no that has to be true because it gives == (* a b (/ 1 c)) which _is_ true.
03:17paddymahoneyah I was confused. a*(b/c) == (a*b)/c.
03:18paddymahoneypaddymahoney is sad his is.
03:19paddymahoneymy prefix to infix parser is broken :(
03:45arrdem*bed
03:54MikeSethhmmm
04:01MikeSethI 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?
04:04arrdem,(group-by #(= (first %1) 3) (vector [1 2 3 5 4 6 7 8 3] (range 9))
04:04clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
04:04arrdem,(group-by #(= (first %1) 3) (vector [1 2 3 5 4 6 7 8 3] (range 9)))
04:04clojurebot{false [[1 2 3 5 4 ...] (0 1 2 3 4 ...)]}
04:05arrdem(vector [1 2 3 5 4 6 7 8 3] (range 9))
04:05arrdem,(vector [1 2 3 5 4 6 7 8 3] (range 9))
04:05clojurebot[[1 2 3 5 4 ...] (0 1 2 3 4 ...)]
04:05arrdem,(map vector [1 2 3 5 4 6 7 8 3] (range 9))
04:05clojurebot([1 0] [2 1] [3 2] [5 3] [4 4] ...)
04:05arrdem,(group-by #(= (first %1) 3) (map vector [1 2 3 5 4 6 7 8 3] (range 9)))
04:05clojurebot{false [[1 0] [2 1] [5 3] [4 4] [6 5] ...], true [[3 2] [3 8]]}
04:05MikeSethaha
04:05arrdemhah. gross and not lazy but that's one way.
04:05SegFaultAXUgh, no.
04:06arrdemSegFaultAX: fix my shit. have fun :D
04:06SegFaultAXyogthos: I have to say I didn't like that list video you posted on proggit.
04:06SegFaultAXyogthos: I thought the speaker was awful. :/
04:07SegFaultAXMikeSeth: What are you really trying to do?
04:08MikeSethSegFaultAX: terminal emulator has method to the effect of [x y str]
04:08MikeSeththere's no way to move cursor relatively etc
04:08MikeSethso I have a list of strings each corresponding to a vertical screen position
04:09SegFaultAXMikeSeth: Ok, so what's the problem?
04:10RaynesSegFaultAX: Paul ingles?
04:10RaynesIngles, even
04:10SegFaultAXRaynes: Yea.
04:10RaynesWhy don't you like him?
04:10SegFaultAXIt's not him I don't like. The talk is terrible.
04:11SegFaultAXHe 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.
04:11RaynesI see.
04:11RaynesI haven't actually seen the talk.
04:12RaynesI emailed Paul once so he is one of my closest friends and stuff.
04:12SegFaultAXBasically 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.
04:12RaynesOr something.
04:12SegFaultAXOr something.
04:17SegFaultAXMikeSeth: Still looking for help?
04:53danneuRaynes: are you there?
04:56Raynesdanneu: Yes.
04:58danneuRaynes: can laser.core/and be rewritten with every-pred: https://gist.github.com/danneu/d2177a9ca4be8d1190be
04:58danneui found every-pred when looking in stdlib when i was trying to do the same thing
04:59danneuwell ive gotta drive home. cya
05:02RaynesFor those watching: the answer is yes, and I commented as such.
05:46roccois there anyone here who'd be willing to answer a question I have?
05:50ivanrocco: you picked the worst freenode time but maybe
05:50ivan(always just ask)
05:50roccoI'll keep that in mind for the future
05:50roccoI'd just like to know how instances of java classes are disposed when I run them in the repl
05:51roccodo I need to dispose them?
05:51ivannope, the JVM's GC will kick in and garbage-collect them (unless they're still in your *1 *2 *3 REPL vars)
05:51roccoI don't like the idea of leaving garbage behind me so I'd just like to clarify for myself what happens
05:52roccoin the repl vars or otherwise referenced, right?
05:52ivanall you have to do is not leave any references to things you want garbage-collected
05:52ivanyes
05:52roccook
05:53roccoI worry about this when I create gui windows and such
05:53roccoI wonder what happens when I close them
05:53roccobut those are classes like any other really
05:54ivanthese 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
05:55roccoI see
05:55roccovery useful
05:55roccocan you suggest other tools off the top of your head? I'm looking to equip my programmer shed :)
05:56ivanfor memory leaks in particular?
05:58roccoI meant in regards to clojure in general but that may be too much..
05:59ivanrecently I learned of java -XX:+PrintFlagsFinal and -XX:+PrintCompilation, those can be useful
05:59ivanhttps://gist.github.com/rednaxelafx/1165804 scroll down to know what the JVM spends all its time doing
06:01ivanbut clojure instead of jvm? you probably already know nrepl.el
06:03roccoactually I didn't
06:03ivansee also http://www.clojure-doc.org/ and Joy of Clojure
06:03roccoI was playing with emacs environ some time back
06:03rocconow I'm looking to start experimenting again with clojure
06:05roccoI've read some joy of clojure
06:05roccohaven't finished it yet
06:06roccowhat I read was great
06:07roccoso which is the preferred site currently - clojuredocs or clojure-doc
06:07roccoI'm trying to get a feeling for what has changed while I wasn't paying attention
06:08ivanclojuredocs is mostly abandoned and stuck on 1.3
06:10roccogood to know
06:12ivanit still has a lot of useful examples that have not been migrated yet
06:13arkxMigrated where? Does clojure-doc.org have API reference section somewhere?
06:14ivanI 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
06:14arkxYeah. :|
06:23modulusHi there. A couple of questions if anyone's around and wakeful.
06:24modulusi do (require 'clojure.set) (intersection #{} #{}) and the symbol intersection seems not to be defined, any clues why?
06:24modulusthe require statement gives me a nice nil, no errors.
06:25AimHereclojure.set/intersection should work
06:25modulusoh damn, i tried clojure.set.intersection but of course it's a /
06:25modulusthanks
07:06lpetithello
07:07fractasticalCan anyone give me advice on frameworks to use for creating a REST API ?
07:07fractasticalI've looked at a few tutorials and also discovered liberator
07:07fractasticalsometimes hard to see how much certain libraries are being maintained
09:44navgeetIs there any way to get the environment in a function, not like it's available as &env in a macro.
10:41edwI'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:52ravsterquestion about liberator: do the post!, put!, get!, etc. actions only get called if its a POST, PUT, GET, etc request?
10:53ravsterwell, maybe not get!, but delete! ?
11:06technomancyedw: iirc it's part of ritz
11:07edwAh. Don't feel like drinking that bowl of Kool-Aid just right now.
11:11hugodedw: should be as simple as the config shown in https://github.com/pallet/ritz/tree/develop/nrepl-middleware#usage
11:12ravsterusing undocumented apis is always so much fun. *sigh*
11:13edwAh! 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:23gfredericksha; clojure.org/special_forms suggests docstrings should be 1-3 lines
11:24hyPiRiongfredericks: But they can be very long.
11:25gfredericksthe lines you mean? :)
11:25hyPiRionyeah :)
11:25gfredericksgood ole clojure
11:26edwOK, so C-c C-j is working but it's opening a browser window with a search string containing "+javadoc"; any ideas?
11:36edwAh. 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:37edwA project for another weekend.
13:03zakwilsonIt 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:39chessguy'afternoon ya'all
13:39satch5150hi 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:41satch5150I am not to up on ipv6 and I tried to connect via a ipv6 version of the localhost ip, but still fails
13:41satch5150anyway, what can I do ?
13:43satch5150anyone ?
13:44zakwilsonThis 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:44satch5150thanks
14:05tomojsatch5150: hmm the lein changelog for 2.0.0-preview10 says "Make repl listen on 127.0.0.1 instead of localhost to address IPv6 issues."
14:10satch5150tomoj: I just turned off ipv6 on my linux machine, nrepl now listening on ipv4, but I still get a connection refused
14:11satch5150using this to try to connect: lein repl :connect nrepl://localhost:43509
14:15satch5150I 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:15satch5150or activated I mean
14:17satch5150indeed, selinux is disabled
14:17satch5150what else could be causing this
14:17satch5150?
14:20MikeSethSegFaultAX: sorry for bailing earlier
14:21satch5150just 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:23satch5150I get a connection refused error, followed the names of java classes with line numbers where they all had trouble
14:28MikeSethsatch5150: can you connect with telnet?
14:28satch5150not even sure I have a telnet client :) - I'll see though
14:29MikeSethsatch5150: try a browser with http://...
14:30satch5150telnet connected
14:31MikeSethsatch5150: try lein repl 43509
14:31MikeSethw/o hostname
14:31MikeSether, lein repl connect 43509
14:31MikeSether, lein repl :connect 43509
14:32satch5150MikeSeth: that seems to work :)
14:32MikeSethsatch5150: I dont think you're supposed to give it an URI
14:33satch5150MikeSeth: I am happy I have it working, but for arguments sake, what if I wanted to connect to a remote server ?
14:33MikeSethsatch5150: host:port
14:33MikeSethno nrepl:// prefix
14:33satch5150ah, I see
14:34satch5150thanks again :)
14:34MikeSethwelcome
14:38horseshoehi, oss.sonatype.org appears to be down and hence lein deps doesn't work, are there any workarounds ?
14:53borkdudewhy exactly doesn't have app-handler (wrap-resource "public") and war-handler does in noir.util.middleware?
15:03mstang_hello
15:03mstang_I have a kind of conceptual question
15:05mstang_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:06borkdudemstang_ probably an atom or a ref
15:06borkdudemstang_ unless you mean a browser session
15:07borkdudemstang_ or you can pass all the "global" data from one function to the other as a parameter
15:07mstang_no, I am "wrapping" a third-party library and they make a connection to a server
15:08mstang_something similar to a jdbc connection
15:09mstang_borkdude I am concerned with limiting the library to a single "session" at a time
15:11borkdudemstang_ in clojure.jdbc a dynamic var *db* is used for that and any database operations can be done with with-open
15:11borkdudemstang_ this way, the user of your library has to keep arround the session/connection himself and just feed it to with-open
15:13mstang_borkdude OK, I saw something similar with another SQL library
15:13borkdudemstang_ are you from NL btw? (your name sounds dutch)
15:14mstang_borkdude maybe a long time ago, via Germany, family immigrated from Germany, came with the name
15:14borkdudeah
15:15mstang_borkdude not sure where they got it ;-)
15:16mstang_bordkdude always wondered, found it meant "bar"...
15:18borkdudemstang_ correct
15:19mstang_borkdude "steel bar" "tavern bar"?
15:19borkdudemstang_ more like the bar in "behind bars"
15:19borkdudemstang_ so steel
15:24borkdudeyogthos|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:27mstang_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:29modulusso 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:29borkdudemodulus probably zipmap
15:30borkdudemstang_ I don't know. maybe keep them around in an atom or smth?
15:30modulusoh lol, that seems exactly what i need.
15:30mstang_borkdude smth?
15:30borkdudemstang_ something
15:30mstang_borkdude lol
15:31a|ithere is so much inconsistancy in clojure emacs docs.
15:31a|iis this out od date? http://clojure-doc.org/articles/tutorials/emacs.html
15:32a|idoes this work? https://github.com/overtone/emacs-live/tree/master/packs/live/clojure-pack/lib/clojure-mode
15:32a|iand what's this one? https://github.com/jochu/clojure-mode
15:33jjttjjthat second one was updated 2 months ago so i would assume it does work?
15:33jjttjj
15:33jjttjjand that third one says it's deprecated right at the top
15:33a|ijjttjj: the 2nd one doesn't work.
15:33jjttjjah
15:34a|ial I wanna do is to open up a repl and evalue a file in it.
15:35mstang_a|i nrepl
15:36a|imstang_: in emacs?
15:37mstang_a|i yes, it is on github, when installed into emacs, a control-c control-k will evaluate a buffer in nrepl
15:38mstang_a|i https://gist.github.com/rkneufeld/5126926
15:39mstang_a|i nrepl runs inside emacs
15:39a|imstang_: how is this different to emacs-live? I thought emacs-live bundles all the useful clojure stuff in emacs.
15:40mstang_a|i sorry, don't know anything about emacs-live, the url I sent was from a Clojure West Conference talk
15:41a|imstang_: thanks, I'll have a look into this now.
15:41zackzackzackAny ideas why leiningen might be hanging when I try to run the tests or repl?
15:41mstang_a|i last week, so I know it is current, nrepl gets you Clojure access, the rest is "just" learning emacs editing
15:43zackzackzackOh. I see why it's hanging now. It's not. The jvm is starting up. Somehow drip got disabled. Odd.
15:47a|imstang_: how is nrepl-jack-in connected to a specific project.clj?
15:49mstang_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:49a|imstang_: then why does it say: 'Open an nREPL session. Intelligently loads project context if launched from any file within a Leiningen project.'
15:50mstang_a|i ah, my guess is if you do it from within a project, not my style of development...
15:50mstang_a|i however, let me try...
15:54mstang_a|i not sure if it did anything when I executed nrepl-jack-in
15:54a|imstang_: did you try C-c M-j or M-x nrepl-jack-in ?
15:55mstang_a|j M-x nrepl-jack-in
15:55a|imstang_: I did that with having a file open. but it doesn't connect to the repl.
15:55a|iC-c C-e doesn't output in repl.
15:56mstang_a|i no, in the status at the bottom
15:56mstang_a|i messages
15:56a|iwhat's the pint of opening a repl then?
15:56a|ipoint*
15:57mstang_a|i well, if you open the messages buffer you can see it run
15:58a|imstang_: ok, but what's th epoint of openning a repl?
15:58mstang_a|i C-c C-k to load the buffer
15:58a|imstang_: C-c C-k outputs in status line, not repl.
15:59a|imstang_: the repl namespace doesn't change from user, is that normal?
15:59mstang_a|i C-c M-n to switch the namespace
15:59mstang_a|i yes it is normal
16:01a|imstang_: does C-c C-k evaluate in repl and only output in the status line?
16:02mstang_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:03mstang_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:15nopromptRaynes: you around?
16:15Raynesnoprompt: Theoretically.
16:16nopromptRaynes: how did you get started with emacs? i'd like to give it another shot but i'm a hardcore vimmer.
16:17RaynesWell, I didn't come to Emacs from Vim so I don't have any big secrets for success there.
16:18nopromptoh haha, for some reason i thought you used vim before.
16:18RaynesIt'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:18RaynesI did.
16:18RaynesI 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:19arrdemRaynes: lol yeah I found your blog post ranting about not having elisp around a few days ago.
16:19borkdudeyogthos|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:20nopromptalrighty. i got evil-mode going. guess i'll just have to suck it up and figure out the rest. :)
16:20Raynesnoprompt: You've got to be willing to take a productivity hit for a week or two while you learn.
16:21arrdemnoprompt: that and I recommend trying emacs sans evil-mode before you use evil.
16:21RaynesYou'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:21chessguydon'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:21RaynesI'm not sure where I stand on evil-vs-no-evil.
16:22arrdemRaynes: it's a personality thing.
16:22arrdemI can handle key chords and was using them in vim before I started emacs-ing
16:22RaynesI 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:22nopromptRaynes: yeah, i was aware there'd be a performance hit. i'll take the advice though and drop evil-mode for now.
16:23nopromptbtw, how's that starter kit?
16:23RaynesIn that case, you should drop to about 3 MPH for a while.
16:23arrdemnoprompt: supposedly it's good but haven't tried it.
16:23Raynesevil-mode would have given you about 5MPH. ;P
16:23nopromptRaynes: that's what it was like when i first started learning vim.
16:23RaynesBut I'm quite satisfied with your confidence, sir.
16:24RaynesI've used bits and pieces of the starter kit, and generally trust technomancy to not mess up Emacs stuff.
16:24Raynes*shrug*
16:24RaynesThere is also emacs-live, but it looks horrible.
16:25arrdemit's abandonware and you'll have to patch a line but the sublime package is a nice wrapper over some stuff...
16:25arrdemgive's you control-c and control-p to copy/paste to system clipboard
16:25arrdemamong other things.
16:25RaynesWait, you guys don't use OS X?
16:26RaynesI didn't realize there were people left that didn't.
16:26arrdemI'm running Arch Linux on all my boxes.
16:26RaynesYou poor thing.
16:26arrdemlol
16:26arrdem!dice
16:26arrdemhum...
16:26arrdem~dice
16:26clojurebotHuh?
16:26Raynes$dice maybe? :(
16:26noprompti use os x.
16:27Raynesnoprompt: 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:27tbaldridgeRaynes: there were waaay more Linux users at Clojure/West than at the Conj
16:27nopromptthe thing that kills me is the meta key.
16:28noprompti had to remap capslock to meta.
16:28tbaldridgeConj was about 10% mac. Clojure/West was about 30-40%
16:28Rayneswat
16:28arrdemTBH 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:28Raynesnoprompt: Remap capslock to control, dude.
16:29noprompti would be my muscle memory for control is pretty there already.
16:29nopromptfwiw, i actually tried to remap caps lock to control
16:29RaynesI used to be really adamant about not changing ctrls location.
16:29RaynesBut then work sent me a laptop with it pre-swapped for control and I was too lazy to change it.
16:29RaynesNever looked back.
16:31noprompti'm planning to get a type matrix pretty soon so the problem may not be a real issue http://typematrix.com/
16:32nopromptbeen wanting to get my hands on one for a while now
16:35arohnertbaldridge: I would have guessed C/W was 70% mac
16:35nopromptRaynes: do you use the gui version of emacs or terminal?
16:35Raynesnoprompt: GUI, for this isn't 1995.
16:36nopromptlmfao
16:36arrdemdespite being the resident Arch pants on head retard I also use the gui
16:36arrdemand why would you buy that... get a gaming mechanical and remap it.
16:37nopromptthe typematrix?
16:37nopromptbecause i like the layout
16:37RaynesI use a das.
16:37noprompti'd like to get a data hand but that's like 1K$
16:37RaynesPeople at work come by to watch me type. Some bring popcorn.
16:38nopromptRaynes: the best thing about the das is that punchy sound.
16:38RaynesThey have recorded albums of my das instrumentals.
16:39nopromptgives a new meaning to the phrase "keyboard solo"
16:40arrdemhaha
16:40nopromptRaynes: you should do a serious recording, and put a picture of yourself on the album cover dressed up as bach
16:40Rayneslol
16:41scottjnoprompt: seen truly ergonomic? I've used typematrix and te and prefer te. (though I prefer choc mini to both)
16:42scottjbtw remapping capslock to control AND escape is nice
16:43nopromptscottj: the te looks interesting. it has the vertical layout i like.
16:44nopromptthe placement of : and / might kill me a little
16:45nopromptscottj: what's nice about the choc mini? looks pretty standard to me.
16:46scottjnoprompt: yeah I like standard :) relatively short spacebar and pgup/pgdn are close. and fns directly above and lined up with # keys.
16:46arrdemthanks for mentioning the TE, that looks cool!
16:47scottjnoprompt: the change of placement on TE is VERY annoying
16:47arrdemabet a significant shift in key layour.
16:47arrdem*layout
16:47nopromptwhat would really be awesome if there was keyboard which let you physically reconfigure the keyboard some how
16:47nopromptinstead of doing it via software
16:48scottjhttp://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:48nopromptyou move a key to a different location but it still sends the original signal
16:48scottjnoprompt: I think kinesis advantage supports that, at least on the thumb keys
16:48arrdemnoprompt: there are a few of those...
16:48arrdemor at least I saw one years ago.
16:48nopromptreally?
16:48nopromptoh man i would love that
16:48arrdemyeah all the keys were done in software so the board was fully reconfigurable.
16:49arrdemit was pretty wacky.
16:50arrdemnoprompt: http://www.ergodex.com/mainpage.htm
16:51nopromptwhoa. that's wild.
16:51technomancyRaynes: am I too late to make a D&D joke on your "not sure where you stand on evil" comment?
16:51arrdemand it's at least a four year old product too...
16:52Raynestechnomancy: Never.
16:53technomancyRaynes: you should get your alignment checked
16:53noprompttechnomancy: nice
16:53RaynesDun dun dun
16:58nopromptarrdem: have you seen the wads keyboard?
16:58nopromptor rather, heard anything good about them?
16:58arrdemnoprompt: neg
16:58arrdemoh this isn't mwo. nil.
17:00nopromptspell check ruined that, wasd
17:02arrdemnoprompt: good grief that's an overkill mech keyboard
17:02arrdemchange the font of your keycaps ffs...
17:02arrdem*you can
17:02RaynesI want a wingding keyboard.
17:02noprompthehe, yeah a bit over the top, eh?
17:03nopromptRaynes: comic sans?
17:09borkdudelpetit is "load file in REPL" in ccw supposed to spawn a repl, without me having to press "Run"?
17:09lpetitborkdude: yes
17:12borkdudelpetit 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:13lpetitborkdude: you close the repl, this will also close the associated console
17:13borkdudelpetit 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:14lpetitborkdude: that's an unfortunate regression.
17:16borkdudelpetit 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:17lpetitborkdude: 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:19borkdudelpetit ok
17:19lpetitborkdude: thx
17:19nopromptscottj: did you say you can remap caps lock to both esc and cntrl?
17:19scottjnoprompt: yep
17:19noprompthow?
17:19clojurebotwith style and grace
17:19scottjnoprompt: what os?
17:20technomancyclojurebot: botsnack
17:20nopromptos x
17:20clojurebotThanks! Can I have chocolate next time
17:20scottj$google steve losh cadet keyboard
17:20scottjnoprompt: http://stevelosh.com/blog/2012/10/a-modern-space-cadet/
17:22borkdudelpetit hmm, it might be that my project is somehow broken. it works in another project in the same workspace
17:22lpetitborkdude: try to "Leiningen > Reset project"
17:22nopromptscottj: thanks
17:37borkdudeRaynes what is the common way to test code that normally uses the stateful sessions from lib-noir?
17:38RaynesPsh, like I test my websites.
17:38borkdudeRaynes I remember in noir there was something like with-noir … blabla
17:38Raynesborkdude: You can use binding to bind the unbound variable things. There might be something in lib-noir. yogthos would know more.
17:39yogthosmoi? :)
17:40yogthosI don't think there's anything special for testing stateful sessions, using binding would probably be the easiest
17:41borkdudeRaynes ah yes, binding
17:41xeqiborkdude: you could use my kerodon library if you want to test the full routes
17:41borkdudexeqi I will look at that… sounds interesting
17:42technomancykerodon is cool
17:43yogthosvery fancy :)
17:44borkdude(binding [noir.session/*noir-session* (atom {})] works
17:45borkdudekerodon looks very interesting though. :-)
17:45xeqijust depends on the level you want to test at
17:46yogthosborkdude: with-redefs can be handy too
17:46yogthosif you have something that goes to db for example, you could redef it with something that spits out some test data
17:53borkdudeyogthos yeah, that's very handy.
17:57nopromptscottj: oh man, this is definitely an improvement
17:57noprompti think i can start learning emacs now
17:59borkdudegnight
18:03pellishello
18:10pellisI'm wondering if anyone is doing async IO with clojure
18:12ravsteris liberator known to fiddle with ring-session?
18:14brehautpellis: https://github.com/ztellman/aleph
18:14amalloyi would have linked to lamina rather than aleph, but it's all the same i suppose
18:15brehautpellis: if you mean 'are people in clojure writing callback soups', the not so much
18:15brehautoh true. sorry
18:16pellis hm, not sure I prefer callback soup.
18:16pellisperhaps it is best if I give some context
18:17pellisu 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:18pellisso 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:19brehautpellis: so you want background workers?
18:19pelliswell not so much. everything works well right now - i'm using maps and pmaps and clojure is very nice to me
18:19pellisthe API was designed for server-to-server communication, so the traffic isn't really web-scale
18:20pellisright now I have a critical requirement, to push it towards "web scale" by letting users directly hit this API
18:21pellisin this case, I'm not sure I can waste so much resources on about threads where there's so much IO around
18:21pellisso 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:22pellisbut 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:22brehautwell, pmap frinstance is capped at available processors + 2
18:23pellisso 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:23pellisall 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:26technomancypellis: sounds like a job for message queues
18:26pellistechnomancy, though, i didn't mentioned this all should be real time
18:26technomancyoh, ok
18:26pellisor, at least synchronous (client hangs and waits for answer)
18:27pellisright now it takes around 0.7s for a call and there's a lot to improve (premature optimization)
18:29pellisso basically i'm stuck with finding a way to call Java code through node.js or find an evented framework for clojure
18:34amalloypellis: that'd be aleph/lamina for sure. nothing else in clojure comes close for evented networking
18:34zakwilsonIt 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:34pellisgreat, so I'll be sure to check lamina out
18:47ScruffyHello.
18:48zakwilsonIt'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:50rhickeybotkilluminati
18:51pelliszakwilson, isn't futures just a form of delayed execution?
18:52zakwilsonpellis: 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:55zakwilsonIn fact, pmap is pretty much just (map deref (map (future (f a-seq))))
18:56pelliszakwilson, thats interesting.. ill have to read about it
18:57zakwilsonpellis: 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:58pelliszakwilson, well, i'm running several algorithms on the same data, and then merging their result. these can run in parallel
18:59zakwilsonIf 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:59pellisand I figured letting the OS handle the IO in the case of evented, will be better than blocked out threads
19:00zakwilsonAnd if you have CPU-bound things that aren't already parallel, you can parallelize them the same way.
19:01zakwilsonIt 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:05pelliszakwilson, yup, i'll keep that in mind
19:07zakwilsonAnd 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:09pellisyep, 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:25number35hi all
19:25number35i would like to know if its possible to interleave two sequences with using only map and reduce
19:28zakwilsonI'm pretty sure it's not.
19:32dnolen,(reduce concat (map vector [1 2 3] ["one" "two" "three"]))
19:32clojurebot(1 "one" 2 "two" 3 ...)
19:32dnolen##(reduce concat (map vector [1 2 3] ["one" "two" "three"]))
19:32dnolennumber35: ^
19:33rplacanumber35: you can do it with mapcat by itself
19:33rplaca##(mapcat #(vector %1 %2) [:a :b :c] [1 2 3])
19:33number35thank you
19:33rplaca,(mapcat #(vector %1 %2) [:a :b :c] [1 2 3])
19:33clojurebot(:a 1 :b 2 :c ...)
19:33rplacawhich amounts to the same thing
19:36dnolennumber35: though unless you're solving puzzles, probably better to use interleave
19:38zakwilsonUsing concat or vector is not doing it using only map and reduce.
19:40dnolenzakwilson: is there *anything* you can do w/ *only* map and reduce? ;)
19:41zakwilsondnolen: I don't think so, because they both require a function as an argument. I think the question may have been poorly phrased.
19:45zakwilson"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:56hyPiRionrplaca: You could just use ##(mapcat vector [:a :b :c] [1 2 3])
19:56hyPiRionexcept lazybot is dead?
19:56rplacahyPiRion: yes, good point!
19:57hyPiRionRaynes ^
19:57hyPiRionOh, but Raynes is offline too. Hmm.
19:57rplaca#(foo %1 %2) is always a code smell :)
19:58rplacalazybot doesn't really exist. Raynes just answers by hand :)
19:58hyPiRionah, and Raynes lost power now.
19:58hyPiRionviable solution
20:02zakwilsonI'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:38bbloomLOL: http://www.haskell.org/haskellwiki/Monad_tutorials_timeline
20:38rplacathe graph there is the best part!
20:38bbloomrplaca: oh yeah, the graph made my laugh pretty hard
20:38rplacawith a curve like that, I think I'll invest
20:38rplacaof course, past results are no guarantee of future performance
20:38bbloomi 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:39akhudekthey need a graph like this: http://www.vayapotra.es/wordpress/wp-content/uploads/2009/02/2rmqi6o.gif
20:40bbloomnice.
20:49ambrosebsHow do I pprint a record so it shows the ctor name?
20:53rplacaambrosebs: you don't, without writing your own dispatch
20:54rplacathat seems to be a highly requested feature, so I'm planning to add a feature for that in the standard dispatch table
20:56bbloomfipp works on records, but not on lots of other stuff, heh
20:57bbloomambrosebs: give it a try & i'm happy to take patches to cover more things. should be pretty easy to add stuff
20:57ambrosebsI'll have a look.
20:57bbloomand thanks to octagon, somebody else on planet earth has tried it and so i was able to hammer out a bug or two
20:58brighidI'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:59brighidWhat's the right way to say "please give me the contents of this file in my project"?
21:00gfredericks(clojure.java.io/resource "my_project/bar.conf")
21:00gfredericksI recommend putting it in /resources instead of /src though
21:00bbloom(doc clojure.java.io/resource)
21:00clojurebot"([n] [n loader]); Returns the URL for a named resource. Use the context class loader if no loader is specified."
21:00gfredericksbut that coud should work either way
21:00brighidgfredericks: actually that's probably a good idea, thanks.
21:00brighid(the "put it in /resources" idea)
21:01gfredericks:) it's what it's for
21:03i_sdoes anyone know why (vals {}) => nil and not an empty seq?
21:03gfredericksnil is sort of an empty seq
21:03gfredericks,[(seq? nil) (empty? nil)]
21:03clojurebot[false true]
21:04gfredericks,(map seq [[] [1] [1 2]])
21:04clojurebot(nil (1) (1 2))
21:04i_shm, ok that helps
21:04hyPiRiongfredericks: oh man, you lost a great opportunity there
21:04hyPiRionHmm, was it
21:04gfrederickswill I ever get it back?
21:04hyPiRion~amalloy
21:04clojurebotamalloy is <amalloy> just use juxt, it'll be great
21:04hyPiRionyeah, that was it
21:04hyPiRion,((juxt seq? empty?) nil)
21:04clojurebot[false true]
21:04bbloomi_s: it's to facilitate "nil punning" where it is often desirable to treat empty sequences as falsey
21:05gfredericksyes, juxt is the best way to explain unrelated concepts :P
21:05hyPiRionbut but but
21:05hyPiRionJUXT!
21:05i_si see
21:05bbloomi_s: ##(if-let [v (vals {})] v :no-vals)
21:05gfredericks~juxt
21:05clojurebotjuxt is usually the right answer
21:05bbloom,(if-let [v (vals {})] v :no-vals)
21:05clojurebot:no-vals
21:05gfredericks&(doc vals)
21:06gfredericks,(doc vals)
21:06clojurebot"([map]); Returns a sequence of the map's values."
21:06gfrederickswell for all we know it's an implementation detail
21:06gfredericks,(list)
21:06clojurebot()
21:06bbloomalso fun:
21:06gfredericks,(list*)
21:06clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core$list-STAR->
21:06bbloom,()
21:06clojurebot()
21:07bbloomwhich weirded me out the first time i saw it
21:07gfredericks,'()
21:07clojurebot()
21:08gfredericks,''()
21:08clojurebot(quote ())
21:08gfredericks,(list* ())
21:08clojurebotnil
21:10gfredericksclojure: it's what you make of it.
21:11bbloomturing machines: it's what you make of them.
21:11gfredericksyou make busy beavers out of them
21:12brighidgfredericks: (clojure.java.io/resource "bar.conf") returns nil - what might I be doing wrong there?
21:13gfredericksis there a parent directory you're forgetting?
21:13gfredericksyou had one earlier
21:14i_swith the nil punning argument though, why doesn't (filter odd? [2 4 6]) => nil instead of ()
21:14bbloombrighid: that fn just delegates to the getResource method of the current class loader
21:14i_sseems inconsistent
21:14gfredericksi_s: it's lazy
21:14bbloombrighid: all info that applies to getResource also applies to clojure
21:14gfrederickslazy seq functions can't return nil
21:14bbloomfor example http://stackoverflow.com/questions/12103371/how-to-use-getclass-getresource-method
21:14i_shm touche
21:15gfredericksi_s: ideally they would but it's not feasible without giving up some laziness
21:15i_sright
21:15bbloom,(seq (filter odd? [2 4 6]))
21:15clojurebotnil
21:15gfredericksthe seq function is often used like ^that when you want to force the empty seq to nil
21:15brighidbbloom: Clojure is my introduction to Java, so I don't have an existing knowledge of "info that applies to getResource" :(
21:16gfredericks(when (seq ...) ...)
21:16bbloombrighid: i'm just telling you what to google for :-)
21:16brighidbbloom: Oh okay. Cheers.
21:16gfredericksbrighid: if you're using leiningen you can try `lein classpath` to double-check what's included in your classpath
21:16bbloombrighid: also, you can try in your REPL (source clojure.java.io/resource) and then work backwards from there
21:17brighidOh hey, #'source looks handy, thank you.
21:17hyPiRionThe best is most likely
21:17hyPiRion,(list? (list* (for [a [1]] a)))
21:17hyPiRionoh clojurebot, you so lazy
21:17hyPiRion,(list? (list* (for [a [1]] a)))
21:17hyPiRion:'(
21:17clojurebotfalse
21:17clojurebotfalse
21:18hiredman,(contains? (set (ancestors (class ()))) clojure.lang.Counted)
21:18clojurebottrue
21:23george_mcflywhy 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:23george_mcfly(= '(1 2 3) (drop-last [1 2 3 4]))
21:24bbloomgeorge_mcfly: no, clojure's sequence functions are generally lazy
21:24bbloomvectors have known size
21:24bbloomif you want to get a vector, you need to strictly evaluate, which you can do with vec or into []
21:24bbloom,(vec (drop-last [1 2 3 4]))
21:24clojurebot[1 2 3]
21:24bbloombut realize what this is doing: it's copying each element into a NEW VECTOR
21:25bbloomthat's an O(1) operation
21:25bbloomer i mean O(N)
21:25bbloomif you want O(1), and you do, you can get that with pop:
21:25bbloom,(pop [1 2 3 4])
21:25clojurebot[1 2 3]
21:25george_mcflycool
21:25bbloomsince 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:25george_mcflyi'll have to read up on strictly evaluating
21:26george_mcflyright
21:26george_mcflyneat trick
21:26george_mcflyalmost too simple to call a trick really heh
21:26bbloomheh
21:26bbloomif you're coming from Scala, you might be used to the CanBuildFrom thing. maybe?
21:26george_mcflyi'm not but good info nonetheless
21:28bbloomanyway, 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:28bbloom,(pop '(1 2 3))
21:28clojurebot(2 3)
21:28bbloom,(pop '[1 2 3])
21:28clojurebot[1 2]
21:28bbloom,(conj '(1 2 3) 4)
21:28clojurebot(4 1 2 3)
21:28bbloom,(conj '[1 2 3] 4)
21:28clojurebot[1 2 3 4]
21:29bbloomlists are built from the front, vectors from the rear b/c of their internal structure and performance guarentees
21:29brighidOkay 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:34xeqi_brighid: try (io/resource "bar.conf")
21:36brighidxeqi: In place of the io/reader call?
21:36bbloombrighid: as an argument to it
21:37xeqiI think in replacement of the path
21:38xeqithough I've rarely needed a pushbackreader, so there might be a different spot depending on how you are using it
21:38gfredericksif (io/resource "bar.conf") returns nil at the repl then I think something is wrong
21:39xeqiif you made the resources/ dir after starting the repl you might need to restart it
21:40gfredericksah ha; good thought
21:40brighidGood point. *restarts nrepl*
21:41brighid(io/resource "bar.conf") => #<URL file:/Users/brighid/Dropbox/clojure/...> \o/
21:42gfrederickshoo-ray
21:43brighidOkay, this version works: https://gist.github.com/brighid/5234382
21:43brighidThank 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:44gfrederickspresumably leiningen doesn't see the point in adding non-existent directories to the classpath
21:45brighidgfredericks: a reasonable enough decisions.
21:51hyPiRionblech, why bother DDoSing Freenode?
21:52headshotwhy bother ddosing anything?
21:53gfredericksD-DOS: for when you can't get enough DOS
21:55gfredericksoh wow I forgot it had a logo with bubble letters
22:22maxb2nick maxb_
23:09wei_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:14akhudekwei_: I always just use a main that does initialization of this sort then runs the server via the ring jetty adapter
23:14wei_i see. that's what I settled on just now
23:15akhudekthough connection pooling would avoid that as the pool will initiate connections as needed
23:15akhudekthink korma has connection pooling built in
23:15akhudekno doubt there is a way to add it easily for clojure.jdbc too