#clojure log - Nov 12 2012

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

0:32 dakrone: ibdknox: hey, I'm in Raleigh, gimme a holler when you're here and would like to compile lighttable on a 10.6 machine

4:04 sunkencityryleh: so there's no defmulti- why not?

4:08 Apage43: sunkencityryleh: (defn- foo [] … is the same as (defn ^:private foo [] ….

4:09 so you can (defmulti ^:private foo blah)

4:10 the shorthand version is only provided for defn, but you can use the metadata syntax (^:private) with all of the things that create vars

4:10 sunkencityryleh: ok so I'll just add the metadata then. I wondered if there was another reason. tnx.

4:11 iZZard: Hi

4:12 I need to ask a few questions..

4:13 Whats the primary platform for clojure?

4:13 _ulises: iZZard: don't ask to ask :)

4:13 iZZard: I'd say the JVM

4:13 iZZard: Yeah,

4:14 Could clojurescript replace it in the future?

4:14 _ulises: no idea and it'd depend on what you're building I'd say

4:15 iZZard: hmm.. I want a stable reliable platform for many years... for say Research?

4:16 _ulises: I'd go for the JVM

4:16 it's been around for a long time, it probably will be around for many more years

4:16 clgv: iZZard: no I dont think so

4:16 _ulises: not saying that JS won't; just saying that the JVM is already here

4:17 clgv: clojurescript compiles to javascript whose vms can not compete with the jvm, afaik

4:18 algernon: js is single-threaded

4:18 the JVM isn't

4:18 clgv: the mission statement is (last time I read it) to get clojure on all platforms that support javascript, not to replace clojure's implementation on the jvm

4:20 iZZard: So should I conclude that the JVM implementation will be kept primary (more documentations, code and people) till the open source JVM exists?

4:20 and ClojureScript a side project?

4:21 clgv: "till the open source JVM exists" what should that mean?

4:21 cmn: sounds like it should say "while"

4:21 iZZard: English is not my native....

4:22 clgv: cmn: no I meant the semantic behind that

4:22 iZZard: Oracle dosen't get Barmy....

4:22 cmn: the semantics change from till to while

4:23 iZZard: So what about it?

4:23 mattis: hi, how does line-seq handle blocking IO? does it need the stream to close before I can evaluate the elements?

4:24 clgv: clojurescript wont replace clojure imho

4:24 cmn: that wouldn't make any sense, no

4:24 iZZard: Can you assure it to me... I will be greatfull to you :)

4:25 clgv: iZZard: assure? do you want to sue someone if agaisnt all odds it wont?

4:30 iZZard`: So what about it?

4:30 Sir?

4:30 clojurebot: I will hold the money!

4:31 cmn: you won't get a press release stating that

4:31 clojure is mainly made for the jvm

4:31 iZZard`: hey I am simply a 17 year old school going boy.....

4:31 clgv: iZZard: if you want assurance you will have to make a contract with clojure/core I guess. then you have legal backup ;)

4:32 iZZard`: Ok, 'assure' looks a bit 'legal'......

4:32 clgv: iZZard: ah well then just start learning clojure ;)

4:33 it wont harm you to learn more than one language

4:33 iZZard`: Yeah, that's what I am doing... I want to make it my primary language too.

4:34 guys... Ok don;t assure it. Just tell me your views. :o

4:34 dont

4:34 _ulises: iZZard`: clojure on the jvm is a pretty good bet for the next few years I'd say

4:34 clgv: if you want to choose between clojure and clojurescript, you should decide based on the applications/programs you want to write. currently, clojurescript is mainly used in web development, though chris granger uses it for lighttable as well (which is not classic web dev, I'd say)

4:35 iZZard`: Light Table uses chromium sandbox... thats web dev

4:35 algernon: iZZard`: both will exist for the foreseeable future.

4:35 clgv: with "not classic web dev" I wanted to express that there is no classic web application running on a server as result ;)

4:36 iZZard`: So both do not compete with each other?

4:36 algernon: nope, they don't

4:36 they compliment each other

4:36 clgv: no. I never used clojurescript so far ;)

4:37 * algernon wrote gnome-shell extensions in cljs :]

4:37 iZZard`: So Clojure will be primarily for the JVM till the JVM exists?

4:43 clgv: algernon: ah they are using JS as well?

4:44 iZZard`: hmm?

4:45 ChongLi: there are some very important differences with data structures between JVM and CLJS

4:45 some of ClojureScript's data structures lack the structural sharing found in their JVM equivalents

4:46 algernon: clgv: yes

4:47 iZZard`: Can I say, that JVM will be the primary target in the future?

4:47 ChongLi: looks that way to me

4:47 clgv: algernon: so do they have a way to expose APIs of binary libs to JS?

4:49 iZZard`: Thank You.... You have assured me.

4:49 :)\

4:49 algernon: clgv: they have js bindigs for most glib-based libs, yup. (via some GObject introspectiong thingy I haven't looked into - I just use the results :)

4:49 ChongLi: besides, I don't think you have to worry about the JVM going anywhere

4:50 to say it has an enormous userbase would be an understatement

4:50 clgv: algernon: ah good to know. thx.

4:50 iZZard`: I was worrrying about clojure going away from JVM..

4:50 ChongLi: Clojure is designed to tap into and leverage that ecosystem

4:50 ejackson: ,(doc drop-while)

4:50 clojurebot: "([pred coll]); Returns a lazy sequence of the items in coll starting from the first item for which (pred item) returns nil."

4:51 ChongLi: iZZard`: even if it did you'd still be able to work with what is available now for a long time

4:52 iZZard`: ChongLi: But it won't... right? :)

4:52 ejackson: iZZard`: rest easy, the JVM is likely to remain the primary target

4:52 iZZard`: Thanks..

4:52 There's a haskell book called 'Learn You Some Haskell For Greater Good'

4:53 Is there a clojure equal?

4:53 sunkencityryleh: is memoization thread local?

4:54 as in memo-ttl ?

4:54 ,(doc memo-ttl)

4:54 clojurebot: It's greek to me.

4:57 ejackson: iZZard`: depends what you want, LYHFGG is pretty unique

4:58 generically, you can't go wrong with http://www.clojurebook.com/

4:58 the baba-yaga legs on the web page are an added bonus :)

4:59 sunkencityryleh: hm "Engaged Java developers are usually found working in demanding environments solving nontrivial, often domain-specific problems. "

4:59 shouldn't that be "Enraged Java developers...

5:00 clgv: :D

5:01 ejackson: indeed, indeed.

5:02 clgv: ejackson: and I though "baba yaga" is russian for "witch"

5:03 jakubH: sunkencityryleh: you are completely right :)

5:03 ejackson: yeah, one who's house is on chicken logs, right ?

5:03 chicken legs !!

5:04 http://en.wikipedia.org/wiki/Baba_Yaga

5:04 clgv: uuuh, that could be right. My memory on the movies is quite blurry ;)

5:05 ejackson: this is from my misspent your playing Sierra quest games - I think she turns up in Quest for Glory :)

5:05 s/your/youth/

5:07 sunkencityryleh: I liked the orally clojure programming book. But I really wish there was a clojure nutshell book.

5:07 oreilly

5:08 PudgePacket: I just installed leiningen on windows, any way to check where it actually installed itself to ?

5:10 ah nevermind, i figured it out

5:10 thorwil: i'm using friend with the interactive-form workflow. attempting to login redirects to http://localhost:8080/login?&login_failed=Y&username=. now how could i go about finding out what exactly goes wrong?

5:13 andrewmcveigh|wo: thorwil: looks like your login fn is not returning a username key.

5:17 thorwil: my code: https://www.refheap.com/paste/6569

5:19 POST to /login is handled by friend automatically. the redirect from /login to /login?&login_failed=Y&username= implies that friend indeed handles the POST, right?

5:20 andrewmcveigh|wo: yeah, that's what usually happens, but (from memory) usually, the &username=username - so I think somehow the username is not getting passed in at some point

5:22 thorwil: i'm actually surprised its not just "?&login_failed"

5:25 andrewmcveigh|wo: thorwil: I'm not seeing anything wrong with the "friend" part of your code. I can't really comment on the moustache bits, I've never used it.

5:28 thorwil: now where does firefox show request bodies

5:36 ebraminio: hi, is this some kind of pattern matching in clojure where this (let [[l & *left] left

5:36 [r & *right] right] ...)

5:36 be equal to

5:36 (let [l (first left)

5:36 *left (next left)

5:36 r (first right)

5:36 *right (next right)] ...)

5:38 i just want to know what clojure call this, no more :)

5:38 ejackson: destructuring ?

5:41 ebraminio: ejackson, thanks :)

5:41 thorwil: andrewmcveigh|wo: the POST body my form creates is correct. or does friend expect client-side hashing?

5:42 andrewmcveigh|wo: thorwil: no, not on the client side.

