#clojure log - Feb 06 2015

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

0:19 mercwithamouth: .

1:08 justin_smith: gfredericks: remind me not to tell you about the lazybot logs

1:10 arrdem: justin_smith: I'm sure gfredericks' secrets are safe with you, _amalloy, _raynes and the NSA

2:04 julianleviston: Does anyone know: 1. If a new version of Joy of Clojure is imminent covering 1.7 and also 2. If purchasing it from Amazon entitles one to an eBook version?

2:05 unfortunately, the website is substantially lacking in an explanatory outlook of what might be somewhat of a plan for the inevitable future of the series...

2:07 justin_smith: julianleviston: considering 1.7 isn't even released yet, I doubt JoC covers it - writing a book takes a non-negative amount of time

2:08 julianleviston: err, misread, never mind!

2:08 expez: :db/id #db/id[:db.part/db] <- what does this literal notation mean in datomic schemas? Is this simply how you tell datomic to fabricate an id for you?

2:10 justin_smith: expez: yeah, that tells datomic to generate a unique id

2:11 expez: justin_smith: cool, thanks

2:11 julianleviston: expez: looks a bit confusing on first blush, doesn't it.

2:12 justin_smith: it starts with # as with all other tagged readers

2:12 ,(java.util.Date.)

2:12 clojurebot: #inst "2015-02-06T07:09:56.927-00:00"

2:13 expez: julianleviston: yeah, they could've had some suger for that like :db/id :auto as this is it looks like this is used almost always

2:13 justin_smith: expez: usually you don't want :db.part/db though - that is only for db internal type stuff

2:13 for a user field you wouldn't use it

2:14 expez: I just started looking at datomic so I still have a lot of docs to read :)

2:15 justin_smith: expez: I found it really helpful to read the alice db book from inria

2:15 mercwith`: ping?

2:15 clojurebot: PONG!

2:15 justin_smith: (it's a free pdf on database systems theory that covers datalog)

2:16 mercwith`: justin_smith: what pdf would that be?

2:16 justin_smith: mercwith`: the inria alice book pdf

2:16 expez: mercwith`: http://webdam.inria.fr/Alice/

2:16 justin_smith: $google inria alice book pdf

2:16 lazybot: [Foundations of Databases - Inria] http://webdam.inria.fr/Alice/

2:16 mercwith`: sweet

2:16 justin_smith: I won't claim I understand everything in there - but I learned a lot from it

2:17 expez: justin_smith: I've had that book on my shelf for a while, just needed an excuse to move it to the top of the pile. Thanks! :)

2:17 justin_smith: heh

2:17 physical copy?

2:17 expez: yeah

2:20 mercwith`: any datomic aficionados her?

2:20 here*

2:20 no real questions..i'm just watching a few talks on it tonight...

2:21 julianleviston: mercwith`: I'm a fan… definitely by no means an afficionado tho

2:21 * julianleviston can use it enough to get what he wants to do done, thusfar.

2:21 mercwith`: julianleviston: can you think of any projects it would be used for...outside of like banking, etc

2:22 expez: What is going to limit write performance first? The write bandwidth or the size of the existing store which has to be re-indexed?

2:22 mercwith`: or transactions, etc

2:22 julianleviston: mercwith`: hehe… actually I'm building the version-after-next of my current project with it.

2:22 mercwithamouth: and it would have been very handy at my last job...

2:22 mercwithamouth: hmm what project would that be?

2:23 julianleviston: mercwithamouth: where we were building a system that aggregated fuel data for the mining industry (in australia)

2:23 mercwithamouth: ok gotcha

2:23 julianleviston: mercwithamouth: the current project is a content management system.

2:23 mercwithamouth: see it makes sense for stuff like that....though for like 'in home' projects...nothing comes to mind

2:23 definitely useful though for stuff like that

2:24 julianleviston: mercwithamouth: it's useful anytime you don't want to lose data… which to my mind is pretty much any time you want to do anything useful with a database.

2:24 mercwithamouth: if you haven't seen it, check out gracefulplace

2:24 mercwithamouth: i suppose...

2:24 julianleviston: mercwithamouth: what is the sticking point? Is it the accretive nature that is discombobulating you?

2:25 mercwithamouth: no, not at all. lack of ideas...lol

2:26 and warranting the expense for keeping that much data on hand

2:26 julianleviston: mercwithamouth: you don't know why you'd use a database?

2:26 mercwithamouth: what's the expense?

2:26 mercwithamouth: i would think that if you're holding multiple versions of a database...you'd need space to hold each version?

2:27 or is it more so like git?

2:27 julianleviston: mercwithamouth: isn't that particular conversation going to go a similar way to never changing data structures in memory? (aka persistent data structures). Turns out it's actually MORE compact most of the time, no?

2:28 mercwithamouth: possibly...consider me a newb.

2:28 i'm more of a hobbyist developer

2:28 julianleviston: mercwithamouth: because of not having to create things you don't use (ie smallest item is a datom, which is a single fact) as averse to the row… which is kinda big… efficiency-storing-algorithms put somewhat aside.

2:28 mercwithamouth: i haven't had the opportunity to run into such issues yet

2:28 julianleviston: mercwithamouth: you should def watch RH's intro

2:29 mercwithamouth: next...i played it once though i'll admit i was moving around the room during it

2:29 julianleviston: mercwithamouth: he addresses most of the arguments one can think of as being somewhat challenging.

2:31 mercwithamouth: ok..i'll take a look tonight

2:33 julianleviston: mercwithamouth: including what I think is possibly the coolest part about datomic: that your code contains an opaque server, and that these servers are small because they don't have to do everything, so queries are stupidly fast. The architecture of it is pretty nice, to say the least.

2:33 mercwithamouth: hmm thats actually interesting...

2:33 now lets talk 'cost'...should i make something i wanted to release...

2:34 julianleviston: mercwithamouth: it reminds me a lot of the same principles as the ref types… except scaled to a different level.

2:39 mercwithamouth: there are free, pro starter or pro versions. For anything you're probably going to use, you probably won't have to pay. It's really inexpensive. http://www.datomic.com/pricing.html

2:41 mercwithamouth: julianleviston: true..but should i do make something useful...i suppose it pays for it's self

2:42 julianleviston: mercwithamouth: well the pro starter comes with 2 peers and a transactor… that's a fair amount of power.

2:42 mercwithamouth: and that's free...

2:42 justin_smith: free as in beer

2:42 mercwithamouth: ok, maybe i'll toy with it along with postgres when/if an idea comes to me

2:43 ok the virtual database feature is cool...

2:43 julianleviston: mercwithamouth: I'm building a CMS platform that will technically be able to serve thousands of websites and the pro starter will probably be ok for me… however if I get to the point where I have even hundreds of sites, I'll probably send some cash their way…

2:43 mercwithamouth: it has a different definition of what a database is… by the way… :) but you probably knew that…

2:45 mercwithamouth: the 5 -> 8 proc version is like $3300 perpetual license and $1500 per year optional maintenance… that's pretty darn cheap.

2:45 mercwithamouth: if you're making something that needs more than 3 procs, then you can prolly afford $3300 ;-)

2:45 mercwithamouth: lol i suppose so =P

2:46 ok well then..there's no reason NOT to familiarize myself with datomic...fine fine.

2:46 any books on the way for it? i'd assume so, it seems popular enough...in the next year or two

2:47 julianleviston: mercwithamouth: I don't know.

2:47 mercwithamouth: with that said..there's plenty of info out there as is

2:47 what was your project again? are you on github?

2:47 graceful place

2:47 julianleviston: mercwithamouth: yeah, the main doc site had more than enough info for me to understand it… and the grateful place and another github repo I forget now has more than enough info on implementing it.

2:48 no that's not me.

2:48 http://gratefulplace.com

2:48 mercwithamouth: grateful**

2:48 julianleviston: My site is http://getcontented.com.au/

2:48 justin_smith: mercwithamouth: last I asked about books the answer was no datomic books, but there is the free inria alice book on datalog

2:48 mercwithamouth: oh! ok i've been here....

2:49 julianleviston: mercwithamouth: but at the current version, it's built in rails and ember…

2:49 mercwithamouth: this was helpful to me : http://www.flyingmachinestudios.com/programming/building-a-forum-with-clojure-datomic-angular/

2:49 mercwithamouth: ok, cool. yeah i toyed with rails for a few years as well off and on

2:49 julianleviston: that's the guy talking about grateful place

2:50 mercwithamouth: sweet...going through it now.

2:50 julianleviston: mercwithamouth: I programmed with rails professionally for years. It's kind of a bad toy.

2:50 mercwithamouth: i've been toying with OM for the last few days but i've touched angular as well

2:51 lol...i like rails but get annoyed when gems act crazy and you have to do a lot of digging around. the benefits outweigh the annoyance though for getting something up and running quickly

2:51 julianleviston: mercwithamouth: yeah Om is what I'm using to rewrite my app in :) from Ember…

2:51 mercwithamouth: it's so good.

2:52 mercwithamouth: you like OM? seems cool

2:52 julianleviston: mercwithamouth: and all the next set of stuff facebook are doing is only making it better (react native, for example)

2:52 mercwithamouth: yeah! i saw that speech earlier this week...react native

2:52 julianleviston: mercwithamouth: not to badmouth Rails too much, but I really don't like the way things are hidden so much from the programmer… and there's so much "magic" and a lot of it is kind of bad… like the whole ActiveRecord ORM thing. ORMs are potentially dangerous.

2:53 mercwithamouth: turns out if you want to do something serious and efficient in it, you have to strip large chunks of it away, and you may as well have not use Rails in the first place.

2:54 mercwithamouth: EXACTLY.

2:54 i didn't want to come out and say it...but...i loved rails until i really got into it and it's easy to get lost when something doesn't work as expected

2:54 julianleviston: mercwithamouth: having said that, it's good that it's there, and it greases the wheels from a whole set of PHP devs to be aware of better industry practice, and then discover even better things...

2:54 mercwithamouth: ...you dare mention PHP?

2:55 julianleviston: mercwithamouth: :) everything has its place.

2:56 mercwithamouth: i'm biased...plus i've picked on php for too many years. i wouldn't dare touch it and get caught doing so by my friends.

2:56 julianleviston: mercwithamouth: what about if you just wanted to add a few snippets of server side processing? you'd spin up python or ruby or java for that?

2:57 mercwithamouth: yes.

2:57 julianleviston: mercwithamouth: purist! :P

2:57 mercwithamouth: i recall...outdoing php with just xslt once

3:00 julianleviston: hehe… and now I have to go write some swift…

3:01 acron^: morning

3:01 julianleviston: acron^: hey! :)

3:23 mercwithamouth: julianleviston: also it seems i can use datomic and later choose to put another db behind it...postgres, dynamo...after the fact?

3:23 julianleviston: mercwithamouth: um… not exactly. Rather datomic requires a store of some sort.

3:24 mercwithamouth: ok so i have to choose beforehand.

3:24 julianleviston: mercwithamouth: I'm not too sure if you have to choose beforehand.

3:24 mercwithamouth: I think it'll store in flatfiles if you don't… not 100% about this, but I think that's how my current version works. You should look this up.

3:25 mercwithamouth: yeah, from the front page of datomic.com: Datomic provides rich schema and query capabilities on top of modern scalable storage engines like DynamoDB, Cassandra, Riak and more

