#clojure log - Apr 16 2013

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

1:04 tieTYT: i have a list of booleans. How do I "or" the elements in the list?

1:06 rhg135: (apply or the-list)

1:06 alandipert: tieTYT: (some identity thingies) perhaps

1:06 tieTYT: rhg135: that's what I thought...

1:06 alandipert: (can't apply or, as it's a macro)

1:06 rhg135: i think

1:06 ok

1:07 tieTYT: CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/or, compiling:(fileorganizer\core.clj:31:26)

1:07 rhg135: (apply #(or %&) the-list)

1:07 i mean

1:07 idk

1:07 alandipert: (reduce #(or %1 %2) the-list) maybe

1:08 rhg135: yes ^

1:08 tieTYT: ok

1:08 thx

1:08 alandipert: i'd go with the 'some identity' approach personally

1:09 tieTYT: whats that?

1:09 alandipert: (some identity the-list)

1:09 rhg135: wow, fancy

1:11 tieTYT: that's kind of cool

1:12 i'll do that, thanks

1:12 mthvedt: some is one of my favorite clojure fns, it's surprising where/when it shows up

1:12 s/shows/comes

1:13 tieTYT: this is my first time using it

1:24 patbrown: :alandipert Dude, thanks for helping me learn some Clojure. I write some every day and I love it.

1:30 alandipert: patbrown: np man happy hacking!

1:32 patbrown: :alandipert Yeah, send my best to Brenton, I definitely didn't get much at the time, but I kept referring back to the class handout for the first three months and remembering some of yall's points. It was worth every penny.

2:01 base698: Anyone know how to read a bufferedreader and NOT use line-seq. I need a sequence of chars. All i can find is line-seq

2:03 amalloy: base698: look up the methods defined for bufferedreader and see if you can come up with something clever

2:10 base698: amallay: I just did passed the stream and called read. I just didn't want to do that if there was something built in.

2:10 Thanks!

2:23 noidi: base698, if you want to encapsulate that in a `char-seq` function, it should be easy to do: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2725

5:03 yusup: is anyone using clojure in production ?

5:05 ordnungswidrig: yusup: many do

5:06 maleghast: Yeah, in a tiny way so far… There are those with much more "in prod" experience on here...

5:09 yusup: everyting great?

5:09 maleghast: For Sho!

5:09 yusup: *everything

5:10 maleghast: You should try and see if you can talk to some of the engineers from Forward in London - one of their guys does a talk about re-inventing their application(s) with Clojure that is very encouraging...

5:11 yusup: thanks maleghast

5:12 maleghast: Here you go, his name is Paul Ingles and here is what he has to say on Clojure in Production… -> http://www.infoq.com/presentations/Clojure-uSwitch

5:12 ordnungswidrig: We should build a showcase site "clojure in production" to advertise clojure

5:12 maleghast: ordnungswidrig: That's a great idea, no question.

5:13 yusup: that will be awesome.

5:13 * ordnungswidrig thinking about it

5:14 ordnungswidrig: short description of project / application, used liberaries/stacks. team size, and free text testimonial

5:14 and public rating to define importance of an entry

5:16 any volunteers?

5:16 btw. there is http://dev.clojure.org/display/community/Clojure+Success+Stories

5:17 wink: ordnungswidrig: there's not many links to click though

5:17 I'd love another page of real websites for example

5:17 yusup: that page is extremely slow.

5:18 wink: that's at least one heap of projects you can actually try :D

5:18 yusup: it's confluence :P

5:20 Netfeed: infoq has great content in a shitty presenation

5:21 jasonjckn: Netfeed: have you tried horizontal button

5:21 Netfeed: hmm, no

5:24 ordnungswidrig: you can also download infoq slides after registration.

5:24 sometimes.

6:01 bosie: ordnungswidrig: nice nick

6:03 ordnungswidrig: bosie: i tried to be subversive :-)

6:03 bosie: ordnungswidrig: but but ... you are german

6:03 ;)

6:07 ordnungswidrig: :-p

6:09 john2x: how do I start a clojurescript repl with all the dependencies in my project.clj ready for loading? (`lein repl` but for clojurescript?)

6:19 ambrosebs: john2x: Try lein-cljsbuild https://github.com/emezeske/lein-cljsbuild

7:53 nonuby: What approach are clojurers using to handle error notification in request based apps (ring/compojure), hipchat?

7:55 anyone got clojure logs as data video?

8:13 ordnungswidrig: nonuby: what do you mean, "error notification"?

8:25 mynomoto: nonuby

9:07 jjl`: hi all. i have a question about clojurescript's support for legacy browsers. is there some documentation on how far back things are supported?

9:32 stuartsierra: jjl`: ClojureScript is mostly browser-agnostic.

9:33 jjl`: yes, but things like :keys, do they support old IE

9:33 as object.keys() was added in ie9

9:33 (part of KS1.6)

9:33 JS1.6*

9:33 when i'm writing javascript, i either have to use a library to settle the differences for me or write it differently

9:34 stuartsierra: ClojureScript itself does not attempt to abstract over differences in JavaScript APIs.

9:34 jjl`: yes, but which version of javascript does it attempt to compile down to?

9:35 stuartsierra: That I do not know.

9:35 jjl`: i suspect it requires 1.6, which means it's not a viable option. but it's not documented anywhere i can find

9:35 ordnungswidrig: it depend son what the google closure spits out

9:36 bbloom: jjl`: I'm not sure what you're talking about with Object.keys, that's not anywhere in the clojurescript source that i can tell

9:37 jjl`: where 'Object' is any instance object

9:37 mpenet: yeah clojurescript maps do not map 1:1 with js maps

9:37 bbloom: jjl`: are you referring to the clojure.core/keys function?

9:37 mpenet: and js-keys uses google closure to iterate over the maps to get the keys

9:37 jjl`: mpenet: aha. that's the useful bit

9:37 mpenet: map entries*

9:38 bbloom: Google Closure abstracts over browsers

9:38 mpenet: so mostly browser agnostic as it's been said

9:38 jjl`: so i suppose what i'm looking at is google closure's browser support?

9:38 mpenet: yep

9:38 bbloom: jjl`: yes

9:39 jjl`: *sigh* there is of course no documentation on their support either

9:39 bbloom: jjl`: that's because it supports anything google supports, which is everything

9:39 jjl`: when google have been dropping support for old IE on their homepage?

9:39 Ember-: a long time ago

9:40 jjl`: sadly, i have a need to support ie8 as a hard limit and sometimes ie7

9:40 Ember-: google has supported officially only latest two major releases of each browser for a while now

9:40 which rules out IE8

9:40 jjl`: *nod*