5:44 thorwil: it expects the login/user fn to return a map of {:username ... :password "hashstr"} - in this case your (def users) map should do that for users "admin" & "jane"

5:46 thorwil: yes, i'm working closely following the examples

5:48 andrewmcveigh|wo: thorwil: is your immutant/moustache using ring?

5:48 thorwil: andrewmcveigh|wo: yes

5:49 andrewmcveigh|wo: thorwil: maybe your ring request map is not using wrap-keyword-params ?

5:50 not sure that made sense...?

5:50 thorwil: andrewmcveigh|wo: oh, that sounds like a good lead. thanks so far, i will look into that after lunch

5:51 andrewmcveigh|wo: thorwil: np, hope it helps.

7:18 sunkencityryleh: Where can i find vimclojure with nrepl support? "The branch 'nrepl' does not exist." https://bitbucket.org/kotarak/vimclojure/src/43edac157b14/?at=nrepl

7:20 andrewmcveigh|wo: sunkencityryleh: I don't think there is one yet.

7:21 sunkencityryleh: hm, seems like there should be one in bitbucket somewhere https://bitbucket.org/kotarak/vimclojure/issue/82/use-nrepl

7:23 andrewmcveigh|wo: that branch did exist at one point (iirc), but I don't think it was ever finished/working.

7:23 sunkencityryleh: ah, ok.

7:23 damn, back to copy & paste then I guess.

7:25 andrewmcveigh|wo: It would be nice to have, an nRepl vimclojure for sure.

7:28 ambrosebs: Tim Pope was talking about making a Clojure plugin for vim on twitter.

7:28 clgv: andrewmcveigh|wo: you are sold to vim definitively? other wise there is Emacs or Eclipse+CCW

7:28 ambrosebs: Not exactly sure what he meant.

7:28 sunkencityryleh: I used emacs for 10+ years but switched to vim because the key commands was giving me trouble with RSI

7:29 wrists are much better now

7:29 andrewmcveigh|wo: clgv: I'm pretty heavily invested in vim, but I've been contemplating giving emacs another go recently.

7:30 sunkencityryleh: though I guess emacs is the way to go for LISP

7:30 maybe I could try evil mode

7:30 lucian: sunkencityryleh: it's pretty good

7:31 ambrosebs: tpope: Are you going to write a new Clojure plugin for vim?

7:37 ticking: anybody some insight on math.cobinatorics? It's supposed to be lazy, but blows up on infinite sequences, so I'm not sure how lazy it _actually_ is.

7:41 clgv: ticking: what exactly do you use?

7:41 sunkencityryleh: lucian: setting it up now

7:41 ambrosebs: Do we know which Conj Unsessions will be presented?

7:42 augustl: ambrosebs: I haven't been informed at least

7:42 (and i have a suggestion on the list)

7:42 ticking: clgv, combinations

7:43 clgv: ticking: what does your blowing-up code look like?

7:43 ambrosebs: I guess we'll find out in the next few days :)

7:44 ticking: clgv, (take 5 (combinations (range) 2))

7:44 augustl: ambrosebs: I e-mailed them about it actually, I'll post here when I know more

7:45 ticking: clgv, I suspect its lazyness be to precalculate all elements of the form (1 x), but as x is infinite it will stall

7:45 clgv: ticking: well it's input is not allowed to be infinite

7:45 ticking: see here https://github.com/clojure/math.combinatorics/blob/master/src/main/clojure/clojure/math/combinatorics.clj#L70

7:47 ticking: clgv, right but this also means that it will use a huge amount of memory for huge lazy seq right?

7:49 clgv: ticking: yes

7:49 ticking: clgv, that is what I had feared :( I had hoped that it only needs to hold the current element plus some meta information

7:50 clgv, thanks ^^

7:51 clgv: ticking: but there is a formula to build that sequence you are looking for from (range)

7:52 ticking: clgv, the range thing wasn't what my production code looks like, there the seq is finite but a few gigs large ^^

7:52 clgv, I just wanted to check how lazy it actually is and a infinite seq seemed appropriate to test

7:53 clgv, in reality I'm calculating the levenstein distance between a huge bunch of words ^^

7:53 clgv: ticking: you want the inverse function here: http://en.wikipedia.org/wiki/Pairing_function

7:54 ticking: clgv, yeah but the infinite range thing would be even easier with (map #([1 %]) (range)) ;P

7:54 clgv, as range is infinite, you will never reach the tipping point :D

7:54 clgv: ticking: ah you only want the (1 n) tuples?

7:55 ticking: clgv, no it was an example to check how lazy combinations is

7:55 as I said above ^^

7:56 my production seq is a few hundred mb of different words, that I wan't to calculate the levenstein distance between

7:57 clgv: for `combinations` it has to fit into memory once.

7:58 Chiron: Hi, how to write a public field of java object in clojure ? https://github.com/nathanmarz/storm-contrib/blob/master/storm-kafka/src/jvm/storm/kafka/TestTopology.java#L31

7:59 ticking: clgv, yeah, I had hoped it doesn't :D

7:59 clgv, but it should be handable ^^

7:59 noidi: Chiron, IIRC (set! (.bar foo))

8:00 (set! (.bar foo) value)

8:00 ticking: clgv, thanks a lot ^^

8:00 clgv: ticking: well you could use the function I told you about above to avoid it

8:01 ticking: clgv, right and use it over the indices

8:01 clgv, I'll see how much will fit in memory and adapt if nessesary thanks :D

8:03 ambrosebs: augustl: that would be great

8:06 _ulises|away: when in the nrepl, where do the println messages go?

8:11 clgv: stdout

8:18 _ulises: clgv: fair enough; does that go to some buffer in emacs?

8:18 with the old slime setup messages went to the minibuffer or even to the repl buffer

8:19 oh but they do here with nrepl too

8:19 not when printing from another thread though :/

8:21 clgv: in CCW+Eclipse the println from another thread went to console output and not to the repl output

8:21 so maybe there is some analogue in emacs?

8:23 _ulises: clgv: I'd hope so; otherwise I'll have to do proper debugging instead of my ghetto-println debugging

8:24 clgv: _ulises: if this will be more than a toy project you should start using logging. tools.logging might help you there.

8:24 _ulises: clgv: that's what I was just thinking

8:25 clgv: while I have your attention, have you any experience with agents? I seem to remember that there was a *agent* var which pointed to the currently running agent?

8:25 clgv: _ulises: yes, this variable exists. I never used it though

8:25 ,(doc *agent*)

8:26 clojurebot: "; The agent currently running an action on this thread, else nil"

8:26 _ulises: ah, so it still exists, great, thanks

8:27 hum, logging doesn't strike me as active...

8:29 sunkencityryleh: which clojure mode should I use for emacs to get nrepl (I now run with evil mode)

8:30 _ulises: sunkencityryleh: I use the one that comes as part of the elpa packages

8:32 sunkencityryleh: _uilses: I installed "clojure-mode" and "nrepl" now with marmalade

8:34 Sgeo: ,{(Object.) 1 (Object.) 2} ; this makes sense but I can imagine it tripping up people

8:34 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Duplicate key: (Object.)>

8:42 sunkencityryleh: hm, nrepl seems to work pretty nice. but how the hey can i now do M-x nrepl when my meta key is ESC?

8:42 (running evil mode in vim)

8:42 emacs

8:42 :)

8:43 augustl: sunkencityryleh: in sequence

8:44 press esc, then x

8:44 or does evil mode override esc?

8:44 sunkencityryleh: yes :( I just found the section on "defining your own escape" in evil-modes docs

8:47 augustl: print screen maybe? Not a button I use a lot at least ;)

8:50 sunkencityryleh: augustl: maybe left alt could do the trick

8:50 augustl: that's the default one yeah

8:50 unless you run that strange OS some people seem to prefer, it's just called "10" or something I think.. ;)

8:51 jweiss: ,[(-> nil lazy-seq) (-> nil lazy-seq seq)]

8:51 clojurebot: [() nil]

8:52 jweiss: that confuses me

8:52 sunkencityryleh: nothing js ever easy when not in linux

8:54 jweiss: ah nevermind, (seq '()) is nil according to the docs

9:03 sunkencityryleh: ah, case closed. Had to check "Use alt as meta key" in terminal preferences. Successfully flipped a bit with M-x butterfly in evil mode after.

9:05 augustl: sunkencityryleh: ah, why not use Cocoa emacs? :)

9:07 sunkencityryleh: augustl: terminal is the way to go, multitask with Control-Z.. oh wait, that doesn't work in emacs.

9:10 ah, this is the shit. Damn, it has only taken a couple of years for clojure to get a decent repl, but now, it's good!

9:21 augustl: sunkencityryleh: sounds like an artifact of the lack of window management in OS X :)

9:22 sunkencityryleh: augustl: well, if I didn't do design from time to time I'd run linux with the tiling awesome window manager. I used to run wmii and was very happy with that.