3:26 mercwithamouth: ok...great!

3:26 julianleviston: mercwithamouth: follow that link and you get a comprehensive list of storage backends: http://docs.datomic.com/storage.html

3:26 it's very very flexible.

3:26 mercwithamouth: noice...

3:27 julianleviston: I think there has even been some work to build some frontside datomic like things, too… IIRC… which is really cool.

3:28 mercwithamouth: if that's your interest, this could be useful to look at : https://github.com/tonsky/datascript but it all depends what you're interested in.

3:28 mercwithamouth: hmmm

3:28 very

3:29 hah! well that answers a question i had about a possible client side only todo list i wanted to make for work

3:29 acron^: anyone got any experience working with Excel (xlsx) files?

3:29 julianleviston: oh god

3:30 acron^: :((

3:30 mercwithamouth: lol

3:30 julianleviston: acron^: sorry… I just had bad flashbacks… it matters which version… is it the new x format? coz I think that's probably going to be manageable… but the other kind… I'm sure it's well documented now and easier with java libs or something… don't let me dissuade you.

3:31 acron^: hah

3:31 daniel__: acron^: they are zip files containing xml

3:31 acron^: it's the new one... I'm using docjure at the moment but it doesn't quite do what I want it to

3:33 julianleviston: acron^: does clj-excel not do everything you need?

3:34 https://github.com/mebaran/clj-excel

3:34 acron^: might look at that instead

3:34 docjure seems quite basic

4:05 expez: How can I view log messages from timbre while working at the repl?

4:07 when I call the code from the repl I see the log messages, but not when I hit the server

4:15 clgv: expez: they are logged to a file I guess

4:16 expez: you could add an additional console logger to the configuration

4:17 expez: clgv: actually they end up in the *nrepl-server <project>* buffer. I had 'nrepl-hide-special-buffers' set to t and I had to restart cider to get that buffer back after changing the variable.

4:18 clgv: ok, I thought you ware talking about a deployed server

4:19 expez: ah, my bad.

4:25 luxbock: https://gist.github.com/luxbock/7226ce0d65d5846ecbbf

4:25 is there a better way to write this?

4:26 the `eval` inside the defmacro feels wrong, but I couldn't figure out how to do it otherwise

4:26 TEttinger: what should blah->> do?

4:27 clgv: luxbock: TEttinger: that is a good question

4:27 luxbock: same as ->> but it returns a list of the steps for each expression

4:27 i.e. (blah->> 1 inc inc even?) would return (1 2 3 false)

4:28 clgv: luxbock: this code shouldnt work at all because of the wrong usage of syntax quote and autogensym

4:28 luxbock: clgv: it works for me

4:28 clgv: oh wait there is another syntax quote outside. so that saved you ;)

4:29 luxbock: yeah, this is not for anything serious, I'm just messing around to get better at writing macros

4:29 clgv: luxbock: ah, so you want all the intermediate results?

4:29 luxbock: clgv: yep

4:30 clgv: luxbock: you should be able to enhance "as->" to do that

4:30 luxbock: hmm, how would that work?

4:30 clgv: luxbock: in principle you generate statements within a `let` to bind the intermediate results

4:31 probably simpler without looking at let.

4:32 luxbock: so you generate something like (let [x1 (f1 ...), x2 (f2 ... x1), ...] (vector x1, x2, ..., xn))

4:32 luxbock: ah I see

4:32 arossouw: when should you use the -> expression?

4:33 clgv: you can put that together via map, gensym, interleave, ....

4:33 arossouw: when you want to use the result of a calculation in the next one at least twice

4:33 arossouw: ok

4:34 acron^: is there a way to increase the stack?

4:34 clgv: arossouw: if you have some computation that is like a pipeline anyway

4:34 acron^: sure, there is a jvm flag

4:34 acron^: I'm using "lein run"

4:35 clgv: acron^: you can set jvm flags via project.clj

4:35 acron^: oh awesome

4:36 TEttinger: ,(reductions #(conj %1 (%2 (last %1))) [1] [inc inc even?])

4:36 clojurebot: ([1] [1 2] [1 2 3] [1 2 3 false])

4:36 arossouw: http://paste.linuxmint.com/view/wjkx/ , looks ugly any hints?

4:37 TEttinger: ,(reduce #(conj %1 (%2 (last %1))) [1] [inc inc even?]) ; even this should work huh

4:37 clojurebot: [1 2 3 false]

4:37 arossouw: i thought of changing databases to hash-map of sequences

4:37 luxbock: TEttinger: yeah but this would fail if the arguments are expressions instead of functions

4:38 TEttinger: yeah, I was just thinking you could assemble it like that

4:39 clgv: TEttinger: that would not be ideal for the macro

4:40 TEttinger: luxbock: using `as->` as inspiration, a very simple and fully functional implementation of the intended macro is easily implemented via generating an appropriate `let` form

4:41 luxbock: clgv: working on that as an excercise for myself :)

4:41 clgv: luxbock: that's why I didn't paste any impl ;)

4:41 acron^: noob question. ...how do I include files other than 'core.clj' in a lien project? I have added a 'util.clj' and added the same namespace but it can't find the function

4:42 lein*

4:42 Empperi: and you have require in place in your core.clj?

4:42 clgv: acron^: the file just has to be at the appropriate place corresponding to the namespace name. myproj.util needs to be in "src/myproj/util.clj"

4:43 acron^: clgv: yep

4:43 but the namespace is myproj.core as well

4:43 does each separate file need a separate namespace ?

4:44 TEttinger: yes

4:44 kinda

4:44 myproj is the equivalent to a package in java, core is the closest thing to a class

4:45 so you will likely have multiple files in the folder src/myproj/ , with the file name matching the last part of the ns name

4:45 acron^: I know very little about Java :/

4:45 TEttinger: yeah clojure has to inherit this inflexible package thing from java

4:45 acron^: Ok, so I canged the namespace

4:45 DO I need a require?

4:46 TEttinger: in core, yeah

4:46 acron^: how does that look?

4:46 [myproj.util :as util] ?

4:46 TEttinger: core is your main, so you would have a require section in your ns, usually

4:46 sure

4:46 that looks fine

4:47 acron^: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Named,

4:47 :\

4:47 TEttinger: oh is that part of an (ns) form?

4:47 like

4:48 acron^: yeah

4:48 TEttinger: (ns myproj.core :require [[myproj.util :as util]])

4:48 err

4:48 (ns myproj.core (:require [[myproj.util :as util]]))

4:48 I can't remember here

4:48 acron^: (ns myproj.core

4:48 (:require [clojure.java.io :as io]

4:48 [clojure.string :as cstr]

4:48 [myproj.util :as util]))

4:49 oh wait

4:49 i got it

4:49 sorry

4:49 it was something IN my util file :)

4:50 TEttinger: ah!

4:50 acron^: I look forward to reaching clojure competancy... :p

4:51 TEttinger: yeah, it's gotten easier with the good resources that are available now

4:51 4clojure is great

4:51 http://www.braveclojure.com/ is good too

4:51 luxbock: clgv: https://gist.github.com/3e2e54598946a2d3d2b3

4:51 this works but I'm not sure if it's the simplest way to do it

4:51 I'm still using reductions, and I can't figure out how I'd do the nesting without it

4:52 clgv: acron^: please use something like refheap.com

4:52 acron^: clgv: my apologies

4:53 kir: acron^, if you don't mind a suggestion from a fellow noob, I found these videos to be exceptionally useful: https://www.youtube.com/watch?v=9A9qsaZZefw&list=PLAC43CFB134E85266

4:53 clgv: luxbock: why do you use `reductions` there?

4:53 acron^: kir: super! thank you!

4:54 clgv: luxbock: this will perform your computations multiple times

4:54 luxbock: clgv: (boo->> 1 inc (+ 10)) should return [1 2 12], i.e. I need the expressions 1, (inc 1) and (+ (inc 1) 10)

4:54 kir: acron^, welcome.

4:56 clgv: luxbock: I know. but have a look at the macroexpansion and you see what I mean

4:57 luxbock: clgv: ahh right

5:10 ddellacosta: luxbock: I think semantically what that thing does is a bit confusing

5:10 luxbock: for example, this is roughly what you're trying to do, but separates the initial value out:

