#clojure logs

2014-12-16

00:00andyfWhat expressions are the \2 and \3 supposed to refer to there?
00:06andyfSeems like a reasonable definition would be that it could match the string "xx", where (y) matches nothing, and so does \3, but the Java regex implementation doesn't see it that way.
00:09gfredericksyeah that's a good summary of my thoughts
00:09rritochgfredericks: There is no third term so what is the point of \3?
00:09gfredericksrritoch: there is
00:10gfredericksI wonder how easy it is to statically determine whether a regex has such impossibilities
00:10andyf\3 should refer to expression starting with 3rd (
00:10rritoch,(clojure.string/replace "xxx" #"((x)|(y))" "$3")
00:10clojurebot""
00:10rritoch,(clojure.string/replace "xxx" #"((x)|(y))" "$2")
00:10clojurebot"xxx"
00:13rritochgfredericks: I obviously need to dig more into the docs but $3 is returning that which isn't matched ##(clojure.string/replace "dxxxe" #"((x)|(y))" "$3")
00:13lazybot⇒ "de"
00:14gfredericks,(clojure.string/replace "yyy" #"((x)|(y))" "$3")
00:14clojurebot"yyy"
00:15gfredericksI don't understand that "de" part
00:15TEttingerit's replacing it with an empty string
00:15gfredericksoh right
00:15TEttinger##(clojure.string/replace "" #"(.)" "$9")
00:15lazybot⇒ ""
00:16TEttinger##(clojure.string/replace "a" #"(.)" "$9")
00:16lazybotjava.lang.IndexOutOfBoundsException: No group 9
00:16TEttingeroh!
00:16TEttingerinteresting
00:17TEttingeroh ok
00:17TEttingerso it never matched y, so group 3, (y), was empty
00:18TEttinger##(clojure.string/replace "a" #"((h)|(i)|(j))" "$4")
00:18lazybot⇒ "a"
00:18TEttinger##(clojure.string/replace "a" #"((a)|(h)|(i)|(j))" "$4")
00:18lazybot⇒ ""
00:18TEttinger##(clojure.string/replace "a" #"((a)|(h)|(i)|(j))" "$2")
00:18lazybot⇒ "a"
00:19TEttingerso you can't use $n to get an n that is higher than the number of groups in the regex.
00:19TEttingerbut if those groups were empty, the $n for that group will be ""
00:20TEttinger##(clojure.string/replace "dxxxe" #"((x)|(y))" "$1")
00:20lazybot⇒ "dxxxe"
00:25rritochTEttinger: Ok, I see, my problem was that I was only working with the x values of the problem. ##(list (re-matches #"((x)|(y))\3" "xx") (re-matches #"((x)|(y))\3" "yy"))
00:25lazybot⇒ (nil ["yy" "y" nil "y"])
00:26rritochgfredericks: I believe you are right, the regex you provided is unmatchable because either \2 or \3 will have a value, but not both. Or so it seems.
00:42rritochDoes clojure have anything similar to LPC reg_assoc? http://discworld.atuin.net/lpc/playing/documentation.c?path=/driver/efuns/strings/reg_assoc ?
00:48justin_smithsomething like this? ##(let [[a b c] (re-seq #".a." "happy and sad")] [c b a])
00:48lazybot⇒ ["sad" " an" "hap"]
00:48justin_smithno, that's not the same at all
00:50rritochjustin_smith: Yeah, this is for natural language processing, you pass it an array of patterns which are each attempted, and when a match is found it returns the token associated with that expression.
00:54rritochjustin_smith: I coded it once in pike https://github.com/rritoch/PikeVM/blob/master/root/boot/system-1.1/simul_efuns.pike#L648-L719 but right now I can't recall how the no-match moves forward
00:55justin_smith,(condp re-find "hello" #"good" :exit #"sup" :stay #"hel" :greet)
00:55clojurebot:greet
00:55justin_smithstill not it
01:11rritochjustin_smith: Well, either way I need to add this to my todo list, but I am not looking forward to it, but being able to tokenize a string with regular expressions is occasionally useful.
01:11justin_smithwhy not a proper parser?
01:13rritochjustin_smith: Parsers in java tend to be a bit slow, even if you use a stringbuilder. Regular expressions are implemented in native code in many languages so it is usually faster. I am not sure if java uses a binary library to backup regular expressions though.
01:40Html-01 someone is here ? ì
01:41justin_smithyeah, there area a few of us here
01:41Html-01someone here is a unity 3d programmer ?
02:04rritochDoes anyone know how to monitor for creation of a certain DOM node when using PhantomJS? Specifically I want to pause until a certain condition is met, such as document.getElementById returns non-null.
02:28BorisKourtI can't figure out how to turn something like: {:z [[:z 262.0] [:z 262.0] [:z 262.0]] :x [[:x 262.0] [:x 262.0] [:x 262.0]] : y [[:y 262.0] [:y 262.0] [:y 262.0]]}
02:28BorisKourtinto just this: {:z [262.0 262.0 262.0] :x [262.0 262.0 262.0] :y [262.0 262.0 262.0]} can anyone help?
02:28BorisKourtpreserving order in the vectors
02:28SagiCZ1BorisKourt: you can call set on each of the key
02:28SagiCZ1,(set [262.0 262.0 262.0])
02:28clojurebot#{262.0}
02:29SagiCZ1or distinct
02:29SagiCZ1,(distinct [262.0 262.0 262.0])
02:29clojurebot(262.0)
02:29SagiCZ1wait, nevermind
02:29BorisKourt[[k a] [k b] [k c]] into [a b c]
02:30Empperi,(into {} (for [[k v] {:z [[:z 262.0] [:z 263.0]]}] [k (map second v)])
02:30clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
02:30Empperi,(into {} (for [[k v] {:z [[:z 262.0] [:z 263.0]]}] [k (map second v)]))
02:30clojurebot{:z (262.0 263.0)}
02:30andyfBorisKourt: Maybe you want to call #(map second %) on each value in the map?
02:30BorisKourtIll try Empperi's solution one moment
02:38BorisKourtEmpperi works perfectly thank you
02:38Empperinp
02:55ottihas someone a clue how i can close database connections when using korma that is based on jdbc?
03:02nXqdhi guys, what is this kind of variable, does it have any special meaning or just naming convention : options#
03:02nXqd(let [options# (dissoc ~options :xml?)]
03:07luxbocknXqd: it's syntax sugar for `gensym`
03:07luxbocknXqd: it's used to create unique local variable names inside macros
03:08nXqdluxbock: thanks ! it is, I just forgot what I read yesterday ...
03:16rhg135Is gensym unique per VM invocation?
03:21andyfrhg135: yes
03:22rhg135Good, andyf , i considered UUID
03:22rritochrhg135: It is not guaranteed. I tested this myself by launching (gensym "x") as the first repl command, and repeating, I received the same value. So it is not guaranteed unique
03:23rhg135D:
03:23andyfWait, when you say "per VM invocation" I thought you meant "within a single JVM running a single instance of Clojure". Within that, it is unique. Across different JVM invocations, the names can be the same.
03:23rhg135,(repeatedly 3 gensym)
03:23clojurebot(G__27 G__28 G__29)
03:24andyfgensym source: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L558
03:24rritochrhg135: You can use UUID to get guaranteed unique gensyms though
03:24opqdonutandyf: I think it's more like "per clojure classloader" or something like that, if you unload all the clojure stuff from your jvm, you'll probably get the same values again
03:24rritoch,(gensym (.toString (java.util.UUID/randomUUID)))
03:24clojurebot176704f8-55bc-476c-9b62-0b0c30c0a2de54
03:25rhg135im using it to label strings i get over irc
03:25rhg135im not to worried
03:26rhg135If i get non uniques chances are im OOM anyway
03:27TEttingerrhg135, add the timestamp then
03:29rhg135TEttinger: it's completely possible for two people to say something
03:29TEttingerat the same millisecond?
03:29TEttingerwith the same username?
03:29rhg135I could lean on the fact lazybot runs sequentially
03:30TEttingerheh
03:30rhg135But it smells ugly
03:30andyfIf you are willing to look up new messages time stamps in the collection of previous messages, you can append a unique counter value per second or millisecond to the messages that occur at the same time.
03:31rritochTEttinger: On IRC it is because of network latency, if both messages arrive on the same packet, and your code is extremly fast (such as using multiple threads).
03:31rritochTEttinger: For a single threaded app, it would probably be impossible.
03:34rhg135Im indexing by network channel and gensym I think I'm just being paranoid about collisions
03:35rritochrhg135: A single person isn't going to be able to send two messages at the same millisecond, not even a bot. If you don't like UUID's for some reason, you could use something more exotic, like a SHA256 hash of the catenated string of username, IP, and timestamp (ms).
03:36rritochrhg135: There are no known collissions of SHA256 yet.
03:36rhg135rritoch: you beat me in paranoia lol
03:37TEttingeror inc a ref
03:38rhg135Isn't this basically a gensym, assuming I run one JVM which I hope so?
03:39rhg135To the counter not hashing
03:40TEttingeryeah, except it isn't clear how well many many gensyms work without collision
03:42rhg135,(reduce = true (repeatedly 100000 gensym))
03:42clojurebotfalse
03:42rhg135Oops
03:43rritochHas anyone here used clj-webdriver? I thought I found a solution to my problem by using wait-until, but it's implementation doesn't seem to work as I keep getting "No implementation of method: :wait-until of protocol" errors.
03:49rhg135Gensym seems unique
04:07TEttinger,(distinct (repeatedly 100000 gensym))
04:07clojurebot(G__27 G__28 G__29 G__30 G__31 ...)
04:07TEttinger,(distinct? (repeatedly 100000 gensym))
04:07clojurebottrue
04:07TEttingerthere we go
04:08yogsotothikitommi_: thanks I just saw your message.
04:18rhg135TEttinger: thx
04:28amalloyTEttinger: ITYM (apply distinct? ...)
04:28amalloy,(distinct? (repeat 100 10))
04:28clojurebottrue
04:29TEttinger,(apply distinct? (repeat 100 10))
04:29clojurebotfalse
04:29TEttinger,(apply distinct? (repeatedly 100000 gensym))
04:29clojurebottrue
04:32rhg135Why is Symbol an IObj and keyword not?
04:33andyfI guess if you are going to stress gensym, realize that it can only return 2^32 unique gensym's, since it is based on the AtomicInteger class.
04:35nXqdcan we disable a test in clojure by adding _ prefix ?
04:35nXqdskip*
04:36luxbocknXqd: you can ignore any expression by prepending it with #_
04:36nXqdluxbock: thanks :)
04:37luxbockI'd like to get a sanity check for something that I'm working on
04:37luxbockI have a C library that I call via Clojure's JNA that crunches some data for me, and this data can take up to 50gb of memory to hold
04:38luxbockand I'd like to save this data on disk, and then serve it via a ring based Clojure web app
04:39luxbockthe data is basically just a collection of double-arrays
04:40luxbockso I think for saving disk space I should keep it in the native data format, and I'm thinking about using ztellman's Gloss for this
04:42luxbockI've also thought that maybe I should use Gzip to minimize it further, and to transport it to the client for the webapp
04:42luxbockdoes this all seem sensible?
04:43zarkonehello all. I want to learn apache storm and try to implement my first example. In examples data in spout is always local.. Is there simple example with outer source, e.g. from websoket stream
04:54rritochIs there any way to automatically ungreedy a regular expression? I tried using flag 512 from PCRE but java doesn't honor that flag for ungreedy.
04:54rritochI just need to mimic the ungreedy flag of PCRE.
04:55BorisKourtIs there a library or set of examples that deal with analysis of numeric collections? Having a hard time describing what I need. Some sort of super rudimentary wave analysis, grab highest peaks, average amplitude, sustain, and other 'wave shape' facts? This is not related to sound.
04:56vijaykiranBorisKourt: doesn't Incanter have something like that ?
04:56dysfunincanter has loads of stuff like that
04:57BorisKourtIt likely would, I am hesitant though as my sets of data are miniscule and this is not meant for any visual output whatsoever. Ill take a look for sure if there is no smaller alternative.
05:01BorisKourtLooks like its innards do have just what I want. Thanks. Now to get it into the project :)
05:03rritochWill this mimic perl's /U (ungreedy) properly? (defn ungreedy [re] (re-pattern (clojure.string/replace (.toString re) #"(\*)([^?])" "$1?$2")))
05:05andyfrritoch: It does not cover * at the end of regex, nor handle the difference in their meaning when they are inside of [], and it doesn't include +
05:06andyfprobably a few other things that I'm not thinking of, but not sure
05:06rritochandyf: Ok, as for the * at the end of the regex, isn't that ungreedy?
05:07rritochandyf: I'll have to check but I'd think "/.*/U" would still match the entire string
05:08andyfparsing regex's to modify them is not something I'd do lightly, if I wanted it to be correct in all cases.
05:11amalloyandyf: it woulsn't be quite so bad if rritoch were actually parsing them. but just wanton string replacement is going to be a disaster. there are a *lot* of cases this ungreedy function misses that you didn't think of
05:13amalloyeg, #"\Qabcd*\E"
05:13amalloyor #"abc\*def"
05:13amalloyand it doesn't un-greedify the + repetition operator, or the {N,M} operator
05:15andyfamalloy quantifies my unnamed fears. Thanks amalloy :)
05:15amalloyclojurebot: amalloy |is| your unnamed fears made real
05:15clojurebot'Sea, mhuise.
05:16birdspiderhello, how would I access a inner enum value ? (https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/Pixmap.java Pixmap's Format/RGBA8888 for instance)
05:19rhg135I love having a good gc
05:20rhg135Pixmap$Format/xxx
05:29andyfrritoch: I'd suggest if you truly need PCRE capabilities, you use actual PCRE library. Going to the trouble of building it and calling it via JNI or similar mechanisms might be more pain than it is worth.
05:30andyfGoogle searches for existing PCRE library implementations in Java are not promising.
05:32rritochandyf: Thanks, for now I'm just trying to see if I can just solve the currently mentioned issues.
06:48hellofunkis this most elegant way to assoc the same value into all the maps that are values of a sorted map? https://www.refheap.com/94984
06:49hellofunkbasically taking the map apart and then putting it back together.
06:49hellofunki suppose an alternative would be to reduce over the map but wouldn't be more elegant
06:50trissis there a form of let where all functions used take the same first argument?
06:50trissso I say:
06:50triss(let [a (func ctx)
06:51triss b (func-two ctx)
06:51martinklepschis there a reason = works for one argument as well?
06:51trissc (func-three ctx)] blah blah)
06:51trissbut i don't want to type ctx all the time
06:51jack_rabbittriss, not that I know of... You could easily macro it if you do it often.
06:52hellofunktris you could (defn f [func] (partial func ctx)) then do (let [a (f func..) b (f func-two)
06:52hellofunktriss ^
06:53hellofunkor you could put the defn f as the first let form
06:54trisscheers guys. I'll have a play.
06:54hellofunki can't tell if you are defining fns or calling them but you get hte idea
06:55trisscalling them...
06:55hellofunktriss: (defn f [x & a] (apply x 2 a))
06:55hellofunkthen if you do (f inc) or (f + 5 6) whatever, the arg 2 is added to every call
06:56trisscheers. hellofunk that's splendid.
06:56hellofunkjack_rabbit: definitely don't need or want a macro for this. it's basic FP at work
06:58trisswell it's not saving that much typing as it is.... a macro would result in cleaner code.
06:58hellofunktriss: no, first rule of macros, never use a macro if a good higher order function will do the trick instead
06:59hellofunkthere is no reason for a macro here.
06:59trissI'm writing a little DSL for doing web audio stuff.
06:59hellofunkDSL's typically use macros, but the problem you've presented is not good macro material
07:00trissok man. I can see why they'd be avoided. I'll bare that in mind and try and get things done functionaly.
07:01luxbockhellofunk: I would use reduce-kv, but I don't think it makes a big difference
07:01hellofunkwhenever you are trying to consolidate functions, as you are, or consolidate args to functions, etc, then this is normal stuff for FP without macros
07:01jack_rabbithellofunk, if he wants to write just [a (func) b (func-two)] I don't see a way around it.
07:02hellofunkjack_rabbit: he wants to pass other args but keep one arg the same for the functions
07:03hellofunkunless i misunderstood his question
07:03jack_rabbitI still don't see the problem with a macro, if that's what he wants to do. It's only worthwhile if he's doing it lots of places (probably not), but if he wants to do this, setting up the environment without a macro would be more code than just inserting the first parameter where it goes manually.
07:04jack_rabbithellofunk, no, I reread it. I think you're right.
07:05hellofunkwhether you are "setting up more code" by not using a macro, or setting up more code by writing the macro, either way it's all code. and in this case the important uses for macros isn't apparent here. he is not delaying evaluation of arguments, for example.
07:07jack_rabbitMy only argument is that if this is worth doing, it's worth putting in a macro, so he doesn't need to "set up the code" everywhere. If it's not worth doing that, it's just easier and more readable to put the argument where it goes in each function call.
07:08hellofunkbuilding the HOF only needs to be done once, just as writing a macro would probably be done once, so it's not causing lots of code to get written everywhere
07:09jack_rabbitWell, it would need to be done once for each let, no?
07:10hellofunkjack_rabbit: then it wouldn't go in a let, it would be its own separate function
07:10jack_rabbitThat's fine. You'd still need something like [a (f func) b (f func-two)] which is not quite the requirement
07:10clgvif really need, a macro combining `let` and the `doto` like fill-in would be the way to go
07:12jack_rabbitunless I'm mistaken. [a (f func) b (f func-two)] doesn't seem any better than [a (func ctx) b (func-two ctx)]
07:20clgvjack_rabbit: that simple pattern word be solvable via `juxt`
07:20clgvtriss: (let [[a b] ((juxt func func-two) ctx)] ...)
07:24jack_rabbitclgv, thanks! I was unaware of that.
07:25jack_rabbitclgv, although, I don't see that he could add other parameters to those functions.
07:25trissah very nice. thanks clgv
07:25hellofunkjack_rabbit: the point is that with func and func-two, you are now having to define each of those, which isn't making anything easier
07:26trissfunc & func-two are already defined in a library
07:27jack_rabbithellofunk, sorry, I miss your meaning.
07:30jack_rabbitAt the very least, something *like* juxt could be written as a function that would satisfy triss's requirements. Not exactly to how he specified them, but close enough probably. Better than a macro.
07:31clgvjack_rabbit: yeah, well for the most flexible scenario you'd need a macro
07:31jack_rabbitclgv, right.
07:31clgvjack_rabbit: although the difference to an higher order function can be made pretty small
07:32jack_rabbitright again
07:33clgv(defn invoke-with-ctx [ctx & fns] (reduce #(conj %1 (%2 ctx)) [] fns)) called via (invoke-with-ctx ctx #(some-fn % arg2 arg3) #(other-fn % arg4))
07:35jack_rabbitNot quite so elegant.
07:36clgvjack_rabbit: yeah, but probably the closest you can get with a higher order function
07:37jack_rabbithmm... what about something that would result in a call like (invoke-with-ctx ctx [some-fn arg2] [other-fn arg2 arg3])
07:37jack_rabbitThat shouldn't be too hard.
07:37clgvjack_rabbit: easy to do, but not much better
07:37jack_rabbitLooks a little better *maybe*
07:38clgvyou have replaced the lambdas by implicit specification...
07:40jack_rabbitIt only looks better. Is it inferior in some way?
07:41jack_rabbit(apply (first fn-seq) cxt (rest fn-seq))
07:42jack_rabbitctx even
07:43clgvI don't think it is. More code in the implementiation but not problematic
07:44jack_rabbitRight. I just like the look of [some-fn arg2] better than #(some-fn % arg2)
07:56trissI'm feeling like a proper noob today. super slow.
07:56trissso if i want to adda new namespace to a project I just create a folder....
07:56clgvtriss: source file and potentially a folder
07:56trissstick my my-ns/core.cljs my-ns/thing.cljs
07:57clgvtriss: namespace my.lib.core needs to be in my/lib/core.clj
07:57trissand then I can require it another namespace via (:require [my-ns :as my-ns])
07:58clgvno. you need to require the full namespace
07:58trissoh yeah so (:require [my-ns.core :as my-ns])
07:58triss?
07:58clgvnamespace "my.lib.core" needs to be in "my/lib/core.clj" and is required via (:require [my.lib.core :as mlc])
07:59trissgod dman I don't understand why it;s not being seen
08:00trissI get the error message:
08:01trissWARNING: Required namespace not provided for hm.core
08:01trissbut hm.core lives under my source folder in hm/core.cljs
08:01trissclojurescript btw
08:03clgvtriss: you got an "(ns hm.core ...)" expression in that file?
08:04trissyup.
08:04trissi just restarted the repl....
08:05trissnow the cljs compiler has stopped warning me but in the browser I'm told hm.core can't be found:
08:06triss Uncaught Error: Undefined nameToPath for hm.corebase.js
08:06trisserm ignore the base.js on the end of that
08:07trissI'm using figwheel... could that make things more complex?
08:09clgvtriss: the provided information is not enough to be able to help you further. try to minimize the project setup until it stops failing, then you usually find the problem.
08:09trisscheers man will do
08:11dnolen_triss: there's also a #clojurescript specific channel you might want to join.
08:11trissoh... hadn't spotted that. thanks dnolen.
08:27michaelr525hey
08:52thatguyanyone have a favorite validation library for web forms? building my first and the options are almost overwheliming
09:14SagiCZ1thatguy: i have no experience in this matter, but what seems so complex about it?
09:25thatguyprobably nothing, just seeing what people have had success with
09:27zotrandom idiom: i have a variable that gets updated in a loop. go figure. in any case, is there a naming convention for these sorts of things, similar to A and A' (A-prime)?
09:32clgvzot: not that I know. if you don't need the old value you should bind it to the name of the loop argument to avoid errors
09:33clgv*you should bind the new value to the name of the loop argument
09:33zotgenerally i do, but sometimes it's useful to have both; foo-cur and foo-next work, but i thought there might be sth already "normal"
09:35clgvzot: not really since it is application specific anyway. in a time series calculation "v_n+1 (f v_n)" might be a documenting name
09:38clgvzot: I have used both "prime" and "subscript-like indices"
10:01craigglennieI’m trying to write a toy web-scraper for threadless.com. The site has multiple pages of links to t-shirts. I would like a function that produces a list of all the links, moving to the next page as needed. In Python I could use a generator that took the starting URL, extracted product links to a list, yielded them one-by-one, and repeated this for the next page once the list of product links was empty. If there was no next page the generator would
10:01craigglennieexit. How would I go about something like this in clojure? I’ve looked at lazy-seq but I’m not sure that it’s the right answer
10:02craigglennieI also thought about using a list comprehension, but it doesn’t seem quite right, either
10:02SagiCZ1you could use lazy-seq
10:02teslanickYou could use core.async to do something like a producer-consumer.
10:04hellofunkthatguy are you talking about browser-side web form validation?
10:04craigglennieteslanick: That sounds like what I’d want - would that also allow for the consumers to work in parallel?
10:10teslanickcraigglennie: Yes. One go-block would consume the pages and put to a channel. Another (pool?) of go-blocks would consume the channel and generate a list of links.
10:12ebaxtIs there a simple way to access the constructor function (map->Name) of a record given only an instance of the record?
10:16justin_smithtriss: quick correction - my-ns.core needs to go in src/my_ns/core.clj - note the underscore
10:19craigglennieteslanick: Thanks, I’ll take a look at core.async - I had wanted to parallelize this anyway
10:21EvanRjoin #haskell
10:22EvanRs/^/\//
10:23justin_smithebaxt: it is possible, since the class of the record and the namespace it is in will match up, but there is no simple method
10:24justin_smithebaxt: but if you have the thing already you can use (into (empty this-record) {:some "input"})
10:24justin_smithwhich does what map->Name does anyway
10:25ebaxtjustin_smith: thx, guess I will have to call qualified_record_name/name or empty the map like you say
10:25justin_smithwell that's not "emptying the map"
10:25justin_smithit just makes an empty record, of the same type as the input
10:25justin_smithrecords are immutable
10:26pjstadigi don't think empty works on records
10:26ebaxtjustin_smith: ah, didn't see the into. Nice, thanks a lot!
10:26justin_smithpjstadig: actually, you are right, my bad
10:26justin_smithebaxt: never mind, i expected empty to work on records, but it does not
10:26pjstadigit would be nice if it did :)
10:27pjstadigdissoc'ing any of the basis keys in a record cause it to "degrade" to a plain hashmap
10:27justin_smith,(defrecord MyRec [a b])
10:27clojurebotsandbox.MyRec
10:27justin_smith,(def r (MyRec. 0 1))
10:27clojurebot#'sandbox/r
10:27justin_smith,(into r {:a 42})
10:27clojurebot#sandbox.MyRec{:a 42, :b 1}
10:28justin_smithso that works, but will leave the old values for anything you did not specify
10:28EvanRwhats the difference between defrecords and maps, practically
10:29justin_smithyou can implement protocols on records
10:29pjstadigEvanR: some performance differences when you access the basis fields, and you can extend protocols to them
10:29EvanRi implemented protocols on the map though
10:29pjstadigthey are also a distinct type
10:29justin_smithEvanR: but what if you wanted to implement the protocol differently on a different map
10:30justin_smithrecords are distinct classes, so they can be extended seperately
10:30EvanRok
10:30EvanReach record schema has to be a dedicated type/class ?
10:30ebaxt,(sandbox.MyRec/create {:foo "bar})
10:30clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
10:31justin_smithEvanR: defrecord creates a class
10:31pjstadig,(sandbox.MyRec/create {:foo "bar"})
10:31clojurebot#sandbox.MyRec{:a nil, :b nil, :foo "bar"}
10:31ebaxt,(sandbox.MyRec/create {:foo "bar"})
10:31clojurebot#sandbox.MyRec{:a nil, :b nil, :foo "bar"}
10:31EvanRlike, it registers a new class name? or its anonymous
10:31justin_smithEvanR: there is no such thing as an anonymous class
10:31pjstadig,(class MyRec)
10:31clojurebotjava.lang.Class
10:31clgvEvanR: usually you should use a map. if a map is not sufficient anymore you can switch to a record.
10:31EvanRthere isnt?
10:31pjstadiger
10:31pjstadig,(class r)
10:31clojurebotsandbox.MyRec
10:32justin_smithEvanR: nope, the closest you get is gibberish auto-generated names
10:32justin_smith,(class (fn [x] x))
10:32EvanRok that explains that
10:32clojurebotsandbox$eval232$fn__233
10:32justin_smithnames like the ones you get for fn
10:37arkhI was wondering if someone could explain defmulti to me. I have a map like the following: {:something/new {:id 1 :userid 100}} and like to run maps like that through a multimethod. I'm trying to do variadic argument deconstruction but I'm not getting something right
10:37arkh(defmulti foo (fn [[k v & xs]] k))
10:38justin_smiththat is not variadic
10:38justin_smiththat is destructuring a single arg
10:38arkh(defmulti foo :something/new [[k v & xs]] (:id v))
10:38arkhI'd like to do variadic destructuring on that single arg
10:38andyfarkh: Will all of your maps have a single key/value pair? If not, the particular key/value pair chosen will vary from map to map.
10:39justin_smitharkh: you don't need to do the & xs part at all for destructuring to work
10:39arkhall the maps will have a single key value pair
10:39arkhok
10:39justin_smith,((fn [[a b c]] c) (range)) ; arkh
10:39clojurebot2
10:39justin_smithwhere (range) of course produces an "infinite" series of numbers
10:40arkhI'm trying to understand that magic right now ... ; )
10:40justin_smithit's not magic, destructuring does not specify the length - it only specifies which parts you have names for
10:40justin_smithit's not pattern matching
10:41arkhright - my brain just had to catch up. I think I get it now
10:41justin_smithalso, maps through list destructuring is a bit odd, because maps are not ordered
10:42arkhtrue, but I thought it would be ok if my maps are only a single key/value pair
10:42justin_smithnope, nth not supported, it will fail
10:42arkhthat's what the repl was saying too
10:42arkhfair enough
10:42justin_smith,((fn [[a b]] b) {:a 0 :b 1})
10:42clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap>
10:42justin_smith,((fn [[a b]] b) (seq {:a 0 :b 1}))
10:42clojurebot[:a 0]
10:43justin_smithso you could add seq to your defmulti definition
10:43arkhsure!
10:43justin_smithor just not try to destructure maps with list destructuring
10:44arkhthank you
10:45justin_smithhaha, you could define a defmulti for your dispatch function for your defmulti
10:45justin_smithyo dawg, I heard you like multimethods...
10:45arkhno need(!)
10:45arkh#xzibit #yolo
10:49craigglennieAnother question… In my toy web-scraper I am going to be extracting data from multiple sites, each with their own layouts. I’d like a common public interface to each scraper; in OO I would have an actual interface, or an abstract base class. In Clojure I could put each scraper in it’s own namespace, and just make sure each one implements the appropriate functions, but it seems like multi-methods or protocols might also be appropriate. Any
10:49craigglennieadvice?
10:49clojurebotthe tao of warfare is deception
10:50justin_smithcraigglennie: if performance is not the main concern, multimethods are more flexible, and easier for interactive usage (you can actually redefine them and may not break things)
10:51justin_smithand a protocol is literally an interface plus some niceties - it literally compiles down to a java interface in the bytecode
10:52craigglenniejustin_smith: Performance is not a concern (I’m still just trying to learn Clojure) so multimethods might be good.
10:52craigglennieInteractive usage would probably be nice, too
10:52justin_smithcraigglennie: another option is to write a higher order function, and pass in the function that fulfills some task it needs
10:53justin_smiththat would be the old-school-lisp (pre-clos) option
10:54arkha warning on interactive usage of defmulti - it can't be redefined at the repl apparently
10:54justin_smitharkh: it can, you just need to undef it first
10:55justin_smith,(defmulti foo :x)
10:55clojurebot#'sandbox/foo
10:55justin_smith,(defmulti foo :y)
10:55clojurebotnil
10:55justin_smith,(ns-unmap *ns* 'foo)
10:55clojurebotnil
10:55justin_smith,(defmulti foo :y)
10:55clojurebot#'sandbox/foo
10:55arkhnice
10:56justin_smithclojure.tools.namespace has some utilities for this kind of redefinition stuff
11:03puredangeryou can also (remove-all-methods foo)
11:03justin_smithoh, I was not aware that existed, cool
11:04justin_smith(inc puredanger)
11:04lazybot⇒ 25
11:08andyfClojure cheatsheet has what I think are all multimethod-related functions/macros grouped together in a Multimethod section, including remove-all-methods: http://jafingerhut.github.io Most other related functions/macros are grouped near each other, too.
11:10ppppauldoes read-string work with cljs?
11:13chouserppppaul: yes, but consider cognitect/transit, depending on use case.
11:26arkheven if there's clojure on both sides of the communication is cognitect/transit still recommended from a e.g. compression standpoint?
11:28tomjacktoo bad #(partition-by f %) can't be like #(eduction (partition-by f) %)
11:28stuartsierraarkh: Transit will usually be faster than EDN.
11:28puredangerarkh: if all-Clojure, then Fressian will be faster than Transit or EDN (also does caching)
11:28stuartsierraarkh: Because Transit can take advantage of platform-native JSON libraries.
11:29stuartsierraHi puredanger!
11:29puredangerHI
11:30stuartsierrappppaul: read-string is in its own namespace in cljs, I think it's called cljs.reader
11:30chouserbut fressian isn't a real option in ClojureScript yet
11:31arkhmy use case is clojurescript on one side and clojure on the other - thanks!
11:32puredangerin that case, I'd use Transit
11:32chouserditto
11:39annapawlickampenet: hi Max, how do I do “UPDATE users SET top_places[2] = 'riddermark' WHERE user_id = 'frodo’;” using hayt?
11:44verma,(def options ["hello" "world"])
11:44clojurebot#'sandbox/options
11:45verma,(for [o options] {:text o :selected false})
11:45clojurebot({:text "hello", :selected false} {:text "world", :selected false})
11:45vermadafuq
11:45vermawhen I am doing it here in cljs, its giving me an emtpy {} in that list
11:45vermachecking again
11:46ppppaultransit is an optimization... i'll use it in the future.
11:47tickingeverytime I use fold I get bitten by argument counts changing on mapentry, please somebody tell me that this is done with a sane reason
11:49puredangerticking: don't understand what you mean
11:49trissso is there anything in the library that's equivalent to (comp doall repeat)
11:49tickingreduce and reducers/reduce have different semantics
11:49triss?
11:49stuartsierratriss: dotimes
11:49puredangerticking: you mean around maps in particular ?
11:50tickingpuredanger: to be more precise, reduce and clojure.reducers/reduce behave differently on maps, reduce will require you a function like (fn [acc [k v]] while reducers/reduce will require (fn [acc k v]
11:50trissso dotimes returns the list of things it acts on?
11:51tickingpuredanger: yeah
11:51stuartsierratriss: No, it's just for side effects.
11:51tickingtriss: no
11:52tickingtriss: most functions in clojure that do things just for side effects make this explicit by returning nil, e.g. dorun println dotimes
11:53trissah ok....
11:54trissso its seems doall is the only one that returns...
11:54tickingall yes
11:54puredangerticking: yeah, it was done for efficiency I believe
11:54trissi suppose mapv sort of fits in there
11:54tickingpuredanger: I think in the code there is an explicit check for this case which would seem slower to me
11:55puredangerI believe it has to do with parallel folding over maps but I haven't looked at in depth
11:55stuartsierratriss: In general, the "do" is a hint that these functions are reserved for side effects. It frequently doesn't work out well to combine the lazy-sequence functions with side effects.
11:55tickingpuredanger: https://github.com/clojure/clojure/blob/f3259f4f34a68eae7db7efc0be9d19fa5dafbd3c/src/clj/clojure/core/reducers.clj#L77
11:55tomjackticking: I guess (r/map identity) is a "just reduce please" shim
11:56tickingtomjack: yeah but urgh
11:56tomjack(which makes some parts of me unhappy, since (r/map identity) should be identity!)
11:56tickingtomjack: that this "fixes" it shows how broken the current behaviour is
11:56tickingtomjack: yeah exactly :D
11:57ppppauli'm using datascript and it comes with some readers in a file. how do i get my cljs read to use those? (right now i'm doing a (swap!...) in my application code
11:58dnolen_Bronsa: ping
11:58puredangerticking: the clojure map impls can .kvreduce themselves and avoid creating every intermediate entry object
11:58puredangerticking: only to then tear it apart again into k and v
11:59tomjackbut we have reduce-kv already
11:59puredangerthe reducer impl is trying to have the best of both reduce and reduce-kv automatically
11:59tickingtomjack: reducers/reduce uses reduce-kv internally
12:00puredangerthere is a ticket to consider this aspect again for transducers in 1.7
12:00puredangersorry in 1.8
12:00tickingpuredanger: really transducers do this to?
12:00tomjackI guess the auto-kv behavior is specialized for stuff like conj?
12:01puredangertomjack: not sure what you're thinking of
12:01tomjackcan't be just "I don't have to type -kv when I know I'm reducing a map", I presume
12:02puredangerI think there would be more double work than just that inside reducers
12:02tomjackso it only makes sense if the binary op is also at least ternary, like (conj coll k v)
12:02stuartsierra,(conj {} :key 3)
12:02clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword>
12:03dysfunis anyone using core.async with aleph? or is there something aleph-like people are using with it?
12:03tomjack,(conj [] :key 3)
12:03clojurebot[:key 3]
12:03stuartsierra,(conj {} [:key 3])
12:03clojurebot{:key 3}
12:03tickingwow
12:04stuartsierraconj is variadic, but key/value pairs must be passed as a vector.
12:04tickingand this is done by transducers as well?
12:04puredangerno, not right now
12:04puredangerthere's a ticket to consider this again
12:05tickingpuredanger: do you have a link for the ticket? can't seem to find it :/
12:05puredangerCLJ-1552
12:05tickingpuredanger: thanks :D
12:05puredangerhttp://dev.clojure.org/jira/browse/CLJ-1552
12:05stuartsierrapuredanger is the kinder, gentler interface to JIRA
12:05tickinglol
12:06tomjackstuartsierra: if you knew you were reducing a map, you could just call reduce-kv. so I'm trying to think of cases where the reducing fn works for either reduce or reduce-kv
12:06puredangerI just loaded it all into my brain and can regurgitate it at will
12:06dysfunthere used to be a workable emacs library for doing jira things
12:06dysfunthat was vastly preferable to the web interface
12:06stuartsierratomjack: I think that would be pretty rare.
12:06puredangerI have a Clojure library that can access it
12:06puredangerthat I wrote to scrape jira
12:06dysfunnow we just need someone to finish DEUCE and we can use that, heh
12:07tickingpuredanger: I'm begging you please don't do this :D, it is so horribly confusing and breaks abstraction in so many ways, (reduce ... foo should equal (reduce ... (map identity foo
12:07puredangerI'm about 90% of the way towards an automated program that can scrape it and replicate it (with history) in Datomic :)
12:07tomjackif it's rare, why https://github.com/clojure/clojure/blob/f3259f4f34a68eae7db7efc0be9d19fa5dafbd3c/src/clj/clojure/core/reducers.clj#L77 ?
12:07dysfunpuredanger: great, now you have to write datomic bindings in elisp. that's gonna be *fun*
12:08puredangerdysfun: well I don't need that :)
12:09puredangerticking: I'm mostly in agreement
12:09kenrestivodysfun: aleph has its own async-like thing called manifold (in case nobody answered already)
12:09puredangerin a side bar, I've built a new direct iterator for maps (CLJ-1499) and also built a variant of it that would provide a new direct iterator for only-keys and only-values (which avoids this same intermediate entry cost). it was surprisingly (to me) not much faster
12:09dysfuni'm tickled by the idea of just treating it as a database though
12:10dysfunkenrestivo: yeah, i was just reading through it. i understand there's interop with core.async
12:10tickingpuredanger: interesting, JIT being fancy?
12:10puredangerticking: the cost of allocating and throwing away small Java objects is really really low these days
12:10dysfuni've got a brand new app and i've been looking for a reason to play with core.async, so it seems like a fun project
12:11tickingpuredanger: long live the generational gc and david ungar :D
12:11puredangerheh. I've tried to get him to speak at Strange Loop a couple times, just hasn't worked out
12:12tickingpuredanger: too bad :D, I'd love to hear some more stuff from him, self is so awesome
12:13puredangerhe seemed interest, maybe in the future. just bad timing in the past.
12:14puredangerticking: anyhow, what I got from the key/val iterator experiment was that we're not getting *that* much benefit from reduce-kv over reduce
12:14puredangeronce you're leveraging transducers/reducers
12:15tickingpuredanger: good to hear, every time an implicit reduce-kv is used god kills a kitten ;)
12:15puredangerand maybe the complexity of reduce-kv is not worth it. unrolled small collections will also possibly make this faster
12:16tickingpuredanger: yeah, can't wait for the small fixed arity vectors
12:28hellofunkis this most elegant way to assoc the same value into all the maps that are values of a sorted map? https://www.refheap.com/94984
12:30joegalloyou might (empty sorted-map-in) rather than invoking (sorted-map) directly.
12:30joegallobut besides that it seems like perfectly fine code
12:31joegalloyou also could have used a reduce rather than an into/for, but that's a matter of taste, imho
12:31joegalloi prefer the into/for route, but that's just me
12:31clgvwhich is the default library to implement a service via ring + compojure consuming and producing JSON?
12:32weavejes_clgv: There's ring-json
12:33clgvweavejester: I just found that, but it's use case is serializing return values only. what is the usual setup to get the json data from the request?
12:33weavejesterclgv: It does both
12:34clgvah thank you. quick reading was too quick ;)
12:35dnolen_puredanger: is CLJ-1499 ready to go? http://dev.clojure.org/jira/browse/CLJS-836
12:36m1dnight_Can I use an atom to wait() and notifyAll()?
12:37m1dnight_Or should I create a seperate object for that?
12:41EvanRwhen i do future-cancel, and then the corresponding java Future.cancel "cancels a task if possible", what exactly does this mean?
12:41EvanRwhat if my "task" is blocking waiting for something
12:41EvanRdoes it really cancel?
12:43justin_smithEvanR: well, .cancel is a method on java.util.concurrent.Future http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Future.html#cancel(boolean)
12:43justin_smithit returns a boolean that tells you whether it was actually cancellable
12:45EvanRso future is the recommended way to spawn a thread to do something, possibly forever?
12:45llasramEvanR: And the actually mechanics of the interruption will generally defer to http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#interrupt()
12:45EvanRllasram: thanks for that, i was really wondering
12:45justin_smithEvanR: it's one way to do it, and it tends to work pretty nicely
12:46justin_smith(inc llasram)
12:46justin_smiththanks for the extra info
12:46lazybot⇒ 43
12:46EvanRon one hand you see people saying threads cant be killed/cancels/interrupted, and then theres this interaction with Future
12:46justin_smithEvanR: not that they *can't* be
12:46justin_smithjust that there is no foolproof way to do it
12:46llasramExactly. It's just ultimate cooperative
12:47llasramultimately
12:47EvanRand then theres this Thread.interrupt which suggests that it works if its sleeping or "doing IO"
12:47EvanRand not if its busy looping
12:47llasramExactly -- that's the "cooperative" part
12:48justin_smithEvanR: if you have a loop in your future, check (.isInterrupted (Thread/currentThread)) before recurring
12:48EvanRgood to know
12:48justin_smitha future-cancel will set the interrupted flag
12:48justin_smiththen you are cooperating :)
12:48EvanRim planning to be blocking-dequeuing
12:48EvanRthen looping
12:49EvanRso hopefully i dont need to check the flag explicitly
12:57justin_smithEvanR: I'd say a check on that flag can't hurt and could possible help "If none of the previous conditions hold then this thread's interrupt status will be set." - better safe than sorry
12:58EvanRyes
12:58justin_smithit's effectively a race condition, if you catch the thread while it isn't blocking, the interrupt is a no-op (other than setting that flag)
12:59EvanRhold on... what would cause a no-op?
12:59justin_smiththe thread isn't blocking, so none of the listed exceptions are triggered
12:59EvanRwhat exceptions
13:00justin_smiththe ones listed before "If none of the previous conditions hold then this thread's interrupt status will be set." in the docs llasram linked to
13:01EvanRurg
13:01justin_smithwhich makes it clear that you should check that status, to be safe ##(.isInterrupted (Thread/currentThread))
13:01lazybot⇒ false
13:02justin_smithyou can wrap it in a function (defn alive? [] (not (.isInterrupted (Thread/currentThread))))
13:02EvanRso if it happens to not be blocking on the queue, the flag will get set and obviously nothing like ClosedByInterruptedException will be thrown, and then later it will attempt to dequeue, and the flag being set doesnt make a damn of a difference?
13:02EvanRit will just continue?
13:02justin_smithas llasram meantioned, at the root, it is cooperative, you need to check that flag to cooperate
13:02justin_smithEvanR: exactly
13:03EvanRgot it
13:04EvanRand also i need a loop recur, not normal recursion for a thread like this to work?
13:04EvanRor is there something like "loop forever"
13:06justin_smithusing the function I defined above (while (alive?) ...)
13:26danneubuilding an oauth api at the moment. can anyone recommend a site with a pleasant oauth api experience that i can swaggerjack some ideas from? so far i'm aping twitter and github
13:28danneutook a gander at oauthbible.com and was paralyzed with indecision
13:28ajmccluskeydanneu: Stack Overflow works well from memory
13:28danneuajmccluskey: thanks
13:29danneulinkedin ranks up there among the worst oauth apis i've used, though
13:35TimMcdanneu: What made it bad?
13:37ajmccluskeyIs there a library function to check "cyclic equality"? e.g. (ce? [1 2 3] [2 3 1]) => true
13:38justin_smithI assume this is more strict than (= (set a) (set b))
13:39ajmccluskeyjustin_smith: yeah - I'm looking at a path through a graph where I can start from any node in the path - so order matters, but not starting point
13:39justin_smithI checked clojure.math.combinatorics, it was my first guess, but seems to have nothing like that
13:40ajmccluskeyI'm thinking I can roll my own easily enough with a rotate fn, iterate, and some
13:40justin_smithI bet a combination of cycle and take would be useful
13:41justin_smith,(take 4 (drop 2) (range 4))
13:41clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core/take>
13:41justin_smitherr
13:41justin_smith,(take 4 (drop 2 (range 4)))
13:41clojurebot(2 3)
13:41justin_smith,(take 4 (drop 2 (cycle (range 4))))
13:41clojurebot(2 3 0 1)
13:42ajmccluskeyjustin_smith: thanks, something like this should make for a neater rotate function
13:43EvanRcalculate the cyclic equivalence class representative and compare those
13:43trissok so I've got a load of static data in: resources/public/my_files
13:44trisshow do I add a route to compojure that serves these up?
13:44justin_smithEvanR: that is awesome, TIL
13:44justin_smith(inc EvanR)
13:44lazybot⇒ 7
13:44EvanRwuh
13:45justin_smith?
13:45justin_smithtoday I learned
13:45EvanRi didnt even think my idea was that great
13:45justin_smithheh, no, it's the right answer here
13:49ajmccluskeyEvanR: I don't know enough maths to understand what you mean :(
13:50TimMcEvanR: You mean rotate to lowest-ID element or something?
13:51TimMcso [9 7 23 4 10] would be become [4 10 9 7 23]
13:52EvanRgood idea ;)
13:54justin_smithajmccluskey: the idea is to define a rotation that would be guaranteed to give you the same result for any rotation of the same items (eg. TimMc's suggestion of rotating so the lowest item is always first before comparing)
13:55ajmccluskeyjustim_smith: gotcha
13:55TimMcThere's probably some higher-performing approach where you take the first element of the first path, find a match in the second path, then walk both and compare.
13:55ajmccluskeyTimMc: EvanR: thanks
13:55TimMcDo you know for sure that your paths are simple cycles?
13:55TimMcor whatever the term would be
13:56ajmccluskeyTimMc: I thought of that, but my paths may traverse the same node multiple times
13:56TimMcIn that case finding the class representative could be tricky.
13:56EvanRsounds like a more sophisticated notion of equivalence
13:57TimMcPathological cases could look like ##(take 20 (interleave (repeat 0) (range)))
13:58lazybot⇒ (0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9)
13:58TimMcerr, close enough
13:58ajmccluskeybasically, yes
13:59TimMcThe slow and simple approach it is!
14:00ajmccluskeyright now I was just looking at doing this for a unit test, so the easiest approach is to manually verify that my returned path is equivalent to the expected output in the sense I'm thinking and then reorder the expected output
14:00TimMcThis is probably a *great* opportunity to use test.check, by the way.
14:01ajmccluskeyTimMc: good point. I'm verifying an eulerian path, so I guess I could verify that the path is valid and contains each edge only once.
14:05ebaxt,(defrecord Foo [a])
14:05clojurebotsandbox.Foo
14:05ebaxt,(eval (list (symbol (str (-> (Foo. "a") class .getName) "/create")) {:a "a"}))
14:05clojurebot#sandbox.Foo{:a "a"}
14:05ebaxtI can't figure out how to do the above without eval, any suggestions?
14:07gfredericksebaxt: what's the input? an instance of Foo?
14:08gfredericksebaxt: it's not clear what the crucial part of this is that you're trying to replicate
14:09ebaxtgfredericks: I'm trying to call the constructor function of a record using only an instance of that record
14:09gfredericksebaxt: I assume assoc wouldn't work for your use case?
14:11ebaxtgfredericks: So basically I want to call (map->Foo {:a "a") , only I must figure out which record by the instance passed to me
14:15gfredericksI don't think there's any clean way to do this, but maybe cleaner than what you have
14:15ebaxtgfredericks: I have a couple of workarounds.But I'm trying to understand why the above works but not (. (resolve (symbol (-> (Foo. "a") class .getName))) create {:a "a"})
14:15gfredericks,(Foo. 2)
14:15clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Foo, compiling:(NO_SOURCE_PATH:0:0)>
14:16justin_smith. is a reader macro, you cannot synthesize args to it
14:16justin_smithyou need eval for that
14:16TimMcajmccluskey: I was thinking more that test.check might help you generate some really good pathological test cases. :-)
14:16Bronsaebaxt: you have to use reflection
14:16mgaare_ebaxt: you could create a Constructible protocol and implement it on the records you want, if you know them ahead of time
14:17ebaxtmgaare_: Yeah, that's the workaround I'm going with
14:17mgaare(probably with a different name, one that's spelled correctly at least)
14:17Bronsaebaxt: core.incubator has a new-by-name function you can use
14:18ajmccluskeyTimMc: my code got me past the question in my course, so I'm almost scared to go there right now. Got a deadline :p. Definitely want to throw test.check at it when I get time.
14:18puredangerdnolen_: re CLJ-1499, it's ready to be screened (hey, you could help with that wink wink)
14:19dnolen_puredanger: heh ok
14:19ebaxtBronsa: thanks, that worked
14:19puredangerdnolen_: I'm still mentally wondering whether I should push forward with the additional stuff I have on it for key- and val-only iterators
14:20ebaxtjustin_smith: thanks btw, that explains it
14:20Bronsapuredanger: btw re: 979 I tried loading aleph/lamina/core.typed with the new patch and didn't see any slowdown in compilation times. If anything I actually saw a minor performance improvement but that was probably a random fluctiation
14:21puredangerBronsa: I'm not really expecting any slowdown, but it's a question that needs to have an answer
14:21dnolen_puredanger: probably not a bad idea? keys / vals is quite common. CLJS used to not have keys / vals specific iterators, adding them lot match Clojure made a huge difference.
14:21dnolen_s/lot/to
14:22puredangerdnolen_: I added a new interface to obtain those specific iterators, then made use of them in CLJ-1602. surprisingly little improvement.
14:22puredangerover the improvements already in 1602 that is
14:22puredangermaybe a 5% additional benefit
14:23dnolen_puredanger: you benching against zipmap usage or something like that?
14:23puredangerthere's a test in 1602
14:23puredangerthere are so many outstanding patches with perf improvements in different areas right now, it's hard to keep them all straight :)
14:24puredangerreduce over maps, keys, vals, range, repeat, cycle, iterate, vec, etc!
14:26puredangerdnolen_: the additional iterators required the creation of a new interface (I called it MapIterable) to provide them. I wasn't sure if I was pushing it too far for a 5% benefit.
14:27dnolen_puredanger: right 5% seems kind small
14:28puredangerit's basically just saving the cost of creating and throwing away the entry objects, but object allocation is really fast these days
14:29puredangermaybe I'll make a separate ticket for it so it can be evaluated separately
14:34EvanRjustin_smith: what about easily getting exceptions from the future thread
14:35noonianEvan I believe if you deref a future that threw exceptions it will throw it on the thread you deref the future from so you could try/catch your deref
14:35noonianEvanR*
14:35EvanRright...
14:36EvanRthough my main thread is busy, it cant wait forever on a particular future
14:36EvanRand yet another thread for this purpose seems to have the same issues
14:39noonianif you want to know about exceptions on your main thread but dont want to block maybe core async is appropriate? could have a channel and deref your future in another thread (of just try/catch in your future thread) and put on the channel if you get an exception
14:40EvanRi dont even want to know about it in the main thread
14:40EvanRi just want the error print out somewhere
14:40EvanRi guess i have to catch all exceptions in the future
14:40nooniancan't you just wrap your call inside future in a try/catch block then?
14:44znnwhat is the difference between a channel and a message bus?
14:45znnor is a channel another term for a bus and vice versa?
14:45noonianin this context a channel is specific to core.async, its like a queue with "blocking" put/read semantics by default
14:47zanesAw man. I guess instaparse can’t parse indentation?
14:48gfrederickszanes: I think I remember coming to that conclusion at some point
14:48zanesgfredericks: Sad panda.
14:48gfredericksis generating keywords w/ test.check a guaranteed memory leak?
14:48reiddraperprobably
14:49gfredericksI can't remember if they get GC'd somehow
14:49amalloyEvanR: you can put a try/catch in your future that prints the exception somewhere useful, or even write a macro/function that does that. or you can set the defaultuncaughtexceptionhandler for your whole program, which controls what happens when an exception makes it out of a thread's run() method
14:50amalloygfredericks: pretty sure they do get GCd
14:50stuartsierraKeywords are interned as WeakReferences.
14:50amalloyas long as you don't hang onto them, anyway
14:51noonianzanes: this stackoverflow talks about trying to parse indentation ala python in instaparse: http://stackoverflow.com/questions/16779676/can-i-parse-an-indentation-based-language-using-instaparse-or-any-other-clojure
14:51zanesnoonian: Yeah, thanks. I saw that one.
14:52zanesSerializing it and running it through instaparse a second time feels gross.
14:52gfredericksstuartsierra: amalloy: yeah that was my hunch
14:52noonianagreed
14:52amalloygfredericks: if you're interested, the relevant code is in Keyword.intern and Util.clearCache
14:52gfrederickshas anybody written a JSONish generator for test.check yet?
14:53amalloygfredericks: how would that be different from (fmap json/generate-string ...)?
14:53gfredericksI remember bbloom complaining about parsing json with keywords...I assume that's just because calling .intern at runtime is slow, not because of memory concerns
14:53stuartsierraIt's not clear to me if Keyword automatically removes references to interned keywords that are never used.
14:53bbloomgfredericks: ignoring perf, i'm complaining semantically
14:53puredangerstuartsierra: yes
14:54puredangerthat is, yes they should get removed
14:54amalloystuartsierra: never used? they're used once, of course, when they get interned. but after that if nobody has any references to them, they get cleaned up
14:54Bronsastuartsierra: yeah, see Util.clearCache
14:54bbloomthe day you decide you want a map with URLs as keys is the day you say "fuck. i wish i didn't keywordize everything"
14:54gfredericksamalloy: it wouldn't be necessarily generating the strings, just a restricted set of scalars & collections -- e.g., only vectors (no lists/sets), no characters, only keyword keys (or strings if bbloom is looking)
14:54gfredericksI think I might have just started three parallel conversations
14:54amalloyi always weigh in with bbloom on this one
14:54puredangerbbloom: given the evil things URLs do with the network, I don't think I'd use java.net.URL as a key in a map
14:54amalloygfredericks: it's a test of character. you've just started a fourth i think
14:54TimMcOoh, this is my favorite complaint too!
14:55bbloompuredanger: no, i meant string encodings of URLs
14:55stuartsierraAn interesting idea: "soft intern" — create a new keyword, but only intern it if it's already interned.
14:55amalloyanyone who can keep up is clearly of high moral fibre
14:55puredangerbbloom: withdrawn :)
14:55bbloompuredanger: ie anything other than a valid keyword as a property which is valid json
14:55amalloystuartsierra: why would that be useful? it's not different from the regular intern except that it allocates a map entry briefly, right?
14:55bbloomhell, even just id numbers :5 vs "5", neither of which are 5, which is invalid json
14:56gfredericksk I'm prollably gonna put a json-data generator in test.chuck
14:56stuartsierraamalloy: It's a vague thought: If I'm creating keywords from JSON, or an HTTP request, or something, I don't want interned keywords for things which weren't already keywords in my code.
14:57dgleesonhello all, does anyone know if there is a way to get at the file attributes of a file in clojure? I can see how to read and write, but what if I want to know the permissions or ownership?
14:57stuartsierraBut I guess I wouldn't want them to be keywords at all.
14:57puredangergfredericks: regarding your comment N messages ago, in 1.7 keywords and symbol no longer string intern
14:57amalloystuartsierra: right, exactly: you don't want keywords
14:57amalloyif you *did* get keywords which weren't interned, you would be inviting disaster
14:57stuartsierrayeah, right
14:57stuartsierraof course
14:57gfrederickspuredanger: oh I remember seeing something about that; curious what the advantage is there
14:57puredangerintern is slow :)
14:58gfrederickspuredanger: does that mean keyword comparisons might require string comparisons?
14:58puredangerkeywords are still cached
14:58dgleesonoh, doh, I suppose I could just use the java interopt to get that
14:58gfredericksokay that's the detail I was missing
14:58amalloygfredericks: for your json generating thing, you can just do some slight tweaks to gen/any, right?
14:58stuartsierradgleeson: Yes, you will have to use Java interop.
14:58puredangergfredericks: the cache code was tweaked slightly too to make it faster
14:58gfrederickspuredanger: so before it was effectively "interning" in two steps?
14:59gfredericksamalloy: totes
14:59gfredericksamalloy: also maybe use my double generator
14:59puredangergfredericks: yes, it's all tricky
15:02gfredericks~it is all tricky
15:02clojurebotAlles klar
15:04gfredericksI just sampled an old json generator I wrote and got: {:--:Rb!?8:tTJi-:iB5:8*?*m false, :JJ:8:3:T (), :d+eI:L:!KXg false}
15:04gfrederickscurious if that's even readable
15:04gfredericks,{:--:Rb!?8:tTJi-:iB5:8*?*m false, :JJ:8:3:T (), :d+eI:L:!KXg false}
15:04clojurebot{:--:Rb!?8:tTJi-:iB5:8*?*m false, :JJ:8:3:T (), :d+eI:L:!KXg false}
15:08TimMcgfredericks: Make sure to throw some \u2028 and \u2029 in there for good measure.
15:10gfredericksTimMc: in the oven: https://github.com/gfredericks/test.chuck/tree/regexes-2#string-from-regex
15:11TimMcoooo
15:13amalloygfredericks: i don't want test.chuck to subsume my library, but are you aware of https://github.com/amalloy/thrift-gen ?
15:14TimMcgfredericks: Please tell me you have a macro that turns that BNF into clojure code. :-)
15:14gfredericksTimMc: what? you mean instaparse?
15:15gfredericksamalloy: nope
15:15TimMcDoes instaparse do that?
15:15gfredericksTimMc: well it turns the BNF into a parser...
15:16amalloywhat BNF are we even talking about?
15:17gfredericksI hope this one, otherwise I'm even further confused: https://github.com/gfredericks/test.chuck/blob/regexes-2/resources/com/gfredericks/test/chuck/regex.bnf
15:18amalloyman, who looks in resources/ anyway?
15:18uptowni have a different generation question. i seem to spend a lot of time wrapping fns for use by controllers of some sort. 'component' for instance. has anyone tried to generate those wrappers? maybe scanning code based on metadata tags or similar?
15:32TimMcI think that's called spring.
15:33TimMcand it is the source of all evil
15:36clrndhey is there something like Akka for Clojure?
15:36xemdetiaspeaking of sources of evil, does anyone know of a quick and dirty LDAP server for integration testing?
15:36uptowni was hoping for a clever metamacro
15:36uptownbut i see what you mean
15:40amalloyi think sdegutis has something vaguely like the evil uptown is thinking of, but i don't recall the details
15:42gfredericks~metamacros are functions for writing macros for writing macros for writing functions for deleting your code
15:42clojurebotCool story bro.
15:42gfredericks~metamacros |are| functions for writing macros for writing macros for writing functions for deleting your code
15:42clojurebotYou don't have to tell me twice.
15:49turbofailclrnd: there's some libraries that do bindings for akka - https://github.com/setrar/akka-clojure
15:50turbofailmight be a little bit dead though
15:51clrndturbofail, I see, was hoping for something actually clojurist
15:52turbofailmessage-passing isn't really the clojure way™
15:53stuartsierramessage-passing — with queues — is totally the Clojure way!
15:53stuartsierracore.async + your messaging bus of choice is really all you need.
15:54dnolen_reiddraper: ping
15:54turbofaili guess i meant more "erlang-style message passing"
15:54reiddraperdnolen_: pong
15:55dnolen_reiddraper: I have a some real interest to just port test.check a la core.async now (rather than wait for feature expressions), I've already started, probably won't take me long to wrap it up
15:55dnolen_reiddraper: would you take a patch?
15:55clrndwell that's not really fault tolerant
15:56clrndsee akka implements actor system architectures for error tolerance
15:57reiddraperdnolen_: yes, however, gfredericks, aphyr and i have been doing some work that may be interesting/tough to do in js. There's a branch now that uses a new RNG, and adds parallel tests, using executors, etc.
15:58reiddraperjust anticipating some interesting merge conflicts
15:58gfredericksoh I'm sure JS comes with a few block ciphers
15:58dnolen_reiddraper: that's I meant about core.async style - there's separate directory for all the cljs stuff, no code sharing
15:58reiddraperyeah, maybe it won't be too bad then
15:58gfrederickswell actually: http://docs.closure-library.googlecode.com/git/class_goog_crypt_Aes.html
15:59dnolen_reiddraper: it means copy and pasting to but honestly I don't think it's a big deal esp. when the Clojure side may be evolving faster
15:59dnolen_reiddraper: ends up being nice, was true for core.async
16:00reiddraperdnolen_: here's what the diff looks like at the moment: https://github.com/aphyr/test.check/compare/clojure:master...feature/parallel-testing
16:00reiddraperdnolen_: yeah, I think that would be great. Will we be able to run the cljs tests from the command-line?
16:01dnolen_reiddraper: yep that's the idea
16:01reiddraperexcellent
16:01dnolen_reiddraper: cljs.test is basically good to go in ClojureScript master
16:01reiddrapergfredericks: any objections?
16:01dnolen_reiddraper: so I'm making sure all the clojure.test integration stuff just works similarly w/ cljs.test
16:02gfredericksreiddraper: nope
16:03gfredericksdnolen_: what system deps do you need to run the tests? same as cljs proper?
16:03l1xhi guys, i was wondering what am i doing wrong here https://gist.github.com/l1x/3e991063483f1204536f
16:03l1xit seems i cant catch that exception
16:04amalloy~map
16:04clojurebotmap is *LAZY*
16:04amalloy~botsnack
16:05clojurebotthanks; that was delicious. (nom nom nom)
16:05turbofailcrypto in javascript?
16:05amalloyl1x: that one's for you. map is lazy. it immediately returns a lazy seq, and your try/catch completes successfully. then, the repl tries to print your map, and gets an exception while realizing the seq
16:05gfredericksturbofail: the new test.check RNG uses a block cipher
16:05l1xamalloy: ahh this is what i missed
16:05l1xthanks!
16:05gfredericksI'd like to figure out something simpler but that would require learning how to test the quality of a RNG
16:06amalloyl1x: this would be more apparent if you tried printing the stacktrace, by the way
16:06dnolen_gfredericks: cljsbuilds w/ :notify-command, probably simplest for everyone if we just run the tests against Node.js
16:06amalloythe summary message that gets printed by the repl is often not terribly useful
16:06turbofailgfredericks: ah, so not actual crypto-crypto
16:06EvanRtheres dieharder for testing rngs
16:06amalloybut if you look at the trace, and see it's inside of printing instead of inside something else...
16:06gfredericksturbofail: no, not crypto-crypto-crypto
16:07reiddraperturbofail: actual crypto, but not for the purposes of crypto
16:07turbofailheh
16:07seonhello
16:07seonno one from Lyon
16:07reiddraperturbofail: http://publications.lib.chalmers.se/records/fulltext/183348/local_183348.pdf
16:09l1xamalloy: so is there any way to catch an exception like this?
16:10turbofaildoall
16:10turbofailaround the map
16:11l1xturbofail: thanks!!
16:13EvanR~filter
16:13clojurebotfilter doesn't stop
16:14joobusis aleph considered stable for production work? The bottom of the github page says "Aleph is meant to be a sandbox for exploring how Clojure can be used effectively in this context.".
16:17ben8hi. quick question about compojure. I'm missing a run-jetty function?
16:18joobusben8: I'm guessing you are reading some example with a run-jetty function?
16:18joobusben8: ring can be used with multiple servers. run-jetty runs the jetty server, and there is some include that you'll need to use it.
16:18ben8I've read several of various age I guess
16:19ben8ah right, it's a ring function. compojure has an app function
16:20PetruchioI'm having trouble getting started with Leiningen. Per the instructions, I downloaded lein (to Ubuntu), ran it, and I just get the main help menu.
16:20joobusPetruchio: go to a scratch directory and do 'lein new app whateveritscalled'
16:21joobusPetruchio: it should make a new lein folder/app with all the relevant parts if lein installed correctly
16:22PetruchioAh! I didn't get it... apparently it's already installed correctly, since that worked. Thanks.
16:29EvanR,(= false nil)
16:29clojurebotfalse
16:29EvanRjust checking
16:29gfredericks,(#'= false nil)
16:29clojurebotfalse
16:29gfredericksoh right
16:30Bronsagfredericks: did you brainfart for a second and think = was a macro or what?
16:31gfredericksBronsa: yeah I confused inlining with macrotude
16:32gfredericksI misremembered the nature of the classic wat
16:32Bronsa,(#'or true true)
16:32clojurebotnil
16:32gfredericksoh also there's that other one
16:32gfredericks,('= false nil)
16:32clojurebotnil
16:32gfredericksstill a falsy answer, but now quite the same ;-)
16:32Bronsa,('= true true) is more effective
16:32clojurebottrue
16:32gfredericksnot*
16:33Bronsa:< no wait.
16:33Bronsa,('= false true) there
16:33clojurebottrue
16:33stuartsierraugh
16:33stuartsierraNever do that again.
16:34gfredericks,(:= false true)
16:34clojurebottrue
16:34gfredericksit's great that = := '= and #' are all callable
16:35gfredericks#'= I mean
16:35gfredericks,#{= := '= #'=}
16:35clojurebot#{= #'clojure.core/= #<core$_EQ_ clojure.core$_EQ_@88f71a> :=}
16:36nullptr,((juxt = := '= #'=) 1 2)
16:36clojurebot[false 2 2 false]
16:37gfredericks,(let [eqs [= := '= #'=]] ((fn [[f & args]] (apply f args)) (shuffle eqs)))
16:37clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: Symbol>
16:37gfredericks,(let [eqs [= := '= #'=]] ((fn [[f & args]] (apply f args)) (shuffle eqs)))
16:37clojurebotfalse
16:38gfredericksI guess that could be written a little clearer
16:38gfredericks,(let [eqs [= := '= #'=], [f & args] (shuffle eqs)] (apply f args))
16:38clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: Symbol>
16:45l1xjoobus: i tried the netty version but it was yielding to less performance as stock compojure with jetty
16:45ztellmanjoobus: yes, it's used extensively in production, that sentence hasn't changed in three years
16:46joobusztellman: thanks.
16:46l1xhaha, i did not realize the author is here! :)
16:46l1xztellman: did you measure the performance of aleph?
16:46joobusztellman: I'm guessing you favor event-based architecture for web servers?
16:46ztellmanl1x: https://github.com/ptaoussanis/clojure-web-server-benchmarks/
16:47ztellmanjoobus: I favor having the ability to do async and streaming request/responses
16:47ztellmanbut the synchronous ring model is good enough for most cases
16:48joobusztellman: yeah, i'm at the point of picking one or the other for a project right now, and at this point it is a toss-up, but I don't want to limit myself down the line. Currently, I use python's twisted framework for most of my web stuff, so I am familiar with the event-based model right now.
16:49ztellmanjoobus: the concurrency model for Aleph is pretty similar to Twisted's
16:49joobusi know, i've been reading your/the docs :)
16:50ztellmanwell, happy to answer any questions
16:51l1xztellman: thanks
16:52joobusi don't have any brainbusters for you today. I did just notice that benchmarks graph has looked different every time I've looked at it.
16:52EvanRalways run it until it breaks a speed record
16:52EvanRthen publish i
16:52ztellmanno, we did extensive testing across all of them, with feedback from all the authors
16:53ztellmanmostly it's just that people are actively working on improving performance
16:53l1xztellman: are you familiar with this project? https://github.com/basho/basho_bench
16:53ztellmana lot of the approaches used by one server tend to get borrowed, too
16:53l1xprefer latency + throughput together on a chart when talking about performance
16:53ztellmanl1x: latency is in the raw data
16:53l1xcool
16:53l1xthanks
17:00Jaoodztellman: was the reason of the improvement in performance of Aleph from May to Nov? or is it that just performs much better with big hardware?
17:01ztellmanjaood: May was 0.3.x, November is 0.4.x
17:01ztellmanbasically a ground-up rewrite
17:01ztellmana lot of the improvement is from using the latest Netty
17:03mgaareI've been working on updating a little TCP server app that was originally on aleph 0.3 to the stack around aleph 0.4. Liking it so far
17:06l1xztellman: nice!
17:06mgaareztellman: it might be nice to have a link to the aleph google group somewhere in the readme, since there's a lot of useful stuff on the group that helps fill in the gaps until the documentation catches up
17:06l1xi am rerunning my benchmarks just noticed the new version
17:06Jaoodztellman: cool, thx
17:07ztellmanl1x: here's latency metrics from an earlier run of the benchmark https://github.com/ptaoussanis/clojure-web-server-benchmarks/blob/5fd6ec249851dd9ab08e32f590929a9a2f3cced8/results/20141025-20-40.png
17:07ztellmanit was too tedious to do it for every run
17:08l1xztellman: thanks, this is exactly why i settled on basho_bench
17:08l1xit just 2 commands and you are done
17:09ztellmanl1x: might be worth investigating for this, or we just write a little turd script that turns the benchmark output into a csv
17:19l1xztellman: cool
17:19l1xztellman: where did the wrap-ring-handler function go from aleph?
17:19ztellmanl1x: it's gone, aleph handlers = ring handlers
17:19ztellmanexcept that aleph handlers can returned a deferred response
17:20l1xnice one!
17:20noonianlong time passing
17:21l1xztellman: WARNING: get already refers to: #'clojure.core/get in namespace: hystrix-event-stream-clj.core, being replaced by: #'aleph.http/get
17:21Jaoodztellman: does Aleph implements ring-core or it implements some ring netty adapter?
17:22ztellmanJaood: it follows the ring spec for requests and responses
17:23ztellmanI'm not sure if the lein plugins for Ring would work with it, last I checked they assumed servlets but that may have changed
17:27nicferriercan anybody think of a good way to handle async http requests with go blocks?
17:27amalloyl1x: that's a warning to remind you to stop using :use
17:27ztellmannicferrier: aleph can do that
17:27amalloy(or :refer :all)
17:27ztellmannicferrier: you just coerce the channel returned by a go block to a Manifold deferred
17:27nicferrierztellman: looking, thx.
17:28puredanger…. said the technologically advanced alien
17:28puredangerseriously, that was like the nerdiest thing I heard all day ztellman
17:28ztellmanpuredanger: I try
17:28l1xamalloy: you are right, i have stopped using it, but this time i got the code from my co-worker and guess what :)
17:28l1xthanks for pointing out though
17:28amalloyl1x: put the fear of god into your co-worker
17:29l1x:D
17:29l1xztellman: i see lots of 500 errors in the logs are you interested what is happening or you are aware of these ?
17:30ztellmanl1x: this is in the webserver-benchmark?
17:30l1xyes
17:30l1xwell it seems the new code is a little bit unhappy with hystrix
17:30ztellmanl1x: I'm not aware of any issues, happy to look at any stack traces
17:31l1xthis is weird
17:31l1xthe performace is up ~20%
17:31ztellmanwhy is hystrix being used in the benchmarks, exactly?
17:32l1xhttp://s4.postimg.org/arrpn2x4s/summary.jpg
17:32l1xout stack works with hystrix
17:33ztellmanoh, this isn't the standard benchmark, it's your service, gotcha
17:33l1xyes, sorry, i misunderstood your question earlier
17:33l1xi wanted to compare our stack + aleph 0.3 vs. our stack + aleph 0.4
17:33ztellmanI see
17:34l1xyeah it looks pretty sweet
17:34ztellmanyeah, should be an across-the-board improvement
17:34ztellmanbut at that throughput maybe not too drastic
17:34l1xok, i am going to figure out why hystrix is unhappy
17:34l1xthis is on my 13" mbp
17:34l1xdo you have any performance recommendation how to start up the service?
17:35l1x:max-threads 200 :min-threads 20 or something like that
17:35ztellmanoh
17:35ztellmanthe defaults should be okay
17:35ztellmanyou can specify the executor
17:35ztellmancheck out aleph.flow
17:35l1xcool thanks!
17:42arohnerl1x: FYI, the words "async", "performance" and "hystrix" are unlikely to go together well, depending on your load
17:43arohner(assuming you're using the default hystrix thread pool)
17:44m1dnight_is there a function that allows me to modify the statements in tail position of a form?
17:44m1dnight_im wanting to replace either all recurs (which are in tail position by definition) or otherwise the other expressions in tail position
17:45l1xarohner: i see, do you have any more details? we are in the initial phase of this project
17:45l1xso if you have more context please share it
17:45arohnerm1dnight_: you could use a (complex, hard to write) macro to do that, but first I'd ask why
17:45ztellmanm1dnight_: https://github.com/ztellman/vertigo/blob/master/src/vertigo/core.clj#L409-L441
17:45arohnerl1x: hystrix runs each command in a separate thread, so then if the command times out, it just terminates the thread
17:45m1dnight_because i'm writing an actor library for my thesis and I have to have hooks when a receive block (which is my macro) finished
17:46arohnerl1x: that works fine, but lots of threads = lots of context switching, which is a problem if you want "real" performance
17:47arohnerl1x: if you care more about reliability, that's great. I'm just pointing it out because you were mentioning benchmarks
17:47l1xhmm i see what you mean
17:49TimMcarohner: Have you played around with their newer support for rx?
17:49arohnerTimMc: no
17:49TimMcPreviously there was no way for an Observable-emitting Hystrix command to register failure (leading to a circuit breaker trip) but I hear they've addressed that now.
17:50l1xarohner: what is the alternative way of handling a request lets say skip hystrix, just use a go block or something
17:50l1xis there a good pattern to lets say talk to a DB with a timeout and retry?
17:50arohnerTimMc: I don't know enough about how Rx works. What is the recovery situation like? they still terminate your thread?
17:52arohnerl1x: probably, but that depends on your DB drivers
17:52arohnerl1x: if you need serious performance, the best way is to process all the async requests in the same thread, using NIO select
17:53arohnerbut that code is tricky to write, so I wouldn't recommend it unless you know you need it
17:57l1xhmm alright, i am going to investigate this more, thanks for the info
18:06wildnuxhi, if i have a seq of objects (say eg, File objects i got using file-seq ), how do i turn the list into a map of name attribute of object and the object itself?
18:07wildnuxi tried (map #(assoc m (.getName %) %) s)
18:07wildnuxbut it created many maps
18:08justin_smithwhat is m ?
18:08amalloywildnux: you are looking for reduce
18:08Bahmanwildnux: fold the list.
18:08justin_smithyeah, actually that does sound like a reduce
18:08wildnuxjustin_smith: the map is called inside let binding, m is empty map
18:10wildnuxbasically i was doing something like this: (let [s (filteredseqoffilesindir d) m {}] (map #(assoc m (.getName %) %) s))
18:11justin_smith,(reduce #(assoc % %2 (name %2)) {} [:a :b :c :d]) ; something like this
18:11clojurebot{:d "d", :c "c", :b "b", :a "a"}
18:11justin_smithbut with (.getName %2) %2 instead
18:11wildnuxjustin_smith: cool, let me try
18:12TimMcarohner: Recovery situation?
18:12justin_smithwildnux or (group-by #(.getName %) files) - especially good if more than one file may have the same base name
18:12wildnuxjustin_smith: i tried replacing map with reduce but did not work.. probably i needed to pass empty map as well for it to fold the list
18:12justin_smithand it takes an extra arg, the accumulator
18:12amalloyit is a common beginner error to try and modify an immutable object in a for loop or a map or something
18:12arohnerTimMc: in your Rx + hystrix situation. 'normal' hystrix terminates the thread. I was asking how Rx Hystrix recovers there
18:13amalloyremember that in clojure, objects never change. if m starts as {}, it will be {} forever. the way to do this sort of "incremental build-up" of an object is with a recursive function, or with reduce, which is the same thing under the hood
18:14TimMcarohner: Hmm, not sure. I didn't dig that much into hystrix in the first place after finding out it didn't work well with rx (at the time.)
18:15wildnuxjustin_smith: actually i am calling function on that file object so probably group-by does not work
18:15justin_smithwhy would calling a function on the file make the group-by not work?
18:15wildnuxcalling function on that object as the value of the map
18:16justin_smithoh, I see
18:16wildnuxwhat i am trying is get list of classes from all of jar files in a directory
18:17justin_smithahh, so the key is .getName and the val is some function call
18:17wildnuxso, i have file-seq on that directory, filter jar files, create JarFile out of them and get enumeration of the contents, then again filter based on .class
18:17wildnuxand now, i have list of classes for a single jar, i want to write a function which can give me map of jarfile name (absolute path) and the classes in them
18:17wildnux:)
18:19wildnuxjustin_smith: yes
18:19justin_smith,(into {} (map (juxt keyword #(str % (.toUpperCase %))) ["a" "b" "c"]))
18:19clojurebot{:a "aA", :b "bB", :c "cC"}
18:19justin_smithjuxt / map / into will do that trick
18:20justin_smithactually, for is often more readable for that (but it would do the same thing)
18:20wildnuxjustin_smith: cool, let me try juxt as well
18:20wildnuxfor some reason, i have not been able to get my head around using for for looping and collecting value easily :(
18:21justin_smithfor is not a loop
18:21justin_smithit's a list comprehension
18:22wildnuxjustin_smith: what is the best way to accumulate values using for?
18:22dbaschjustin_smith: feature request: parse chat lines that have “for” and “loop” in them, and make the bot reply
18:22justin_smith,(into {} (for [c ["a" "b" "c"]] [(keyword c) (str c (.toUpperCase c))]))
18:22clojurebot{:a "aA", :b "bB", :c "cC"}
18:22justin_smithdbasch: that is a good one
18:22justin_smiththough it could be annoying if you do it wrong
18:23amalloy~for
18:23clojurebotfor is not a loop
18:23dbaschfeature request: make amalloy a bot
18:24EvanR~though
18:24clojurebotCool story bro.
18:24wildnuxdang!
18:24amalloydbasch: i did that a while ago. amalloybot was a rousing success
18:24hyPiRion~amalloy
18:24clojurebotamalloy is the spotlight illuminating my dumb mistakes
18:24TimMc~amalloybot
18:24clojurebotCool story bro.
18:25amalloyapparently this was on march 10th: http://logs.lazybot.org/irc.freenode.net/%23clojure/2014-03-10.txt
18:26justin_smithlol, I remember it like it was yesterday
18:29m1dnight_Is there a particular reason that macroexpand does not do a "deep" expand?
18:29m1dnight_it's simply solved by (postwalk macroexpand <form>) though, but i'm not sure
18:30ztellmanmidnight_ macroexpand is for the top-level form, by definition
18:30amalloym1dnight_: because it's not the compiler, and trying to be the compiler is hard
18:30ztellmanm1dnight_ and don't use postwalk with macroexpand, that will cause issues
18:30ztellmanhttps://github.com/ztellman/riddley
18:30amalloypostwalk macroexpand, for example, is one of those things that works great for simple cases but breaks if you try to rely on it
18:32amalloyztellman: how does that compare to the stuff in tools.macro?
18:32m1dnight_hrm, any hints, then?
18:32m1dnight_I can't imagine a case where it could break too, though
18:32ztellmanamalloy: last I checked, tools.macro didn't do inline function transformation, and didn't differentiate between expressions and non-expression forms
18:33amalloym1dnight_: easy. (quote (let 1))
18:33ztellmanm1dnight_ did you see this wen I posted it earlier? https://github.com/ztellman/vertigo/blob/master/src/vertigo/core.clj#L409-L441
18:33m1dnight_ztellman: Yes, that's what Im using
18:33ztellmanI see
18:33m1dnight_but i'm thinking that it requires an exanded form, no?
18:33ztellmanso yeah, use riddley.walk/macroexpand-all
18:33ztellmanand apply that
18:33ztellmanthat's what the code surrounding the quoted region does
18:33amalloythat's a perfectly fine expression, which produces the list (let 1). but if you postwalk macroexpand, it will break because it doesn't understand quoting
18:34m1dnight_oh, I did not notice the macroexpand-all
18:34m1dnight_:) sorry
18:34ztellmanno worries
18:35amalloyztellman: expressions and non-expression forms? i think i understand the difference between those two things but not what tools.macro does wrong with them
18:35ztellmanamalloy: oh, I just meant that tools.macro didn't give you a way to walk expressions and transform them
18:36ztellmanw.r.t. macorexpansion I think the issue is only inline functions
18:36amalloyinline functions?
18:36amalloyoh
18:36amalloyinlined functions :P
18:36ztellman:inline functions
18:36ztellmannot handling that will break pervasive transforms pretty badly, sometimes
18:36amalloyyeah, fair enough, that seems like it could matter
18:37amalloyactually i just remembered another issue with tools.macro that is pretty interesting. i wonder if riddley handles it right
18:37ztellmanfile an issue if not
18:38ztellmanamalloy: oh, and tools.macro passes in a nil &env, too
18:38ztellmanagain, last time I checked
18:39amalloyztellman: yeah, pretty sure it does
18:39amalloyztellman: riddley doesn't have macrolet, does it?
18:39ztellmanamalloy: it trivailly could
18:40ztellmantrivially*
18:40amalloymacrolet is like the only thing in tools.macro i use
18:40ztellmanI just haven't needed it
18:40amalloyztellman: (macrolet [(m [x] `(case ~x ~@(mapcat (partial repeat 2) (range 10))))] (m 9)) is a way to reproduce the problem in tools.macro
18:40amalloyit doesn't break for numbers smaller than 10 and 9, which is the fun part
18:41Bronsaamalloy: ouch. sorted map -> hash map
18:41amalloyBronsa: yep
18:41Bronsaamalloy: I don't think that's tools.macro's fault
18:41amalloyBronsa: yeah it is
18:41Bronsauh ok.
18:41amalloytools.macro implements something like postwalk, and does it via like (cond (map? x) (into {} (map ... x)))
18:42Bronsaah, gotcha
18:42Bronsa,(defmacro x [] (sorted-map 1 1))
18:42clojurebot#'sandbox/x
18:42Bronsa,(class (x))
18:42clojurebotclojure.lang.PersistentArrayMap
18:42Bronsai thought it was a case of that ^
18:42amalloyi don't think so
18:43amalloybecause the sorted map emitted by the macroexpansion of case is consumed by case* at macro time, not emitted to be eval'd
18:43Bronsayeah, makes sense
18:45ztellmanamalloy: I do handle that case correctly
18:45ztellmanI ended up getting bit by it in automat
18:45amalloyztellman: anyway, feature request: add macrolet, c'mon how can you be a macro library without macrolet
18:46ztellmanamalloy: https://github.com/ztellman/riddley/blob/master/src/riddley/walk.clj#L161
18:46ztellmanyeah, ok
18:50amalloyztellman: is a special-cased handler for case really the right way to do this? what if someone else writes a macro like case that needs to emit a sorted map for consumption by something else?
18:50ztellmanamalloy: this is the underlying case* map
18:51ztellmanif they want to handle sorted-map specially, they can define a special handler for whatever their scope is
18:52ztellmansince we don't know what the comparator is, that's the only way we can do it
18:52amalloyi see, you first go through their predicate/handler function
18:53ztellmanamalloy: right, and if the predicate fires, I don't descend any further
18:53ztellmanyou can have scoped transforms
18:54chouserWhat if I want to write some transit data, but for any object that doesn't have a write handler, I'd like to just write out a special symbol, like 'unwritable. That should be possible, right?
18:55amalloyztellman: what about https://github.com/ztellman/riddley/blob/master/src/riddley/walk.clj#L242-L243 ? it won't trigger this case/case* issue because you handle that separately. but if i want to transform some of my code, and it's inside of a map that's sorted and needs to stay sorted, i don't want to have to handle that myself
18:56ztellmanamalloy: you can halt the walk when you find a sorted map
18:56ztellmanunless (empty sorted-map) retains the comparator?
18:56ztellmanin which case I should change that
18:56Bronsaztellman: it does
18:56ztellmanoh!
18:57ztellmanok, new release forthcoming soon
18:57amalloylovely
18:58amalloyztellman: you can enjoy the shiny new features in 1.4 by using mapv here, too: https://github.com/ztellman/riddley/blob/master/src/riddley/walk.clj#L237
18:58ztellmanamalloy: eh, I'll use (into (empty x) ...) just to make sure I retain whatever weirdo vector type it is, too
19:01amalloy,(var inc dec)
19:01clojurebot#'clojure.core/inc
19:01amalloyvery funny, clojure
19:04amalloyztellman: why is walkable? defined the way it is? is it intended to roughly correspond to "forms which could possibly be macro invocations" or what? it seems weird to say "sequential but not a vector or a map entry"
19:04amalloyie, it looks kinda like a weird way to write the function seq?
19:04ztellmanamalloy: I'm pretty sure walkable? means expression-ish
19:05ztellmanyeah, it's only used by walk-exprs
19:05ztellmanpoor name
19:06amalloyi don't get expression-ish at all. vectors are expression-ish, in that they are actual expressions
19:08amalloyif you just used seq? instead of defining walkable? i think you'd be fine; all the uses of walkable? that exist seem to be using it to check for a special form
19:08ztellmanamalloy: it's been a while since I looked at this code, I recall some reason seq? wasn't good enough
19:08ztellmanjust not what it was
19:08ztellmanand I may have been wrong
19:10amalloyi worry because Sequential is an open interface, of course, so someone can write a sequential thing which is neither a vector nor a seq, so that you'll think it's walkable but the compiler wouldn't actually treat it as a macro invocation
19:10ztellmanfair point
19:26crispinhi there crew!
19:26crispinI cant get *command-line-args* to work
19:26crispinI want to get the name of the executable, argv[0] in other languages
19:26crispinif I (defn -main [& args]
19:27crispinargs is everything but the first argument
19:27crispinif I use *command-line-args*, the same thing with lein run, and nil with a binary
19:27crispinhow do you get the name of the executable
19:28crispinIm using "lein bin" to make a standalone executable
19:29crispinhttps://github.com/Raynes/lein-bin
19:30crispin$ lein run arg1 arg2
19:30crispinProgram: arg1
19:31crispin$ target/binary arg1 arg2
19:31crispinProgram: nil
19:34crispinhttp://rosettacode.org/wiki/Program_name#Clojure
19:35crispin^ this doesnt work
19:35justin_smithcrispin: with a *nix type system, you should find it via (System/getenv "_")
19:35justin_smith,(System/getenv "_")
19:35clojurebot#<AccessControlException java.security.AccessControlException: access denied (java.lang.RuntimePermission getenv._)>
19:35crispinyeah its unix... let me try
19:37crispin$ lein run arg1 arg2
19:37crispinProgram: /usr/bin/java
19:37crispin$ target/binary arg1 arg2
19:37crispinProgram: nil
19:37crispinworks with leiningen. Doesn't work with standalone
19:38crispinbut good idea to use java interop
19:38justin_smithOK. Try printing the output of (System/getenv) from the standalone, there may be some env key
19:38justin_smithif it's anywhere at all that is
19:40crispinjustin_smith: nope
19:40crispinhas SHELL, and PWD
19:40crispinbut no executable name
19:40crispinsheeeeet :P Am I gonna have to look up the PID in /proc?
19:40crispinblech
19:41justin_smiththat's weird, because I know for a fact that the shell puts that info into env for the java process
19:41justin_smithso I don't know why java is hiding it from you...
19:41crispinit could be a side effect of lein bin
19:41crispinnow the header of the self executable is...
19:41crispin:;exec java -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -client -Droll.version=0.1.0-SNAPSHOT -jar $0 "$@"
19:41crispin@echo off
19:41crispinjava -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -client -Droll.version=0.1.0-SNAPSHOT -jar %1 "%~f0" %*
19:41crispingoto :eof
19:42crispinbut I dont see how thats removing the /usr/bin/java
19:44crispinI think it must be an issue with lein-bin
19:45crispinwill open an issue on the project and see what comes out of it
19:47justin_smithif nothing else, you should be able to modify that header to pass in the executable name
19:51crispinsubmitted ticket: https://github.com/Raynes/lein-bin/issues/19
19:51crispinyes, thanks for your help justin_smith
19:52justin_smithcool info of the day "You can get anyone's SSH pubkey from GitHub via https://github.com/USERNAME.keys . Handy for giving people access to servers."
19:53dbasch(inc justin_smith) great to know
19:54dbasch(inc _)
19:54lazybot⇒ 1
19:54dbasch(inc justin_smith)
19:54lazybot⇒ 160
20:29crack_userhey guys
20:30crack_usersome one have a good article about clojure immutability internals?
20:31justin_smithhyPiRion has a good series of blog posts on persistentvector
20:31TimMc++ to that, good series
20:31justin_smithhttp://hypirion.com/musings/understanding-persistent-vector-pt-1
20:32justin_smith(inc hyPiRion)
20:32lazybot⇒ 57
20:33TimMc(inc hyPiRion)
20:33lazybot⇒ 58
20:36trissso just to double check in clojure the theory for the most part is to keep all the do and doseq etc in the applicaion level of code?
20:38trissyou would try not to hide these in he api and make sure its happens from a single place?
20:38trissor am I not getting FP?
20:40ztellmantriss: it depends if the library needs to do side effects
20:40ztellmanif they're interacting with Java libraries, they often do
20:40trissah ok... coz thats exactly what i've been doing
20:40trissjust had a little panic there...
20:41trissso this "virtual dom" idea... is that becoming really common in libs too?
20:42trissbut mapped across different objects?
20:42trissthe code I'm writing is fast becoming a library
20:43trissand I can't really work if there any best practices you could folllow for wrappng oo code
20:44triss^wrapping oo java/js code in clojure style clothing
20:50NoCreativityHello people
20:51NoCreativityIm trying to use clojure.java.jdbc and reuse a transaction, but something is going wrong and my transaction loses connection with database before I can insert all data. Does anybody has any tips ?
20:51gratimaxcan you confirm that you are actually connected to the database for some period of time
20:52justin_smithNoCreativity: also, that symptom can be caused by trying to use a lazy operation like map or for inside a db operation
20:52NoCreativitygratimax: yes! I have an answer from it with the generated primary key
20:52justin_smithwhere by the time the laziness is forced, you are no longer in the transaction context
20:52NoCreativityjustin_smith: Aw jeez
20:52justin_smithso be sure you aren't doing anything lazy in the db
20:53NoCreativityjustin_smith: Im trying to use for
20:53justin_smithOK, wrap it in a doall
20:53justin_smithor use doseq instead of for
20:53justin_smithlaziness and resource lifetimes don't play nicely together
20:53gratimaxwell you got to it before I did :P
20:53NoCreativityThx a lot, guys!
20:53NoCreativityI will try here
20:57crack_usercan I convert clojure symbol to string?
20:57justin_smith,(name 'sym)
20:57clojurebot"sym"
20:57gfredericks,(name 'com.gfredericks.forks.org.clojure.test.check.generators.properties/cats)
20:57clojurebot"cats"
20:59crack_userthe ' does the symbol not evaluate?
20:59justin_smith,''cats
20:59clojurebot(quote cats)
20:59justin_smithit's a read syntax for quote
20:59justin_smithwhich gives you a symbol, instead of resolving it
21:00justin_smith,'''cats
21:00clojurebot(quote (quote cats))
21:00justin_smiths/symbol/value
21:01crack_userit makes sense
21:07gfredericks,(cycle '(boots cats))
21:07clojurebot(boots cats boots cats boots ...)
21:10gfrederickshelp I'm about to write a custom data structure
21:14amalloygfredericks: put down the keyboard and back away slowly
21:15NoCreativityIm so stupid
21:15NoCreativity:(
21:15NoCreativity(sql/db-set-rollback-only! t-con)
21:16NoCreativityIt would never commit my stuff
21:17NoCreativityWell... btw... I think I need more 4clojure training and reading... :( Again, thank you guys! It made my night. =] Now I'm happy again.
21:18gfredericksmaybe I'll just start with a sorted set
21:19justin_smithNoCreativity: actually, since none of 4clojure deals with side effects, the gotchas of lazy-seqs are not really covered I don't think
21:19NoCreativityjustin_smith: hmmm... Okay. This made me feel better! =D
21:20NoCreativityjustin_smith: Well... I think these relational databases are going to help me somehow on learning datastructure functions to build data the way I want.
21:20NoCreativityI hope Im right. ^ ^
21:38TimMcgfredericks: Stop it you're making me want to pick up Overtone again!
21:39TimMcboots and cats and boots and cats and boots and boots and boots and cats
21:39gfredericksTimMc: huh? like to play boots and cats?
21:39TimMcgenerative music in general
21:40gfredericks,(repeatedly #(rand-nth '(boots boots cats)))
21:40clojurebot(cats boots boots cats boots ...)
21:42TimMcThat generates long stretches of the same word.
21:43TimMc,(sort-by key (frequencies (map count (partition-by identity (repeatedly 100 #(rand-nth '(boots boots cats)))))))
21:43clojurebot([1 18] [2 9] [3 4] [4 4] [5 1] ...)
21:44TimMcTrue randomness is less satisfying.
21:46justin_smithTimMc: yeah, algorithmic composition code is often full of stuff like (repeat (+ x (rand-int y)) z)
21:46justin_smiththough Xenakis was fond of requiring that events in his compositions fit a poisson distribution
21:47justin_smithhe was an outlier though
21:47justin_smith(he also made the first GUI for making music with)
21:49gfredericksokay I have no idea how sorted-set-by works
21:50gfredericks,(def self (sorted-set-by #(> %1 %2)))
21:50godd2gfredericks you mean what it does or how it does what it does?
21:50clojurebot#'sandbox/self
21:50gfredericks,(conj self 5 1 4 2 3)
21:50amalloygfredericks: it takes a comparator, not a predicate
21:50clojurebot#{5 4 3 2 1}
21:50amalloyright?
21:50gfredericks,(def self (sorted-set-by #(compare %1 %2)))
21:50clojurebot#'sandbox/self
21:50gfredericks,(conj self 5 1 4 2 3)
21:50clojurebot#{1 2 3 4 5}
21:50gfredericks,(def self (sorted-set-by #(compare %2 %1)))
21:50clojurebot#'sandbox/self
21:50gfredericks,(conj self 5 1 4 2 3)
21:50clojurebot#{5 4 3 2 1}
21:50gfredericksI don't get this behavior at my repl
21:51gfredericksoh I bet it's that damn puget
21:51amalloygfredericks: your pretty-printer is evil
21:51amalloywhat is the draw of puget? so far all i've heard about it is weird bugs
21:52justin_smithPRETTY COLORS
21:52gfrederickscompared to no pretty printer or to some other one I don't know about?
21:52amalloycompared to no pretty printer
21:52gfredericksyou must never deal with data
21:53amalloyi manually pprint the things i want pretty
21:53amalloyit's not onerous
21:54gfrederickswe each have our own stockholm syndrome
21:54amalloyi suppose so. but everyone else's is dumb
21:55justin_smith~everyone else |is| dumb
21:55clojurebot'Sea, mhuise.
21:55gfredericksso if I want to handle generic unicode "characters" I'm gonna use length-1-or-2 Strings is that accurate? or maybe int I guess?
21:56justin_smithgfredericks: the jvm native representation is 32 bit, right?
21:57justin_smithso, thanks to sign issues, I would think you would need a long
21:57TimMcgfredericks: Is this a regex generator thing?
21:57gfredericksTimMc: generator *from* a regex
21:58gfredericksjustin_smith: oh snapchat maybe so; I'll just stick with strings
22:02TimMc"oh snapchat"
22:03gfredericksthat's what the kids say these days right?
22:04TimMcI think so
22:14andyfgfredericks: Max code point fits in 20 or 21 bits so int is enough
22:14gfredericksandyf: why would justin_smith lie to me?
22:15andyfYeah, still working out some kinks in his OS
22:17andyfThere was a proposal for Unicode lib sent to clojure-Dev in early Oct 2014 . Not sure if it would have anything of use for you
22:18justin_smithandyf: wait, I thought it was a 32 bit representation?
22:18gfredericksoh the connection between code points and surrogats is nontrivial isn't it
22:18gfrederickssourroguhts
22:18gfrederickssourguts
22:18gfrederickssoregum
22:19andyfDepends on what you call trivial :-). Just a bit of shifting and anding/prong
22:19andyf*ORing
22:19justin_smith"Characters whose code points are greater than U+FFFF are called supplementary characters. The Java platform uses the UTF-16 representation in char arrays and in the String and StringBuffer classes. In this representation, supplementary characters are represented as a pair of char values, the first from the high-surrogates range, (\uD800-\uDBFF), the second from the low-surrogates range (\uDC00-\uDFFF)."
22:19justin_smithhttp://docs.oracle.com/javase/7/docs/api/java/lang/Character.html
22:20justin_smithso it uses UTF-16, but some characters require 2 Chars
22:20andyfWikipedia pages are decent for Unicode info, too
22:21gfredericksjustin_smith: right but the code point representation is still small
22:21gfrederickslooks like max is ##16r10FFFF
22:21andyfCheck out Wikipedia for code point
22:21gfredericks,16r10FFFF
22:21clojurebot1114111
22:22gfredericks~1114111 is totes intsable
22:22clojurebotOk.
22:22justin_smithUnicode comprises 1,114,112 code points in the range 0hex to 10FFFFhex
22:22justin_smithyeah
22:22gfrederickshalf of which are snowmen characters
22:22justin_smith,Integer/MAX_VALUE
22:22clojurebot2147483647
22:24andyfYeah, we're good until meeting the pangalactic empire, but then different tech will be available
22:24TEttingerandyf, if star wars has taught me anything it's that they'll speak either english or huttese.
22:25TEttingeror unpronounceable rawrs
22:25justin_smithwith occasional reverse-polish grammar
22:25andyfThere is a how to speak wookie book with push buttons to make sounds. Hilarious
22:28andyfAmazon reviews for it are even entertaining
22:28TimMcThere are entertaining Amazon reviews for toilet paper, to be fair.
22:28TimMcand gallon jugs of milk
22:29TimMcgfredericks: I'm intrigued that the max unicode char is a palindrome in decimal.
22:29TimMcs/char/code point/
22:29gfredericksTimMc: numbers! how do they work!
22:30TimMc,[16r10FF 16r10FFF 16r10FFFF 16r10FFFFF]
22:30clojurebot[4351 69631 1114111 17825791]
22:30rritochjustin_smith: I completed the reg_assoc function and the re-ungreedy, though I did end up needing to use a parser, I couldn't find a regex that would do the job. https://github.com/rritoch/andylisp/blob/master/src/clj/andylisp/regex.clj
22:32gfredericksTimMc: did you know that numbers that look like 100010001000100010001 are never prime?
22:33gfredericksno wait
22:33gfredericksthat's probably false
22:33andyfThe matches a short regex primes conjecture?
22:34gfredericks,(apply str (repeat (rand-int 10) (rand-int 19389243)))
22:34clojurebot""
22:34gfredericks,(apply str (repeat (rand-int 10) (rand-int 19389243)))
22:34clojurebot"90907769090776909077690907769090776909077690907769090776"
22:34gfredericks^ that sort of number
22:34gfredericksis never prime
22:35gfredericksokay this numeric approach makes it a lot simpler
22:37andyfI don't have the heart to tell you that there are undefined holes in the range of code points, and those change from one JDK to the next as more are defined.
22:37andyfBut I don't think that should need to affect your random gen fn
22:41gfrederickstest.check will tell me if anything weird happens
22:43andyfI choose to interpret that as: nothing weird happened before test.check was created
22:50TimMcgfredericks: If there's anything I've learned from the tiny bit of number theory I've been exposed to, it's that you can't make provable statements about prime numbers. :-P
22:50TimMcexcept that there are lots f them
22:50justin_smith"60 is not prime"
22:51TimMcthere's an xkcd for this
22:51rritochTimMc: Prime numbers are evil, as are the supposed "rules" about them, most of the rules you'll run into are simply invalid, like the ln(x) approaching Pi(x) as you near infinity.
22:51TimMchttp://xkcd.com/1310/ "Goldbach Conjectures"
22:52TimMcrritoch: And yet they're the atoms of the number world.
22:52rritochTimMc: If I recall correctly, the zeta function is the only thing in prime number theory that has provided significant results.
22:53TimMcThe zeta function has led to significant advances in the field of fragmentary ceramics.
22:54rritochTimMc: I spent a few weeks trying to crack the Pi function. I had this idea that maybe I could find a power that would match the Pi function. I found that no matter what I chose it would curl away from the real value, so I made an adjustment that would curl to ln(x) at some number in the distant future of the pattern. It probably would have worked if the rule about ln(x) was true
22:54rritochTimMc: Since the ln(x) rule isn't true, it failed miserably
22:55TimMc"psychoceramics", that's the phrase
22:56gfredericks"The limit of the quotient of the two functions pi(x) and x/ln(x) as x approaches infinity is 1
22:56gfredericks"
22:56rritochgfredericks: Yes, that statement is false
22:57rritochgfredericks: x/ln(x) eventually crosses over pi(x)
22:57TimMcWhere?
22:58TimMcReminds me of being given the https://en.wikipedia.org/wiki/P%C3%B3lya_conjecture as an extra credit assignment (but not by name)
22:58rritochTimMc: I really don't know. I don't have enough computing resources to prove it, but that was the explaination I received from experts in number theory as to why curling to it didn't work.
22:59gfredericksfinite behavior doesn't prove anything about assymptotic behavior
22:59rritochTimMc: Either way, if you solve Pi(x) you solve the P(x) function, and to me Pi(x) seems easier to solve, but it's still not solved.
22:59gfrederickswhat's P(x)?
22:59rritochgfredericks: The nth prime
22:59gfredericksah right
23:01rritochTimMc: Anyhow, my point is, take much of what you learn in number theory with a grain of salt, they are just theories, and many of them have recently been disproven, but the information hasn't fully disseminated.
23:01TimMchmm
23:01gfrederickso_O
23:02rritochTimMc: In my case, I wasted a few weeks trying to solve a nearly unsolvable problem using inaccurate information. It wasn't until I consulted the experts that I found my error.
23:03rritochTimMc: They suggested I look into the zeta function, but my frustration was at the level that I really had to drop that project.
23:03Farehi. Is there an easy way to build a map that mirrors the deconstructor {:keys [a b c d]} ?
23:03Fareof course, I could write a defmacro to do the same...
23:03gfredericksFare: some util libs have a macro for it
23:03Fareok
23:03TimMcFare: Yeah, flatland/useful has something for that, right?
23:04TimMchttps://github.com/flatland/useful/blob/develop/src/flatland/useful/map.clj#L9
23:04TimMckeyed
23:12rritochTimMc: If your interested, this is the "project" https://www.physicsforums.com/threads/epic-fail-trying-to-solve-p-x.614121/
23:18rritochTimMc: The real problem with my attempt is there is no solution to the cosine integral, so I hit a dead-end.
23:19gfredericksrritoch: is that reply there what you mean about the earlier statement of the prime number theorem being wrong?
23:20rritochgfredericks: Yes.
23:21gfredericksit doesn't seem like a contradiction to me
23:21gfrederickscrossing over doesn't mean not approaching
23:23rritochgfredericks: According to the response it doesn't approach Pi(x), it wraps around it, similar to the behavior of my function for low values of Pi(x). What I needed for my function is a case where the limit of the function approaches Pi(x) as x approaches infinity.
23:24gfredericksrritoch: well the limit of the quotients approaching 1 doesn't mean that they actually approach each other, and the crossing over doesn't contradict either of those
23:24rritochgfredericks: It wasn't a complete loss though because if the cosine integral is solved, the accuracy of my formula could be further improved.
23:26rritochgfredericks: I don't know where you learned math but x/x = 1
23:26tuft_core.match goes really nicely with instaparse
23:26rritochgfredericks: I can't think of any other case where that's true
23:26amalloyrritoch: for most x, anyway
23:27gfredericksrritoch: e.g., x/(x+1) approaches 1 but x does not approach x+1
23:28gfredericksso pi(x)/(x/ln(x)) approaches one but x/ln(x) does not approach pi(x)
23:30rritochgfredericks: I accounted for this "issue" by curling to x/ln(x) at something like x^10, so if the prime number theory held the deviation would have been less than .01
23:31rritochgfredericks: Either way, the number was very large so it could have been floating point errors that caused some of my problems.
23:34rritochgfredericks: Since clojure promotes to Big types I'm somewhat curios how reducing the floating point errors would improve the results for large primes, but I've already invested enough time in that project. I'm just waiting for someone to solve the cosine integral.
23:47gfrederickshelp I'm using a sorted-set with a partial ordering
23:48andyfsounds like an invitation to disaster.
23:48andyfhelp you create a total order instead, or some other way?
23:49gfredericksI was hoping somebody would tell me to back slowly away from the keyboadr
23:49gfrederickskeyboard
23:50gfredericksandyf: I'm trying to store unions ranges of numbers (characters) efficiently
23:50andyfI?d recommend sending the RSVP with the answer ?no? back to disaster.
23:50hiredmansure, you could use a total order, but wouldn't you rather experience the rush of living like there is no tomorrow?
23:51gfredericksandyf: so if I do it right there shouldn't ever be two incomparable elements in a set together
23:52andyfelements of the set are contiguous ranges like [10,15], or elements of the set are sets of contiguous ranges?
23:52gfredericksthe former
23:52rritochgfredericks: Sets have a map impl, it "should" be possible to create a map with the behaviors you want, and then use that as the impl for the set. I dug into the source code of sets because I was looking into how to establish equality criteria in sets.
23:53andyfWhat operations do you want to do on such sets efficiently?
23:54gfredericksunion, difference, count, nth
23:54gfredericksand right not I'd settle for "eh sorta efficiently"
23:54gfredericksin the sense of ignoring the worst-case assymptotics
23:54gfrederickss/not/now/
23:55andyfMaybe just implement union and difference so that the contiguous ranges are always non-overlapping?
23:55gfredericksright that's what I'm doing
23:55andyfSo the elements can always be compared by the beginnings of their ranges, or the ends, and you have a total order?
23:56gfredericksyeah within the set it's a total order
23:56gfredericksjust not over the whole space of possible elements
23:57andyfyou want to compare two sets-of-contiguous-ranges and put them as elements into a sorted set?
23:58gfredericksI'm only using sorted sets for this
23:58gfredericksspecifically (sorted-set-by (fn [[x1 x2] [x3 x4]] (if (< x2 x3) -1 (if (< x4 x1) 1 0))))
23:58gfredericksso I don't know what you mean by "put into"
23:59andyfif the contiguous ranges are always kept non-overlapping, then I don't see the problem yet.
23:59andyfe.g. if you implement union so that #{[1 5] [8 10]} with #{[4 9]} so that the result is #{[1 10]}