9:25 Licenser: I've a odd problem with noir, I want to set a cookie value and it crashes with a 500, not even stack trace o.O.

9:26 augustl: sunkencityryleh: I'm currently experimenting with running Linux in a virtualbox with Win8 as a host, works very well so far actually

9:26 (so that I can use tablet features when I'm not programming)

9:29 sunkencityryleh: Licenser: I recently added [org.slf4j/slf4j-api "1.6.6"] [org.slf4j/slf4j-log4j12 "1.6.6"] and a log4.properties file to my compojure project and removed the wrap-exception middleware. A lot better exceptions and insight into what is happening. maybe that could work on noir as well.

9:30 Licenser: sunkencityryleh thanks for the hint I'll see if that is an option :)

9:30 sunkencityryleh: augustl: VMs are nice as long as you don't have to compile lots of C++ :)

9:31 augustl: true.. there's a performance loss

9:31 sunkencityryleh: mostly it doesn't matter but there are some things.

9:31 it's very nice to be able to save a working copy of the programming environment

9:33 _ulises: sunkencityryleh, augustl: I experimented running an EC2 instance as dev. env. and NX for the gui

9:33 sunkencityryleh, augustl: it works pretty well actually

9:34 augustl: _ulises: how do you run the GUI elsewhere? VNC or something?

9:34 _ulises: augustl: NX - it's an optimised X protocol which includes compression, encryption, etc.

9:35 augustl: it's far more performant than pure X and VNC

9:35 augustl: http://www.nomachine.com/

9:36 augustl: _ulises: very interesting, I'll look that up, thanks

9:36 sunkencityryleh: I ran an ec2 instance for a while and used an ssh client on the iPad. but the control characters didn't work all that great from a bluetooth keyboard so I gave it up.

9:36 augustl: thin clients ftw, my dream is to use a microsoft surface pro for real work :)

9:38 the surface pro is, after all, a real computer. It's hard getting work done on Windows when you work in a unix env though.. Hence the idea of using linux in virtualbox for work stuff.

9:41 sunkencityryleh: I find the web browser experience on windows 8 absolutely horrible. Coded a windows8 app awhile ago though in c# and it was a lot of fun. Had the idea to use clojure-clr but didn't have the time to get it up (was a hackathon). Liked the await stuff in c#.

9:47 _zach: Is there a particularly good way to extend a particular protocol implementation to all types that meet a certain interface?

9:48 Right now I'm extending LazySeq, PersistentVector, etc... in reality, I just want everything that's sequential

9:48 augustl: sunkencityryleh: I'm mostly using the desktop for now, since I don't have a tablet yet.. Tablet part would be mostly for reading PDFs and stuff.

9:51 clgv: _zach: extend on clojure.lang.Sequential

9:52 znDuff: _zach: I just tested that extending clojure.lang.ISeq works...

9:52 _zach: Thank you both.

9:52 That makes perfect sense.

9:53 znDuff: Hmm.

9:53 * znDuff doesn't know offhand what things are Sequential but don't implement ISeq.

9:54 _zach: That's okay, I have a much better idea what to look for now. Thanks!

9:56 clgv: ,(map #(instance? clojure.lang.Sequential %) [[] () (lazy-seq) (cons 1 nil) {} #{}])

9:56 clojurebot: (true true true true false ...)

9:56 clgv: &(map #(instance? clojure.lang.Sequential %) [[] () (lazy-seq) (cons 1 nil) {} #{}])

9:56 lazybot: ⇒ (true true true true false false)

9:58 _zach: Thanks clgv

10:25 randomenduser: hello, I'm reading 'Clojure Programming' and just read "lojure regex literals yield are entirely

10:25 equivalent to those you might create within Java, and therefore use the generally ex-

10:25 cellent java.util.regex regular expression implementation

10:25 (sorry for the spam)

10:26 what makes java's regex good? how does it compare w/pcre?

10:28 solussd: is there any way to add assertions / :pre conditions to the auto-generated constructor functions for records (i.e. ->Record and map->Record)?

10:28 znDuff: randomenduser: the Java documentation explicitly covers differences from PCRE.

10:29 randomenduser: search for "Comparison to Perl 5" in http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

10:29 randomenduser: znDuff: ahh, thanks. should've searched for 'perl' instead of 'pcre' :P

10:30 TimMc: I don

10:30 I don't know if Java's regex engine can be called "excellent", but it's not shitty.

10:32 mmitchell: Anyone have an opinion on what the best emacs start-kit w/clojure support is?

10:32 znDuff: mmitchell: emacs-live

10:32 solussd: I've seen some 3rd-party implementations defrecord, ie. "defrecord2", which might be a place to start if you want to add features

10:32 TimMc: http://swtch.com/~rsc/regexp/regexp1.html <-- interesting comparison of regex engines with pathological cases.

10:33 mmitchell: znDuff: ok cool, have you tried the original technomancy start-kit?

10:33 znDuff: mmitchell: ages ago.

10:33 randomenduser: I thought pcre was the desirable standard for regular expressions, why not ensure compatibility? reading the differences, they seem minor, but why not go for complete compatibility?

10:34 znDuff: randomenduser: Actually -- I'd say that Java's standard picks up too many things from PCRE.

10:34 randomenduser: znDuff: why is that?

10:34 znDuff: randomenduser: PCRE supports features which don't lend themselves to performant implementation. See also TimMc's link.

10:35 randomenduser: znDuff: gotcha, reading it now :)

10:35 TimMc: What I'd like to see is something that first check the pattern for certain characteristics, then picks an engine to use for it. :-P

10:36 You'd have to make sure that there are no pathological cases in the analysis step.

10:36 randomenduser: TimMc: sounds like a project to me

10:36 TimMc: Well, one problem is that the different engines out there generally have different feature sets, which complicates things.

10:37 gauravag: I am trying to write a simple tail recursive algorithm to find gcd of two numbers.. It is in this gist..

10:37 https://gist.github.com/4060000

10:37 even with relatively small numbers like 21 and 7

10:37 randomenduser: well you could pick the lowest common denomenator and annotate your implementation w/a big disclaimer

10:37 gauravag: I get a ArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1374)

10:37 in the repl..

10:38 znDuff: randomenduser: if one were using the lowest-common-denominator, you'd only need one engine for that -- which already exists, and is tremendously fast.

10:38 gauravag: can someone help me with the aboce?

10:39 randomenduser: znDuff: oh, looks like I have more reading to do then >.>

10:39 gfredericks: gauravag: a side note is that you don't need loop there

10:39 TimMc: What you could do is check if the pattern is a member of that set, then use the super-fast engine for it.

10:39 gfredericks: you can recur to the function itself

10:40 gauravag: I thought loop and recur were used for optimization by tail recursion

10:40 gfredericks: yes but you can use recur without loop

10:40 TimMc: So is fn/recur.

10:41 gfredericks: in any case I'm not convinced the algorithm is correct; so it might have something to do with that

10:41 I can imagine it exploding into large negative numbers

10:41 you could add a println to check that

10:42 gauravag: I really am just starting now with clojure.. not really sure how I add println..

10:43 TimMc: just say (println x y) after the loop line

10:43 The loop body can have multiple expressions, and only returns the value of the last one after executing them in sequence.

10:44 gauravag: all right cool..

10:44 btw I called the function using (gcd 4 2)

10:44 return 2, which is right

10:44 but with any number higher it bombs

10:45 gfredericks: my guess is that if it's wrong it's related to the fact that (- x y) isn't always smaller than y

10:46 gauravag: I always called it using x being created than y

10:46 greater*

10:46 let me try this very quickly..

10:47 gfredericks: sure but if you call it with 14 and 5 for example

10:47 14 - 5 = 9, which is still greater than 5

10:47 TimMc: I seem to recall the Euclidian GCD algorithm requiring that you switch the numbers if they are in the wrong order.

10:48 gfredericks: yeah that would probably fix it

10:48 the more efficient way of fixing it is using rem instead of subtraction

10:49 gauravag: (rem 21 7) gives 0!

10:49 AWizzArd: Is there a Leiningen plugin that works with Leiningen 2 (Preview 10), which packs a webapp into a .war file?

10:49 gauravag: am I doing something wrong here?

10:49 mmitchell: znDuff: so does the latest emacs-live require nREPL running in my projects in order to connect?

10:51 znDuff: mmitchell: it no longer supports slime/swank, if that's what you're asking.

10:51 gauravag: thanks guys.. updating the gist with the right algo..

10:52 mmitchell: znDuff: ahh ok, yes that's what I was asking, thanks. Is getting my app setup with nREPL pretty straight forward?

10:52 ejackson: ,(* 3 7)

10:52 clojurebot: 21

10:55 znDuff: mmitchell: it's not easier or harder than slime or swank, usually. There are corner cases where there are differences in ease-of-setup -- nrepl is easier to get going inside an OSGi container, for instance.