5:10 &(reduce (fn [acc v] (conj acc (v (last acc)))) [1] [inc #(+ 10 %)])

5:10 lazybot: ⇒ [1 2 12]

5:11 ddellacosta: and unfortunately Clojure doesn't do currying by default, so (+ 10) is not a function...alas

5:12 luxbock: ddellacosta: what I'm actually trying to do is make a version of print->> from foo-print, that prints the values inside a nicely formatted table instead of value by value

5:12 ddellacosta: oh, I guess it makes sense to thread the first value through the other fns, it's the collecting that is a bit confusing

5:12 luxbock: sorry I kind of jumped in late

5:12 luxbock: https://gist.github.com/97588fd2a4d03f1ef8f7

5:13 hyPiRion: it's just a ->> that collects the results of each form

5:13 luxbock: this works again, but I don't know if it's the simplest way to do it

5:13 ddellacosta: yeah, that's why reduce seems like the most obvious way

5:13 or for actually, probably

5:13 noncom|3: does ccw support starting multiple repls?

5:14 luxbock: could probably use a bit more destructuring

5:24 Runner: s,awr At who like this game ? https://www.youtube.com/watch?v=rSAAdKE84Ts

5:27 acron^: that game looks mental

5:30 does 'defn-' mean it can't be called outside this namespace ?

5:30 hyPiRion: ,(defn ba [s [f & r]] (if f (let [y (gensym)] `(-> ~(peek s) ~f (as-> ~y ~(ba (conj s y) r)))) s))

5:30 clojurebot: #'sandbox/ba

5:30 hyPiRion: ,(defmacro boo->> [x & f] (let [g (gensym)] `(let [~g ~x] ~(ba [g] f))))

5:30 clojurebot: #'sandbox/boo->>

5:30 hyPiRion: ,(boo->> 1 inc (+ 10) even?)

5:30 clojurebot: [1 2 12 true]

5:31 acron^: hyPiRion: that's awesome

5:32 TEttinger: nice hyPiRion

5:32 (inc hyPiRion)

5:32 lazybot: ⇒ 67

5:33 luxbock: oh nice

5:33 hyPiRion: luxbock: it doesn't seem like the gist you posted worked, but that one should work

5:33 luxbock: hmm it was working for me

5:34 acron^: yep, though you can get around that by using its var to call the function

5:34 Runner: 3, ur At who like this game ? Is a shit game this https://www.youtube.com/watch?v=rSAAdKE84Ts

5:35 luxbock: i.e. if some.namespace/foo is private, then you can still call it with (#'some.namespace/foo a b c)

5:37 hyPiRion: I am jealous of how you can think up something like this

5:37 hyPiRion: luxbock: that gist makes (boo->> 1 inc) expands to (let* [G__989 1 G__990 (inc G__990)] [G__989 G__990]), at least over here. so I guess you just had an off by one error. Seems like a solid way to implement it though

5:37 luxbock: It probably takes me more time to undestand how this works than what it did for you to write it

5:38 hyPiRion: ah yeah I might've gisted the wrong version on accident

5:38 hyPiRion: ,(ba ['x] '[inc (+ 10)])

5:38 clojurebot: (clojure.core/-> x inc (clojure.core/as-> G__107 (clojure.core/-> G__107 (+ 10) (clojure.core/as-> G__108 [x G__107 G__108]))))

5:38 hyPiRion: oh, that looks messy. well

5:39 it just expands to (let [x 1] (-> x inc (as-> y (-> y (+ 10) (as-> z [x y z])))))

5:40 which is just another fancy way of saying what your macro expanded to :)

5:41 luxbock: right

5:43 hyPiRion: ,(->> 10 conj (-> [1]))

5:43 clojurebot: [1 10]

5:45 hyPiRion: ,(-> [1] conj (->> (->> 10)))

5:45 clojurebot: [1 10]

5:45 hyPiRion: These things can go weird pretty fast when combined.

5:46 acron^: quick question: how to remove a particular index from a sequence?

5:46 (1 2 3) => (1 3)

5:48 hyPiRion: acron^: there's no built-in support for that, as it's very slow

5:48 but if you really need it for sequences in general, you can implement it like this

5:49 ,(defn remove-nth [coll n] (let [[f r] (split-at n coll)] (concat f (rest r))))

5:49 clojurebot: #'sandbox/remove-nth

5:49 hyPiRion: (remove-nth '(1 2 3) 1)

5:49 ,(remove-nth '(1 2 3) 1)

5:49 clojurebot: (1 3)

5:49 acron^: erk

5:49 I'll think of a different approach

5:51 Glenjamin: does anyone know if it's possible to get the generated input when catching an exception in test.check ?

5:51 hyPiRion: well, it's doable, just be aware that it's O(k) (where k is the index) on the sequence you're working on

5:51 acron^: I'll think of a different approach

5:51 oops

5:52 slipset: acron^: worth considering, though if this is the bottleneck in your application

5:53 arossouw: clgv: is it better to write like this? (-> testdb :master (jdbc/query sql-query))

5:53 slipset: acron^: in this talk https://www.youtube.com/watch?v=I7IdS-PbEgI

5:53 @leeb shows that persistent datastructures are slower than mutable datastructures in js by a constant factor.

5:54 acron^: sure

5:54 slipset: he also suggests that the arr.push('foo'); will be somewhat slower with persistent datastructures, but it will never be the bottleneck

5:55 the_frey: I am having the weirdest issue but not 100% sure how do describe it

5:55 Glenjamin: a cljs persistent vector in "mutable mode" is actually faster than a large JS array

5:56 the_frey: so basically I've got a bunch of namespaces in a lein project, the code compiles, so I know all the namespaces are being loaded (as they are required by others)

5:56 Glenjamin: (transients, that is)

5:56 hyPiRion: and a clojure transient vector might on rare occations be faster than an arraylist.

5:56 the_frey: but lein run throws an error that shows they aren't loaded properly - at least, not the current version of the code

5:57 slipset: glenjamin: yes, but my main point is that IMHO nothing is a peformance problem before it is proven so by benchmarking your application

5:57 Glenjamin: right, agreed

5:57 the_frey: in the emacs repl if I go to the most deeply nested namespace and load it, then repeat until I get to the main function, I can run it and it works

5:57 but why aren't they being loaded in the first place? I'm not having to change any code to get them to work

5:58 hyPiRion: the_frey: that sounds strange, could you do `lein clean` and check if that helps? Might be an AOT/protocol issue

5:59 the_frey: yeah I did lein clean and it had no effect

5:59 hyPiRion: hm

6:00 the_frey: project.clj looks like this FWIW https://github.com/Swirrl/artsapi-email-processing-tool/blob/master/project.clj

6:00 julianleviston: acron^: you could always use subvecs coupled with into

6:04 hyPiRion: the_frey: fwiw I cloned the project, and it works fine here on leiningen 2.5.1

6:04 luxbock: how would I check if a value is an exception?

6:04 the_frey: yeah it'll lein run just fine

6:04 acron^: i could if i knew what that meant ;)

6:04 julianleviston: acron^: ##(doc subvec)

6:04 lazybot: ⇒ "([v start] [v start end]); Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not supplied, defaults to (count vector). This operation is O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done."

6:04 the_frey: *lein repl

6:05 julianleviston: acron^: ##(doc into)

6:05 lazybot: ⇒ "([to from] [to xform from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined. A transducer may be supplied."

6:05 hyPiRion: luxbock: (instance? Exception my-value)

6:05 luxbock: hyPiRion: thanks

6:09 donbonif_: Returns the sum of the elements or 42 if any element is 42 -> any leet way of doing this? I'm basically using reduce and return 42 based on the conditions.

6:09 hyPiRion: the_frey: Strange, lein run works here

6:10 donbonif_: (or (some #{42} coll) (reduce + coll))

6:10 julianleviston: acron^: ## (let [x [1 2 3 4 5]] (into (subvec x 0 1) (subvec x 2)))

6:10 lazybot: ⇒ [1 3 4 5]

6:11 donbonif_: hyPiRion: that was my other option, but that will force to check the full collection twice

6:12 can be faster, can be slower

6:12 the_frey: hyPiRion yeah actually lein run will work for a number of cases that don't include needing to have some newer files

6:13 there's basically a set of rdf-izing templates only called in a specific case (the newest code) that are there, but what lein thinks is in there... is not what's in there.

6:13 acron^: julianleviston: nice one, thanks

6:13 slipset: donbonif_: reduce has a special (reduced) value

6:13 the_frey: ah well, I'll return to searching for an answer

6:13 hyPiRion: donbonif_: right. Well, if perf is a concern, then (reduce (fn [acc n] (if (= n 42) (reduced 42) (+ acc n))) 0 coll) is probably sufficient

6:13 the_frey: cheers!

6:13 slipset: hyPirion :)

6:13 hyPiRion: the_frey: good luck, if you can't find it out, feel free to submit an issue on the Leiningen tracker

6:14 slipset: ahh, you beat me! :)

6:14 (inc slipset)

6:14 lazybot: ⇒ 2

6:14 the_frey: cool, if I can replicate it in some way, I will :)

6:14 donbonif_: hum.. didn0t know about reduced, thatnks hyPiRion and slipset :)

6:14 slipset: hyPiRion: you had the implementation though :)

6:14 (inc hyPiRion)

6:14 lazybot: ⇒ 68

6:15 slipset: donbonif_: as a side note, reduced is purty cool in transducers, since it lets you send 'quit' messages down the chain of transducers

6:15 julianleviston: the_frey: sorry to ask a stupid question, but you *are* in the right folder when you run lein right?

6:15 the_frey: had to check there for a second but yes :)

6:16 julianleviston: the_frey: I only ask because that's caught me out before :)

6:16 the_frey: haha yeah

6:16 In-Runner: 3nk Is true that Bill Gates is gay ?

6:16 the_frey: the weirdest thing is that you can load it all up via emacs and run it

6:16 real head scratcher

6:17 hyPiRion: yeah, that's just confusing

6:17 acron^: what are these Runner and In_runner bots doing?

6:17 slipset: donbonif_:http://clojure.org/transducers search for "Early termination"

6:17 donbonif_: thanks slipset :)

6:17 acron^: what are these Runner and In_runner bots doing?

6:17 oops

6:17 gotta stop that

6:21 if a function returns a sequence generated by a map, is it still lazy until the sequence is queried?

6:22 TEttinger: yeah, the type is lazyseq so it knows how to compute the next element

6:23 julianleviston: acron^: yeah it's a common bug that new people make… they do a map expecting the same effect as doseq or dorun

6:23 acron^: i definitely make this mistake

6:23 TEttinger: if you're struggling with str on a lazyseq, as I did a lot at first, there's that handy mapv

6:23 ,(str (map inc [1 2 3]))

6:23 clojurebot: "clojure.lang.LazySeq@7c42"

6:24 TEttinger: ,(str (mapv inc [1 2 3]))

6:24 clojurebot: "[2 3 4]"

6:24 acron^: thanks guys

6:24 In-Runner: 45n Who know this girl ? http://s4.postimg.org/e98mohfnx/Girl.jpg

6:24 slipset: ,(apply str (map inc [1 2 3]))

6:24 clojurebot: "234"

6:24 slipset: hmm

6:24 different thing :)

6:25 TEttinger: ,(pr (map inc [1 2 3]))

6:25 clojurebot: (2 3 4)

6:25 TEttinger: ,(pr-str (map inc [1 2 3]))

6:25 clojurebot: "(2 3 4)"

6:25 acron^: pr ?

6:25 TEttinger: pr-str is extremely handy for getting lisp code that you can then read-string in

6:26 print readably

6:26 readably by clojure, that is

6:26 acron^: ahhh

6:26 TEttinger: ,(pr-str {:a "alpha"})

6:26 clojurebot: "{:a \"alpha\"}"

6:26 TEttinger: it handles escapes and everything

6:33 Glenjamin: any test.check experts around? I'm setting my check size to be 100+, but it's only running ~20 iterations - any idea's where i should direct my debugging?

