#clojure logs

2014-11-16

00:00oskarkvi don't remember what i did before :P
00:00andyftools.namespace is a more general solution, but the (use ns :reload) is fine if you just want to reload a single namespace
00:00andyfand do not have many namespaces to deal with in your project
00:02andyfIf you have just a small number, (require '[my.namespace.name :as myns] :reload) might be preferable, to avoid bringing in all of your Vars together into the user namespace
00:04munderwoHi all. im attempting to play around with datomic, and use the repl thats shipped. I was wondering if anyone knows if it has a nrepl port built in? or how I could expose it to cider?
00:08marchdownI did it! https://gist.github.com/marchdown/d1388e064570439a39fb thanks guys. (that’s non-gender-specific _guys_ if anyone cares.) Off to write some tests.
00:09andyfexcellent
00:35TEttingermarchdown: brosephina is probably acceptable as a gender-neutral substitute for guy
00:39sohumhey, so I have a flawed little recursive program here that never bails out of its recursion, but the interesting thing is it never StackOverflowError's either
00:40sohumit just infinite loops
00:40j201sohum: tail call optimized?
00:40sohumI'm not using recur, so I don't _think_ any TCO is going on...
00:40j201hm
00:56andyfsohum: Is there any looping going on within one "level" of the recursive function?
00:57andyfAn infinite loop at one level could give inf loop without stack overflow
00:59sohumandyf: I'm not sure what that would look like, but here's the minimal-as-far-as-I-can-tell example of this behaviour http://pastebin.com/6Y98s9UV
01:02zerkmssohum: how does it stop actually?
01:02sohumzerkms: it doesn't!
01:03sohumI'm going to leave an instance of this running in a different shell, to see if it does StackOverflowError, just a long time later
01:03sohumif it's, I dunno, trying to do increasingly complicated arbitrary precision arithmetic, or something
01:05zerkmsthat's strange
01:05sohumyes, it is :D
01:05sohumwell, it's certainly pegging a cpu
01:06zerkmsI changed it to be 2 levels only, without invoking average
01:06sohumclojure 1.6.0, if it matters
01:06zerkmsand now it overflows
01:07sohumoh, really?
01:07zerkms(defn improve [guess x]
01:07zerkms (/ x guess))
01:07zerkmswith this
01:07zerkms(I understand I've broken the computation logic, but still)
01:07sohumoh, I've been stripping parts out myself, too
01:08sohumbut interestingly,
01:08sohumif you put that logic back into improve, without the function call
01:08sohum(defn improve [guess x] (/ (+ guess (/ x guess)) 2))
01:08sohumit still loops forever
01:08zerkms:-S
01:08sohumso, yes, something about the arbitrary precision arithmetic
01:09zerkmsI'm curious to ask it on stackoverflow
01:09zerkmswould you?
01:09sohumyea, I'm definitely curious
01:09sohumis there a clojure stackoverflow, or should I just use the normal one
01:11zerkmshttp://stackoverflow.com/q/26954404/251311
01:11zerkms:-P
01:11sohumwell fine :p
01:12dbaschsohum: you neglected to say that you’re running it with a long and not with a double
01:13dbaschif you try it with 1.0 and 4.0 it stackoverflows quickly
01:14sohumdbasch: oh, I guess 1 and 4 default to longs?
01:14dbaschsohum: they are longs
01:14sohumyes, so it's _definitely_ the arbitrary precision arithmetic, then
01:15dbaschit’s computing very long rationals
01:17sohumI don't know why that stops it from throwing a StackoverflowError, though, unless it _eventually_ will
01:17dbaschsohum: it will but it will take a while
01:17andyfWild guess: It will stack overflow eventually, but very slowly, because the arguments you are using cause it not to allocate new Longs.
01:18sohummmm
01:18sohumyeah, that makes sense
01:19zerkmsandyf: so they are integers?
01:19dbaschif I run it with 1.0 and 4.0 it stackoverflows after ~6500 calls on my machine
01:20dbaschbut if I run it with longs it gets very slow after 10 calls
01:20dbaschso most likely you won’t see it blow the stack
01:21sohumyeah, I've had it running for twenty minutes on my machine, and still none
01:21sohumit's just getting very, very slow
01:21sohumthat makes a lot of sense
01:23clojure_beginnerWhat is the best book to learn clojure from ? I am currently using Programming Clojrue 2nd edition
01:25andyfhmm. If you give it integers, not doubles, then the intermediate results are rationals, which get to be BigInteger numerators and denominators very quickly
01:26andyfthe size of those BigIntegers seems to approximately double with each recursive call of sqrt-iter
01:26clojure_beginnerWhat is the difference of reduce and apply ?
01:27andyfI don't know what the run-time of the BigInteger arithmetic ops are, but I wouldn't be surprised if it was linear in the size of the integers for addition, and the product of their sizes for multiplying
01:27pdkreduce takes a function F that accepts two arguments and a sequence
01:27zerkmsclojure_beginner: apply - invokes a function with arguments
01:27zerkmsand reduce converts a sequence into somethingelse
01:27pdkcalls F on the first two items of the sequence, then calls F with the result of the first call and the third item of the sequence, repeats until end of the list
01:28pdkeg (reduce + [1 2 3 4]) would add 1 and 2, add the result of that to 3, then add the result of that to 4
01:29pdkif i recall apply essentially lets you unpack a list of arguments to a function and call it with them
01:29clojure_beginnerAhhh I see.
01:29pdk,(apply + 1 2 [3 4])
01:29clojurebot10
01:29pdkyea
01:30clojure_beginnerOk, I understanded already how reduce worked, I got confused because sometimes I was able to use reduce or apply and it worked the same
01:30pdkso if you have a case where some or all of the arguments you want to give to a function are stored in a list
01:30clojure_beginnerthanks for explaining apply, now I understand, unpacking the list of arguments and calling the function with that arguments
01:30pdkyou can put the list as the last argument in your call to apply and it will essentially take each item in the list out to pass as an argument to whatever function you're applying
01:32clojure_beginneryo uactually put vector as the last argument not a list
01:32zerkmsit may be any sequence
01:32clojure_beginneraha ok
01:32zerkms,(apply + '(1 2))
01:32clojurebot3
01:32zerkms,(apply + #{1 2})
01:32clojurebot3
01:33pdkvectors lists and lazy sequences are broadly grouped together as seqs
01:34clojure_beginneryeah, I learned that today :) So basically I can do (reduce str (reverse "Hello")) or (apply str (reverse "Hello"))
01:35clojure_beginnerbut this is just because str takes 2 or more arguments
01:35pdkyea
01:35pdkreduce will always call the passed function with 2 arguments
01:36pdkapply will call it with as many arguments as you give it
01:36clojure_beginnerI see. It is clear now, thanks. But which solution is faster ?
01:36pdkname the use case
01:36zerkmsspeed doesn't matter
01:36zerkmssemantics does
01:36TEttingerfor str, apply
01:36TEttingerI think
01:36pdkmost likely
01:36pdkapply is just making a single call to str with a bunch of arguments for you
01:37pdkreduce is going to call str N-1 times for an N item list
01:37TEttingerreduce creates temporary two-element collections to call str on
01:37zerkms(apply str (reverse "Hello")) <--- this actually does not work as you expect
01:37clojure_beginnerso basically those for appy and reduce return a lazy sequence ?
01:37pdkso it will invoke a lot of intermediate calls
01:37zerkmsbecause it calculates the (reverse) call
01:37pdkapply will just return whatever the function given returns
01:37pdksimilarly reduce can return whatever
01:38pdkeg reducing + over a list of numbers returns the sum of that list
01:38clojure_beginneraha, so apply is not part of the list comprehensions functions
01:39pdkit can let you call a function with an arbitrary number of arguments at runtime but it's still only calling that function once and returning its result
01:41clojure_beginnerAha ok, so (apply + [1 2 3 4] [5 6]) is basically just doing (+ 1 2 3 4 5 6) at runtime
01:41pdkiirc only the last argument to apply gets unpacked if it's a list
01:41pdk,(apply + [1 2] [3 4])
01:41clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number>
01:41pdkyea
01:42pdkall arguments before the last get preserved as is
01:43clojure_beginnerah, nice gotcha
01:43pdkit lets you supply fixed arguments at the beginning
01:44clojure_beginneryea
01:44pdk,(reduce concat [1 2] [3 4] [5 6])
01:44clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core/reduce>
01:44pdkhm
01:44pdk,(apply concat [1 2] [3 4] [5 6])
01:44clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
01:44TEttinger,(apply map [inc [1 2 3]])
01:44clojurebot(2 3 4)
01:44zerkms,(apply concat [[1 2] [3 4] [5 6]])
01:44clojurebot(1 2 3 4 5 ...)
01:45TEttinger,(concat [1 2] [3 4] [5 6])
01:45clojurebot(1 2 3 4 5 ...)
01:45pdki assume there's gotta be some standard function to concatenate a series of lists together
01:45TEttingerconcat you mean?
01:45pdkwell yeah :p
01:46pdkoh wait now i see why it didnt work
01:46pdk,(reduce concat [[1 2] [3 4] [5 6]])
01:46clojurebot(1 2 3 4 5 ...)
01:46pdk,(reduce + (reduce concat [[1 2] [3 4] [5 6]]))
01:46clojurebot21
01:46pdkthat's one way you could accomplish what you intended with the (apply + [1 2 3 4] [5 6]) example
01:46clojurebotTitim gan éirí ort.
01:46clojure_beginnerthat returns LazySeq pdk
01:47pdkyea
01:47pdkit's lazily concaenating all of the lists together into one
01:47pdkthen reducing + over the combined lazy sequence
01:47clojure_beginnerSo basicaly what is returned is not the end result yet..
01:47TEttinger,(into [] [1 2] [3 4] [5 6])
01:47clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core/into>
01:47TEttinger,(into [] [[1 2] [3 4] [5 6]])
01:47clojurebot[[1 2] [3 4] [5 6]]
01:47TEttingerhm
01:47clojure_beginnerOnly when you say for example (nth 9 my-seq) you get a result
01:48pdkyes
01:48pdklazy sequences defer calculation of the actual list values until the point they're requested
01:48pdkand only so far as needed to fulfill the request
01:48clojure_beginneraha
01:48TEttinger,(into [1 2] [3 4])
01:48clojurebot[1 2 3 4]
01:49pdkthis allows for generating infinite lists or lists where each item takes a large amount of memory without exhausting resources while also letting regular functions be agnostic to what type of list they're dealing with
01:50pdkfair warning though that if you hold onto the head of a 1 million item lazy seq when you're already at the million item then all the intermediate items will still be in memory
01:50pdkat the millionth item*
01:51clojure_beginneryea I read about it, then you have some doall and dorun functions that actually walk over all the sequence before returning it
01:51pdkyea they force evaluation of the list
01:51clojure_beginnerdorun does not keep the previous value of the seqence in memory, only current value i believe
01:51clojure_beginnerWhat would be the use case of this ?
01:52clojure_beginnerif you want to make some temp calculation with elements from the seq ?
01:53pdkusually the do* functions are useful for code that has side effects
01:53clojure_beginneraha, so by side effects you mean the function does something else not related with its return value
01:53pdkyes
01:54pdkusually i/o or changing an object's state or global state
01:54clojure_beginnercool.
01:58clojure_beginnerThanks pdk. Clojure is so interesting. I sure won't be learning it in 21 days :)
01:58clojure_beginnerI give it 2 years :)
01:58pdkdepends a lot if you're coming into it with an existing lisp background
01:59luxbockclojure_beginner: check out https://www.4clojure.com/problems if you haven't already
01:59luxbockvery fun way to get started
02:00clojure_beginnerno lisp background, just java, ruby, some c. I was learned OO ways, which I am starting to doubt in
02:00clojure_beginnerThanks luxbock, I'll take a look
02:01clojure_beginnerI can sense the future will be bright for clojure, but I can not understand why TIOBE index is not showing it yet.
02:03clojure_beginnerwow, great resource
02:03amalloyclojure_beginner: there's a google group for discussing 4clojure problems, if you need assitance
02:06clojure_beginnertnx amalloy, I am sure I will use that mailing list. . Already registered to 4 clojure now, so Ill be doing that today :)
02:09kenrestivowhat i'm trying to do can't be impossible nor has it likely never been done, but i can't find any working examples: stuffing the input and output of a shell process into core.async channels
02:35amalloykenrestivo: get it as a seq via line-seq, and then use onto-chan or whatever it is?
02:36kenrestivook, will try that
02:42kenrestivoaha, buffering is ruining my day
02:43kenrestivoi've tried with clojure.java.io, raw (.exec (Runtime/getRuntime)...), and conch. the issue is in java-land somewhere, buffering.
02:44kenrestivoi think i got it, nevermind. thanks!
03:15kenrestivougly, but works! https://www.refheap.com/93446
03:20borromakotI'm fairly new to clojure, but I'm trying to find a way to get a range from 1 to infinity. I want to (take-while pred (range 1 infinity), but pred returns true for two things, which are 0, and the answer. I don't want to modify pred, as it SHOULD return true for 0.
03:20borromakotany ideas?
03:21borromakotthe fact that pred returns true for 0 means I can't just say (take-while pred (range))
03:23zerkmsborromakot: (iterate inc 1)
03:23borromakot:zerkms facepalm thank you!
03:24borromakotthat being said, I'm doing a project euler problem and my solution is almost definitely a bad one.
03:25TEttingeralso,
03:25TEttinger,(rest (range))
03:25clojurebot(1 2 3 4 5 ...)
03:25TEttingerrest returns a lazy seq
03:26borromakotnice
03:27borromakotAt first, I was under the impression that clojure was really difficult to understand, and it gave me a lot of trouble. Something clicked a few days in and I realized its far simpler than almost any other language I've come across.
03:27TEttingerit's funny how that is, huh
03:27TEttingerthe symbols are part of it
03:27TEttingerbut the way data is in clojure is so elegant
03:27borromakotthe whole damn language is just (function args)
03:29borromakotI'm not sure if they would be called special forms or not, but other languages are filled with these special language forms and control flow things.
03:29kenrestivomessing with all this shell and channels stuff, i've never restarted my jvm and repl so many times before
03:30kenrestivoit's an emacs-using-100%-CPU and java-using-200%-CPU kind of experience
03:30jack_rabbiteww.
03:31borromakotkenrestivo: what are you doing that requires all that?
03:32kenrestivonothing at all. it just tends to happen.
03:32borromakothave you tried lighttable?
03:32kenrestivothere's a lot of just runaway loops, <!! endlessly returning nil
03:33borromakotlol
03:33kenrestivoclosed channels, orphaned processes, unkillable threads
03:33kenrestivoit's amusing in it's botched-ness.
03:35borromakotI've just started learning myself, doing some project euler projects and the like, so I haven't gotten to that point.
03:35borromakothope I never do
04:20kenrestivooh, euler projects won't do that to you. dealing with java interop and unix processes and such will
04:21kenrestivostay in the nice, safe world of pure functions and you'll be fine :-). it's all that side-effecting stuff where the ugliness is
04:27dysfunkenrestivo: you said unix. yes. well. i'm just waiting for the better thing that isn't coming
04:27dysfunlike the double-fork idiom for daemonising
04:27dysfunewwww
08:12justin_smithso, for this contract job, I promised to be on GMT time until after the deadline...
08:13Bronsajustin_smith: and what would your timezone be?
08:13justin_smithUS west coast
08:13justin_smithso I'll be adjusting a bit
08:14justin_smithbut I live in Portland, where the sun is rarely out, so it's just an arbitrary number that is changing for the most part :)
08:15justin_smithI just got my system time zone set up so everything on my computer tells me it is GMT
08:15Bronsa8hour offset is a bit crazy
08:15justin_smithyeah, it is
08:16justin_smithbut I can handle it for a few days
08:16Bronsaah ok, I thought it was for an extended period of time
08:16justin_smithoh, no
08:16justin_smithyeah, that would be a big commitment
08:16justin_smithwe're in the final stretch here
08:17BronsaI've lived in a 5/6 hour offset for most of the summer but irl stuff makes it really hard
08:17justin_smithI'm taking a shell script with - no joke - 72 stdio stream redirects, that keeps crashing, and trying to do it in clojure so that each individual process can be restarted
08:18justin_smithinstead of "oh, one of your 144 programs crashed? whole thing goes down"
08:18justin_smithmaking me wish I knew erlang :)
08:18Bronsayeah that sounds like it would be the perfect fit for this kind of thing
08:18Bronsabut I don't know any erlang myself
08:20justin_smithit is kind of hilarious using a for comprehension to build all the redirect clauses in one shell invocation
08:21clojureRule(defn av [x] (.java.lang.Math.round (/ (reduce + x) (count x))))
08:21gfrederickscoooomputers
08:21justin_smithgfredericks: seriously tho
08:21gfredericks,(Math/round 41.9)
08:21clojurebot42
08:21clojureRuleNo matching field found: java.lang.Math.round for class java.lang.Long clojure.lang.Reflector.getInstanceField (Reflector.java:271)??
08:21lazybotclojureRule: Definitely not.
08:21justin_smithuhoh
08:22clojureRulehow to fix thetype/
08:22gfredericksclojureRule: ^ I showed you up there
08:22Bronsalol I thought clojureRule was clojurebot for a second
08:22justin_smithBronsa: I was afraid it was a new bot
08:28clojureRule(Math/round (+ 1 2 3)) ,wont run with integers,my question is if i would difficult to mix static libraries with a dynamic languange
08:29clojureRule,(Math/round (+ 1 2 3.1)) works ok
08:29clojurebot6
08:29clojureRule,(Math/round (+ 1 2 3)) works ok
08:29clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: round>
08:32justin_smith,(Math/round (+ 0.0 1 2 3))
08:32clojurebot6
08:32clojureRulewhenever i use a java librarie , i have to be carefull to call with the exact type ? (Math/round (/ (+ 2 3) 2)) in a dynamic languange is 2,
08:33clojureRuleso i have to take care of the types when calling java libraries...?
08:33justin_smithwell, even with normal clojure, sometimes types are an issue
08:33justin_smith,(pop [1 2 3])
08:33clojurebot[1 2]
08:33justin_smith,(pop '(1 2 3))
08:34clojurebot(2 3)
08:34justin_smith,(pop (list 1 2 3))
08:34clojurebot(2 3)
08:34justin_smith,(pop (map identity [1 2 3]))
08:34clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IPersistentStack>
08:34justin_smithso you either get the beginning elements, the ending ones, or an error
08:34justin_smithbased on type
08:34Bronsawoah, I didn't know PersistentList implemented IPS
08:36clojureRulethe problem is tha jvm is build for static languanges/
08:36justin_smithBronsa: it's useful - if you don't need quick indexed lookup on a stack, and want lifo, then PersistentList is your best bet
08:37justin_smithclojureRule: well, we also want the performance you can only get if you specialize on types a bit
08:37justin_smithfully generality has a price
08:38clojureRulei was thinking about clojurescript tha runs on a dynamic vm
08:38Bronsajustin_smith: I frequently forget about the existence of pop/peek. I think I've written (nth v (dec (count v))) a bunch of times because of that
08:38justin_smithhaha
08:38clojureRuleis clojurescript slower tha clojure?
08:38justin_smithgenerally, yes. Also the development toolchain is more complex / weirder.
08:40clojureRulethanks room :) have a nice day with lots of clojure
08:40justin_smithyou too
09:08gfrederickspop with vectors makes me realize you could probably write multipop pretty efficiently inside the vector class but I'm not sure it's possible otherwise
09:08gfrederickslike a constant-ish time impl I mean
09:08gfredericks(in contrast to transients which would be linear time)
09:10gfredericksnot that I've ever needed that.
09:28justin_smithmultipop?
09:32gfrederickslike pop 10 things
09:32justin_smithahh, right
09:32justin_smithyou'd want multipeek to go with it
09:32gfredericksif I have a vector of 5,000,000 elements and I want to pop 3,000,000 of them
09:32gfredericksmultipeek doesn't make as much sense
09:33llasramAren't those things both already O(1) via `subvec`?
09:33gfredericksyes, but subvec has a big asterisk though
09:33gfredericksof the "memory leak" flavor
09:33gfrederickswhereas multipop you could do in the proper fashion
09:33llasramAsterix the Gaul is actually pretty small
09:33llasramGotcha
09:35gfredericksI think multipeek would just be subvec though
09:39Bronsagfredericks: isn't subvec your multipop?
09:43gfredericksBronsa: see above
09:44gfredericksbasically multipop is a special case of subvec that could remove the memory leak
09:44hyPiRiongfredericks: yeah, takev is O(~1). As efficient as WC pop.
09:44gfredericksWC?
09:44hyPiRionworst case
09:45justin_smithhyPiRion: is takev a thing?
09:46gfrederickspresumably means the same thing as multipop and is just as unreal
09:46justin_smithI can't find it in clojure 1.7-alpha3
09:46gfredericksoh I guess it takes a slightly different arg
09:46hyPiRionjustin_smith: not yet, but multipop is just a different name on take
09:46justin_smithgfredericks: specifying the amount to leave rather than remove
09:46justin_smithhyPiRion: itym drop
09:46hyPiRionjustin_smith: itym?
09:46justin_smithtakev / dropv would be good names
09:46justin_smithI think you mean
09:46justin_smithpop tells you how many to remove
09:47justin_smithnot how many to keep
09:47gfredericksno drop is the thing you *can't* do better than subvec
09:47gfredericksbut take you can
09:48justin_smithoh, I thought the idea with multipop was "pop n times", but you meant "pop until n remain" ?
09:48hyPiRionjustin_smith: no, but one can be represented by the other
09:48gfredericksright, doesn't matter
09:48gfrederickscall one multipop and the other takev
09:48hyPiRiondrop-lastv is probably a better name
09:48gfredericksbut they're the same impl
09:48gfredericksokay
09:49gfrederickstakev & drop-lastv
09:49gfredericksimplemented in terms of each other
09:49gfrederickslike some sort of weird haskell typeclass
09:49hyPiRionyeah
09:51gfredericksmy point though is I don't think you can do this at all without doing it inside the PV class[es]
10:47engblomBesides just indentation (which both vim and emacs does), is there a tool for tiding up a file? Something breaking up a long line in a sane way?
10:50Nathellengblom: pprint?
10:50engblompprint will remove comments and make some stuff really strange
10:51engblom,(pprint '#(+ 1 %))
10:51clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: pprint in this context, compiling:(NO_SOURCE_PATH:0:0)>
10:52gfredericksyeah pprint is not meant for code at all
10:52gfredericksI've thought a customizable auto-formatter would be an excellent lib; but probably difficult.
10:55justin_smithgfredericks: I bet a script you could run based on emacs -q would work (just launch emacs as an elisp interpreter, load clojure-mode, format the file, write to stdout)
10:55gfredericksdoes clojure-mode do a decent job of formatting *arbitrary* code?
10:55justin_smithso even people who don't want to interact with emacs can still get the formatting
10:55gfredericksI thought it just indented
10:55justin_smithhmm
10:55engblomIt would be quite nice if you could specify the width of the file and the script would make sure the file never gets wider and formats it according to that.
10:56justin_smithyeah, you would need some extra logic for real formatting I think
10:56gfredericksand a requirement for this is a round-tripping reader
10:56gfredericksI can never remember if somebody's written that or not
10:56justin_smithbut emacs clojure-mode already has a bunch of the logic, and is already runnable as a non-interactive tool, so it may be a decent start
10:56mavbozoC language has formatter that can change your code format to allman, k&r, or stroustroup style
10:57gfredericksmy ideal is a tool where you can put the config file for it in your repo and wire up git or tests to enforce it
10:57engblommavbozo: It was the fact that C has this that caused me to ask if Clojure has it.
10:57mavbozodo we--lisp programmers, has such styles?
10:57gfredericksanother thing you'd need is a way to declare which vars deserve macro-style indentation
10:58mavbozoengblom: even Common Lisp does not have it
10:59mavbozomaybe we--clojure programmers, has one format style already, let's call it bbatsov https://github.com/bbatsov/clojure-style-guide
10:59gfredericksI think that guide has some non-standard things in it
11:02mavbozoengblom: and the fact that Common Lisp does not have a program to automatically format code
11:02mavbozoengblom: makes me think that such a program is really hard to make that those smart common lisp people still could not build it
11:05gfredericksmavbozo: probably one thing that makes it hard is that due to macros the meaning of form structures is somewhat open-ended
11:11justin_smithI think you could get pretty far with a formatter that did no parsing, but just had special case rules for various flavors of macro, and then just applied function rules for everything else
11:12justin_smiththen you can give it a config file for the macros that should use various indenting flavors (ie. tell it for is indented using the same rules as doseq)
11:13justin_smithnot a clojure parser, or even editor, just going through and removing/adding whitespace until things are good
11:15gfrederickswhat do you do when it gets something wrong?
11:15gfredericksat least in emacs you can manually opt out by formatting it yourself and trying really hard not to autoformat that form again
11:15gfredericksI'd like a workflow like gofmt where you can make the tool authoritative
11:18llasramThat would be nice... Last time I tried to create some organizational style guidelines my team at the time failed to agree on anything at all, even a maximum line length
11:19justin_smithgfredericks: if all it did was make whitespace changes, and it was good about strings, what could it break?
11:19gfredericksum
11:19gfredericksidunno
11:20justin_smithwhitespace changes as in replace one range of 1 or more whitespace characters with some other range of 1 or more characters, and never adding it (except perhaps betwen ')(' etc.)
11:21gfrederickswould it ever add/remove line breaks?
11:21TimMcjustin_smith: comments
11:21llasramI was wondering something related recently. Are there any cases in Clojure where the presence or absense of whitespace *between* complete forms would change the interpretation on reading?
11:22gfredericksllasram: well in some cases I think no whitespace would make it one form
11:22llasramgfredericks: Such as?
11:22TimMca b
11:22gfredericks,(map count [[:foo:bar] [:foo :bar]])
11:22clojurebot(1 2)
11:22llasramOh duh
11:22gfredericksa b is good too :)
11:22gfredericks(inc TimMc)
11:22lazybot⇒ 80
11:22justin_smithTimMc: OK, I think the set of rules would be pretty small, tractable, and doable in a tool like elisp or even perl that doesn't actually know any clojure
11:22llasram(int TimMic)
11:22llasram(inc TimMic)
11:22lazybot⇒ 1
11:22llasramGeez, typing toda
11:22llasramI apparently need to turn up the heat a bit
11:23llasram(inc TimMc)
11:23lazybot⇒ 81
11:23llasramI went straight to thinking about tagged literals and missed the forest for the trees
11:23gfrederickswe could start with a rudimentary tool if there were a rigorous opt-out mechanism
11:24gfredericksthen improve it as things come up
11:25Bronsallasram: both tagged literals and record ctor literals don't care about whitespaces
11:27justin_smithso, for implementation, I can see the advantages of using clojure (it's guaranteed available in contexts where you need this tool, right?) but also it may be more apropriate to use a string processing tool like elisp or perl or whatever
11:27gfredericks;; autofmt-ignore +5
11:28gfredericksI feel like committing to something non-clojure is just going to be eternally regretted
11:28gfrederickscompared to the one-time cost of figuring out how to do whatever is hard about it
11:29justin_smithgfredericks: fair point
11:29justin_smithand maybe we would get a sweet string-processing lib for clojure out of the deal
11:29gfredericks:)
11:30gfredericksthe name of the lib should have something to do with yak shaving
11:30gfredericksyak-razor
11:30justin_smithheh
11:30justin_smithyak-barber?
11:32gfredericksis there a good greek/latin prefix related to yaks similar to "hippo-" for horses?
11:32gfredericksapparently the word is from tibetan so I'm not optimistic
11:33llasramYakrazor would be a great name for the sword of a swords&sorcery/programming parody character
11:33dbasch“The yak (Bos grunniens and Bos mutus) “
11:33dbaschgrunniens is a good name
11:34dbasch$google grunniens
11:34lazybot[Yaks | Grunniens Yak Ranch | Tibetan Yak Breeder | Farm - Ranch] http://www.theyakranch.com/
11:34gfredericksbov- can refer to an ox
11:35justin_smithgiven that grench would be a good way to run the tool, grunnien sounds good
11:35justin_smithgr gr gr
11:35TimMc(inc grunnien)
11:35lazybot⇒ 1
11:35dbaschofficial soundtrack of yak shaving https://www.youtube.com/watch?v=ZnHmskwqCCQ
11:36TimMcThat had better be that one Bach piece
11:36TimMcoh well
11:37dbaschclose enough
11:39llasramBach yak shaving?
11:41TimMcyeah, still searching
11:41TimMcyach-shaving
11:45TimMcKleines Harmonisches Labyrinth
11:47TimMcGEB mentions this as a piece that keeps changing key and then changes back but not quite to what it was in the beginning.
11:47justin_smithTimMc: when I youtube it, one of the side bars is "Grelling's Paradox"
11:47justin_smithyet another gr
11:48TimMc("I could swear that I wrote this sweet string-processing library for *something*. Oh well.")
11:50TimMcalthough I don't have enough musical training to hear the missing resolution.
11:51engblomSomeone here had a quil fork for a more functional way of programming. I have forgotten what it was called. I would want to pass down to draw arguments without having some kind of global variable (with def).
11:52justin_smithTimMc: yeah, pop music doesn't really do the whole evolution / tension / resolution paradigm of classical in the same way, and that's what most of us can understand natively as a musical language
11:55engblomI found it myself. Inkwell it is called.
11:56TimMcjustin_smith: I can hear it in a lot of electronic music.
11:57justin_smithTimMc: but electronic music isn't using the same rules - it has it's own cues / rules for tension and resolution, that partly overlap
11:57justin_smithTimMc: one of my big pet peeves is the over-generalization of classical music theory to other music
11:59jeffterrellQuestion: I'm consistently getting a timeout for 4clojure #131, even though it runs locally on the test cases in ~100ms. Any ideas/common pitfalls with 4clojure I should be aware of?
11:59jeffterrellWhere by "it" I mean "my solution".
11:59justin_smithjeffterrell: are you sure you are using all the same inputs locally?
11:59jeffterrellProblem is here BTW: http://www.4clojure.com/problem/131
12:00jeffterrellI got it using the foreclojure lein template, which has been serving me well for the last ~20 problems.
12:00jeffterrellAnd they do look identical…
12:03dbaschjeffterrell: which case gets you the timeoutÇ
12:03dbasch?
12:03jeffterrellThe first one. I mean I get no passes or failures, just a timeout.
12:03jeffterrellI can share my solution if that would be helpful.
12:04dbaschI just re-ran my solution and it passed just fine
12:04dbaschsure, go ahead
12:06jeffterrellOK thanks, one sec.
12:10jeffterrellHere's what I have, including passing test cases.
12:11gfredericksI just got it to pass after a couple iterations
12:12jeffterrellWeird. So 4clojure is accepting some solutions, just not mine. :-)
12:12gfredericksmy powerset function didn't have a base case :)
12:14jeffterrellHa, nice.
12:14jeffterrellIncidentally, I love that I can do this in Clojure (for sets that don't contain nil anyway): (fn intersect [s1 s2] (set (keep s1 s2)))
12:15gfredericksclojure.set/intersection
12:15jeffterrellYeah, but not in 4clojure.
12:15gfredericksI used it
12:15jeffterrellReally? Hmm… Did you require it or just call it directly?
12:16gfredericksjust called it fully qualified
12:16jeffterrellHuh, alright. I thought I tried that and it didn't work. Trying again, thanks!
12:17jeffterrellIf only clojure.set had a power-set function.
12:17gfredericksmy favorite powerset impl uses a range of integers
12:18gfredericksI wonder if there's some number theory way to make a pseudorandom permutation of (range 2^n)
12:19gfredericksthat would let you do a shuffled lazy power set on arbitrarily large input
12:19gfrederickswhich is useful for...spaceships.
12:19gfredericksand...marketing.
12:19gfredericksand cancer.
12:20jeffterrellBy range of integers, are you basically going from 0 to (2^n)-1 and using the binary representation of the number to control whether an item is included or excluded?
12:20justin_smithgfredericks: map xor (rnd) across the range?
12:20gfredericksjustin_smith: hey that's a good enough one
12:20jeffterrellHmm, interesting. I bet there's a PRNG out there that can do that.
12:20gfredericksI bet there are tricks you can layer on top of that to get alternate orderings
12:21gfredericksjeffterrell: yes that exactly
12:21jeffterrellYeah cool.
12:21gfrederickswait I take back my tricks suspicion
12:22gfredericksjustin_smith: it's crazy how many possibilities there are with that method but how far short it comes of giving you all permutations
12:27gfredericksis there any perf reason that clojure's bit operations shouldn't support BigInt?
12:34gfredericksjustin_smith: looking more closely, since the number's being treated as a bit set it's actually not a very random looking order that results
12:34gfredericksi.e., the high bits are pretty static
12:46justin_smithgfredericks: yeah, makes sense
12:47jeffterrellgfredericks: I wonder if Knuth's tome has a good algorithm for what you want. Half of Volume 2 is about random numbers.
12:49justin_smithgfredericks: is there an weird semi-rng that is guaranteed to not repeat any output?
12:50justin_smithlol, an-weird
12:53gfredericksjustin_smith: yeah that's what I was wondering; number theory with all the groups seems the most promising
12:54gfredericksevery group defines N permutations...but getting a useful group of size 2^N seems hard;
12:54gfredericksyou could pick the next prime above 2^N and then...
12:54gfredericksget a permutation from that and just filter out the stuff that's too large
12:55jeffterrellWhat version of Clojure does 4clojure use to evaluate code?
12:59jkj4clojure is quite boring when you are not following anybody. anyone care to be stalked?
12:59dbaschjeffterrell: you never shared your code
13:00jeffterrelldbasch: lol, totally thought I did, sorry about that
13:00jeffterrellhttps://www.refheap.com/93465
13:00justin_smithI am using refs to hold hash maps of identifier to Process (as created by ProcessBuilder). I have a checker that restarts those processes and replaces the value in the map if they exit. How do I ensure that this isn't retried? because with retries I am getting multiple processes for each index (but only one actually tracked in my map of processes, so it has effectively leaked)
13:02justin_smithI should probably be using atoms, but an atom would retry too...
13:03gfredericksa function that returns a lazy shuffled version of (range 2^n) via the prime thing I just thought of: https://www.refheap.com/93466
13:04dbaschjustin_smith: how do you test if a process has exited?
13:05justin_smith(.isAlive process)
13:05justin_smithmaybe I should just isolate all actions on processes to one thread, that is likely the simplest solution...
13:18justin_smith(inc eastwood)
13:18lazybot⇒ 1
13:18justin_smith(inc andyf)
13:18lazybot⇒ 7
13:18justin_smiththat tool just keeps saving me from my own stupidity
13:19andyfjustin_smith: cool. If you are going to the conj (unfortunately I am not) hiredman will be leading an unsession on it. You can go and rave about it there.
13:20justin_smithsadly I am not going either
13:20andyfjustin_smith: Or if you have any favorite examples of things it caught for you, I can add them to some 'teaser slides' I have early in a slide deck that ask people 'do you see anything wrong with this'?
13:20gfredericksI am not going either let's the three of us hang out in #clojure and gripe
13:21andyfWait, you can do other things in #clojure besides gripe?
13:22gfredericksyou can make the bots factor numbers
13:23gfredericks&((fn factor [n] (if-let [p (->> (range 2 (inc (Math/sqrt n))) (filter #(zero? (mod % n))) (first))] (cons p (factor (/ n p))) [n])) (System/currentTimeMillis))
13:23lazybot⇒ [1416162185644]
13:24gfredericksI don't think that worked right.
13:24andyfgfredericks: Regarding your earlier question about bit ops on BigInteger, I don't know the details, but I suspect performance is the reason that it isn't built into clojure.core
13:24gfredericks&((fn factor [n] (if-let [p (->> (range 2 (inc (Math/sqrt n))) (filter #(zero? (mod n %))) (first))] (cons p (factor (/ n p))) [n])) (System/currentTimeMillis))
13:24lazybot⇒ (2 491 1442120377)
13:24gfredericksandyf: the strange thing about it though is that the *other* perf-sensitive functions do support BigInt
13:24gfredericks,(inc 3N)
13:24clojurebot4N
13:24gfredericks,(bit-not 3N)
13:24clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: bit operation not supported for: class clojure.lang.BigInt>
13:25andyfIf someone finds a way to extend them to work on BigInteger, with the right kinds of performance tests showing little or no slowdown, that would be interesting.
13:25andyfto me. Can't say whether clojure.core maintainers would find it interesting.
13:25gfredericksandyf: do you know something about bit ops vs normal arithmetic that I don't?
13:26andyfyes.
13:26gfredericksokay good.
13:26andyf:) I don't know what, but probably something
13:26gfredericksI'm just wondering why it's worth doing this for bit ops but not addition etc
13:26gfredericksit smells more like not-implemented-yet
13:27andyfWhy it might be difficult to get bit ops to perform well in Clojure, that I don't know.
13:27andyfI am pretty sure it was there in an earlier version, and was removed, maybe as part of Clojure 1.3 numeric changes.
13:27gfrederickshey I bet leiningen would let me try out 1.2 pretty easily
13:28arrdemyes, yes it will
13:28arrdemwhether you'll like what you find...
13:28gfredericks(inc leiningen)
13:28lazybot⇒ 6
13:28gfredericks(inc lein)
13:28lazybot⇒ 2
13:28gfredericks(inc line)
13:28lazybot⇒ 1
13:28gfredericks(inc lint)
13:28lazybot⇒ 1
13:28gfredericks(inc lent)
13:28lazybot⇒ 1
13:29gfrederickshaha actually `lein new; switch to 1.2.1; lein repl` fails
13:29gfredericksprobably something to do with cider-nrepl
13:29arrdemswitch to?
13:29gfredericksI'm just gonna call java with that dang jar.
13:29gfredericksthis is not worth figuring out
13:30gfredericksclojure.lang.BigInt didn't even exist
13:31gfredericksbut looks like bit ops did work on BigInteger
13:31gfrederickshey I bet abedra would know this
13:33andyfhttps://github.com/clojure/clojure/commit/601d9521f88f8fb00e670d2823857cdcb2b2e1c3 Removed during alpha releases leading up to Clojure 1.3.0
13:36andyfhttp://dev.clojure.org/jira/browse/CLJ-767 and http://dev.clojure.org/jira/browse/CLJ-772 look like they may have the patches. I haven't read through them in enough detail to see what the rationale was.
13:37andyfclojure-dev discussion thread: https://groups.google.com/forum/#!topic/clojure-dev/IZHL8ASNjKY
13:37andyfok, now that I've thrown a denial-of-service attack at gfredericks :)
13:38arrdemclearly he just needs to learn to read faster
13:38arrdemI'm on the dev thread :P
13:39Bronsaso the rationale is "Rich said so"
13:39gfredericks"People that are using
13:39gfredericksshifts as nature intended are doing so for the utmost performance, and
13:39gfredericksany conditional test kills it."
13:39gfredericks-- rhickey
13:40andyfBronsa: well, he gave reasons for the decision in the thread.
13:40gfredericksI guess the conditional has something to do with edge cases in the shifters? and it was cleaner to just not support any bit ops for consistency?
13:40justin_smithgfredericks: so clearly we need a slow-* variant for each bitwise op
13:41andyfjustin_smith: At least as far as naming goes, putting a ' at the end would be fairly consistent with inc' +' etc.
13:41Bronsaandyf: well removing them alltogether isn't the best solution though, we have + and +', we could have bit-foo and bit-foo'
13:41arrdem&(let [c 63] (bit-shift-right (bit-shift-left 1 c) c))
13:41lazybot⇒ -1
13:41gfredericksjustin_smith: the numeric-tower lib doesn't solve this problem, does it?
13:42arrdem(bit-not 0)
13:42arrdem&(bit-not 0)
13:42lazybot⇒ -1
13:42andyfSomeone could ask Medley maintainers whether they are interested.
13:42arrdemnumeric tower seems inactive
13:42gfredericks,(bit-not' 7)
13:42clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: bit-not' in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:42arrdemsorry no it's algo.generic that's inactive-ish
13:42arrdemgfredericks: oh. that's an interesting one. what bit width would you expect for that?
13:43andyfarrdem: I haven't looked recently -- tickets with no response for a long time, or no tickets?
13:43gfredericksarrdem: ah right no idea
13:43andyfno tickets could just mean no one is looking to change it.
13:44arrdemandyf: no response. ALGOG-5 being the ticket in question.
13:44olivierrrIs there a way to get subs from a number?
13:45arrdemolivierrr: subs?
13:45olivierrrsubstring
13:45andyfarrdem: you could try personal email to Konrad, if you haven't already.
13:45olivierrri wanna pop the last character
13:45andyf(quot num 10)
13:45andyfif by character you mean 'decimal digit'
13:45arrdemgfredericks: I think the answer is that you get the same width you put in back
13:46arrdemgfredericks: anything else will be... silly
13:46Bronsaandyf: jira emails only the project authors that requested it right?
13:46gfredericksarrdem: oh righto
13:46gfredericksandyf: is medley your preferred utils lib?
13:46arrdemgfredericks: I mean... ~0 is clearly infinite so... we have to do something
13:47andyfBronsa: I believe Alex Miller changed it early 2014 so that by default all project leads get email on all project JIRA ticket updates (with a few exceptions, probably clojure core itself)
13:47olivierrrThat should do it andyf, thanks
13:47Bronsaok
13:48andyfgfredericks: For Eastwood, extra dependencies are more pain than for the average project. I tend to copy in individual functions I want and attribute the source, if licenses are compatible. Only 3-4 functions right now, I think.
13:48gfredericksmedley looks nice; enough overlap with plumbing that I probably won't use it though
13:48arrdemBronsa: interesting comment about platform types. do you really find that dominates host interop forms?
13:49andyfI don't have full knowledge of the contents of Plumbing, Useful libs, for example, given their size and my lack of taking time to explore them fully.
13:49gfredericksevery time plumbing doesn't have something I want I just make a PR
13:50engblomHas anyone managed to get Quil to run on Android?
13:50gfredericksI feel like there has to be a nicer way to do util libs but I have no idea what that is
13:50Bronsaarrdem: I wouldn't say they dominate host interop forms, but not having all the necessary predicates + unimported classes/interfaces makes it really hard to write "portable" clojure
13:50arrdemBronsa: understood
13:50andyfBronsa: arrdem: Even though notes on tickets should auto-email project leads, sometimes a private email can be effective, since it doesn't look auto-generated.
13:51Bronsaarrdem: I'm thinking about tools.analyzer. the only necessary jvm interop there is because of that & to work around clojure bugs
13:52Bronsaalso not having ex-info? & ExceptionInfo auto-imported makes writing portable clojure unnecessarily difficult
13:53arrdemI'm very entertained by the automatic imports
13:53Bronsaentertained?
13:54arrdemI would not have thought of the code sharing that it enables and I think it's neat
13:54Bronsaandyf: I mean, if I have to go through all that trouble just to get a bug report noticed I might just use another library
13:56andyfBronsa: Understood. hence the mention of Medley/Plumbing/useful, one of which may be more responsive.
14:08stephenmac7Is there a good reference for people who want to learn clojure but already know scheme?
14:09stephenmac7Or, any other lisp dialect
14:10andyfClojure: Also Lisp-1, use let or letfn instead of nested define/def, Clojure even more encouraging of defaulting to immutable data than Scheme
14:10gfredericksclojure.org has a list of differences
14:11gfredericks$google clojure clojure.org lisp
14:11lazybot[Clojure - lisp] http://clojure.org/lisp
14:11gfredericksthat page is not what I meant
14:11gfrederickshaha clojure.org/lisps is it
14:12godd2stephenmac7 try http://www.braveclojure.com/getting-started/
14:12dc_who's the guy that does Cursive Clojure?
14:12Bronsadc_: cfleming
14:13andyfI came across this via a few Google search terms, but don't know whether I would recommend it yet, as I haven't dug through it, and the fact that it mentions Clojure version 1.2 at the top (about 4 years since that was released?) is not greatly encouraging: http://hyperpolyglot.org/lisp
14:13dc_Bronsa: cool, thanks
14:13stephenmac7gfredericks: andyf: godd2: Thanks
14:13Bronsaandyf: yeah that's really old & has some unidiomatic clojure code
14:14andyfYes, scanning through Clojure examples I can see some of those
14:14Glenjamingfredericks: i've had this idea for a while to make a "lein misc" which builds a util.clj by letting you depend on individual functions
14:15dc_cfleming: i'm having a minor issue in cursive involving the debugging. when i add breakpoints to my code, execution halts on those breakpoints the first time i run the function that contains them, but not after that. i have to rerun the debugged REPL to trigger the breakpoints again
14:15dc_cfleming: i'm not sure if it's an actual error or just user error
14:15gfredericksGlenjamin: ah ha so the main difference would be your requires, right?
14:16Glenjamini've not thought too heavily about it, but the rough idea is you'd require myproject.utils :as utils, and put something in project.clj that's used to generate myproject/utils/clj
14:16gfredericksGlenjamin: this reminds me of dot-slash & lein-shorthand, but would be more production-oriented than dev-oriented
14:17Glenjaminyeah, i think it's similar. in this case i'd want a registry with functions and a dependency graph
14:17gfredericksdep graph?
14:18Glenjaminyeah, so i wrtil a util flatten-maps, which needs another util traverse-maps
14:18gfredericksyou wrtil it?
14:18Glenjaminwrite
14:18Glenjamintyping not my strong point today
14:18gfredericksI thought this was about using util libs, not writing them?
14:18Glenjaminit'd be like clojars for functions
14:19gfredericksoh you're trying to solve versioning and whatnot too
14:19gfredericksI'm thinking something more restrained
14:19Glenjaminbasically i'd like to be able to take a few functions from useful, some from medly etc
14:19gfredericksit would mainly solve the problem of duplication between util libs and having to remember what namespaces all your dang utils come from
14:20Glenjaminah, so you'd still pull them all in as the usual jars, but then rename them into a single ns?
14:20gfredericksso you would add all N util libs as deps to your project, and then have a list in the project.clj of the functions you want to use, and they get packaged into one namespace so you can require without thinking
14:20andyfGlenjamin: Someone put a link to a video of a talk by Mark Hibberd about annex recently that I watched part of. You might be interested in watching it. I'll send the video link if I can find it: https://thestrangeloop.com/sessions/towards-annex-a-fact-based-dependency-system
14:21Glenjamincheers andyf, will make sure it's on my to-watch list
14:21andyfGlenjamin: Making that work for what you want in Clojure is perhaps a much bigger job than the feature you're looking for, though.
14:21gfrederickspaging hugoduncan
14:22andyfGlenjamin: here is the video link: https://www.youtube.com/watch?v=JjYAnBhF2JU
14:22Glenjaminta
14:22Glenjamini should probably stop talking about it and start building it
14:22gfredericksGlenjamin: check out lein-shorthand first
14:23Glenjamini just skimmed it now, looks pretty neat
14:23Glenjamindoesn't solve the versioning/namespace conflict issue though :)
14:23gfredericksI'm thinking that's not too big a deal
14:23gfredericksfor my use case
14:23Glenjaminprobably not, but it's a fun* problem to tackle
14:24Glenjamin*possibly not at all fun
14:25gfredericksthings get drastically less fun once you have to start worrying about commiting to things that lots of people will use for years
14:27csd_Is there any way to put a constructor inside a defrecord call? Like (defrecord x [foo] #(rand-int 10)) where the function sets foo?
14:28Glenjaminyou can replace the generated factory functions
14:29csd_Can you give an example?
14:30csd_Put another way I guess what I'm looking for is a way to create a record where it's properties are generated endogenously
14:30andyfDang, I should have done this months ago -- support Eastwood warning output format in emacs compilation-mode buffer format. I could have saved myself so many hours
14:30justin_smithandyf: nice, please do - clickable links would be awesome
14:30gfrederickscsd_: I think that's a problem you want to solve with not-just-records
14:30gfredericksi.e., use a regular function to do the logic you want
14:30csd_gfredericks: what do you mean?
14:31andyfIt will definitely be in next release. I just finally implemented it a few mins ago
14:32andyfand started about 10 mins before that. I knew it wouldn't be hard, but just didn't do it.
14:32csd_have defrecord x and function x-caller to construct x?
14:34kenrestivoi'm having a brain-fart. is the most idiomatic way to modify keys (into {} (for [[k v] [k (something v)])) ? or is there less verbose way?
14:34kenrestivourg, sorry (into {} (for [[k v] m] [k (something v)]))
14:34andyfkenrestivo: that is most concise way I know of, if you don't use map-vals in some of the utils libraries.
14:35Bronsakenrestivo: yeah there's no update-vals in clojure.core. you can use reduce-kv if you prefer
14:35kenrestivoright reduce-kv, thanks
14:35Bronsaandyf: I keep thinking update-vals is a better name for map-vals
14:36gfrederickscsd_: yep
14:36Bronsabut it looks like everybody else disagrees with me on this one :P
14:36csd_ok well thanks
14:37gfredericksBronsa: update suggests calling f once, map suggests N times
14:38Bronsagfredericks: map-vals to me means (fn [f m] (map f (vals m)))
14:39gfredericksthat one I always name call-vals-and-then-call-map-with-the-result
14:39gfredericksfor clarity
14:39andyf(inc gfredericks)
14:39lazybot⇒ 105
14:39Bronsalol
14:40andyfverbosejure - it will make you swear for a different reason
14:41gfredericks(defn like-last-but-from-the-other-size [[x]] x)
14:41andyfcoboljure
14:41gfredericksside*
14:48hyPiRionFrom experience it's not verbosejure. It's just common lisp.
14:50hyPiRionI mean, when you have functions named update-instance-for-different-class
14:55kenrestivohaha, digging through old code, i found a function i didn't know what to name: https://www.refheap.com/93469
14:55kenrestivoi think i was rewriting walk
14:56andyf*cough* unsigned-bit-shift-right
14:58csd_Is it possible for records to inherit fields from other records?
15:00gfrederickscontrasigned-byte-buffer-shift-up-and-slightly-to-the-left
15:01kenrestivobut-not-too-far-i-dont-want-it-to-block-the-window
15:02andyfReflection warnings give a file path name relative to the classpath they are in. Is there a way (without modifying the source code of Clojure itself) to get the full path, or at least prefix that with the classpath directory?
15:04csd_What is the proper way to subclass datatypes-- i.e. your typical Person, Employee example? Ostensibly, Employee should be able to inherit something like Person.name, rather than have its own name field for the same person
15:05Bronsaandyf: don't think so
15:06gfrederickscsd_: there's a hodgepodge of approaches
15:06andyfI added full paths, or relative to the current working dir, to Eastwood warnings recently, and that saves me confusion of where files are. Do other people get confused by this?
15:07csd_gfredericks: I found this really long thread on the mailing list about it from back in 2012, but no one seemed able to agree on best practice
15:07csd_Some even said it's a bad idea to even try to do it (I don't know what the alternative would be?)
15:07andyfI mean, especially for cljx projects where they put auto-generated clj/cljs files in target/generated/foo/bar/baz
15:07gfrederickscsd_: yeah I feel like somehow clojure users don't have a common use case they're attacking so nothing obviously standard has coalesced
15:07gfrederickscsd_: are you literally dealing with an Employee type and a Person type?
15:08csd_Not that use specifically, but essentially
15:08csd_record-type Monster, and then subclass Orc that inherits Monster
15:08gfrederickscsd_: I think the most interesting approach that I haven't actually done much with myself is multimethods, with inheritance hierarchies if necessary
15:08andyfcsd_: If you are not dealing with existing class hierarchy, a common recommendation is "use maps with the fields you want, and write functions that operate on them, perhaps using preconditions or something like Schema to catch you if you try to pass the wrong 'map type' in"
15:09gfredericksyeah ^that approach is pretty normal too
15:09csd_andyf: so use merge to get the parent class fields?
15:09gfredericksparent?
15:09csd_the inheritee
15:09gfredericksoh merge like at construction-time?
15:09andyfcsd_: There would be no separate classes using that approach, just maps with different collections of keys, and functions that operate on those maps
15:10csd_yes at construction time
15:10gfredericksyeah you could do that
15:10csd_i guess you could have the subclass be a value in the map of the parent too
15:10csd_does that make any sense
15:11csd_I have basically zero experience working with defrecords, deftypes, multimethods, etc in clojure
15:12gfredericksandyf is advocating one flat map per object
15:12gfredericksyou could namespace the keys if you like that
15:12csd_So person foo gets two maps?
15:12gfredericks,{:monster/name "ROhhohnvth" :orc/sword-length 11}
15:12clojurebot{:orc/sword-length 11, :monster/name "ROhhohnvth"}
15:13gfredericksno when I said "one" I specifically meant "not two"
15:13andyfcsd_: Caveat emptor: I haven't gone off and written big systems using that approach, so can't give any info based on experience on what the pros/cons of that approach are, but I think some Clojure developers have.
15:13gfredericksI can see how it could be interpreted both ways though :)
15:13csd_I see, I was thinking of Employee and Person representing distinct objects
15:13gfredericksmaybe I shoulda said "instance"
15:14csd_The truth is this is just toy code. I just want to learn how to do things the Right Way
15:14gfredericksclojure doesn't have a lot of right ways in this area
15:15csd_For a beginner, difficulty is directly proportional to lack of established consensus
15:15csd_yeah
15:15gfredericksif you just want to inherit base functionality, just write a function that does the same thing for everything. If you need per-type overrides, try a multimethod.
15:15csd_I'm more concerned with being able to inherit the parent fields
15:16csd_multimethods wouldn't fix that I don't think
15:16gfredericksyeah merge in your constructors is fine
15:16csd_I guess I'll give maps a go
15:16gfrederickswhere "constructors" are regular functions
15:16gfredericksthey're the most flexibleest
15:17csd_So you think I should just get rid of defrecords altogether for this use case?
15:17gfredericksyeah
15:17bbloomBronsa: how hard would it be to do what i proposed in https://groups.google.com/d/msg/clojure-dev/6pnIeXFRwnI/_KyMvgtszOsJ ?
15:17bbloomBronsa: my guess is relatively easy, but you're the tools.reader expert
15:17csd_ok
15:18csd_thanks
15:18gfrederickscsd_: it's actually pretty normal to antirecommend defrecord for beginners
15:18csd_I've seen that
15:19csd_I see the advantage but I imagine most people coming from an OO background feel uncomfortable with it
15:19bbloomgfredericks: https://github.com/clojure/clojure/blob/05af4b52a474bc60d2eb931e388b302c14edc884/src/jvm/clojure/lang/Numbers.java#L1096 maybe there's a reason?
15:20Bronsabbloom: should be quite trivial, yes btw wrt "uninterpreted tagged literals", clojure/tools.reader have *default-data-reader-fn*
15:23Bronsabbloom: another place where the reader depends on an available namespace env is for var qualification on syntax-quote
15:23gfredericksbbloom: yeah andyf unearthed a discussion that suggested that other types require extra logic for weird shifting cases, thus not worth it
15:24bbloomarrdem: assuming twos-complement, shouldn't the bit width not matter?
15:24andyfbbloom: negative numbers and complement leave options available
15:26bbloomandyf: extra dependencies are a pain for all projects... people just don't realize it right away
15:26andyfbbloom: no argument. I've just imposed some extra pain on myself for Eastwood
15:30annelieshttps://twitter.com/lvsn/status/533685461957349376
15:32estKrisHi, a clojure beginner here, would anyone be willing to show me a way to construct something like this [[0 0] [0 1] [0 2] [1 0] [1 1] .. [2 2]] in a Clojure like style :)
15:32estKris
15:32andyf,(for [v1 (range 3) v2 (range 3)] [v1 v2])
15:32clojurebot([0 0] [0 1] [0 2] [1 0] [1 1] ...)
15:33annelies,(for [x (range 3), y (range 3)] [x y])
15:33clojurebot([0 0] [0 1] [0 2] [1 0] [1 1] ...)
15:33csd_,(for [x x] (range 3))
15:33clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:33anneliesOh. :P
15:33csd_(for [x (range 3)] [x x])
15:33andyfBetter 3 answers than 0 :)
15:33csd_,(for [x (range 3)] [x x])
15:33clojurebot([0 0] [1 1] [2 2])
15:34csd_ok dont listen to me
15:34anneliesActually
15:34annelies,(vec (for [x (range 3), y (range 3)] [x y]))
15:34clojurebot[[0 0] [0 1] [0 2] [1 0] [1 1] ...]
15:37estKrisHaha, excellent, many thanks. I was hesitating to use (for ) as I thought it was not the "Clojure way" of doing things. Am I trying to hard to be functional or is for a part of functional programming as well?
15:37BronsaestKris: clojure's for is not the imperative for
15:37andyfestKris: Clojure's for is functional, if you don't do side effects inside of it yourself.
15:37csd_clojure's implementation of for is functional
15:38estKrisMan, you guys are eager to help, seems what I've heard about Clojures community is true :)
15:39mi6x3mhey clojure, is it customary to have predicates with more than 1 argument?
15:39mi6x3mlike
15:39mi6x3mdeps-in-order? [a b]
15:41anneliesIf you need it, you need it.
15:42anneliesThough something like deps-in-order? would be variadic, like < and > are.
15:47gfredericks$google github gfredericks compare
15:47lazybot[gfredericks (Gary Fredericks) · GitHub] https://github.com/gfredericks
15:47gfredericksthat was insufficient
15:49andyfgfredericks: If you are interested in functions that get, if not all the way, at least closer to being able to compare arbitrary objects, I've got some code for you
15:51gfredericksandyf: I have a library that just does clojure.core/compare on things
15:51gfrederickswhich is good enough for most of my purposes
15:52andyfgfredericks politely and deftly deflects andyf's subtle attempt to foist off code maintenance on him.
15:52gfredericksandyf: what're you trying to maintain
15:53andyfnothing :)
15:53gfredericksout with it
15:54andyfSeriously, I have a tiny bit of example code in thalia docs that shows how to generalize compare to be able to work for a larger variety of pairs of things. 1 or maybe 2 people have asked if I have put it in a lib somewhere, but I haven't.
15:54anneliesgfredericks: I'm looking at your qubit library.
15:54andyfyour lib has the right name
15:54gfredericksandyf: :)
15:54anneliesAFAIK qubits can only be observed once. Why can it be observed twice in your library?
15:54gfredericksannelies: I've never heard that
15:55anneliesOh wait nevermind.
15:55gfrederickssubsequent observations are trivial to my knowledge -- you keep getting the same result
15:55anneliesYou observer them multiple times you get the same alue.
15:55bbloomBronsa: what type does that return?
15:55Bronsabbloom: whatever you make it return
15:56bbloomBronsa: if you look at transit, it has a custom type for tagged values
15:56anneliesbrainfart :p
15:57anneliesBinary X is controlled NOT right?
15:57bbloomBronsa: seems like there should be a way for all reader evaluated forms to be defined in terms of unknown tagged literals
15:57bbloomBronsa: for example, both `... and (clojure.core/syntax-quote ...) could become #clojure.core/syntax-quote ...
15:57Bronsahttp://sprunge.us/CPVf?clj
15:57gfredericksannelies: right
15:58bbloomBronsa: and ::foo/bar could become #clojure.core/keyword [#clojure.core/resolve-alias-or-something foo bar]
15:58anneliesI always wanted to implement this in Clojure but I never actually did it.
15:58anneliesHave a star.
15:58bbloomBronsa: similar story for wherever feature expressions land
15:58bbloomseems like it would address the "more reader features hurts tooling!" complaint
15:58Bronsabbloom: yeah, that's a solution
15:58gfredericksannelies: thanks :) I spent a while a couple weeks ago trying to implement shor's algorithm. lots of binary arithmetic work.
15:59Bronsabbloom: those return value would need a backing type, not sure if it should be the job of tools.reader to define that type though
15:59andyfgfredericks: In case you every have more time than sense: https://github.com/jafingerhut/thalia/blob/master/src/thalia/comparators.clj
15:59bbloomi expected at least one more :-P
15:59bbloomi must have counted myself when i decided not to answer
15:59bbloom:-)
16:00gfredericksandyf: what on earth
16:00gfredericksbbloom: are you watching this channel with a 10 minute delay?
16:00andyfhe's catching up
16:00godd2he's on challenge mode
16:01gfredericksI guess I shouldn't expect a response for another ten minutes
16:01andyftest msg to see if my IRC client stays scrolled back in history if I type a message
16:01andyfok, he's not using the same client I am then :)
16:02bbloom,(doc instance?)
16:02clojurebot"([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"
16:02bbloom,(doc satisfies?)
16:02clojurebot"([protocol x]); Returns true if x satisfies the protocol"
16:02Bronsaahah, he definitely is
16:02bbloom,"hello?"
16:02clojurebot"hello?"
16:02bbloom&"hi?"
16:02lazybot⇒ "hi?"
16:02anneliesgfredericks: implementing Shor's algorithm is a fun exercise. Gonna try that with your library :)
16:02gfredericksannelies: let me know if you succeed
16:02andyfAll the talk of qubits has caused bbloom to become a Dr. Who-like time traveler
16:03BronsaI bet those were to answer mi6x3m question about 2-args predicates
16:03gfredericksI figured he was just reading the backlog until he made the comment expecting everybody else's responses imminently
16:03ghost_of_bbloombbloom: wtf?
16:03ghost_of_bbloomseems like my outbound messages are delayed...
16:03gfredericksoh right that's the other way this could happen
16:04Bronsaghost_of_bbloom: yeah we have all been talking about it for the last 5 minutes
16:04Bronsaghost_of_bbloom: you'll catch up with the rest of the world in about 3 minutes
16:04ghost_of_bbloomghost_of_bbloom: so werid
16:05anneliesgfredericks: fo' shor
16:05anneliesSCNR
16:05ghost_of_bbloomnope
16:05ghost_of_bbloomrestarting my irc client didn't seem to fix it
16:06ghost_of_bbloomi feel like somebody is playing a prank on me ...
16:06bbloomghost_of_bbloom: ping
16:06gfredericksannelies: every time I implement qubit math I get mad at trig functions and having to use floating point
16:06anneliesProbably the hardest part is getting the library to work. :V
16:06anneliesI have never used a non-Maven library with Clojure.
16:06anneliesLike, from project.clj.
16:07justin_smithannelies: like, nothing from clojars?
16:07gfredericksannelies: `lein install` will put it in your local
16:07anneliesYeah clojars.
16:07anneliesAh ok.
16:07Bronsaannelies: clone the repo and lein install it
16:07gfredericksbut I never released it because it did not occur to me anybody would use it that way
16:08ghost_of_bbloomthis explains why puredanger was ignoring me the other day...
16:08andyfso the delay is gone now, I take it.
16:08ghost_of_bbloomno, i'm using a web-based irc client
16:08anneliesgfredericks: I'll put it up here: https://github.com/rightfold/shor
16:08gfrederickshey bbloom how many fingers am I holding up
16:08bbloomgfredericks: 3
16:09gfredericksbbloom: correct
16:09bbloomoh hey, looks like that one was fast?
16:09gfredericksyep
16:09bbloomstupid distributed systems.
16:20gfredericks~distributed systems |are| stupid
16:20clojurebotIk begrijp
16:24annelieswoot clojurebot knows Dutch
16:33bbloomnamespaced keywords are weird.
16:34bbloomintuitively, un-namespaced keywords feel like global variables to me
16:34bbloombut that just doesn't seem to match the experience of using them
16:34bbloomuntil you want to make something remotely extensible, then it's like "oh crap. everybody behave themselves and namespace your keywords!"
16:34bbloommeanwhile...
16:34bbloom,(def foo foo)
16:35clojurebot#'sandbox/foo
16:35andyf#cloure is not available right now. It should be able to read your message in 10 minutes, when we will get back to you.
16:35bbloom,{foo 123}
16:35clojurebot{#<Unbound Unbound: #'sandbox/foo> 123}
16:35bbloomandyf: heh
16:37andyfbbloom: The (def foo foo) thing leaving foo unbound has something to do with keyword namespacing, or another topic?
16:37hyPiRionthat's different from kw namespacing
16:37bbloomandyf: related thought. idea being that a keyword is just an undeclared self-evaluating symbol
16:38bbloomthe fact that it's undeclared is convenient and also problematic
16:38bbloomFactor, for example, doesn't have "keywords"
16:38bbloominstead there is http://docs.factorcode.org/content/word-SYMBOL__colon__,syntax.html
16:38bbloomwhich basically is the same as (def foo foo)
16:39hyPiRion,(declare bar)
16:39clojurebot#'sandbox/bar
16:39hyPiRion,bar
16:39clojurebot#<Unbound Unbound: #'sandbox/bar>
16:39bbloommaybe it's more like:
16:39bbloom,(def foo 'foo)
16:39clojurebot#'sandbox/foo
16:39bbloom,foo
16:39clojurebotfoo
16:39andyfThe (def foo foo) thing has been mentioned in a recent ticket. http://dev.clojure.org/jira/browse/CLJ-1591
16:39Bronsa,(def foo #'foo)
16:39clojurebot#'sandbox/foo
16:39Bronsa,foo
16:39clojurebot#'sandbox/foo
16:40bbloomi'm just thinking through the design space a bit
16:40andyfI believe there is a rationale for it: it makes it easier in the implementation (or no other reasonable way?) to have functions call themselves recursively via their vars.
16:40bbloomin mathematica, symbols self-evaluate unless they have definitions
16:40Bronsaandyf: yup
16:41hyPiRionbbloom: so in Forth, "keywords" have to be defined before used? And they're self-evaluating and namespaced?
16:41hyPiRionI guess that makes sense
16:41Bronsaandyf: also useful for recursive lazy-seqs
16:41bbloomhyPiRion: not forth, that's factor
16:41bbloomhyPiRion: Factor : Forth :: Clojure : Common Lisp -- i guess
16:42bbloombut yeah, namespaced... they call them "vocabularies" though
16:42mi6x3mthanks to all for the deps-in-order? answers :)(
16:42mi6x3mI was away
16:42bbloomweirdly lots of places in Factor use strings instead of symbols
16:43hyPiRionhrm
16:43bbloomanother thing about "declaring" keywords, is that you need to import them too
16:43bbloomwhich is also true of double-colon keywords in clojure with alias
16:44anneliesgfredericks: why does this work? https://github.com/gfredericks/qubits/blob/master/src/com/gfredericks/qubits/examples/deutsch_jozsa.clj#L42
16:44anneliesIsn't map lazy?
16:45mi6x3mthanks for the answer some time ago annelies :)
16:47andyfannelies: It is, and that looks like either a bug, or at least dead code.
16:49bbloomanother thought: double colon keywords are a copy/paste nightmare
16:49bbloomevery time i've used them, copy-pasting burns me
16:53mi6x3mwhat would you pick for a a plural of ns (namespace)?
16:54andyfmi6x3m: nss
16:54mi6x3myeah thought so too
16:56kenrestivoi've always wondered about the frequent lein trampoline errors like Exception in thread "main" java.io.FileNotFoundException: /home/src/target/84fe468ce05c57c6782ee7bc16cc0a927b58c9a8-init.clj
16:57kenrestivorm -rf target/trampolines seems to clear them out, but not sure why they happen
17:04olivierrr!clj (str "testing")
17:04clojure-eval"testing"
17:05kenrestivowhat is !clj?
17:05kenrestivonew bot?
17:05kenrestivo!clj (str "~clj! is a new bot")
17:05clojure-eval"~clj! is a new bot"
17:05olivierrryeah :p
17:06danielcomptonooh, a new bot to play with
17:06kenrestivo!clj (println "~clj! is a new bot")
17:06clojure-eval~clj! is a new bot
17:06clojure-evalnil
17:06clojurebotA nod, you know, is as good as a wink to a blind horse.
17:06kenrestivo:-P
17:06winkdammit clojurebot, shut up
17:06kenrestivothree bots, no waiting.
17:07justin_smithhaha
17:07olivierrr!clj (range)
17:07kenrestivohahah
17:07kenrestivobot torture
17:08justin_smithmore like checking the bot's basic viability
17:08bbloom,"you don't see the" #! comment macro too often, huh?
17:08clojurebot"you don't see the"
17:08kenrestivoooh, didn't know about that one
17:08kenrestivo#_, sure but not #!
17:09bbloomi'm not sure #! offers anything that ; doesn't
17:09justin_smithit's for #!java -jar
17:09danielcomptonin shell land, not clojure land?
17:09jeffterrell,"testing multiple forms in eval" (+ 1 2)
17:09clojurebot"testing multiple forms in eval"
17:09kenrestivoah! that explains that syntax in lein bin files
17:09justin_smithdanielcompton: for shell scripts that are really cjojure files
17:09justin_smithdanielcompton: on those operating systems that don't make it impossible
17:09bbloomaaaahh duh, #! is for scripts
17:09bbloomdur
17:09danielcomptonjustin_smith: do you have an example?
17:10kenrestivoi guess just yer basic #!/bin/bash
17:10danielcomptonor are we just talking about basic shell scripts?
17:10kenrestivobbloom: yeah, but i wouldn't expect that as a reader macro
17:10jeffterrell,"testing again: should throw exception if 2nd form eval'd" (- a b)
17:10clojurebot"testing again: should throw exception if 2nd form eval'd"
17:10justin_smithdanielcompton: basic shell script, where the top like is something like #!/usr/bin/java -jar clojure.jar
17:11justin_smithand the rest is your clojure file
17:11danielcomptonjustin_smith: ah that's cool, hadn't thought of doing it that way
17:11justin_smithdanielcompton: turns out, on linux passing args on the top line of a shell script doesn't work
17:12danielcomptonjustin_smith: is there any other OS?
17:12justin_smithbut you could use another OS, or make a "clj" program, and make the top like be #!/bin/clj
17:12justin_smithor whatever
17:12danielcomptonjustin_smith: so it works in OS X?
17:12justin_smithdanielcompton: iirc bsd based systems allow args on the shebang line
17:12justin_smithyeah
17:13danielcomptonbrb just swapping linux servers for Mac Pro's in the data center
17:13justin_smithhaha
17:14justin_smithmaybe easier to just make that clj program :)
17:14danielcomptonor lein run?
17:14justin_smithno args, remember
17:14justin_smithoh yeah, just using lein run, sure
17:16kenrestivohuh, says it works on windows, mac, and linux: https://github.com/Raynes/lein-bin
17:20kenrestivoman i gotta get with this schema program. tired of trying to remember which map structure i'm dealing with in which function
17:21danielcomptonwhy are we able to alias clojure.set to set, and still use (clojure.core/)set without qualifying it?
17:23justin_smithdanielcompton: namespaces and vars are not in the same namespace
17:23justin_smithit is never ambiguous whether the thing you refer to is a namespace or a var
17:27danielcomptonjustin_smith: so set/intersection is resolved to clojure.set/intersection?
17:28Bronsadanielcompton: correct
17:37justin_smithyeah
17:57gfredericksannelies: yeah that map call looks like something I should've used doseq for...or should probably just delete;
17:57gfredericksthanks!
17:57clojurebotHuh?
17:59gfredericksannelies: even if it wasn't lazy it wouldn't change the outcome, so I think it was just there in an older version of the function
18:05danielcompton!clj (doc <=)
18:05clojure-eval-------------------------
18:05clojure-evalclojure.core/<=
18:05clojure-eval([x] [x y] [x y & more])
18:05clojure-eval Returns non-nil if nums are in monotonically non-decreasing order,
18:05clojure-eval otherwise false.
18:05clojure-evalnil
18:05gfrederickswhat
18:05arrdemwhois clojure-eval
18:06lodinMaybe the wrong channel, but is there a word for functions that map types from a to (x a), and conversely for functions that maps from (x a) to a? (E.g. vector resp. first.)
18:06danielcomptonolivierrr might know
18:06gfredericks,(println "!42")
18:06clojurebot!42\n
18:06gfredericks,(print "!clj 42")
18:06clojurebot!clj 42
18:06clojure-eval"!clj 42"
18:06clojure-eval42
18:06gfrederickswhat
18:06gfredericks,(* 2 3 7)
18:06clojurebot42
18:07danielcomptonirc bot quine
18:07olivierrrclojure eval... evals clojure
18:07arrdemkenrestivo: what's unique about clojure-eval
18:07arrdemsince clojurebot and lazybot still exist :P
18:07gfredericks,(print "!clj (println \",42\"))
18:07clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
18:07gfredericks,(print "!clj (println \",42\")")
18:07clojure-eval"!clj (println \",42\")"
18:07clojurebot!clj (println ",42")
18:07clojure-eval,42
18:07clojure-evalnil
18:07clojurebot42
18:08gfrederickswelp
18:08olivierrrit's my bot arrdem, no real reason for it
18:08danielcompton,(println "println \"!clj println "))
18:08clojurebotprintln "!clj println \n
18:08clojure-eval"println \"!clj println "
18:08gfredericksit's only a matter of time now
18:08arrdemamalloy: yo ignore can lazybot clojure-eval before this gets out of hand
18:08arrdemhiredman: you can't here me, but it's time to add to the ignore list
18:09gfredericksdon't some of them do throttling anyhow?
18:09gfredericks&(inc 41)
18:09lazybot⇒ 42
18:09gfredericks&(inc 41)
18:09lazybot⇒ 42
18:09gfredericks&(inc 41)
18:09lazybot⇒ 42
18:09gfredericks&(inc 41)
18:09lazybot⇒ 42
18:10gfredericks&(inc 41)
18:10lazybot⇒ 42
18:10gfredericks&(inc 41)
18:10lazybot⇒ 42
18:10Bronsaolivierrr: we already have 2 bots, what's the reason for another one?
18:10gfredericks&(inc 41)
18:10lazybot⇒ 42
18:10gfredericks&(inc 41)
18:10lazybot⇒ 42
18:10gfrederickslooks like it
18:10gfrederickser
18:10arrdemBronsa: none apparently
18:10gfredericksnevermind
18:10arrdemgfredericks: lazybot doesn't have ratelimiting, he has throttling on concurrent ops
18:10olivierrrno reason Bronsa
18:10godd2"We already have X programming languages, what's the reason for X+1 of them?"
18:11amalloy$login
18:11lazybotYou've been logged in.
18:11amalloy$reload
18:11lazybotReloaded successfully.
18:11Bronsagodd2: that's a really moot argument, adding useless bots to a channel is only going to create confusion
18:11godd2I agree, I was just being obtuse :P
18:13gfredericks!clj (println "&'testing-lazybot")
18:13Bronsagfredericks: the bot quit
18:13olivierrrkilled the bot
18:13gfredericksbye bye bot
18:13olivierrrsince we already have one
18:13cflemingdc_: Are you on IntelliJ 14?
18:13arrdemolivierrr: thanks
18:13arrdemamalloy: thanks, sorry for the ping
18:14danielcomptonpour one out for clojure-eval, we barely knew ye
18:14cflemingdc_: The breakpoints have always been slightly flaky, but v14 seems to have broken a lot of debugger functionality, they changed a bunch of their APIs.
18:14godd2,(print ",(print \"hello, world\")")
18:14clojurebot,(print "hello, world")
18:15olivierrrhahah, no worries, he lives in #learnclojure
18:15danielcomptonolivierrr: good to know he hasn't gone to the great garbage collector in the sky
18:17godd2who needs garbage collection when you can just unplug your computer?
18:18pdkyea
18:19pdkif your application's requirements don't account for periodic hard reboots you got some problems!
18:36gfredericksthat's not even a joke is it; I heard something about jvm restarts being a decent GC approach for low-latency app servers
18:37bbloomi believe that's what we call "region based memory management"
18:37bbloomwhere region == the entire damn vm
18:38arrdemOkay. anyone with a live repl and two seconds, please try running cider-grimoire on a symbol and see if you get HTML
18:38arrdemkbd C-c C-d C-g
18:40gfredericksyou made my computer touch the internet
18:40gfredericksI have a *cider grimoire* buffer that appears to be empty
18:40arrdemwhat did you doc?
18:40arrdemwhat symbol
18:47gfredericks+
18:47gfredericksfrom a repl buffer not a normal source buffer
18:49arrdemweird that worked just fine for me
18:49arrdemI didn't see a request for + go into the logs except mine
18:53gfredericksthis mccarthy paper just pointed out that and/or are not commutative
18:53gfrederickswhich hadn't occured to me
18:55gfredericksthey are if the inputs are strictly booleans
18:56TimMcand not side-effecting expressions :-)
18:57gfredericksyeah I meant booleans in the concrete sense
18:57gfredericksnot "thing that supposedly evaluates to a boolean"
18:57gfrederickswhich is what you'd get in a statically typed language, e.g.
19:09danielcomptoncfleming: I'm liking the unused vars feature. Was just thinking about it this morning
19:10cflemingdanielcompton: Awesome - yeah, I like that one too.
19:10cflemingdanielcompton: It's not 100% reliable - the offline one will be.
19:10cflemingdanielcompton: But it shouldn't produce false positives.
19:10danielcomptoncfleming: Analyze > Inspect Code ?
19:11cflemingdanielcompton: Yeah, but that inspection doesn't work offline yet, only in the editor.
19:11cflemingdanielcompton: You can use Analyze->Inspect to find all unused imports and aliases though, and you can even fix all the imports at once.
19:12cflemingdanielcompton: Just create an inspection profile with those two inspections and run it over all your code.
19:12cflemingdanielcompton: You can also configure that to be run before you commit.
19:13cflemingdanielcompton: There'll be more unused items found in use/require statements soon too.
19:14cflemingdanielcompton: It's kind of embarrassing how much I managed to clean up my own code just with those two.
19:16danielcomptoncfleming: that's really cool, didn't realise you could run it before committing
19:17cflemingHaha
19:17cflemingIt's amazing how satisfying deleting code is, given that it's also fun to write.
19:19TEttingercfleming: are you the coolguy behind Cursive? I can't remember
19:20cflemingTEttinger: Um, well, I'm the guy behind Cursive, yes
19:20cflemingTEttinger: The jury is out on how cool I am though.
19:21TEttingerit seems really nice! it's good to have more IDE support and it makes clojure much more usable to folks like me who can't grok emacs
19:21arrdemeh you build good tools you can't be all bad
19:21cflemingTEttinger: Thanks! I'm glad it's useful - having it be easier to use is definitely a major goal.
19:22cflemingarrdem: *blush*
19:22arrdemlol
19:23arrdemthere is a special place in hell where you have to use tools you made a long time ago
19:23cflemingMan, I don't want to go there.
19:24cflemingMy last real job was working on an IDE product - occasionally I went back to try versions from 6 months or a year earlier, it's really painful.
19:27cflemingcfleming: It helps when your issue tracker is overflowing to remember that you're still much better off now than you were then
19:27kenrestivo~garbage collection
19:27clojurebotHuh?
19:28kenrestivo~garbage collection is who needs garbage collection when you can just unplug your computer?
19:28clojurebotGabh mo leithscéal?
19:28arrdemkenrestivo: ~garbage collection |is| ...
19:28kenrestivo~garbage collection |is| who needs garbage collection when you can just unplug your computer?
19:28clojurebotCool story bro.
19:28kenrestivo~garbage collection
19:28clojurebotIt's greek to me.
19:28TEttinger~garbage colection
19:28clojurebotexcusez-moi
19:28kenrestivoaw, nevermind
19:28arrdemkenrestivo: sorry. you don't need the leading ~
19:29TEttingerclojurebot: garbage collection |is| something you don't need, since you can just unplug your computer?
19:29clojurebotTitim gan éirí ort.
19:29TEttinger~garbage colection
19:29clojurebotPardon?
19:29kenrestivoit was funny the way godd phrased it.
19:29TEttingerdidn't see it
19:30TEttingerhm, are any facts working?
19:30TEttinger~anyone
19:30clojurebotJust 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 ..."
19:30danielcompton~clojurebot
19:30clojurebotclojurebot is a multimap
19:31TEttingerclojurebot: garbage collection is who needs garbage collection when you can just unplug your computer?
19:31clojurebotPardon?
19:31TEttinger~garbage colection
19:31TEttingerodd
19:31TEttinger~garbage collection
19:31arrdemI had a writeup of this on clojurewiki... but it looks like bitemyapp has deleted that site
19:32TEttingerlol
19:32arrdembetter go read the lazybot source code
19:32TEttingerclojurebot
19:32arrdems/lazybot/clojurebot/g
19:32TEttinger$help
19:32lazybotYou're going to need to tell me what you want help with.
19:33TEttinger@help
19:33TEttingergah
19:36amalloyTEttinger: clojurebot won't accept factoids with a ? in them
19:36TEttingerhaha
19:36TEttingerwow
19:37TEttingerclojurebot: garbage collection |is| who needs garbage collection when you can just unplug your computer
19:37clojurebotc'est bon!
19:37TEttinger~garbage collection
19:37clojurebotgarbage collection is who needs garbage collection when you can just unplug your computer
19:37TEttingeryay amalloy
19:37TEttinger(inc amalloy)
19:37lazybot⇒ 190
20:43emaczen`Can I ask someone here about clojure's luminus web framework?
20:46TEttingeremaczen`, you can ask your question, it might help get an answer sooner
20:46arrdem~ask applies here
20:46arrdemnot that I can activate it...
20:47TEttinger~ask
20:47clojurebotThe Ask To Ask protocol wastes more bandwidth than any version of the Ask protocol, so just ask your question.
20:48arrdemalso going by Grimoire's traffic logs, US buisness hours account for ~75% of traffic so asking during those hours here is likely to reach more active people.
20:49TEttingeror ask TEttinger whenever it isn't US business hours
20:49emaczen`Okay
20:49TEttingerget online at 4:00 PM, go offline at 4:00 AM
20:49arrdemhehe
20:50danielcomptonemaczen`: you had a question?
20:50emaczen`Yes, I am trying to express it cleanly...
20:51emaczen`So, I am trying to serve my local mongodb database with the luminus framework.
20:52emaczen`If you run lein new luminus <app-name> +mongodb -- you get a nice template.
20:52emaczen`Then running lein ring server, is pretty much where I am at.
20:53emaczen`A browser will open, and it tells me my mongo connection is not happening... and just says I need to go to /src/app-name/db/core.clj and set the connection parameters, but I had no diea what these are.
20:54emaczen`I have been able to connect to my mongodb instance with a clj repl... but everything I have tried does not seem to work...
20:54emaczen`Am I making any sense to anyone? hah
20:54TEttingeremaczen`, yeah, I've used mongo a bit
20:54arrdem/src/<app-name>/db/core.clj should be a file in your generated source tree..
20:55emaczen`Yes, everything I have tried in there (like I did when I experimented in the REPL) is not working...
20:55arrdemshould be able to just go edit it as the error says
20:55TEttingeryou're running mongod (the daemon process) right?
20:55emaczen`Yep.
20:55arrdemrestart the app with the edited file?
20:55arrdemthe app won't magically reload on changes..
20:55arrdem* usually
20:56emaczen`I did lein clean and lein compile -- is that sufficient for restart?
20:56emaczen`Then lein ring server again of course.
20:56emaczen`TEttinger: Yes, I am running mongod
20:56emaczen`arrdem: There isn't an official error message? It looks just like html..
20:57dc_lulz @ topic
20:57dc_newer versions with still higher numbers
20:57dc_but how high?
20:58arrdemsomething something drill something heavens
20:59TEttingeremaczen`: http://clojuremongodb.info/articles/connecting.html you can use some clojure wrappers around mongo to make this easier
21:00emaczen`TEttinger: This template uses monger as a dependency. Also, I have successfully connected to Mongo from the REPL using monger.
21:01TEttingergood good. then the info there should be applicable
21:01TEttingershould be the same connection params, really...
21:06emaczen`Can someone verify that my 'compiling' step is correct/
21:06emaczen`I use, lein clean
21:06emaczen`Then lein compile
21:06emaczen`then lein ring server
21:09arrdemyou don't need to clean or compile unless you're using AOT
21:10emaczen`arrdem: what is AOT?
21:10arrdemalso you can do "lein do clean, compile, ring server" to only spin up one JVM for lein
21:10arrdememaczen`: class generation, which you almost certainly aren't
21:10emaczen`Then it is sufficient to just kill my server and restart it?
21:11arrdemyep
21:11emaczen`cool.
21:12arrdemyou can actually do better than that if you've got emacs or some other REPL set up...
21:12arrdemyou can boot and kill your server from the repl meaning you never restart Clojure
21:12arrdemyou just reload code
21:29emaczen`arrdem: I toyed around with the Austin repo for attaching cider to a browser repl -- do you know what I am tlaking about?
21:29arrdememaczen`: can't help you with cljs stuff sorry :/
21:30emaczen`could you help me get setup with what you were talking about then? I see what you mean, restarting a server is kinda slow...
21:31arrdememaczen`: https://www.refheap.com/93493
21:31arrdemoops
21:31arrdemhttps://github.com/clojure-grimoire/grimoire/blob/master/src/grimoire/web/service.clj
21:55andyf~anyone
21:55clojurebotJust 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 ..."
21:56andyfSorry, that was intended to be a response from before I last dropped off for 45 mins -- I didn't check the time stamps when I should have.
22:04gfredericksandyf: based on the symptoms I diagnose you with bbloomitis
22:05andyfgive it to me straight, doc. Don't sugar coat it.
22:05gfredericksandyf: you've only got 3 months to release a programming language.
22:06arrdem(inc gfredericks)
22:06lazybot⇒ 106
22:06arrdemgood lord when did you rack up that much karma
22:06gfredericksmakin jokes
22:06arrdemwell I'm laughing now, so I can't disagree
22:06andyfmaking refined jokes for the discerning palate, I would say.
22:07kenrestivoreally, most of the traffic on grimoire is business hours? that's pretty amazing. either that means clojure is something heavily used at work, or used as a way to slack off while at work.
22:07andyfProbably many of them with subtle hINCs that not only don't make people wINCe, but convINCe them of what they ought to do next.
22:08gfredericksandyf: was that a recipe for tripling your karma throughput?
22:08arrdemkenrestivo: so that's what Google Analytics reports, but I think it's lying because my server side logging suggest 10x more traffic-ish
22:08arrdemkenrestivo: but yeah 2-4pm CST is peak Grimoire traffic time IIRC
22:08andyfNo, I was just accusing you of using subliminal advertising in your jokes.
22:08gfredericks(inc andyf)
22:08lazybot⇒ 8
22:08andyfShoot, I did it again -- explaining the obvious. My son is trying to cure me of that.
22:09gfredericksI'd give you two more but lazybot won't let me
22:10kenrestivoHINcs? what is that? Happy Isles Nature Center? Haskell Indians Nations College?
22:10andyfWith most or all of the Internet available, I have a hard time believing people would slack off while browsing grimoire (no offense, arrdem -- I like it, but slacking off while using it?)
22:10kenrestivo~hinc
22:10clojurebotGabh mo leithscéal?
22:11kenrestivo~Gabh mo leithscéal?
22:11clojurebotGabh mo leithscéal?
22:11arrdemandyf: yeah... reading docs is not my idea of relaxation either :P
22:12andyfUnless 'static html' includes links to some racy sites :)
22:12arrdemnot that I know of
22:13Glenjaminanyone else find the clojuredocs update makes it look like grimoire?
22:13arrdemlol
22:14Glenjaminthe typeahead search thing is pretty neat though
22:15andyfClearly we need to get Reid and Zachary Kim at a Conj together, and have a cage match.
22:15arrdemnot this conj.. clojure/west maybe
22:17arrdemandyf: what would you think of a PR to thalia that uses the lib-grimoire backend and adds a dep to a package packing core docs & notes as lib-grimoire notes?
22:17arrdembasically where I'm going with Grimoire itself..
22:18andyfarrdem: Sounds fine to me.
22:18arrdemandyf: okie doke.
22:26kenrestivowow a for with a :let and a :when in it sure smells funny
22:26arrdemreally? I love :when and :let
22:26arrdemyou just need to get the indentation right
22:27andyfkenrestivo: Feel the pressure to conform. It smells fine. :)
22:27andyfseriously, I've started using it more often in some code I've been writing, and I kind of like it.
22:28kenrestivoit's ok... it just seems compected to me. like, i've got a thinking flaw here and should bust this up somehow
22:28arrdemfor is literally my favorite thing about clojure besides ->
22:28arrdemand the datastructures
22:29kenrestivofor was the most familiar thing to me when i was first learning clojure coming from python
22:29kenrestivo"list comprehensions, oh cool, know these!"
22:29andyf:when makes it easy to skip things conditionally in the resulting sequence, without sticking in nil's and remove'ing them later.
22:29kenrestivoyeah, that's how i ended up with it in this case.
22:29arrdem:when also makes it really nice to write "search"ish problems in fors..
22:33kenrestivoso. i have a function that is piping data to a c daemon to be processed and returned asynchronously. should i name it foo! or just foo. it's pure in the sense that it doesn't launch any missiles, but callign it is something that definitely must happen in a doseq and not for :-/
22:33arrdem-! is officially only for STM unsafe (non-idempotent) operations
22:34arrdembut... it's not used to denote side-effects
22:34arrdemso
22:34arrdemup to you
22:34andyfyou can stick a word like write/print/pipe in the name to give a strong hint.
22:34arrdemthere have been a couple attempts I've seen to nail puredanger or someone else down on the subject of the -! convention to no avail that I'm aware of
22:35andyfpipe actually not so strong of a hint as write/print
22:35arrdem"do" is a good hint
22:35arrdem(do-deamon-process ...)
22:37kenrestivosend- has been what i've been usnig
22:37kenrestivousing
22:37kenrestivosend-foo
22:37arrdemsend is good
22:38arrdemwhat we really need is an annotative effects system library...
22:38arrdemor at least it'd be nice
22:39arrdemandyf: idle curiosity, do you have a dog in the feature expressions fight?
22:39andyfI haven't looked at core.typed enough to know whether ambrosebs is hoping to include effects?
22:40ambrosebshoping!
22:40ambrosebsbut not clear how to do it
22:40arrdem^ yeah
22:41andyfarrdem: Not that I can think of. There could easily be good/bad consequences of the proposals that I haven't thought of, though.
23:03arrdemidle thought - local caching and federation on a Grimoire API rather than distributing datafiles in a package?
23:04arrdemI have relatively serious reservations/design issues with slapping resource packages on the classpath, whereas just using the 0.4.0 API and caching the result with configurable bounds on cache size/freshness would be pretty easy
23:05andyfFor development machines I doubt cache size will ever be an issue. freshness maybe
23:07arrdemyeah. so the issue is that, as presently designed, lib-grimoire assumes that you can "stat" a "directory" to list stuff like all artifacts and all versions of an artifact and soforth
23:07arrdemwhich is great, but turns out to be a real pain when you have a classpath not a real monolithic shared dir tree
23:07arrdemone approach is to have a ".list" file, but then you have to search for classpath aliases and concatenate all results
23:07arrdemwhich is messy
23:08arrdemor you can walk the classpath and look manually, which is messy
23:08arrdemor I could punt, call out to a web API, which is clean, and cache in a dir which I can work with nicely
23:09arrdemprobably just gonna do that..
23:18danielcomptonIs there a more idiomatic way to compare byte arrays in Clojure than using java.util.Arrays/equals ?
23:19andyfnot in core that I'm aware of
23:19andyfwouldn't be surprised if some lib out there had something for it
23:21brennonhey all, have a question I'm hoping someone can help clear up
23:21danielcompton~ask
23:21clojurebotThe Ask To Ask protocol wastes more bandwidth than any version of the Ask protocol, so just ask your question.
23:22brennonis there a way, in clojure, to replicate the concept of (Integer. 12) => 12 with any other clojure object
23:23brennoni.e. (deftype Big. [v]) then (Big. 12) => 12
23:23brennonrather than (Big. 12) => #<Big 12>
23:23bbloombrennon: just use a function
23:23bbloom,(deftype Big [x])
23:23clojurebotsandbox.Big
23:23bbloom,(defn big [x] (if (instance? Big x) x (Big. x)))
23:23clojurebot#'sandbox/big
23:23bbloom,(big 5)
23:23clojurebot#<Big sandbox.Big@120e76d>
23:24bbloom,(big (big 5))
23:24clojurebot#<Big sandbox.Big@4a04aa>
23:24brennonim trying to abstract out the necessity of calling an additional function from the end user of my library
23:24bbloomthat's probably the opposite of what you want to do
23:24brennoni.e. i internally box a primitive to gain the aspects of the object
23:24bbloomyou should expose factory functions rather than types, where possible
23:24brennonbecause i want to be able to store metadata
23:24bbloomdo you actually care about UNBOXED values?
23:25bbloomif that's the case, you're out of luck. primitives are special on the JVM
23:25brennonyes
23:25brennonthats what i was afraid of
23:25bbloomthe jvm does not allow custom unboxed types
23:25bbloomwhile they certainly have their uses, you probably don't really need them though...
23:25bbloomwhy do you want them?
23:26brennontrying to add metadata to any obj passed into my function
23:26brennonand quickly realized if someone just had a primitive id have to box it just to get metadata
23:27brennonor add an extra function to create a map with {:val <actual-val>, :other ...}
23:27bbloomboxing occurs automatically, but metadata must be baked in to a type when it's defined
23:27bbloomso you're going to have to wrap boxed values too, like strings
23:27bbloom,(with-meta "abc" {:x 1}) ; will fail, but "abc" is boxed
23:27clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IObj>
23:27brennonhmmm
23:27brennongood point
23:27bbloommaybe instead of metadata, you just want a map?
23:28brennonthats what im thinking
23:28bbloomalmost always a good call
23:28brennonbut then i need to provide an 'unbox' method to the downstream dev
23:28brennonwanted to alleviate them from calling (getValue <someMap>) etc.
23:28TEttingerthey would in java too
23:29bbloomif it's a well known key, (:value <someMap>) is probably just fine
23:29TEttingercollections can't contain primitives, though autoboxing helps
23:29bbloomit really depends on your use case though, w/o knowing what you're doing, i can't suggest more
23:29brennonyeah i think im just going to have to go with a known key plus some helper fns
23:30brennonthanks for the tip on the JVM though, good to know
23:30bbloomdo the clients of your library ever need the metadata?
23:30bbloomyou can unwrap objects you give back to callers after you're done w/ your metadata
23:30brennonyeah theyll want the metadata
23:30bbloomthen maps are definitely the right answer
23:30brennonbut i wanted to mask it for them so they could continue using the objects as normal
23:31bbloomsimply not possible on the jvm
23:31danielcomptonclojurebot: map |is| put a map on it
23:31clojurebotOk.
23:31arrdemhehe
23:31brennondarn, okay thanks
23:40danielcomptonis there a way to only show reflection warnings for code you're writing?
23:41andyflein check will show reflection warnings for source (not test) files, but also any compiler errors
23:42andyfI guess it would show other kinds of warnings, too, but not sure what you might want to disable in your 'only' qualifier
23:45danielcomptonthey're showing up in the cursive REPL, but I assume the solution would be general to all REPL environments