10:57 mmitchell: znDuff: cool ok, yeah just went through some of the nREPL docs, looks straight forward

11:02 gfredericks: gauravag: (rem 21 7) => is what you'd want for your algorithm

11:03 gauravag: gfredricks: yeah.. I have added a comment.. the last one shows the updated algorithm..

11:04 I wasn't aware that the sub can be replaced by rem though.. thank you for the tip..

11:07 gfredricks: it still has a few rough edges though..

11:32 edw: Anyone here know how to make a JS array a sequence in CLJS, off-hand?

11:33 scriptor: wouldn't just seq work?

11:34 edw: (Trying to use a JS object as an argument to GET-IN...)

11:34 One would think...

11:35 And that would be correct! It helps to specify the arguments of GET-IN in the correct order.

11:42 muhoo: AWizzArd: "lein ring war"

11:42 AWizzArd: actually "lein ring uberwar"

12:29 TimMc: gauravag: (if (< x y) (recur y x) ...)

12:30 Maybe that does it?

12:30 deg: I'm trying to do output within map within a with-open, but the stream is already closed. I assume that I'm misunderstanding the scoping model, or something...

12:30 (with-open [w (clojure.java.io/writer "hrules.chrif")] (map #(doto w (.write %)) [1 2 3 4 5]))

12:30 IOException Stream closed java.io.BufferedWriter.ensureOpen (:-1)

12:30 technomancy: clojurebot: map?

12:30 clojurebot: map is hiredman

12:30 technomancy: aw come on clojurebot

12:30 clojurebot: map?

12:30 clojurebot: map is *LAZY*

12:30 technomancy: ^^ there we go

12:30 TimMc: clojurebot: forget map |is| hiredman

12:30 clojurebot: I forgot that map is hiredman

12:31 technomancy: TimMc: I'm afraid that might be his inference engine kicking in

12:31 TimMc: ugh

12:31 technomancy: hiredman is lazy -> map is hiredman perhaps?

12:36 ieslick: I'm using the latest leiningen2 and trying to launch something that runs perfectly with lein swank, but I keep getting NullPointer or ClassDefNotFound errors using 'lein2 run'

12:36 I must be missing something basic around the classpath and main

12:37 e.g. Exception in thread "main" java.lang.NoClassDefFoundError: experiment/infra/protocols/Lifecycle at experiment.main__init.load(Unknown Source) at experiment.main__init.<clinit>(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at clojure.lang.RT.loadClassForName(RT.java:2056) at clojure.lang.RT.load(RT.java:419) at clojure.lang.RT.load(RT.java:400) at clojure.core$load$f

12:41 AWizzArd: muhoo: ah nice, I didn’t know that this was already integrated into ring.

12:44 TimMc: ~botsmack

12:44 clojurebot: Owww!

12:44 raek: ieslick: it sounds like you have ahead of time compiled code in your classes/ dir

12:45 and that you changed to a new clojure version

12:45 technomancy: noclassdef is usually not from clojure version mismatches

12:45 ieslick: <raek> It's a freshly pulled git distribution, I deleted target/classes, reran deps, etc. WIll look into version issues

12:46 technomancy: ieslick: protocols break when the underlying class files get wiped out from under them

12:46 ieslick: unlike regular Clojure defns they're unable to fall back to the JIT-compiled equivalents

12:46 one of many reasons not to use them if you don't need the speed they provide

12:47 ieslick: technomancy: so a fresh compile, followed by lein run should resolve?

12:47 technomancy: ieslick: depends on where the protocols are defined and where they're consumed

12:48 ieslick: Yeah, I tend to prefer multimethods but did some work with Relevance and Stuart Sierra added a bunch of protocols to the system

12:48 technomancy: ah, bummer

12:51 ieslick: However, all the protocols are in a single file with no external dependencies and are pulled in by a number of subsystems that implement or use them. Pretty simple.

12:52 lein deps :tree shows the use of a global :exclusion of clojure.org/clojure

12:53 If I remove that from the project.clj, then I clearly have version issues. I should have only clojure 1.4 pulled in with that added to top of projects.clj

12:58 Simple question then: is it imperative to aot compile protocol files for use in lein run vs. interactive use in lein swank?

12:58 technomancy: best to completely avoid AOT if possible

12:58 or rather: AOT everything, but during deployment only

12:59 ieslick: So add :aot :all to the deploy profile in lein2?

13:00 technomancy: sure

13:00 ieslick: (Appreciate the help, this part of clojure is fairly opaque to me despite a few years with the language, I rarely do anything outside lein swank)

13:00 technomancy: you can do it from the command-line as well: lein compile :all

13:00 yeah, my only experience with protocols is basically just helping people over IRC who find themselves in protocol-driven messes =)

13:00 ieslick: Ultimately trying to get this as part of an autodeploy script using chef... :)

13:01 Fortunately day to day use of protocols in the lein swank context has been a non-issue

13:03 Surprised there isn't a canonical "learning to live with defprotocol" document on Google...maybe when the curent project is over I'll add one!

13:04 ivenkys: Any suggestions for Clojure for Java,C++ devs ?

13:04 antares_: ivenkys: learning materials?

13:05 llasram: Huh. I haven't run into this problem when using protocols... Requiring the namespace which defines the protocol should create and load the class...

13:05 ivenkys: antares_: yup - google and stackoverflow are full of suggestions , but ultimately confusing - i am looking for people who have "walked that way"

13:05 technomancy: llasram: yeah, but if other code that uses the protocol has been AOTed then it can be a real mess

13:06 antares_: ivenkys: http://blip.tv/clojure/clojure-for-java-programmers-1-of-2-989128, http://blip.tv/clojure/clojure-for-java-programmers-2-of-2-989262, clojurebook.com and http://clojure-doc.org

13:07 ivenkys: antares_: are those videos the famous "ant demo"

13:08 antares_: ivenkys: I don't think so

13:08 ivenkys: antares_: ah ok - thanks -

13:12 llasram: technomancy: Oh, right. I was thinking of the no-AOT case, which is what I try to go for

13:13 mdaines: I must be missing it in the docs, but how to do you reload your code in lein? Doing (require ...) again doesn't do it

13:14 sorry, lien repl

13:14 antares_: mdaines: try (require … :reload :all)

13:16 mdaines: Hmm, was :all added recently? I get an unsupported op error.

13:17 Sorry, typo. Got it

13:17 Thanks, antares_

13:17 TimMc: antares_: Not :reload-all ?

13:20 nightfly_: Does emacs nrepl mode give you something like slimes C-c C-k and C-c C-c for compiling the currently edited file?

13:21 technomancy: nightfly_: sure; in most cases the bindings are the same

13:26 egghead: in maven, is there any way to get the same effect as 'lein uberjar' from the output of 'lein pom' ?

13:28 or is there any suggested way to integrate lein into jenkins?

13:29 technomancy: egghead: there's a jenkins plugin for lein, but it's so simple to just shell out that I don't know if it's worth bothering with

13:30 egghead: technomancy: just a pre-build execution phase directly invoking lein?

13:30 i.e. maintaining lein on the build box rather than via jenkins?

13:31 technomancy: egghead: right. you can manually install the lein plugin, or you can manually install leiningen itself.

13:32 I haven't done jenkins in a while but it doesn't seem like a lot of value-add

13:34 nightfly_: technomancy: Awesome! I guess I just tried C-c C-c, had it not work, and assumed all the bindings would be different.

13:35 technomancy: C-c C-c is an alias for C-M-x IIRC

14:01 Chiron: Hi, I have a seq of files and i want to post them to an endpoint in one post . i don't want to create a post for each file . would u please help with a snippet if that using clj-http ?

14:03 piranha: There was long discussion about reactive programming for uis in clojurescript in clojure-dev. I've read it and wikipedia page on reactive programming and it seems that unfortunately I'm unable to learn without examples. Can somebody share a link to CLJS app using reactive programming style? I just don't get idea at all. :(

14:04 technomancy: piranha: have you looked at elm at all?

14:04 augustl: piranha: not really an answer, but iirc the most common way to do UI programming in a functional style is to keep the mutable tree structure representing your UI, and treat it as I/O

14:04 technomancy: not cljs, but it looks like they have a lot of this stuff figured out: http://elm-lang.org/

14:04 piranha: technomancy: nope

14:04 ah!

14:04 this elm

14:05 yes, a bit... and also at RxJS

14:05 augustl: well, right, that's what I thought, and I even have started laying out my own thoughts: http://github.com/piranha/mesto - some in-memory storage (atom), which has ability to notify subscribers about updates

14:06 but as I think about it more, I'm wondering if I'm doing something really wrong, because of my bias towards Backbone.js-like model layer

14:06 augustl: UI programming is the only perfect use case for OO I'm aware of though.. just sayin' :)

14:07 nbeloglazov: Chiron: you want to use multipart post requests?