6:39 arossouw: how can i turn {:sn "mylastname :firstname "myfirstname"} into string output "sn\nmylastname\nfirstname\nmyfirstname" ?

6:40 Glenjamin: gah, sample produces the right results - but quick-check doesn't

6:42 clgv: luxbock: looks good to me

6:45 TEttinger3: arossouw: ##(reduce-kv #(str %1 "\n" (name %2) "\n" %3) "" {:sn "mylastname" :firstname "myfirstname"})

6:45 lazybot: ⇒ "\nfirstname\nmyfirstname\nsn\nmylastname"

6:46 TEttinger3: of course maps are unsorted by default so you end up with that

6:46 hm

6:47 arossouw: ##(clojure.string/join (map #(str (name %1) "\n" %2) {:sn "mylastname" :firstname "myfirstname"}))

6:47 lazybot: clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox6330/eval12776/fn--12777

6:47 TEttinger3: ##(clojure.string/join (map #(str (name (key %1)) "\n" (val %2)) {:sn "mylastname" :firstname "myfirstname"}))

6:47 lazybot: clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox6330/eval12789/fn--12790

6:47 TEttinger3: gaaaah

6:48 ##(clojure.string/join (map #(str (name (key %1)) "\n" (val %1)) {:sn "mylastname" :firstname "myfirstname"}))

6:48 lazybot: ⇒ "firstname\nmyfirstnamesn\nmylastname"

6:48 arossouw: TEttinger3: thanks

6:48 TEttinger3: that last one doesn'thave the \n at the start

6:48 arossouw: do you have some docs where i can educate myself with?

6:48 TEttinger3: I don't really know... the main thing this uses is that maps can be treated as seqs

6:49 ##(seq {:sn "mylastname" :firstname "myfirstname"})

6:49 lazybot: ⇒ ([:firstname "myfirstname"] [:sn "mylastname"])

6:49 julianleviston: arossouw: I found the cheatchefat useful.

6:49 TEttinger3: so that's what it's operating on

6:50 those aren't normal vectors even though they print in []

6:50 arossouw: julianleviston: thanks, i'll look it up

6:50 julianleviston: arossouw: yeah, they're MapEntry thingos

6:50 TEttinger3: those [] allow you to call key and val on them, or first and second

6:50 muhuk: If I have a simple function (single threaded calc.) that uses a constant (say the gravity), it seems using with-bindings is preferable to override the constant.

6:51 AFAIU bindings is for multi-threaded stuff

6:53 arossouw: ok, i think i just need to learn how to destructure different types

6:53 clgv: muhuk: you could pass that constant directly and just create partials

6:54 muhuk: clgv: I know.

6:54 clgv: muhuk: the binding approach might backfire

6:54 muhuk: I'm trying to understand the difference between bindings & with-bindings

6:54 reading source, seems like they both use thread-locals

6:56 arossouw: how would you destructure results of clojure.set/difference?

6:56 clgv: muhuk: from quickreading the source I guess with-bindings might work for arbitrary vars?

6:56 arossouw: TEttinger3: first time i see ##( , what is that called?

6:56 muhuk: clgv: what does "arbitrary var" mean?

6:57 clgv: arossouw: lazybot syntax

6:57 arossouw: oh

6:57 muhuk: arossouw: I don't think you can destructure sets

6:57 clgv: muhuk: `binding` is limited to dynamic vars

6:57 TEttinger: it's similar to ,(+ 1 2) to call (+ 1 2) with clojurebot

6:58 arossouw: ive tried this, but just gives me the hash-map let [result (apply str (merge-with (str "\n") x) , from clojure.set/difference result

6:58 clgv: muhuk: or it's just the automatic variable treatment thats missing

6:58 TEttinger: arossouw, oh you're using sets now?

6:59 arossouw: yes, using sets to compare data results from databases

6:59 http://paste.linuxmint.com/view/nkbl/

6:59 TEttinger: well (merge-with (str "\n") x) won't do what you want

6:59 clgv: muhuk: ah no, just different interface

6:59 julianleviston: arossouw: I suggest composing your forms piece by piece in the REPL… and testing them as you do so… until you're sure they do what you want.

6:59 TEttinger: (doc merge-with)

6:59 clojurebot: "([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."

7:00 clgv: muhuk: you pass a map of variables and values instead of the vector notation that `binding` uses

7:00 arossouw: julianleviston: ok, i'll try with small data sets, to see how i can destructure

7:00 TEttinger: your function f there is just the result of calling str on \n, so "\n"

7:00 julianleviston: arossouw: can you clearly say what you're trying to do, simply if possible? We can probably help.

7:01 TEttinger: and yeah, the repl is a great place to work this stuff out

7:01 (inc julianleviston)

7:01 muhuk: clgv: yeah, also there's this `(var ...) stuff in binding. It seems those vars are re-defined in the new frame.

7:01 TEttinger: oh lazybot just died

7:01 arossouw: ok, i'll try. i'm comparing a master and slave database count results of tables, the results of each is then passed to clojure.set/difference to detect differences

7:01 clgv: muhuk: I think `binding` could be implementer on top of `with-bindings` but due to historic reasons (1.0 vs 1.1) it is not

7:01 arossouw: then i'd like to neatly write clojure.set/difference results to file

7:02 julianleviston: arossouw: so you have some data from the master and slave… what form is it in? Is it hashes? sets?

7:02 TEttinger: so you're using the set you get by calling the fn keys on the map?

7:03 clgv: arossouw: check out (doseq [e your-set] (println e))

7:04 julianleviston: arossouw: sorry, when I said "hashes" I meant maps… old ruby habit :(

7:04 TEttinger: good idea, clgv

7:05 acron^: So, I'm using (spit f (doall (flatten ...

7:05 but it's still printing a lazyseq :/

7:05 julianleviston: acron^: um… doall is for side-effects.

7:06 arossouw: sorry, power failure (load-shedding) in south africa

7:06 clgv: julianleviston: not really, it forces the evaluation of the lazy-seq passed to it

7:06 TEttinger: you could just replace doall with vec there

7:06 arossouw: yes, the jdbc query returns hash-map results

7:06 clgv: arossouw: check out (doseq [e your-set] (println e))

7:06 julianleviston: clgv: yeah but it doesn't return the value does it?

7:07 TEttinger: assuming it's a vec

7:07 clgv: julianleviston: it does - you are confusing it with dorun

7:07 TEttinger: if it's a lazyseq now it will convert it

7:07 julianleviston: clgv: ah ok sorry… I wonder why it isn't working then

7:07 arossouw: clgv: ok, thanks

7:07 TEttinger: acron^, are they nested lazyseqs?

7:07 slipset: arossouw: is your example the exact thing you want to do or is it just an example of a more general question?

7:07 clgv: ,((juxt doall dorun) (range 10))

7:07 clojurebot: [(0 1 2 3 4 ...) nil]

7:07 acron^: i'm trying to (spit f (flatten [[x y z (map ...)]]))

7:07 TEttinger: because doall won't turn those into a different type

7:08 ah...

7:08 arossouw: slipset: just confused how to output clojure.set/difference that contains hash-maps to newline formatted output

7:08 acron^: vec did it

7:08 kinda :)

7:08 TEttinger: (doc flatten)

7:08 clojurebot: "([x]); Takes any nested combination of sequential things (lists, vectors, etc.) and returns their contents as a single, flat sequence. (flatten nil) returns an empty sequence."

7:09 clgv: acron^: check out `mapv`

7:09 TEttinger: I'm surprised flatten would return a lazyseq

7:09 arossouw: ah

7:09 acron^: clgv: it's not the map that's the problem, it's the flatten

7:09 docs dont say it but the result is lazy

7:09 justin_smith: TEttinger: flatten has so many surprises!

7:09 clgv: acron^: the flatten is weird in this case anyway

7:09 TEttinger: ,(class (flatten [[(map inc [1 2 3])]]))

7:09 clojurebot: clojure.lang.LazySeq

7:10 TEttinger: yup!

7:10 it's awful

7:10 justin_smith: (spit f (apply concat x y z (map ...)))

7:10 julianleviston: TEttinger: actually I don't think flatten does… it returns a seq over it's given, if I'm reading the source correctly.

7:10 clgv: acron^: every `flatten` usage you encounter has a high probability of being the wrong, erm let's call it "solution", to the problem at hand

7:10 julianleviston: hehe yeah, avoid flatten.

7:10 TEttinger: I just checked the class it returns

7:11 justin_smith: ,(flatten {:a 0 :b 1 :c [12 3 4 5]})

7:11 clojurebot: ()

7:11 clgv: ,(class (doall (flatten [[(map inc [1 2 3])]])))

7:11 clojurebot: clojure.lang.LazySeq

7:11 clgv: ;)

7:11 TEttinger: heh

7:11 we're all trying it!

7:11 arossouw: (flatten (set [{:sn "Arno" :fn "B"}{:sn "BB" :fn "A"}]))

7:11 ?

7:11 ()

7:11 TEttinger: ,(flatten (set [{:sn "Arno" :fn "B"}{:sn "BB" :fn "A"}]))

7:11 clojurebot: ()

7:11 julianleviston: arossouw: put a comma in front.

7:12 arossouw: ij

7:12 ok

7:12 clgv: arossouw: as I said, `flatten` is the wrong function to use in a lot of cases ;)

7:12 julianleviston: arossouw: or a double-# for inline like this ## "yay!"

7:12 arossouw: or a double-# for inline like this ##"yay!"

7:12 TEttinger: lazybot died

7:12 clojurebot lives

7:13 julianleviston: TEttinger: I am confuze… different syntax for inline?

7:13 justin_smith: julianleviston: ##(str 'clojurebot " requires () for ##")

7:13 muhuk: ,(sequential {})

7:13 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: sequential in this context, compiling:(NO_SOURCE_PATH:0:0)>

7:13 clgv: does "lein deploy" use the :user profile?

7:13 julianleviston: justin_smith: ahhhh

7:13 TEttinger: clojurebot doesn't have inline eval

7:13 muhuk: ,(sequential? {})

7:13 clojurebot: false

7:13 arossouw: i'll try clojure.data/diff instead of clojure.set/difference

7:13 justin_smith: TEttinger: meant lazybot, sorry

7:13 muhuk: arossouw: flatten needs sequential colls.

7:14 justin_smith: and lazybot is out anyway

7:14 ~flatten

7:14 clojurebot: flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.

7:14 TEttinger: ,(flatten {:a [1 2 3] :b [4 5 6]})

7:14 clojurebot: ()

7:14 justin_smith: (since we don't see that enough)

7:14 TEttinger: heh

7:15 javjarfer: Hi there! i'm new to clojure and i don't know how to solve a little problem i have with the lightTable instarepl

7:15 anyone use it?

7:16 clgv: ~anybody

7:16 clojurebot: anybody is anyone

7:16 julianleviston: javjarfer: I have.

7:16 clgv: ~anyone

7:16 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

7:17 julianleviston: ~noone

7:17 clojurebot: Pardon?

7:17 julianleviston: ~you heard me

7:17 clojurebot: julianleviston: I'm just giving you a second chance

7:17 clgv: ~guards

7:17 clojurebot: SEIZE HIM!

7:17 julianleviston: HEH :)

7:17 arossouw: ok, so this is the output i get http://paste.linuxmint.com/view/e1lj

7:17 javjarfer: sorry, it wasn't a language related question, so i didn't want to have the whole conversation here

7:18 muhuk: javjarfer: just type your little problem, if someone knows the answer they'll reply

7:18 julianleviston: javjarfer: we're all friendly folks...

7:18 arossouw: it's a set of hashes! yay!

7:19 arossouw: julianleviston: is that good or bad?

7:19 julianleviston: arossouw: or… a seq over a set of hashes it seems

7:19 clgv: arossouw: very bad. straight way to hell ;)

7:19 julianleviston: arossouw: neither… so you want to do what with it?

7:19 arossouw: lol, ok

7:19 julianleviston: arossouw: diff it with something else and spit the diff'd bit?

7:19 arossouw: if its a bad way, i'll rewrite code and make it better

7:19 luxbock: clgv: this is what I worked myself up to: https://gist.github.com/luxbock/38d245ff1f1a194921cb

7:19 arossouw: julianleviston: exactly

7:20 luxbock: clgv: it looks horrible but I think after I refactor it a bit I can use the same idea to implement this for all other arrow-macros and let/when-let/if-let

7:20 javjarfer: so, the problem is that when i evaluate something thing the instarepl that i have defined in another namespace i don't get a console output, if instead i define it in the instarepl window, it appears

7:20 * arossouw takes mental note set of hashes, bad

7:20 muhuk: javjarfer: does your instareply import that thing?

7:20 julianleviston: arossouw: it's not bad. It's fine.

7:20 clgv: luxbock: you can encapsulate tasks in functions

7:21 luxbock: clgv: yep that's what I plan on doing, but I just wanted to get everything working first

7:21 javjarfer: yes, it gets evaluated to 'nil' because it just prints, but shows nothing on console

7:21 luxbock: it's easier for me to have everything workin in one big mess before I brake it into parts

7:21 julianleviston: javjarfer: where are you looking for the console?

7:21 clgv: luxbock: so the ultimate goal is debugging threading forms?

7:22 luxbock: clgv: yes, and binding forms as well

7:22 and `defn`

7:22 javjarfer: julianleviston: i look at the console that shows up with the "view console" tab

7:23 clgv: luxbock: I had an attempt on defn, but it still does not support `recur` calls

7:23 luxbock: clgv: this library already does this: https://github.com/AlexBaranosky/print-foo but I wanted to improve the formatting of the printed messages