9:40 mpenet: jjl`: https://groups.google.com/d/msg/closure-library-discuss/cpHlaWAkFag/HzpCAD9ThIMJ

9:41 seems safe, unless you are making a time machine

9:41 jjl`: hrm, that's from 2009

9:41 and googling for 'ie9 clojurescript' turned up a few people complaining about poor ie9 support

9:42 (also old, so hard to know what current status is)

9:42 bbloom: jjl`: if you find it doesn't work on a particular browser, come in here and complain (with a repro case) and i'm sure somebody can fix it up pretty quickly

9:42 or file a ticket

9:43 jjl`: okay, thanks

9:43 mpenet: I really doubt the core breaks on ie9 tbh, I think prismatic say they support ie8+ and they rely on cljs for their frontend

9:43 bbloom: cljs isn't coupled to the dom in any interesting way, so browser compat is relatively easy

9:44 for the most part, google closure totally alleviates that pain

10:04 ordnungswidrig: If a type implements multiple interfaces and a protocol is implemented for multiple interfaces, which implementation is used?

10:05 say, I implement a protocol for ILookup and Sequential which implementation of the protocol would be used for a [] or a {}?

10:06 ok, I found it. "extend" say it's TBD :-)

10:09 bbloom: ordnungswidrig: yes, but there must be some opaque decision proces internally. i had the same question recently. let me know if you find anything out

10:10 ordnungswidrig: bbloom: I guest it boils down to map key order or like that.

10:12 I remember a chart showing clojure datatypes and their implemented interfaces

10:13 bbloom: (source find-protocol-impl) ;; seems to be the definition

10:13 in src/clj/clojure/core_deftype.clj

10:14 stuartsierra: ordnungswidrig: It is currently undefined what happens when you invoke a protocol function on an instance of a type which implements multiple interfaces to which you have extended that protocol.

10:15 As a result, I generally recommend not to extend protocols to interfaces but only to concrete types.

10:16 ordnungswidrig: In liberator we provide default reoresentations for maps, sequences etc. To do this a protocol is extended for the types.

10:17 bbloom: stuartsierra: yeah, a quick read of the code suggests that the behavior that occurs depends on the order that java.lang.Class.getInterfaces returns

10:17 ordnungswidrig: I thought of using MapEquivalence and Sequential

10:17 bbloom: stuartsierra: which is " The order of the interface objects in the array corresponds to the order of the interface names in the implements clause of the declaration of the class represented by this object. "

10:18 stuartsierra: So at least it's predictable. Just arbitrary.

10:18 bbloom: yeah

10:18 it's also a weird arbitrary

10:18 ordnungswidrig: like tax law

10:18 bbloom: if you write class Foo extends Bar implements IFoo, IBar

10:18 then it seems like priority is left to right

10:18 stuartsierra: Not entirely - CL resolves multiple inheritance left-to-right based on declaration order.

10:19 bbloom: yeah, i guess that's consistent, but my intuition is that "mixins" override

10:19 ordnungswidrig: stuartsierra: IIRC you can even define the resolution order.

10:21 bbloom: just checked. scala resolves traits right to left

10:22 a more careful reading shows that clojure reviews the chain of concrete inheritence first, THEN checks interfaces

10:23 then resolves interface type preferences with .isAssignableFrom

10:25 seems like this ought to be documented :-P

10:25 ordnungswidrig: bbloom: noboy should rely on this :-)

10:25 bbloom: I suggest reading about CLOS. It's that powerful that you don't want to use it.

10:27 bbloom: fair enough. i was just curious how protocols worked. mystery solved: trivial method cache :-)

10:28 asaleh: question: is there a function to know if my var is a record?

10:29 bbloom: asaleh: (defn record? [x] (instance? clojure.lang.IRecord x))

10:29 stuartsierra: bbloom: Rich tends to regard docstrings as specification, so he won't commit to anything that he might want to change in the future.

10:29 Ember-: ,(defrecord Rec [x]) (instance? clojure.lang.IRecord (Rec. "hi"))

10:29 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

10:30 Ember-: aww

10:30 anyway, that way

10:30 asaleh: bbloom, thanks, was looking for the clojure.lang.IRecord :)

10:30 bbloom: stuartsierra: makes sense

10:30 stuartsierra: We need words to differentiate between 'documentation of how it works NOW' versus 'documentation of the API I am promising to adhere to in the future'.

10:30 Ember-: and I was too late, bbloom was faster

10:31 (needed to check with repl before my answer)

10:32 bbloom: Ember-: i did check in the repl ;-)

10:32 Ember-: hehe

10:32 I wonder if clojurebot will accept this:

10:32 ,(do (defrecord Rec [x]) (instance? clojure.lang.IRecord (Rec. "hi")))

10:32 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

10:32 Ember-: no, it doesn't

10:32 which does make sense

10:37 danielgl_: stuartsierra: *coming soon* <--- ?

10:37 stuartsierra: danielgl_: ?

10:38 bbloom: stuartsierra: i think he is referring to your comment about differentiating documentation of spec vs impl

10:38 danielgl_: stuartsierra: a way to differentiate between the now and the later

10:38 bbloom: stuartsierra: either way, "Alpha" does not appear to be a robust spec mechanism in doc strings:

10:38 (doc add-watch)

10:38 clojurebot: "([reference key fn]); Alpha - subject to change. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Whenever the reference's state might have been changed, any registered watches will have their functions called. The watch fn will be called synchronously, on the agent's thread if an agent, before any pending sends if agent

10:38 bbloom: weee alpha!

10:39 stuartsierra: bbloom: Tell me about it.

10:39 bbloom: "Implementation Details -- Subject To Change"

10:39 boom.

10:39 :-)

10:43 katratxo: hi all, one newbie question, i need an String[] for java interop, how can i get it from a vector? (.toArray ["one" "two"]) returns an Object[]

10:44 arrdem: ,(doc make-array)

10:44 clojurebot: "([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."

10:44 nDuff: kategeek: (into-array String ["one" "two"])

10:44 katratxo: ha! thanks

10:48 asaleh: question: can I ask if some val implements a protocol?

10:48 bbloom: (doc satisfies?)

10:48 clojurebot: "([protocol x]); Returns true if x satisfies the protocol"

10:49 asaleh: bbloom, thanks!

11:34 naeg: is there some value representing infinity in clojure? or just the max. value of int64?

11:34 gfredericks: depends on what numeric types you're using

