#clojure logs

2016-04-06

00:00Lewisamalloy: sorry im multitasking. My fault
00:01Lewis,(doc next)
00:01clojurebot"([coll]); Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil."
00:02Lewis(next [ 1 2 3 4])
00:02Lewis,(next [ 1 2 3 4])
00:02clojurebot(2 3 4)
00:04Lewis,(not [1 2 3])
00:04clojurebotfalse
00:05Lewis(not [])
00:05Lewis,(not [])
00:05clojurebotfalse
00:05Lewis,(doc not)
00:05clojurebot"([x]); Returns true if x is logical false, false otherwise."
00:06Lewiswow I don't think today. I've been working all day it might not help
00:06Lewisi even for got what not* was lol
00:35dorianhey can anybody tell me why lein-bin keeps trying to put the generated binary into a target/base+system+user+dev (which doesn't exist)?
00:40dorianoh i see, boilerplate made :target-path "target/%s" which presumably gets formatted in something
00:40tolstoyYeah, I always delete that line. Can't remember what it messed up for me.
00:41doriani kiiiinda understand what it's doing, i just don't understand why the dir doesn't get made
02:14Lewis,(doc max)
02:14clojurebot"([x] [x y] [x y & more]); Returns the greatest of the nums."
02:14Lewis,(doc max-key)
02:14clojurebot"([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is greatest."
05:43ulrichschinzhey there, I'm learning clojure and plain around... i dont understand why this is not working, mybe someone can explain....
05:43ulrichschinz(reduce (fn [aggr field] (if field (when (:pn field) (println (:pn field)) (conj aggr (:pn field))))) [] column))
05:43ulrichschinzreturns nil
05:43ulrichschinzwhereas column is a vec of maps
05:43ulrichschinzprintln prints the right thing
05:44ulrichschinzbut it returns nil, i would expect to get a vec of str-entries
05:51Kneivaulrichschinz: println returns nil
05:51ridcullyulrichschinz: field is most likely always true, so this branch always gives you nil
05:51ridcullyulrichschinz: either the when gives you nil or the print
05:52Glenjaminone way to help with debugging, is to extract the function outside the reduce, and try it with different values to see if it does what you expect
05:52ridcullyor use doto
05:59ulrichschinzok
06:00ulrichschinzso println inside a reduce always results in a nil?
06:02ulrichschinzsame thing without println returns nil as well
06:06ridcullya println always returns nil
06:56aptablipsHi. Quick Clojure question: How do you do an inexact numerical comparison? For example, I'd like this to come out true: (= (+ 0.1 0.2) 0.3)
07:06tdammersaptablips: not a clojure specific question really; you can't do that with floats in any language
07:06tdammerswhat you want is "epsilon comparison"
07:06tdammersi.e., compare against a tiny range
07:07gon__one way (= (+ 0.1M 0.2M) 0.3M)
07:07dmsnell(< (- 0.3 (+ 0.1 0.2)) epsilon)
07:07dmsnell^^^ really need absolute value
07:07dmsnellbut I wrote that to clarify
07:07dmsnellwhere epsilon is small
07:08jaaqo(= (+ (rationalize 0.1) (rationalize 0.2)) (rationalize 0.3))
07:08tdammersalso note that because floating-point precision decreases with growing absolute values, there is no single "ideal" epsilon; you have to pick one that works well enough for your domain
07:10dmsnellfun fact, JavaScript just introduced this as a language construct -> Number.EPSILON
07:10dmsnell"the difference between one and the smallest value greater than one that can be represented as a Number."
07:10tdammerswhich makes it suitable for numbers between -1 and 1
07:11tdammersor actually not
07:11Glenjamin,2.220446049250313e-16 ; the value in my version of firefox
07:11clojurebot2.220446049250313E-16
07:11tdammers,(+ 1.0 2.220446049250313E-16 -2.220446049250313E-16)
07:11clojurebot1.0
07:11tdammers\o/
07:12tdammers,(+ 1.0 2.220446049250313E-16)
07:12clojurebot1.0000000000000002
07:12tdammers,(+ 1.0 2.220446049250312E-16)
07:12clojurebot1.0000000000000002
07:12tdammers,(+ 1.0 2.2204460492503E-16)
07:12clojurebot1.0000000000000002
07:12tdammershmm
07:14cwgem|macIs there something like this ( https://github.com/liebke/cljr ) that's not 6 years old? It seems like I have to create a temp lein project just to automate package downloads and install.
07:14dmsnelltdammers: -1 to 1 is very useful for floating-point numbers
07:14tdammersdmsnell: agree.
07:17Glenjamin,(def epsilon 2.220446049250313E-16)
07:17clojurebot#'sandbox/epsilon
07:17Glenjamin,(< (- 0.3 (+ 0.1 0.2)) epsilon)
07:17clojurebottrue
07:17MJB47i think if i saw that code in a project
07:18MJB47i would become angry
07:18dmsnellMJB47: Clojure is a LISP, so this would normally be a macro if needed
07:18MJB47i mean it works
07:18MJB47but holy magic number batman
07:18Glenjamini'd probably do something like (float= x y)
07:18dmsnell(~= (+ 0.1 0.2) 0.3)
07:19MJB47ye i more meant the def than anything :P
07:19Glenjaminoh, i'd have added a docstring i expect, better than a bare use in-place :D
07:20MJB47sure but
07:20MJB473E-16
07:20MJB47would be better (with a comment)
07:20MJB47imo
07:21MJB47or 2E-16
07:21MJB47w/e
07:22dmsnellMJB47 that value is specifically chosen to be "the smallest value for which two floats could be different"
07:22MJB47i know
07:22dmsnellso in that sense, it's a "discrete" value and changing it to look better for a human would disturb its mathematical value
07:23MJB47but that also means you need to explain why that is the case to every intern that comes through
07:23dmsnelllike PI, why not PI=3?
07:23MJB47or have a mother of all comments
07:23dmsnellit _is_ surprising this doesn't appear to be baked into Clojure, I'll give you that
07:23MJB47w/e im just nitpicking
07:31someone1hi
07:31someone1Caused by: java.io.FileNotFoundException: Could not locate clojure/core__init.class or clojure/core.clj on classpath.
07:31someone1what error is this?
07:31someone1clojure is in my classpath
07:35mavbozosomeone1, did you try to run clojure repl?
07:41someone1mavbozo: no, use clojure from jython
07:49dysfunyou probably want clojure.lang.RT
07:49dysfunand clojure.lang.* generally
07:57prohobowe need some closure
09:29TimMcsomeone1: clojure.core is a Clojure namespace, not a Java package. See above advice.
09:29TimMchmm, looking again, I'm not even sure what exactly you did to provoke that
09:31jondotwhat's the best way to contact rich hickey?
09:31Empperisacrifice your soul to the lambda god
09:31someone1TimMc: I think its a classloader problem
09:31Empperireally, I'm guessing it's not that easy to just contact him - except he hangs around here every now and then
09:32TimMcsomeone1: What did you do to get that error?
09:32TimMcIt will be very hard to help you without that info.
09:32Empperialthough less recently, guess he got to be a too big a celebrity
09:32Glenjaminmost reliable way is to work in the same office as him afaik
09:32Empperiwhen he was a normal programmer kinda guy he used to be here too :)
09:33jondotyes i remember when he was here
09:33jondotbut seriously then, is there any way to contact him? we'd like to get him to speak on a keynote for a conference
09:34Glenjamini'd suggest probably cognitect is your best port of call for that
09:34someone1TimMc: https://nopaste.me/view/c5826bad#mXhyfNTGjnIRRfhTg9W7qUMi4gDzGbHS
09:35TimMcsomeone1: That's a big block of base64
09:35someone1should I feel proud that I talked with Rich in 2008 over IRC? :D
09:35jondotsomeone1: yes!
09:35Glenjaminsomeone1: http://clojure.org/reference/java_interop#_calling_clojure_from_java
09:37someone1Glenjamin: is this somehow build in in JRuby? Because with JRuby, all works like expected
09:38someone1builtin*
09:38Empperijondot: yeah, contact cognitec
09:38Glenjaminno idea i'm afraid
09:38Empperiwith luck you *might* get him as a speaker
09:38Empperibe prepared though to not get him unless your conference is a big one
09:38jondotEmpperi: you think that's impossible?
09:38Empperihe is kinda busy, he chooses the conferences
09:38jondotright
09:38Empperiso definitely not impossible
09:39Empperibut that is a very real possibility that he refuses
09:39jondotsure i can understand
09:39Empperibut if your conference isn't totally insignificant you should be able to get someone from cognitec as a speaker
09:39jondotyou think info@congnitect.com is good? or should i use a better email for such a cold call?
09:39someone1best way is to build a competitive lisp language and take his market shares
09:39Empperithey do have a lot of brilliant guys after all
09:39jondotthat's true
09:40EmpperiRich Hickey is the Big Gun and the most wanted speaker, so there's a lot of demand for him
09:40jondotdamn.
09:41EmpperiI personally haven't tried to get him as a speaker but I do know some people who did :)
09:41Empperiit was one of the largest software conferences in Finland which was centered around clojure that year, didn't interest mr Hickey
09:41Empperinot significant enough
09:41EmpperiI totally understand though
09:42Empperibut they did get Stuart there and he was awesome
09:45jondotEmpperi: so i have something close. Stockholm
09:46jondotany other notable speakers you think of? clojure isn't a focus, but someone with a mind-opening point of view like Rich
09:46EmpperiJFokus would definitely be big enough for Mr Hickey :)
09:46EmpperiI really like David Nolen's talks
09:46Empperidnolen: your welcome for the compliment
09:46Empperi;P
09:47dnolenEmpperi: ha! thx :)
09:47jondotdnolen: ah!
09:47jondotdnolen: would it be appropriate to approach you on this perhaps? :)
09:48EmpperiOm Next style is the future of web development and would definitely be a "mind-opening" kinda of talk
09:49EmpperiI personally am trying to do something similar to Om Next but in a slightly different way for different usage scenarios
09:49EmpperiI'll talk about it later if I get it to something properly working :)
09:49jondotyep, we love Om, didn't realize dnolen is here
09:50someone1jondot: me neither
09:50Empperisuprisingly large portion of significant Clojure people are here or have been here
09:50someone1he destroyed pedestal
09:50dnolenjondot: if you're looking to get in touch with anyone at Cognitect yes I would use that email.
09:50someone1little joke
09:51jondotdnolen: I mean, get in touch with you :)
09:52someone1just watched a talk from him, first comment "Many different interesting ideas, however Clojure looks so strange and difficult to parse."
09:52dnolenjondot: sure send me an email https://github.com/swannodette. Note I may or may not respond for various reasons yadda yadda.
09:52someone1the last part in the sentence is really true :)))))))
09:53jondotdnolen: thanks :)
09:55sdegutisI wrote a bunch of macros. :(
09:55ToxicFrogyay macros
09:55someone1at least you can
10:11sdegutisBut I did :/
10:19sdegutisWell, it's done.
10:26sdegutishttps://gist.github.com/sdegutis/4112dd4989fe7be17326d57d57b3ca6b
10:26sdegutis,(defmacro some-let [bindings body] (let [[x y & rest] bindings] `(if-let [~x ~y] ~(if (empty? rest) body `(some-let ~(vec rest) ~body)))))
10:26clojurebot#'sandbox/some-let
10:26sdegutis,(some-let [a 1, b (inc a), c (inc b)] [a b c])
10:26clojurebot[1 2 3]
10:26sdegutis,(some-let [a (prn :a!), b nil, c (prn :b!)] [a b c])
10:26clojurebot:a!\n
10:27sdegutisVery handy. I may use this every day.
10:27Glenjaminmulti-clause if-let?
10:28sdegutisGlenjamin: similar, yeah
10:28sdegutisGlenjamin: it's basically a nested if-let
10:28sdegutisGlenjamin: it'll short-circuit and return nil if any of the bindings are nil along the way
10:30Glenjamini imagine useful has something similar, although the api docs appear to have gone missing
10:30sdegutisIt should probably use when-let though rather than if-let
10:30sdegutisGlenjamin: I looked in amalloy_'s useful and didn't see anything like it
10:32Glenjaminsimilar-ish to cond-> i guess, but more flexible with how you use the args
10:34sdegutisGlenjamin: im not seeing how some-let is similar to cond->
10:35Glenjaminwell i was thinking you'd often chain values as you went with some-let
10:37sdegutisGlenjamin: the purpose I created it for was so that I can create bindings that are based on other bindings, but short-circuit if any are nil
10:38Glenjaminright, that's sort of what cond-> does, but without the bindings
10:39Glenjaminsimilar sort of "drilling down" effect
11:09sdegutisGlenjamin: ah
11:50sdegutisback
11:53sdegutisGood morning. Is there a built-in way to create a record that conforms to a protocol purely by its keys?
11:53sdegutis,(do (defprotocol Foo (bar [this])) (defrecord RealFoo [bar] Foo) (bar (RealFoo. "foo")))
11:54clojurebot#error {\n :cause "sandbox.RealFoo.bar()Ljava/lang/Object;"\n :via\n [{:type java.lang.AbstractMethodError\n :message "sandbox.RealFoo.bar()Ljava/lang/Object;"\n :at [sandbox$eval68 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval68 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval68 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6927]\n [clojure.lang.C...
11:54sdegutisI'd like to be able to do something like that.
11:54sdegutisKind of like Ruby's #attr_accessor or whatever it's called.
11:54sdegutisOr must I write my own macro to do this?
11:55sdegutisThe problem I'm trying to solve is to have some kind of type-safety on keys on what is currently just a map.
11:55sdegutisI end up typing (:email-service env) and hoping I didn't make a typo, and writing a unit test if I need to prove that I didn't.
11:56sdegutisWhereas I'd like to just have it fail at compile-time if it's not a valid key, like (env/email-service env)
11:56sdegutisI suppose I can just create functions that are the keys, such as (do (ns myapp.env) (def email-service :email-service))
11:56sdegutisThen I can access env/email-service knowing for sure it's legit.
11:57sdegutisOkay, thanks, I'll do that.
11:57sdegutisGood morning justin_smith.
12:00Lewix,(conj nil 0)
12:00clojurebot(0)
12:01sdegutishow are you luma
12:01Lewix,(conj '(1) 0) ;; added in the most natural way ok?
12:01clojurebot(0 1)
12:01Lewix,(conj '(0) 1) ;; added in the most natural !? no way
12:01clojurebot(1 0)
12:03Lewixso no matter what it adds it after the number in this instance
12:03Lewix(class '(:foo))
12:03Lewix,(class '(:foo))
12:03clojurebotclojure.lang.PersistentList
12:04GlenjaminLewix: conj always adds in the most efficient way
12:04Glenjamin,(doc conj)
12:04clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
12:04Glenjaminthat's not very helpful
12:09sdegutiswow I guess everyone else is productive today
12:09sdegutiswell that's good I suppose
12:17justin_smithI'm much more productive now that I only IRC on the mobile (which I have connected to a bluetooth kvm)
12:19sdegutisjustin_smith: nice
12:19sdegutisjustin_smith: on one hand I really enjoy socializing in #clojure (anything more than that is too much socialization for me)
12:19sdegutisjustin_smith: on the other hand, I feel bad like I'm dragging everyone else here's productivity down with me
12:19sdegutisjustin_smith: so its good to see you're being more productive with a clever solution
12:41sdegutisPhew, we're a lot less stringly-typed now.
12:53tolstoyFor some reason, I rarely have an issue with fat-fingered keywords, etc, etc.
12:53tolstoyNot sure why.
12:53tolstoyI used to.
12:54tolstoyI bet I use maps (and so on) in a much more temporary way than I used to.
12:54tolstoyLike Clojure has taught me to be the designer it prefers.
12:59spiedeni habitually use the cursive keyword completion and check the "find usages" popup
12:59spiedenalso use namespaced keywords much more lately
13:00spiedenkeyword indexing can lag behind though it seems
13:01spiedencfleming: should that be the case?
13:02tolstoyI imagine another technique is that outside a concern, the data blobs are largely opaque.
13:03tolstoy(create-email {:to "blah" :from "blah" :smtp "whatev"})
13:03tolstoyThen (email/send email "nub@example.com").
13:03tolstoySo, it's only in the email namespace I ever have to track keywords or worry about types more complicated than strings.
13:04spiedentolstoy: do you use prismatic plumbing's fnk, et al?
13:05tolstoyNope.
13:06tolstoyI'm guessing most of the problems I work on are pretty simple.
13:07tolstoyI do read a config.edn and validate it with schema, then just assume it's valid when I pass a sub-map to a component.
13:07tolstoyWhen I get data from a websocket (say), I use schema to validate it.
13:07tolstoyBut those are the two pain points.
13:08spiedentolstoy: i like the fnk destructuring forms a lot
13:08tolstoyI think if it were all painful to me, I'd just move on to a Haskell of some sort.
13:08spieden.. but yeah, schemas for the entrypoints of data
13:09tolstoyEsp. if other people are going to use it.
13:09tolstoyI've had people send me a JSON doc that was just wrong, but get a cryptic error back and just assume I was a crappy programmer and start digging around in my code.
13:10tolstoyMaybe I am a crappy programmer!
13:10tolstoyBut a nice "missing key" error sure cuts down on people having to be disappointed in me. ;)
13:11sdegutistolstoy: we all are
13:12tolstoyYeah. It's never my fault your lib doesn't work! You clearly don't know what you're doing! ;) Oh, wait. Sorry. <--- programmer mindset
13:14sdegutistolstoy: what do you use instead of maps now?
13:15tolstoyI use maps like everyone else, for the most part.
13:15sdegutisyeah but how is that?
13:15tolstoyI'm just trying to piece together why I don't get into as much trouble with them anymore.
13:16sdegutistolstoy: I've started passing around an "env" map that has keys like :email-service, :env-name, :host-name, :db-connection, stuff like that which changes based on environment
13:16sdegutisI pass it to all my (defn routes [env] [...]) functions, which just return a vector of compojure routes, that capture the env via lexical scope
13:16tolstoyWell, for instance, I like websockets. So, I get a message like [:some/thing {:map "of stuff"}]. Then I destructure, and validate the map, then call a function based on the first word in the tuple, and then the map is over.
13:16sdegutisand they pass it to whatever functions need to send emails or change the DB, etc
13:17sdegutistolstoy: ahh I see
13:17tolstoyThe map is just good for that message, not meant to represent a domain object.
13:17sdegutisright
13:17sdegutishmm yeah I use it for inter-function communication sometimes too
13:18tolstoyI don't think I do that much any more (just evolved to be that way), which I'm guessing is why things seem smoother for me.
13:19tolstoyLately, I get a message in [:topic msg-map] and I've been casting it to a record (map->SaveUser msg-map).
13:19sdegutistolstoy: ah
13:19tolstoyThen I have protocols for that.
13:19sdegutisthanks for ur feedback
13:19tolstoy(if (satisfies? IMutate msg) (protcol/mutate msg db) ...)
13:20tolstoyAlso, (when (satisfied? Validatable msg) (protocols/validate! msg)) and so on.
13:20sdegutistolstoy: I've found protocols & records to be very handy, but only for services which could change depending on whether you're in a test environment (i.e. deftest), development, or production, such as EmailService, LiveEmailService, and MemoryEmailService
13:20tolstoyThen I have a single file "validate" that handles that concern for all (or most) messages.
13:21tolstoysdegutis: That's what I use them for too. I have a Publisher component, for instance (def record) which I can re-instantiate with different topics. But they all implement the send! protocol.
13:22sdegutishmm interesting
13:22tolstoysdegutis: The advantage of converting a message or data item to a record is you can hang protocols on it. No matter what the message is, you can call "validate" on it, for instance.
13:22sdegutistolstoy: do you work on a clojure app full time btw?
13:23tolstoyI'm freelance at the moment, so, yes and no: quick and dirty apps, for the most part.
13:23sdegutistolstoy: hmm interesting, re: "validate" & protocols
13:23sdegutistolstoy: not sure I fully understand, but..
13:23tolstoysdegutis: It's overkill on a small app, but starts to work out well (I think) for a big app.
13:25sdegutishmm
13:25tolstoyThink of a validate namespace (myapp.lib.validate ...), and then (extend-protocol Validatable m/UserCreate (validate [_] ...) m/UserEdit (validate [_] ...) m/AccountDelete (validate [{:keys [id auth]}] ...)). All your "validation" is in that one file, and dispatched based on the type of message.
13:26sdegutistolstoy: ahh, that's an interesting way to do it
13:26tolstoyWith a web socket, there's just one end point, so instead of a giant case statement for each type of message, I have a "process!" function that tests which protocol a given message implements, then invokes the right function.
13:27tolstoyAll the database query stuff is in one file, the database mutate in another, all based on the type of message.
13:27tolstoyDownside: Stuff starts to get spread out. You have to edit four files for ever new message you want to process.
13:28tolstoyUpside: your one file isn't 1000 lines long. ;)
13:28tolstoyOy.
13:28tolstoyANYWAY, what I don't do is pass maps from one component to another, to seems. ;)
13:28sdegutistolstoy: I see this making a lot of sense when you have a single entry-point into the system
13:28tolstoyYeah.
13:29sdegutistolstoy: in our case we handle them on a case-by-case basis, for better or worse, since we just use plain-jane HTTP
13:29sdegutisunrelated, there should be a one? function
13:29sdegutis,(defn one? [x] (= 1 x))
13:29clojurebot#'sandbox/one?
13:29sdegutis,(map (juxt neg? pos? zero? one?) (range 10))
13:29clojurebot([false false true false] [false true false true] [false true false false] [false true false false] [false true false false] ...)
13:30tolstoyHeh. We already have zero?. So, zero? one? a-few? a-lot? tons? webscale?
13:30sdegutisI too often wanna check if there's only one item in a collection.
13:30sdegutisLike, 4 times so far..
13:30sdegutisso that's about.. once per year
13:31rcassidyseveral?
13:31tolstoya-scosh?
13:31tolstoysmidgen?
13:32TimMc(defn big-data? [n] (< 40 n))
13:32sdegutishaha
13:32TimMcIf you don't think 40 is a big number, I challenge you to eat 40 hot dogs in a sitting.
13:33sdegutisTimMc: thats an interesting way to look at it
13:33sdegutisTimMc: I would have done (> n 40)
13:33TimMcsdegutis: Yeah but then your number line is backwards. :-P
13:34TimMc<---39-40-41---n--->
13:35sdegutisTimMc: interesting
13:53bendlashi, are there read-cond flags for cljs macros?
14:05TMAactually, 40 was established as value of infinity in ancient middle east
14:25sdegutisha
14:33anewell, it's more than 39
14:41rcassidyhttp://www.therobotsvoice.com/wp-content/uploads/2011/03/lexluthorcakes.jpg
14:59jjmalinarcassidy where is that from
15:02TimMcSo many!
15:02TimMcTMA: Seems implausible. :-)
15:10TMATimMc: it does: https://en.wikipedia.org/wiki/40_%28number%29#In_religion
15:16Empperiyou must have edited that page just before pasting the link, spent the last hour typing that stuff in
15:16Empperilmao
15:17TimMcTMA: Eh, that's not infinity, that's "large number"
15:26TMATimMc: that's nitpicking :) the English word "forever" is too understood as a "long time" not as "infinite time" in day-to-day contexts; likewise "infinite" is "too large number to count" -- “It seemed like forever ago, like we've had this brief but still infinite forever. Some infinities are bigger than other infinities.” ― John Green, The Fault in Our Stars
15:31rcassidyjjmalina: http://knowyourmeme.com/memes/lex-luthor-took-forty-cakes
15:33gganleyHi, I'm starting a project that needs a connection to an IRC server. I've never made a program that uses the network this way but I've worked on a lot of Cisco routers so I have plenty of knowlage of the protocol itself. I'm just looking for some advice on how to start in network programming. it doesnt have to be clojure specific but i would like if it was
15:36Empperiyou insist on doing the IRC stuff yourself?
15:36Empperior do you want to use a library for that
15:41gganleyin my mind its a good learning opertunity but I'm not opposed to using a library
15:42Empperithis is an old java library but it works for irc communication http://www.jibble.org/pircbot.php
15:42Deraengganley: You could take a look at https://github.com/Raynes/irclj for IRC impl
15:43DeraenAleph might also be interesting if you want to do async TCP/UDP stuff
15:45gganleyI just found aleph also
15:46gganleyit uses the manifold library which im havent heard of
15:51anemanifold is great
16:10asdf12z_if i have a program (server) running using clojure, and i repl into it to update some code, will it crash if my updated code throws? is there a way to make it just fallback
16:10anedepends if it's the main thread
16:54Lewiswhat does it mean to thread an expression through a variable number of forms?
16:55ridcully,(-> 1 inc inc inc)
16:55clojurebot4
16:56luma,(-> 1 (+ 2) (* 3) (+ 4))
16:56clojurebot13
16:56luma,(+ (* (+ 1 2) 3) 4)
16:56clojurebot13
16:56lumathose forms are the same thign
16:59yottabyteis it difficult to add a clojure class to a java web application and have it work with other java classes
17:00rcassidythe double arrow threads in last position so you can do things like
17:00hiredmandepends what you mean
17:00amalloyyottabyte: it's easier to instead use a clojure function (or functions), and write a java wrapper class that acts as a facade for it
17:00rcassidy,(->> "abcdef" (.toUpperCase) (take 3) (reverse))
17:00clojurebot(\C \B \A)
17:00hiredmanclojure doesn't have something called a 'class'
17:00yottabyteamalloy: can you show me an example of that?
17:01amalloyhttps://github.com/amalloy/thrift-gen
17:10jbrhbrhey guys. i've been trying to learn clojure and have been doing some of those codewars kata. i have a solution that's mathematically correct but i think i'm getting an ob1 error due to precision rounding or something with respect to sqrt's behavior with bigints. would anyone mind taking a look at what i have and letting me know if you see anything funny? https://gist.github.com/jerryhebert/ecf54d3c33faa0c0c4d9a19efd5d1199
17:11jbrhbrtrying to avoid writing it some other way since this one is basically just a math problem
17:12jbrhbrthe issue is (find-nb 10252519345963644753026N) yields the solution 450010N, but verifying 450010N yields 10252519345963644753025N (off by 1)
17:13lumaMath/sqrt takes and returns a double
17:14lumathat's where a precision error probably comes fro
17:14jbrhbryeah
17:15jbrhbrit's all i can see too, i guess i was just hoping it was overloaded for bigints or something
17:15lumanope
17:16jbrhbri'm honestly surprised it's this close if it isn't doing something near-correct tho
17:16rcassidyyou might just need to implement bigint sqrt logic yourself
17:19jbrhbrit's actually producing the correct value for 20250148500407250495000225N, somehow. guess i'll have to poke around some more
17:20jbrhbrand that one is way more than 64bits
17:21jbrhbrthanks for the input
17:33jbrhbri discovered this today: (number? (Math/sqrt -1)) => true
17:33jbrhbri'm sure there's a good reason for it but NaN being a number is pretty funny :p
17:36rhg135,(Math/sqrt -1)
17:36clojurebotNaN
17:36hiredmanyou may be confusing math with computers
17:37rhg135I is dissapoint. that's i/j
17:38hiredman,(type NaN)
17:38clojurebot#error {\n :cause "Unable to resolve symbol: NaN in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: NaN in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: NaN in this conte...
17:38hiredman,(type Double/NaN)
17:38clojurebotjava.lang.Double
17:38hiredman,(supers (type Double/NaN))
17:38clojurebot#{java.lang.Comparable java.io.Serializable java.lang.Number java.lang.Object}
17:38jbrhbra NaN type could be its own class that isn't a number, for less language asymmetry
17:40hiredmanNaNs exist as part of floating point standards, so just don't do floating point
17:40hiredmanjbrhbr: and then the return type of Math/sqrt is either double or whatever NaN is
17:41jbrhbrsure
17:41hiredmanand of course, Math/sqrt doesn't return an Object anyway, it returns primitive
17:41jbrhbri'm not denying there are good explanations
17:42jbrhbrbut the english "not-a-number is a number" is funny
17:42jbrhbrthat seems like a jvm oddity to me though
17:42hiredmanit isn't it is built right in the hardware
17:43jbrhbrit's a design choice
17:43jbrhbralternative: raise an exception when your function is cornered into making a weird type choice
17:44amalloyjbrhbr: seems like a pretty reasonable alternative is: "follow the IEEE spec everyone else follows"
17:46hiredmanthe fp spec folds nan values and floating point valus in to the same bit space, the fpu instructions all take those bit patterns and produce them
17:47jbrhbramalloy: that spec doesn't define a language type system
17:47jbrhbrsorry if i offended you guys, it was meant to be a joke
18:09aptablipsHi. Quick Clojure question: How do you do an inexact numerical comparison? For example, I'd like this to come out true: (= (+ 0.1 0.2) 0.3)
18:09TEttingergood ol' epsilon.
18:09TEttingeraptablips: arguably the simplest way for those exact numbers is
18:10aptablipsYou mean I should just compare with the absolute value of the difference?
18:10TEttinger,(= (+ 1/10 2/10) 3/10)
18:10clojurebottrue
18:10aptablipsWell, those exact numbers are only an easy illustration. My app needs floating point. :)
18:10TEttingeryeah, sadly
18:11TEttingerthe ratios are a pretty useful concept, though they need more numeric tower support
18:12aptablipsHmm, well, googling for "clojure epsilon" just turned this up: https://crossclj.info/doc/avenir/0.2.0/avenir.math.html#_approx%3D
18:12TEttingerI was just going to do
18:12aptablips(defn approx= "Approximate equality test within epsilon ( *default epsilon* 1e-6)" {:added "0.2.0"} ([x y] (approx= x y 1e-6)) ([x y epsilon] (< (abs (- x y)) epsilon)))\
18:13TEttingerok you got it :)
18:13aptablipsWell, the formatting got messed up. But it does exactly what one would expect.
18:13aptablipsThanks! (I only just started Clojure a couple days ago.)
18:14TEttingercool. there's a few neat things you might not have seen yet in regards to those floating point things
18:14TEttinger,1M
18:14clojurebot1M
18:14TEttinger,0.0001M
18:14clojurebot0.0001M
18:14TEttinger,0.00000000000000000000000001M
18:14clojurebot1E-26M
18:15aptablipsBigDecimal, then? How is it on performance? I need this thing to run super-fast.
18:52sdegutisHello!
18:52sdegutisHow are you this evenign?
18:53sdegutisHello justin_smith how are you?
18:53tolstoyAvoiding his phone, apparently. ;)
18:53sdegutisGood day TEttinger how is your status thus far?
18:53TEttingeris good.
18:53sdegutistolstoy: Good evening kind sir, what is your state now?
18:54sdegutisTEttinger: I am glad to hear this.
18:54tolstoyWrapping protocols around defrecords. Like any other day.
18:54sdegutistolstoy: Adds up.
18:54sdegutisI have found that a few glasses of alcohol increases my ability to concentrate and thus my productivity.
18:55sdegutisHowever, it decreases my ability to hit the correct keys on the keyboard, which seems to neutralize at least some of the productivity benefit.
18:55sdegutis(Since I have to backspace quite often.)
18:55sdegutisAlso, it increases my ability and will to DANCE!!!
18:55sdegutisI am sciencing alcohol.
18:56sdegutisEspecially to Bon Iver, which is a homonym for the French phrase for "good winter", which I suppose is due to it sounding very much like winter when I listen to them.
18:57sdegutis:)
19:03sdegutisamalloy_: I'm not sure if you're aware of it, but your IRC nick often changes between amalloy_ and amalloy.
19:03sdegutisamalloy_: At least N times per hour, where N is roughly a unit.
19:05sdegutisYeah, like that.
19:11amalloyhave you also noticed that i am never signed out of irc?
20:06cflemingspieden: I've noticed that too, but I haven't had time to investigate.
20:06cflemingAll the other indexes update pretty much immediately, but that one lags for some reason.
21:20sdegutisamalloy: yes
21:31amalloyi will give you a hint, sdegutis: those two phenomena are closely linked
21:31sdegutisamalloy: it wasn't a mystery for me to solve, requiring hints
21:31sdegutisamalloy: it's a "feature" you may want to consider disabling
21:32sdegutisbbl renting The Usual Suspects
21:32amalloyi could. i think it's nice for people to know that i'm not actually here by looking at my nick
21:43sdegutisamalloy: that would be cool, if it were always accurate, but in my experience those things are often very inaccurate
22:03TimMcSome channels kick people for changing their nick as an afk indicator.
22:03TimMc(which just raises the question: who doesn't ignore nick changes?!)
22:29machinewarif I do doseq over a sequence of maps with possibly nested maps, willl it visit every key?
22:30machinewarhttp://www.chrisumbel.com/article/clojure_xml_parsing_xml-seq I'm reading this and can't understand how I can get to every nested key in the sequence as in first example it does!
22:46TimMcmachinewar: It will only "visit" the maps themselves.
22:48TimMcmachinewar: Ah, I think I see your confusion -- you'd be iterating over a seq of all the XML nodes. I think you're confusing maps with keys with XML nodes maybe?
22:48TimMcNot sure what your goal is.
22:54justin_smithmachinewar: look at what xml-seq outputs for that example file
22:55justin_smithmachinewar: https://gist.github.com/noisesmith/5e277b89e2c6cb7c00525378a74a721d
22:55justin_smiththat should make it clear how doseq found the nested tags
22:55justin_smithoutput is from loading a copy of the data in that post
22:56justin_smithxml-seq is a tree walk
22:56justin_smithit returns each node, until it hits all the leaves
22:57machinewarjustin_smith: ahhh wow
22:57machinewarwhat a function!
22:58machinewari'm stilll getting the hang of this whole functional thing, and its insane how powerful some of these standard library functions are
22:58justin_smithalso, they combine in really powerful ways, yeah
22:59machinewarthanks for pointing that out
22:59TimMcI should... not be trying to answer questions, and go to bed. :-P
22:59machinewarTimMc: thanks to you too