#clojure logs

2012-12-08

00:00dOxxxIt was rather hard, probably because I'm not very practiced in Clojure, and the performance sucked *hard*
00:00dOxxxOnce I changed the clojure implementation to use mutable structures, the performance improved quite dramatically.
00:00devnthere are lots of tricks. I remember _ato's version of WideFinder2
00:00dOxxxNow, I may have implemented the immutable version badly.
00:01dOxxxLike I said, not very practiced. I'm Java programmer by day :)
00:01flying_rhinodOxxx: performance sucking hard is precisely what I am trying to avoid here
00:01devnflying_rhino: but dude... science.
00:01dOxxxBut it was only through testing and timing that I was able to figure out what was best.
00:01devntry it.
00:01dOxxxAnd I actually learned a few tricks from the clojure experiments that I was able to apply to the Scala implementation to make it *fly*
00:01bbloomforgive me for repeatedly linking to it… but it's really the best summary:
00:02bbloomflying_rhino: http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey
00:02bbloomwatch taht
00:02devnthere are tradeoffs here. if you want to write this in assembly, you can do that. i remember this sort of discussion coming up a lot several years ago.
00:02bbloomflying_rhino: and everything here http://www.infoq.com/author/Rich-Hickey
00:02bbloomthe idea isn't to eliminate mutability
00:02bbloomit's to limit and control it
00:02devn'"should i use haskell or clojure or C or OCaml or whatever" for it to be fast?'
00:03bbloomclojure has a very specific notions of state, time, value, and identity
00:03bbloomrich discusses them eloquently through those talks
00:03bbloomthey are all worth watching and reflecting on
00:03devn(inc bbloom)
00:03lazybot⇒ 2
00:03devnseriously, listen to bbloom -- and definitely check out "Are We There Yet?"
00:04bbloomflying_rhino: any real clojure application is going to have mutability, but it's carefully planned and minimized
00:04bbloomi often have a single top-level mutable value in my applications
00:04devnExactly
00:04flying_rhinomaybe my mistake is that I am trying to implement one high order system (entity systems) to another high order system (clojure). Because Entity Systems have their way of handling state and identity.
00:04bbloomflying_rhino: i haven't read the things you've linked yet
00:05devnthe point is: When you work with a clojure application, you can point at the parts of your program without much effort and say: "State changes here."
00:05bbloomflying_rhino: but you should also watch the videos about datomic
00:05devnfuck the datomic videos.
00:05bbloomflying_rhino: www.datomic.com is rich's new database
00:05flying_rhinohow free is it?
00:05bbloomit's not
00:05devnwatch the clojure videos about state identity and time
00:06devnthat's all you need to get it
00:06bbloomyes, watch the clojure videos first
00:06devndatomic's videos are icing on the cake
00:06bbloomwatch the datomic videos after you have a firm grasp on clojure's vocabulary
00:07bbloomyou're trying to run before you can walk… and people coming from java et al backgrounds often find that they can't even crawl at first!
00:07devnflying_rhino: is this your first lisp?
00:07Apage43I wrote some Java for the first time in a while the other day
00:08Apage43Screenful of "final"s.
00:08bbloomApage43: heh. it makes me want to weep trying to write java… and that was even before clojure
00:08flying_rhinodevn: I was doing some stuff with plt scheme/racket but that thing has plenty of mutable state so it is different.
00:08devnflying_rhino: i dont mean for that to sound like im judging you or something, but im telling you, clojure was my first-ish lisp after a brief encounter with common lisp
00:08dOxxxI'll say this about Java: It's predictable and the syntax is very straightforward.
00:09devnflying_rhino: i think what you have exactly wrong is that clojure somehow purely functional. i said it before and ill say it again: stuart halloway nailed it when he said that "Clojure is a consenting adults language"
00:09devnyou can have mutable state
00:09devnexcept it's *separate* from your program in a way that i think most programmers would appreciate
00:10devnwhen you can point at your program and say: "hello code reviewer. state happens here at line 38 and line 49"
00:10devnthat is a beautiful thing.
00:11devnit's not that state doesn't happen, or that magical monads are employed
00:11devnits' that state is accessed like a database
00:11devnit's*
00:11dOxxxheh magical monads
00:11dOxxxthe way some people describe monads, you'd think they were responsible for the big bang
00:12devnhey man, ask the haskell community
00:12devnthere used to be an old joke
00:12devn"how many monad tutorials have you read?"
00:12devn*end of joke*
00:12dOxxxhehehehehe
00:14dOxxxanyway, lovely chat, gotta get up early in the morning. ciao.
00:14flying_rhinogood bye
00:14devnciao dOxxx
00:14dOxxxflying_rhino: good luck with grokking clojure :)
00:15flying_rhinodOxxx: I'll need more than luck
00:15dOxxxpersistence :)
00:15devn(inc dOxxx)
00:15lazybot⇒ 1
00:16flying_rhinolike in LOTR my sword, and my bow, and my axe :)
00:17devndude, if a rhino can fly
00:18devnyou can grok clojure
00:18flying_rhinolol
00:19devnbtw, i think just about anyone who has used the word "grok" in a sentence on IRC
00:19devnhas every bit of capability required to undestand just about anything
00:19flying_rhinogrok grok grok
00:19devnour friend dOxxx is right though...
00:20devnpersistence!
00:26tpopethis weekend I'm going to learn clojure!
00:33alandiperttpope: booya!
00:38bordatouehello, is there an easy way write a client in clojure that connects to different ports with a same ip address using tcp
00:44bbloomtpope: while i'm busy repeating it to everyone: watch rich's talks! :-)
00:45RaynesI don't like that bbloom guy.
00:45bbloomRaynes: yeah, he's a jerk. what did he do this time?
00:45RaynesJust a jerk
00:45Raynes:p
00:46bbloomRaynes: yeah, last time he was in here, he was going around demanding people waste their time watching useful videos
00:46RaynesWhat a dick.
00:46bbloombig time.
00:48Raynescldwalker_: Dude.
00:48Raynescldwalker_: Why didn't you tell me about this? https://github.com/cldwalker/datomic-refheap
00:48RaynesIt's cool.
00:48RaynesAnd if I understood datomic *at all* I might even pull it.
00:49RaynesOh man, https://gist.github.com/samaaron/emacs-live/blob/master/packs/live/power-pack/config/refheap-conf.el Sam Aaron uses refheap.
00:50RaynesI've hit the big time now.
01:12urthwhyteHey, anyone had luck getting #clojure up and running on the RPi?
01:12urthwhytenot sure why I added that pound sign, too much time on twitter of late I s'pose
01:14tpopebbloom: I just made it through simple made easy
01:14Sgeo|webIf a function on clojuredocs is fundamentally broken, should I add an example to the body showcasing its brokenness?
01:14Sgeo|web(I currently have a comment. That comment seems to have been misunderstood by another commenter)
01:23clj_newb_234are there any publicized benchmarks of how fast clojure's "read" is ?
01:32Apage43clj_newb_234: ptaoussanis did some to compare it with his "nippy" serializer: https://github.com/ptaoussanis/nippy
01:33Apage43clj_newb_234: also, if you want to benchmark something yourself https://github.com/hugoduncan/criterium may be handy
01:45mindbender1I'm trying to rid my projects from being infested with thneed snapshots that can't be found anywhere on planet earth
01:45mindbender1please send the paramedics
02:05clj_newb_234Apage43: got it; thanks
02:17karimofthecrophi there. I am new to clojure. Trying to run tests from nrepl in emacs. I get error Unable to resolve symbol: run-tests in this context. what am I missing?
03:25broquaintkarimofthecrop: You need to be in the namespace (or qualify it) that run-tests lives in.
03:26karimofthecropbroquaint: how do I do that? when I say new, I mean, I started programming clojure 60 min ago
03:29karimofthecrop:-)
03:29tomojkarimofthecrop: https://github.com/kingtim/nrepl.el#keys
03:29tomojin particular, "C-c M-n: Switch the namespace of the repl buffer to the namespace of the current buffer."
03:29karimofthecropnice
03:29tomojor, to do it manually in the repl, you can just (in-ns 'the.ns)
03:29karimofthecropthx
03:30tomoj..though that only works if the namespace has already been loaded
03:31karimofthecroptomoj: thx again
03:38karimofthecropso, now I have my buffer loading
03:38karimofthecropand I have tests written, but (run-all-tests) is not in the ns
03:38karimofthecropis there some special command to load that from clojure-test-mode?
03:42tomojwell, you can jump back and forth between implementation and test with C-c t (if you're lucky)
03:42tomojthen C-c C-k in the impl to load it
03:44tomojdoes clojure-test-mode even work with nrepl?
03:44muhooif i wanted to have a monotonically-increasing number (like for a message id), should i use an atom for that?
03:44tomojoh, I have a very old version I think
03:46muhooyep (swap! foo inc), perfect
04:06karimofthecroptomoj: C-c t in clojure-mode 1.11.5 is very broken. I fixed it to go one way, but am a little green to fix it in both directions
04:07karimofthecropmatter of fact, I can't see that it is even intended to be bidi
04:09tomojyou're right
04:12tomojthe clojure-test-mode at https://github.com/technomancy/clojure-mode/blob/master/clojure-test-mode.el has C-c C-s called clojure-jump-between-tests-and-code
04:12tomojbut why is it version 1.6.0? O_o
04:12tomojmy clojure-test-mode.el says 1.6.0 as well though it's different
04:12tomojguess that is dev version of 1.7.0
04:13karimofthecrop that fn isn't defined
04:14karimofthecropthe binding is
04:14tomojI see, still wip I guess
04:14karimofthecrop:-
04:14karimofthecrop:-)
04:14karimofthecropmaybe I'll feel frisky and write one after I am done with 99 clojure problems :)
04:14tomojlooks like they do have a test->impl fn though?
04:14tomojoh, that's the one that already works, huh
04:15tomojwhere'd you get 1.11.5?
04:15tomojah, that's your clojure-mode version
04:16borkdudegoat moaning to y'all
04:17karimofthecropmornin
06:23fckwHi there.
06:24fckwI have a challenging programming problem:
06:24fckwI have many numbers, and each number can - but does not have to - be paired with 0..n other numbers.
06:25fckwAll I am interested in is: Are two numbers paired or not?
06:25fckwHow would you implement this, knowing that we are talking about millions of numbers?
06:26fckwAnd also knowing that in general, most numbers will not be paired, but few numbers will be paired with many other numbers.
06:26ucbfckw: what do you mean by paired?
06:26AimHereHere's a thing, if a is paired with b, and b is paired with c, is a paired with c? i.e. are these equivalence classes?
06:26fckwBuilding a tuple without further meaning.
06:26RaynesWinner of the vaguest question ever award right here.
06:26Raynes;)
06:26fckw:)
06:26ucbheh
06:27fckwAimHere: No, it's not transitive.
06:27fckwAn example:
06:27fckw5555 -> 345, 876, 1024
06:27fckw237 -> 1, 9999, 240
06:28fckw9999 -> 14, 8927, 1024
06:28fckw777 -> none
06:28fckw999 -> none
06:28fckw35232 -> none
06:28fckwLike this.
06:28AimHereIn clojure terms, given that you're saying these are sparse, would a clojure hashmap to a list of vectors of the paired numbers be useful?
06:28RaynesHow do you determine if a number is paired or not? Is this a list of numbers that you'd like to iterate through?
06:28RaynesI don't even know where to start.
06:29fckwIt's a sparse matrix, yes - but for a few elements there are many combinations with other numbers.
06:29AimHereas in {555 #{345 876 1024} 237 #{1 9999 240} ....}
06:29AimHerelist of sets, even, since you're just searching for some random member in them
06:29fckwThe numbers represent "pointers" (not in C++ terms)
06:29fckwThe easiest solution:
06:29fckwUse a HashMap or Dictionary with key = number, value = list of numbers
06:30fckwBut that's very inefficient in terms of memory being used.
06:30AimHereWell you're doubling the memory, really
06:30AimHereWhich is not really 'very inefficient', I'd say
06:30fckwBut is there not a better solution on the bit level?
06:31fckwI don't know exactly, but something like this:
06:31fckw4 -> 01001 would mean that number 4 is paired with number 2 and 5
06:31AimHereWell you could just have a set of one single number, each number representing a pairing, and which can be easily searched for
06:32fckwAimHere: And how would I conclude from the single number to the two original ones?
06:32ucbif you want some form of bit-based solution then you'd have to have a vector of all paired numbers, then use the index in the vector as bit position and then have a hashmap from number -> seq of bits
06:32AimHereSo if you have a maximum MAX_VAL, then a set of values of (a*MAX_VAL+b), and use integer division or modulus to fetch the numbers
06:32ucbnot sure why you'd want to do that though
06:33AimHereAs one quick suggestion - that one might not be totally trivial to search, though
06:33fckwucb: Yes, I was thinking about such a solution. But I was also wondering, whether this bit string could be compressed further.
06:33fckwAimHere: What would a and b be? My paired numbers?
06:34AimHereYes
06:34ucbfckw: depending on how many numbers are paired, you could replace your bit string (which might be super sparse) with a vector of bit positions
06:34ucb*badum-tish*
06:34AimHereYou'd likely want to be able to sort by key%MAX_VAL and key/MAX_VAL for that idea
06:35fckwucb: So I had some sort of vector/list, holding (2,5) to indicate that bit 2 and 5 were set, right?
06:35ucbfckw: yup
06:35fckwucb: Hm. But in Java an int takes usually 32 bits. It all depends whether I'd save memory that way or not.
06:36ucbfckw: that's what I was saying initially; also an int might not be large enough to index your initial vector someimtes
06:37RaynesAre by any chance planning to run this on a toaster?
06:37fckwAimHere: I'm trying to understand. a*MAX_VAL+b would compute some sort of z or whathever that would represent a and b, right?
06:38AimHereYes, and just store those zs
06:38AimHereTrouble is, you need to have them sorted two different ways performancewise
06:39fckwAimHere: The question already arises out of a pairing function: I am using Cantor pairing function to compute z from x and y.
06:39fckwThat's fine, code works. But the trouble is, for some z, there are other zs this z is combined with.
06:40fckwI was also thinking about using tries (e.g. Patricia trie) or the like.
08:15squidzthis may be a bit off topic, but does anybody know which software development methodology works for 2-person teams or even single person projects?
08:27kmicuit depends x]
08:34squidzkmicu: go on..
08:35squidzyou've got my attention ...
08:39kmicuit depends on how smart are those persons
08:40squidzokay, please lay out the options
08:44kmicuif they are smart then any methodology will be good, and if they are not so smart then nothing saves them ;)
08:45kmicuand seriously can you be more specific with your goal?
08:47kmicuAre you considering waterfall/scrum/xp... for 1-2 person team? ;]
08:50squidzim actually looking for a technique for myself for a personal project, and im hoping to have minimal distraction with said methodology
08:51squidzI mentioned the two person team because that might come in handy in the future, but for now, it is a single-person project
08:54squidzi'm not really looking to use scrum for a 1-2 person team, I really just want a way to organize my own work on a project
08:57ucbsquidz: then use whatever works best for you :)
08:57ucbsquidz: some people use jira/trello/asana + pomodoro for instance
08:59squidzim looking at pomodoro right now, and I have only barely used jira and trello. I'm thinking trello + pomodoro looks good to try out. I don't know what works for me, since Ive never really tested these waters, but I guess now is that time. Thanks ucb and kmicu
08:59NatchTODO.org file and a generous helping of red bull works for me :)
08:59ucbsquidz: sure; if you're regimented and virtuous pretty much anything will work for you ;)
09:01kmicuRescutTime for procrastination monitoring
09:02kmicuRescueTime*
09:04squidzkmicu: thanks
09:08yedilinks to some alternatives to disclojure?
09:10kmicuclojure gazette, planet clojure, prismatic?
09:11Gonzihclojure subreddit
09:11andrewmcveighI need a multi-method, but where the dispatch value can be something like a core.match pattern. Does something like that exist?
09:19yedithanks
09:19yedidunno why the clojure reddit didnt immediately come to my mind
09:21Scriptorit doesn't see a lot of activity, but good to check once a day or so
09:21AimHereThere's also the google group for clojure (maybe it's actual usenet, even)
09:30gfredericksI'm trying to run 4clojure on a fresh box; I installed mongo (which I don't have any experience with), but get odd connection errors when I try to start 4clojure
09:31gfrederickson second thought maybe it's a vanilla connection-refused :/
09:33gfredericksjava.io.IOException: couldn't connect to [li424-81/50.116.34.81:27017] bc:java.net.ConnectException: Connection refused
09:33gfredericksthe syntax there makes me wonder if it's somehow mangling the hostname and the IP address together?
09:34gfredericksconnections are definitely being accepted at port 27017
09:34gfredericksor maybe just that it's trying to connect to the public interface instead of localhost
09:35gfredericksthe config says host is "localhost" though :/
09:44kmicu:db-name "4clojure"
12:11krtfulChousuke, do you have a code example for me where empty collections counting as false in boolean logic can lead to bugs or is otherwise inconvenient?
12:14devngfredericks: you could try 127.0.0.1 and see if you get a different result from localhost maybe?
12:15AimHereI don't know what Chousuke has been talking about, but consider a map whose values are collections; you can't just (if (get foo :bar) <whatever>) anymore, since the result will be false if you either have empty collections or :bar isn't in the map
12:17devn,(if (get {:bar [1 2 3]} :bar) true false)
12:17clojurebottrue
12:18devnAimHere: i don't follow
12:19ucb,(if (get {:bar []} :bar) true false)
12:19clojurebottrue
12:19ucbeep
12:19ucb,(if (get {:bar #{}} :bar) true false)
12:19clojurebottrue
12:19ucb,(if (get {:bar {}} :bar) true false)
12:19clojurebottrue
12:19ucb,(if (seq (get {:bar {}} :bar)) true false)
12:19clojurebotfalse
12:19ucbthere we go
12:19devn,(if [] true false)
12:19clojurebottrue
12:19AimHeredevn, I was answering krtful; he was talking about the hypothetical case where '() would be equal to false. Clojure doesn't do that, unlike other lisps
12:20devnoh, gotcha
12:21devn,(if (get {:bar #{}} :bar nil) true false)
12:21clojurebottrue
12:21AimHere,(if (get {:bar nil} :bar) true false)
12:21clojurebotfalse
12:22devn*nod*
12:22krtfulAimHere, you should never use (if (get foo :bar) though bur thar (if (contains? foo :bar) yeah, but I suppose it's safe if you intend to map on collecitons only.
12:23AimHerekrtful, When should you ever test collections for boolean truthiness in the first place? I just picked the first one that sprang to mind...
12:25krtfulAimHere, you "shouldn't", I'm just seeking particular cases. I'm implementing some toy lisp and I've been debating with myself if I should have only nil and false as falsy or that + empty collections + NaN
12:25krtfulBasically, I'm vehemently against 0 as falsy because it leads to a thousand and one bugs.
12:25AimHereMake everything falsy, except true
12:26krtfulBut I'm not sure if considering empty strings, empty lists and the loss does cause bugs.
12:26krtfullol
12:26krtfulTHere was this one lagauge which did that right?
12:26krtfulIsn't in visual basic anything falsy except -1 or something.
12:26gfredericksmaybe there could be a special object called not-nil that is also truthy
12:27gfredericksonly true and unit are truthy
12:27krtfulunit as in the unit type or the value in that type?
12:27gfredericksthe value I suppose
12:27gfredericksalso any double larger than 1e10 is truthy
12:27AimHereMake true true; make false false. Make everything else a coinflip
12:28AimHereYou'd better understand your damn code before you try debugging!
12:40krtfulAimHere, in PHP "0" is false though
12:41AimHerePHP probably borrowed that from Perl
12:45llasramOr from C?
12:45AimHere"0" isn't false in C
12:45krtfulI'm pretty sure "0" doesn't count as false in C
12:46llasramOh, the string "0"
12:46AimHere"0" here is a string with the numeral 0 in it
12:46seangroveIs there an equivalent method for (not (empty? '()))
12:46krtfulNo, a string with the character '0'
12:46llasramIgnore me, I obviously wasn't following the convorsation
12:46krtful0 shouldn't be false either
12:46krtfulI'm okay with making NaN false though.
12:47llasramseangrove: seq ?
12:47AimHereseancorfield, "false"
12:47krtfulNaN tends to signal 'stuff didn't go as expected'
12:47seangrovellasram: Oh, interesting
12:48AimHere,(seq? '())
12:48clojurebottrue
12:48AimHere,(seq? '(3))
12:48clojurebottrue
12:48metellus,(seq '())
12:48clojurebotnil
12:48llasramseangrove: The docstring for `empty?` even mentions the idiom, making it enshrined in code :-)
12:49devnseangrove: I tend to just create (defn not-empty? [x] (comp not empty?)) because i like the way it reads
12:49seangrovedevn: That's probably best, yes. It's a bit more obvious than just `seq`
12:51llasramIt's obvious to people don't know Clojure well, but using `seq` to test for emptiness is pretty well enshrined
12:51llasramer, non-emptiness rather
12:51llasrams,obvious,more obvious,
12:51oskborHi, is this the place for a newbie question?
12:52llasramIt is the place for all questions
12:52llasramAnswers come and go :-)
12:52seangrove~justask
12:52clojurebotTitim gan éirí ort.
12:52oskborok :) I cant really wrap my head around why this shouldnt work: (+ [1 2 3])
12:53gfredericksoskbor: what other languages are you familiar with?
12:53oskborjava ruby javascript
12:54gfredericksin java you would not expect {1,3,4} + {4,5,6} to work, correct?
12:54gfredericks(assuming those are arrays)
12:55oskborhmm true
12:55gfredericks+ expects its arguments to be numbers
12:55oskborok, but how do i sort of flatten the vector then?
12:55gfredericksyou can give any number of arguments
12:55gfredericksapply is your friend in this situation
12:56raek,(apply + [1 2 3])
12:56clojurebot6
12:56oskborwill look into this apply voodoo
13:18sshackSo simple clojure question. Say I've got a record, (defrecord account [number balance]), and I want to do some aggregate function over all the balances (mean, histogram, whatever). Can I transpose all those balances into a list easily?
13:18gfredericksyou have one record or a list of records?
13:19sshackSorry, a list of records.
13:19gfredericksyou can (map :balance my-records)
13:20gfredericksthat would give you a list of balances
13:20sshackAwesome.
13:20sshackI'm porting some code from Mathematica here. So it's sort of lost in translation issues.
13:37creasehm. anyone know of good libraries to assemble (even janky) call hierarchies on clojure source?
14:42gfredericksRaynes: ping
14:44qerubI have a Seq that I want to convert to a type that depends on a value. I'm happy with (into (empty myvalue) myseq), apart from that (into (list) '(1 2 3)) reverses the list because of conj. Is there any nice way to do this?
14:44qerub&(into (list) '(1 2 3))
14:44lazybot⇒ (3 2 1)
14:45qerubI could always dispatch on the type myself and use (apply list myseq), but…
14:50gfredericksRaynes: unping
14:58qerubFor the record: I'm settling with (defn ordered-into [to from] (into to (if (seq? to) (reverse from) from))) for now. :/
14:59hyPiRionqerub: concat?
15:00hyPiRion,(concat (list) '(1 2 3))
15:00clojurebot(1 2 3)
15:00hyPiRion,(concat (vec) '(1 2 3))
15:00clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core$vec>
15:00hyPiRion,(concat (vector) '(1 2 3))
15:00clojurebot(1 2 3)
15:01qerubI currently need to be able to get the result as a vector too.
15:01qerub&(into [] '(1 2 3))
15:01lazybot⇒ [1 2 3]
15:05qerubSorry, I'm not expressing myself clearly. I have a function that can operate on lists and vectors and I want the return type to match the input type. The function works with seqs internally so I'm looking for a way to convert back.
15:08qerub&(defn test [] "Are functions OK?")
15:08lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
15:09tylergilliesIs there something like rubygems for analogous to clojars? Its a cool site, but theres not much sexay there :)
15:10tylergilliess/for/for clojure/
15:10qerubtylergillies: What are you missing the most from Clojars?
15:11tylergilliesqerub: all links are internal to clojars, rubygems has links to source, documentation, authors website, etc
15:14tylergilliesi usually use it to find github page for projects on a general topic
15:14qerubtylergillies: Actually, there are website links if the URL is specified via e.g. :url in project.clj.
15:14tylergilliesqerub: ah, thats just my ignorance :)
15:15qerubtylergillies: I don't know about the other link types, but I do agree they should be there too.
15:17tylergilliesi just did search for "png" on clojars, i found a lib for png manipulation, would like to know what the github url is so i can thumb through the code before i download it
15:17tylergilliesthats my biggest usecase for visiting a site like that
15:18qerubtylergillies: There's http://www.clojuresphere.com/ too.
15:18tylergilliesqerub: checking it out, thanks :)
15:19tylergilliesno link to github, but theres a link to clojars lol
15:19qerub:>
15:20qerubtylergillies: http://www.versioneye.com/search?lang=%2Cclojure%2C&amp;q=png
15:20qerubtylergillies: Same there, hehe.
15:20clojurebotI don't understand.
15:21tylergilliesthat might be a bad example, i just found another project on clojuresphere with link to github
15:21tylergilliescan't find lib on clojars though
15:21tylergillieshttp://www.clojuresphere.com/org.lispnyc.webapp.homebase/org.lispnyc.webapp.homebase
15:24qerubtylergillies: Have you managed to track down the source to png-extract?
15:24tylergilliesqerub: nope heh
15:28ivaraasenqerub: what kind of png manipulation do you need to do?
15:28qerub*redirects ivaraasen's question to tylergillies*
15:29ivaraasenah sorry, too little coffee this evening
15:29tylergilliesivaraasen: something that will break png image data into chunks for easy chunk manipulation
15:29tylergilliestheres a good ruby lib called chunkypng
15:30ivaraasencould perhaps use im4clj
15:30tylergilliesphilosophical question: do you guys think that easy interop with java makes it so people don't feel the need to create clojure specific libraries?
15:31tylergilliesivaraasen: googlin it, thanks
15:31tylergilliesimagemagick wrapper.... gah
15:32tylergilliesthanks but no thanks ;)
15:32ivaraasenI've used it a couple of times, but nothing fancy
15:32ivaraasenmaybe ImageIO from Java?
15:33tylergilliesivaraasen: thanks
15:34tylergilliesfound http://code.google.com/p/javapng/
15:34tylergilliesmeh, its not in maven
15:35devntylergillies: depends. sometimes i want a more clojure-ey way of dealing with a java library, so i wrap those parts up
15:35devntylergillies: in some cases the answer is absolutely yes, because i dont want to write a library to do something really difficult that is...done already, and very mature
15:35tylergilliesdevn: valid points :)
15:36qerubtylergillies: Re: the philosophical question; yes, I believe so. A factor is that Clojure was created to be a "hosted language" that doesn't hide the underlying platform (even clojure.core leaks some Java-isms), so I guess it isn't looked down upon to drop down to the libraries for the underlying platform.
15:37devntylergillies: that being said, i think that sometimes it might discourage people from building something that exists in java, but actually sucks
15:38devn*maybe*
15:38devni dont have data or anything, just guessing
15:38tylergilliesqerub: ah so yes, but its not a bad thing
15:39tylergilliesdevn: something sucking in java? never. *disclaimer* I'm coming from ruby ;)
15:40devntylergillies: everything sucks. we're all just trying to pick the thing that sucks the least at any point in time.
15:41qerubI'm a bit of a purist, so my stomach turns a little bit every time I see Clojure code with lots of Java interop, but I realize my unacceptance is rather irrational.
15:41devnqerub: yeah, well, then you call (class "string") => java.lang.String
15:41devnthere's no need to pretend we're not in java
15:41devnjust bask in the fact that you live in the sane part of it
15:42qerubdevn: Well put :)
15:42devnor allow other people to fool themselves by wrapping every bit of java in a function
15:43sshackHrm. Any way to define a record from an table in a database?
15:45amalloydon't do it, man. maps are the one true data structure
15:47sshackIn this case, I don't think so.
15:48sshackMy main purpose is to load a bunch of records into memory and doing aggregate functions on their various fields.
15:48citizenparkerAnyone done much with per-environment configuration in leiningen?
16:00tylergilliesamalloy: speaking of maps being ultimate datastructure, why do a bunch of functions use vectors to map things instead of actual maps? e.g. (let [foo bar biz baz]) vs (let {:foo bar :biz baz}) or something similar
16:01gfrederickswell let is order-dependent
16:01gfredericksvectors in general are used in clojure for introducing locals
16:02tylergilliesi understand its idomatic, its just strike me as a bit odd
16:02tylergilliesmaybe i need to drink more koolaid ;)
16:02llasramI think the order-dependance gfredericks mentioned is the thing. Clojure in `let` previous locals are visible to subsequent locals
16:03gfredericksletfn is the only exception to the order-dependence that I know of
16:03llasramRight, and the syntax of that one is a bit different in a way which doesn't lend itself to using a map at all
16:04tylergilliesorder dependance meaning (let [foo bar biz (i can use foo here?)]) ?
16:04gfredericksyep
16:04tylergilliesgotcha
16:04tylergilliesthat makes sense
16:35popo1234,(let [s (iterate inc 0)] (print (take 2 s)) (print (take 2 s))))
16:35clojurebot(0 1)(0 1)
16:36popo1234How do I get (0 1)(2 3) ?
16:37amalloy&(take 2 (partition 2 (iterate inc 0)))
16:37lazybot⇒ ((0 1) (2 3))
16:41daniel_karlssonThought I would get to know Clojure for a bit. Is Emacs the way to go (I have never used Emacs and are on OS X)?
16:43tpopeif you don't have strong attachments to any other editor, probably
16:43amalloydaniel_karlsson: emacs is most popular, but your best bet is to use what you know
16:45RaynesThere is counterclockwise for eclipse, vimclojure for vim, clojure-mode for Emacs, crappy support in sublime text 2.
16:45RaynesYou could also write it down on paper and scan it later.
16:45RaynesLots of ways to write Clojure.
16:45daniel_karlssonI tried it in Sublime Text 2 and it was a bit of a pain
16:46Foxborondaniel_karlsson, i have made some stuff for Sublime regardiung Clojure :)
16:46FoxboronPorted some snippets and made a clojuredoc search plugin.
16:46FoxboronBut the SUblimeREPL is still broke with Lein2
16:47daniel_karlssonok, I tried to interact with the REPL but it was not picking up key commands
16:47daniel_karlssonMight be since I use the Vim bindings
16:47RaynesIt's more that the indentation is just pathetic.
16:47popo1234amalloy: thanks!
16:48ivaraasentylergillies: did you succeed in chunking up your img?
16:48daniel_karlssonOk, cool. Mostly wondered if Emacs was the way to go. Thanks
16:50bbloomdaniel_karlsson: if you're a vim guy, just stick with vim. don't try to learn a language and an editor at the same time :-)
16:50tpope^^^
16:54daniel_karlssonyes, I guess Clojure will be enough for my brain to handle
16:58RaynesI've never really bought that.
16:59RaynesIf you want to learn an editor and a language, go for it.
16:59RaynesTurns out the human brain is capable of it.
16:59RaynesWhat they really should be saying is "Don't learn an editor just because you think you have to in order to use Clojure." because you certainly do not.
17:00bbloomRaynes: I tried to learn clojure and emacs at the same time, but it didn't go well. and i already had some basic emacs skills...
17:00bbloomso while this human brain may be capable, it doesn't seem favorable
17:00tpopeI'm pretty fiddly about my editor, so trying to learn emacs at the same time would mean learning elisp
17:00amalloyi had a great time learning emacs and clojure at the same time
17:01tpopeI don't think anyone is smart enough to learn their first two lisps at the same time :)
17:01bbloomtpope: "pretty fiddly" is an understatement….
17:01Raynesbbloom: Were you, by chance, learning Emacs because you felt you needed to to use Clojure?
17:01RaynesIf so, you fall into the above category I mentioned.
17:02bbloomRaynes: to some extent. however it was because i simply didn't have a workable repl available to vim
17:02bbloomthat was pre nrepl, early broken nailgun days of vimclojure, etc
17:02Raynestpope: Nice to meet you, btw. I used lots of your Vim stuff in my Vim days.
17:02Raynes<3
17:02tpopecheers
17:02RaynesBut I guess so does everybody.
17:02tpopeI have a clojure plugin now too
17:02tpopein case you missed it
17:03RaynesI saw. Good stuff.
17:03RaynesI use Emacs with evil-mode these days or I'd be all over it.
17:03RaynesI was actually using vim last night though, because Emacs doesn't highlight viml out of the box.
17:03tpopeweird, cuz vim highlights elisp out of the box :)
17:04bbloomheh.
17:04RaynesAlso, regarding the other convo.
17:04RaynesI learned Haskell and Emacs at the same time.
17:04bbloomRaynes: I tried evil-mode, but learning clojure, emacs, and not-quite-vim at the same time was even less favorable than learning clojure and emacs without the not-quite-vim mode
17:05RaynesIt's pretty-close-to-vim
17:05RaynesEverything I most commonly used in Vim is there.
17:05RaynesFor me, anywyas.
17:05bbloom*shrug* pretty-close-to-vim is almost worse than no vim bindings at all
17:05Raynesanyways*
17:05RaynesThat's pretty silly.
17:06tpopeI couldn't get the hang of it, but I didn't fight it very long
17:06bbloomnah, i'd rather have no vim bindings than ones that break my muscle memory
17:06bbloombut my normal mode fu is pretty strong
17:06RaynesI don't know what you just said, but okay
17:07tpopeI'll up my emacs game if I ever get a chance to pair with someone who's really good at it
17:07bbloomnormal mode is vim's default mode
18:10sveduboisI would like to write an android app using clojure. Do you know some tutorial ?
18:11gfrederickstpope: http://bjeanes.com/2012/09/pure-evil
18:13gfredericks(a coworker of mine who switched vim->evil and was particularly enamored of the internal design)
18:14sveduboisDo you know some website wrapper to develop android applications using clojure ?
18:16ghachey_quit
18:26ivaraasenanyone want to critique my first shot at Java inter-op?
18:28antoineBshow
18:30amalloyanyone who wants to, can't do it till you link it
18:31ivaraasenhttps://www.refheap.com/paste/7424
18:34amalloyivaraasen: you certainly don't need that atom in save!
18:35amalloyyou can, for example, (dorun (map-indexed ...)), or you can reduce over (range n), or you can loop/recur
18:37ivaraasenagreed
18:38antoineBwhy do you use "(into []" in create-buffer?
18:39ivaraasenrough translation from some Java code, so I utilised the fact that vectors given a number return the item at that index
18:40antoineB,(nth [1 2 3] 2)
18:40clojurebot3
18:40ivaraasenargh
18:40ivaraasenthis is embarassing
18:40antoineB,(nth '([1 2 3) 2)
18:40clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>
18:41antoineB,(nth '(1 2 3) 2)
18:41clojurebot3
18:41metellus,(nth [1 2 3] 0)
18:41clojurebot1
18:41callenantoineB: please use a repl or something privately if you're just learning something.
18:41callenantoineB: clojurebot is mostly for demonstrating a concept to others, not for personal experimentation.
18:41RaynesBecause you're just bothering the crap out of us, man.
18:41callenantoineB: alternately, /query the bot.
18:41RaynesI was about to call the internet police.
18:41RaynesBut since callen is obviously the sheriff.
18:41callenRaynes: no call the internet FBI
18:42callenRaynes: DEMS A FELON!
18:42RaynesOh noes
18:42callenfelonious repl.
18:43RaynesSounds like a character from Harry Potter.
18:44callenRaynes: maybe from HP:MOR
18:44antoineBivaraasen: "for" return a sequence so you can directly use nth, don't need "(into []"
18:45antoineBcallen: sorry
18:45amalloywell if he actually needs random access nth on a seq is not a very nice solution
18:45callenantoineB: never apologize! be unabashed at all times.
18:46antoineBivaraasen: you use bang at end of your function name, this mean the function mutate an object
18:47antoineBamalloy: vector is good for random access isn't?
18:47amalloyindeed, and you told him not to use one
18:47ivaraasenantoineB: most of these fns change objects. wasn't sure if the convention was for passed objects or changing the world in general
18:47antoineByes right
18:48ivaraasenmost of this is done sequentially, so it's not that important with random access, yeah
18:48antoineBread-image! should read-image
18:48ivaraasenagreed
19:04tomojdoes persistent! have a ! because you shouldn't try to use it more than once on a given transient?
19:06tomojah yes
19:19kenshoHi. I have a list of key-value pairs like this [[:foo :a] [:foo :b] [:bar :c]]. I want to get this into a map where each key maps to a seq of all values, i.e. for my example this would be {:foo [:a :b] :bar [:c]}. I can do it with (reduce (fn [m x] (update-in m [(first x)] conj (second x))) {} key-value-pairs) but this strikes me as a pretty common use-case so I'm wondering if there is a shortcut for this kind of thing?
19:20mthvedtkensho: have you looked at group-by
19:21tomojgroup-by frustrates me. but if you had r/group-by, which returned an IKVReduce (and if IKVReduce were useful), that could be pretty nice
19:22tomoj(comp ((comp r/map r/map) second) (r/group-by first)) ?
19:23amalloytomoj: that sounds more like rap lyrics than a useful clojure function
19:23tomojkensho: ignore me
19:25kenshothanks. group-by looks promising but doesnt work quite the way I need because it should only use the second element of each pair as value, group-by simply takes the whole pair so I get {:foo [[:foo :a] [:foo :b]]} etc.
19:26tomojyes, and then you have to break up the map, do your thing, and then recreate another map :(
19:26tomojs/recreate/create/
19:27kenshoyeah, I guess I stick with the reduce version
19:28amalloykensho: well, write a more general version of group-by that solves your current problem as well as future problems like it
19:28tomoj(fn group-with [kf vf coll]) ?
19:28amalloy(group-with find-key keep-value coll)
19:29tomojis r/group-by even feasible?
19:29kenshothat's a good idea thanks
19:29amalloy(defn group-with [kf vf coll] (reduce (fn [acc x] (update-in acc [(kf x)] (fnil conj []) (vf x))) {} coll))
19:30amalloythat's a function i've wanted a few times
19:30tomojwhoa, I think that's the first time I've seen fnil in use, and that is a pretty nifty use
19:31amalloytomoj: it's the most common use :P
19:32amalloyit tends to be pretty hard to think of any other uses for it
19:32tomoj(fnil inc 0) similarly
19:32amalloyoh, that's true
19:32amalloyalso (fnil + 0)
19:32tomojI always write #(inc (or % 0)) or whatever
19:33bbloomamalloy: i had no idea that existed. thank you
19:33amalloythough on reflection i can't remember why i needed nil to work in an addition
19:34kenshooh nice, didn't know about fnil, very handy. thank you.
19:34bbloomnow i really want to query a codeq db to see who uses fnil
19:34bbloomsomebody get on that :-)
19:35tomoj&(update-in {} [:foo :bar] (fnil + 0) 2)
19:35lazybot⇒ {:foo {:bar 2}}
19:37bbloom(def conjs (fnil conj #{}))
19:38bbloom((fnil conj #{}) nil 5)
19:38bbloom,((fnil conj #{}) nil 5)
19:38clojurebot#{5}
19:38bbloomi need that frequently
19:41gfredericksevery 2 months somebody mentions fnil and I decide it's something I need to remember
19:47tomojbblöom: I remember you asking about that and me suggesting #(conj (or %1 #{}) %2) :(
19:57bbloomtomoj: yeah, but the fnil version works with var args too :-)
19:58gfredericksuse-only is the same as require-refer, correct?
19:59bbloomgfredericks: if there are any differences, they are too subtle for me to have noticed
20:07seangroveAny reason I wouldn't have clojure.pprint?
20:07seangrove~pprint
20:07clojurebotCool story bro.
20:08seangrovehrm, getting "CompilerException java.lang.ClassNotFoundException: clojure.pprint"
20:08gfredericksseangrove: you've required it successfully?
20:09seangrovegfredericks: Nope, that was the problem
20:09seangroveI thought if I referenced the full name, it needn't be required
20:09seangroveThanks!
20:10gfredericksthat only works if some other ns already required it
20:10gfredericksso best to be explicit
20:14augustltrying to use proxy for the first time, seems the objects it generates aren't accepted by Java method signatures.. Getting "no matching method".
20:15augustlhere's my code https://www.refheap.com/paste/7427
20:15bbloomtpope: been abusing cpr, even though i generally have been evaluating individual forms. got burned hard by instance? breaking because i redefined a type that i had an instance of in my scratch file :-/
20:16bbloom(class x) returned foo.Bar and (instance? foo.Bar x) returned false :-/
20:16bbloomemacs people: any good way to deal with that?
20:16amalloybbloom: don't redefine types and expect old instances to be any good
20:16bbloomother than to avoid reloading files that declare types for which i have instances of them?
20:17bbloomamalloy: yeah that's clearly the problem
20:17bbloomi just wish it wasn't so easy to be fooled by (= (str (class old-x)) (str (class new-x)))
20:18amalloyaugustl: scheduleAtFixedRate isn't static
20:22augustlamalloy: doh, thanks
20:27gfredericks(defn siblings? [x y] (= (class x) (class y)))
20:27seangroveHave trouble with this macro https://www.refheap.com/paste/7428
20:28seangroveMap is returning a list, so the resulting form isn't right for doto
20:28gfrederickstry list* instead of list
20:30seangroveThat looks great, thanks
20:36amalloyseangrove: more like https://gist.github.com/69abccfc2793eeaafe45 maybe
20:37seangroveooohhh, interesting
20:38seangroveI was just wondering how to prevent value from being qualified on expansion
20:38seangroveThank you
21:16callenmy google-fu is failing me here and I end up in a maze of Google Group mailing lists, all alike. What's the story on futures/promises in ClojureScript?
21:16benizilein bootstrap is equivalent to: lein deps git-deps
21:17benizi(sorry: apparently responded to a question from days ago)
21:17tomojcallen: there isn't much of one that I know of
21:18callentomoj: namely, they don't work?
21:18tomojwell, neither cljs.core/promise nor cljs.core/future exist (right now)
21:18callentomoj: disturbing...okay. Thanks!
21:19tomojthere's this thread https://groups.google.com/d/msg/clojure-dev/-/XD1hnBvjNt8J
21:19tomoj(with links to wiki design pages. the link to cljque is out of date, the master branch is now the interesting one)
21:19tomojthat thread is about unifying promises and futures under a callback-based interface
21:20tomojwhich, eventually, could lead to something in cljs, though cljque is only on the jvm for now
21:23muhoobut isn't javascript single-threaded?
21:24tomojhence "callback-based interface"
21:24tomojoh, it's unclear what clojure.core/future might look like in cljs, yes
21:25tomojor whether it's even necessary?
21:27muhooi haven't used futures or promises yet. then again, i'm still new.
21:27tomojI think stu's current idea is that @(promise) will throw an exception in cljs
21:38bbloomis there a quick/easy way to see all of the interfaces/protocols on a given instance of an object?
21:39brehautsupers?
21:39brehaut(without the question)
21:39bbloom,(supers (class {}))
21:39clojurebot#{java.lang.Runnable clojure.lang.IObj java.lang.Iterable clojure.lang.IPersistentCollection clojure.lang.Counted ...}
21:39brehautoh probably (comp supers class)
21:39bbloomyeah
21:39bbloomhm thanks
21:40bbloom,(doc supers)
21:40clojurebot"([class]); Returns the immediate and indirect superclasses and interfaces of c, if any"
21:40bbloomseems to be interfaces tho, not protocols
21:40amalloywell, that will show you the interfaces. protocols, you're sorta SOL
21:40amalloyno such mechanism exists
21:40technomancyI always use the slime inspector for that
21:40bbloomtechnomancy: and us vim peasants?
21:40amalloytechnomancy: how? i'd be amazed if the slime inspector worked
21:40brehautamalloy: it'll show you any protocol generated interfaces for types that are lucky enough to use the interface right?
21:40amalloy(for that)
21:41amalloyof course
21:41technomancyamalloy: not protocols; I never use protocols
21:41technomancyjust to explore classes, interfaces, methods, constructors, etc
21:41brehauttechnomancy believes in the monomorphism restriction
21:45bbloomi want an IAssoc that has a dispatch function with a hierarchy, like a multimethod
21:46bbloomunless somebody tells me that exists, i'm going to make a DispatchMap class, which will be basically the immutable/persistent internals of MultiFn
21:47bbloomplus the caching behavior
23:06seangrovebbloom: So you can dispatch on subkeys in maps?
23:50RaynesDear #clojure. You can do this now: http://jsfiddle.net/frf8C/3/
23:50RaynesCarry on.
23:53ivanRaynes: why not just attach one callback that does both steps? ;)
23:54RaynesWhat?
23:54clojurebotwhat is exceptions
23:55ivanI assume this is a goog.async.Deferred or similar
23:55RaynesI don't do ClojureScript.
23:56RaynesOh.
23:57RaynesOH.
23:57RaynesJesus.
23:57ivan:)
23:57RaynesThe code.
23:57RaynesI thought you were talking about my embedding js, ivan!
23:57ivanI knew something was up
23:57RaynesYeah, thats just a random paste I plucked out of recent pastes to demonstrate embedding.
23:59tomojseangrove: I think goog.async.Deferred is, uh, bad
23:59seangrovetomoj: How so?