#clojure logs

2013-07-27

00:01futilehaving two reverses just for the sake of destructuring seems dumb. i like #54 the best.
00:03isaacbwfutile: oh man, that's clever. It took me a while to grock
00:03futileisaacbw: thats a sign that its stupid :)
00:03isaacbwlol
00:04isaacbwI just haven't seen the -> macro before
00:04futileisaacbw: the last tweak i would make is to use doseq instead of map to make it more explicit whats happening.
00:04futilehttps://www.refheap.com/16956
00:04futileisaacbw: oh ->, yeah thats a good thing. i thought you meant the destructuring and reversing.
00:07futileisaacbw: and for the sake of separation-of-concerns i'd split it into two functions: https://www.refheap.com/16957
00:08futileplus that makes the two parts more re-usable and easily maintainable.
00:08futileand testable
00:09isaacbwyay testing
00:10futileactually you dont even need to name "lines" in (let) ... https://www.refheap.com/16958
00:11futileisaacbw: i guess this has been a whirlwind tour of how my mind tries to make clojure code "more idiomatic"
00:12isaacbw:P
00:12isaacbwit's been very helpful. Thank you
00:12futilebut i recommend having someone else in here write it too
00:12futile... if there is anyone else in here?
00:12chouser_loglookin' good. I'd use 'when' instead of 'if'. Or maybe cond->
00:13futilechouser: hmm
00:13futile,(doc cond->)
00:13clojurebot"([expr & clauses]); Takes an expression and a set of test/form pairs. Threads expr (via ->) through each form for which the corresponding test expression is true. Note that, unlike cond branching, cond-> threading does not short circuit after the first true test expression."
00:14futilechouser: i dont know why but it seems like 'when' implies side-effects
00:14chouserso (-> data ... (cond-> last-line-complete? (concat [""])) ...)
00:14futilechouser: ah! yes, i see now! thats perfect
00:14futileis that what cond-> was designed for?
00:15chouserI believe so, yes.
00:15futilesweet
00:15futile(inc chouser)
00:15lazybot⇒ 14
00:15chouserAlso what synthread was designed for, but you don't have to go there. https://github.com/LonoCloud/synthread
00:16chouserfutile: Your observation about 'when' is fair.
00:16chouserThe fact that it allows multiple "then" clauses makes it useful for side-effects, like 'do'.
00:17chouserBut it also makes it absolutely clear up front that you're not going to provide an "else" clause, so that's why I like to use it.
00:18futileisaacbw: with chouser's edit it's https://www.refheap.com/16959 although im on the fence about cond-> when first learning clojure
00:18chouserThat's also fair. :-)
00:18futilechouser: hmm yeah good point.
00:18chousercond-> is quite new and not yet widely used, I think.
00:19futileit seems like maybe 'when' should be split into two forms, one implying side-effects and one thats just 'if' but without any else clause.
00:19futilenot sure what itd be named though.
00:19futile(iff) ?
00:21futilechouser: my reasoning about cond-> is that it requires a firm grasp of imagining clojure macro-transformations, which i think beginners dont have yet
00:21chouseryep, perfectly fair. Even -> is often a stretch.
00:21futilealthough the same might be said about ->, but that one seems simpler and probably easy.
00:22futile,(iff foo (println "yep, its a foo alright")
00:22clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
00:22futile,(iff foo (println "yep, its a foo alright"))
00:22clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: iff in this context, compiling:(NO_SOURCE_PATH:0:0)>
00:22futileclojurebot: *yet*.
00:22clojurebotCool story bro.
00:22chouseryou can always use let instead of ->
00:23futilechouser: actually the more i think about it, the more i think beginners should get used to -> right up front
00:23futilechouser: at work we've had some (let) blocks that continuously rebind the same name on each line, and it makes it really easy to do bad stuff
00:24chouseryeah? what about ->> ? and doto ? and cond-> and when-> :-)
00:24futilei think using -> and ->> makes it easier to avoid bad practices. cant say for sure what they were though, this was a few months ago when we were new to clojure
00:24futilewhen-> !?
00:25futile,(doc when->)
00:25clojurebotPardon?
00:25chouserhm... The names changed a couple times right before they were released.
00:25futilemaybe as-> ?
00:25futile,(doc as->)
00:25clojurebot"([expr name & forms]); Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form."
00:26futilethats useful for when you want to mix -> and ->> but cant really
00:26chouseroh, I was thinking some->
00:26futileoh yeah, i still dont know what thats there for
00:26futile,(doc some->)
00:26clojurebot"([expr & forms]); When expr is not nil, threads it into the first form (via ->), and when that result is not nil, through the next etc"
00:27futileoh, so its just a short-circuiting ->
00:27futile,(doc some->>)
00:27clojurebot"([expr & forms]); When expr is not nil, threads it into the first form (via ->>), and when that result is not nil, through the next etc"
00:27futileneat
00:27chouserPeople were asking for that for ages. Often named -?>
00:27futileheh, naming is getting harder now that its a pretty rounded out core lib
00:27futilei dont see how it relates to 'some'
00:28futilebut im sure they settled on some-> for good reason
00:28futilei mean.. for *some* good reason :D
00:28chouserheh
00:28chousersome stops as soon as it gets a non-nil, some-> stops as soon as it gets a nil, so ... umm ...
00:29chouseryeah, I guess I don't know either.
00:29futile,(doc some)
00:29clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
00:29futilelogical true means non-nil-or-false
00:30futilemeh, whatever.
00:30futileso.. isaacbw, got any more fun exercises like that one?
00:34chouserfutile: http://clojure-log.n01se.net/date/2012-11-29.html#10:15
00:35isaacbwfutile: hah, none at the moment
00:35futilechouser: ahh
00:35futileisaacbw: aww
00:35isaacbw:P
00:36chouserDoesn't look like it got resolved there.
00:36chouseroh well. :-)
00:36sdegutisheh
00:36sdegutischouser: interesting nonetheless
00:37sdegutishmm, i dont think i can change nicks like this, callen will yell at me for it
00:38sdegutisi still like test-> better
00:40sdegutisas-> seems right
00:41isaacbwI'm trying to write an LMTP server with clojure, but I'm starting to realize that this may not be the best learning project
00:41isaacbwlol
00:41futileheh
00:41isaacbwconsidering how stateful that kind of thing can be
00:41futilehow about hangman?
00:41futilefor cmdline
00:42isaacbwoh, that would be cool actually
00:42futileok
00:42futileif i write it too, want me to not show it to you?
00:43futile(it sounds like fun)
00:43futilechouser: ooh i get some-> now.. it threads through "some" of the expressions, but maybe not all
00:44futileseems like it should be (while->) or something
00:44futilebut not while-> because its unrelated to while
00:44futilemaybe iff->
00:45futile:D
00:45futileoh who cares what callen thinks
00:45sdegutisthere.
00:56Raynessdegutis: FWIW, Jose was already gone by time you joined #elixir-lang. It's a pretty active channel during some hours of the day.
00:56sdegutisRaynes: ah
00:56sdegutisi want to be interested in it, its just so.. infixy
00:56Raynes:P
00:56sdegutisextra rules for my poor brain to memorize
00:56sdegutisand special cases and edge cases
01:14sdegutischouser_log: thx for the tips
01:14sdegutischouser_log, isaacbw nite.
01:28akurilinQuick dumb question, is there a list literal in clojure? As in, can I do '(1 2 3) as opposed to (list 1 2 3)? Hasn't worked too great for me, hence the question.
01:29alandipertakurilin: what about it hasn't worked for you? '(1 2 3) and (list 1 2 3) are both legit
01:38akurilinalambert, I'm using (fn [id] '(ks1 ks2)) in a with-redefs where ks1 and 2 are two maps I deffed earlier. My UTs don't pass when I use the literal approach.
01:39akurilinactually let me repl this for a sec, see if I can repro by hand.
01:40alandipert akurilin sounds like you're running into the fact that '(..) => (quote ...) and anything inside the quote form isn't evaluated (such as the elements of a list)
01:40akurilinalambert, yes
01:41alandipertakurilin: `(~ks1 ~ks2) is one option, as syntax-quote allows for selective evaluation of forms via ~ (unquote)
01:42alandipertakurilin: but i would prefer just [ks1 ks2] which relies on the fact that literal vectors do evaluate their constituent elements, which is the best bet if you're not relying on listiness particularly
01:42alandipert,`(1 ~(+ 1 1) 3)
01:42clojurebot(1 2 3)
01:43akurilinalandipert, I don't think I am. I'm trying to have my with-redefs stubs for clojure.jdbc return whatever data structure the form returns, which is probably just a sequence.
01:43akurilinI was hoping a list would be more legit than a vector, but I might not really need this at all
01:43alandipertakurilin: i think returning a vector is a safe bet, esp. since vectors are also sequential
01:44akurilinalandipert, yeah that's a good point.
01:45akurilinalandipert, thanks for clarifying, I learned something new today :)
01:45Raynesalandipert: Ohai. How's things?
01:45alandipertnp! happy computing
01:45alandipertRaynes: good, and thyself?
01:46RaynesI'm fantastic enough.
02:14SegFaultAXPi is a weird movie.
02:40rattboigood one though
02:40rattboieasier to follow than Primer
03:29speedwagonHi! beginner question: The nrepl i started in emacs does not seem to know clojure.contrib. duck-streams . How can i fix this or am i using an outdated tutorial ?
03:31supersymduck-streams If a clojure.contrib namespace is not listed here, it is most likely an old namespace that was either migrated somewhere else or deprecated as part of Clojure 1.2 (e.g., clojure.contrib.duck-streams mostly migrated to clojure.java.io
03:31supersymhttp://dev.clojure.org/display/community/Where+Did+Clojure.Contrib+Go
03:37speedwagonThanks, I will read that.
03:41speedwagonI should probably look for a different tutorial/book.
05:01tomjack(memoize (fn [& args] (Object.)))
06:16noncomif, when i am in repl, *ns* is the current namespace then what is *ns* when a clojure program is executed from a jar?
08:07squidzhow would you normally translate this into clojuresciprt? https://www.refheap.com/16961
08:07squidzit is only a couple of lines of javascript
08:35patrkrishi. i'm pretty new to Java interop in Clojure, and wrote the following code to try out netty: https://www.refheap.com/16962
08:36noncomsquidz: do you know how to translate this to clojure?
08:36noncom(i mean not clojurescript)
08:36patrkrisI've set *warn-on-reflection* to true, and Clojure now warns me that the call to .option can't be resolved
08:37patrkrishow do I get Clojure not to use reflection in this case?
08:37patrkris(.channel and .childHandler can't be resolved either, but curioulsy it doesn't complain about the call to .group)
08:40noncompatkris: why do need warn-on-reflection?
08:40squidznoncom: no i'm guessing I would use an atom, but i've never done so
08:40noncomsquidz: gimme a sec, i'll give it a try
08:41squidzokay thanks
08:42squidzi've tried avoiding atoms and state for as long as possible, but it seems like the time has come where I can't get around it again
08:42patrkrisnoncom: I don't need it per se
08:43noncompatrkris: i am no pro, but i think that if you need it (coz it is needed to know if speed-critical places ose reflection), i would enable and disable it when required
08:43noncomand created a macros to do that for me
08:44patrkrisyou may be right, but I'm still curious to know how to avoid reflection in this case :)
08:46noncompatrkris: try using explicit type hints maybe?
08:47noncomsquidz: tell me what do yo want to get with that code?
08:48noncomsquidz: you want to get a set of objects which have x and y properties set depending on passed value?
08:48patrkrisnoncom: I tried annotating b with ^ServerBootstrap, but it didn't help... :-(
08:49squidzyeah I want the nodes variable to contain x and y properties dependent on an index
08:52noncompatrkris: huh i look in the javadoc and it contains plenty on generics and stuff. are you sure that the java version of these methods itself does not use reflection?
08:53patrkrisnoncom: I don't know. I would've thought that a simple method call to a newly instantiated object wouldn't involve reflection (like the call to .option does)
08:54noncompatrkris: i think it uses some reflection here: http://netty.io/4.0/api/io/netty/channel/ChannelOption.html
08:56patrkrisbut it warns explicitly that it is the call to .option on ServerBootstrap that can't be resolved
09:04noncomsquidz: smth lik htis? https://www.refheap.com/16963
09:05noncomsquidz:threr is also a protocol way, like http://stackoverflow.com/questions/9018326/how-do-i-create-an-js-object-with-methods-and-constructor-in-clojurescript
09:06patrkrisnoncom: aaah, I am starting to see what you mean about generics now
09:06noncompatrkris: yeah, it looks a convoluted type-inference work there in java
09:07noncommy best guess really... what else..
09:09noncomsquidz: i did not test, though, but should work if you call mk-objs.. and yeah,this could be written far more compact, but just for the sake of explicitness...
09:11squidzyes I see what you did there. My main problem is modifying the objects once they are created and I see that you pulled the indexing out into a separate function. I will try something similar out
09:16noncomsquidz: further fun: https://www.refheap.com/16965
09:16noncomoh forgot (into {})
09:18noncomoh crap, no it wont work
09:19noncomsquidz: as a good advice: try always to separate you single object creation logic from you sequence-of-objects creation logic. you get benefits then. soon you find how you can use same code in many places then
09:20squidznoncom: check out this solution that somebody else recommended https://www.refheap.com/16964
09:24noncomsquidz: very nice! this enlightens me since i too a newb in clj and cljs. but note that this approach is less modular. in real projects, when you have big objects, you will want to break this one up (not always). i would make the main function separate, and the body looks a bit cryptic at first glance..
09:25noncomi would not choose this kind of creating values for x and y since it is hardly readable (for me :))
09:25clojurebotIn Ordnung
09:26squidzyeah maybe pull out the logic with the adding and bit-wise operations and keep the threading creating as a general function and be able to push in different logic
09:27noncomyes. threading is a good idea here... my two concerns are modularity and reading this breaks my eyes: (+ (:y o 0) (if (= (bit-and 1 i) 1) 42 -42))
09:28squidzyes that logic can be pushed in on the fly
09:29squidznoncom: here is the actual javascript that i'm trying to translate: http://bl.ocks.org/mbostock/1021841
09:29squidzbecause the simplified snippet i posted may give false impresssion
09:29noncombut irl i kill people that i meet who use ternary operators too :D
09:30squidzyes I don't like it but if you look at the link that is what they use in the javascript
09:30noncomnice!
09:30noncomnice example, i also first time hear of d3
09:30squidzdown below in the force.on("tick" ...)
09:31noncomhow is your experience on d3? you like it?
09:34squidznoncom: yeah it's good, but I hate the mutability of everything
09:35squidzthat is why i'm trying to switch over to clojurescript, but i'm trying to wrap my head around how I will do things the clojurescript way, which is why i have the problem code I pasted
09:36noncomsquidz: ahahah :D. so you don't like mutability from your personal preference and you seek functional immutable approaches? what is your main languages of like?
09:39squidzwell I love clojure but I have mostly done java. Now I have to dig into javascript and so i thought what better opportunity than to use clojurescript. I am hoping that if I can understand how to translate that the benefits of using clojurescript should outweigh the difficulties but a conclusion hasn't been made
09:39squidzthis translation of the link I pasted is kind of a test-run to see if I can get this working. If i feel confident afterwards I am going to switch and use clojurescript at work
09:44noncomsquidz: i see, much like me. well, my transition was first to clj than cljs, and when i finally made it, now i simply can't think of coding in another language.. besides other lisps maybe and C when things come to what C is great for.
09:53noncomsquidz: i find myself fine building a full-scale gui framework based on kineticjs, although, still i'm learning things. also, note that when in clojure, you code backend with clojure and front end with cljs, which are like one language (not exactly, but still, where else you saw smth alike?), and you can call backend functions seemlesly from the frontend with shoreleave rpc mechanism
10:01squidznoncom: yeah in the end it's really aweesome. The only downside is that everything is still relatively new and not as mature as a lot of java and javascript libraries, but it is getting there for sure
10:11squidznoncom: Yeah I am also wanting to play around with clojurescripts async
11:14dotemacshi, silly question: how do you search clojars from the CLI ? Or better: what's the recommended way to see what packages are available via the CLI ?
11:18hyPiRion$latest leiningen.core
11:18lazybotNo project by this name exists on clojars.
11:19hyPiRionI know there's a `lein search`, command. You could look at its help info through `lein help search`.
11:22dotemacshyPiRion: OK, so I wanted to see whats the latest package for postgresql, so i ran: lein search postgresql, it showed a list of packages with the first one at version 9.0-801.jdbc4. But when I do a search on postgresql on clojars.org, the first result is: 9.1-901.jdbc4. How come ?
11:27hyPiRiondotemacs: Not sure. Perhaps clojars' cache is a bit old, or there's a bug somewhere. You should probably ask in the #leiningen channel, there are people in there knowing how the internals of how `search` works better than what I do.
11:31dotemacshyPiRion: thanks, will do
12:03ToBeReplacedIf you have a .clj file that is compatible with both clojure and clojurescript, how can you deploy it to clojars for use on either platform?
12:21dotemacsIs there a way to "disable" a deftest from the test suite? For example you have 10 deftests and you only want to run 9 of them, would there be a way to prefix deftest with a ... to not have it run? Rather than just commenting it out and running the tests.
12:25seangrov`dotemacs: You can add metadata to them, might be one approach
12:31dotemacsseangrov`: sorry, not sure how, any pointers/URLs ? :)
12:36hyPiRiondotemacs: have a look at the sample.project.clj in the Leiningen repo on Github
12:37dotemacshyPiRion: thanks :)
12:41rlbWhat am I missing? The javadocs say that (.indexOf this s fromIndex) returns k such that "k >= Math.min(fromIndex, s.length()) && this.startsWith(s, k)", or -1.
12:41rlbHowever (.indexOf "xyz" "" 10) returns 3.
12:42rlbAccording to my math Math.min(10, ...) can't be less than 10.
12:42rlbOk, now that was stupid.
12:43rlbnevermind
12:47rlb...was overlooking the edge case where "" matches at the end of the string and satisfies the predicate.
12:59noncomin ccw if i load a file into a repl, and it depends on other files and those other files fail to compile, the loading is stopped. and it becomes broken, since i can't restart or continue it without restarting repl. is there a way to re-load all without restarting repl?
13:00Bronsa(let [x 1] (defn x [] x)) returns 1, I wonder if that's the desired behaviour
13:01dnolenBronsa: in CLJS?
13:01Bronsadnolen: clj
13:02dnolenBronsa: I just tried that w/ 1.5.1, I don't see that behavior
13:02alandipertnoncom: not sure about ccw, but you can reload a namespace and its dependencies from the repl with: (require 'foo.bar :reload-all)
13:02Bronsadnolen: I meant when invoking (x)
13:02noncomalandipert: gonna try it
13:02noncomthanks!
13:03dnolenBronsa: hrm, there may be a reason for that ... I vaguely recall something
13:03noncomBronsa: so it creates a closure i think
13:04hyPiRionBronsa: It expands to (let* [foo 1] (def foo (fn* ([] foo)))), go figure
13:04dnolenBronsa: CLJS doesn't preserve that behavior, it returns the self reference
13:04Bronsayeah, if only it expanded into (fn* foo ([] foo)) there would be no problem
13:05hyPiRionyup.
13:05dnolenBronsa: would break redef
13:06Bronsahm?
13:06clojurebotbenchmarking is https://github.com/hugoduncan/criterium
13:06dnolenBronsa: oh right I guess not
13:08Bronsahm
13:08hyPiRiondnolen: actually, I think you're on the right track.
13:08Bronsaactually
13:08Bronsayeah.
13:08Bronsasee: http://sprunge.us/OLDM
13:09dnolenBronsa: hyPiRion: ok yeah
13:11dnolenBronsa: I think this is treated as special case in the CLJS compiler.
13:15hyPiRionBronsa: also, recursive functions through alter-var-root https://www.refheap.com/16976
13:15Bronsadnolen: I see, the var name gets passed around and https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/analyzer.clj#L386-L387
13:15dnolenBronsa: yeah
13:16BronsahyPiRion: right
14:04squidznoncom: I posted the results of the code you were helping me with earlier. Here it is in it's glory. I still want to improve it though since the cljourescript is pretty much a 1-to-1 translation from the javascript http://s.trokes.org/beandipper/6095600
14:07noncomsquidz: cool! well, i would avoid using (set!) and use (cljs->js) instead...
14:07noncomalso using forEach is anti-pattern since clojure is all about sequences and it should be used here
14:09squidzyeah just not sure how to use doseq here with an index while being able to modify the structures in place
14:13bbloomdnolen: why are you deleting tickets, rather than closing them?
14:20noncomsquidz: just try smth like (js/Object. (cljs->js {:x 2 :y 4}))
14:21noncomsquidz: but! on coord modification i would certainly use (set!) because immutability is very natural to game-like processes
14:21noncomsquidz: oh i meant MUTABILITY not immutability
14:22squidznoncom: i'm not sure that it will work because the nodes objects that i am setting are custom structures from the library I believe
14:22noncomi will look more into your code on monday, now i'm finishing my work and have to go.. if i find something i can think can be improved, i'll let you know and ask you if you found something too, since i'm intereted coz i learn too
14:23squidzokay
14:23noncomsquidz: see, you create them with native js/Object. and they take json i think
14:23noncomyou could try
14:23noncomit worked for me with kineticjs
14:23noncomlooks much finer that way
14:23squidzyeah I can try it out later, but I am going to work on something else for now. That was mostly a test project
14:24noncomtests are life :D
14:40wheefor someone just getting into clojure and web applications, are ring and compojure a safe start?
14:40gfredericksyep
14:41onrwhat about Java EE Servlets? :)
14:43noncomwhee: maybe luminus will be a good start. it uses ring and compojure
14:43noncomthey have nice docs too
14:46dnolenbbloom: I'm deleting them, cloning them now
14:47dnolenbbloom: I'm tired of seeing crap in the year 2020
14:48bbloomdnolen: heh ok, just wanted to make sure you weren't accidentally bulk deleting stuff. b/c i got an email about a ticket being deleted
14:48dnolenbbloom: only applies to tickets from the initial import
14:48bbloomah ok
14:48bbloomdnolen: are you able to carry over watchers too?
14:49dnolenbbloom: I don't think it carries over everything but again it only applies to the initial tickets, I think we can live with that.
14:49bbloomok
14:50dnolenbbloom: up to CLJS-23
14:50dnolenso not many tickest
14:50bbloomyup
15:05dnolenk CLJS JIRA cleaned up no more stuff from 2020
15:06squidzis there a way to refer to map entries while defining that same map. For example {:first 1 :second (inc (:first this))} producing {:first 1 :second 2} ?
15:07dnolensquidz: there is not
15:08squidzokay thanks
15:16fbernierHow would you indent the word-count function? Would you indent it at all?
15:16fbernierhttps://gist.github.com/fbernier/6095820
15:16bbloomfbernier: try -> and ->>
15:16bblooms/and/or
15:17fbernieroh right thanks
15:20bamford_People, if there is a patient soul in here, can you explain to me how the (atom {}) can leave the scope of the (let) in the memoize function at this address? http://clojure.org/atoms
15:20bamford_still learning ... :/
15:21gfredericksbamford_: what languages are you familiar with?
15:21bamford_gfredericks: Java, Python, Perl, Vim script, ...
15:21bbloombamford_: it's not leaving the scope
15:22bbloombamford_: think of the fn as defining an instance of a Function class
15:22gfredericksbamford_: any language with closures will do; I think that includes python?
15:22bbloombamford_: but if it uses somethign above it, it creates a Closure class which is a Function and map of variables
15:22bamford_gfredericks: I believe I understand simple closures well enough ... :?
15:22bbloomso fn is basically something like new Closure(new Function(…), new HashMap(…))
15:23bamford_ok
15:23gfredericksbamford_: so the fn includes a reference to the atom, in somewhat the manner than bbloom is suggesting
15:23gfredericksthat*
15:23bamford_bbloom: ok, but where is the atom mem stored? is it inside the fn closure?
15:23bbloombamford_: precisely
15:23bbloominside the hashmap
15:23bamford_oh boy
15:24gfredericksotherwise it would get GC'd
15:24isaacbwcan anonymous functions be passed from clojure to a java class, and then called from java?
15:24bamford_very cool, but puzzling for an unenlightened soul
15:24isaacbw*object
15:24bbloombamford_: enlightenment takes time :-)
15:24gfredericksisaacbw: yes
15:24bamford_bbloom: :)
15:24gfredericksisaacbw: they're both Runnable and Callable
15:24isaacbwgfredericks: oh, awesome
15:25gfredericksif you want to pass args you might need to treat it as an IFn
15:25bamford_bbloom: last question: so if multiple threads call the memoized fib, they will all see the same mem atom
15:25gfredericksbamford_: yep
15:25bamford_... actually yes, that must be it
15:25bamford_gfredericks: thankx
15:26bbloombamford_: if you want different threads to see different values, you can use (doc binding)
15:27bamford_bbloom: yes, Vars, Refs, Atoms I can tick off, now over to Agents ... :)
15:28bbloombamford_: 90% of clojure code only ever needs a very small number (preferably zero) dyamic vars and like ONE atom
15:29bamford_bbloom: heh, ok, so which one is your basic workhorse for concurrency stuff, Refs? (or "it depends", I know)
15:29bbloombamford_: in 1.5 years of clojure, i've used refs ONCE and nobody believed me that i actually needed them for my use case until after an hour of explaining myself in IRC
15:30bamford_?! but they look so cool! I want to use them
15:30gfredericksI have also used refs jutsifiably 1 time.
15:30bbloombut atoms are simpler :-)
15:30gfredericksjustifiably*
15:31gfredericksbamford_: clojure has a lot of cool features that you don't usually need, which is itself kind of a cool feature
15:31bamford_no but seriously, what do you use then? (Thread.) ?
15:31gfredericksfor what?
15:31srrubyI can create an anonymous function that always returns the number 1. (fn [] "always return 1" 1) How do I do the same with #() form ?
15:31bbloombamford_: i didn't even really need refs for concurrency (although they gave me that) i really needed them for independent garbage collection. i could have stuck a map in an atom, but then i'd need to manage lifetime manually :-P
15:32gfrederickssrruby: returning literals with #() isn't worth doing
15:32gfrederickssrruby: #(do 1), #(identity 1) (constantly 1)...
15:32gfredericksthe first two are distracting I think
15:32gfredericksthe third communicates your intent
15:33srrubyThanks!
15:35bamford_gfredericks: actually I don't know, all this clojure has me stoked for concurrency, but I should probably put my head in ice water for a bit and see what I want to use it for :)
15:36gfredericksbamford_: yeah I know the feeling.
15:36bbloombamford_: yeah, it's sorta unfortunate that concurrency gets so much airtime, since it means that people come to clojure & try really hard to run before they can walk or crawl
15:39fbernierbamford_: I've also been stoked about concurrency in clojure, but up to now I've done close to none. I really enjoy learning the language right now!
15:40bamford_bbloom, gfredericks: thanks for your insights. I actually spent some time looking into Haskell some time ago, which is also very functional, but the community and docs have much less emphasis on concurrency
15:49isaacbwgfredericks: using IFn worked perfectly!
15:49gfredericksnice
15:50isaacbwman, this stuff is making me so happy. I can wrap existing java libraries into functional clojure APIs
15:51isaacbwjava's got two things going for it: the jvm and the ecosystem
16:00rhg135hello, i would be grateful for any advice on how to make https://www.refheap.com/16979 more "idiomatic"
16:00bugrumHi, new Clojure programmer here. I was wondering if anyone can point me to a library that implements the dataflow model, similar to that of Cells on Common Lisp
16:01gfredericksrhg135: any use/only can be replaced with require/refer
16:01rhg135ok
16:02rhg135but im pretty sure that's why :only exists
16:04Bronsaif only there was a way to group different dispatch values in a single defmethod :(
16:04gfredericksrhg135: require/refer was added so that :use isn't needed anymore
16:04rhg135hmm i guess
16:04rhg135idk the order lol
16:06rhg135i had this working, but after some minor changes it broke, i guess i need some good tests, but i've never written a test
16:07gfredericksclojure.test is pretty easy to use
16:07Bronsagfredericks: it's tests that are difficult to write
16:08rhg135i know HOW to use it, but don't know how to TEST it
16:08gfredericksyou're testing downloading some stuffs?
16:08rhg135it's a scraper lib
16:08gfredericksyou could stub your download function
16:08gfredericksor use a vcr lib to record the things you're scraping
16:09gfredericksfor high-level tests
16:09rhg135stub? vcr?
16:09gfredericks(binding [*download* (constantly {:some :data})] (test the other functions))
16:10rhg135true but what'd be the point of testing it on arbitrary data
16:10rhg135i guess I need intergration tests
16:10gfredericksto make sure it doesn't blow up. if you have something more specific in mind, test that too at a lower level maybe
16:11gfrederickshigh level tests with recorded data can go nicely with pre/postconditions and other assertions/contracts
16:11rhg135yeah, im gonna bactrack to a working revision and add testing
16:12rhg135or just add now and hax it till it works
16:14rhg135also I'm wondering, in Haskell (which I last used) it's common to use the type system to ensure functions take and return the proper type would pre/post conditions be the best alternative
16:16gfredericksyeah I think so.
16:17rhg135ok I'm going to add some testing
16:17gfredericksshould java.jdbc change its default :result-set-fn from doall to vec, so that processing can be chunked?
16:26bbloomdnolen: shesh, your jira attach has generated a ton of email for me :-P
16:26bbloomattack*
16:35functionformis this the appropriate channel for newbie questions?
16:35gfrederickstotally
16:36functionformassuming a vector of words, i want to use string/replace on each of them
16:36noonianand get a vector of words back that have had replacements made?
16:36functionformexactly!
16:37functionformwhy does this return a quoted string?
16:37functionform(-> words (str/replace "i" "b"))
16:38functionformor is my approach totally wrong
16:38gfredericks,(doc map)
16:38clojurebot"([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."
16:38Bronsa,(mapv #(clojure.string/replace % #"a" "b") ["aa" "ab"])
16:38clojurebot["bb" "bb"]
16:39functionformok so function is required
16:39functionformi was trying to figure something out with threading etc
16:39noonian,(map (fn [word] (clojure.string/replace word "foo" "bar")) ["blargfooey" "bardom"])
16:39clojurebot("blargbarey" "bardom")
16:39arcatanfunctionform: that converts words to a string first and then replaces i with b - that's why you get a quoted string
16:40functionformbizarre, i wouldn't have expected that conversion to take place
16:40arcatan,(str ["this" "will" "be" "quoted"])
16:40clojurebot"[\"this\" \"will\" \"be\" \"quoted\"]"
16:40noonian,(->> ["blargfooey" "bardom"] (map (fn [word] (clojure.string/replace word "foo" "bar"))))
16:40clojurebot("blargbarey" "bardom")
16:41functionformooooooh now i see what iw as doing
16:41functionformok
16:41functionformright
16:41functionformthanks!
16:42functionformoh its so beautfil
16:42functionformwhen i get it working... loving this language.
16:43jprestonAnyone fancy giving a newbie a hand? :)
16:44bbloom~anyone
16:44clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
16:44jprestonWhen I try to use the function in here: http://codepad.org/RViLS8Kf
16:44jprestonI keep getting "Wrong number of args"
16:45jprestonThis is in a lein repl, and that file lives in overtone_workspace/controls/slipderpanel.clj in the lein project's src/ dir.
16:45gfrederickswhat function does it say the wrong number of args were passed to?
16:45jprestonsliderpanel
16:46jprestonBut AFAIK [& opts] would make it completely variadic.
16:46gfredericksyep
16:46gfredericksmaybe your repl has some stale code?
16:47jprestonlets see
16:47jprestonhaha that was it
16:47jprestoncheers! :D
16:58RuralClojurerare there any resources to explain how aot compilation affects macro evaluation?
16:59gfredericksRuralClojurer: presumably the macros still happen at compile-time
17:01RuralClojureroccasionally i hear someone mention vaguely that their macro may not work in aot-compiled code
17:01RuralClojureri'm just wondering what this means
17:02gfrederickshmmm; I can imagine macros with side effects might have that problem?
17:02RuralClojurerok, mb it's not something i need to worry about then
17:03gfredericksafaik
17:03gfrederickswhy do you need AOT?
17:03RuralClojureri'm writing a library that someone might choose to compile
17:03gfredericksah
17:04RuralClojurerthanks gfredericks, i'll stop worrying then!
17:07gfredericksomg this is the weirdest stack overflow I've ever seen. (f (doall (map (constantly nil) coll))) throws a SO, but (f (repeat (count coll) nil)) does not.
17:07gfredericksI have no idea what the difference between those two is
17:07gfredericksthe (doall ...) is not the part throwing the SO, f is.
17:08gfredericksand coll is not chunked.
17:08dnolenbbloom: yep, still got another 150 issues to close
17:08bbloomdnolen: fun times
17:09dnolenbbloom: will be careful to close resolved tickets in the future
17:09bbloomdnolen: can't just bulk update them?
17:09dnolenbbloom: not sure how to do that?
17:09bbloomi'm quite confident it's in there somewhere :-P
17:11bbloomdnolen: "tools" menu in top right
17:11bbloomgo to the issues tab
17:11bbloomjira's UI is atrociously bad
17:12bbloomalso, if that just saved you 150*nMinutes, you owe me a beer :-)
17:12dnolenbbloom: sweet done!
17:12dnolenand no emails :)
17:12bbloomhaha even better!
17:13dnolenbbloom: beer owed
17:13bbloompleasure doing business with you
17:35scapeHi all, I come with a question :) I am working with libgdx in clojure and am curious how I am to properly call the Mesh class that exists in graphics. When I call something like: (Mesh. true 4 4 attrs) I get UnsatisfiedLinkError com.badlogic.gdx.utils.BufferUtils.newDisposableByteBuffer(I)Ljava/nio/ByteBuffer; com.badlogic.gdx.utils.BufferUtils.newDisposableByteBuffer (BufferUtils.java:-2)
17:36scapeHowever I have this (:import (com.badlogic.gdx ApplicationListener Gdx) (com.badlogic.gdx.graphics GL20 Mesh VertexAttribute Color) (com.badlogic.gdx.utils BufferUtils))
17:37scapeSo if anyone may know what I am doing wrong, I'd appreciate help.
17:37avishaia question about promises
17:37avishaiis there a function which "breaks" a promise?
17:37avishaior do i have to deliver some magic keyword to mark the promise as broken
17:38hyPiRionscape: I have no idea how that library work, but UnsatisfiedLinkError is thrown by the JVM whenever one tries to call a native method, but is unable to find it. I guess you need to include some native DLL or SO or something.
17:39scapeinteresting, ok. if i nest the call in (proxy [ApplicationListener] [] ) then it will work, this is strange to me since the class exists in a different interface, graphics
17:39scapei'll see if there is a native library i'm missing
17:45lpetitgreetings
17:46scapeavishai, you could break the promise as you suggest with some flag you recognize
17:47noonianavishai: to me, the promise is that you will deliver a value. I think instead of breaking it you want to return a different value than normal, often nil, so that the receiver isn't stuck blocking if it dereferences the promise
17:51AtKaaZ,(contains? [1] 1)
17:51clojurebotfalse
17:51AtKaaZ,(contains? [1,2] 1)
17:51clojurebottrue
17:51AtKaaZwhat am I missing here?
17:52AtKaaZoh that's right
17:52AtKaaZ,(contains? [1] 0)
17:52clojurebottrue
17:52AtKaaZi don't even want to know, something about indexes
17:53hyPiRion,(doc contains?)
17:53clojurebot"([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."
17:53hyPiRionemphasis on key, there.
17:53lpetittechnomancy: ping
18:02clj_newb_2345anyone know of a good tutorial on _implementing/writing_ PEG parsers in Clojure?
18:02clj_newb_2345I don't want to use use a PEG parser; I wnat to understand how to implement one.
18:04bbloomclj_newb_2345: check out the source code to instaparse. it's not a PEG parser, it's a full CFG parser, so the algorithm will be different, but the clojure code will give you the right idea
18:04bbloomfrom there, you can try reading the original paper about PEGs to see how the algorithm differs :-)
18:05dbushenkohi all!
18:05dbushenkowhich is the best unit-tesing library/framework for clojure&
18:06clj_newb_2345bbloom: isn't the only difference "CFG = can be ambigious" "PEG = removes ambiguity by always taking the first"
18:06bbloomclj_newb_2345: that's the only difference in their semantics, but deterministic choice can allow a dramatically different implementation strategy
18:06hyPiRiondbushenko: some are satisfied with clojure.test, others prefer a tool named Midje.
18:07bbloomthe purpose of PEG is the be 1) fast and 2) un-ambiguous after composition
18:07hyPiRionWell, a library, rather.
18:07dbushenkohyPiRion: thanks!
18:07bbloomclj_newb_2345: where by composition, i mean union
18:21gfredericks&(->> (repeat 30000 (cons :x [:y])) (apply concat) (reduce (constantly nil)))
18:21lazybotjava.lang.StackOverflowError
18:21gfredericks^ trying to figure out if that's a bug
18:22gfrederickswe have a sequence that you can do just about anything with with no problems except for reduce it
18:22gfredericksas far as I can tell
18:23hyPiRionthat's a lazy seq, though.
18:23gfrederickssure
18:23amalloygfredericks: i actually think i know what's up with that
18:23gfredericksamalloy: it's bouncing between different reduce impls no?
18:23amalloyyes
18:23gfredericksthis seems avoidable
18:23gfredericksgiven I can wrap the thing in (take 1000000000 ...) and it's okay
18:24hyPiRiongfredericks: yeah, then this is obviously a bug
18:24gfredericksthis is not contrived btw. came up at work and I spent several hours wittling it down to this
18:25gfredericksamalloy: I don't imagine you have a fix in your head?
18:26amalloygfredericks: well, wait for java 9+ and get TCO :P
18:26gfredericksw00t
18:27hyPiRionnot sure why it jumps from IChunkedSeq to Object and back again.
18:27hyPiRionbut that's what it does
18:28gfredericksbecause the seq is an alternation of chunked seqs and regular seqs
18:28amalloyhyPiRion: because (cons:x [:y]) is a two-element sequence, where (seq thing) is non-chunked, and (next thing) is chunked
18:29amalloyand he concats a zillion of them together
18:29rboyd_is ob-clojure meant to have support for code blocks with arguments? doesn't seem to work for me.
18:29hyPiRionshh
18:30kristofIs the Reducers library part of standard Clojure?
18:30hyPiRionthat's stupid, although I can see the rationale for bouncing down to a faster one.
18:30lpetitAre there Counterclockwise users there ?
18:31hyPiRionWould be better if if could jump up instead of down the stack there.
18:32kristofBecause if it's not, I'm wondering what the rationale is in that.
18:32hyPiRionkristof: it is
18:32gfredericksI guess I'll file a ticket
18:32gfredericksno fix to protocols.clj is coming to mind
18:32kristofhyPiRion: So why don't they just reduce map and reduce?
18:33kristofhyPiRion: I mean replace.
18:33gfrederickskristof: reducers are a little trickier to use
18:33gfredericksand only work on special data structures
18:33kristofWell, they work on collections
18:33gfredericksnot seqs
18:33kristofOh, I see
18:34kristofAnd so you don't want to use a reducer in a place where order is important?
18:34gfredericksthat's also true
18:34gfredericksin any case it'd be a backwards incompatible change
18:34hyPiRionkristof: because their semantics are different. reduce is single-threaded, map is lazy. Reducers may be multi-threaded, mappings is eager
18:34gfrederickswhich is not something that rich does just for funs
18:34kristofAh, I see
18:34kristofSo different tools for different jobs.
18:35hyPiRionyeah
18:35kristofCool, that makes sense. Thanks hyPiRion and gfredericks. =)
18:35gfredericksI need a good word to describe my sequence
18:36gfredericksI have something on the tip of my tongue, like "edge case" but stronger
18:36kristofextrema
18:36kristofoutlier
18:36gfredericksit refers to the fact that the sequence is exactly the worse thing given the code that's running
18:37hyPiRiongfredericks: a "sequence with oscillating chunkedness"?
18:37gfredericksworst*
18:37gfrederickshyPiRion: too long for the ticket title :)
18:37gfrederickspathological
18:37gfredericksthat's it
18:38gfredericksit seriously weirded me out that (map (constantly nil) coll) was bad but (take 100000000 coll) was okay
18:38kristofI was going to say a Murphy. :P
18:38gfredericksmakes sense now though
18:38hyPiRiongfredericks: map or reduce?
18:38gfrederickshyPiRion: I'm talking about passing the results of those to reduce
18:39hyPiRionoh, right
18:39gfredericksmap preserves the alternating chunkiness but take masks it
18:39hyPiRionchunky/funky
18:46gfredericksCLJ-1237 it is: http://dev.clojure.org/jira/browse/CLJ-1237
18:49hyPiRionwatched
18:49hyPiRionNow I'll get an email about the fix in 1.5 years
18:50hyPiRionwooho
19:10gfredericksI guess we could trampoline the whole thing, but that seems lame
19:10gfredericksmaybe not a deal-breaker for perf though?
19:10gfredericksit'd probably be constant-time overhead for most uses
20:47teI'm trying to make System/getenv a bit friendlier since its a java.util.Collections$UnmodifiableMap
20:48teI'd like to do (:foo (System/getenv)) as well as (get (System/getenv) :foo 33)
20:48teI'd also like to treat the map from System/getenv as a map with indifferent access
20:49teso I can use :foo, even if the map itself has a key of "FOO".
20:51tealso, i always wonder why clojure.walk doesn't have a more generic hash-map walker/modifier
20:53tein addition to keywordize-keys and stringify-keys it'd be nice to see a form which takes takes a pred and form, pred checks whether key meets pred, if so, apply form, same for keys
21:08tehttps://gist.github.com/devn/6096924
21:08teDoes anyone see why that couldn't be included in clojure.walk? After all, there postwalk-demo lives in there.
21:19amalloyte: (a) clojure.walk is dead and buried; (b) that doesn't really walk over a generic data structure recursively like everything else in clojure.walk
21:20teamalloy: im confused -- stringify-keys and keywordize-keys do the exact same thing as those fns, they just dont expose pred and f as args.
21:20teamalloy: i wasn't aware that clojure.walk was dead -- why do you say that? what took its place?
21:22amalloyoh, you're using postwalk. i thought you used map, ie nonrecursively
21:23amalloymostly what's taken the place of clojure.walk is a realization that it is slow, unwieldy, and doesn't work very well with several data types (eg, records), so that it's better to just start from scratch than use a not-quite-right lib as a starting point
21:26bbloomamalloy: stuart recently published this: https://github.com/stuartsierra/clojure.walk2
21:26bbloombased on protocols, supports records :-)
21:27tethere's no refuting that it doesn't work with some data types, but i often wind up pulling in clojure.walk simply for keywordize-keys or stringify-keys. I don't see why adding some more general versions of those functions would be a terrible addition.
21:28bbloomgood call :-)
21:28bbloomstuart might require you have a clojure contributor license, in case he plans to get this integrated back into clojure proper
21:33tei have one
22:05vraidhow does "frame.getContentPane().add(canvas)" translate into clojure?
22:06vraidi can't seem to fit the 'add' in there
22:06bbloom(doc ..)
22:06clojurebot"([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on the result, etc. For instance: (.. System (getProperties) (get \"os.name\")) expands to: (. (. System (getProperties)) (get \"os.name\")) but is easier to write, read, and understand."
22:11amalloy(-> frame (.getContentPane) (.add canvas))
22:12amalloyor, if you prefer, (.add (.getContentPane frame) canvas)
22:15thm_proverdoes peg == packrat parsing, or are they different things?
22:15bbloomone is a formalism, the other is a possible algorithm for implementing it
22:16vraidamalloy: the last one worked, thanks
22:17thm_proverso it's like binary search tree :: red-black tree ?
22:17Raynesvraid: Pretty sure they both worked, right?
22:17bbloomthm_prover: eh, close enough
22:18thm_proverbbloom: why are you so knowledgable ?
22:18bbloomthm_prover: abstraction & concrete implementation is one way to look at it, yeah
22:18teI'm trying to make System/getenv a bit friendlier since its a java.util.Collections$UnmodifiableMap and I want to have indifferent access to keys so I can say (:foo (System/getenv)), (get (System/getenv) :foo) even though k/v pairs in the result are {"FOO" "BAR", "BAR" "BAZ"}.
22:19bbloomthm_prover: b/c i spend more time reading doing a pruning search across a citation graph, than i do reading the top N items on hacker news ;-)
22:19vraidRaynes: ah, right, i missed the ->
22:19thm_proverbbloom: ouch :-)
22:19teim currently doing this: https://gist.github.com/devn/46b4f7a871e1ac0d5b9a
22:20tepretty sure im doing it wrong
22:20bbloomthm_prover: wasn't intended as an insult to either you or HN
22:20tos9te: Why's that friendlier, the environment is case sensitive
22:20thm_proverbbloom: no, it's so true though
22:20thm_proverbbloom: HN provides the drug-like-feeling as if I;m learning somethig new
22:20thm_proverbbloom: but it's one thing to know that X exists; it's another thing to have a formal definition of X; and it's entirely different to be able to use X understand how X is implemented
22:20tetos9: okay then, throw out the case insensitivity -- i'd like indifferent access
22:21bbloomthm_prover: my understanding comes from implementation. go make things!
22:22bbloomfake it until you make it, it works
22:22thm_proveri recall this other statement
22:23thm_proverthe best performance improvement is not "exp time to linear time", it's "not working to exp time
22:23justin_smithte: for one thing, it seems that you are keywordizing-keys, but using the name of the key to do the lookup
22:23justin_smithone of those should probably be skipped
22:23justin_smithon one side making keyword out of string, while on the other making string out of keyword - like two ships in the night
22:24tejustin_smith: pay no attention to that impl. -- the question is still about indifferent access
22:25tenamely the (:foo {"FOO" "BAR"}) case
22:32te(:term (System/getenv)), for instance, throws: ClassCastException clojure.lang.Keyword cannot be cast to java.lang.String java.lang.ProcessEnvironment$Variable.valueOfQueryOnly (ProcessEnvironment.java:144)
22:32teis there any way around that or no?
22:32tejustin_smith: also, see updated gist https://gist.github.com/devn/46b4f7a871e1ac0d5b9a
22:40justin_smithte: is the "get" that you are referencing in EnvMap actually the same "get" that :keyword uses when called?
22:40justin_smithwhen I run your code in a repl I get warnings that the new get is repacing the previous core/get
22:41justin_smithI think :keyword is still using the previous core/get, and user/get isn't even coming into play with (:term (System/getenv))
22:42justin_smithuser> (get (System/getenv) :term) => "dumb"
22:42justin_smith
22:42justin_smiththat totally works with your code
22:45justin_smithyeah, (clojure.core/get (System/getenv) :term) throws the same error (:term (System/getenv)) does; I am not sure how you would redefine/extend what a keyword does when called, but just defining get in a new namespace definitely won't do it
22:46clj_newb_2345is there a clojure builtin that mimics the "shift" on US keyboards? i.e. a -> A, b -> B, 1 -> !, 2 -> @, ..., [ -> {
22:48justin_smithclj_newb_2345: you could define it, it would be a little tedious - {\a \A \b \B ...} etc.
22:48clj_newb_2345yeah, the berst I have is to define all but a-Z
22:48clj_newb_2345and then use to upper case for a-z
22:49justin_smithclj_newb_2345: I would be tempted to just use a map, but then you can't use upper-case
22:49clj_newb_2345union + map
22:50justin_smith,(apply str (map {\a \A \b \B} "ababab))
22:50clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
22:50justin_smithoops
22:50justin_smith,(apply str (map {\a \A \b \B} "ababab"))
22:50clojurebot"ABABAB"
22:53justin_smiththe reason I would always be inclined to use a map rather than a function with conditionals is it makes code much easier to read, and fewer moving parts leads to more solid code
22:55justin_smiththough of course a 101 key keyboard is a pretty big map
23:00justin_smith,(into {} (map (fn [c] [(char c) (-> c (- 32) char)]) (range (int \a) (int \z))))
23:00clojurebot{\a \A, \b \B, \c \C, \d \D, \e \E, ...}
23:05justin_smithhttps://www.refheap.com/16989
23:06justin_smithclj_newb_2345: that link has something that should work
23:06clj_newb_2345justin_smith don't we need: (+ (int \z) 1) ?
23:07justin_smithwhy?
23:07clojurebotwhy not?
23:07justin_smithahh
23:07clj_newb_2345, (range 1 10)
23:07clojurebot(1 2 3 4 5 ...)
23:07clj_newb_2345, (range 1 3)
23:07clojurebot(1 2)
23:07justin_smithyeah, you are right
23:08justin_smith,(range (int \a) (inc (int \c)))
23:08clojurebot(97 98 99)
23:13clj_newb_2345justin-smith: https://gist.github.com/anonymous/6097177 not as elegant as your code; but avoids lots of \'s
23:15justin_smithyou don't like \?
23:19justin_smithI, on the other hand, prefer to avoid #
23:19justin_smithheh
23:25clj_newb_2345justin_smith: nah, inputting 1! is "1 shift 1", whereas \1 \! is "\ 1 \ shift 1"
23:26clj_newb_2345in the context of core.async, how does >!! and >! differ?
23:26gfredericks>! is only allowed in a go block
23:26gfredericks>!! does actual blocking
23:27justin_smithclj_newb_2345: what I am trying to minimize is the (human) read overhead
23:28justin_smithI tend to read things many times for every once I write them
23:28clj_newb_2345!! <-- blocks a real Java thread; ! <- blocks a "light weight go thread" ?
23:28clj_newb_2345gfredericks: is the above interpreation correct?
23:31gfredericksclj_newb_2345: sounds right
23:31gfredericksthe translation to cljs is !! is not allowed
23:33gfredericks(def unchunk (partial take Double/POSTIVE_INFINITY))
23:35justin_smithgfredericks: what would that do that doall would not?
23:35clj_newb_2345(create a channel, write one msg to it, read from it) * 1000 = 342 milliseconds <-- is this timing about right fore core.async?
23:35gfredericksjustin_smith: return a sequence that isn't chunked
23:36gfredericksjustin_smith: also it would not realize the sequence
23:36gfredericksso it has very little in common with doall
23:36justin_smithahh
23:36justin_smithcool, thanks