11:35 bbloom: naeg: for integers, use Integer/MAX_VALUE or Long/MAX_VALUE

11:35 naeg: for floats and doubles, there are standard floating point infinity values

11:36 you can also use keywords as sentinel values, if that is useful for your needs

11:36 naeg: just found out there seems to be Infinity too, like (> Infinity Integer/MAX_VALUE)

11:37 gfredericks: ,Infinity

11:37 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: Infinity in this context, compiling:(NO_SOURCE_PATH:0:0)>

11:37 gfredericks: &Infinity

11:37 lazybot: java.lang.RuntimeException: Unable to resolve symbol: Infinity in this context

11:37 gfredericks: o_O

11:37 bbloom: i dont think that exists

11:38 gfredericks: ,(> Double/POSITIVE_INFINITY Integer/MAX_VALUE)

11:38 clojurebot: true

11:38 naeg: woot, worked for me inside lighttable

11:38 bbloom: naeg: ah, clojurescript

11:39 different thing :-P

11:39 naeg: I see. gotta use Double/POSITIVE_INFINITY then

11:39 gfredericks: ,(- Double/POSITIVE_INFINITY)

11:39 clojurebot: -Infinity

11:39 gfredericks: ,Double/POSITIVE_INFINITY

11:39 clojurebot: Infinity

11:39 bbloom: javascript only has double percision floating points

11:40 gfredericks: yeah, that's just toString basically :-)

11:40 although, I think that Infinity and -Infinity should probably be added to clojure (and maybe EDN) for cross-plat support

11:40 gfredericks: that doesn't sound too unreasonable

11:40 does EDN have a way to represent it currently?

11:41 I assume Double/POSITIVE_INFINITY doesn't mean anything

11:41 &clojure.edn/read-string

11:41 lazybot: java.lang.ClassNotFoundException: clojure.edn