7:23 clgv: luxbock: do you know spyscope?

7:23 julianleviston: javjarfer: ok.. just checking the obvious things :) sorry.

7:24 luxbock: clgv: yes, I was using it before

7:24 arossouw: julianleviston: ok, i think there should be a cleaner way though, i'll do some research

7:24 muhuk: javjarfer: if it's a function, you're calling it right?

7:24 luxbock: can't remember why I took it out of my profiles.clj though anymore

7:24 julianleviston: arossouw: so just to check… you want the set difference? or the set exclusion?

7:24 arossouw: the difference

7:24 javjarfer: julianleviston: no worries :)!

7:24 clgv: luxbock: (-> 2 dec dec (/ 1)) shouldnt throw an exception ;)

7:25 sm0ke: hello, can lein deps :tree be used on a particular dep

7:25 julianleviston: arossouw: the exclusion will get you all the bits not in either… from both…. but the difference will remove all the elements of the second set from the first… effectively

7:25 luxbock: clgv: oh yeah this is ->>, I forgot to change the name :)

7:25 arossouw: i actually only need the values, so i can do vals on the hash-map

7:25 julianleviston: arossouw: and why isn't it working for you then?

7:25 arossouw: or rather, how isn't it working?

7:26 javjarfer: muhuk: yes, it just a function defined in: (ns clojtest.core (:gen-class)) and i call it like: ('clojtest.core/fun "test")

7:26 arossouw: i'm getting the correct results, just confused on how to neatly format and output the results to a file

7:26 javjarfer: evaluates to nil, but get nothing on console

7:26 julianleviston: arossouw: haha oh ok…

7:26 arossouw: is spit not working for you?

7:26 arossouw: sorry, my explanation sucked

7:26 julianleviston: arossouw: a little, but we got there in the end.

7:27 justin_smith: arossouw: (spit f (with-out-str (clojure.pprint/pprint ...))) maybe?

7:27 julianleviston: justin_smith: nice!

7:27 muhuk: javjarfer: got it. It should work. I can try here if you paste a minimal code.

7:28 julianleviston: arossouw: with-out-str redirects the side effecting *outs* output to a string instead of *outs*, which spit will then put in the file for you…

7:28 arossouw: i'm getting a hash-map in the output file, {:table_name blah :rows blah}{table_name blah :rows 2123} <- output file

7:28 javjarfer: muhuk: ok, i will post it here.

7:28 julianleviston: arossouw: what would you like?

7:28 arossouw: justin_smith: i think that might work

7:28 justin_smith: arossouw: what do you want to be there a) in terms of data b) in terms of contents

7:28 err I mean b) presentation

7:29 arossouw: format the hash-map keys and vals with newline, neat output

7:29 justin_smith: arossouw: yeah, then the with-out-str / pprint combo should do it

7:29 arossouw: ok, thanks

7:30 julianleviston: arossouw: tho if you want the hashes newline-delimited it won't.

7:30 arossouw: you might wanna chuck an interpose \/n in there for good measure.

7:31 justin_smith: julianleviston: for a large enough hash it will insert newlines

7:31 arossouw: ok

7:31 julianleviston: justin_smith: look at you with your awesomeness :) that's cool.

7:32 arossouw: justin_smith: that did the trick

7:32 justin_smith: cool

7:32 julianleviston: (inc justin_smith )

7:33 justin_smith: lazybot's disco again

7:33 julianleviston: (inc justin_smith)

7:33 arossouw: is it common to use clojure.set/difference or is there better way of comparing data-sets?

7:33 julianleviston: justin_smith: it's just every time I use it lol

7:33 arossouw: it's common.

7:33 arossouw: ok

7:33 justin_smith: arossouw: there is also clojure.data/diff

7:34 julianleviston: arossouw: the things in data are pretty good for this tho tho… https://www.google.com.au/search?client=safari&rls=en&q=clojure.data&ie=UTF-8&oe=UTF-8&gfe_rd=cr&ei=G7TUVLmUIc_u8wfX-YCADA

7:34 justin_smith: or is it clojure.data.diff

7:34 arossouw: justin_smith: that one doesn't look so good in comparison

7:34 julianleviston: ugh… safari. sorry.

7:34 https://clojure.github.io/clojure/clojure.data-api.html

7:34 javjarfer: muhuk, first file: (ns clojtest.core (:gen-class)) (defn testing [a] (println "hi")) second file: ('clojtest.core/testing "a")

7:34 justin_smith: arossouw: it's got a different use case for sure

7:35 arossouw: i'll see if i can learn something from clojure data analysis cookbook

7:35 justin_smith: ,(require '[clojure.data :as data])

7:35 clojurebot: nil

7:35 justin_smith: ,(data/diff {:a 0 :b 1} {:b 1 :c 2})

7:35 clojurebot: ({:a 0} {:c 2} {:b 1})

7:36 justin_smith: it shows you what's only in a, what's only in b, and what's shared, as separate outputs

7:36 arossouw: ok, looks good

7:37 muhuk: javjarfer: 2 things. You're not importing your 1st file. And also you're quoting the fn var.

7:37 javjarfer: remove that ' and you'll see it's complaining that it can't find the var.

7:37 sm0ke: how do i add some extra jars to leiningen classpath?

7:37 arossouw: hehe, need to practise more of hammock driven development

7:38 javjarfer: muhuk, oh... sorry, thanks you very much

7:38 muhuk, noob mistake

7:38 julianleviston: arossouw: auto-marketing term for what mum used to call "think before you act" ;-)

7:38 muhuk: sm0ke: http://stackoverflow.com/questions/17259054/how-can-i-add-a-not-maven-compatible-jar-file-to-a-leiningen-project

7:38 arossouw: indeed, guess i'm too rushed with things

7:38 muhuk: javjarfer: np

7:38 sm0ke: muhuk: i dont really want to install it maven repo

7:38 julianleviston: arossouw: it's pretty difficult not to be in our world a lot of the time.

7:39 sm0ke: just add it to classpath

7:39 julianleviston: arossouw: one has to make a conscious effort to not be, perhaps.

7:39 muhuk: sm0ke: yeah. Me too. However I haven't got a better/different answer since then.

7:39 arossouw: true, since most people are so demanding

7:40 julianleviston: arossouw: I have a feeling you're thinking of either managers or clients?

7:40 arossouw: usually clients, my boss is a reasonable person

7:41 acron^: with there was a .write-line

7:41 wish*

7:42 julianleviston: acron^: there's a prn-str

7:43 acron^: does that work with io/writer ?

7:44 wink: hehe nice, https://www.reddit.com/r/nethack/comments/2tluxv/yaap_fullauto_bot_ascension_bothack

7:44 muhuk: Why isn't binding working here: http://dpaste.com/186ZEEV (it's clojurescript)

7:45 julianleviston: oh weird… clojure.set doesn't seem to have "the union of a diff b and b diff a"

7:45 muhuk: I expect it to at least pring :debug [1 2 3]

7:45 julianleviston: which I was calling exclusion, but there's no such thing in set theory apparently.

7:45 muhuk: s/pring/print

7:46 julianleviston: maybe I remembered that from Adove Illustrator. LOL

7:46 adobe*

7:47 justin_smith: julianleviston: outer join?

7:47 julianleviston: ah… symmetric difference it's called.

7:47 justin_smith: for relational algebra, yeah.

7:47 justin_smith: assuming I remember my relational algebra ok. :) I very rarely needed that particular join.

7:48 justin_smith: well, to be precise outer excluding join

7:48 http://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins

7:48 julianleviston: http://en.wikipedia.org/wiki/Set_theory

7:48 justin_smith: nice.

7:49 justin_smith: yeah, I julianleviston the best illustration is at the bottom of the page

7:49 julianleviston: in set theory, the symmetric difference

7:49 julianleviston: justin_smith: yup.

7:50 justin_smith: in illustrator, an exclusion. ;-)

7:50 justin_smith: see we should all just ditch these technical terms and use illustrator's terms. lol

7:50 "front subtraction"

7:52 justin_smith: "I'm on a linux box, you insensitive clod"

8:06 _2_cherina: what is a ocean??:)

9:30 mmitchell: would anyone here happen to know the job posting rules for the clojure google group?

9:31 do i just prefix the subject with [job] ?

9:31 tcrayford____: mmitchell: find an older job post on there and copy that one's style?

9:31 mmitchell: yeah cool

9:32 tcrayford____: (just a suggestion - I have no idea)

9:32 mmitchell: sounds good though :)

9:43 stuartsierra: mmitchell: Don't sound like recruiter-spam. :)

9:43 mmitchell: yeah :) I'll do my best!

9:48 can-of-bees: hi all. could someone point me towards a new-user-friendly example for writing XML? specifically XML that has been parsed/opened with clj-tagsoup.

9:49 what i've tried so far, in pastebin:

9:50 oops, here's the link http://pastebin.com/iQGe5iZN

9:51 justin_smith: can-of-bees: what do you want to write to the file?

9:51 can-of-bees: hi justin_smith. i'm trying to take malformed XML, open it with tagsoup, and write well-formed XML.

9:51 justin_smith: also, what you have there is basically spit

9:52 can-of-bees: OK, yeah, the code you have will write the parsed version, you need to do the processing and reconstruction

9:52 can-of-bees: justin_smith: okay.

9:53 justin_smith: http://clojure.github.io/data.xml/#clojure.data.xml/emit try clojure.data.xml/emit

9:53 or emit-str

9:54 tagsoup should generate an output compatible with data.xml

9:54 and instead of the whole with-open, just (spit "filename" (xml/emit-str ...))

9:54 krat0sprakhar: hi all.. i've been using clojure for a little over a month now and wanted to get started with some web development.. ring/compojure looks great and easy to get started with.. but on the frontend - there's just too much learn - clojurescript / react / om / reagent / core.async

9:54 can-of-bees: justin_smith: that's great, thank you. i had started to look through data.xml but wasn't sure if that was the right thing to try using.

