#clojure logs

2014-03-10

00:44firefauxhow would you go about iterating over the values of two (or more) maps, for matching keys, and for keys that are missing in one of the maps, use a default value?
00:51tolstoyfirefaux: Maybe not what you want, but there's clojure.data/diff.
00:53firefauxactually
00:53firefauxI might be able to use that
00:53firefauxthough it might not be the best way to do it
00:54firefauxI could diff the keys
00:54firefauxthen iterate over the shared keys on both maps
00:54firefauxand then iterate over the keys that aren't shared, using the default value
00:54TravisDfirefaux: this isn't particularly elegant, but it works: https://www.refheap.com/55476
00:55firefauxhmm
00:55TravisDit makes a set containing all the keys that appear in any of the maps, and then there is a function which takes a map and fills in the missing values
00:55TravisDthen maps that function over the maps.
00:55TravisDlol
00:56firefauxthat's quite a bit of work
00:56TravisD(add-missing-keys :missing {:one 1} {:two 2}) ; => ({:one 1, :two :missing} {:one :missing, :two 2})
00:56TravisDyeah, there is likely a cleaner solution
00:56TravisDconceptually this is a clean solution, though
00:56firefauxwell, efficiency isn't a big concern of mine at this point
00:57firefauxas long as it takes nice inputs and gives nice outputs, I'm happy
00:58firefauxtaking [default & maps] is pretty much perfect
00:58firefauxand returning a seq of maps is also perfect
01:04ddellacostahmm, is there a way to auto run tests w/cljsbuild?
01:05ddellacostaI thought I'd done it in the past but can't figure it out now
01:06TravisDfirefaux: I like this implementation more than the last one: https://www.refheap.com/55501
01:07TravisDor even https://www.refheap.com/55504
01:08firefauxwhat makes them better? the fact that they use --> ?
01:08firefauxlol
01:09TravisDYeah, this seems easier to read to me
01:09firefauxis it doing anything differently, though?
01:09TravisDAlso, I like that they use merge, instead of another function
01:09firefaux(doc merge)
01:09clojurebot"([& maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping from the latter (left-to-right) will be the mapping in the result."
01:10firefauxah, that's smart
01:10TravisDI guess it's what merge is for :)
01:11firefauxok, this does make more sense
01:11TravisDIt makes a dictionary that maps all present keys to the default value, and then merges that with every map you provide
01:12firefauxyeah
01:12firefauxthat's a neat way of doing it
01:12TravisDand now that I look at it, there's really no need for add-keys to be a named function: https://www.refheap.com/55512
01:13firefauxI thought about that
01:13firefauxis there any harm in it, though?
01:13TravisDnot really
01:13firefauxI kinda like it like that
01:13firefauxmakes it clear what it's doing
01:13TravisDhehe, to each his own
01:14TravisDThis is also clearer than the one before, I think: https://www.refheap.com/55514 . Instead of using partial, it uses the fact that map can combine multiple sequences
01:15firefauxooh
01:15firefauxI like it
01:16arubinSo Lambda Jam will only be two days this year, and it is on the south side, although I believe that it is on the U of Chicago campus.
01:21firefauxis there a prepending version of conj?
01:22andclojCan someone tell me why this evaluates to 3 and not 5? http://pastebin.com/fiPFfKaA
01:22firefauxoh, I guess I can just use cons
01:23TravisDfirefaux: For lists, conj will add to the beginning and for vectors it adds to the end
01:23firefauxoh
01:23TravisDmore generally, I think the implementation is free to choose where to add the new element based on what is the most efficient
01:23firefauxwhat about cons?
01:23firefauxis that always guaranteed to put it at the front?
01:23firefauxactually, of course
01:23firefauxthat's what conses are
01:23TravisDcons is only defined for lists, but it does the same as conj
01:24TravisDaside from having its arguments swapped
01:24firefauxI can still use a vector as input to it, right?
01:24firefaux,(cons 2 [1 2 3])
01:24clojurebot(2 1 2 3)
01:24firefauxok good
01:24firefauxI don't care what kind of seq I get out
01:24firefauxas long as it's a sequence of some sort
01:25TravisDah, and what I said I think is wrong. When I was testing things out I had the arguments mixed up :)
01:29andclojWhy does this evaluate to 3 and not 5? code: (let [x '(+ 2 3) op (first x) args (rest x)] (apply op args))
01:35ddellacostaandcloj: you want
01:35ddellacosta,(let [x '(+ 2 3) op (first x) args (rest x)] (apply (resolve op) args))
01:35clojurebot5
01:36ddellacostaandcloj: what you are doing is essentially this:
01:36ddellacosta,(apply (symbol "+") [2 3])
01:36clojurebot3
01:37ddellacostaI'm actually not sure what that is doing.
01:37TravisDddellacosta: Hmm, why doesn't that give an arrity exception, since the symbol is a function on dictionaries, expecting one argument?
01:37TravisDer, it is not that. It is just not a function
01:37ddellacostaTravisD: yeah, it's a bit strange to me...
01:37TravisDon my machine it does give an error
01:38TravisDbut not for the original code pasted by andcloj
01:38ddellacostaTravisD: wat
01:39andclojI get no exception.
01:40TravisDAh, no, sorry. I get an error depending on the number of arguments I provide: https://www.refheap.com/55533
01:40ddellacostaTravisD: ah, yeah, I see that too.
01:40andclojI find this to be interesting, too: (= + (resolve (symbol (first '(+))))) evaluates to false
01:41andcloj(= + (resolve (first '(+)))) also resolves to false
01:42pdk,(= '+ (resolve (first '(+)))
01:42clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
01:42pdk,(= '+ (resolve (first '(+))))
01:42clojurebotfalse
01:43andcloj,(= + (resolve (symbol (first '(+)))))
01:43clojurebotfalse
01:43ddellacostaandcloj: do you expect that to be true?
01:44ddellacosta,(= (first '(+)) '+)
01:44clojurebottrue
01:44ddellacosta,(= (resolve (first '(+))) #'+)
01:44clojurebottrue
01:45andclojddellacost: I'm not sure what I expect, I'm new to clojure
01:45ddellacostaah, okay
01:45andcloj:)
01:45ddellacosta,+
01:45clojurebot#<core$_PLUS_ clojure.core$_PLUS_@1ac5f00>
01:45ddellacosta,'+
01:45clojurebot+
01:45ddellacosta,#'+
01:45clojurebot#'clojure.core/+
01:45ddellacosta,(resolve '+)
01:45clojurebot#'clojure.core/+
01:45andclojI very much so appreciate the help though.
01:45ddellacostaetc
01:45ddellacostaandcloj: :-)
01:45andclojYeah so they are different things
01:47ddellacostaandcloj: yeah, I recommend taking a look at these two pages for more context: http://clojure.org/reader and http://clojure.org/data_structures#Data%20Structures-Symbols
01:50andclojok thanks
01:51andclojddellacost: going back to the original I still don't quite understand the actual mechanics of how it returns 3 instead of 5, I'll see if I can figure it out from those pages
01:51andcloj,('x 1 2)
01:51clojurebot2
01:52andcloj,('+ 1 2)
01:52clojurebot2
01:52ddellacostaandcloj: This explains what is going on there: http://stackoverflow.com/questions/12281631/what-do-clojure-symbols-do-when-used-as-functions
01:53ddellacostait's apparently the same as doing (get {:foo "foo"} :bar "bar")
01:53ddellacosta,(get {:foo "foo"} :bar "bar")
01:53clojurebot"bar"
01:53ddellacostanot the same, but analogous, I should say
01:54andclojddellacosta: this stack overflow references the same 4clojure that led me to this confusion :)
01:54ddellacostaandcloj: haha, there ya go, it all comes full circle. ;-)
01:56ddellacostaer, more like
01:56ddellacosta,(:bar {:foo "foo"} "bar")
01:56clojurebot"bar"
01:56xuser0
01:57andclojso then is using (resolve op) a no no?
01:57andclojlike using an eval in other languages would be?
01:57andclojif we had to worry about user input
01:58andclojI guess you could check if it's in a list of allowed symbols
02:00ddellacostaandcloj: no, I use it all the time. eval is definitely...questionable. But resolve is fine if you know what you're doing. Worst thing that'll happen probably is that you'll get an exception because something doesn't resolve.
02:00ddellacostaandcloj: I mostly find myself using it in macros.
02:02firefauxdamned daylight savings time
02:02firefauxit's 2 already :\
02:02firefauxalright, 'night everyone
02:09dissipate,(and)
02:09clojurebottrue
02:09dissipate,(or)
02:09clojurebotnil
02:10dissipate,(= (and) (or))
02:10clojurebotfalse
02:10dissipate,(= (or) (or))
02:10clojurebottrue
02:10dissipate,(= (and) (or))
02:10clojurebotfalse
02:11dissipateanyone care to explain that ^
02:19dissipatelazy-seq seems like python's 'yield'
02:30Nyyxanyone know of any clojure IDE's for android
02:35dissipateNyyx, not sure about IDE but there is a repl
02:35dissipate'Clojure REPL'
04:41BartAdvNyyx: and what about Nightcode?
04:51scottjBartAdv: I think the assumption was the IDE was going to run on android, not make apps for android (which is I think all nightcode does)
04:53BartAdvhah, I assumed the same, somehow I thought Nightcode can be run there
05:46anarsI'm writing my own workflow for cemerick's friend library, but I'm not sure what to return from the workflow function when auth succeeds. I've looked at https://github.com/cemerick/friend/blob/master/src/cemerick/friend/workflows.clj#L54 of course, but I'm not sure what should go into the meta map.
05:47anarsI figured I'd put in a ::friend/workflow key, but can I just invent a new value for it? instead of :http-basic that is. that part isn't being validated anywhere down the road?
05:51noidiin http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded , Stuart Sierra keeps the system reference in a var that he updates with alter-var-root. what's the reason for updating the var instead of storing an atom in the var and updating it?
05:51noidithis has been bugging me for quite a while now :)
05:52clgvnoidi: no big reason. I guess he wants to make clear that it is a dev time constant
05:53clgvand the few dev functions associated to it do not have the additional noise an atom would introduce
05:55sm0kehey guys how to design multivariate macros?
05:55sm0ke,(defmacro foo ([x y] `(prn ~x ~y)) ([x] (foo x 1)))
05:55clojurebot#'sandbox/foo
05:55sm0kethis doesnt work
05:55sm0ke,(foo 1)
05:55clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox/foo>
05:55sm0ke,(foo 1 2)
05:55clojurebot1 2\n
06:00fredyrthink about what's happening when you macro expand the macro
06:01fredyrat compile time
06:01sm0kegot it
06:01sm0ke(defmacro foo ([x y] `(prn ~x ~y)) ([x] `(foo ~x 1)))
06:01sm0kehit and trial though
06:01sm0ke,(defmacro foo ([x y] `(prn ~x ~y)) ([x] `(foo ~x 1)))
06:01clojurebot#'sandbox/foo
06:01sm0ke,(foo 3)
06:01clojurebot3 1\n
06:02sm0kemakes sense though
06:06sm0keso i have this protocol where i want to define a function `flush`
06:06sm0keis this a good idea?
06:11dsrxwell..
06:11dsrx,(doc flush)
06:11clojurebot"([]); Flushes the output stream that is the current value of *out*"
06:26sm0keyes but i have seen people using reserved function names
06:33cemerickanars: ::friend/workflow is more to aid in debugging (i.e. "where did this map of credentials come from?") than anything else
06:49zoldarClourescript related question: I need to set an attribute deeper in the nested structure of object, like "elem.style.margin-left". The problem is the dash in "margin-left". How to do that? I can't find a valid form for "set!" for such case
06:54zoldarok, got it: (aset (.-style elem) "margin-left" 0)
07:00dsrxzoldar: that JS property is elem.style.marginLeft
07:00dsrxat least, if you're talking about a dom element
07:00zoldardsrx: ouch, thanks
07:00zoldardsrx: yes, yes I do, however I suppose that in case of non-dom attributes, I would have to resort to my version
07:01dsrxyeah, if you'd have to use a string property accessor rather than dots to get at it in JS, you'd probably need to do the same in cljs
07:04dsrxseems that elem.style["background-color"] etc also works, huh. dunno if that's standard
07:04dsrxi've always usedthe camelized versions of css properties
07:07zoldarwell afaik all object attributes in js are accessible through string notation, no?
07:08dsrxyes, they are; i was surprisde that you can use either style["backrgroundColor"] or style["background-color"] in the case of css properties, at least in chrome
07:08zoldarah
07:11anarscemerick: alright. I've written this, and it's gotten me a bit further: http://hastebin.com/xavoripise.clj
07:12anarsalthough now the request is 403'd telling me I don't have the proper roles. however, the resources I've secured using friend doesn't require any roles.
07:12anars(i.e. :roles #{})
07:13anarsthe setup works when I'm using the bundled http-basic workflow, but I'm definately missing something here with my custom JWT workflow.
07:15anarslast note: I know I don't need the if-let from line 8 in the hastebin. that's only there because I started out with the http-basic handler and started shaving things off.
07:16cemerickanars: what is the actual message provided? There's nothing in friend that should emit any mention of roles in a 403 AFAIK.
07:18anarscemerick: you're right, I wasn't specific enough. it seems to be the default-unauthorized-handler which is being invoked: "Sorry, you do not have access to this resource."
07:19anarsmy println's tell me that the JWT provided is valid, and it even prints out the creds map: {:identity anars, :username anars, :roles #{:meve-webservice.web/user}}
07:23cemerickanars: You must be throwing an unauthorized exception somewhere
07:25anarscemerick: yeah, but I'm not doing that on purpose :-) if you have the time, you can have a look at my route and app defs here: http://hastebin.com/worimixuru.clj
07:25anarsbut there's nothing seemingly wrong with what I'm returning from the jwt auth handler, is there?
07:28cemerickanars: the empty set provided to wrap-authorize is probably the culprit
07:31anarscemerick: as always, I would've sworn I tried that ;) but you're perfectly right. it's working now. thanks a ton.
07:32cemerickanars: pull req welcome to assert that that set isn't empty
07:34anarscemerick: roger - will do that.
08:23pyrtsaWhat's the concensus on reflection warnings? Should one try everything to get rid of them? Is it considered acceptable to send pull requests that fix them in open source libraries?
08:25ambrosebspyrtsa: yes
08:26clgvpyrtsa: there are sometimes (rare) cases where you cant get rid of them without loosing general applicability
08:27anarscemerick: would you accept the usage of :pre condition map for that?
08:27cemerickanars: No, there should be a useful message thrown when the condition fails
08:28anarsroger
09:39arav93Hi!
10:02steerioanyone alive? :)
10:03jballancnope
10:03jballanc;-)
10:04steeriooh, carry on then.
10:04steerio:D
10:04jballancEDT is probably sleeping off their DST hangovers
10:04steeriowas the switch just now?
10:04steeriototally different in europe
10:04jballancyesterday for the US
10:04steerioTIL :)
10:04jballancheh...Europe and the rest of the "sane" world ;-)
10:05steerioi'm questioning the sanity of DST in general
10:05jballancas a programmer, doubly true!
10:06jballancI once caught a DST bug only because I was up, coding at 2 AM during a DST transition
10:06steeriolol
10:06steerioalways use UTC!
10:06jballancindeed
10:07steerioanyway, check what i've just found http://pastie.org/8903501
10:07steerioquite interesting behaviour of seqable, i say
10:08steeriothe klass is an excerpt of one of an actual class that does a couple of things that are irrelevant here
10:10Anderkentsteerio: that's because (list) and (seq (list)) are not the same thing, and map gets confused when doing (seq coll) returns '() rather than nil
10:11Anderkentsteerio: pretty sure the contract of Sequable specifies that if it's empty it should return nil
10:11Anderkent... but htere's no javadoc on the class so there.
10:13steerioAnderkent: yep, nothing in clojure.lang.Seqable
10:13steerioAnderkent: but it's good to know
10:13Anderkentsteerio: i.e. map goes (if (seq xs) (cons (f (first xs)) (map f (rest xs))) nil); xs is your Klass thing, (seq xs) gives back '(), which is truthy
10:13Anderkentso map does (cons nil (map f nil)) -> '(nil)
10:13steerioAnderkent: yep that's what was confusing, that map does seq anyway
10:13Anderkentyeah but your thing is only valid when its seq'd twice
10:14Anderkent(seq xs) -> '() , (seq (seq xs)) -> nil
10:14steeriotricky
10:14Anderkentwhat you want your class to do
10:14Anderkentis RT.seq(loader.invoke())
10:15Anderkentnice repro though
10:15Anderkent(inc steerio)
10:15lazybot⇒ 1
10:15steeriothanks for the help
10:15clgvsteerio: I think the contract is the seq() must return nil if the collection is empty
10:17steerioAnderkent: repro?
10:17Anderkentexample
10:17steeriooh right, thx
10:18jjroI have a route "/rest/v1/async", and when I'm sending a websocket message through I get an error: java.lang.ClassCastException: org.jboss.netty.handler.codec.http.websocketx.TextWebSocketFrame cannot be cast to org.jboss.netty.handler.codec.http.HttpChunk
10:18jjro(defroutes async
10:18jjro (GET "/rest/v1/async" {}
10:18jjro (aleph/wrap-aleph-handler connect-message)))
10:20jjronon-websocket requests the route works, but I cannot figure out why it fails, when using websockets
10:22steerioAnderkent, clgv: works like a charm now, thx for making it clear about seq()
10:27whodidthisCan't open 'Successfully compiled "out/test.js". how to fix when trying to run cljsbuild tests
10:27scape_jjro: take a closer look at compojure, which I think you're using for routing
10:28scape_also remember that websockets get routed only once for the entirety of the connection
10:34jjroscape_: thanks for the hint. I'm following http://alexkehayias.tumblr.com/post/28783286946/a-simple-real-time-chat-server-using-clojure-and-aleph and I haven't yet spot the difference in my code.
10:38scape_use refheap or something and post your connect-message function
10:47jjrook, here is the paste of all relevant parts: https://www.refheap.com/55822
10:53jjl`_anyone have an opinion on what's the easiest library for handling config files?
10:54jjl`_no particular format is required. it's liable to only store simple keys/values
10:56jjroI solved that websocket-problem. Upgrading aleph to 0.3.1, and compojure to 1.1.6 changed something, and now it works.
10:57scape_oh good, jjro
10:58joegallojjl`: tell us more about these config files
11:00jjl`they'll be storing configuration for webapps. likely to be things like database credentials etc., nothing too complicated, doubtful i'll need anything more than key/value pairs. i don't want to pass them on the command line though
11:00steeriojjl`: https://github.com/weavejester/environ
11:00steeriojjl`: may or may not be what you want
11:00jjl`i was just looking at that. i'm a little unclear about how the jvm resolves properties files at runtime though
11:00steerioyou can also use java properties files
11:01joegallothere's also require and load-file, you could just a config ns with a bunch of defs in it...
11:01jjl`yeah, properties files are sufficiently structured for my purposes. environ seemed like a nice way of handling it
11:01joegalloor something like https://github.com/sonian/carica
11:02jjl`heh. i'm not configuring my app with executable code :)
11:02joegalloshrug
11:03jjl`something that parsed EDN would be okay
11:05joegalloyou could just edn-read a file from the classpath, then http://clojure.github.io/clojure/clojure.edn-api.html#clojure.edn/read
11:12johnnyblazeQuestion: how do you escape parenthesis in a string ?
11:14jjl`a string of...?
11:14johnnyblazetrying to execute a stored procedure. args to that stored procedure are enclosed in parenths
11:15jjl`using what? i suspect what you actually want is a placeholder
11:16johnnyblaze(execute! db-spec "execute sp ('mode"))
11:16johnnyblazeas an example
11:16johnnyblazechange the last quote to a single
11:16johnnyblaze(execute! db-spec "execute sp ('mode'))
11:17johnnyblazeNo way to do it with just jdbc? I don't use korma.
11:18jjl`i'm sure there is, but i've tried to avoid using raw jdbc because i find it quite painful
11:18jjl`but i think what you want is a placeholder in any case
11:18koalallamajohnnyblaze: aren't you missing a close double-quote?
11:19johnnyblazeyeah I am. (execute! db-spec "execute sp ('mode")")
11:19johnnyblazeerr (execute! db-spec "execute sp ('mode')")
11:19johnnyblazesorry coffee hasn't kicked in yet... apparently
12:04TravisDSo this came up last night, and I'm still not totally sure what's going on. Can someone explain it to me? I understand that the + symbol is not being resolved to the addition function, but it's not clear to me why this doesn't give an arity exception in all four cases: https://www.refheap.com/55870
12:05bbloom(doc +)
12:05clojurebot"([] [x] [x y] [x y & more]); Returns the sum of nums. (+) returns 0. Does not auto-promote longs, will throw on overflow. See also: +'"
12:05bbloomTravisD: note the variadic signatures
12:05bbloom+ is a monoid
12:05bbloomhttp://mathworld.wolfram.com/Monoid.html
12:05TravisDbbloom: I don't think that's what going on. (apply '+ [2 3]) evaluates to 2
12:05bbloom(doc *) ;; multiplication too
12:05clojurebot"([] [x] [x y] [x y & more]); Returns the product of nums. (*) returns 1. Does not auto-promote longs, will throw on overflow. See also: *'"
12:06bbloomTravisD: oh, duh, overlooked that. symbols are functions like keywords are functions
12:06TravisDand, why doesn't the 3-argument apply return
12:06bbloom,('x {'x 5})
12:06clojurebot5
12:06TravisDAh, okay, and what do the functions do?
12:06bbloom,('y {'x 5} 10)
12:06clojurebot10
12:06bbloom,('y {'x 5} 10 15)
12:06TravisDnamespace resolution or something?
12:06clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: Symbol>
12:06hyPiRionTravisD: they are like keywords
12:07hyPiRion,(map 'foo '[{foo :bar} {foo :zap}])
12:07clojurebot(:bar :zap)
12:07TravisDhyPiRion: Right, so keywords look themselves up in maps. But what do symbols do?
12:07bbloom('sym associative) is similar to (get associative 'sym)
12:07hyPiRionTravisD: exactly the same thing
12:07TravisDAh, cool
12:07TravisDand why can they take two arguments instead of one?
12:07bbloom(doc get)
12:07clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
12:07rasmusto,(map 'foo '[{foo :bar} {bif :bof}])
12:07clojurebot(:bar nil)
12:07bbloomsimilar to the second signature
12:07TravisDAh, very neat. Thanks a lot
12:07hyPiRionTravisD: For the same reason keywords can, as a fallback if no value exists
12:07TravisDYeah, I didn't realize that was an option
12:10clgv,({:a 1} :b :c)
12:10clojurebot:c
12:11TravisD,(:b {:a 1} :c!)
12:11clojurebot:c!
12:11clgvyou build riddles by mixing those frequently in the same source ;)
12:12TravisDHehe, unpleasant riddles
12:13hyPiRion(apply map list ...) is also a fun riddle
12:13hyPiRionHOFing, how does it work
12:14rasmusto,(apply map list [[1 2 3] [4 5 6] [7 8 9]])
12:14clojurebot((1 4 7) (2 5 8) (3 6 9))
12:14rasmusto:)
12:14TravisDIt be the transpose!
12:14sm0keanyone else having problem with maven repositories today?
12:15rasmusto,(apply (comp (partial reduce +) (partial map list) [[1 2 3] [4 5 6] [7 8 9]])
12:15clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
12:15rasmusto,(apply (comp (partial reduce +) (partial map list)) [[1 2 3] [4 5 6] [7 8 9]])
12:15clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Number>
12:15rasmustoaw :(
12:15rasmusto,(apply (comp (partial apply reduce +) (partial map list)) [[1 2 3] [4 5 6] [7 8 9]]) ; oh man
12:16clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core/reduce>
12:16rasmusto,(apply (comp (partial map #(apply reduce + %)) (partial map list)) [[1 2 3] [4 5 6] [7 8 9]]) ; oh man
12:16clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core/reduce>
12:16TravisD:(
12:16rasmustook I give up. use a list comprehension
12:16TravisDPoor clojurebot
12:17rasmustooh whoops, forgot to eat breakfast. brb
12:19justin_smithrasmusto: you do know you can /msg clojurebot right?
12:19rasmustojustin_smith: k. sorry about the spam
12:20justin_smithnp
12:21justin_smithit's more like "you can keep trying and find that answer without showing off all your mistakes", since you weren't interrupting another convo or anything
12:21rasmustogotcha
12:24rasmustofood is kicking in ##(apply (comp (partial map #(apply + %)) (partial map list)) [[1 2 3] [4 5 6] [7 8 9]])
12:24lazybot⇒ (12 15 18)
12:28mindbender1,(seq? [4 1 9])
12:28clojurebotfalse
12:29mindbender1,(sequential? [4 1 9])
12:29clojurebottrue
12:33justin_smith,(sequential? "hello")
12:33clojurebotfalse
12:34mindbender1,(more [4 1 9])
12:34clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: more in this context, compiling:(NO_SOURCE_PATH:0:0)>
12:36mindbender1why doesn't PersistentVector qualify as ISeq?
12:37mindbender1ISeq interface demands first() next() more() cons()
12:37justin_smithmindbender1: were you looking for "rest" instead of more?
12:38justin_smith,(.more (cons 1 ()))
12:38clojurebot()
12:38mindbender1justin_smith: no, I was wondering why my test for seq? on PersistentVector fail
12:38justin_smithit isn't more, it's .more
12:38yedianyone in boston wanna do a clojure thing for this: http://grandhackfest.wordpress.com/
12:39justin_smithmindbender1: because of the underlying implementation of vectors you have peek and pop with an appending conj instead of first / rest with a prepending conj as the primitives
12:40justin_smith,(.pop [0 1 2])
12:41clojurebot[0 1]
12:41justin_smith,(.first '(0 1 2))
12:41clojurebot0
12:41mindbender1justin_smith: is there any reason why PersistentVector was not tagged as implementing ISeq?
12:42mindbender1since the .first works on it
12:42justin_smithbecause iseq is for things that conj at the front
12:42justin_smith,(.first [0 1 2])
12:42clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: first for class clojure.lang.PersistentVector>
12:42justin_smithno it doesn't
12:42mindbender1ok
12:42justin_smithseq is useful here
12:42mindbender1justin_smith: thanks
12:42stompyjHow are people deploying their webapps? I'm kinda torn on just sticking with heroku v. jetty v. nginx-clojure module
12:43mindbender1yeah
12:43justin_smith,(.first (seq [0 1 2]))
12:43clojurebot0
12:43mindbender1got it
12:44justin_smithstompyj: my latest fave is http-kit standalone (uberjar run with java -jar) with whatever in front of it (nginx in my case)
12:44justin_smithstompyj: heroku is annoying because you can get discrepencies between their version of lein and your own
12:44justin_smith(among other reasons)
12:44stompyjjustin_smith: yeah, there's a host of reasons I want to leave herokuu
12:45stompyjgreat for development, but too $$$ for production
12:45justin_smithand also I don't think git or lein should be running on the web server, personally
12:45stompyjesp. if you know how to roll your own
12:45technomancyjustin_smith: does setting :min-lein-version help?
12:45justin_smithtechnomancy: not sure - haven't tried it
12:45justin_smithfrankly it was my coworker patchwork who was mainly dealing with these issues
12:45stompyjI'll take a look @ what you suggest. Bascially I just want something that's easily scriptable via chef/ansible and supports new relic, heh
12:46stompyjtechnomancy: yeah, :min-lein-version fixed it for me
12:46technomancyjustin_smith: we don't actually recommend leaving lein around in production any more fwiw
12:46justin_smithright, I agree with that :)
12:47justin_smithI was more listing my heroku annoyances
12:47technomancykeep it coming =)
12:47stompyjtechnomancy: you mean lein on the box at all? or running lein as the executable to launch the production process?
12:48technomancystompyj: we keep the lein shell script around on the unit of deployment, but the jar file gets deleted in order to keep the size down. if you end up using it for interactive debugging or whatever it gets downloaded on demand.
12:49technomancystompyj: this happens for you if you deploy using an uberjar
12:49stompyjahhh ok
12:49stompyjwhat do you guys use as your http server?
12:49stompyjor 'front-end' server
12:49stompyjor however you want to call it
12:50technomancywe have a custom erlang front end that routes HTTP requests to the right place by tracking the way the runtime system moves around processes
12:50stompyjhahahahah
12:50stompyjthats probably overkill for my liberator based data api
12:50stompyj;)
12:50stompyjthat awesome tho
12:51technomancyyeah it's not like there are any off the shelf solutions that would work in a situation like that
12:51stompyjcool to see erlang getting some love. I used it back in the mid 90s in my mobile dev days, back when Ericcson ruled the roost
12:51technomancyoh wow, nice.
12:52technomancyyeah unfortunately the http server isn't oss yet, but the erlang codebase I'm working on is.
12:52stompyjYeesh, I meant mid-2000s.
12:52stompyjwow, sweet. you're working on riak right?
12:53technomancyI was going to say, you couldn't even get erlang outside ericsson in the mid nineties iirc
12:53technomancyno, https://github.com/heroku/logplex
12:55stompyjhaha yeah, it just *felt* like the 90s
12:55stompyjhahaah
12:55stompyjpre iPhone pre android
12:55winktechnomancy: wait, heroku does not do "lein run" in a tmux? :)
12:55technomancyhehe
12:55winkwe all do it!
12:57technomancylet it crash
13:15ghazquit
13:31jballanchuh...would've expected clojurebot to have something snarky to say to that...
13:33rasmusto~quit
13:33clojurebotrasmusto: We'll never let you leave.
13:34TimMcjballanc: It didn't come up on the dice this time.
13:35jballancclojurebot's off his game, it seems
13:35jballancclojurebot, pull yourself together
13:35clojurebotI don't understand.
13:35jballancyeah, that's what I thought
13:51TimMcclojurebot is not so much a Chinese Room as a _____
13:51TimMcSomeone fill in the blank, I can't come up with anything really funny.
13:52turbofailmaltese falcon?
13:53hiredman~clojurebot
13:53clojurebotclojurebot is a time-capsule for snark
13:53hiredmanthat'll do
13:55amalloy(inc clojurebot)
13:55lazybot⇒ 34
13:55Raynes(inc amalloybot)
13:55lazybot⇒ 1
14:01steerioamalloybot: what's this (inc nickname) thing?
14:01steerio-bot
14:01steeriostupid tab
14:03seangrove(inc amalloybot)
14:03lazybot⇒ 2
14:03koalallamaRaynes: ran across your irclj library the other day. very nice
14:04pdkirclj is truly a national treasure
14:08justin_smithregarding erlang mentioned above, I was just looking at the version of erlang that can run directly as a VM with no OS the other day
14:09justin_smithI wonder how hard it would be to have a JVM that is directly hosted as a VM instance
14:09justin_smith(next question: would it actually be any benefit)
14:10pdkwith a vm running on top of nothing wouldn't you have to roll your own versions of all the background services that an os would normally provide
14:10justin_smithif you use them, yeah
14:10pdkthen again i guess you could just implement the parts of an os you want on top of a really simple vm
14:11justin_smithalso you could have ie. a log server, that is a bog standard *nix box that runs rsyslog, and just send all your logs there via syslog UDP
14:11justin_smithit would get trickier for anything that absolutely needed to run within the same box
14:16amalloybotsteerio: it's just this channel's quaint way of thanking someone. and the bot keeps track of how often someone's been thanked
14:16amalloybotregrettably, amalloybot's circuits are not advanced enough to keep track of that, so we have to use lazybot
14:17Rayneskoalallama, pdk: Heh, happy you guys like it. <3
14:20amalloybotalso the network latency to amalloybot is unacceptable. sometimes it takes up to eight hours to get a response!
14:21RaynesPackets sent by carrier pigeon.
14:21rasmustofancy merge-with: https://www.refheap.com/55878 thoughts?
14:22rasmusto(both on impl and utility)
14:24amalloybotrasmusto: the first apply-merge step seems silly
14:24amalloybotjust use a default merge-fn of (fn [a b] b)
14:24amalloybotand otherwise look it up in the merge-fn-map
14:25RaynesThere's a lot of merging happening in that code.
14:25rasmustoamalloybot: ah, okay. Does the list comprehension make sense? or could I do "merge-fn-map" more generically
14:25justin_smithamalloybot: thing is, he needs a step that merges together all the unmerged keys
14:26justin_smiththe ones that only appear in one map I mean
14:26arrdemrasmusto: that's pretty slick
14:26amalloybotyeah, i confess it's not as easy as it first appeared to me. i was thinking you have access to the key in merge-with
14:27rasmustoah, yeah.
14:27rasmustowould it help to dissoc the specified keys from the (apply merge maps) step?
14:28AmnesiousFunesrasmusto: I think you could work out a version with a more enjoyable implementation, but the functionality is very neat
14:29rasmustoalright. I'll tweak it to make it more readable/efficient
14:29amalloybotrasmusto: https://www.refheap.com/55881 is how i'd write it. yours is more readable :P
14:31rasmustoamalloybot: reduce works because it's assumed to go left-to-right?
14:32amalloybotincidentally, you don't test for what happens if a key needs to be merged that you don't specify a function for
14:32justin_smithamalloybot: he reduces across the function keys
14:32amalloybot"assumed"? reduce is defined to operate on sequences in order
14:32justin_smiththat's what the apply merge is for
14:33amalloybotjustin_smith: i can see his implementation. i meant his test case at the bottom
14:33justin_smithOK, now I get it
14:35justin_smithhttps://www.refheap.com/55883
14:36amalloybot(merge x (into {} foo)) is (into x foo), by the way, rasmusto
14:38sdegutisamalloy is a bot now? How long was I gone!?
14:39amalloybotsdegutis: it was only a matter of time before my tendency to rewrite people's functions in shorter or faster ways became automated
14:39zspencerisn't that just clojure.core/assimilate
14:39bbloomamalloybot: your services are automated now!? is there a vim plugin?
14:40sdegutisM-x insert-emacs-joke-here
14:40RaynesI'll write his Vim integration. All it has to do is prompt you to install Emacs.
14:40amalloybotsdegutis: vim is just a very long-term emacs joke
14:40sdegutisBah-dum tshh!
14:40zspencerbecause no one knows how to :q! it?
14:40arrdemzspencer: haha
14:41chouserI use evil in emacs, demonstrating that emacs is just a really complicated vim implementation.
14:41amalloybotzspencer: amusingly, i've bound C-x C-c to (lambda () (message "Why would you ever leave?"))
14:41technomancychouser: two vim implementations, technically
14:41amalloybotis it only two?
14:41technomancyamalloybot: two built-in
14:41amalloybotah
14:42technomancyoh my bad
14:42technomancyevil isn't built in
14:42amalloybotbbloom: you mentioned an editor
14:42technomancyit's two built-in IRC clients
14:42amalloybotthis is a programming-language channel. it's inevitable
14:42bbloomamalloybot: i just wanted my functions to be shorter and faster :-P
14:42chouserviper is does not implement vim, it tries to implement vi. But nobody wants to use vi
14:42amalloybot*chuckle*
14:42InvidFlowerHey, is there anything in clojure by default to let you partial application in a way more like scala syntax where you can skip things in the partial application? Like (partial2 do-thing 1 _ 5) would return a func that applies the first argument to the second param.. and any additional ones to 4th param, etc ?
14:43sdegutisI was hoping to rewrite emacs in a JavaScript VM on top of ObjC the other day. Got pretty far actually.
14:43amalloybotInvidFlower: lambda
14:43sdegutis(And by "emacs" I meant a <textarea> linked to a file.)
14:43chouserInvidFlower: #(apply do-thing 1 % 5 %&)
14:43amalloybotsdegutis: ymacs?
14:43sdegutisI guess that's LightTable though...
14:44amalloybotnah, ibdknox doesn't want to implement emacs
14:44InvidFloweramalloybot, chouser: Yeah I was thinking of that, though I didn't realize the %& syntax..
14:44sdegutisamalloybot: well, it's in the spirit of emacs
14:45amalloybotInvidFlower: the #() syntax is fine there, although personally i usually use a "long-form" lambda rather than %&: (fn [x & args] (apply do-thing 1 x 5 args))
14:46sdegutisamalloybot: ymacs looks neat, if limited
14:47amalloyi'm tired of being a bot already
14:47koalallamayou were the smartest bot I had ever seen
14:47amalloyvim integration sounded like too much work
14:49InvidFloweramalloybot: Good point. In my case I was trying to do a dynamic query to Korma which transforms (select table (fields :id :name)) to (-> (select* table) (fields :id :name)). So to pass a collection to fields it had to be something like (select table (#(fields % field-names))). I guess if I wrap "fields" in my own func or macro it'd help..
14:51InvidFlowerErrr… I mean (select table (#(apply fields % field-names)))
15:07akais there an idiomatic way to grab a single random value from a map?
15:08akaI don't need truely random here... just randomish.
15:09pyrtsaaka: I think your best option is to keep (vec (keys m)) at hand, and call (m (rand-nth ks)) with it.
15:09justin_smith(rand-nth (vals {:a 0 :b 1}))
15:09justin_smith,(rand-nth (vals {:a 0 :b 1}))
15:09clojurebot1
15:10akathanks for the suggestion
15:10justin_smithof course if you knew the keys ahead of time you could do ((rand-nth ks) m)
15:11justin_smithbut that depends on your implementation
15:11justin_smithwell no, that only works with keyword / symbol keys, better pyrtsa's version in the case where you know the keys ahead of time
15:11akaI will have them ahead of time
15:12justin_smithyeah, (m (rand-nth ks)) in that case
15:12justin_smithas pyrtsa suggested
15:12akasweet, thanks
15:12justin_smithpyrtsa: any particular reason to want ks to be a vector?
15:13pyrtsaOne possible downside, if m is big, in (rand-nth (vals m)) is that rand-nth is O(N). That's why I had the (vec ...) in there.
15:13justin_smithis rand-nth faster on a vec?
15:13pyrtsajustin_smith: That. ^ :)
15:13justin_smithahh
15:15hyPiRionrand-nth is constant time for vecs
15:15justin_smithcool, TIL
15:15hyPiRionafaik it uses nth to lookup
15:15pyrtsahyPiRion: Exactly.
15:16justin_smithhmm, if only rand-nth worked on maps
15:16justin_smiththat seems hypothetically possible - since in rand-nth it isn't the nth part we care about, it is the equal probability per element we care about
15:16pyrtsajustin_smith: Maps in general don't implement a mechanism for jumping to the nth element.
15:16shep-werkbut, wouldn't converting it to a vector also be O(N)? thus you only save if you do it multiple times?
15:17pyrtsashep-werk: Yes.
15:18amalloyjustin_smith: hash maps don't really keep the information you'd need to do a uniformly-random selection, i think
15:18justin_smithoh, OK
15:18pyrtsaWhat amalloy said.
15:18amalloythe tree has N branches, each of which has M actual nodes in its subtree; you can't choose a branch at random, you have to weight them according to each M
15:19shep-werkwell, aka did say "random-ish" and maps arent sorted... so just use `first` :-)
15:19shep-werk(def rand-int 4)
15:19justin_smithyeah, and you need a full tree walk for that, so you may as well put the vals in a vec at that point
15:19amalloyjustin_smith: well, a hash-map *could* manage enough information so that you could do rand-nth without a tree walk
15:20justin_smithright, just not the current clojure default {} impl
15:20amalloybut that would be a lot of wasted effort for the vast majority of time when nobody wants to select at random
15:22chouserNow with a sorted map and a carefully constructed object passed to subseq...
15:23Pate_where is .emacs on Windows? I can't find it in ~/.emacs (there is no .emacs in ~)
15:23justin_smithPate_: is there a .emacs.d ?
15:23Pate_justin_smith: nope :\
15:24justin_smithI don't think .emacs is even considered the "right thing" any more
15:24justin_smithhave you made any customizations?
15:24turbofailPate_: if it's not there you can create it
15:24Pate_could it be somewhere else?
15:25turbofaildoubt it. it won't exist by default
15:25turbofailespecially not on windows
15:25justin_smith"~/.emacs.d/init.el" is the current recommended place for config I think
15:26hyPiRionyeah
15:27justin_smiththat's why I asked if you customized anything: it should prompt for creating the config file unless there is one you just don't see
15:27Pate_~ should be C:\Users\<my-user>\ on Windows, right?
15:27clojurebotExcuse me?
15:27Pate_~ test if cbot answers
15:27clojurebotHuh?
15:27justin_smith~ should equal $HOME
15:27Pate_hmmm
15:27clojurebotIt's greek to me.
15:27Pate_~ google test
15:27clojurebotFirst, out of 280000000 results is:
15:27clojurebotSpeedtest.net by Ookla - The Global Broadband Speed Test
15:27clojurebothttp://www.speedtest.net/
15:27Pate_cool :)
15:27justin_smith$HOME exists on win
15:28Pate_there is no $HOME, but there is $HOMEPATH, which is at /Users/myuser
15:29justin_smithahh, I guess the canonical thing on win is %USERPROFILE%
15:36Pate_justin_smith, I can echo $HOME and get c:/users/myuser
15:37Pate_should I create a .emacs.d folder there?
15:37justin_smithyeah, and a file called init.el in that
15:37justin_smithand emacs will pick it up
15:37justin_smithbbl; lunch
15:37gfrederickswhy is autopromotion slower than overflow detection?
15:42hyPiRiongfredericks: I guess it's because there are alu flags for overflow detection?
15:43hyPiRionI mean, it's probably faster to do a short `jo throw_overflow_exception` in machine code
16:19edwMy CIDER's been hanging like crazy recently while attempting complete; has anyone else been running into this? I'm getting very good at typing C-g C-g C-g.
16:21rasmustoamalloy: thanks
16:22AeroNotixedw: I occasionally do
16:22AeroNotixToo busy to look into ti
16:22AeroNotixit
16:23edwAeroNotix: I'd be too busy to look into it too, if it weren't hanging all the time. :P
16:23AeroNotixhaha
16:24technomancyusing auto-complete.el or built-in completion?
16:25edwBuilt in, though it was happening when I was using auto-complete and then disabled while troubleshooting.
16:26edwtechnomancy: The only thing remotely not default I'm doing right now is this: I was requiring nrepl-eval-sexp-fu, but I just disabled that too.
16:28ProfpatschSo if I have a function get-token that returns a token if there is one, how would I write Cloj-onic code for the case that there is none?
16:28ProfpatschIn Python I’d throw an exception.
16:29ProfpatschI could do this in Clojure, too, but there has to be a better way.
16:29amalloyreturn nil
16:29ProfpatschWe’re back to that?
16:29technomancythere is a superior way, but it's not the clojure way
16:29ProfpatschI thought returning a null pointer was a very bad idea.
16:29amalloyyeah, that's about right, technomancy
16:30ProfpatschWhat would be the superior way?
16:30amalloyProfpatsch: you can also take the approach `get` and friends use: an optional extra argument to get-token, which is what to return if there isn't one
16:31technomancyProfpatsch: returning [:not-found] | [:ok value] while making the assumption the caller will be pattern matching against the return value
16:31technomancyor throwing an exception
16:31shep-werkor a Maybe ;-)
16:32technomancyshep-werk: ^ actually is effectively a dynamic Maybe
16:32ProfpatschSo [:not-found] is not the Clojure way?
16:33technomancyProfpatsch: that approach is pretty terrible without pervasive pattern matching
16:33shep-werktechnomancy: in that case, are you advocating something like core.match? Or somethign more manual?
16:33chouserAnother potentially nicer way is a condition system like Common Lisp.
16:33technomancyshep-werk: I'm saying it's not idiomatic clojure, so I'm not advocating anything =)
16:33shep-werkProfpatsch: I'd expect nil, with the optional argument like `get`
16:34technomancyhaven't used the new actually-working version of core.match yet
16:34shep-werktechnomancy: oh, it's certainly not idiomatic, but I was hoping you'd tell me how awesome (or not) core.match was ;-)
16:34rasmustotechnomancy: actually-working?
16:35technomancyshep-werk: I can strongly advise against using old versions of core.match; that's all
16:35technomancyrasmusto: old core.match blows up if you use it with AOT
16:35amalloyfor an even more awful dynamic-maybe: (get-token stream (fn ([] ...no-token...) ([token] ...))
16:35dnolen_rasmusto: old versions of core.match had problems with AOT
16:35rasmustodnolen_, technomancy: ah, okay :)
16:36turbofailhooray, manual CPS transforms
16:36amalloyturbofail: well, it's not really CPS because of the arity stuff
16:36amalloyi'd say it's more like hijacking the arity dispatcher, or like Maybe with an implicit bind
16:38turbofailit's basically a success and fail continuation packaged into a "single"-ish function
16:38amalloyyeah, i guess that's true
16:40arrdemoh good amalloy isn't a bot anymore
16:40arrdemI can still act like programming is NP-hard
16:45stuartsierraWhat's the most direct way to do truncating division of java.util.Longs?
16:46amalloystuartsierra: ##(doc div), i think?
16:46lazybotjava.lang.RuntimeException: Unable to resolve var: div in this context
16:46rasmustoamalloy: oh, your code makes perfect sense, and is faster. Thanks for giving me more use-cases for reduce :)
16:46amalloy&(doc quot)
16:46lazybot⇒ "([num div]); quot[ient] of dividing numerator by denominator."
16:46amalloyor do you mean in java-land
16:47rasmustoamalloy: the double-reduce is a bit strange at first, but it makes sense since its a coll of maps we're dealing with
16:48stuartsierradiv makes sense, thanks amalloy
16:48amalloystuartsierra: it's actually quot, i was wrong
16:48stuartsierraah
16:49amalloy$findfn 10 4 2
16:49lazybot[clojure.core/rem clojure.core/unchecked-remainder-int clojure.core/quot clojure.core/unchecked-divide-int clojure.core/mod]
16:49amalloyoh, of course mod shows up in that list too :P
16:54dbaschwhat's the right way to validate from input in a compojure app (e.g. emails, numbers)?
16:54dbaschor at least, the easiest way besides doing it myself with regexes
16:55justin_smithThe only way to reliable and simple way to validate an email is to send an email. The email spec is weird.
16:55justin_smithOT I know, just saying
16:55amalloyjustin_smith: that's true, and i almost said it myself, but that doesn't mean it's wrong to want to validate them anyway
16:55amalloyyou can easily say "that can't possibly be a valid email address because it has no @, please check it"
16:56amalloyonce all the idiot-tests have passed, you validate it for real
16:56pyrtsaAlso, there are client-side JS libraries that let you warn the user of probable typos in email addresses, even suggest corrections.
16:59justin_smith"very.unusual.@.unusual.com"@example.com http://en.wikipedia.org/wiki/Email_address#Examples
17:01Pate_I'm trying to follow this tut: http://clojure-doc.org/articles/tutorials/emacs.html
17:02Pate_but I'm stuck at the "Configuring Emacs" step
17:02seangroveWhat's the clojure metrics plugin?
17:02seangroveI'd like to see LoC, etc.
17:02Pate_I found the .emacs.d folder: C:\Users\myuser\AppData\Roaming\.emacs.d\
17:02justin_smithPate_: have you created init.el?
17:03Pate_yes, I can put stuff in init.el
17:03Pate_and it seems to run
17:03Pate_now, in the tut it says to put (require 'package) ...
17:03Pate_that works
17:03justin_smithOK
17:03justin_smithnow you can use package to install stuff
17:03Pate_then it says to put: (defvar my-packages '(starter-kit...
17:03Pate_should I replace the previous content or append it to init.el?
17:03Pate_I tried both
17:03justin_smithappend
17:04Pate_if I append, Emacs starts up blank
17:04justin_smiththat stuff won't work without package required
17:04justin_smithyou may need to wait for it to finish installing things
17:04Pate_ah, so no loading indicator?
17:04justin_smiththat will take a few, it is downloading stuff etc.
17:04myguidingstarhi all, I have a corelogic question
17:04justin_smithPate_: not sure, I have not installed things that way, but I would not be surprised if there was no indicator
17:05justin_smithyou could check the process manager, emacs should be using the network and using some CPU and using the HD
17:05myguidingstar;"reverse" in the Reasoned Sch; 3.98
17:05myguidingstar(define memberrevo
17:05myguidingstar (lambda (x l)
17:05myguidingstar (conde
17:05myguidingstar ((nullo l) fail)
17:05myguidingstar (succeed
17:05myguidingstar (fresh (d)
17:05myguidingstar (cdro l d)
17:05myguidingstar (memberrevo x d)))
17:05myguidingstar (else (eq-caro l x)))))
17:05amalloy~refheap
17:05clojurebothttps://www.refheap.com/
17:05myguidingstar(test-check "3.100"
17:05myguidingstar (run* (x)
17:05myguidingstar (memberrevo x `(pasta e fagioli)))
17:05myguidingstar `(fagioli e pasta))
17:05Pate_ok so it finally started to respond
17:06Pate_it seemed to be eating WM_MESSAGE
17:06alewmyguidingstar: please don't paste code into irc
17:06myguidingstaralew, I'm sorry
17:06technomancyit's still recommending the starter kit? =/
17:06alewas amalloy suggested, use ~refheap
17:06technomancyshould drum up a pull request
17:06alew~refheap
17:06clojurebothttps://www.refheap.com/
17:06Pate_emacs is complaining about args out of range
17:06Pate_can't select the text to paste
17:07Pate_how do I switch to the bottom window?
17:07amalloyPate_: C-x b *Messages*
17:09myguidingstarI tried to "translate" the memberrevo function in The Reasoned Schemer 3.98
17:09myguidingstarhttps://www.refheap.com/55936
17:09myguidingstarbut it doesn't work
17:12ProfpatschAnyone knows what steps I need to take when changing my ns in Clojurescript (in Lighttable)? I can’t reevaluate it, so what do I have to reset minimum to get the imported stuff to work?
17:12dnolen_myguidingstar: what result do you get?
17:12justin_smithProfpatsch: maybe use in-ns?
17:12myguidingstarwell, the original list was returned
17:13Profpatschjustin_smith: Nah, when re-evaling in Lighttable from my code. I’m not in a repl.
17:14technomancythe heck
17:14technomancythe clojure doc guide doesn't even mention paredit
17:15RickInAtlantamyguidingstar: where you have (firsto l x) I have eq-caro
17:15RickInAtlantaoh,which is just firsto, nm
17:16dnolen_myguidingstar: hmm, I don't have an old version of miniKanren to verify the original behavior.
17:16myguidingstardnolen_, okay, so is there any way to do 'reverse' in core logic?
17:17RickInAtlantais it because conde in core.logic is actualy condi in minikanren?
17:17dnolen_myguidingstar: what I'm saying is I'm not even convinced that will work, core.logic is based on a newer version of mK
17:18myguidingstardnolen_, I got it. I just ask 'how do we do that with core.logic?'
17:18dnolen_myguidingstar: also reading it, it doesn't appear to me that the original does what you think it does
17:19dnolen_myguidingstar: but again hard for me to confirm
17:20myguidingstardnolen_, ok, forget that book. Please help me with my latest question: how do we do that?
17:21dnolen_myguidingstar: https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/bench.clj#L42
17:23myguidingstardnolen_, thanks a lot. You're my hero ;>
18:05justin_smith(str str str)
18:05justin_smith,(str str str)
18:05clojurebot"clojure.core$str@f4b5c1clojure.core$str@f4b5c1"
18:06technomancybuffalo buffalo buffalo
18:06justin_smith,(vector vector vector)
18:06clojurebot[#<core$vector clojure.core$vector@81d1ed> #<core$vector clojure.core$vector@81d1ed>]
18:06AeroNotix,(partial partial partial)
18:06clojurebot#<core$partial$fn__4196 clojure.core$partial$fn__4196@f300fa>
18:06justin_smithnice
18:07justin_smith,(juxt juxt juxt)
18:07clojurebot#<core$juxt$fn__4179 clojure.core$juxt$fn__4179@12dea42>
18:07justin_smithnow to find a context where (juxt juxt juxt) would be in some way useful
18:10technomancyjuxt praemium suum est
18:11technomancymuch like TCO
18:11justin_smithindeed
18:14rasmusto,((apply juxt [:a :b :c :d]) {:a 1 :b 2 :c 3 :d 4}) ; am I doing it right?
18:14clojurebot[1 2 3 4]
18:14atyzCould someone tell me how I might find the fully qualified path for a function?
18:15amalloy&(map {:a 1 :b 2 :c 3 :d 4} [:a :b :c :d])
18:15lazybot⇒ (1 2 3 4)
18:15bbloomatyz: functions don't have fully qualified paths
18:15technomancyatyz: you need a var for that
18:15rasmusto,((apply juxt [:a :b :c :d #(get % :e :baz)]) {:a 1 :b 2 :c 3 :d 4}) ; am I doing it right?
18:15clojurebot[1 2 3 4 :baz]
18:16atyzThanks!
18:16redx543Is it possible to remove nils from a vector of vectors, for example [nil nil [1 5] nil nil [3 8] nil nil]?
18:17amalloyredx543: sure, i mean, there's ##(doc remove)
18:17lazybot⇒ "([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns false. pred must be free of side-effects."
18:17rasmustoredx543: you almost have it typed out in pseudocode already
18:17redx543I already tried that but for some reason it flattens the vector.
18:17amalloybut also consider why you've generated such a weird vector to begin with - there's usually a better way that doesn't involve generating something weird and then fixing it
18:17S11001001redx543: don't use for
18:18redx543Wait, is for the reason for generating nils inside of the vector?
18:18amalloydon't use for??? what is the context for this that i'm missing?
18:18justin_smithS11001001 parsed a sentence oddly
18:19redx543I don't know, but it's true that I'm generating this in a for loop.
18:19amalloyoh, i see
18:19rasmusto,(for [a [nil [1 2] nil [3 4]] b a] [a b])
18:19clojurebot([[1 2] 1] [[1 2] 2] [[3 4] 3] [[3 4] 4])
18:19amalloyredx543: why don't you paste your code on refheap or gist? i'm sure someone will see the right way to do it
18:19rasmustois that what we're talking about?
18:20amalloyrasmusto: no, i think you're three levels deep into a nested misunderstanding
18:20amalloyeveryone abort
18:20rasmusto,for
18:20clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/for, compiling:(NO_SOURCE_PATH:0:0)>
18:20turbofaileveryone out of the universe!
18:22S11001001it's *cosmos* these days.
18:27justin_smith~for
18:27clojurebotfor is complected
18:28justin_smith~for
18:28clojurebotfor is complected
18:28rasmustoi've seen this a few times ##(#(for [a %] a) [1 2 3])
18:28lazybot⇒ (1 2 3)
18:30justin_smith it's less characters than #(map identity %) I guess
18:30justin_smithbut more than seq
18:30rasmustowell, I just pasted the simplest version of it
18:30justin_smithahh, right
18:30rasmustoits better than trying to do everything complex using thread-last
18:40technomancyis "thread-last" the canonical pronounciation?
18:40amalloytechnomancy: that's my understanding, yes
18:40rasmustoI saw it written somewhere, I just say ->>
18:40amalloyi say "double-arrow", but i don't mind being wrong
18:40technomancyI call -> "thrush" in my head
18:40amalloyrasmusto: out loud? i'd loev to hear that
18:40amalloytechnomancy: :((((
18:40technomancyI guess I call ->> "thrushush"
18:41AeroNotixthread and thread-last here
18:41rasmustohyphengreaterthangreaterthan
18:44amalloytechnomancy: i don't understand the popularity of the name thrush for that operator. it does things that don't make sense from the combinatorial-bird perspective
18:45SegFaultAX(inc amalloy)
18:45lazybot⇒ 89
18:45technomancyamalloy: it seems like a natural extension when you move from SKI->lisp though
18:45technomancyI don't call it a combinator, because that's silly
18:45SegFaultAXDidn't fogus do a blog post about the thrush operator?
18:45amalloyyes, i'm inclined to mostly blame him for the popularity, SegFaultAX
18:46amalloyit doesn't even take functions
18:46technomancythread-first is to lisp forms as the thrush combinator is to SKI
18:47technomancyfogus's post was pretty explicit about -> not being the thrush combinator
18:48technomancywhich doesn't imply that -> does not partake in the nature of thrushiness
18:50amalloyyou're right, i'm definitely wrong in saying the name popularity came from fogus
18:50danielszmulewiczseangrove: ping
18:53dsrxwill company-cider use the complete op from the cider-nrepl middlewares if it's available?
18:53danielszmulewiczamalloy: there is an explanation of the name here referencing the combinator: http://debasishg.blogspot.co.il/2010/04/thrush-in-clojure.html I don't know if it makes a lot of sense.
19:03RickInAtlantaI used the mies-om template to create a project, but when I try to evaluate my ns I get "no such var clojure.core/require-macros when I make my ns (:require-macros [cljs.core.async.macros :refer [go]])
19:04RickInAtlanta(ns om-test.core
19:04RickInAtlanta (:require-macros [cljs.core.async.macros :refer [go]])
19:04RickInAtlanta (:require [om.core :as om :include-macros true]
19:04RickInAtlanta [om.dom :as dom :include-macros true]))
19:04dsrxRickInAtlanta: refheap.com
19:05RickInAtlantahttps://www.refheap.com/56131
19:05AnderkentRickInAtlanta: are you running it as clojure or cljs?
19:05RickInAtlantaI am trying to run as cljs
19:08SegFaultAXamalloy: Sorry, I wasn't clear. I meant fogus wrote a blog post about the actual thrush operator vs. the threading macros in Clojure.
19:09RickInAtlantaweird,I try it in LightTable I get 'goog' is not defined
19:11yarouwhich one is thrush? something like: \ab -> ba
19:11technomancyyarou: that's S, I think
19:12danielszmulewiczAnyone has opinions about CSS frameworks? I'm starting a new cljs project, and I'm not set in my mind regarding which framework to use. I've worked with bootstrap, but I'm inclined to experiment with a more semantic framework (no classes littering the html). Would love to hear from anyone with experience in that matter.
19:13yarouhmm, it might be
19:13yaroui read raganwald's javascript book a while ago, so i dont remember the combinators too much
19:13rasmusto~thrush
19:13clojurebotI don't understand.
19:14justin_smithdanielszmulewicz: sass is popular around here
19:14justin_smithhttp://sass-lang.com/
19:14yarouah, i see
19:14yarou-<
19:14rasmustoI always thought that (-> blah (#(something %))) felt weird
19:14yarou->
19:15stcredzeroAny good Clojure web application examples with database backend and authentication...that actually work? http://vijaykiran.com/2012/01/web-application-development-with-clojure-part-1/ and https://github.com/xavi/noir-auth-app seem subject to bit-rot.
19:15amalloyrasmusto: that's because it's bad
19:15amalloylike, sometimes it's the least-bad alternative
19:16yaroulambda a, b: b(a) is that thrush??? in python ofc
19:16rasmustoyarou: don't think so
19:16amalloybut usually you can structure things so that -> or ->> makes sense, and if you can't then it's often more readable to not use them
19:17yarouok, how about this
19:17amalloyi think those are both thrush, yarou. (defn thrush [a b] (b a))
19:18yaroua function that takes (possibly) functions a and b as parameters, and returns b applied to a
19:18yarouamalloy: gotcha
19:20rasmusto,(reduce #(%2 %1) [(range 10) #(map inc %) reverse])
19:20clojurebot(10 9 8 7 6 ...)
19:22danielszmulewiczjustin_smith: thanks. SASS is a CSS extension language. I'm wondering about frameworks to quickly iterate on the design. I need a grid system, UI components, responsiveness, etc.
19:26SegFaultAXdanielszmulewicz: The common choices right now are bootstrap and foundation.
19:26SegFaultAXI prefer the latter but lots and /lots/ of people use bootstrap.
19:26SegFaultAXAlso, wrapbootstrap.com is a thing.
19:27seangrovedanielszmulewicz: SASS on top of bootstrap is what you're looking for, most likely
19:27SegFaultAXseangrove: Not likely
19:27SegFaultAXBootstrap is LESS
19:27SegFaultAXFoundation is SASS
19:27seangroveSegFaultAX: Yes, yes, but that idea
19:27SegFaultAXUnless you're just using .min.css straight up, in which case use whichever you like more.
19:27SegFaultAX:)
19:27yaroubootstrap is the devil
19:28yarouone can only hope we can find god
19:28SegFaultAXyarou: Why?
19:28danielszmulewiczyarou: That's what I had in mind :-)
19:28seangroveLooks like there's a sass-port of bootstrap
19:28SegFaultAXdanielszmulewicz: Then check out Zurb Foundation.
19:28seangroveI'm an atheist, I actively try avoiding religious associations with tech :P
19:28zspencerI'm a fan of suzy: http://susy.oddbird.net/
19:28zspencersusy(
19:28zspencersusy*
19:28danielszmulewiczThe problem of bootstrap is that it breaks the semantic coherence of html by its heavy (mi)suse of classes
19:29danielszmulewiczthere's semantic ui. Anyone tried it?
19:29yarouseangrove: i am an atheist too
19:30yaroubut literary characters are attached to some sentiment or philosophy
19:30seangroveyarou: Just a joke ;)
19:30SegFaultAXAssuming atheism is defined as lack of belief in god or gods, how can one /be/ atheist.
19:30danielszmulewiczzspencer: thanks. I had heard about it.
19:30zspencerdanielszmulewicz: if you're obsessive about keeping the classes as less mixins it works reasonably ok
19:30SegFaultAXAtheism is the default position.
19:30yarougeocities
19:30yarouis our savior
19:30stcredzeroseangrove: We could highlight similarities to religious dogma and other pathologies in tech and programming language communities, but some fraction of the audience will end up thinking "Hey, that's COOL!" and get the opposite message.
19:30seangrovedanielszmulewicz: The whole idea with with SASS + bootstrap is that you have semantic classes in the markup, but they're compiled from the presentational classes
19:31Cr8SegFaultAX: by fitting that definition, I guess?
19:31SegFaultAXCr8: What other definition could there be?
19:31yarouhas anyone used luminous or w/e in production ?
19:31seangrovestcredzero: One must be careful with sarcasm, heh
19:31yaroui'm contemplating porting my rails app to this
19:31Cr8of that word? none, but one could *not* fit the definition, and then they wouldn't be
19:31SegFaultAXCr8: "There are no gods" is a belief, but /a/theism literally means not theist, as in not someone who subscribes to a theological worldview.
19:32seangroveyarou: Certainly could do worse than that
19:32stcredzero"Animal House" was a cautionary parody which spawned endless clueless imitators. (Me in my late teens being one of them, admittedly)
19:32danielszmulewiczseangrove: BTW, have you had time to look into the externs for om (ReactCSSTransitionGroup)?
19:33Cr8that's a thing you could argue, but I feel it's being a bit pendantic ;)
19:33rasmustois pedantic a css framework?
19:33seangrovedanielszmulewicz: I did, but it turned out to be a very, very involved process. I'm going to meet up with some of the React team and see if there's anything that can be done about moving them over to using Closure (perhaps even on top of browserify).
19:33seangrovedanielszmulewicz: Have you tried just using auto-generated externs?
19:34seangroveThat was going to be my next attempt
19:34danielszmulewiczseangrove: Awesome news. No, I've been stalling.
19:34Cr8and then there are noncognitivists, who hold the position that "there are(n't) gods" isn't a belief
19:35justin_smithand ignosticism, which contends "is there a God" is an underdefined, and nonsensical question
19:36SegFaultAXCr8: Which makes no sense, since "there are(n't)..." is a claim which must be substantiated with evidence.
19:36SegFaultAX(Irrespective of the claim)
19:36Cr8well the position is the stuff after the "..." is not defined in any useful sense
19:36Cr8same as ignosticisim
19:37Cr8so it's useless to make the statement
19:37tlbakhis there anyone that i can ask a question about clojure ?
19:37SegFaultAXtlbakh: Ignore us, carry on. :)
19:37Cr8tlbakh: yes
19:37zspencerOnly if your say 10 hail-hickey's first.
19:38SegFaultAXHaha, hail hickeys.
19:38SegFaultAX"Our father, who art in bytecode, Clojure be thy name..."
19:38tlbakhstarted yesterday to code in clj. The thing is I tried to increment every element of a list by 1 by using map.
19:39tlbakhand i wrote a main for it as follows
19:39SegFaultAXtlbakh: Wait
19:39SegFaultAXtlbakh: Don't paste code longer than one line to the chat.
19:39SegFaultAXtlbakh: refheap.com or gist.
19:39tlbakhi was gonna post gist page
19:39tlbakhoh oke then :)
19:39SegFaultAXGreat! :)
19:41tlbakhhttps://gist.github.com/wishfulpanda/9476787
19:41tlbakhhere is the link
19:41tlbakhand i commented it
19:41tlbakhwhy are these giving different outputs
19:41tlbakhis there any relevance with immutable collections?
19:42akhudektlbakh, because everything is immutable in clojure
19:42SegFaultAXtlbakh: def is a top-level form. Use let to introduce local bindings.
19:42justin_smithtlbakh: inc does not change its argument
19:42zspencerwhen you call `def` you're declaring a n immutable list
19:42SegFaultAX,(let [x 5] (prn x))
19:42zspencerprint x then just reprints the list
19:42clojurebot5\n
19:42akhudekso x is always going to be same, but the map returns a value (that you are not capturing) that represents what you want
19:43justin_smiths/inc/#(+ % 1)
19:43zspencerAlso, let is the preferred nomenclature for declaring locally scoped variables, from what I understand
19:43tlbakhim kinda confused right now but thank you so much
19:44zspencerIs there a language you're more familiar with I could write an alternate gist for?
19:44tlbakhdef is not used for what my purpose as far as i understand
19:44tlbakhjava c++ python
19:44tlbakhim just a newbie for fp
19:45zspencerMe too :). Let me take a stab at this in python and link you to it
19:45zspencerI'm not a python guru though
19:45justin_smithdef always adds a binding to a namespace, so using it inside a function is usually wrong
19:45justin_smithit does not create any function-local binding
19:45tlbakhthat makes sens
19:45tlbakhsense*
19:45tlbakhthank you
19:45SegFaultAXtlbakh: Think of it like this: l = [1,2,3]; [n + 1 for n in l]
19:45tlbakhzspencer, thank you really appreciated
19:46SegFaultAXtlbakh: There is no reason that would modify the original value.
19:46SegFaultAXIt just produces a new list.
19:46tlbakhSegFaultAX, what if i call it with let?
19:47SegFaultAX,(let [n [1 2 3] n (map inc n)] n)
19:47clojurebot(2 3 4)
19:47SegFaultAXtlbakh: Let is recursive.
19:47justin_smithyou can capture the binding with let
19:47SegFaultAX(In other words you can access previous bindings in the same let form)
19:47SegFaultAXOr even re-bind them, as above.
19:48SegFaultAXtlbakh: Mind you def and let really have nothing to do with eachother.
19:49SegFaultAXlet introduces a local name for a value, def creates a var in the top-level of the current namespace.
19:49justin_smiththe commonality is they create bindings from symbols in the code to values
19:49tlbakhoke so let is the right way to local binding
19:49tlbakhi get it
19:49nightflyyes
19:52tlbakhnow i got it worked =)
19:52tlbakhthank you guys
19:53tlbakhfrom the point i stand, i have to learn a lot of stuff. whats the best road map that i should follow? any recommendations?
19:53zspencertlbakh: https://gist.github.com/zspencer/9476808
19:53justin_smithclojure koans and 4clojure are helpful (but not sufficient)
19:54tlbakhim working on 4clojure , its helpful but not enough for a noob
19:54justin_smithhttp://clojure.org/cheatsheet is good to refer to (even though it points to out of date docs, the functions are still useful in newer versions)
19:54zspencerYea, 4clojure was too hard for me :/
19:55SegFaultAXzspencer: Ehhh, map really isn't idiomatic Python so it's probably less useful in examples. Pythonistas tend to prefer comprehensions.
19:55zspencerI get to pair everyday with clojure programmers, so that was nice
19:55zspenceryea, the idiomatic is more clojure centered :) I don't know python well
19:55SegFaultAXzspencer: [x + 1 for x in [1,2,3]]
19:57rasmusto,(reduce #(%2 %1) [[1 2 3] inc])
19:57clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number>
19:58rasmusto,(reduce #(%2 %1) [[1 2 3] #(map inc %)]) ; my bad
19:58clojurebot(2 3 4)
19:58zspencerSegFaultAX: list comprehensions don't seem to mutate state
19:58SegFaultAXzspencer: They don't, that's the point.
19:58SegFaultAXAnd neither should map.
19:58zspencerConcur
20:01zoldarI'm playing around with core.async and I wanted to make a channel through which I could send messages to multiple receivers (every message is directed at a particular receiver). I've come up with this: https://www.refheap.com/56170 - is that the right way to accomplish this?
20:01turbofaildon't mutate? lulz. a = [lambda: x for x in range(10)]; a[0]() => 9
20:02turbofailat least in python 2.7.3
20:02zspencerLammmbbbdddaaaaaaaaassssss
20:03SegFaultAXturbofail: That isn't mutation, that's a capturing problem.
20:03amalloyyeah, exactly. java "solves" that problem by making you promise not to change x before it lets you close over it
20:03SegFaultAXYup, finals all the way down.
20:03turbofailwell because of its capturing problem it mutates
20:04SegFaultAXturbofail: Impure, sure. But mutating?
20:04turbofailhow is that not mutating?
20:05turbofailit's mutating x
20:05turbofailit has the exact same symptoms that altering a mutable data structure would
20:05SegFaultAXturbofail: Because the mutation is not a side effect of the lambda itself.
20:05rasmusto,(let [a 4 a 5] a) ; is mutating?
20:05clojurebot5
20:06SegFaultAXThe mutation is external to the lambda.
20:06turbofailsure, the list comprehension is mutating state, not the lambda
20:06SegFaultAXWhich is what amalloy was saying: you have to promise to java this reference you gave it won't mutate before you can close over it.
20:06SegFaultAXturbofail: I didn't say you couldn't mutate state with listcomps or map, just that you shouldn't.
20:07SegFaultAXturbofail: Nothing it stopping you from using impure functions (in Python or Clojure), but why would you want to?
20:07turbofailall i'm saying is that something that looks like it should be pure isn't
20:08dsrxwhat's that, a list comprehension can't mutate state?
20:08SegFaultAXdsrx: s/can't/shouldn't/
20:08dsrx:p
20:08turbofailwell specifically you said they "don't" mutate state
20:08turbofailand it looks like they don't, until they do
20:10SegFaultAXturbofail: Fair enough. But then Python is almost entirely imperative.
20:10SegFaultAXturbofail: But "don't capture loop state" is a pretty common thing in lots of languages.
20:11gfrederickswould it be haxy to make a (def-record-ns IFoo IBar) that implements all the protocols by calling identically named functions in the namespace?
20:11gfredericksto avoid doing all the code inlined in a defrecord form
20:12turbofailSegFaultAX: sure. but list comprehensions look like they're functional, which is why i find that particularly egregious
20:14SegFaultAXturbofail: Yea :(. I have fallen entirely out of love with Python, even though I write it everyday (professionally)
20:14amalloygfredericks: that would probably be okay, although it doesn't sound *super* easy - you have to inspect the protocols (or interfaces!) to figure out what method bodies to emit
20:23mr-foobarIn om, what's the best place to put ajax call for initial data of a component ?
20:31zoldarmr-foobar: IWillMount / will-mount , probably
20:33gfredericksamalloy: right
20:36mr-foobarzoldar: I can fire the ajax in IWillMount, but how do I check if the ajax call has returned ?
20:37seangrovemr-foobar: You can use a core.async channel for it
20:38mr-foobarseangrove: I want to render the component with the data. Without the data, I'd like to show zilch.
20:39seangrovemr-foobar: (will-mount [_] (let [finish-ch (chan)] (ajax-call ... finish-ch) (go (let [res (<! finish-ch)] (om/set-state! owner :result red)))))...(render [_] (when-let [res (om/get-state owner :result)] (dom/div ...)))
20:40seangroveAmongst another dozen ways, I sure. That's a QND way though
20:41seangroveI would do the ajax calls elsewhere, but if you have to do it in the component, then there you go
20:41mr-foobarseangrove: sounds right. thx !
20:51danielszmulewiczgf3: ping
20:51gf3holla
20:52danielszmulewiczgf3: Hi, I was looking for any-matches? in secretary but couldn't find it anymore...
20:52gf3danielszmulewicz: It's all been changed
20:52danielszmulewiczgf3: :-)
20:52gf3danielszmulewicz: The new secretary is much more powerful and robust
20:52gf3Mostly thanks to noprompt
20:52danielszmulewiczgf3: that's nice to hear
20:53danielszmulewiczgf3: how do I acheive any-matches? though?
20:53gf3danielszmulewicz: You should be able to use `locate-route`
20:53gf3danielszmulewicz: https://github.com/gf3/secretary/blob/master/src/secretary/core.cljs#L181-L186
20:53danielszmulewiczgf3: ah so that's what I'm looking for. Thanks a bunch.
20:54gf3oops, it's not exported though
20:54danielszmulewiczgf3: private function :-)
20:54gf3danielszmulewicz: We can see about opening it up, though
20:54gf3danielszmulewicz: What's the use-case, if you don't mind me asking?
20:56danielszmulewiczgf3: sure, I have a go loop that listens for uris. If it's a real URI, fetch it with XHR, if it's a route, dispatch with secretary. That's my use case. You got a solution.
20:56danielszmulewicz?
20:58danielszmulewiczgf3: https://www.refheap.com/56178
20:58gf3danielszmulewicz: Ahh cool
20:59gf3danielszmulewicz: This might even be a good use-case for this → https://github.com/gf3/secretary/issues/21
21:00stcredzeroIs clojure.java.jdbc db-do-commands vulnerable to SQL injection?
21:00danielszmulewiczgf3: Yes, but the API should have a simple boolean check for routes if you don't mind my opinion :-)
21:01gf3danielszmulewicz: I agree
21:01danielszmulewiczgf3: cool.
21:01gf3danielszmulewicz: For now it should be possible to simulate `locate-routes` as the route atom is accessible → https://github.com/gf3/secretary/blob/master/src/secretary/core.cljs#L158-L159
21:02gf3danielszmulewicz: Can you open an issue to make that fn public, and I'll triage it?
21:02danielszmulewiczgf3: sure
21:02danielszmulewiczgf3: thanks.
21:03gf3danielszmulewicz: No, thank you!
21:15seangrove$seen noprompt
21:15lazybotnoprompt was last seen quitting 7 hours and 38 minutes ago.
21:35gfrederickswhat causes clojure.repl to be use'd when I run `lein repl`?
21:55akurilin2So I'm looking at http kit here trying to figure out the idea behind async http connections. Why do I want that?
21:56akurilin2Is the idea that I'm not keeping a connection open while handling the request?
21:56noonianakurilin2: you are keeping a connection open in the case of something like a websocket, but you don't have to have 1 thread per connection is the idea
21:57akurilin2So the difference is that you're not having a 1 to 1 thread to connection mapping?
21:57noonianyou can serve multiple long running connections from a single thread
21:57noonianright
21:57akurilin2Does jetty do thread pooling of any sort?
21:58akurilin2I've been oblivious to this eveer since I started using it.
21:59akurilin2Not sure if there's a thread pool, but there's a default cap of 50 threads per ring app if you use the adapter
21:59noonianit uses a thread pool i think, so whenever a connection it comes in it grabs a thread to handle it from the thread pool
22:03mlb-How popular is the clojure library incanter?
22:03mlb-I'm playing about with R, but it's been a while and it seems most things with R have moved to ggplot2
22:04akhudekmlb-: R has a huge ecosystem and plotting is only a small part of it
22:05noonianbut if you want something like R thats Clojure, you'd use incanter
22:07mlb-akhudek: R's huge ecosystem is somewhat part of the issue for me ;] It's hard to identify what parts of said ecosystem are still maintained and are compatible. The situation gives me perl-like feelings
22:08akhudekmlb-: well, unlike perl, R is still popular, isn't it? In that sense, incanter is much less mature and has much less out of the box. Not sure how big it's user base is, but it's no where close to Rs, that's for sure. I use it from time to time for the odd bit of statistics.
22:11mlb-akhudek: Actually, I honestly don't know. That said, popularity can be subjective. Do you know where I might find a sizable R community?
22:13akhudekmlb-: probably the mailing lists?
22:17mlb-akhudek: hmm, I'll check those out. Thanks!
22:18michel_slmmlb-: there's Stack Overflow too, the R tag is quite active
22:26bufferlossso I'm running a basic empty/test project (almost empty except for a single postgres query throuhgh clojure.java.jdbc) and when I assign the results of the query to a var using (def rs (clojure.java.jdbc/query "")) then println works as expected, if instead I use for example (let [rs (query...)]) I get an error that rs is not within that scope, but both the println and the let are in the same defn and I though that let just create variable
22:26bufferlosss within the local scope
22:26bufferlosswhat am I missing?
22:26bufferlossI've gotten through about the first 3rd of this http://java.ociweb.com/mark/clojure/article.html
22:26bufferloss(the first, left hand column in the table of contents)
22:27bufferlossmaybe my understanding of let is incorrect
22:27dsrxbufferloss:
22:28dsrx,(let [x 32] (+ x 10))
22:28clojurebot42
22:28dsrx,((fn [] (let [x 32]) (+ x 10)))
22:28clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)>
22:29bufferlossoh, I see, so it creates its own scope
22:29bufferlossand you have to use x within the let block, right?
22:29noonianyep
22:29bufferlossaight cool thx, didn't catch that
22:29bufferloss,(+ 1 2)
22:29clojurebot3
22:31bufferloss,((defn hello (+ 1 2) (def x 4)) hello)
22:31clojurebot#<CompilerException java.lang.IllegalArgumentException: Parameter declaration + should be a vector, compiling:(NO_SOURCE_PATH:0:0)>
22:31bufferloss,((defn hello [& args] (+ 1 2) (def x 4)) hello)
22:31clojurebot#'sandbox/x
22:32bufferloss,((defn hello [& args] (+ 1 2) (def x 4)) x)
22:32clojurebot#'sandbox/x
22:32bufferlossis a symbol defined within a function using (def ...) accessible outside the function?
22:32bufferloss(I am guessing/hoping no)
22:32hiredmanyes
22:32hiredmanclojure is not like scheme
22:33bufferlossI don't know scheme
22:33hiredmandef/defn always creat/definee a global var
22:33bufferlossso how do I define a variable local only to the scope of a function
22:33hiredmanlet
22:33hiredmanlet and fn arguments are local bindings
22:33bufferlossah, so I'd need to let all my vars and then work within that let block within the function block if I want locally scoped vars
22:34hiredmana "var" is a distinct thing, it is always global
22:34hiredmangenerally in clojure people don't talk about variables, because locals are immutable and don't vary, and globals are vars
22:34bufferlosslet all my symbols then
22:35hiredmanso the bindings of names to values created via let, and via fn application tend be called "locals"
22:35noonianthe symbols you use in a let will be bound to the value you provide in the let binding form
22:35hiredmanso you let bind locals
22:35bufferlossright, so I can't actually, strictly speaking "declare" a bunch of empty symbols with let and then define them later, right?
22:35noonianyou can bind them to nil if you want
22:36hiredmanbufferloss: correct
22:36noonianlet only takes an even number of forms so you have to give everything a value
22:36hiredmanbufferloss: but symbols is not the right word either
22:36nightflybindings
22:36noonianit binds what the symbols resolve to when they are evaluated
22:36hiredmansymbols are the datatype that happen to be used in the reader to represent names
22:36noonianyea
22:37hiredmanbut they don't have storage associated with them, (let [x 1] x) doesn't somehow stick 1 in some value slot on x
22:38hiredmansomewhere there is a thing that locally binds the name x to the value 1, a local binding
22:46akurilin2Oh man I need to write down what noonian just said, always wanted to phrase that whole symbol resolution process elegantly :)
22:50vjktmI am trying cider in emacs
22:50vjktmI can't get the error highlighting to work, i.e., I don't see the red highlight
22:50vjktmwhat should I try?
22:54bufferlossam I supposed to use * for all my local bindings? e.g. function parameters or let bindings?
22:55akurilin2What's *?
22:56hiredmanbufferloss: confusingly there is a thing in clojure called binding, which doesn't have anything to do with local bindings, but is for dynamic binding of vars, earmuffs( *foo* ) are used to indicate vars that are dynamicly bindable
22:56bufferloss,(println *clojure-version*)
22:56clojurebot{:interim true, :major 1, :minor 6, :incremental 0, :qualifier master}\n
22:56noonianthe use of asterisks is a convetion used with dynamic vars to tell you that they are dynamic
22:56bufferlossakurilin2, stuff like that as far as I know
22:56hiredmanit is just a convention to use them though
22:56bufferlossnoonian, ah ok
22:56akurilin2Yeah it's a naming convention for dynamic vars
22:56akurilin2Because they're freaky and you should avoid making your own.
23:01bocajWould anyone like to share an extract, transform, load experience with clojure? I'm sick of thick tools.
23:16seangrovestcredzero: By the way, as a osx/ios dev, do you use IB at all? Or is everything done in XCode? And do you use VFL and autolayout?
23:24bufferlossis there an equivalent to "each" aside from (doall (map...))
23:25noonian,(doseq [i (range 10)] (println i))
23:25clojurebot0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n
23:26noonian,(doseq [i (range 10)] (print i))
23:26clojurebot0123456789
23:27bufferlossnoonian, ah cool
23:27bufferlossanyone happen to know how to get the actual SQL error message out of clojure.java.jdbc if a sql error occurs?
23:28jcromartienoonian: it's also worth noting: "doall" holds onto the head and keeps the whole seq in memory, while "dorun" and "doseq" do not
23:28bob2when does 'ns-level code' run in clojure? e.g. if I put a (set-logger) statement at the top level of a file, is it executed at import-time? or does all that get run and jar load time?
23:28jcromartienoonian: i.e. use doall when you care about ALL the seq
23:28jcromartiebob2: only when it is require'd
23:29bob2cheers
23:30trptcolinbbloom: thanks again for the delimc help the other day - i'm getting close to grokking it.
23:30noonianjcromartie: but for printing out a seq you don't really care about holding onto the head right?
23:30jcromartienoonian: correct
23:31bbloomtrptcolin: np, did i explain the kernel call metaphore to you? that's my new favorite way to think about it
23:31nooniancool, it seemed like bufferloss wasn't trying to hold onto the result with his question
23:33trptcolinbbloom: no, i don't think so.
23:34bbloomtrptcolin: the idea is that all continuations are delimited SOMEWHERE and that an undelimited (or "full") continuation (ie "call-cc") is simply delimited by the top-level of the process
23:34bbloomtrptcolin: when you make a normal call in C code, you push some args on the stack and run some code, then pop back off... but that means that you and the code you call are in control. that's not acceptable for security and multiprocessing reasons when you need to make an OS system kernel call
23:35bbloomtrptcolin: so when you make a call to your OS, your C code will put the arguments in a special place (registers, etc) and then yield to the kernel
23:36trptcolinso you delimit a continuation around the system call w/ the stuff you stuck in the registers? :)
23:36trptcolini like it
23:38bbloom_trptcolin: shit. i wrote a bunch of stuff, but i got disconnected
23:38bbloom_trptcolin: https://www.refheap.com/56255 <- there
23:38trptcolinbbloom: :) yeah shift/reset are weird names. i kept thinking shift/reduce initially
23:38bbloom_yeah
23:39bbloom_i much prefer the handle/raise variant since it maps to how i already understand try/throw
23:39trptcolinbbloom_: the metaphor is interesting though
23:40trptcolinbbloom_: if you have another min, does it seem reasonable that a reset should delimit the extent of the continuation, e.g. https://github.com/swannodette/delimc/pull/11 ?
23:40trptcolin[specifically a nested one]
23:41technomancygfredericks: you know you have commit on lein, right?
23:41bbloom_trptcolin: also good: http://www.cs.indiana.edu/l/www/pub/techreports/TR615.pdf
23:42trptcolinbbloom_: i have so many tabs of this stuff open, that's in there somewhere :)
23:43technomancytrptcolin: so ... are you familiar with the sjacket api?
23:43trptcolintechnomancy: kinda sorta :)
23:43technomancyI noticed reply uses it
23:43technomancybut it doesn't actually have any docs
23:45trptcolintechnomancy: yeah basically i threw a tree-seq at the parse tree looking for unexpected or unfinished nodes: https://github.com/trptcolin/reply/blob/fff1fbc42ddc76e06cc4bd5e5d24b0f6308f24cb/src/clj/reply/parsing.clj#L5-L8
23:45trptcolinusing net.cgrand.sjacket/str-pt on an input string
23:46trptcolini haven't done any of the fancy rewriting stuff
23:49technomancyyeah... I want to do stuff like that for lein 2.4
23:49technomancybut yeah. no docs makes it tricky.
23:50charewhen you guys do something distributed with Clojure like something similar to Erlang what do you do for rpc or mesage passing?
23:51trptcolinchare: i'm suddenly seeing irony, because i often use erlang (rabbitmq) for that
23:51technomancymost people use a queue like rabbit, yeah
23:51technomancyit's only vaguely erlang-like of course
23:51charewhat? you guys use clojure with a erlang backbone messaging?
23:52technomancywell yeah, use the best tool for the job
23:52chareso use rabbitmq except when you're already using erlang?
23:53chareand also what happened to javaEE stuff, isn't there suppose to something for rpc/messaging that would make sense to use with clojure
23:53trptcolinchare: rabbit just happened to be one i've used on some projects. i know plenty of folks who use hornet, plain old http, and other stuff.
23:54trptcolintechnomancy: yeah, i struggled a bit - i was hoping to point you at the tests, but looks like i wrote most of them and they're almost all parser stuff