11:41 gfredericks: &(require 'clojure.edn)

11:41 lazybot: java.io.FileNotFoundException: Could not locate clojure/edn__init.class or clojure/edn.clj on classpath:

11:41 clgv: ,(pr-str Double/POSITIVE_INFINITY)

11:41 clojurebot: "Infinity"

11:41 clgv: ,(binding [*print-dup* true] (pr-str Double/POSITIVE_INFINITY))

11:41 clojurebot: "Infinity"

11:41 clgv: well thats buggy

11:42 gfredericks: yeah edn/read-string reads Double/POSITIVE_INFINITY as a symbol

11:43 TimMc: As it well should.

11:45 gfredericks: does the IEEE spec say anything about string representations of the numbers?

11:45 ,9e1000

11:45 clojurebot: Infinity

11:46 gfredericks: ,-9e1000

11:46 clojurebot: -Infinity

11:46 gfredericks: well I guess that's one way to encode it

11:46 bbloom: yeeeesh

11:47 gfredericks: better than nothing? is there any other way?

11:47 TimMc: niiiice

11:47 trptcolin: http://dev.clojure.org/jira/browse/CLJ-1074

11:47 bbloom: ,(Double/parseDouble "Infinity")

11:47 clojurebot: Infinity

11:47 bbloom: (Double/parseDouble "Inf")

11:48 gfredericks: bbloom: in edn I mean

11:48 bbloom: gfredericks: i was trying to answer the question of standard notation

11:48 gfredericks: ah

11:49 juhu_chapa: Hi all! Is there a function like 'into' that does (into {} [[:x 1] [:x 2]]) -> {:x [1 2]}

11:49 mabes: juhu_chapa: merge-with

11:50 gfredericks: ,(merge-with into (for [[a b] [[:x 1] [:x 2]] [a [b]]))

11:50 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>

11:50 gfredericks: ,(merge-with into (for [[a b] [[:x 1] [:x 2]]] [a [b]]))

11:50 clojurebot: ([:x [1]] [:x [2]])

11:50 gfredericks: ,(merge-with into (for [[a b] [[:x 1] [:x 2]]] {a [b]}))

11:50 clojurebot: ({:x [1]} {:x [2]})

11:50 gfredericks: ,(apply merge-with into (for [[a b] [[:x 1] [:x 2]]] {a [b]}))

11:50 clojurebot: {:x [1 2]}

11:51 bbloom: neat. i forget that into is a fn and not a macro for some odd reason

11:57 juhu_chapa: mabes: :D thank you!

12:04 gfredericks: thank you!

12:04 gfredericks: for executable jars, you generally need a main namespace and a :gen-class. But that means that namespace gets AOT'd as well as everything it depends on?

12:04 i.e., inevitably the entire project is AOT'd? am I missing something?

12:08 hiredman: unless you use require and resolve to do runtime code loading

12:09 asaleh: question: is there a way to improve precondition errors?

12:11 cemerick: gfredericks: I saw a project once that provides a shim Java class with a main(String[]) that loads a file at a fixed location on the classpath. Seemed like a sane way to avoid the AOT business.

12:11 I can't remember its name now, but it'd be quite simple to replicate.

12:12 trptcolin: i do that for reply

12:13 https://github.com/trptcolin/reply/blob/master/src/java/reply/ReplyMain.java

12:13 clgv: gfredericks, cemerick: lein-otf

12:14 cemerick: clgv: oh, that's even more clever

12:15 TimMc: It used to be all-Clojure. I don't remember why it has a Java shim now.

12:18 technomancy: you can also piggyback off the fact that clojure.main is AOTed and accepts a -m arg

12:22 gfredericks: trptcolin: this could be done in clojure, right?

12:24 TimMc: hyPiRion: WTF, how is http://dev.clojure.org/jira/browse/CLJ-1179 marked as "Declined"? Did you get a reason?

12:25 * gfredericks expects it is some swearjure-enhancing patch

12:25 rasmusto: gfredericks: haha

12:25 trptcolin: gfredericks: yeah, same idea but using require/resolve in the -main like hiredman says. i should probably do that; that would be better

12:26 gfredericks: TimMc: hyPiRion: I'm trying to figure out if you could argue that no-arg distinct? is a meaningless as no-arg -

12:26 TimMc: &#{"hello" "goodbye" do} ;; That's *awesome*! http://dev.clojure.org/jira/browse/CLJ-1184

12:26 lazybot: ⇒ "hello"

12:26 TimMc: gfredericks: No, it's perfectly meaningful.

12:26 unlike -

12:27 gfredericks: certainly under the "no duplicates" interpretation

12:27 is that the only way to look at it?

12:27 TimMc: gfredericks: You can also use a set of invariants like "if (list* a xs) is distinct, then xs is as well."

12:28 and "if x is in a distinct collection xs, then (list* x xs) is not distinct"

12:28 gfredericks: yeah; seems to make sense

12:29 TimMc: If you use invariants like those, you end up needing to define a base case... which the empty collection serves as nicely.

12:37 cemerick: dakrone: The note about trailing periods in the clojure-opennlp readme should be at the top. I was convinced the whole thing was a lost cause until I saw that, added periods to my play data, and found joy. :-)

12:39 TimMc: hyPiRion: That definitely explains it.

12:42 hyPiRion: yup. Life is hard

12:44 TimMc: hyPiRion: I love that that tweet is on a background of swearjure.

12:44 Just got that.

12:46 hyPiRion: heh

12:48 TimMc: &(let [distinct?* (comp (partial (fnil apply :_ [:_]) distinct?) seq)] (map distinct?* [[] [1 2] [2 2]]))

12:48 lazybot: ⇒ (true true false)

12:49 TimMc: Is this what you want, rhickey? Is this really what you want?

12:53 dchandna: Hi. I have a question regarding the 'map' function.

12:53 ivaraasen: hyPiRion: the other night I started playing around with a generalisation of swearjure called trønderjure. it allows for the inclusion of æ, e, i, a, and å

12:53 pbuckley: I am getting errors with duplicate vars for libs that I want to use in my ns - but it seems like I should be able to have duplicate "namespaced" var names if I use :as, no?

12:54 (ns myproj.core (:refer-clojure :exclude [read read-string replace reverse get]) (:use [clojure.data.json :as json :exclude [pprint write read]] [clj-http.client :as client] [clj-http.cookies :as cookies] [clojure.edn :as edn] [clojure.string :as s]))

12:54 dchandna: (map [8 7 6 5 4 3 2 1] [7 6 5 4])

12:54 pbuckley: I'm thinking I'm dumb and there is a better way to setup my ns, so I could for example use edn/read-string and json/read-string in the same ns?

12:54 trptcolin: pbuckley: use require

12:55 dchandna: and it returns (1 2 3 4). I am unable to wrap my brain around this. Can someone help?

12:55 pbuckley: trptcolin: thanks, I'll try that instead of use

12:56 hyPiRion: ivaraasen: hah

12:56 ivaraasen: dchandna: vectors, when called with a number as an argument, returns the element at that index

12:57 TimMc: ,#{(println "of") do (do :z/h283r (println "order")) (do :b121 (println "out"))}

12:57 clojurebot: out\nof\norder\n

12:57 dchandna: oh ok. so something like ([1 2 3 4 5] 1) would return 2

12:57 thanks ivaraasen

12:58 TimMc: hyPiRion: ^ New Clojure "art form" -- build programs out of do and #{} by cracking hashes.

12:58 hyPiRion: TimMc: what, how is do working inside there?

12:58 technomancy: bespoke clojure programs that only work on a given version of clojure

12:59 TimMc: hyPiRion: http://dev.clojure.org/jira/browse/CLJ-1184

12:59 hyPiRion: ,((-> [$ !] #(* $ !)) 2 3)

12:59 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: $ in this context, compiling:(NO_SOURCE_PATH:0:0)>

12:59 hyPiRion: hm, what did I forget there

12:59 TimMc: hyPiRion: I was sad that I could inject an entire fn arity into #() via -> -- the problem is the trailing arg vector.

13:00 &(macroexpand '(-> ([x y] (+ x y)) #()))

13:00 lazybot: ⇒ (fn* ([x y] (+ x y)) [] ())

13:00 hyPiRion: yeah, I know, it's sad

13:00 I've tried out that as well, but got no way of doing closures

13:00 gfredericks: ,[do 1 2]

13:00 clojurebot: 2

13:02 TimMc: &'(#{do *} 5 6)

13:02 lazybot: ⇒ (#{* do} 5 6)

13:03 TimMc: &'(#{do (identity *)} 5 6)

13:03 lazybot: ⇒ (#{do (identity *)} 5 6)

13:03 TimMc: &(#{do (identity *)} 5 6)

13:03 lazybot: java.lang.RuntimeException: Unable to resolve symbol: do in this context

13:03 TimMc: Blah, sorry -- wrong window.

13:06 callen: ah motherfucker

13:06 fucking fucker heroku fuck

13:07 ppppaul: what is the simplest way to turn something into a vector, and if it's already a vector, keep it the way it is

13:07 ticking: ppppaul: (apply vector …)

13:08 TimMc: vec

13:08 ticking: better ^

13:08 TimMc: ppppaul: vec will give you back a new vector, by the way

13:09 ppppaul: ticking, thanks. that's what i came to as well

13:09 ,(doc vec)

13:09 clojurebot: "([coll]); Creates a new vector containing the contents of coll. Java arrays will be aliased and should not be modified."

13:09 hyPiRion: the simplest way is obviously `[~@foo]

13:09 ppppaul: ^_^

13:10 hyPiRion: ,[`[~@(list 1 2 3)] `[~@[:a :b :c]]]

13:10 clojurebot: [[1 2 3] [:a :b :c]]

13:12 ppppaul: ,(->> "17592186045423" (apply vector))

13:12 clojurebot: [\1 \7 \5 \9 \2 ...]

13:13 ppppaul: ,(->> "17592186045423" (apply vec))

13:13 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (14) passed to: core$vec>

13:13 gfredericks: ,[if 1 2 3]

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

13:14 ppppaul: i don't want the string to get seqed

13:14 i would like the vector to look like ["17592186045423"]

13:14 gfredericks: do you always have just a string?

13:14 ppppaul: sometimes i have an array of strings

13:14 gfredericks: and you want to do something different depending on which it is

13:15 you could say (if (string? x) [x] (vec x))

13:15 dakrone: cemerick: duly noted, I've moved it up to near the top

13:15 ppppaul: i want to keep the array as is, or i want to turn the single string into an array of 1 string

13:16 well, guess i'm throwing in some conditions.... i was just curious if there was some other way to do this in clojure

13:21 dchandna: ppppaul: How about this: (vec (cons "1234554456" [])).   Disclaimer: I am a Clojure newbie :)

13:24 Foxboron: ppppaul: conj?

13:25 (conj [] "clojure")

13:25 I am not really sure what you mean by "turn" tbh.

13:27 jjttjj: anyone know why I might be getting a "java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal" error out of the box when I try to use the latest stable clj-webdriver?

13:27

13:43 lynaghk: dnolen: do you know what the story is with ClojureScript's (undefined?) macro?

13:43 cyff: is it possible to run clojurescript on node.js without using clojure?

13:43 lynaghk: dnolen: it emits (void 0 === x), but that throws a reference error in Chrome if x is undefined. Any reason it's not typeof x == "undefined"?

13:44 noncom: is it possible to link 2 or more terminals to a clojure repl?

13:44 lynaghk: cyff: you can run the emitted JavaScript from ClojureScript, sure. If you're talking about avoiding the JVM entirely, I think a few people are working on ClojureScript-in-ClojureScript

13:44 technomancy: noncom: sure; `lein repl` in one and `lein repl :connect $PORT` in the other

13:44 cyff: lynaghk: you know the project?

13:45 the name of it

13:45 lynaghk: cyff: nah, not offhand but just google/github around and you'll find it

13:45 cyff: https://github.com/kanaka/clojurescript

13:45 cyff: doesn't seem to updated

13:46 lynaghk: cyff: there may be others

13:46 callen: lynaghk: void 0 is the standard way to check for undefined.

13:46 noncom: technomancy: very good! thank you!

13:47 lynaghk: callen: yeah, but you'll still get a reference error if you try to refer to a var that's not defined in the scope.

13:48 callen: my exact use case is a library that extends ClojureScript protocols to JavaScript things; I'd like to extend protocols to jQuery if it's available

13:48 cmajor7: compojure, is there a way to route URNs. e.g. it comes is as "context/bank:dept:account-number:87632498763" (GET "/bank:dept:account-number:number"). The way Compojure (clout) matches it is not as a whole string "bank:dept:account-number:number", but as different variables (since it overloads ':' to recognize vars). regex can be used to match the "number", but the matching still fails (e.g. will match other "aaa:bbb:ccc")

13:48 lynaghk: callen: but (when-not (undefined? js/jQuery)) won't cut it because that throws a reference error when jQuery isn't defined.

13:48 callen: lynaghk: write your own macro?

13:49 this is a lot of why I can't use CLJS right now. Too much impedance mismatch with the native client language. That along with sourcemaps. Ehgk.

13:49 lynaghk: callen: thought I'd ask David first about the cljs.core/undefined? behavior =)

13:49 callen: lynaghk: file an issue on the github to rattle cages more effectively.

13:49 lynaghk: callen: this has nothing to do with ClojureScript, the problem is with the JavaScript it's emitting

13:50 callen: I'd call that an act of sophistry.

13:50 lynaghk: callen: I troll dnolen enough in person

13:50 callen: then troll him in person.

13:50 Seeing the pain with full CLJ/CLJS apps, I can see why node/meteor people run screaming.

13:53 dnolen: callen: lynaghk: it's come up before, perhaps we could provide a resolve macro which can be used for this purpose.

13:54 lynaghk: dnolen: is the typeof check slow or otherwise unidiomatic JS?

13:54 dnolen: I'm not sure what that's not being used. Or typeof x === void 0

13:54 dnolen: lynaghk: no that sounds like reasonable approach to me, to use the typeof operator

13:55 lynaghk: dnolen: you want a patch?

13:55 dnolen: lynaghk: the reasoned undefined works the way it does is because it's function. we probably want something special for this particular case that JS people use typeof for.

13:56 lynaghk: dnolen: it's implemented as a macro

13:57 dnolen: lynaghk: that just for inlining

13:57 lynaghk: it's proper function

13:57 octagon: hello! i would like to extend clojure.lang.IFn, the goal being to achieve support for variadic protocols which i need. is this a really bad idea? does anyone here know what would be involved, more or less?

13:58 dnolen: octagon: if you want variadic protocol behavior w/o a lot of work - it's simpler to put a real function in front of it which will handle the variadic bit

13:59 lynaghk: dnolen: I don't follow.

13:59 dnolen: lynaghk: undefined? is a function

13:59 lynaghk: it's not a macro

13:59 lynaghk: undefined? checks for the undefined value

14:00 octagon: dnolen: that doesn't work because i need to have a record type that implements IFn with variadic parameters

14:00 dnolen: lynaghk: for the typeof global case we probably want something else to handle that

14:01 lynaghk: dnolen: hmm, I have no idea what's going on here. it looks core.cljs's undefined? just proxies to the core.clj's undefined? macro.

14:02 dnolen: octagon: if you're going to implement IFn I don't really see how you can avoid implementing every arity. so perhaps a macro.

14:02 lynaghk: and it's not different than + in that regard.

14:02 octagon: dnolen: thank you for supporting variadic protocols in cljs btw. seriously.

14:03 konr``: in cljs, is there a function to turn a js object into a map?

14:03 dnolen: lynaghk: macros in ClojureScript can serve a different purpose than Clojure - we can use macros for inlining.

14:03 octagon: there's no support for variadic protocols in CLJS - if it works it's an accident and not something you can depend on w/o some larger discussion.

14:04 octagon: IFn is a gnarly case where inheritance actually seems pretty useful.

14:04 octagon: dnolen: please keep it in there. it's important.

14:04 dnolen: octagon: don't depend on it.

14:05 lynaghk: dnolen: sure. I'm still don't quite see what the issue would be with adding a "typeof" in the definition of core.clj undefined?

14:05 octagon: dnolen: the only means of combination there is in Lisp is function application

14:05 dnolen: this means that semantics is defined by IFn

14:05 dnolen: that's really important and deep i think

14:06 dnolen: octagon: I'm not going to have a larger discussion about IFn, if you think it's important bring it up on the dev list, I'll chime in and we'll see what the powers that be think.

14:07 lynaghk: that won't work

14:07 lynaghk: undefined? is a *function*

14:07 (map undefined? [js/jQuery])

14:07 will blow up, even if you add typeof to the macro in core.clj

14:08 lynaghk: dnolen: ahhhh, got it.

14:09 dnolen: need to wake up a bit over here.

14:09 cyff: could someone who is good at clojure help him out: https://github.com/ajaxorg/ace/issues/1372#issuecomment-16461385

14:10 and regexp

14:11 dnolen: lynaghk: feel free to open up a ticket for a special undefined? macro, if you have a good idea for a name that'd be nice.

14:12 lynaghk: dnolen: objections to converting the existing one into a macro? It's not being used as a value anywhere in core.cljs

14:13 dnolen: I just suspect that's what people will naturally reach for (especially if they're coming from JS)---more people will run into the reference error problem than the cannot-take-value-of-a-macro problem.

14:13 dnolen: but yeah, I'll open up a ticket.

14:14 dnolen: lynaghk: hmm, that'll break things. The only reason we didn't defer to goog.isUndefined is because we can tag undefined? as being a boolean returning function.

14:14 patchwork: The cannot-take-a-value-of-a-macro problem has driven me to never use macros

14:14 dnolen: lynaghk: I'd prefer a different name at this point I think.

14:19 naeg: is there something like a (max a b) supporting nils? e.g. (max nil 0) => 0

14:20 noidi: naeg, http://clojuredocs.org/clojure_core/clojure.core/fnil

14:20 naeg: guess I can use (or nil 0) for that...

14:20 noidi: ,((fnil max 0 0) nil 8)

14:20 clojurebot: 8

14:21 noidi: ,((fnil max 0 0) 3 nil)

14:21 clojurebot: 3

14:21 naeg: noidi: how about using (or) instead?

14:21 it's actually a (max (f) 0), where f returns a number or nil. so I guess (or (f) 0) does the same?

14:22 ieure: Hm, I thought contains? worked for strings, but it seems like it doesn't.

14:22 Was this a 1.5.x change?

14:22 TimMc: ieure: contains? would never have worked on strings

14:23 ~contains

14:23 clojurebot: contains? checks whether an indexed collection (set, map, vector) contains an object as a key. to search a sequence for a particular object, use the `some` function, which accepts a predicate. if you want to only match a certain object, you can use a set as the predicate: for example, (some #{5} (range)) finds the first occurrence of 5

14:23 stuartsierra: ieure: `contains?` only works on keyed collections, but prior to Clojure 1.5 it would silently return nil when called on an unsupported type.

14:23 TimMc: oho

14:23 noidi: naeg, yes, that would work

14:23 ieure: stuartsierra, I see that ticket, but I have this unit test code which works in 1.4 and breaks in 1.5: (is true (contains? h "Available commands"))

14:24 Ah; but that should have been (is (= ...))

14:24 I see.

14:24 Or (is (contains? ...))

14:24 stuartsierra: ieure: And your `h` must be a set or a map.

14:25 ieure: stuartsierra, Got it.

14:25 Would be nice if there was a clojure.string/contains? method.

14:26 stuartsierra: ieure: That's just (.contains string substring)

14:26 Luyt_: Is there some clojure-specific pastebin somewhere which will also execute the code? (It's not mentioned in topic)

14:27 ieure: stuartsierra, Sure, and (subs) is just (.substring string i)

14:28 stuartsierra: Can't explain that one. ;)

14:29 nDuff: Luyt_: ideone.com supports Clojure, among many other languages.

14:29 trptcolin: ,(map resolve '[every? not-every? any? not-any?])

14:29 clojurebot: (#'clojure.core/every? #'clojure.core/not-every? nil #'clojure.core/not-any?)

14:30 trptcolin: o_O

14:30 Raynes: Evaluation is still a planned feature of refheap.

14:32 stuartsierra: trptcolin: `some` can fulfill the role of `any?`, but it's not a boolean predicate.

14:32 trptcolin: sure. (comp boolean some)

14:33 technomancy: you could say the same about not-any? as (comp not some)

14:33 trptcolin: and i know that discussion has been rehashed dozens of times

14:33 stuartsierra: (comp not some) is actually the definition of `not-any?`

14:34 technomancy: heh; nice

14:34 trptcolin: i just found that list of namings illustrative

14:34 stuartsierra: I tend to forget that `not-any?` exists.

14:35 technomancy: most of these discussions boil down to "these were written a long time ago, before the guidelines were solidified"

14:35 stuartsierra: yep

14:36 Luyt_: http://ideone.com/izBszw I'm trying to destructure a vector and a map in a function call, but I do something wrong and I can't see what. The destructuring in the let bindings, however, do work OK.

14:36 trptcolin: stuartsierra: me too, just ran across it in auto-complete

14:36 technomancy: (which makes me thankful that Clojure stayed small early on)

14:38 noidi: Luyt_, you have a def instead of a defn

14:39 konr``: shouldn't `js->clj` work for all objects? A map created from applying it to a goog.events.BrowserEvent doesn't respond to regular seq functions such as `count` with the error "Uncaught Error: No protocol method ISeqable.-seq defined for type object: [object Object]", although I can create a map from, say, `(-> "{...}" js* js->clj)`

14:40 Luyt_: noidi: Ah! Thanks

14:42 noidi: Now it works. http://ideone.com/9ciD20 I also had to add extra [ ] to the defn.

14:44 noidi: great

14:45 Luyt_: stuartsierra: Are you the author of the book I have here: Practicl Clojure ?

14:46 stuartsierra: Luyt_: Yes, the Apress book, which I wrote with Luke VanderHart.

14:47 Luyt_: Cool. I bought it a while ago, but only now I get around to stuff with clojure.

14:56 amalloy: naeg: using 0 doesn't work too well if (f) returns -100

14:56 you probably want (apply max (remove nil? coll)) or similar

14:57 er, i guess i meant noidi

14:57 TimMc: &(max)

14:57 lazybot: clojure.lang.ArityException: Wrong number of args (0) passed to: core$max

14:58 trptcolin: lol, missing zero-arg arity strikes again!

14:58 err, zero-arity?

14:58 amalloy: well, it's not exactly missing

14:58 TimMc: I can't decide whether max should have a nullary invocation.

14:58 amalloy: there's simply no good way to define it

14:58 TimMc: no way

14:58 TimMc: Double/NEGATIVE_INFINITY

14:58 pmonks: nil?

14:58 clojurebot: ⟹ "Returns the metadata of obj, returns nil if there is no metadata."

14:59 amalloy: gross as half a worm in your apple, TimMc

14:59 TimMc: haha

14:59 It wouldn't change the behavior of max.

15:00 amalloy: obviously it would: calling it with zero args would behave differently

15:00 TimMc: meh

15:01 If someone was relying on that throwing, they kind of deserve code breakage.

15:02 trptcolin: somebody could rely on getting ints back

15:02 err, longs

15:02 amalloy: i don't really agree. anyone who relies on (max) giving back NEGATIVE_INFINITY, though...

16:28 SegFaultAX: ,(into {} '((:a "foo")))

16:28 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry>

16:28 technomancy: jweiss: mapentries are a subclass of vectors

16:28 SegFaultAX: That

16:28 It has nothing to do with array-map, though.

16:28 technomancy: the error message on the list one is really weird though

16:28 jweiss: yeah, i didn't mean to imply it was array-map, just happened to be using that

16:29 technomancy: I'd expect it to be a list that can't be cast

16:29 jweiss: yeah, why is it trying to cast Long to MapEntry

16:32 SegFaultAX: This is why: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/APersistentMap.java#L40

16:33 If it's not a map entry or a vector, it tries to turn each element into a map entry

16:33 technomancy: why does that sound so familiar

16:33 oh yeah http://brehaut.net/blog/2013/duck_wrapping

16:33 gfredericks: (inc brehaut)

16:33 lazybot: ⇒ 12

16:33 SegFaultAX: I don't know, but that's really strange behavior.

16:34 gfredericks: it's not actually duck-wrapping though

16:34 SegFaultAX: Haha, that's an awesome name. Duck wrapping.

16:34 gfredericks: duck wrapping would be something dumb like "if it's not a map entry, make a map entry where that's the key and the value is nil"

16:35 SegFaultAX: gfredericks: Yea that's not quite what's happening here.

16:35 gfredericks: The list '(1 2) doesn't become {(1 2) nil} in the case above.

16:36 gfredericks: thank goodness

16:37 SegFaultAX: gfredericks: Not that the /actual/ behavior is any more sensical.

16:37 jweiss: ok so this is basically into trying to do its best with the given input, what's an alternative, (apply array-map (interpose ...))?

16:37 SegFaultAX: I mean, it should error, but not the way it's erroring here.

16:38 ,(into {} (map vec '((1 2) (3 4))))

16:38 clojurebot: {1 2, 3 4}

16:38 gfredericks: you're just saying the error message should be better, right?

16:38 jweiss: (oh i guess it wasn't clear from my example that i was trying to zipmap two lists, but keep the order

16:38 rbxbx: duck wrapping is a fairly common pattern in ruby :X

16:38 SegFaultAX: gfredericks: That it shouldn't be erroring like this at all.

16:38 rbxbx: aka probably a bad idea ;D

16:38 gfredericks: SegFaultAX: I must be missing the point

16:39 SegFaultAX: gfredericks: It should be a different class of error entir16:50 -!- machuga is now known as machuga|away

16:50 gfredericks: it's been discussed before. I'm sure ambrose had to deal with it.

16:50 ,(doc conj)

16:50 clojurebot: "([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."

16:51 SegFaultAX: gfredericks: You'll note that conj just delegates to cons

16:51 https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L559

16:52 gfredericks: SegFaultAX: yep

16:52 but the docs should go on the var

17:02 TimMc: OK, here's my splicing version of prewalk-replace: https://gist.github.com/timmc/5399621 I feel like there could be some way to generalize, though.

17:03 Tekhne: I'm just learning clojure. Where can I find documentation on "cond" that exlains ":else"? I can guess well enough, but I'd like to read docs.

17:03 TimMc: Tekhne: :else is just a convention -- it's any truthy value

17:04 Tekhne: TimMc: ah, okay. Thanks.

17:04 SegFaultAX: Tekhne: Do you know how cond works without and :else branch?

17:04 Tekhne: TimMc: kind of a self-documenting thing. I get it.

17:04 nightfly__: SegFaultAX: it just runs the conditions that are matched

17:05 SegFaultAX: nightfly__: Redirect to Tekhne, he's the one asking.

17:05 Tekhne: SegFaultAX: Yea, and now it makes sense. I was looking at other tutorials on stuff like destructuring function argument vectors and ":as" and that made me think that ":else" was something special. Now I see that it's not.

17:06 SegFaultAX: Tekhne: Cool!

17:10 gfredericks: The only obvious use case I can think of for handling arbitrary seqs in cons is for something like

17:11 ,(into {} (.entrySet {:a 1 :b 2 :c 3}))

17:11 TimMc: :or-I-guess-maybe

17:11 clojurebot: {:a 1, :c 3, :b 2}

17:12 SegFaultAX: gfredericks: I can't really think of another common case where you would have an iterable of map entries hanging about. :)

17:12 TimMc: Seems like a reasonable alternative to :else

17:12 :or-if-you-really-must

17:12 nightfly__: :fuck-it-do-this-instead

17:13 SegFaultAX: For the lisper on the ragged edge.

17:14 Also, why doesn't APeristentMap.entrySet return a normal persistent set instead of an anonymous abstract set?

17:27 amalloy: SegFaultAX: it would be expensive to create, for no particular benefit

17:27 and, of course, it *does* return a "normal" IPersistentSet: it just uses the underlying map as its backing store instead of using something else

17:28 oh, entrySet? i guess it's returning a java.util.Map, not an IPersistentSet, but the same thing applies

17:30 SegFaultAX: amalloy: And I suppose how often do you really need to access the entrySet directly in Clojure. More often you can just seq over the map.

17:41 rasmusto: tpope: is it possible to evaluate a clojure expression with 'cpp' from a :Gdiff/:Gedit window? I'm curious what it would take to figure out what namespace the old git file would have been for

17:44 SegFaultAX: rasmusto: With fireplace?

17:46 pocho: How do you use cljsc/build with multiple .cljs files? If I build seperately, it complains about not having goog.provide().

17:57 rasmusto: SegFaultAX: yes

17:58 SegFaultAX: when I try it, it asks me to install classpath.vim or :Connect to a repl

20:09 hugod: callen: what were you trying to do with clj-ssh?

21:09 devn: Good evening

21:12 * ivan wonders if anyone has a hack that prints all of the methods matching a method name when you do (.method obj) and get an IllegalArgumentException

21:13 technomancy: ivan: you could probably do that with an nrepl middleware

21:14 gfredericks: is there a way to get nrepl to look at the :repl-options in the project.clj?

21:15 amalloy: technomancy: really? i guess i don't know how nrepl middlewares work, but that sounds like witchcraft

21:16 technomancy: amalloy: you can do anything with middleware

21:17 it would only work on direct .method calls though

21:17 unless you do some insane rewriting/decorating thing a la guzheng

21:18 makes you pine for CL conditions though

21:18 ritz could probably do it actually =)

21:18 amalloy: right, i can believe it as a ritz thing

22:04 gfredericks: wow that data.json pretty printer is pretty bad

22:12 * gfredericks notices that cheshire can do it

22:12 ivan: can I eval some forms in a function at compile time, without sticking them in top-level def?

22:13 gfredericks: you can do whatever you want at compile-time, generally

22:13 * ivan remembers that #= probably does this

22:14 ivan: haha sublime text really doesn't like #=

22:14 yeah #= totally does not work for this Java method call

22:15 amalloy: ivan: you can write a macro that does the evaluation when it runs, or you can (let [pre-computed ...] (defn ...))

22:15 #= is 100% the wrong solution

22:15 ivan: oh, right, thanks, forgot I could put a let there

22:18 gfredericks: clojurebot: #= is 100% the wrong solution

22:18 clojurebot: Roger.

22:18 amalloy: (inc gfredericks)

22:18 lazybot: ⇒ 19

22:18 gfredericks: I need to start endorsing things by saying that they are "0% the wrong solution"

22:19 ivan: #=?

22:19 clojurebot: #= is 100% the wrong solution

22:20 gfredericks: clojurebot: clojure is 0% the wrong solution

22:20 clojurebot: You don't have to tell me twice.

22:20 langmartin: so...... I have a problem with getting blocking serialization working. I have a pretty complicated threaded app and a largish set of tests. the tests need to line up neatly if it all possible. any suggestions are welcome

22:20 tpope: rasmusto: shouldn't be that hard but I have yet to reason it out

22:21 langmartin: I currently have a java.util.concurrent.Semaphore and in the result procedure I (def a global variable) and then release the semaphore

22:21 this doesn't actually give me predictable values for the global

22:24 brehaut: langmartin: def?

22:24 langmartin: brehaut: yeah, I know

22:24 brehaut: langmartin: you should not be deffing things outside of your top level.

22:25 langmartin: the result handler gets called asynchronously from the perspective of the tests, and I need it to block, synchronous style

22:25 so that I can make sequential assertions

22:26 if it helps any, using an atom to carry the returned value doesn't seem to result in predictable values either, because I still have to deref it

22:26 brehaut: have you looked at promises?

22:26 langmartin: and deref seems to sometimes give me last run's answer even after I've released the lock

22:26 brehaut: I did have promises in there before, yeah

22:27 perhaps not in a neat pattern

22:29 all this stuff (including the def) is just in the handler I pass into the application from the tests; it's not actually part of the program itself

22:29 I just need the tests to block on each successive answer

22:29 amalloy: langmartin: yeah, promises or rewrite the whole thing to use lamina channels

22:29 langmartin: oof

22:29 that's ... unlikely in the short term

22:30 brehaut: i think that if you want broader help than 'have you tried X' you will need to put some code somewhere because nobody is going to try to diagnose your threaded apps problems via irc guessing

22:30 amalloy: you might be able to just rewrite the handler; it's not really clear to me what's going on

22:30 (inc brehaut)

22:30 lazybot: ⇒ 13

22:30 langmartin: sure

22:30 amalloy: although i do enjoy "throw stuff till it sticks" debugging

22:31 gfredericks: try adding more parens

22:31 langmartin: I'm not free to share the code, unfortunately (not yet anyway).

22:31 TimMc: I bet you just need a few more dosyncs.

22:32 (not actual advice)

22:33 gfredericks: TimMc: unable to resolve symbol: actual in this context

22:33 TimMc: langmartin: OK, is the general problem that you need to step the application through a series of I/O events and test the behavior?

22:34 langmartin: TimMc: exactly, and the application is multithreaded

22:34 TimMc: langmartin: I once wrote a thing called Lockstep.java that did something like that. Unfortunately, it was for a previous employer...

22:34 langmartin: ah

22:35 TimMc: Basically I had my handful of threads and a lock (or several?), and the threads took turns acquiring and releasing locks.

22:35 amalloy: gfredericks: usually it's "try removing some of the parens"

22:36 TimMc: It was pretty complicated to set up. :-/

22:37 langmartin: TimMc: that's basically where I'm have it now, and it does, mostly, work

22:38 I've probably missed something silly but def does not seem to be a reliable way to return the results even when the def statement is gaurded by the locks

22:41 amalloy: that's really what a promise is for, as far as i can tell

22:43 langmartin: amalloy: that's helpful. I may be able to cook up a more reasonable use of promises if I take another crack at it

22:48 hmmm no promise?

22:49 er, the procedure `promise?' thatis

22:52 brehaut: langmartin: that'd be pretty hard; promise is just a reification of IDeref and IBlockingDeref

22:53 langmartin: brehaut: 's cool, I'll just wrap it in my own deftype

22:54 brehaut: huh, i didnt realise that promises were callable, and thats all deliver does

22:54 Raynes: I promise that promises are callable brehaut.

22:54 technomancy: Raynes: `deliver` is my favourite horrible way to fake out 1-arity funcall

22:55 brehaut: technomancy: haha love it

22:55 technomancy: brehaut: I live on the wild side

22:59 l1x: hey guys

23:00 i am looking for a bitset/bitarray library in clojure, do you know any/do you use something like that what you would recommend?

23:08 langmartin: sorry to be so vague everyone, and thanks for the help.

23:09 brehaut: l1x: maybe https://github.com/rosejn/byte-spec ? never used it, but it turned up on clojuresphere and its used by overtone

23:11 oh, http://github.com/overtone/byte-spec looks newer

23:12 l1x: thanks!

23:17 amalloy: l1x: what about using a java bitset? iirc that's a thing

23:17 $google java bitset

23:17 lazybot: [BitSet (Java Platform SE 7 ) - Docs Oracle] http://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html

23:20 amalloy: it's mutable, but c'est la vie

23:21 l1x: amalloy: yeah i have seen that, thanks for pulling it up. i was wondering how is this working if you have most of the values in the bitset 0s and some1s

23:21 amalloy: *shrug* i'm sure it's just an int, or array of ints, under the hood

23:21 l1x: i see

23:23 amalloy: it's a long[], apparently

23:24 but it doesn't really matter: it does whatever it promises to do

23:36 l1x: :))

23:36 i was reading the redis article about unique counts

23:45 adu_: l1x: link?

23:45 l1x: adu_: http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps/

23:45 it is freakin' amazing

23:46 adu_: l1x: what is?

23:46 l1x: using bitset to count visitors for your website :)

23:48 (for that matter, having a bitset where your index is a userid(int) and the values are bits (in case your collected data is binary) is really efficient, and surprisingly small footprint, applying compression is easy too)

23:48 adu_: I can see some problems with that

23:50 like what happens when a new user is created? how does the bitmap know to be resized? what happens when a user is deleted? does the bitmap remain empty? what if someone hacks your captcha and creates a large number of users? does redis run out of memory?

23:51 but yes, it's on the edge of optimization

23:53 l1x: user is deleted -> you dont care, keep the user's id in the system

23:55 user is created -> add a new item to the bitset with a higher index than you had (it is not necessarily fix size, what happens when you add a new element to an array in any language?)

23:55 someone hacks -> it wont impact your system because you are counting the visitors, not the users created

23:57 adu: l1x: which are counted by user_id

Logging service provided by n01se.net