9:54 krat0sprakhar: its getting a bit overwhelming now :(

9:55 justin_smith: can-of-bees: yeah, iirc tag-soup improves the parsing compared to data.xml, but produces compatible output

9:55 krat0sprakhar: why not ignore frontend clojure at first, and do one thing at a time?

9:55 krat0sprakhar: oh add google closure library to the frontend also

9:55 justin_smith: yeah, I would start with ring, compojure, some static pages

9:56 then think about maybe adding in a db backend, or clojurescript on the frontend

9:56 or, alternately, ignore ring/compojure and just generate some cljs and serve that statically - either way, do one of the two sides at a time

9:56 krat0sprakhar: ah ok

9:57 so hiccup is one way of doing templates..

9:57 justin_smith: having used all those things, I think you'll make more progress if you focus a bit more

9:57 krat0sprakhar: is there a more standard way - like other languages?

9:57 justin_smith: krat0sprakhar: just do ring/compojure and static html first, then do templating after that works

9:57 krat0sprakhar: the clojure community tends to be pretty averse to "frameworks"

9:58 krat0sprakhar: right

9:58 justin_smith: though we have things like figwheel that bundle a bunch of stuff up

9:58 krat0sprakhar: i am majorly from flask background..

9:58 justin_smith: but I don't think that's the right way to learn

9:58 krat0sprakhar: so i like minimal libraries as well

9:58 i finished the tutorial here http://www.jarrodctaylor.com/posts/Compojure-Address-Book-Part-1/

9:58 this covers ring / compojure / yesql / hiccup

9:59 justin_smith: that sounds decent

9:59 but yeah, break it into steps

9:59 krat0sprakhar: yeah

9:59 yesql was awesome! :D

9:59 justin_smith: there's a value to figuring out what each constituent part does

10:00 krat0sprakhar: agreed... so i should go slow then

10:01 is hiccup the dominant way the clojure community does templating or is there anything else you recommend?

10:01 justin_smith: hiccup makes sense if the person building the pages is clojure-friendly

10:01 there are other templating libs that are more similar to mustache if you have a dedicated front-end team

10:03 krat0sprakhar: ah ok

10:03 hiccup it is then

10:04 thanks justin_smith!

10:05 darrenh: can a record implement multiple protocols?

10:06 having trouble finding any examples on the web

10:06 Bronsa: ,(defprotocol p1 (f1 [_]))

10:06 justin_smith: darrenh: yes, you can just add more protocols to the record def

10:06 clojurebot: p1

10:06 Bronsa: ,(defprotocol p2 (f2 [_]))

10:06 clojurebot: p2

10:06 Bronsa: ,(defrecord r [] p1 (f1 [_]) p2 (f2 [_]))

10:07 clojurebot: sandbox.r

10:07 zoldar_: krat0sprakhar: there's also enlive for a more designer-friendly templating

10:07 darrenh: thanks

10:07 justin_smith: zoldar_: or sente, or antlers, or...

10:08 zoldar_: justin_smith: kixi and etc. yeah I know what you're at, right, too much overload in the beginning helps no one

10:08 justin_smith: zoldar_: his initial problem was too many details to take in :)

10:10 err wait I didn't mean sente, but whatever

10:48 darrenh: Has anyone got a link to a 'real' example of how to use Stuart Sierra's component library? The examples on github are confusing me.

10:49 In particular I'm having real trouble understanding how to make a component that depends on another component

11:03 AeroNotix: darrenh: what have you tried so far?

11:04 justin_smith: a couple good reasons to check out pixie if you want to do scripting / OS level stuff in a lang very much like Clojure but with fast startup and lower resource usage https://www.refheap.com/97005

11:04 darrenh: I was having trouble working out what to pass to the constructor. It seems as though an empty map works just fine. The library must be 'magically' injecting the dependency

11:05 AeroNotix: darrenh: it's not magic

11:05 it uses assoc

11:05 justin_smith: darrenh: it should be able to calculate the graph of which parts of your system need which other parts

11:05 AeroNotix: AFAIK assoc is not considered magic

11:06 darrenh: ended up with this:

11:06 (component/system-map :cache (->MemoryCache (agent {}))

11:06 :needs-cache (component/using (->NeedsCache {}) [:cache]))

11:06 justin_smith: darrenh: the relevant part of the github page is where he shows usage of component/system-map https://github.com/stuartsierra/component

11:06 Glenjamin: justin_smith: is that using 7 gig to produce a process tree?

11:06 justin_smith: Glenjamin: um no...

11:06 darrenh: inside NeedsCache the argument has 'magically' become the MemoryCache

11:07 justin_smith: Glenjamin: that's with firefox, chrome, and opera all running, plus a massive emacs

11:07 Glenjamin: oh right, i was a bit confused by the graph at the top

11:07 justin_smith: Glenjamin: relevant part is the line listings for bash vs. pixie (bash shown for scale)

11:07 Glenjamin: right, i see - looks neat

11:07 32gig of ram is a serious machine :D

11:07 AeroNotix: justin_smith: which parts of Clojure does Pixies explicitly not support?

11:08 justin_smith: Glenjamin: the "process graph" program is just hello world right now

11:08 AeroNotix: it's implemented in Python afaikcr

11:08 justin_smith: Glenjamin: system76 bonobo laptop

11:08 AeroNotix: rpython

11:08 AeroNotix: ah

11:08 justin_smith: AeroNotix: which is a super optimized python subset

11:08 AeroNotix: I know

11:08 justin_smith: OK

11:08 it's the tool used to build pypy

11:08 (which you probably also know)

11:08 AeroNotix: yup. justin_smith does Pixie support everything which clojure does?

11:09 justin_smith: AeroNotix: not everything, but it's got the important stuff, and is making progress

11:09 AeroNotix: justin_smith: awesome

11:09 justin_smith: AeroNotix: it has persistent data structures, protocols, records, etc.

11:10 and not perfectly code compatible with clj, but close enough for me to feel comfortable in it

11:10 (eg. check out that require form)

11:11 AeroNotix: missing is the concurrency stuff, but it's lightweight enough that I think I can do some cool stuff via ipc and multiple instances (thus the process-tree lib idea)

11:11 and they plan on implementing proper stm

11:12 AeroNotix: aha ok\

11:12 worth a look then

11:13 justin_smith: I like it so far, yeah

11:13 AeroNotix: cool, I'll take a gander whenever I need to drop to shell

11:22 justin_smith: it's small enough / fast enough startup that I could consider shelling out to it to do tricky stuff in emacs / elisp code.

11:23 stuartsierra: darrenh: That's how it's supposed to work. :)

11:25 darrenh: stuartsierra: don't get me wrong, once I got it working it's very cool, I just can't work out how an empty map has turned into a record

11:26 stuartsierra: and it wasn't completely clear from the examples that that was what would happen

11:26 hence 'magic'

11:26 {blake}: justin_smith: Is pixie your baby?

11:26 stuartsierra: darrenh: it's all just assoc-ing on maps.

11:26 justin_smith: {blake}: no, tbaldridge and some collaborators, I am just discovering it

11:27 {blake}: but I may end up contributing

11:27 {blake}: justin_smith: It looks pretty keen.

11:27 darrenh: stuartsierra: I think I need to update my mental model :)

11:28 stuartsierra: darrenh: The system is a map. The components are maps. The `using` dependencies declared on each component are the keys whose values should be copied from the system into the component.

11:35 darrenh: stuartsierra: that makes complete sense, it's just the bit where I can pass an apparently arbitrary argument to a component's constructor that gets somehow replaced by the system

11:37 stuartsierra: darrenh: It's not the value that matters, it's the *key*.

11:37 Any value of that key will get replaced when the system starts.

11:37 That's why I always write constructor functions for my records that only take the non-component keys as arguments.

11:38 darrenh: stuartsierra: this I think is where my understanding of records is lacking - do their constructor args become keys of the same name?

11:38 stuartsierra: darrenh: yes

11:38 darrenh: stuartsierra: now it makes sense :)

11:39 stuartsierra: thank you

11:39 stuartsierra: darrenh: You're welcome, glad it makes sense now.

12:41 tcrayford____: current status: have a perf improvement to clojure.core/assoc that's potentially up to 4x times faster than current (if you call assoc with more than one key/value pair): http://dev.clojure.org/jira/browse/CLJ-1656

12:54 justin_smith: tcrayford____: awesome, voted

13:02 tcrayford____: Coni probably as well

13:02 Waiting on benchmark results there

13:02 Thank's!

13:02 Bronsa: we really need http://dev.clojure.org/jira/browse/CLJ-731

13:04 tcrayford____: Yeah. Unsure that'd work properly for assoc, but yeah

13:20 dnolen: https://github.com/clojure/clojure/pull/6

13:21 seangrove: hrm...

13:21 dnolen: I admit it makes me laugh

13:21 justin_smith: dnolen: I think that would have been accepted if he had renamed the .clj files to .lava files

13:21 glaring omission

13:27 postpunkjustin: justin_smith: yeah, the most recent comment on the PR makes the same point

13:28 justin_smith: aha!

13:30 postpunkjustin: Frankly, renaming the language to Lava is the best idea I've heard since defclass and defmixin

13:31 noonian: justin_smith: the other justin at the meetup made that comment while we were talking about it

13:31 justin_smith: noonian: I sometimes forget who made the joke first, but yes :)

13:31 noonian: no, i mean he made the comment on github :P

13:32 justin_smith: right, but I said it out loud first? I don't even know.

13:32 haha

13:32 noonian: ah right lol

13:32 postpunkjustin: Even I don't remember

13:32 I may or may not have been one of the Justins in question

13:33 justin_smith: yes, I think I may have been the other one

13:33 or maybe visa versa

13:34 justin_gfrederic: are we all justins today?

13:34 justin_TimMc: I think so.

13:35 justin_rhickey: I know I am!

13:35 postpunkjustin: I'm so happy right now

13:35 justin_gfrederic: the justin_possibilities are endless

13:36 justin_rhg: why not

13:36 hellofunk: what in the world is happening right now.

13:36 have i taken too much cold medication

13:36 justin_smith: hellofunk: Friday is happening.

13:37 justintimeforjus: thank god

13:37 llasram: hellofunk: As it turns out, yes, but that is an entirely orthogonal problem

13:37 justin_hellofunk: hellofunk: It is I, your justin twin!

13:37 hellofunk: i'm voting for the theory that all those justin's are the same user

13:37 justin_gfrederic: justin_hellofunk: "justwin" as the kids call it these days

13:38 hellofunk: i was going to say it must be friday the 13th. then i realized that next week it really will be the 13th

13:38 aperiodic: I can see one of them and he's not typing all that

13:38 justin_hellofunk: haha

13:39 hellofunk: lol

13:39 llasram: Well, and also you can see the messages from other people changing their nicks :-p

13:39 DanKreek: I'm another Justin, just letting you all know

13:39 hellofunk: llasram: oh i can't cuz i have all those things hidden

13:39 TimMc: je suis justin

13:39 hellofunk: \

13:39 justin_rhg: my client which shows partial nicks dislikes this lol

13:40 hellofunk: well, you boys have fun. i'm going back to sleep

13:42 justin_smith: noonian: I sent you a /msg

13:59 hellofunk: justins: i kid you not, this was unplanned. i was flipping through synth programs and landed on this: https://www.dropbox.com/s/qrdd94sd7ns1k8g/2015-02-06%2019.49.59.jpg?dl=0

13:59 luxbock: https://gist.github.com/luxbock/6dcfeb2cdccc82b75e0b

14:00 how do I properly use nested gensyms?

14:00 I know potemkin has a unify-gensyms macro but I don't want to add it as a dependency just for this

14:01 TimMc: hellofunk: Justin, justin justin! Justin justin justin justin?

14:02 Juuuusssttin justin justininininin inJUsJ jj iuuuststisint n SnisTUisnSNSnuNNSSSSSSjJjjjjjjjjjjjjjjj

14:02 We now return you to your regularly scheduled chat.

14:02 postpunkjustin: Can I help you?

14:02 hellofunk: this must be Being John Justin

14:03 TimMc: Sponsored by: Nyquil

14:03 hellofunk: literally