14:07 piranha: so if somebody could give me some feedback on that, that would be equally nice to good example :))

14:07 augustl: well... that's an uneasy thought, hah :-)

14:07 Chiron: yes

14:07 piranha: why would someone use cljs then? :P

14:07 augustl: I don't ;)

14:07 nbeloglazov: did you try functions from clj-http.multipart?

14:07 augustl: but now I'm _definitely_ not answering your question

14:08 piranha: augustl: :-)) sure, thanks anyway

14:10 nbeloglazov: Chiron: I think it's something like (multipart/create-multipart-entity (map #(multipart/make-file-body {:content %}) [file-1 file-2 file-3])))

14:14 Chiron: that is clj-http ?

14:17 nbeloglazov: Chiron: yes

14:18 At least it's in repo: https://github.com/dakrone/clj-http/blob/master/src/clj_http/multipart.clj

14:19 Chiron: oh i see

14:22 where to set the endpoint url ?

14:29 nbeloglazov: Chiron: there is actually an example on main page: https://github.com/dakrone/clj-http Search for "Multipart form uploads"

14:30 Netfeed: what's the best way to destruct the the content from a form into a regular hash in noir? i don't want to do something like {:keys [foo bar]} but i rather want it to be something like {:foo 1 :bar 2}

14:31 rodnaph: Netfeed: is that not what u start with?

14:31 nbeloglazov: I have 2 almost identical pieces of code. They both solve task 120 on 4clojure: https://www.4clojure.com/problem/120 . One of them passes all tests, the other fails with timed out exception. Only difference that I use (* v v) in the first and (Math/pow v 2) in the second. Is it caused by clojail?

14:31 https://www.refheap.com/paste/6589 code

14:32 Netfeed: rodnaph: honestly, i'm not really sure, i can't find any good examples for how i just get the "raw" in hash

14:33 technomancy: nbeloglazov: Math/pow forces everything into floats unfortunately

14:33 kind of ridiculous really

14:33 nbeloglazov: But there is on difference between 2 versions on local computer

14:33 rodnaph: Netfeed: i'd (println req) if u can see the console

14:33 nbeloglazov: But on 4clojure first one executes about 1-2 second. And second takes about 10 seconds with time out

14:38 Netfeed: ooh, should be {:as params} got to learn to read the docs properly

14:48 Tolstoy: Got a function (defn foo [x] ...)

14:48 A string "(foo 1)".

14:48 amalloy: don't do it, man

14:48 Tolstoy: But (eval (read-string "(foo 1)")) doesn't apply the function.

14:48 amalloy: this is just a one-off hack for some testing, not a Real App and Best Practice.

14:49 amalloy: eval is probably in a namespace/context where foo isn't imported

14:49 Tolstoy: Unable to resolve foo "blah".

14:49 amalloy: iirc it runs in clojure.core

14:49 Tolstoy: So, some sort of intern thing?

14:49 amalloy: uh?

