#clojure logs

2013-04-16

01:04tieTYTi have a list of booleans. How do I "or" the elements in the list?
01:06rhg135(apply or the-list)
01:06alandiperttieTYT: (some identity thingies) perhaps
01:06tieTYTrhg135: that's what I thought...
01:06alandipert(can't apply or, as it's a macro)
01:06rhg135i think
01:06rhg135ok
01:07tieTYTCompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/or, compiling:(fileorganizer\core.clj:31:26)
01:07rhg135(apply #(or %&) the-list)
01:07rhg135i mean
01:07rhg135idk
01:07alandipert(reduce #(or %1 %2) the-list) maybe
01:08rhg135yes ^
01:08tieTYTok
01:08tieTYTthx
01:08alandiperti'd go with the 'some identity' approach personally
01:09tieTYTwhats that?
01:09alandipert(some identity the-list)
01:09rhg135wow, fancy
01:11tieTYTthat's kind of cool
01:12tieTYTi'll do that, thanks
01:12mthvedtsome is one of my favorite clojure fns, it's surprising where/when it shows up
01:12mthvedts/shows/comes
01:13tieTYTthis is my first time using it
01:24patbrown:alandipert Dude, thanks for helping me learn some Clojure. I write some every day and I love it.
01:30alandipertpatbrown: np man happy hacking!
01:32patbrown: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.
02:01base698Anyone know how to read a bufferedreader and NOT use line-seq. I need a sequence of chars. All i can find is line-seq
02:03amalloybase698: look up the methods defined for bufferedreader and see if you can come up with something clever
02:10base698amallay: I just did passed the stream and called read. I just didn't want to do that if there was something built in.
02:10base698Thanks!
02:23noidibase698, 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
05:03yusupis anyone using clojure in production ?
05:05ordnungswidrigyusup: many do
05:06maleghastYeah, in a tiny way so far… There are those with much more "in prod" experience on here...
05:09yusupeveryting great?
05:09maleghastFor Sho!
05:09yusup*everything
05:10maleghastYou 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...
05:11yusupthanks maleghast
05:12maleghastHere 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
05:12ordnungswidrigWe should build a showcase site "clojure in production" to advertise clojure
05:12maleghastordnungswidrig: That's a great idea, no question.
05:13yusupthat will be awesome.
05:14ordnungswidrigshort description of project / application, used liberaries/stacks. team size, and free text testimonial
05:14ordnungswidrigand public rating to define importance of an entry
05:16ordnungswidrigany volunteers?
05:16ordnungswidrigbtw. there is http://dev.clojure.org/display/community/Clojure+Success+Stories
05:17winkordnungswidrig: there's not many links to click though
05:17winkI'd love another page of real websites for example
05:17yusupthat page is extremely slow.
05:18winkthat's at least one heap of projects you can actually try :D
05:18winkyusup: it's confluence :P
05:20Netfeedinfoq has great content in a shitty presenation
05:21jasonjcknNetfeed: have you tried horizontal button
05:21Netfeedhmm, no
05:24ordnungswidrigyou can also download infoq slides after registration.
05:24ordnungswidrigsometimes.
06:01bosieordnungswidrig: nice nick
06:03ordnungswidrigbosie: i tried to be subversive :-)
06:03bosieordnungswidrig: but but ... you are german
06:03bosie;)
06:07ordnungswidrig:-p
06:09john2xhow do I start a clojurescript repl with all the dependencies in my project.clj ready for loading? (`lein repl` but for clojurescript?)
06:19ambrosebsjohn2x: Try lein-cljsbuild https://github.com/emezeske/lein-cljsbuild
07:53nonubyWhat approach are clojurers using to handle error notification in request based apps (ring/compojure), hipchat?
07:55nonubyanyone got clojure logs as data video?
08:13ordnungswidrignonuby: what do you mean, "error notification"?
08:25mynomotononuby
09:07jjl`hi all. i have a question about clojurescript's support for legacy browsers. is there some documentation on how far back things are supported?
09:32stuartsierrajjl`: ClojureScript is mostly browser-agnostic.
09:33jjl`yes, but things like :keys, do they support old IE
09:33jjl`as object.keys() was added in ie9
09:33jjl`(part of KS1.6)
09:33jjl`JS1.6*
09:33jjl`when i'm writing javascript, i either have to use a library to settle the differences for me or write it differently
09:34stuartsierraClojureScript itself does not attempt to abstract over differences in JavaScript APIs.
09:34jjl`yes, but which version of javascript does it attempt to compile down to?
09:35stuartsierraThat I do not know.
09:35jjl`i suspect it requires 1.6, which means it's not a viable option. but it's not documented anywhere i can find
09:35ordnungswidrigit depend son what the google closure spits out
09:36bbloomjjl`: I'm not sure what you're talking about with Object.keys, that's not anywhere in the clojurescript source that i can tell
09:37jjl`where 'Object' is any instance object
09:37mpenetyeah clojurescript maps do not map 1:1 with js maps
09:37bbloomjjl`: are you referring to the clojure.core/keys function?
09:37mpenetand js-keys uses google closure to iterate over the maps to get the keys
09:37jjl`mpenet: aha. that's the useful bit
09:37mpenetmap entries*
09:38bbloomGoogle Closure abstracts over browsers
09:38mpenetso mostly browser agnostic as it's been said
09:38jjl`so i suppose what i'm looking at is google closure's browser support?
09:38mpenetyep
09:38bbloomjjl`: yes
09:39jjl`*sigh* there is of course no documentation on their support either
09:39bbloomjjl`: that's because it supports anything google supports, which is everything
09:39jjl`when google have been dropping support for old IE on their homepage?
09:39Ember-a long time ago
09:40jjl`sadly, i have a need to support ie8 as a hard limit and sometimes ie7
09:40Ember-google has supported officially only latest two major releases of each browser for a while now
09:40Ember-which rules out IE8
09:40jjl`*nod*
09:40mpenetjjl`: https://groups.google.com/d/msg/closure-library-discuss/cpHlaWAkFag/HzpCAD9ThIMJ
09:41mpenetseems safe, unless you are making a time machine
09:41jjl`hrm, that's from 2009
09:41jjl`and googling for 'ie9 clojurescript' turned up a few people complaining about poor ie9 support
09:42jjl`(also old, so hard to know what current status is)
09:42bbloomjjl`: 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
09:42bbloomor file a ticket
09:43jjl`okay, thanks
09:43mpenetI really doubt the core breaks on ie9 tbh, I think prismatic say they support ie8+ and they rely on cljs for their frontend
09:43bbloomcljs isn't coupled to the dom in any interesting way, so browser compat is relatively easy
09:44bbloomfor the most part, google closure totally alleviates that pain
10:04ordnungswidrigIf a type implements multiple interfaces and a protocol is implemented for multiple interfaces, which implementation is used?
10:05ordnungswidrigsay, I implement a protocol for ILookup and Sequential which implementation of the protocol would be used for a [] or a {}?
10:06ordnungswidrigok, I found it. "extend" say it's TBD :-)
10:09bbloomordnungswidrig: 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:10ordnungswidrigbbloom: I guest it boils down to map key order or like that.
10:12ordnungswidrigI remember a chart showing clojure datatypes and their implemented interfaces
10:13bbloom(source find-protocol-impl) ;; seems to be the definition
10:13bbloomin src/clj/clojure/core_deftype.clj
10:14stuartsierraordnungswidrig: 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:15stuartsierraAs a result, I generally recommend not to extend protocols to interfaces but only to concrete types.
10:16ordnungswidrigIn liberator we provide default reoresentations for maps, sequences etc. To do this a protocol is extended for the types.
10:17bbloomstuartsierra: yeah, a quick read of the code suggests that the behavior that occurs depends on the order that java.lang.Class.getInterfaces returns
10:17ordnungswidrigI thought of using MapEquivalence and Sequential
10:17bbloomstuartsierra: 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:18stuartsierraSo at least it's predictable. Just arbitrary.
10:18bbloomyeah
10:18bbloomit's also a weird arbitrary
10:18ordnungswidriglike tax law
10:18bbloomif you write class Foo extends Bar implements IFoo, IBar
10:18bbloomthen it seems like priority is left to right
10:18stuartsierraNot entirely - CL resolves multiple inheritance left-to-right based on declaration order.
10:19bbloomyeah, i guess that's consistent, but my intuition is that "mixins" override
10:19ordnungswidrigstuartsierra: IIRC you can even define the resolution order.
10:21bbloomjust checked. scala resolves traits right to left
10:22bblooma more careful reading shows that clojure reviews the chain of concrete inheritence first, THEN checks interfaces
10:23bbloomthen resolves interface type preferences with .isAssignableFrom
10:25bbloomseems like this ought to be documented :-P
10:25ordnungswidrigbbloom: noboy should rely on this :-)
10:25ordnungswidrigbbloom: I suggest reading about CLOS. It's that powerful that you don't want to use it.
10:27bbloomfair enough. i was just curious how protocols worked. mystery solved: trivial method cache :-)
10:28asalehquestion: is there a function to know if my var is a record?
10:29bbloomasaleh: (defn record? [x] (instance? clojure.lang.IRecord x))
10:29stuartsierrabbloom: Rich tends to regard docstrings as specification, so he won't commit to anything that he might want to change in the future.
10:29Ember-,(defrecord Rec [x]) (instance? clojure.lang.IRecord (Rec. "hi"))
10:29clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
10:30Ember-aww
10:30Ember-anyway, that way
10:30asalehbbloom, thanks, was looking for the clojure.lang.IRecord :)
10:30bbloomstuartsierra: makes sense
10:30stuartsierraWe 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:30Ember-and I was too late, bbloom was faster
10:31Ember-(needed to check with repl before my answer)
10:32bbloomEmber-: i did check in the repl ;-)
10:32Ember-hehe
10:32Ember-I wonder if clojurebot will accept this:
10:32Ember-,(do (defrecord Rec [x]) (instance? clojure.lang.IRecord (Rec. "hi")))
10:32clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
10:32Ember-no, it doesn't
10:32Ember-which does make sense
10:37danielgl_stuartsierra: *coming soon* <--- ?
10:37stuartsierradanielgl_: ?
10:38bbloomstuartsierra: i think he is referring to your comment about differentiating documentation of spec vs impl
10:38danielgl_stuartsierra: a way to differentiate between the now and the later
10:38bbloomstuartsierra: either way, "Alpha" does not appear to be a robust spec mechanism in doc strings:
10:38bbloom(doc add-watch)
10:38clojurebot"([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:38bbloomweee alpha!
10:39stuartsierrabbloom: Tell me about it.
10:39bbloom"Implementation Details -- Subject To Change"
10:39bbloomboom.
10:39bbloom:-)
10:43katratxohi 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:44arrdem,(doc make-array)
10:44clojurebot"([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:44nDuffkategeek: (into-array String ["one" "two"])
10:44katratxoha! thanks
10:48asalehquestion: can I ask if some val implements a protocol?
10:48bbloom(doc satisfies?)
10:48clojurebot"([protocol x]); Returns true if x satisfies the protocol"
10:49asalehbbloom, thanks!
11:34naegis there some value representing infinity in clojure? or just the max. value of int64?
11:34gfredericksdepends on what numeric types you're using
11:35bbloomnaeg: for integers, use Integer/MAX_VALUE or Long/MAX_VALUE
11:35bbloomnaeg: for floats and doubles, there are standard floating point infinity values
11:36bbloomyou can also use keywords as sentinel values, if that is useful for your needs
11:36naegjust found out there seems to be Infinity too, like (> Infinity Integer/MAX_VALUE)
11:37gfredericks,Infinity
11:37clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: Infinity in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:37gfredericks&Infinity
11:37lazybotjava.lang.RuntimeException: Unable to resolve symbol: Infinity in this context
11:37gfrederickso_O
11:37bbloomi dont think that exists
11:38gfredericks,(> Double/POSITIVE_INFINITY Integer/MAX_VALUE)
11:38clojurebottrue
11:38naegwoot, worked for me inside lighttable
11:38bbloomnaeg: ah, clojurescript
11:39bbloomdifferent thing :-P
11:39naegI see. gotta use Double/POSITIVE_INFINITY then
11:39gfredericks,(- Double/POSITIVE_INFINITY)
11:39clojurebot-Infinity
11:39gfredericks,Double/POSITIVE_INFINITY
11:39clojurebotInfinity
11:39bbloomjavascript only has double percision floating points
11:40bbloomgfredericks: yeah, that's just toString basically :-)
11:40bbloomalthough, I think that Infinity and -Infinity should probably be added to clojure (and maybe EDN) for cross-plat support
11:40gfredericksthat doesn't sound too unreasonable
11:40gfredericksdoes EDN have a way to represent it currently?
11:41gfredericksI assume Double/POSITIVE_INFINITY doesn't mean anything
11:41gfredericks&clojure.edn/read-string
11:41lazybotjava.lang.ClassNotFoundException: clojure.edn
11:41gfredericks&(require 'clojure.edn)
11:41lazybotjava.io.FileNotFoundException: Could not locate clojure/edn__init.class or clojure/edn.clj on classpath:
11:41clgv,(pr-str Double/POSITIVE_INFINITY)
11:41clojurebot"Infinity"
11:41clgv,(binding [*print-dup* true] (pr-str Double/POSITIVE_INFINITY))
11:41clojurebot"Infinity"
11:41clgvwell thats buggy
11:42gfredericksyeah edn/read-string reads Double/POSITIVE_INFINITY as a symbol
11:43TimMcAs it well should.
11:45gfredericksdoes the IEEE spec say anything about string representations of the numbers?
11:45gfredericks,9e1000
11:45clojurebotInfinity
11:46gfredericks,-9e1000
11:46clojurebot-Infinity
11:46gfrederickswell I guess that's one way to encode it
11:46bbloomyeeeesh
11:47gfredericksbetter than nothing? is there any other way?
11:47TimMcniiiice
11:47trptcolinhttp://dev.clojure.org/jira/browse/CLJ-1074
11:47bbloom,(Double/parseDouble "Infinity")
11:47clojurebotInfinity
11:47bbloom(Double/parseDouble "Inf")
11:48gfredericksbbloom: in edn I mean
11:48bbloomgfredericks: i was trying to answer the question of standard notation
11:48gfredericksah
11:49juhu_chapaHi all! Is there a function like 'into' that does (into {} [[:x 1] [:x 2]]) -> {:x [1 2]}
11:49mabesjuhu_chapa: merge-with
11:50gfredericks,(merge-with into (for [[a b] [[:x 1] [:x 2]] [a [b]]))
11:50clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
11:50gfredericks,(merge-with into (for [[a b] [[:x 1] [:x 2]]] [a [b]]))
11:50clojurebot([:x [1]] [:x [2]])
11:50gfredericks,(merge-with into (for [[a b] [[:x 1] [:x 2]]] {a [b]}))
11:50clojurebot({:x [1]} {:x [2]})
11:50gfredericks,(apply merge-with into (for [[a b] [[:x 1] [:x 2]]] {a [b]}))
11:50clojurebot{:x [1 2]}
11:51bbloomneat. i forget that into is a fn and not a macro for some odd reason
11:57juhu_chapamabes: :D thank you!
12:04juhu_chapagfredericks: thank you!
12:04gfredericksfor 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:04gfredericksi.e., inevitably the entire project is AOT'd? am I missing something?
12:08hiredmanunless you use require and resolve to do runtime code loading
12:09asalehquestion: is there a way to improve precondition errors?
12:11cemerickgfredericks: 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:11cemerickI can't remember its name now, but it'd be quite simple to replicate.
12:12trptcolini do that for reply
12:13trptcolinhttps://github.com/trptcolin/reply/blob/master/src/java/reply/ReplyMain.java
12:13clgvgfredericks, cemerick: lein-otf
12:14cemerickclgv: oh, that's even more clever
12:15TimMcIt used to be all-Clojure. I don't remember why it has a Java shim now.
12:18technomancyyou can also piggyback off the fact that clojure.main is AOTed and accepts a -m arg
12:22gfrederickstrptcolin: this could be done in clojure, right?
12:24TimMchyPiRion: WTF, how is http://dev.clojure.org/jira/browse/CLJ-1179 marked as "Declined"? Did you get a reason?
12:25rasmustogfredericks: haha
12:25trptcolingfredericks: yeah, same idea but using require/resolve in the -main like hiredman says. i should probably do that; that would be better
12:26gfredericksTimMc: hyPiRion: I'm trying to figure out if you could argue that no-arg distinct? is a meaningless as no-arg -
12:26TimMc&#{"hello" "goodbye" do} ;; That's *awesome*! http://dev.clojure.org/jira/browse/CLJ-1184
12:26lazybot⇒ "hello"
12:26TimMcgfredericks: No, it's perfectly meaningful.
12:26TimMcunlike -
12:27gfrederickscertainly under the "no duplicates" interpretation
12:27gfredericksis that the only way to look at it?
12:27TimMcgfredericks: You can also use a set of invariants like "if (list* a xs) is distinct, then xs is as well."
12:28TimMcand "if x is in a distinct collection xs, then (list* x xs) is not distinct"
12:28gfredericksyeah; seems to make sense
12:29TimMcIf you use invariants like those, you end up needing to define a base case... which the empty collection serves as nicely.
12:37cemerickdakrone: 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:39TimMchyPiRion: That definitely explains it.
12:42hyPiRionyup. Life is hard
12:44TimMchyPiRion: I love that that tweet is on a background of swearjure.
12:44TimMcJust got that.
12:46hyPiRionheh
12:48TimMc&(let [distinct?* (comp (partial (fnil apply :_ [:_]) distinct?) seq)] (map distinct?* [[] [1 2] [2 2]]))
12:48lazybot⇒ (true true false)
12:49TimMcIs this what you want, rhickey? Is this really what you want?
12:53dchandnaHi. I have a question regarding the 'map' function.
12:53ivaraasenhyPiRion: 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:53pbuckleyI 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:54pbuckley(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:54dchandna(map [8 7 6 5 4 3 2 1] [7 6 5 4])
12:54pbuckleyI'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:54trptcolinpbuckley: use require
12:55dchandnaand it returns (1 2 3 4). I am unable to wrap my brain around this. Can someone help?
12:55pbuckleytrptcolin: thanks, I'll try that instead of use
12:56hyPiRionivaraasen: hah
12:56ivaraasendchandna: vectors, when called with a number as an argument, returns the element at that index
12:57TimMc,#{(println "of") do (do :z/h283r (println "order")) (do :b121 (println "out"))}
12:57clojurebotout\nof\norder\n
12:57dchandnaoh ok. so something like ([1 2 3 4 5] 1) would return 2
12:57dchandnathanks ivaraasen
12:58TimMchyPiRion: ^ New Clojure "art form" -- build programs out of do and #{} by cracking hashes.
12:58hyPiRionTimMc: what, how is do working inside there?
12:58technomancybespoke clojure programs that only work on a given version of clojure
12:59TimMchyPiRion: http://dev.clojure.org/jira/browse/CLJ-1184
12:59hyPiRion,((-> [$ !] #(* $ !)) 2 3)
12:59clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: $ in this context, compiling:(NO_SOURCE_PATH:0:0)>
12:59hyPiRionhm, what did I forget there
12:59TimMchyPiRion: I was sad that I could inject an entire fn arity into #() via -> -- the problem is the trailing arg vector.
13:00TimMc&(macroexpand '(-> ([x y] (+ x y)) #()))
13:00lazybot⇒ (fn* ([x y] (+ x y)) [] ())
13:00hyPiRionyeah, I know, it's sad
13:00hyPiRionI've tried out that as well, but got no way of doing closures
13:00gfredericks,[do 1 2]
13:00clojurebot2
13:02TimMc&'(#{do *} 5 6)
13:02lazybot⇒ (#{* do} 5 6)
13:03TimMc&'(#{do (identity *)} 5 6)
13:03lazybot⇒ (#{do (identity *)} 5 6)
13:03TimMc&(#{do (identity *)} 5 6)
13:03lazybotjava.lang.RuntimeException: Unable to resolve symbol: do in this context
13:03TimMcBlah, sorry -- wrong window.
13:06callenah motherfucker
13:06callenfucking fucker heroku fuck
13:07ppppaulwhat is the simplest way to turn something into a vector, and if it's already a vector, keep it the way it is
13:07tickingppppaul: (apply vector …)
13:08TimMcvec
13:08tickingbetter ^
13:08TimMcppppaul: vec will give you back a new vector, by the way
13:09ppppaulticking, thanks. that's what i came to as well
13:09ppppaul,(doc vec)
13:09clojurebot"([coll]); Creates a new vector containing the contents of coll. Java arrays will be aliased and should not be modified."
13:09hyPiRionthe simplest way is obviously `[~@foo]
13:09ppppaul^_^
13:10hyPiRion,[`[~@(list 1 2 3)] `[~@[:a :b :c]]]
13:10clojurebot[[1 2 3] [:a :b :c]]
13:12ppppaul,(->> "17592186045423" (apply vector))
13:12clojurebot[\1 \7 \5 \9 \2 ...]
13:13ppppaul,(->> "17592186045423" (apply vec))
13:13clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (14) passed to: core$vec>
13:13gfredericks,[if 1 2 3]
13:13clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: if in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:14ppppauli don't want the string to get seqed
13:14ppppauli would like the vector to look like ["17592186045423"]
13:14gfredericksdo you always have just a string?
13:14ppppaulsometimes i have an array of strings
13:14gfredericksand you want to do something different depending on which it is
13:15gfredericksyou could say (if (string? x) [x] (vec x))
13:15dakronecemerick: duly noted, I've moved it up to near the top
13:15ppppauli want to keep the array as is, or i want to turn the single string into an array of 1 string
13:16ppppaulwell, guess i'm throwing in some conditions.... i was just curious if there was some other way to do this in clojure
13:21dchandnappppaul: How about this: (vec (cons "1234554456" [])).   Disclaimer: I am a Clojure newbie :)
13:24Foxboronppppaul: conj?
13:25Foxboron(conj [] "clojure")
13:25FoxboronI am not really sure what you mean by "turn" tbh.
13:27jjttjjanyone 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:27jjttjj
13:43lynaghkdnolen: do you know what the story is with ClojureScript's (undefined?) macro?
13:43cyffis it possible to run clojurescript on node.js without using clojure?
13:43lynaghkdnolen: 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:44noncomis it possible to link 2 or more terminals to a clojure repl?
13:44lynaghkcyff: 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:44technomancynoncom: sure; `lein repl` in one and `lein repl :connect $PORT` in the other
13:44cyfflynaghk: you know the project?
13:45cyffthe name of it
13:45lynaghkcyff: nah, not offhand but just google/github around and you'll find it
13:45lynaghkcyff: https://github.com/kanaka/clojurescript
13:45cyffdoesn't seem to updated
13:46lynaghkcyff: there may be others
13:46callenlynaghk: void 0 is the standard way to check for undefined.
13:46noncomtechnomancy: very good! thank you!
13:47lynaghkcallen: 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:48lynaghkcallen: 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:48cmajor7compojure, 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:48lynaghkcallen: but (when-not (undefined? js/jQuery)) won't cut it because that throws a reference error when jQuery isn't defined.
13:48callenlynaghk: write your own macro?
13:49callenthis 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:49lynaghkcallen: thought I'd ask David first about the cljs.core/undefined? behavior =)
13:49callenlynaghk: file an issue on the github to rattle cages more effectively.
13:49lynaghkcallen: this has nothing to do with ClojureScript, the problem is with the JavaScript it's emitting
13:50callenI'd call that an act of sophistry.
13:50lynaghkcallen: I troll dnolen enough in person
13:50callenthen troll him in person.
13:50callenSeeing the pain with full CLJ/CLJS apps, I can see why node/meteor people run screaming.
13:53dnolencallen: lynaghk: it's come up before, perhaps we could provide a resolve macro which can be used for this purpose.
13:54lynaghkdnolen: is the typeof check slow or otherwise unidiomatic JS?
13:54lynaghkdnolen: I'm not sure what that's not being used. Or typeof x === void 0
13:54dnolenlynaghk: no that sounds like reasonable approach to me, to use the typeof operator
13:55lynaghkdnolen: you want a patch?
13:55dnolenlynaghk: 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:56lynaghkdnolen: it's implemented as a macro
13:57dnolenlynaghk: that just for inlining
13:57dnolenlynaghk: it's proper function
13:57octagonhello! 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:58dnolenoctagon: 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:59lynaghkdnolen: I don't follow.
13:59dnolenlynaghk: undefined? is a function
13:59dnolenlynaghk: it's not a macro
13:59dnolenlynaghk: undefined? checks for the undefined value
14:00octagondnolen: that doesn't work because i need to have a record type that implements IFn with variadic parameters
14:00dnolenlynaghk: for the typeof global case we probably want something else to handle that
14:01lynaghkdnolen: 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:02dnolenoctagon: if you're going to implement IFn I don't really see how you can avoid implementing every arity. so perhaps a macro.
14:02dnolenlynaghk: and it's not different than + in that regard.
14:02octagondnolen: thank you for supporting variadic protocols in cljs btw. seriously.
14:03konr``in cljs, is there a function to turn a js object into a map?
14:03dnolenlynaghk: macros in ClojureScript can serve a different purpose than Clojure - we can use macros for inlining.
14:03dnolenoctagon: 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:04dnolenoctagon: IFn is a gnarly case where inheritance actually seems pretty useful.
14:04octagondnolen: please keep it in there. it's important.
14:04dnolenoctagon: don't depend on it.
14:05lynaghkdnolen: 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:05octagondnolen: the only means of combination there is in Lisp is function application
14:05octagondnolen: this means that semantics is defined by IFn
14:05octagondnolen: that's really important and deep i think
14:06dnolenoctagon: 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:07dnolenlynaghk: that won't work
14:07dnolenlynaghk: undefined? is a *function*
14:07dnolen(map undefined? [js/jQuery])
14:07dnolenwill blow up, even if you add typeof to the macro in core.clj
14:08lynaghkdnolen: ahhhh, got it.
14:09lynaghkdnolen: need to wake up a bit over here.
14:09cyffcould someone who is good at clojure help him out: https://github.com/ajaxorg/ace/issues/1372#issuecomment-16461385
14:10cyffand regexp
14:11dnolenlynaghk: 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:12lynaghkdnolen: objections to converting the existing one into a macro? It's not being used as a value anywhere in core.cljs
14:13lynaghkdnolen: 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:13lynaghkdnolen: but yeah, I'll open up a ticket.
14:14dnolenlynaghk: 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:14patchworkThe cannot-take-a-value-of-a-macro problem has driven me to never use macros
14:14dnolenlynaghk: I'd prefer a different name at this point I think.
14:19naegis there something like a (max a b) supporting nils? e.g. (max nil 0) => 0
14:20noidinaeg, http://clojuredocs.org/clojure_core/clojure.core/fnil
14:20naegguess I can use (or nil 0) for that...
14:20noidi,((fnil max 0 0) nil 8)
14:20clojurebot8
14:21noidi,((fnil max 0 0) 3 nil)
14:21clojurebot3
14:21naegnoidi: how about using (or) instead?
14:21naegit's actually a (max (f) 0), where f returns a number or nil. so I guess (or (f) 0) does the same?
14:22ieureHm, I thought contains? worked for strings, but it seems like it doesn't.
14:22ieureWas this a 1.5.x change?
14:22TimMcieure: contains? would never have worked on strings
14:23TimMc~contains
14:23clojurebotcontains? 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:23stuartsierraieure: `contains?` only works on keyed collections, but prior to Clojure 1.5 it would silently return nil when called on an unsupported type.
14:23TimMcoho
14:23noidinaeg, yes, that would work
14:23ieurestuartsierra, 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:24ieureAh; but that should have been (is (= ...))
14:24ieureI see.
14:24ieureOr (is (contains? ...))
14:24stuartsierraieure: And your `h` must be a set or a map.
14:25ieurestuartsierra, Got it.
14:25ieureWould be nice if there was a clojure.string/contains? method.
14:26stuartsierraieure: That's just (.contains string substring)
14:26Luyt_Is there some clojure-specific pastebin somewhere which will also execute the code? (It's not mentioned in topic)
14:27ieurestuartsierra, Sure, and (subs) is just (.substring string i)
14:28stuartsierraCan't explain that one. ;)
14:29nDuffLuyt_: ideone.com supports Clojure, among many other languages.
14:29trptcolin,(map resolve '[every? not-every? any? not-any?])
14:29clojurebot(#'clojure.core/every? #'clojure.core/not-every? nil #'clojure.core/not-any?)
14:30trptcolino_O
14:30RaynesEvaluation is still a planned feature of refheap.
14:32stuartsierratrptcolin: `some` can fulfill the role of `any?`, but it's not a boolean predicate.
14:32trptcolinsure. (comp boolean some)
14:33technomancyyou could say the same about not-any? as (comp not some)
14:33trptcolinand i know that discussion has been rehashed dozens of times
14:33stuartsierra(comp not some) is actually the definition of `not-any?`
14:34technomancyheh; nice
14:34trptcolini just found that list of namings illustrative
14:34stuartsierraI tend to forget that `not-any?` exists.
14:35technomancymost of these discussions boil down to "these were written a long time ago, before the guidelines were solidified"
14:35stuartsierrayep
14:36Luyt_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:36trptcolinstuartsierra: me too, just ran across it in auto-complete
14:36technomancy(which makes me thankful that Clojure stayed small early on)
14:38noidiLuyt_, you have a def instead of a defn
14:39konr``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:40Luyt_noidi: Ah! Thanks
14:42Luyt_noidi: Now it works. http://ideone.com/9ciD20 I also had to add extra [ ] to the defn.
14:44noidigreat
14:45Luyt_stuartsierra: Are you the author of the book I have here: Practicl Clojure ?
14:46stuartsierraLuyt_: Yes, the Apress book, which I wrote with Luke VanderHart.
14:47Luyt_Cool. I bought it a while ago, but only now I get around to stuff with clojure.
14:56amalloynaeg: using 0 doesn't work too well if (f) returns -100
14:56amalloyyou probably want (apply max (remove nil? coll)) or similar
14:57amalloyer, i guess i meant noidi
14:57TimMc&(max)
14:57lazybotclojure.lang.ArityException: Wrong number of args (0) passed to: core$max
14:58trptcolinlol, missing zero-arg arity strikes again!
14:58trptcolinerr, zero-arity?
14:58amalloywell, it's not exactly missing
14:58TimMcI can't decide whether max should have a nullary invocation.
14:58amalloythere's simply no good way to define it
14:58amalloyTimMc: no way
14:58TimMcDouble/NEGATIVE_INFINITY
14:58pmonksnil?
14:58clojurebot⟹ "Returns the metadata of obj, returns nil if there is no metadata."
14:59amalloygross as half a worm in your apple, TimMc
14:59TimMchaha
14:59TimMcIt wouldn't change the behavior of max.
15:00amalloyobviously it would: calling it with zero args would behave differently
15:00TimMcmeh
15:01TimMcIf someone was relying on that throwing, they kind of deserve code breakage.
15:02trptcolinsomebody could rely on getting ints back
15:02trptcolinerr, longs
15:02amalloyi don't really agree. anyone who relies on (max) giving back NEGATIVE_INFINITY, though...
16:28SegFaultAX,(into {} '((:a "foo")))
16:28clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry>
16:28technomancyjweiss: mapentries are a subclass of vectors
16:28SegFaultAXThat
16:28SegFaultAXIt has nothing to do with array-map, though.
16:28technomancythe error message on the list one is really weird though
16:28jweissyeah, i didn't mean to imply it was array-map, just happened to be using that
16:29technomancyI'd expect it to be a list that can't be cast
16:29jweissyeah, why is it trying to cast Long to MapEntry
16:32SegFaultAXThis is why: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/APersistentMap.java#L40
16:33SegFaultAXIf it's not a map entry or a vector, it tries to turn each element into a map entry
16:33technomancywhy does that sound so familiar
16:33technomancyoh yeah http://brehaut.net/blog/2013/duck_wrapping
16:33gfredericks(inc brehaut)
16:33lazybot⇒ 12
16:33SegFaultAXI don't know, but that's really strange behavior.
16:34gfredericksit's not actually duck-wrapping though
16:34SegFaultAXHaha, that's an awesome name. Duck wrapping.
16:34gfredericksduck 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:35SegFaultAXgfredericks: Yea that's not quite what's happening here.
16:35SegFaultAXgfredericks: The list '(1 2) doesn't become {(1 2) nil} in the case above.
16:36gfredericksthank goodness
16:37SegFaultAXgfredericks: Not that the /actual/ behavior is any more sensical.
16:37jweissok so this is basically into trying to do its best with the given input, what's an alternative, (apply array-map (interpose ...))?
16:37SegFaultAXI mean, it should error, but not the way it's erroring here.
16:38SegFaultAX,(into {} (map vec '((1 2) (3 4))))
16:38clojurebot{1 2, 3 4}
16:38gfredericksyou're just saying the error message should be better, right?
16:38jweiss(oh i guess it wasn't clear from my example that i was trying to zipmap two lists, but keep the order
16:38rbxbxduck wrapping is a fairly common pattern in ruby :X
16:38SegFaultAXgfredericks: That it shouldn't be erroring like this at all.
16:38rbxbxaka probably a bad idea ;D
16:38gfredericksSegFaultAX: I must be missing the point
16:39SegFaultAXgfredericks: It should be a different class of error entir16:50 -!- machuga is now known as machuga|away
16:50gfredericksit's been discussed before. I'm sure ambrose had to deal with it.
16:50gfredericks,(doc conj)
16:50clojurebot"([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:51SegFaultAXgfredericks: You'll note that conj just delegates to cons
16:51SegFaultAXhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L559
16:52gfredericksSegFaultAX: yep
16:52gfredericksbut the docs should go on the var
17:02TimMcOK, 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:03TekhneI'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:03TimMcTekhne: :else is just a convention -- it's any truthy value
17:04TekhneTimMc: ah, okay. Thanks.
17:04SegFaultAXTekhne: Do you know how cond works without and :else branch?
17:04TekhneTimMc: kind of a self-documenting thing. I get it.
17:04nightfly__SegFaultAX: it just runs the conditions that are matched
17:05SegFaultAXnightfly__: Redirect to Tekhne, he's the one asking.
17:05TekhneSegFaultAX: 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:06SegFaultAXTekhne: Cool!
17:10SegFaultAXgfredericks: The only obvious use case I can think of for handling arbitrary seqs in cons is for something like
17:11SegFaultAX,(into {} (.entrySet {:a 1 :b 2 :c 3}))
17:11TimMc:or-I-guess-maybe
17:11clojurebot{:a 1, :c 3, :b 2}
17:12SegFaultAXgfredericks: I can't really think of another common case where you would have an iterable of map entries hanging about. :)
17:12SegFaultAXTimMc: Seems like a reasonable alternative to :else
17:12SegFaultAX:or-if-you-really-must
17:12nightfly__:fuck-it-do-this-instead
17:13SegFaultAXFor the lisper on the ragged edge.
17:14SegFaultAXAlso, why doesn't APeristentMap.entrySet return a normal persistent set instead of an anonymous abstract set?
17:27amalloySegFaultAX: it would be expensive to create, for no particular benefit
17:27amalloyand, of course, it *does* return a "normal" IPersistentSet: it just uses the underlying map as its backing store instead of using something else
17:28amalloyoh, entrySet? i guess it's returning a java.util.Map, not an IPersistentSet, but the same thing applies
17:30SegFaultAXamalloy: 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:41rasmustotpope: 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:44SegFaultAXrasmusto: With fireplace?
17:46pochoHow do you use cljsc/build with multiple .cljs files? If I build seperately, it complains about not having goog.provide().
17:57rasmustoSegFaultAX: yes
17:58rasmustoSegFaultAX: when I try it, it asks me to install classpath.vim or :Connect to a repl
20:09hugodcallen: what were you trying to do with clj-ssh?
21:09devnGood evening
21:13technomancyivan: you could probably do that with an nrepl middleware
21:14gfredericksis there a way to get nrepl to look at the :repl-options in the project.clj?
21:15amalloytechnomancy: really? i guess i don't know how nrepl middlewares work, but that sounds like witchcraft
21:16technomancyamalloy: you can do anything with middleware
21:17technomancyit would only work on direct .method calls though
21:17technomancyunless you do some insane rewriting/decorating thing a la guzheng
21:18technomancymakes you pine for CL conditions though
21:18technomancyritz could probably do it actually =)
21:18amalloyright, i can believe it as a ritz thing
22:04gfrederickswow that data.json pretty printer is pretty bad
22:12ivancan I eval some forms in a function at compile time, without sticking them in top-level def?
22:13gfredericksyou can do whatever you want at compile-time, generally
22:14ivanhaha sublime text really doesn't like #=
22:14ivanyeah #= totally does not work for this Java method call
22:15amalloyivan: you can write a macro that does the evaluation when it runs, or you can (let [pre-computed ...] (defn ...))
22:15amalloy#= is 100% the wrong solution
22:15ivanoh, right, thanks, forgot I could put a let there
22:18gfredericksclojurebot: #= is 100% the wrong solution
22:18clojurebotRoger.
22:18amalloy(inc gfredericks)
22:18lazybot⇒ 19
22:18gfredericksI need to start endorsing things by saying that they are "0% the wrong solution"
22:19ivan#=?
22:19clojurebot#= is 100% the wrong solution
22:20gfredericksclojurebot: clojure is 0% the wrong solution
22:20clojurebotYou don't have to tell me twice.
22:20langmartinso...... 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:20tpoperasmusto: shouldn't be that hard but I have yet to reason it out
22:21langmartinI currently have a java.util.concurrent.Semaphore and in the result procedure I (def a global variable) and then release the semaphore
22:21langmartinthis doesn't actually give me predictable values for the global
22:24brehautlangmartin: def?
22:24langmartinbrehaut: yeah, I know
22:24brehautlangmartin: you should not be deffing things outside of your top level.
22:25langmartinthe result handler gets called asynchronously from the perspective of the tests, and I need it to block, synchronous style
22:25langmartinso that I can make sequential assertions
22:26langmartinif 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:26brehauthave you looked at promises?
22:26langmartinand deref seems to sometimes give me last run's answer even after I've released the lock
22:26langmartinbrehaut: I did have promises in there before, yeah
22:27langmartinperhaps not in a neat pattern
22:29langmartinall 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:29langmartinI just need the tests to block on each successive answer
22:29amalloylangmartin: yeah, promises or rewrite the whole thing to use lamina channels
22:29langmartinoof
22:29langmartinthat's ... unlikely in the short term
22:30brehauti 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:30amalloyyou might be able to just rewrite the handler; it's not really clear to me what's going on
22:30amalloy(inc brehaut)
22:30lazybot⇒ 13
22:30langmartinsure
22:30amalloyalthough i do enjoy "throw stuff till it sticks" debugging
22:31gfrederickstry adding more parens
22:31langmartinI'm not free to share the code, unfortunately (not yet anyway).
22:31TimMcI bet you just need a few more dosyncs.
22:32TimMc(not actual advice)
22:33gfredericksTimMc: unable to resolve symbol: actual in this context
22:33TimMclangmartin: OK, is the general problem that you need to step the application through a series of I/O events and test the behavior?
22:34langmartinTimMc: exactly, and the application is multithreaded
22:34TimMclangmartin: I once wrote a thing called Lockstep.java that did something like that. Unfortunately, it was for a previous employer...
22:34langmartinah
22:35TimMcBasically I had my handful of threads and a lock (or several?), and the threads took turns acquiring and releasing locks.
22:35amalloygfredericks: usually it's "try removing some of the parens"
22:36TimMcIt was pretty complicated to set up. :-/
22:37langmartinTimMc: that's basically where I'm have it now, and it does, mostly, work
22:38langmartinI'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:41amalloythat's really what a promise is for, as far as i can tell
22:43langmartinamalloy: that's helpful. I may be able to cook up a more reasonable use of promises if I take another crack at it
22:48langmartinhmmm no promise?
22:49langmartiner, the procedure `promise?' thatis
22:52brehautlangmartin: that'd be pretty hard; promise is just a reification of IDeref and IBlockingDeref
22:53langmartinbrehaut: 's cool, I'll just wrap it in my own deftype
22:54brehauthuh, i didnt realise that promises were callable, and thats all deliver does
22:54RaynesI promise that promises are callable brehaut.
22:54technomancyRaynes: `deliver` is my favourite horrible way to fake out 1-arity funcall
22:55brehauttechnomancy: haha love it
22:55technomancybrehaut: I live on the wild side
22:59l1xhey guys
23:00l1xi am looking for a bitset/bitarray library in clojure, do you know any/do you use something like that what you would recommend?
23:08langmartinsorry to be so vague everyone, and thanks for the help.
23:09brehautl1x: maybe https://github.com/rosejn/byte-spec ? never used it, but it turned up on clojuresphere and its used by overtone
23:11brehautoh, http://github.com/overtone/byte-spec looks newer
23:12l1xthanks!
23:17amalloyl1x: what about using a java bitset? iirc that's a thing
23:17amalloy$google java bitset
23:17lazybot[BitSet (Java Platform SE 7 ) - Docs Oracle] http://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html
23:20amalloyit's mutable, but c'est la vie
23:21l1xamalloy: 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:21amalloy*shrug* i'm sure it's just an int, or array of ints, under the hood
23:21l1xi see
23:23amalloyit's a long[], apparently
23:24amalloybut it doesn't really matter: it does whatever it promises to do
23:36l1x:))
23:36l1xi was reading the redis article about unique counts
23:45adu_l1x: link?
23:45l1xadu_: http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps/
23:45l1xit is freakin' amazing
23:46adu_l1x: what is?
23:46l1xusing bitset to count visitors for your website :)
23:48l1x(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:48adu_I can see some problems with that
23:50adu_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:51adu_but yes, it's on the edge of optimization
23:53l1xuser is deleted -> you dont care, keep the user's id in the system
23:55l1xuser 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:55l1xsomeone hacks -> it wont impact your system because you are counting the visitors, not the users created
23:57adul1x: which are counted by user_id