14:06 gfredericks: luxbock: nested use of ` confuses the crap out of me and I try to avoid thinking about what it means

14:07 noonian: ^ this

14:07 tbaldridge: luxbock: create the symbols by hand via gensym and then unquote them in

14:07 ,(gensym "foo")

14:07 noonian: luxbock: like this? https://www.refheap.com/97008

14:07 clojurebot: foo27

14:08 luxbock: thanks

14:08 I have a few macros that are almost identical except for a few changing bits, so I wanted to try to create a template

14:08 but this is so hard to read now that it's probably not worth it at all

14:09 TimMc: Example of using gensym for this: https://github.com/timmc/handy/blob/handy-1.7.0/src/org/timmc/handy.clj#L7

14:10 gfredericks: luxbock: you could write a more general macro, and have your other macros expand to that

14:10 ~macros

14:10 clojurebot: I added a ~' and it worked.

14:10 gfredericks: ~macros

14:10 clojurebot: macros are like dessert

14:10 gfredericks: ~macros

14:10 clojurebot: macros are just a game with symbols

14:11 gfredericks: ~macros

14:11 clojurebot: I added a ~' and it worked.

14:11 luxbock: I actually did just add ~' and it worked hah

14:11 justin_smith: gfredericks: clearly in this case it would be ~'~' due to the nested ``

14:11 lol

14:26 crash_ep: Has anyone in here used Reagent?

14:30 TimMc: It is unlikely that no one has.

14:38 kiwitobes: I've played with it, haven't built anything big yet

14:52 crash_ep: kiwitobes: in Reagent, component fns can either return a Reagent component data structure (the nested vector stuff) or a function that returns a component. I'm not clear on why one might choose the latter. Got any idea?

15:17 kiwitobes: I think it's so you can set up local state. If you check the "Seconds Elapsed" example on the reagent homepage you can see how you don't want the atom resetting each time

15:17 The function gets returned with a reference to the atom, but it doesn't set it back to zero every time it's called

16:16 crash_ep: kiwitobes: ah, makes sense. thanks!

16:26 hyPiRion: ,`#=(symbol "#")

16:26 clojurebot: #<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>

16:27 hyPiRion: ahh boo

17:09 nort_: From a name of a method retrieved from clojure.reflect, how can I actually use the method name to call it on the object I just did the reflection on?

17:18 joegallo: well, my understanding is that clojure.reflect is more about telling you what fields and methods and stuff there are, but that actually invoking them is left as an exercise for the reader...

17:19 which, assuming you're on the jvm, means that you'd use that method name you just found as input into the ordinary reflection mechanisms of the underlying platform -- or that you use some kind of library that does such things on your behalf

17:21 justin_smith: nort_: there is a way to actually get the method and apply it from the reflection results, I recall an example amalloy had of doing that to reset the value of one of the integers

17:21 nort_: joegallo: hmm ok. So it is dependent on the platform? I am indeed on the jvm. So there is no standard way of calling a method from, say, a string?

17:22 joegallo: i dunno, i'm just some guy on the internet :D

17:22 nort_: :)

17:23 justin_smith: nort_: you can do that via read-string / eval. But the reflection results should be usable for actually invoking the method. One sec, I think I have an example around here somewhere.

17:23 nort_: justin_smith: Okay, good to hear it's possible at least :)

17:23 joegallo: yeah, i'm interested in seeing this, too. i'm in the source for clojure.reflect, and nothing is jumping out at me

17:23 read-string / eval is totally cheating, though :D

17:24 nort_: justin_smith: ah yeah, read-string / eval. Didn't think about that. But if it's a cleaner way, that would be cool

17:27 I have a large set of Java classes, each one describing a "signal" which each have different public fields. It's much more convenient to just represent them as hash-maps, that's the reason I want to use reflection instead of manually translating every class.

17:28 justin_smith: nort_: how about using bean?

17:28 ,(bean (java.util.Date.))

17:28 clojurebot: #<NoClassDefFoundError java.lang.NoClassDefFoundError: Could not initialize class sun.misc.ProxyGenerator>

17:29 justin_smith: err...

17:29 that usually works :)

17:30 RasterBurn: what is the best way to take one sequence and, based on some conditionals, bucket the elements into N sequences?

17:30 joegallo: ,(.hashCode "foo")

17:30 clojurebot: 101574

17:31 joegallo: ,(.invoke (.getMethod (.getClass "foo") "hashCode" (into-array Class [])) "foo" (into-array Object []))

17:31 clojurebot: 101574

17:31 joegallo: which looks bad, but it's not SOOOOO awful

17:34 justin_smith: (inc joegallo)

17:34 that's actually pretty cool

17:34 RasterBurn: you could do some math and then use partition

17:34 RasterBurn: would you be keeping ordering?

17:34 RasterBurn: yes

17:35 justin_smith: hmm i like your idea. let me stew on it for a bit.

17:35 justin_smith: ,(#(partition (/ (count % 4)) %) (range 20))

17:35 clojurebot: #<CompilerException clojure.lang.ArityException: Wrong number of args (2) passed to: core/count--inliner--4206, compiling:(NO_SOURCE_PATH:0:0)>

17:35 justin_smith: err

17:35 ,(#(partition (/ (count %) 4) %) (range 20))

17:35 clojurebot: ((0 1 2 3 4) (5 6 7 8 9) (10 11 12 13 14) (15 16 17 18 19))

17:36 justin_smith: it would be a little odd with non-integer multiples I guess

17:36 RasterBurn: (inc justin_smith)

17:38 nort_: justin_smith: oh, bean is good! Thanks

17:39 joegallo: haha, thanks, I will look into that one too

17:39 hyPiRion: justin_smith: perhaps use partition-all to avoid losing values?

17:39 justin_smith: hyPiRion: excellent point

17:40 in that case you want to round the count of the first arg up? maybe

17:43 hyPiRion: yeah, I think that would be the easiest

17:59 justin_smith, RasterBurn: https://www.refheap.com/97013 for a solid impl

18:00 It tries to distribute as evenly as possible, adding more to the first partitions if need be.

18:00 RasterBurn: hmmm

18:02 yeah I think I'm asking wrongly. My seq is something like '({:a true :b true} {:a false :b false} {:a false :b true} {:a true :b true}). I want three seqs... one with all the :a == true, and another seq of the remaining elements having :b true, and a third with whatever is left over.

18:02 hyPiRion: oh, yeah, that's a different thing altogether

18:03 RasterBurn: It's like a (cond) into a bunch of seqs

18:03 hyPiRion: you could probably do something with group-by there, I guess?

18:03 RasterBurn: i suppose... hmmm

18:03 that might be the best way. group-by, where f is a cond

18:04 (inc hyPiRion)

18:05 hyPiRion: ,(group-by #(cond (:a %) :a (:b %) :b :else :nil) [{:a true :b true} {:a false :b false} {:a false :b true} {:a true :b true}])

18:05 clojurebot: {:a [{:b true, :a true} {:b true, :a true}], :nil [{:b false, :a false}], :b [{:b true, :a false}]}

18:05 hyPiRion: or something

18:05 RasterBurn: yep

18:05 noonian: ,(frequencies (mapcat seq [{:a true :b true} {:a true :b false} {:a false :b true}]))

18:05 clojurebot: {[:b true] 2, [:a true] 2, [:b false] 1, [:a false] 1}

18:06 noonian: ah, want the actual elements

18:09 justin_smith: hyPiRion: #(cond (:a %) :a (:b %) :b :else :nil) is #(or (:a %) (:b %) nil)

18:09 err, no, never mind :P

18:09 hyPiRion: justin_smith: yeah, I almost did the same suggestion there :p

18:12 whomp: is there any way to see the actual line number where an error occurred in intellij cursive?

18:16 cfleming: whomp: What sort of error?

18:17 whomp: cfleming, 5 lines above the line with the last closing parenthese, i accidentally wrote "(2 3)", but the line number was 5 lines too low

18:17 the line number given

18:18 so i guess it just treats the whole thing as one big call, and gives the last line of the call

18:18 cfleming: whomp: I think that's a Clojure thing unfortunately - occasionally the line numbers of the errors are not always very accurate

18:18 whomp: but you can't get a good stack trace, either. what happens with a big project and an error pops up?

18:19 cfleming, ^

18:20 cfleming: whomp: You fish around until you figure out the problem

18:20 whomp: More or less.

18:20 whomp: Unfortunately unless Clojure gives accurate error line numbers, there's not much more you can do.

18:21 whomp: cfleming, couldn't they just fix that by providing a better stack trace or better ide support?

18:21 i don't see how a language can have that problem inherently

18:22 cfleming: whomp: I think it's to do with the line numbers Clojure emits in the bytecode, although I don't know the details I must admit

18:22 whomp: I do remember seeing a JIRA issue that was hopefully going to fix a couple of cases in 1.7

18:22 whomp: ok, thx :)

18:24 cfleming: whomp: http://dev.clojure.org/jira/browse/CLJ-1561

18:24 whomp: http://dev.clojure.org/jira/browse/CLJ-1568

18:44 sritchie: dnolen, or anyone else w/ cljs fu - I’m trying to call goog.base from within a clojurescript file, and getting an error in advanced compilation

18:45 https://gist.github.com/sritchie/a8f51c104d6c0b522a4d

18:46 basically, this line: (goog/base (js* "this"))

18:46 is generating var G__183483 = this;return goog.base(G__183483)

18:46 which throws this closure compiler error: ERROR: JSC_BASE_CLASS_ERROR. incorrect use of goog.base: First argument must be 'this'. at /Users/sritchie/code/clojure/racehub.com/resources/public/assets/generated/racehub/om/router.js line 520 : 104

18:46 the first arg is indeed “this”

18:47 hiredman_: sritchie: have you tried using this-as or whatever it is called

18:48 I mean, I guess it just does that, so in theory it wouldn't fix anything

18:48 sritchie: yeah, I was following this example, which stated that this-as fails for advanced compilation

18:48 http://www.50ply.com/blog/2012/07/08/extending-closure-from-clojurescript/

18:48 I’ll try it again - I’m looking at the closure compiler source, and it looks like it “this” has to be passed directly

18:48 yeah

18:51 hiredman_: I blame bbloom and all his talk of a-normal forms

18:52 sritchie: :)

18:52 bbloom: i take no responsibility for anything

18:54 sritchie: maybe allowing js* to take over more code will help....

18:54 hmm

18:58 hiredman_: most definitely

18:58 jinagarano: noir.session/put! doesn't seem to store any values. i'm using ring.middleware.session.memory as a store, i don't get any errors, and everything else works fine - only those values keep disappearing. does anyone have an idea what could be the problem?

18:58 hiredman_: the clojurescript compiler is hoisting the (js* ) in to a local for whatever reason

18:59 justin_smith: jinagarano: with ring.middleware.session all you need to do is association :session {...} to the response, and that will be the contents of the session

18:59 *assoc

19:00 hueyp: whats the correct way to test if something implements a protocol? I'm doing (instance? IMyProtocol x) but it throws exceptions if I pass it a map (PersistentArrayMap cannot be cast to java.lang.Class)

19:01 justin_smith: jinagarano: this does require using the map form of the ring response though {:status N :body (render ...) :session (assoc (:session request) ...)}

19:02 noonian: hueyp: satisfies?

19:02 ,(doc satisfies?)

19:02 clojurebot: "([protocol x]); Returns true if x satisfies the protocol"

19:02 hueyp: thanks :)

19:02 noonian: np :)

19:03 hiredman_: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/analyzer.clj#L1566 lifts arguments that are not "atomic" in to locals before analyzing a function call

19:04 classic a-normal form, and in my brain some how clojurescript+anf=bbloom

19:05 jinagarano: justin_smith: i was following along with "web development with clojure" and i've never actually used the map forms. what exactly does (assoc (:session request)) do?