14:50 i mean, you can probably (binding [*ns* (find-ns 'the-ns-with-foo)] (eval ...))

14:51 Tolstoy: So eval inside a namespace doesn't automatically, uh, do the evaluation in the context of the namespace?

14:51 amalloy: *ns* isn't bound at runtime, and if it were the results would be more confusing

14:53 Tolstoy: The binding you mentioned above got rid of the exceptions. Am I misunderstanding that eval calls a function?

14:54 amalloy: pretty much everything in clojure calls a function at some point

14:54 eval invokes the compiler on a form, in a null lexical context, and runs the bytecode that gets output

14:54 noidi: is there any way to do `foo.bar += 123` in ClojureScript?

14:54 Tolstoy: Ah, I'd messed up the expression. Seems to work, now.

14:55 Thanks!

15:02 antares_: noidi: ClojureScript data structures are immutable. Use an atom.

15:04 znDuff: noidi: it _can_ be done, but it's not at all idiomatic. Can you provide more details on your use case?

15:43 ToBeReplaced: preferred way to reconstruct url from request map? seems dirty/wrong to do (URL. (name scheme) server-name server-port uri)

15:47 trmsw: is anyone successfully using ritz + slime?

15:48 I can start the server and slime-connect doesn't give an error, but it doesn't give me a repl either

15:50 wingy: what does "sid" stand for?

15:51 trmsw: Sidney?

15:51 wingy: something with id

15:51 like uid = uniquie identifier

15:51 amalloy: i know some folks named sid

15:51 wingy: :)

15:54 jkkramer: ToBeReplaced: https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/util/request.clj#L4

15:54 ToBeReplaced: jkkramer thanks

15:57 trmsw: wingy: session id / special id / string id? Depends on context

16:02 rbxbx: Any thoughts as to why I'd be seeing "Error loading project.clj" when running lein new (or any other command that shouldn't require presence of said file ie: `lein repl` or just `lein`)

16:02 wingy: trmsw: yeah .. session id was a good shot

16:03 rbxbx: trmsw wingy session id is what I've typically seen

16:42 zackzackzack: Is it possible to do something like lein-checkouts but with java source files instead of clojure?

16:50 ieslick: Solution to earlier AOT loading problem in a main statement due to Protocols...

16:51 Directly referring to a protocol-carrying namespace from an aot compiled file like a -main function is the problem

16:51 If you have no _direct_ dependencies, then it loads fine. I presume that the classloader environment during compilation is different than during normal loading and that explains the errors

16:56 technomancy: hm... I wonder if we could move auto-AOT of :main to the uberjar task

16:57 ~60% of the time it's useless

16:57 clojurebot: forget botsnack is scoobysnack

16:57 technomancy: clojurebot: you're a laugh a minute; you know that?

16:57 clojurebot: ha ha

16:57 * technomancy reluctantly admits he loled

16:58 mdaines: Is there a naming convention on defrecords? CamelCase Skewer-Case ?

16:58 amalloy: camel

16:58 ieslick: It might be nice to require AOT compiling of main explicitly so it's less surprising when it barfs

16:59 technomancy: ieslick: yeah, I think the current behaviour is too clever

16:59 mdaines: amalloy, thanks. Is that because of Java interaction?

16:59 technomancy: ieslick: it made sense before the run task existed

16:59 amalloy: yes. a defrecord creates a named java class

17:07 tgoossens: hi

17:07 I don't understand what is going on here: ,reduce (fn [m i] (+ m 1)) 0

17:07 ,reduce (fn [m i] (+ m 1)) 0

17:07 clojurebot: #<core$reduce clojure.core$reduce@188ae07d>

17:08 tgoossens: what does this line of code mean?

17:09 zackzackzack: ,(reduce (fn [m i] (+ m 1)) 0)

17:09 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>

17:09 tgoossens: it a solution for the problem here: http://www.4clojure.com/problem/22#prob-title

17:09 my solution might be a bit overcomplicated

17:09 ,(fn [coll] (loop [index 0 c coll]

17:09 (if (empty? c) index (recur (+ index 1) (rest c)))))

17:09 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

17:09 tgoossens:

17:09 zackzackzack: reduce takes a function and a list and "folds" the list according to the function

17:09 tgoossens: yes

17:10 i know reduce. but i don't understand the way it is used there

17:10 i thought you had to do (reduce ...)

17:10 (syntax misunderstanding)

17:11 zackzackzack: You do. When you are using it that way in 4clojure, you are putting that code directly in there

17:11 tgoossens: oh. yes of course

17:11 stupid me

17:12 zackzackzack: You probably want (partial reduce #(inc %1)) or something

17:13 tgoossens: mm thats also cool

17:13 i guess that my solution is a bit bloated

17:13 zackzackzack: Yeah, this does it, (partial reduce (fn [m i] (+ 1 m)) 0)

17:14 tgoossens: not even sure whether it is efficient what i wrote

17:14 amalloy: tgoossens: your solution is fine. 4clojure solutions are sometimes written in as few characters as possible for fun

17:15 zackzackzack: Yeah, the one I gave is just using a bunch of built in functions from clojure to make it short.

17:15 danlarkin: 8

17:15 hiredman: 7

17:16 tgoossens: i just discovered 4clojure

17:18 its funny

17:19 mdaines: With records, can you "extend" them? For example, defrecord Alpha [a b c] ... defrecord Beta [... d]

17:19 wingy: what is new in 1.5?

17:24 Bronsa: reducers?

17:24 clojurebot: reducers are http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html

17:27 technomancy: poll: does anyone rely on the fact Leiningen makes :main trigger AOT outside the uberjar task?

17:27 I believe this is a misfeature but don't want to break things

17:30 muhoo: it does? weird.

17:31 technomancy: it used to make sense before the run task existed because :main used to only be about uberjars

17:31 wingy: Bronsa: need to understand it .. so hard

17:31 llasram: technomancy: nack

17:32 Raynes: muhoo: So, are you sold on monads yet?

17:33 technomancy: 2/2 in favour; motion passes

17:34 llasram: I love democracy!

17:35 technomancy: clojurebot: monad labyrinth is http://oglaf.com/labyrinth/

17:35 clojurebot: Roger.

17:50 TimMc: hmm

17:50 clojurebot: monad labyrinth is http://oglaf.com/labyrinth/ (SFW, but has NSFW links)

17:50 clojurebot: Ik begrijp

17:51 TimMc: clojurebot: forget monad labyrinth |is| http://oglaf.com/labyrinth/

17:51 clojurebot: I forgot that monad labyrinth is http://oglaf.com/labyrinth/

17:51 tgoossens: whats the difference between rest and next

17:51 amalloy: (= next (comp seq rest))

17:52 technomancy: TimMc: ah yes, good call; thanks

17:53 tgoossens: so the differnce is

17:53 it will return nil

17:54 and rest will return empty set

18:02 TimMc: empty seq

18:14 tgoossens: why would someone do this: (fn [xs] (= (map identity xs) (reverse xs))) instead of just (fn [xs] (= xs (reverse xs)))

18:14 has it to do something with laziness?

18:15 amalloy: &(= "racecar" (reverse "racecar"))

18:15 lazybot: ⇒ false

18:15 tgoossens: interesting

18:15 amalloy: &(= (seq "racecar") (reverse "racecar"))

18:15 lazybot: ⇒ true

18:31 Sgeo: Uh

18:31 I didn't just crash tryclj, did I?

18:32 unnali: netsplit!

18:34 Sgeo: How can I print out all the digits of Float/MAX_VALUE?

18:37 hyPiRion: ,(printf "%f" Float/MAX_VALUE)

18:38 clojurebot: 340282346638528860000000000000000000000.000000

18:39 Sgeo: Ah, thank you

18:40 ieure: Is there some way to speed up lein? I'm on 1.7.x and it takes upwards of 3m to uberjar a project with ~600 LOC.

18:41 Actually, never mind.

18:41 I have 800mb in resources

18:41 I bet that would do it, eh?

18:41 technomancy: ieure: any particular reason you're still on 1.x?

18:41 ieure: technomancy: Inertia.

18:42 technomancy: someone just told me they sped up uberjar by a factor of 1 hella by upgrading to 2.x

18:42 ieure: Is 2.0 final?

18:42 Last I checked it was still pre-release.

18:42 technomancy: it's super stable

18:42 it's only still in preview due to a technicality

18:42 even that will be addressed in a week or two

18:43 ieure: Awesome.

18:43 This is a side thing.

18:43 Real work uses Maven to build the few Clojure projects.

18:43 technomancy: sounds like fun

18:43 ieure: Because most of our stuff is Scala, and it was easier to build Clojure with Maven than to rejigger Jenkins to know about another project type.

18:43 It's fine.

18:44 technomancy: huh... so that's the second time that's come up today. what benefit do you get from jenkins integration?

18:44 I've never used it for anything other than "here's a couple shell commands to run"

18:44 ieure: It drives the whole build and release cycle.

18:44 Push code to the repo -> Jenkins builds it tells you if something broke.

18:44 technomancy: sure?

18:44 why do you need tool integration for that?

18:45 isn't that what exit codes are for?

18:45 ieure: We don't need anything on the leon side.

18:45 TimMc: ~leon

18:45 clojurebot: leon is a good sign it's time to turn off auto-"correct"

18:45 TimMc: :-D

18:45 ieure: Hah.

18:45 Yeah.

18:45 But we'd have to create a setup that knows how to invoke lein, run tests, etc.

18:45 technomancy: so it's just a uniformity thing?

18:45 ieure: Yeah.

18:46 Managing Jenkins jobs is a pain, so we have a tool to create jobs for different build types. And it doesn't know about lein, because this was the first thing I did that used Clojure.

18:46 So rather than fuck with that, I just used Maven.

18:47 technomancy: lein do test, uberjar && s3cmd put target/myproj-*standalone.jar s3://builds/ # <- typically what I'd use

18:47 ieure: Trust me, I know how to set up Jenkins to do stuff.

18:47 technomancy: or even better, just shell out to bin/ci so it's all first-class

18:47 ieure: That introduces its own set of issues.

18:48 technomancy: how so?

18:48 egghead: I just set it up with lein test && lein uberjar, then showed jenkins where the artifacts live

18:48 i.e. target/*standalone.jar

18:48 ieure: Now you have a hundred copies of bin/ci in your repos all mostly alike but often slightly different.

18:48 mammoth: hello guys

18:48 egghead: oh hi mammoth

18:48 ieure: So you start a new project and cargo-cult bin/ci from another one.

18:49 And if you need to change how they all run, you have to go update N repos.

18:49 technomancy: ieure: yeah, but otherwise you have situations where have to change your job config when a branch gets merged

18:49 but yeah, the target bucket should probably be in an env var or something

18:49 mammoth: does clojure have equivalent of java arrays as datastructure?

18:49 and if yes, how is immutability handled?

18:50 egghead: mammoth: what are you looking for in a java array

18:50 ieure: technomancy: Sometimes. So we have a tool that creates or recreates job configs. So if you need to make a change, you change it in one place and regen all the jobs.

18:50 technomancy: ieure: yeah, if you've already gone down the path of a tool to write job configs I guess that makes sense

18:50 egghead: clojure has clojure.lang.PersistentVector which maybe does what you want

18:50 TimMc: aka vector

18:51 technomancy: I had a hell of a time trying to automate that and would argue it's not worth the hassle personally

18:51 mammoth: egghead: say I have a strategy game in mind. This game needs array to put terrain in. Also for implementing patfinding.

18:52 *pathfinding

18:52 ieure: mammoth: Why can't it use a vector?

18:53 mammoth: ieure: seems wastefull for rectangular map. You think it isn't?

18:53 technomancy: measure twice, cut once

18:54 egghead: such is the price we pay for immutability

18:54 ieure: mammoth: Guess it depends on how big your map is, but I'd just roll with it.

18:54 mammoth: here's the problem: the map is supposed to be, huge. Like, stupid big.

18:55 egghead: perhaps it should be in a datastore?

18:56 Apage43: mammoth: if the thing is sparse and tiled, perhaps use a map of coordinate pairs to things that live there

18:57 mammoth: Apage43: that's actually a possibility. Terrain could be vectorized (mountain height here instead of keeping whole thing in memmory) Still not sure what to do with pathfinding thing.

18:58 Apage43: well your pathfinding really just needs to know if a location is traversible

18:59 mammoth: egghead: how would you handle it in a datastore?

18:59 Apage43: so as long as you can provide a (can-i-go-to? x y)

18:59 you should be okay

18:59 mammoth: so you think I should implement pathfinding in java?

18:59 and clojure would only have handle to it?

19:00 Apage43: I'm just a bit lost as to what the issue is

19:01 mammoth: issue is that clojure seems to lack java array, and any other way to implement terrain seems a bit wasteful.

19:02 callen: mammoth: what makes it unreasonable to use a vec?

19:02 mammoth: nothing is unreasonable per se.

19:02 egghead: premature optimization etc etc

19:02 callen: mammoth: what's the problem then?

19:02 mammoth: why not make it with a vec and then optimize it if there's an actual problem?

19:03 mammoth: egghead explained it for you :)

19:03 callen: mammoth: Clojure's design makes it really easy to perform Indiana Jones style swaps of data structures after the fact without restructuring tons of code.

19:03 mammoth: well...don't?

19:03 seriously, don't prematurely optimize, it upsets me.

19:03 mammoth: lol :-)

19:04 Apage43: if you -have- to go there, the support is there

19:04 callen: right which is kinda my point.

19:05 mammoth: so what's the problem then?

19:07 egghead: lol callen

19:07 mammoth: I am basically exploring (just exploring at this point, don't get your hopes up) weither clojure is viable for creating RTS-style game (not exactly rts but you get the idea). The thing I would hat most is to seriously bite into it only to find out that something can't be done after I am commited.

19:07 egghead: 'indiana jones style swaps of data structures' -- nice

19:07 callen: mammoth: okay so, this is actually a pet subject of mine. I have some strong opinions but bear with me.

19:08 mammoth: what is pet subject of yours? Optimization?

19:08 *hate most

19:08 callen: mammoth: making games in not-C/C++

19:08 mammoth: generally speaking, when you make a game in a higher-level environment than C/C++, you've got a few options. 1. browser 2. JVM 3. C#/Mono 4. the rest

19:08 the "rest" can be summarized as frameworks like Love, PyGame, etc.

19:09 #4 is good for validating a basic, small, limited version of an idea.

19:09 but you can't really make a finished or shippable product that way.

19:09 C#/Mono is a fairly well-trodden realm and has about the same extent of universality as a game well-engineered in C++

19:09 Bastion was a MonoGame, and it was on NativeClient for Google Chrome, Win, Mac, Lin, etc.

19:09 there are still some serious limitations

19:10 the JVM isn't as well explored, but obviously you've got Minecraft and some odds and ends.

19:10 here's the problem, the problem with games is that usually if you're trying to make a fairly modern game...especially a real-time one, using a HLL will bite you hard at some point

19:10 egghead: from what I understand people don't really use clojure for the performance, and all performance sensitive stuff ends up being implemented in java

19:10 callen: egghead: depends on the problem, but basically yes. This isn't about that though.

19:10 and it may or may not be possible to work around the issues, but it's not always possible.

19:10 mammoth: callen: the thing about RTS is that they are really turn based, but turn expires quickly (in AoE 0.25 times per sec).

19:11 technomancy: just use ocaml, duh

19:11 =)

19:11 callen: The problem with games just isn't raw throughput, which is the sort of thing people often use Java for

19:11 it's latency and real-time

19:11 _tca: GARBAGE COLLECTION

19:11 callen: also the graphics pipelines are INSANELY immature.

19:11 _tca: I didn't want to be that direct, but yes.

19:12 mammoth: the immaturity of the graphics pipelines combined with GC and the inability to get directly at the hardware will eventually fuck you unless you're not trying to make a very real-time or graphically intensive game.

19:12 mammoth: even Minecraft has performance issues at many levels and in many situations, which is absurd.

19:12 mammoth: callen: I am gonna use Panda3d for graphic stuff. I'll write small client in python and jvm will be a server with actuall game.

19:12 _tca: he was alreayd in here talking about it a couple weeks ago

19:12 from what he said it sounded like clojure should be fine

19:12 callen: mammoth: mock up however suits you, just be aware that you'll run into a brick-wall eventually.

19:13 if you expect more intensive graphics or real-time behavior.

19:13 if neither of those are an issue, then you're probably fine.

19:13 mammoth: callen: I don't expect ANY graphic

19:13 callen: that's panda3d for.

19:13 callen: nor any phisics

19:13 callen: I don't think that's a very accurate or realistic way of putting it.

19:13 mammoth: callen: physics

19:13 callen: panda3d is still graphics.

19:14 mammoth: callen: which is at client

19:14 while JVM is server

19:14 callen: mammoth: I don't think it's profitable to discuss it much further. Just do your thing man :)

19:14 mammoth: don't preoptimize, just go make it.

19:14 see what happens.

19:15 mammoth: callen: but seriously, if it doesn't have true real time (like fps), nor does it handles graphic, what exactly can go wrong, assuming suitable data structures are in place?

19:16 callen: I am not saying it can't I just don't see what can

19:16 callen: mammoth: you can't really make general statements like that, it depends entirely on what you're doing.

19:16 mammoth: I can imagine a lot going wrong, but I've been programming long enough to have my youthful optimism curb-stomped a long time ago.

19:16 mammoth: just. go. do. it.

19:17 seriously, stop talking to us about it. go make something.

19:17 100,000 people talk about what they'd like to make everyday on the internet instead of coding. Don't be one of those people.

19:17 mammoth: callen: so my optimism can be curb-stomped, too?

19:17 lol

19:17 callen: mammoth: go make.

19:17 mammoth: thanks

19:17 I will sir

19:18 technomancy: callen: but can mongodb _actually_ scale?

19:19 egghead: depends, do you need your data to be consistent?

19:19 callen: technomancy: as a mongodb user, I will now proceed to violently vomit blood on your shoes.

19:19 egghead: MongoDB is a consistent data store actually. It's CP.

19:19 It's just not highly available unless you make consistency trade-offs

19:19 which is true of anything.

19:19 egghead: right

19:20 callen: I think you mean durable, which it is.

19:20 If you remember to turn journaling on.

19:20 if you don't, you deserve to lose your data. Tough cookies.

19:20 egghead: not everything is atomic, is it?

19:20 callen: All document operations are atomic.

19:20 Don't follow the fads unless you're willing to read the manual.

19:21 egghead: meh, I don't admin our mongo cluster, I just use it

19:21 :)

19:21 Apage43: whoaaa

19:21 callen: egghead: just speaking in general about the complainers.

19:21 egghead: I'm not that big a fan of MongoDB, it's just that most people complain about the canards, not the real problems.

19:41 amalloy: anyone know if there's a good way in core.match to match a seq like "at least three elements, the second of which is :foo"? i've tried ([x :foo y & more] :seq), but as of 0.2.0-alpha9 that matches even with only two elements, binding y to nil and more to ()

20:19 muhoo: Raynes: yeah, amalloy's explanation, as was to be expected, was decisively authoritative.

20:20 the real problem is that i'm spending too much time writing java.

20:21 or, at present PROCRASTINATING from writing java :-/

20:33 amalloy: muhoo: i'm still getting the hang of them myself. it's amazing some of the functions you can write that work on any monad rather than some particular monad. yesterday i saw: powerSet = filterM (const [True,False]); powerSet [1,2,3] -- returns [[1,2,3],[1,2],[1,3],[1],[2,3],[2],[3],[]]

20:38 brehaut: amalloy: by not referring to a particular monad are you refering to filterM rather than powerset?

20:39 amalloy: yes

20:42 someone said "hey, here's something useful that makes sense for anything monadic", and wrote filterM; when applied to lists it happens to do this awesome thing

20:44 brehaut: yeah, from memory a bunch of the functions that are sort of intended to work with the IO monad as control flow functions, have similar cool utility with other monadic structures

20:44 brainproxy: amalloy: i'm not sure what filterm does exactly, but I'll look to add it to protocol.monads

20:44 already have liftM

20:45 brehaut: it'd be sad day if it didnt

20:45 brainproxy: :)

20:45 brehaut: whats the deal with protocol.monads vs algo.monads?

20:45 Hodapp: I just wrote 'disclojure' in my notes instead of 'disclosure'. Screw all of you.

20:45 brehaut: (other than the implementation strategy)

20:45 amalloy: brehaut: iirc algo.monads is a bit rubbish?

20:45 brainproxy: brehaut: it's the implementation strategy, for the most part

20:46 but then you don't have to setup the computations using with-monad

20:46 brehaut: amalloy: in my experience, its a bit blunt, but did the job ok

20:47 brainproxy: brehaut: trivial example

20:47 (m/plus [(list 1 2) (list 3 4)])

20:47 will automatically do the right thing

20:47 brehaut: right

20:47 brainproxy: as plus is defined on the type

20:48 also (m/plus [(m/maybe nil) (m/maybe 1])

20:48 amalloy: brehaut: well for example, its Maybe doesn't satisfy the monad laws? because it uses nil as m-zero. you can't have a Just Nothing or a Maybe Maybe x

20:48 brehaut: amalloy: aha yes thats true. so protoocol.monads has a real maybe type then?

20:48 brainproxy: amalloy: that's taken care of with protcol-monads, but the factory function for maybe still does nil -> maybe-zero-val for convenience

20:48 however, the monad laws are still obeyed

20:49 amalloy: what factory function?

20:49 brainproxy: (m/maybe value)

20:49 returns type core.monads.Maybe

20:49 with value inside it

20:49 so m/maybe is the factory

20:49 amalloy: sure, sounds reasonable

20:50 as long as there's a way to create a Nothing or a Just explicitly, which i assume there is

20:50 brainproxy: see https://github.com/michaelsbradleyjr/protocol-monads/blob/examples/test/monads/test/core.clj#L288

20:50 I've been doing a lot (!) of work on my examples branches of my protocol-monads fork

20:50 I'll be merging into master probably tongith, and will push to clojars

20:51 jimduey may merge in my stuff at some point

20:51 back to the maybe thing... long story short, if you want to pass nil around inside Maybe, you can

20:51 you would just write a non nil->maybe-zero-val casting factory for maybe

20:54 brehaut: so is algo.monads effectively dead at this point?

20:54 or are they being developed in paralell?

20:54 brainproxy: brehaut: i think konrad hinsen is still maintaining it

20:55 last commit was a couple of months ago, but it's pretty mature

20:55 not a bad tool, just has some tradeoffs

20:55 brehaut: it does. i've got a lib that depends on it, and its been in snapshot for ages. im just wondering if its worth cutting my losses

20:55 brainproxy: as does protocol-monads, which is still in pretty raw form

20:55 brehaut: right

20:56 brainproxy: i've got to run, but feel free to hit me up about p-m in the future; btw, I'm learning as I go

20:56 3 weeks ago I didn't know anything about monads

20:56 so I'm definitely not an expert

20:56 brehaut: haha nice work :)

20:56 brainproxy: but turning p-m inside out has been a good education

20:57 brehaut: yup. nothing like writing monads to learn them

20:57 brainproxy: btw, if you play w/ my examples branch, note that StateTransformer and WriterTransformer have not yet been brought fully in line w/ all the adjustments I've made to the library

20:58 but I'll finish those tonight, "finish" being a relative term

20:58 brehaut: thanks for the warning

20:59 brainproxy: if you end up being interested, maybe in contributing, take a look at https://github.com/michaelsbradleyjr/protocol-monads/blob/examples/NOTES.md

20:59 there's some todo and ideas stuff in there, would love feedback

21:02 brehaut: brainproxy: thats a lot of notes

21:58 boodle: how can I determine the current directory path of my clojure application?

22:03 amalloy: brainproxy: how does protocol-monads handle letting you specify which monad you want to use, rather than inferring it from an input argument? for example, filterM doesn't take in any monadic values. in haskell, it can infer the monad instance from the expected return type at the call site, but in clojure you have to be able to give it a hint somewhere

22:07 brehaut: ,(System/getProperty "user.dir")

22:07 clojurebot: #<SecurityException java.lang.SecurityException: denied>

22:08 brehaut: boodle: ^ probably works outside of a sandbox

22:08 ToxicFrog: brehaut, boodle: it does.

22:08 boodle: brehaut: ty, *compile-path* seems to get me 'close enough'

22:08 ToxicFrog: user=> (System/getProperty "user.dir")

22:08 "/home/ben/Downloads"

22:09 brehaut: boodle: if you cant find a clojure answer when googling, try searching for a java answer

22:09 * boodle stinks @ java :(

22:10 brehaut: boodle: no better way to get better than to start converting one liners over

22:10 ToxicFrog: boodle: for stuff like this it's a pretty simple conversion - the java is 'System.getProperty("user.dir")', so the Clojure is either (.getProperty System "user.dir") or (System/getProperty "user.dir"), depending on whether System.getProperty is static or not

22:10 In this case, it's static, so it's the latter.

22:10 boodle: brehaut: true. ToxicFrog ty

22:27 shanemook: Hi i'm working on a kata to make change for a give value. Given 50 cents i'd like to get an array back with two quarters, so [25 25].

22:27 What is the functional way to do this?

22:28 I could create a variable and divide the value by 25 to insert the quarters but not sure that's correct for functional

22:31 brehaut: im assuming you dont have a 50c piece?

22:33 amalloy: probably filed under: american coins which are actually accepted by vending machines

22:33 plus pennies, i guess, because while machines usually won't take those, the problem is insoluble without them

22:34 shanemook: No 50c pieces. quarters, dimes, nickles and pennies.

22:34 Should I use the dotimes macro and divide the value by 25? And return 25 for each?

22:35 brehaut: you should be able to do this with a reduce

22:35 amalloy: noooo. you want reduce

22:35 shanemook: I'll read up on reduce. Thanks guys.

22:35 amalloy: or loop/recur, if you prefer

22:37 shanemook: how do I get the initial collection to pass in to reduce? If I just have a value of 50 I don't see how I iterate two times to add the quarters to the array

22:39 brehaut: thats quite a fun little problem

22:40 i made use of into and repeat, as well as quot

22:40 shanemook: Would I do a (range 1 (ammount / 25)) to get get a collection? And then ignore the values and return 25

22:40 amalloy: i must have three separate gists solving this problem, but it's so hard to search for gists that i'll never know

22:40 shanemook: I feel like I'm learning to program for the first time with functional. All thumbs.

22:42 brehaut: heh

22:43 am i correct that your common coins are 25, 10, 5 and 1?

22:43 (rather than your whacky names)

22:43 shanemook: Yes

22:43 What, everyone isn't American?? heh...

22:44 brehaut: for a slightly harder version of the problem, solve for NZ denominations (under a dollar) 50, 20, 10 5

22:45 amalloy: for a version that's NP-complete, add in a 45-cent coin

22:46 brehaut: ha

22:50 amalloy: brehaut: is that harder because of the "round to the nearest 5" aspect, or something else?

22:50 brehaut: yeah just that

22:51 the so called 'swedish rounding'

22:51 wait

22:51 apparently we dont have 5 cent pieces here any more

22:51 who knew

22:51 apparently for 6 years

23:02 cshell: Does anyone have any links to detailed descriptions on how Clojure does it's class loading? In particular I'm able to load clojure.lang.RT and get its class loader, but when I execute the load function from Java, I get a clojure/core and clojure/core_init file not found error

23:07 Sgeo_: There's a lot of repetitive code in RT.javca

23:07 RT.java

23:08 technomancy: boilerplate? in Java

23:08 it's unpossible

23:08 Sgeo_: I assume the code was generated with some external tool?

23:08 I'm mostly looking at all the array manipulation functions

23:11 cshell: I'm trying to upgrade the IntelliJ Leiningen plugin to use 2.0 and use leiningen-core, but interop is failing because it can't find the clojure.core files on the classpath, even though RT is on the stack

23:12 I'm thinking it has to be a classloading problem, but it doesn't make any sense to me

23:15 PeregrinePDX: ibdknox, I tested LightTable with crunchbang too and had no problems. Aezop sure does seem pretty antagnostic.

23:32 mattmoss: @Raynes: If you're there... I'm using conch. See https://gist.github.com/4063931 . My problem is that I'm unpredictably losing lines, so that sometimes my regexp test will never pass because the line that should have matched was lost.

23:32 Is this something you've seen before? Or do I really need to dig into Java IO streams, un/buffered and all that...

23:35 Raynes: mattmoss: Never seen that before, but I also haven't really used it a whole lot.

23:35 mattmoss: hmm, ok

23:36 Raynes: mattmoss: read-line is literally just a clojure.core/read-line call on the stream, so I'm not sure what to say. :<

23:36 mattmoss: Yeah, I know about that... and I read most of the conch code to understand what was going on, where the streams were basically coming from.

23:37 Raynes: mattmoss: Perhaps your code could be written with conch.sh instead? It always consumes all data.

23:37 My only other idea would be that maybe the process is being destroyed or something before you can consume all the data? *shrug*

23:37 mattmoss: Raynes: I'll have to look. I thought i needed the lower-level so I could parse process output.

23:38 Raynes: You should be able to do all that with conch.sh as well.

23:38 cshell: ANyone know how to get the collection of current classloaders in JAva?

23:38 Sgeo_: I am thinking in Clojure-y ways while working with threads in a non-Clojure language.

23:38 Raynes: mattmoss: Look at the examples in the readme. You can get a simple lazy-seq of output from the process.

23:38 Sgeo_: This could turn out really bad.

23:38 Raynes: A lazy-seq of lines even. It's magical.

23:39 mattmoss: Raynes: Ok, I'll check out conch.sh again. Maybe I'm doing something subtley bad.

23:39 Raynes: thanks fo the ideas.

23:47 brainproxy: amalloy: can you tell me more about filterM?

23:48 amalloy: brainproxy: ah! did you get my question earlier? i think i've worked it out from reading your fork of protocol-monads, but i'm not sure

23:48 brainproxy: amalloy: i did, just got back from errands :)

23:48 my guess is that by spec'ing a factory as first argument you could accomplish the same thing

23:49 amalloy: yeah, it looks like that's what you do with m/do as well

23:49 brainproxy: right

23:50 Sgeo_: I'm actually writing Clojure code that I intend to use for real things :)

23:50 Although not at this moment, I have more important stuff to work on

23:51 brainproxy: Sgeo_: shame on you for being practical

23:51 Sgeo_: heh

23:51 Well, "Making a thing that will only be noticed by a community of about a dozen people" might not count as "practical"

23:52 Raynes: Sgeo_: I'm pretty sure the Clojure community consists of more than a dozen people.

23:52 amalloy: brainproxy: i implemented a kinda haskell-flavored clojure version of filter-m at https://www.refheap.com/paste/6615

23:53 a little too busy to really explain it atm, though, so maybe ask brehaut or sgeo about filterM in general?

23:53 Sgeo_: Raynes, and I'm guessing that exactly 1 member of the Clojure community cares about one particular knockoff of an old 3d universe

23:53 old 3d virtual universe

23:53 brainproxy: amalloy: sure, if I can get the idea I'll take a crack at it to ... looking at various google search results related to filterM

23:54 Sgeo_: I really should get back to work on my mess of Python+PHP code

23:54 rboyd: anyone used quil (https://github.com/quil/quil)? I'm struggling with something that ought to be really easy

23:54 mattmoss: Raynes: the conch.sh stuff seems to require that the process complete before I read from :in, correct?

23:55 Raynes: Read from :in?

23:55 mattmoss: I mean :out, whoops.

23:55 Raynes: No.

23:55 (yourprogram "arg1" "arg2" {:seq true}) = a lazy sequence of output from the process, populated in realtime.

23:56 brainproxy: amalloy: alright, well I'll make a note re: filterM, for now I'm going to try finish up my adaptations of state-t and writer-t

23:58 mattmoss: Hmm, okay, I'll try again. I called execute directly (since my prog isn't on the PATH), but maybe I missed something.

23:59 Raynes: mattmoss: Look at let-programs

23:59 mattmoss: Raynes: checking it out now.

Logging service provided by n01se.net