19:06 noonian: (:session request) returns the session map

19:06 justin_smith: jinagarano: the request comes in with any existing session

19:06 noonian: assoc adds a key to a map

19:06 so that form adds a key to a session

19:06 justin_smith: jinagarano: the idea is that instead of using put! to mutate the state of the webapp, the session comes in as a key on the request, and is also returned as a key on the response

19:07 noonian: (assoc (:session request) :authenticated-with :oauth) for example

19:08 jinagarano: oh, now i understand.

19:57 javjarfer: Hey there! Anyone can say to me why a function passed as parameter can't be evaluated inside a let expression?

19:58 hiredman_: clojure's eval doesn't evaluate an expression in the current lexical scope

19:58 it evaluates expressions as top-level forms

19:59 thsig: Hey guys, what's the standard practice for shared clojure libs on a development machine? Let's say I have 10 clojure projects with a lot of common dependencies - in such a case, do people just install everything from scratch for each project using lein, or share the most common libs?

19:59 javjarfer: i used the parenthesis instead of explicit "eval", it is the same?

19:59 amalloy: javjarfer: hiredman_'s answer is right if by "evaluate" you mean "call the eval function"

20:00 if you mean something else, then it's not really clear what you mean

20:00 hiredman_: thsig: lein keeps jars .m2 (just like maven) and it is shared between projects

20:01 thsig: hiredman_: Ok, good to know - thanks!

20:01 hiredman_: javjarfer: easiest way to show us what you mean is to put code + error in a pastebin

20:03 javjarfer: hiredman_: okay

20:07 hiredman_: here it is http://pastebin.com/McuUZ50y

20:07 hiredman_: imagine instead passing (buffer gurl)

20:08 hiredman_: what about the error?

20:08 well

20:08 I suspect I know what the error is anyway

20:08 or maybe not

20:08 javjarfer: hiredman_: you just pass buffer, and you evaluate it inside the let expression like this (let [lin (. (rd gurl) readLine)]

20:09 ka bum! evaluation never ends

20:11 hiredman_: well, that definitely has nothing to do with evaluating functions passed in as arguments

20:12 javjarfer: if I had to guess I would suspect your call to .readLine is never returning for some reason

20:14 (so put in some printlns or use a stepping debugger or whatever)

20:14 javjarfer: hiredman_: i though, and it was just a guess, that like i was doing it inside a recursion and things declared inside let are not variables, they are preserved as values, that the function is just called once, and that keeps you in a infinite loop

20:14 hiredman_: could be a correct guessing?

20:14 hiredman_: no

20:15 javjarfer: hiredman_: nice, short answer xd, i will try to check with the debugger and see what is happening there, thank you

20:15 hiredman_: but there are way better ways to do what you are doing regardless of what the issue is with this, look at line-seq or (heaven forbid) slurp

20:16 javjarfer: okay, i will check, i was just doing it for fun and i found this

20:17 hiredman_: thank you

20:34 hiredman_: i think i got it, just in case you are curious

20:36 crack_user: hello guys

20:44 audiodude: Hello. I have the following warning message at the top of my REPL created with Emacs "M-x cider-jack-in": http://pastie.org/9893686

20:45 I’ve created the ~/.lein/profiles.clj file with the contents specified here: https://github.com/clojure-emacs/cider#using-leiningen

20:48 justin_smith: audiodude: replace "0.8.2" with the version cider needs (which is "0.9.0-SNAPSHOT")

20:48 there is an old and stupid bug that makes it ask for a version with lower case, which does not exist, so you need to fix it to be all caps

20:50 audiodude: I tried changing the profiles.clj line to "0.9.0alpha", then I get this: http://pastebin.com/D8Hk2dNP

20:50 justin_smith: audiodude: that's wrong

20:50 "0.9.0-SNAPSHOT"

20:51 0.9.0alpha is the cider version, 0.9.0-SNAPSHOT is the nrepl middleware version

20:51 audiodude: justin_smith: awesome that works, thanks!

20:52 imanc_: is defrecord a commonly used data structure or is it used to interop with java? Sort of freaks me out that it is (or appears to be) creating a java class

20:52 justin_smith: imanc_: fn creates a java class

20:52 imanc_: so does defrecord

20:52 but it is not for java interop

20:52 imanc_: ahh OK

20:52 justin_smith: lot's of things compile down to classes

20:53 *lots

20:53 well, not strictly to a "java class" - the clojure compiler emits jvm bytecode that creates a class

20:53 imanc_: justin_smith: seems you're never too far away from the underlying jvm

20:54 justin_smith: imanc_: that's actually a good thing most of the time

20:54 imanc_: the alternative would be some kind of state machine / meta circular evaluator, and we'd get worse performance than ruby

20:55 http://en.wikipedia.org/wiki/Meta-circular_evaluator

20:57 well, that page claims clojure is meta-circular, but it's really not. It uses some of the ideas though, for sure.

20:59 imanc_: that makes sense - how does clojure compare to ruby and python in terms of speed?

20:59 justin_smith: about 1 and 2 orders of magnitude faster, respectively

20:59 TEttinger: justin_smith: ruby's faster than python now?

21:00 justin_smith: oops, wrong order, my bad :)

21:00 TEttinger: I was wondering...

21:00 it also depends what you're doing

21:00 justin_smith: you can theoretically get identical performance to java, but idiomatic code is likely about 1/10 java speed

21:01 (in clojure that is)

21:01 TEttinger: also about 1/10 the code length :P

21:01 justin_smith: true dat

21:01 TEttinger: maybe 1/5

21:02 amalloy: justin_smith: i don't think you can theoretically get identical either, because the compiler does some dumb stuff like repeated checkcasts

21:02 but it's close

21:03 justin_smith: interesting

21:03 TEttinger: I'm not sure how LuaJIT compares to whatever the current normal Python impl is, or Ruby for that matter

21:04 amalloy: like uh, (let [^String x (whatever)] (repeatedly 10 #(.length x)))

21:04 i think that stores x as an Object in the closure of the lambda, and casts it to a string every time the function is called

21:04 instead of storing it as a string

21:04 TEttinger: I remember doing some tiny benchmarks and luajit did surprisingly well vs. MSVC++

21:06 justin_smith: yeah, lua is like tcl in that you wouldn't think it would be fast, but sometimes it really is if you hit the sweetspot

21:06 and not at all like tcl in that it has a sane syntax etc.

21:06 TEttinger: the JIT on LuaJIT is bananas, just amazingly good

21:06 justin_smith: in tcl it's super optimized string handling, and most of the language being implemented in terms of said string handling

21:07 crack_user: someone who ever used the java.jdbc clojure wrapper can say who it manage the connection pool?

21:07 TEttinger: ah, yeah regexes are lua's main weak point in speed

21:07 justin_smith: crack_user: there is no pooling unless you provide a pool implementation

21:07 TEttinger: lua doesn't have true replacement regexes

21:07 justin_smith: crack_user: there are some decent wrappers for c3p0 for connection pooling

21:08 crack_user: justin_smith: if I call consecutives "insert!" it will create a new connection for the tdatabase to each call?

21:08 justin_smith: unless you create a connection pool, or put them into one action, yeah

21:08 but the connection pooling is very easy to use

21:08 it's just not in there by default

21:09 crack_user: justin_smith: I am think how it can be implemented

21:09 justin_smith: crack_user: there's libs that do it, they will describe how to provide the pool to jdbc

21:09 it's simple

21:10 crack_user: https://github.com/niwibe/clojure.jdbc-c3p0

21:10 crack_user: justin_smith: like I have to share some global state who will hold the connection?

21:11 justin_smith: crack_user: no, the pool is added to the same connection data that you provide to the query function already

21:11 the github page shows how to use it

21:11 crack_user: justin_smith: I will check that

21:13 justin_smith: lol, its very simple

21:13 justin_smith: like I said!

21:13 crack_user: just replace the database configuration to use the c3p0

21:14 I need to do some ensure that the connection was closed at the end?

21:15 justin_smith: crack_user: the vm will clean it up I think

21:40 lvh: I'm trying to write integration tests for some code that makes HTTP requests using core.test. fixtures seem like the obvious choice, but there's no obvious way to make some things i instantiate available to the test. Am I just supposed to def some module level vars?

21:42 justin_smith: lvh: the fixture can bind a dynamic var

21:42 lvh: oh, right, cool.

21:53 amalloy: justin_smith: i prefer: "In the future, we'll be able to bind dynamic vars. And our cars will fly!"

22:00 justin_smith: haha

22:13 teh_pwnerer: lein new play-clj creates a play-clj project. in the android/libs folder there are several libgdx libraries. do i need to commit these to source control?

22:14 the libraries are not listed in the play-clj template's included gitignore

22:15 TEttinger: teh_pwnerer: they should get downloaded by lein, so they should probably be gitignored

22:17 teh_pwnerer: TEttinger cool thanx

22:17 justin_smith: probably the whole android/libs folder right?

22:17 teh_pwnerer: ya i will just ignore the entire android/libs folder. and the equivalent ios folder

22:19 TEttinger: I kinda am not sure if RoboVM even works with clojure right now

22:19 (iOS you can only build on macs anyway)

22:19 teh_pwnerer: actually the game im making is going to be desktop only, i just want to use play-clj. so i will just delete the android and ios libs since i wont build for them anyway

22:20 TEttinger: err

22:20 android has the content folder, teh_pwnerer

22:20 teh_pwnerer: o oops

22:20 TEttinger: I think you may need to keep android, iOS can go

22:20 teh_pwnerer: ok ill just erase ios

22:42 ibash: Howdy

23:45 sdegutis: Is there a statically typed, type-safe language with similar concepts to Clojure besides Haskell or OCaml?

23:45 justin_smith: sml

23:45 (which is similar to ocaml, but there are a few flavors, and it doesn't have the OO part)

23:45 sdegutis: Besides SML?

23:46 justin_smith: typed racket?

23:46 sdegutis: Ah, thanks.

23:47 justin_smith: also, there is ats which is super weird but definitely statically typed

23:47 atsII is the current version last I checked

23:47 (super weird, as in the lang is a huge bundle of macros implementing hindley/milner plus dependent types that compiles to C)

23:48 and some of the macros have really weird names

23:54 Blake1: Tempted to rewrite some old (Pascal!) code in Clojure. It dealt with (essentially) typed files.

23:55 sdegutis: Blake1: Sounds more like a job for Haskell.

23:56 Blake1: But it was all based around physical data properties.

23:56 sdegutis: Haskell? How so?

23:56 sdegutis: Blake1: well if it's typed, Haskell is great at types

23:57 Blake1: sdegutis: Well, here's the thing: it was a sort of combination of pseudo- and meta- typing.

23:58 Like, I didn't use Pascal's typing, except for code structuring. (It's object Pascal.)

23:58 sdegutis: Blake1: Sure. Any language can do the job fine. I'm just saying, Haskell is especially great when dealing with parses and types.

23:59 Blake1: but heck, you can probably do it in ClojureScript if you want, and then it'll even run in the cloud

23:59 Blake1: The system itself enforced its own typing. So, e.g., the Boolean type was literally a bit under the covers, but presented itself as any designation of true/false yes/no whatever/whatever.

23:59 sdegutis: Clojurescript! That would be kind of wild.

Logging service provided by n01se.net