#clojure log - Mar 10 2014

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:44 firefaux: how 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?

0:51 tolstoy: firefaux: Maybe not what you want, but there's clojure.data/diff.

0:53 firefaux: actually

0:53 I might be able to use that

0:53 though it might not be the best way to do it

0:54 I could diff the keys

0:54 then iterate over the shared keys on both maps

0:54 and then iterate over the keys that aren't shared, using the default value

0:54 TravisD: firefaux: this isn't particularly elegant, but it works: https://www.refheap.com/55476

0:55 firefaux: hmm

0:55 TravisD: it 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

0:55 then maps that function over the maps.

0:55 lol

0:56 firefaux: that's quite a bit of work

0:56 TravisD: (add-missing-keys :missing {:one 1} {:two 2}) ; => ({:one 1, :two :missing} {:one :missing, :two 2})

0:56 yeah, there is likely a cleaner solution

0:56 conceptually this is a clean solution, though

0:56 firefaux: well, efficiency isn't a big concern of mine at this point

0:57 as long as it takes nice inputs and gives nice outputs, I'm happy

0:58 taking [default & maps] is pretty much perfect

0:58 and returning a seq of maps is also perfect

1:04 ddellacosta: hmm, is there a way to auto run tests w/cljsbuild?

1:05 I thought I'd done it in the past but can't figure it out now

1:06 TravisD: firefaux: I like this implementation more than the last one: https://www.refheap.com/55501

1:07 or even https://www.refheap.com/55504

1:08 firefaux: what makes them better? the fact that they use --> ?

1:08 lol

1:09 TravisD: Yeah, this seems easier to read to me

1:09 firefaux: is it doing anything differently, though?

1:09 TravisD: Also, I like that they use merge, instead of another function

1:09 firefaux: (doc merge)

1:09 clojurebot: "([& 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."

1:10 firefaux: ah, that's smart

1:10 TravisD: I guess it's what merge is for :)

1:11 firefaux: ok, this does make more sense

1:11 TravisD: It makes a dictionary that maps all present keys to the default value, and then merges that with every map you provide

1:12 firefaux: yeah

1:12 that's a neat way of doing it

1:12 TravisD: and now that I look at it, there's really no need for add-keys to be a named function: https://www.refheap.com/55512

1:13 firefaux: I thought about that

1:13 is there any harm in it, though?

1:13 TravisD: not really

1:13 firefaux: I kinda like it like that

1:13 makes it clear what it's doing

1:13 TravisD: hehe, to each his own

1:14 This 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

1:15 firefaux: ooh

1:15 I like it

1:16 arubin: So 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.

1:21 firefaux: is there a prepending version of conj?

1:22 andcloj: Can someone tell me why this evaluates to 3 and not 5? http://pastebin.com/fiPFfKaA

1:22 firefaux: oh, I guess I can just use cons

1:23 TravisD: firefaux: For lists, conj will add to the beginning and for vectors it adds to the end

1:23 firefaux: oh

1:23 TravisD: more generally, I think the implementation is free to choose where to add the new element based on what is the most efficient

1:23 firefaux: what about cons?

1:23 is that always guaranteed to put it at the front?

1:23 actually, of course

1:23 that's what conses are

1:23 TravisD: cons is only defined for lists, but it does the same as conj

1:24 aside from having its arguments swapped

1:24 firefaux: I can still use a vector as input to it, right?

1:24 ,(cons 2 [1 2 3])

1:24 clojurebot: (2 1 2 3)

1:24 firefaux: ok good

1:24 I don't care what kind of seq I get out

1:24 as long as it's a sequence of some sort

1:25 TravisD: ah, and what I said I think is wrong. When I was testing things out I had the arguments mixed up :)

1:29 andcloj: Why does this evaluate to 3 and not 5? code: (let [x '(+ 2 3) op (first x) args (rest x)] (apply op args))

1:35 ddellacosta: andcloj: you want

1:35 ,(let [x '(+ 2 3) op (first x) args (rest x)] (apply (resolve op) args))

1:35 clojurebot: 5

1:36 ddellacosta: andcloj: what you are doing is essentially this:

1:36 ,(apply (symbol "+") [2 3])

1:36 clojurebot: 3

1:37 ddellacosta: I'm actually not sure what that is doing.

1:37 TravisD: ddellacosta: Hmm, why doesn't that give an arrity exception, since the symbol is a function on dictionaries, expecting one argument?

1:37 er, it is not that. It is just not a function

1:37 ddellacosta: TravisD: yeah, it's a bit strange to me...

1:37 TravisD: on my machine it does give an error

1:38 but not for the original code pasted by andcloj

1:38 ddellacosta: TravisD: wat

1:39 andcloj: I get no exception.

1:40 TravisD: Ah, no, sorry. I get an error depending on the number of arguments I provide: https://www.refheap.com/55533

1:40 ddellacosta: TravisD: ah, yeah, I see that too.

1:40 andcloj: I find this to be interesting, too: (= + (resolve (symbol (first '(+))))) evaluates to false

1:41 (= + (resolve (first '(+)))) also resolves to false

1:42 pdk: ,(= '+ (resolve (first '(+)))

1:42 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

1:42 pdk: ,(= '+ (resolve (first '(+))))

1:42 clojurebot: false

1:43 andcloj: ,(= + (resolve (symbol (first '(+)))))

1:43 clojurebot: false

1:43 ddellacosta: andcloj: do you expect that to be true?

1:44 ,(= (first '(+)) '+)

1:44 clojurebot: true

1:44 ddellacosta: ,(= (resolve (first '(+))) #'+)

1:44 clojurebot: true

1:45 andcloj: ddellacost: I'm not sure what I expect, I'm new to clojure

1:45 ddellacosta: ah, okay

1:45 andcloj: :)

1:45 ddellacosta: ,+

1:45 clojurebot: #<core$_PLUS_ clojure.core$_PLUS_@1ac5f00>

1:45 ddellacosta: ,'+

1:45 clojurebot: +

1:45 ddellacosta: ,#'+

1:45 clojurebot: #'clojure.core/+

1:45 ddellacosta: ,(resolve '+)

1:45 clojurebot: #'clojure.core/+

1:45 andcloj: I very much so appreciate the help though.

1:45 ddellacosta: etc

1:45 andcloj: :-)

1:45 andcloj: Yeah so they are different things

1:47 ddellacosta: andcloj: 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

1:50 andcloj: ok thanks

1:51 ddellacost: 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

1:51 ,('x 1 2)

1:51 clojurebot: 2

1:52 andcloj: ,('+ 1 2)

1:52 clojurebot: 2

1:52 ddellacosta: andcloj: This explains what is going on there: http://stackoverflow.com/questions/12281631/what-do-clojure-symbols-do-when-used-as-functions

1:53 it's apparently the same as doing (get {:foo "foo"} :bar "bar")

1:53 ,(get {:foo "foo"} :bar "bar")

1:53 clojurebot: "bar"

1:53 ddellacosta: not the same, but analogous, I should say

1:54 andcloj: ddellacosta: this stack overflow references the same 4clojure that led me to this confusion :)

1:54 ddellacosta: andcloj: haha, there ya go, it all comes full circle. ;-)

1:56 er, more like

1:56 ,(:bar {:foo "foo"} "bar")

1:56 clojurebot: "bar"

1:56 xuser: 0

1:57 andcloj: so then is using (resolve op) a no no?

1:57 like using an eval in other languages would be?

1:57 if we had to worry about user input

1:58 I guess you could check if it's in a list of allowed symbols

2:00 ddellacosta: andcloj: 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.

2:00 andcloj: I mostly find myself using it in macros.

2:02 firefaux: damned daylight savings time

2:02 it's 2 already :\

2:02 alright, 'night everyone

2:09 dissipate: ,(and)

2:09 clojurebot: true

2:09 dissipate: ,(or)

2:09 clojurebot: nil

2:10 dissipate: ,(= (and) (or))

2:10 clojurebot: false

2:10 dissipate: ,(= (or) (or))

2:10 clojurebot: true

2:10 dissipate: ,(= (and) (or))

2:10 clojurebot: false

2:11 dissipate: anyone care to explain that ^

2:19 lazy-seq seems like python's 'yield'

2:30 Nyyx: anyone know of any clojure IDE's for android

2:35 dissipate: Nyyx, not sure about IDE but there is a repl

2:35 'Clojure REPL'

4:41 BartAdv: Nyyx: and what about Nightcode?

4:51 scottj: BartAdv: 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)

4:53 BartAdv: hah, I assumed the same, somehow I thought Nightcode can be run there

5:46 anars: I'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.

5:47 I 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?

5:51 noidi: in 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?

5:51 this has been bugging me for quite a while now :)

5:52 clgv: noidi: no big reason. I guess he wants to make clear that it is a dev time constant

5:53 and the few dev functions associated to it do not have the additional noise an atom would introduce

5:55 sm0ke: hey guys how to design multivariate macros?

5:55 ,(defmacro foo ([x y] `(prn ~x ~y)) ([x] (foo x 1)))

5:55 clojurebot: #'sandbox/foo

5:55 sm0ke: this doesnt work

5:55 ,(foo 1)

5:55 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox/foo>

5:55 sm0ke: ,(foo 1 2)

5:55 clojurebot: 1 2\n

6:00 fredyr: think about what's happening when you macro expand the macro

6:01 at compile time

6:01 sm0ke: got it

6:01 (defmacro foo ([x y] `(prn ~x ~y)) ([x] `(foo ~x 1)))

6:01 hit and trial though

6:01 ,(defmacro foo ([x y] `(prn ~x ~y)) ([x] `(foo ~x 1)))

6:01 clojurebot: #'sandbox/foo

6:01 sm0ke: ,(foo 3)

6:01 clojurebot: 3 1\n

6:02 sm0ke: makes sense though

6:06 so i have this protocol where i want to define a function `flush`

6:06 is this a good idea?

6:11 dsrx: well..

6:11 ,(doc flush)

6:11 clojurebot: "([]); Flushes the output stream that is the current value of *out*"

6:26 sm0ke: yes but i have seen people using reserved function names

6:33 cemerick: anars: ::friend/workflow is more to aid in debugging (i.e. "where did this map of credentials come from?") than anything else

6:49 zoldar: Clourescript 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

6:54 ok, got it: (aset (.-style elem) "margin-left" 0)

7:00 dsrx: zoldar: that JS property is elem.style.marginLeft

7:00 at least, if you're talking about a dom element

7:00 zoldar: dsrx: ouch, thanks

7:00 dsrx: yes, yes I do, however I suppose that in case of non-dom attributes, I would have to resort to my version

7:01 dsrx: yeah, 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

7:04 seems that elem.style["background-color"] etc also works, huh. dunno if that's standard

7:04 i've always usedthe camelized versions of css properties

7:07 zoldar: well afaik all object attributes in js are accessible through string notation, no?

7:08 dsrx: yes, 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

7:08 zoldar: ah

7:11 anars: cemerick: alright. I've written this, and it's gotten me a bit further: http://hastebin.com/xavoripise.clj

7:12 although 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.

7:12 (i.e. :roles #{})

7:13 the setup works when I'm using the bundled http-basic workflow, but I'm definately missing something here with my custom JWT workflow.

7:15 last 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.

7:16 cemerick: anars: what is the actual message provided? There's nothing in friend that should emit any mention of roles in a 403 AFAIK.

7:18 anars: cemerick: 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."

7:19 my 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}}

7:23 cemerick: anars: You must be throwing an unauthorized exception somewhere

7:25 anars: cemerick: 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

7:25 but there's nothing seemingly wrong with what I'm returning from the jwt auth handler, is there?

7:28 cemerick: anars: the empty set provided to wrap-authorize is probably the culprit

7:31 anars: cemerick: as always, I would've sworn I tried that ;) but you're perfectly right. it's working now. thanks a ton.

7:32 cemerick: anars: pull req welcome to assert that that set isn't empty

7:34 anars: cemerick: roger - will do that.

8:23 pyrtsa: What'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?

8:25 ambrosebs: pyrtsa: yes

8:26 clgv: pyrtsa: there are sometimes (rare) cases where you cant get rid of them without loosing general applicability

8:27 anars: cemerick: would you accept the usage of :pre condition map for that?

8:27 cemerick: anars: No, there should be a useful message thrown when the condition fails

8:28 anars: roger

9:39 arav93: Hi!

10:02 steerio: anyone alive? :)

10:03 jballanc: nope

10:03 ;-)

10:04 steerio: oh, carry on then.

10:04 :D

10:04 jballanc: EDT is probably sleeping off their DST hangovers

10:04 steerio: was the switch just now?

10:04 totally different in europe

10:04 jballanc: yesterday for the US

10:04 steerio: TIL :)

10:04 jballanc: heh...Europe and the rest of the "sane" world ;-)

10:05 steerio: i'm questioning the sanity of DST in general

10:05 jballanc: as a programmer, doubly true!

10:06 I once caught a DST bug only because I was up, coding at 2 AM during a DST transition

10:06 steerio: lol

10:06 always use UTC!

10:06 jballanc: indeed

10:07 steerio: anyway, check what i've just found http://pastie.org/8903501

10:07 quite interesting behaviour of seqable, i say

10:08 the klass is an excerpt of one of an actual class that does a couple of things that are irrelevant here

10:10 Anderkent: steerio: 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:11 steerio: pretty sure the contract of Sequable specifies that if it's empty it should return nil

10:11 ... but htere's no javadoc on the class so there.

10:13 steerio: Anderkent: yep, nothing in clojure.lang.Seqable

10:13 Anderkent: but it's good to know

10:13 Anderkent: steerio: 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:13 so map does (cons nil (map f nil)) -> '(nil)

10:13 steerio: Anderkent: yep that's what was confusing, that map does seq anyway

10:13 Anderkent: yeah but your thing is only valid when its seq'd twice

10:14 (seq xs) -> '() , (seq (seq xs)) -> nil

10:14 steerio: tricky

10:14 Anderkent: what you want your class to do

10:14 is RT.seq(loader.invoke())

10:15 nice repro though

10:15 (inc steerio)

10:15 lazybot: ⇒ 1

10:15 steerio: thanks for the help

10:15 clgv: steerio: I think the contract is the seq() must return nil if the collection is empty

10:17 steerio: Anderkent: repro?

10:17 Anderkent: example

10:17 steerio: oh right, thx

10:18 jjro: I 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:18 (defroutes async

10:18 (GET "/rest/v1/async" {}

10:18 (aleph/wrap-aleph-handler connect-message)))

10:20 non-websocket requests the route works, but I cannot figure out why it fails, when using websockets

10:22 steerio: Anderkent, clgv: works like a charm now, thx for making it clear about seq()

10:27 whodidthis: Can't open 'Successfully compiled "out/test.js". how to fix when trying to run cljsbuild tests

10:27 scape_: jjro: take a closer look at compojure, which I think you're using for routing

10:28 also remember that websockets get routed only once for the entirety of the connection

10:34 jjro: scape_: 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:38 scape_: use refheap or something and post your connect-message function

10:47 jjro: ok, here is the paste of all relevant parts: https://www.refheap.com/55822

10:53 jjl`_: anyone have an opinion on what's the easiest library for handling config files?

10:54 no particular format is required. it's liable to only store simple keys/values

10:56 jjro: I solved that websocket-problem. Upgrading aleph to 0.3.1, and compojure to 1.1.6 changed something, and now it works.

10:57 scape_: oh good, jjro

10:58 joegallo: jjl`: tell us more about these config files

11:00 jjl`: 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:00 steerio: jjl`: https://github.com/weavejester/environ

11:00 jjl`: may or may not be what you want

11:00 jjl`: i was just looking at that. i'm a little unclear about how the jvm resolves properties files at runtime though

11:00 steerio: you can also use java properties files

11:01 joegallo: there's also require and load-file, you could just a config ns with a bunch of defs in it...

11:01 jjl`: yeah, properties files are sufficiently structured for my purposes. environ seemed like a nice way of handling it

11:01 joegallo: or something like https://github.com/sonian/carica

11:02 jjl`: heh. i'm not configuring my app with executable code :)

11:02 joegallo: shrug

11:03 jjl`: something that parsed EDN would be okay

11:05 joegallo: you could just edn-read a file from the classpath, then http://clojure.github.io/clojure/clojure.edn-api.html#clojure.edn/read

11:12 johnnyblaze: Question: how do you escape parenthesis in a string ?

11:14 jjl`: a string of...?

11:14 johnnyblaze: trying to execute a stored procedure. args to that stored procedure are enclosed in parenths

11:15 jjl`: using what? i suspect what you actually want is a placeholder

11:16 johnnyblaze: (execute! db-spec "execute sp ('mode"))

11:16 as an example

11:16 change the last quote to a single

11:16 (execute! db-spec "execute sp ('mode'))

11:17 * jjl` uses (korma.core/exec-raw ["select stored_proc(?)" [placeholder-value]] :results)

11:17 johnnyblaze: No way to do it with just jdbc? I don't use korma.

11:18 jjl`: i'm sure there is, but i've tried to avoid using raw jdbc because i find it quite painful

11:18 but i think what you want is a placeholder in any case

11:18 koalallama: johnnyblaze: aren't you missing a close double-quote?

11:19 johnnyblaze: yeah I am. (execute! db-spec "execute sp ('mode")")

11:19 err (execute! db-spec "execute sp ('mode')")

11:19 sorry coffee hasn't kicked in yet... apparently

12:04 TravisD: So 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:05 bbloom: (doc +)

12:05 clojurebot: "([] [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:05 bbloom: TravisD: note the variadic signatures

12:05 + is a monoid

12:05 http://mathworld.wolfram.com/Monoid.html

12:05 TravisD: bbloom: I don't think that's what going on. (apply '+ [2 3]) evaluates to 2

12:05 bbloom: (doc *) ;; multiplication too

12:05 clojurebot: "([] [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:06 bbloom: TravisD: oh, duh, overlooked that. symbols are functions like keywords are functions

12:06 TravisD: and, why doesn't the 3-argument apply return

12:06 bbloom: ,('x {'x 5})

12:06 clojurebot: 5

12:06 TravisD: Ah, okay, and what do the functions do?

12:06 bbloom: ,('y {'x 5} 10)

12:06 clojurebot: 10

12:06 bbloom: ,('y {'x 5} 10 15)

12:06 TravisD: namespace resolution or something?

12:06 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: Symbol>

12:06 hyPiRion: TravisD: they are like keywords

12:07 ,(map 'foo '[{foo :bar} {foo :zap}])

12:07 clojurebot: (:bar :zap)

12:07 TravisD: hyPiRion: Right, so keywords look themselves up in maps. But what do symbols do?

12:07 bbloom: ('sym associative) is similar to (get associative 'sym)

12:07 hyPiRion: TravisD: exactly the same thing

12:07 TravisD: Ah, cool

12:07 and why can they take two arguments instead of one?

12:07 bbloom: (doc get)

12:07 clojurebot: "([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."

12:07 rasmusto: ,(map 'foo '[{foo :bar} {bif :bof}])

12:07 clojurebot: (:bar nil)

12:07 bbloom: similar to the second signature

12:07 TravisD: Ah, very neat. Thanks a lot

12:07 hyPiRion: TravisD: For the same reason keywords can, as a fallback if no value exists

12:07 TravisD: Yeah, I didn't realize that was an option

12:10 clgv: ,({:a 1} :b :c)

12:10 clojurebot: :c

12:11 TravisD: ,(:b {:a 1} :c!)

12:11 clojurebot: :c!

12:11 clgv: you build riddles by mixing those frequently in the same source ;)

12:12 TravisD: Hehe, unpleasant riddles

12:13 hyPiRion: (apply map list ...) is also a fun riddle

12:13 HOFing, how does it work

12:14 rasmusto: ,(apply map list [[1 2 3] [4 5 6] [7 8 9]])

12:14 clojurebot: ((1 4 7) (2 5 8) (3 6 9))

12:14 rasmusto: :)

12:14 TravisD: It be the transpose!

12:14 sm0ke: anyone else having problem with maven repositories today?

12:15 rasmusto: ,(apply (comp (partial reduce +) (partial map list) [[1 2 3] [4 5 6] [7 8 9]])

12:15 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

12:15 rasmusto: ,(apply (comp (partial reduce +) (partial map list)) [[1 2 3] [4 5 6] [7 8 9]])

12:15 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Number>

12:15 rasmusto: aw :(

12:15 ,(apply (comp (partial apply reduce +) (partial map list)) [[1 2 3] [4 5 6] [7 8 9]]) ; oh man

12:16 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core/reduce>

12:16 rasmusto: ,(apply (comp (partial map #(apply reduce + %)) (partial map list)) [[1 2 3] [4 5 6] [7 8 9]]) ; oh man

12:16 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core/reduce>

12:16 TravisD: :(

12:16 rasmusto: ok I give up. use a list comprehension

12:16 TravisD: Poor clojurebot

12:17 rasmusto: oh whoops, forgot to eat breakfast. brb

12:19 justin_smith: rasmusto: you do know you can /msg clojurebot right?

12:19 rasmusto: justin_smith: k. sorry about the spam

12:20 justin_smith: np

12:21 it'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:21 rasmusto: gotcha

12:24 food is kicking in ##(apply (comp (partial map #(apply + %)) (partial map list)) [[1 2 3] [4 5 6] [7 8 9]])

12:24 lazybot: ⇒ (12 15 18)

12:28 mindbender1: ,(seq? [4 1 9])

12:28 clojurebot: false

12:29 mindbender1: ,(sequential? [4 1 9])

12:29 clojurebot: true

12:33 justin_smith: ,(sequential? "hello")

12:33 clojurebot: false

12:34 mindbender1: ,(more [4 1 9])

12:34 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: more in this context, compiling:(NO_SOURCE_PATH:0:0)>

12:36 mindbender1: why doesn't PersistentVector qualify as ISeq?

12:37 ISeq interface demands first() next() more() cons()

12:37 justin_smith: mindbender1: were you looking for "rest" instead of more?

12:38 ,(.more (cons 1 ()))

12:38 clojurebot: ()

12:38 mindbender1: justin_smith: no, I was wondering why my test for seq? on PersistentVector fail

12:38 justin_smith: it isn't more, it's .more

12:38 yedi: anyone in boston wanna do a clojure thing for this: http://grandhackfest.wordpress.com/

12:39 justin_smith: mindbender1: 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:40 ,(.pop [0 1 2])

12:41 clojurebot: [0 1]

12:41 justin_smith: ,(.first '(0 1 2))

12:41 clojurebot: 0

12:41 mindbender1: justin_smith: is there any reason why PersistentVector was not tagged as implementing ISeq?

12:42 since the .first works on it

12:42 justin_smith: because iseq is for things that conj at the front

12:42 ,(.first [0 1 2])

12:42 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: first for class clojure.lang.PersistentVector>

12:42 justin_smith: no it doesn't

12:42 mindbender1: ok

12:42 justin_smith: seq is useful here

12:42 mindbender1: justin_smith: thanks

12:42 stompyj: How are people deploying their webapps? I'm kinda torn on just sticking with heroku v. jetty v. nginx-clojure module

12:43 mindbender1: yeah

12:43 justin_smith: ,(.first (seq [0 1 2]))

12:43 clojurebot: 0

12:43 mindbender1: got it

12:44 justin_smith: stompyj: my latest fave is http-kit standalone (uberjar run with java -jar) with whatever in front of it (nginx in my case)

12:44 stompyj: heroku is annoying because you can get discrepencies between their version of lein and your own

12:44 (among other reasons)

12:44 stompyj: justin_smith: yeah, there's a host of reasons I want to leave herokuu

12:45 great for development, but too $$$ for production

12:45 justin_smith: and also I don't think git or lein should be running on the web server, personally

12:45 stompyj: esp. if you know how to roll your own

12:45 technomancy: justin_smith: does setting :min-lein-version help?

12:45 justin_smith: technomancy: not sure - haven't tried it

12:45 frankly it was my coworker patchwork who was mainly dealing with these issues

12:45 stompyj: I'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:46 technomancy: yeah, :min-lein-version fixed it for me

12:46 technomancy: justin_smith: we don't actually recommend leaving lein around in production any more fwiw

12:46 justin_smith: right, I agree with that :)

12:47 I was more listing my heroku annoyances

12:47 technomancy: keep it coming =)

12:47 stompyj: technomancy: you mean lein on the box at all? or running lein as the executable to launch the production process?

12:48 technomancy: stompyj: 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:49 stompyj: this happens for you if you deploy using an uberjar

12:49 stompyj: ahhh ok

12:49 what do you guys use as your http server?

12:49 or 'front-end' server

12:49 or however you want to call it

12:50 technomancy: we 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:50 stompyj: hahahahah

12:50 thats probably overkill for my liberator based data api

12:50 ;)

12:50 that awesome tho

12:51 technomancy: yeah it's not like there are any off the shelf solutions that would work in a situation like that

12:51 stompyj: cool 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:51 technomancy: oh wow, nice.

12:52 yeah unfortunately the http server isn't oss yet, but the erlang codebase I'm working on is.

12:52 stompyj: Yeesh, I meant mid-2000s.

12:52 wow, sweet. you're working on riak right?

12:53 technomancy: I was going to say, you couldn't even get erlang outside ericsson in the mid nineties iirc

12:53 no, https://github.com/heroku/logplex

12:55 stompyj: haha yeah, it just *felt* like the 90s

12:55 hahaah

12:55 pre iPhone pre android

12:55 wink: technomancy: wait, heroku does not do "lein run" in a tmux? :)

12:55 technomancy: hehe

12:55 wink: we all do it!

12:57 technomancy: let it crash

13:15 ghaz: quit

13:31 jballanc: huh...would've expected clojurebot to have something snarky to say to that...

13:33 rasmusto: ~quit

13:33 clojurebot: rasmusto: We'll never let you leave.

13:34 TimMc: jballanc: It didn't come up on the dice this time.

13:35 jballanc: clojurebot's off his game, it seems

13:35 clojurebot, pull yourself together

13:35 clojurebot: I don't understand.

13:35 jballanc: yeah, that's what I thought

13:51 TimMc: clojurebot is not so much a Chinese Room as a _____

13:51 Someone fill in the blank, I can't come up with anything really funny.

13:52 turbofail: maltese falcon?

13:53 hiredman: ~clojurebot

13:53 clojurebot: clojurebot is a time-capsule for snark

13:53 hiredman: that'll do

13:55 amalloy: (inc clojurebot)

13:55 lazybot: ⇒ 34

13:55 Raynes: (inc amalloybot)

13:55 lazybot: ⇒ 1

14:01 steerio: amalloybot: what's this (inc nickname) thing?

14:01 -bot

14:01 stupid tab

14:03 seangrove: (inc amalloybot)

14:03 lazybot: ⇒ 2

14:03 koalallama: Raynes: ran across your irclj library the other day. very nice

14:04 pdk: irclj is truly a national treasure

14:08 justin_smith: regarding 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:09 I wonder how hard it would be to have a JVM that is directly hosted as a VM instance

14:09 (next question: would it actually be any benefit)

14:10 pdk: with 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:10 justin_smith: if you use them, yeah

14:10 pdk: then again i guess you could just implement the parts of an os you want on top of a really simple vm

14:11 justin_smith: also 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:11 it would get trickier for anything that absolutely needed to run within the same box

14:16 amalloybot: steerio: it's just this channel's quaint way of thanking someone. and the bot keeps track of how often someone's been thanked

14:16 regrettably, amalloybot's circuits are not advanced enough to keep track of that, so we have to use lazybot

14:17 Raynes: koalallama, pdk: Heh, happy you guys like it. <3

14:20 amalloybot: also the network latency to amalloybot is unacceptable. sometimes it takes up to eight hours to get a response!

14:21 Raynes: Packets sent by carrier pigeon.

14:21 rasmusto: fancy merge-with: https://www.refheap.com/55878 thoughts?

14:22 (both on impl and utility)

14:24 amalloybot: rasmusto: the first apply-merge step seems silly

14:24 just use a default merge-fn of (fn [a b] b)

14:24 and otherwise look it up in the merge-fn-map

14:25 Raynes: There's a lot of merging happening in that code.

14:25 rasmusto: amalloybot: ah, okay. Does the list comprehension make sense? or could I do "merge-fn-map" more generically

14:25 justin_smith: amalloybot: thing is, he needs a step that merges together all the unmerged keys

14:26 the ones that only appear in one map I mean

14:26 arrdem: rasmusto: that's pretty slick

14:26 amalloybot: yeah, 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:27 rasmusto: ah, yeah.

14:27 would it help to dissoc the specified keys from the (apply merge maps) step?

14:28 AmnesiousFunes: rasmusto: I think you could work out a version with a more enjoyable implementation, but the functionality is very neat

14:29 rasmusto: alright. I'll tweak it to make it more readable/efficient

14:29 amalloybot: rasmusto: https://www.refheap.com/55881 is how i'd write it. yours is more readable :P

14:31 rasmusto: amalloybot: reduce works because it's assumed to go left-to-right?

14:32 amalloybot: incidentally, you don't test for what happens if a key needs to be merged that you don't specify a function for

14:32 justin_smith: amalloybot: he reduces across the function keys

14:32 amalloybot: "assumed"? reduce is defined to operate on sequences in order

14:32 justin_smith: that's what the apply merge is for

14:33 amalloybot: justin_smith: i can see his implementation. i meant his test case at the bottom

14:33 justin_smith: OK, now I get it

14:35 https://www.refheap.com/55883

14:36 amalloybot: (merge x (into {} foo)) is (into x foo), by the way, rasmusto

14:38 sdegutis: amalloy is a bot now? How long was I gone!?

14:39 amalloybot: sdegutis: it was only a matter of time before my tendency to rewrite people's functions in shorter or faster ways became automated

14:39 zspencer: isn't that just clojure.core/assimilate

14:39 bbloom: amalloybot: your services are automated now!? is there a vim plugin?

14:40 sdegutis: M-x insert-emacs-joke-here

14:40 Raynes: I'll write his Vim integration. All it has to do is prompt you to install Emacs.

14:40 amalloybot: sdegutis: vim is just a very long-term emacs joke

14:40 sdegutis: Bah-dum tshh!

14:40 zspencer: because no one knows how to :q! it?

14:40 arrdem: zspencer: haha

14:41 chouser: I use evil in emacs, demonstrating that emacs is just a really complicated vim implementation.

14:41 amalloybot: zspencer: amusingly, i've bound C-x C-c to (lambda () (message "Why would you ever leave?"))

14:41 technomancy: chouser: two vim implementations, technically

14:41 amalloybot: is it only two?

14:41 technomancy: amalloybot: two built-in

14:41 amalloybot: ah

14:42 technomancy: oh my bad

14:42 evil isn't built in

14:42 * bbloom did not intend this

14:42 amalloybot: bbloom: you mentioned an editor

14:42 technomancy: it's two built-in IRC clients

14:42 amalloybot: this is a programming-language channel. it's inevitable

14:42 bbloom: amalloybot: i just wanted my functions to be shorter and faster :-P

14:42 chouser: viper is does not implement vim, it tries to implement vi. But nobody wants to use vi

14:42 amalloybot: *chuckle*

14:42 InvidFlower: Hey, 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:43 sdegutis: I was hoping to rewrite emacs in a JavaScript VM on top of ObjC the other day. Got pretty far actually.

14:43 amalloybot: InvidFlower: lambda

14:43 sdegutis: (And by "emacs" I meant a <textarea> linked to a file.)

14:43 chouser: InvidFlower: #(apply do-thing 1 % 5 %&)

14:43 amalloybot: sdegutis: ymacs?

14:43 sdegutis: I guess that's LightTable though...

14:44 amalloybot: nah, ibdknox doesn't want to implement emacs

14:44 InvidFlower: amalloybot, chouser: Yeah I was thinking of that, though I didn't realize the %& syntax..

14:44 sdegutis: amalloybot: well, it's in the spirit of emacs

14:45 amalloybot: InvidFlower: 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:46 sdegutis: amalloybot: ymacs looks neat, if limited

14:47 amalloy: i'm tired of being a bot already

14:47 koalallama: you were the smartest bot I had ever seen

14:47 amalloy: vim integration sounded like too much work

14:49 InvidFlower: amalloybot: 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:51 Errr… I mean (select table (#(apply fields % field-names)))

15:07 aka: is there an idiomatic way to grab a single random value from a map?

15:08 I don't need truely random here... just randomish.

15:09 pyrtsa: aka: I think your best option is to keep (vec (keys m)) at hand, and call (m (rand-nth ks)) with it.

15:09 justin_smith: (rand-nth (vals {:a 0 :b 1}))

15:09 ,(rand-nth (vals {:a 0 :b 1}))

15:09 clojurebot: 1

15:10 aka: thanks for the suggestion

15:10 * aka uses it

15:10 justin_smith: of course if you knew the keys ahead of time you could do ((rand-nth ks) m)

15:11 but that depends on your implementation

15:11 well no, that only works with keyword / symbol keys, better pyrtsa's version in the case where you know the keys ahead of time

15:11 aka: I will have them ahead of time

15:12 justin_smith: yeah, (m (rand-nth ks)) in that case

15:12 as pyrtsa suggested

15:12 aka: sweet, thanks

15:12 justin_smith: pyrtsa: any particular reason to want ks to be a vector?

15:13 pyrtsa: One 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:13 justin_smith: is rand-nth faster on a vec?

15:13 pyrtsa: justin_smith: That. ^ :)

15:13 justin_smith: ahh

15:15 hyPiRion: rand-nth is constant time for vecs

15:15 justin_smith: cool, TIL

15:15 hyPiRion: afaik it uses nth to lookup

15:15 pyrtsa: hyPiRion: Exactly.

15:16 justin_smith: hmm, if only rand-nth worked on maps

15:16 that 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:16 pyrtsa: justin_smith: Maps in general don't implement a mechanism for jumping to the nth element.

15:16 shep-werk: but, wouldn't converting it to a vector also be O(N)? thus you only save if you do it multiple times?

15:17 pyrtsa: shep-werk: Yes.

15:18 amalloy: justin_smith: hash maps don't really keep the information you'd need to do a uniformly-random selection, i think

15:18 justin_smith: oh, OK

15:18 pyrtsa: What amalloy said.

15:18 amalloy: the 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:19 shep-werk: well, aka did say "random-ish" and maps arent sorted... so just use `first` :-)

15:19 (def rand-int 4)

15:19 justin_smith: yeah, and you need a full tree walk for that, so you may as well put the vals in a vec at that point

15:19 amalloy: justin_smith: well, a hash-map *could* manage enough information so that you could do rand-nth without a tree walk

15:20 justin_smith: right, just not the current clojure default {} impl

15:20 amalloy: but that would be a lot of wasted effort for the vast majority of time when nobody wants to select at random

15:22 chouser: Now with a sorted map and a carefully constructed object passed to subseq...

15:23 Pate_: where is .emacs on Windows? I can't find it in ~/.emacs (there is no .emacs in ~)

15:23 justin_smith: Pate_: is there a .emacs.d ?

15:23 Pate_: justin_smith: nope :\

15:24 justin_smith: I don't think .emacs is even considered the "right thing" any more

15:24 have you made any customizations?

15:24 turbofail: Pate_: if it's not there you can create it

15:24 Pate_: could it be somewhere else?

15:25 turbofail: doubt it. it won't exist by default

15:25 especially not on windows

15:25 justin_smith: "~/.emacs.d/init.el" is the current recommended place for config I think

15:26 hyPiRion: yeah

15:27 justin_smith: that'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:27 Pate_: ~ should be C:\Users\<my-user>\ on Windows, right?

15:27 clojurebot: Excuse me?

15:27 Pate_: ~ test if cbot answers

15:27 clojurebot: Huh?

15:27 justin_smith: ~ should equal $HOME

15:27 Pate_: hmmm

15:27 clojurebot: It's greek to me.

15:27 Pate_: ~ google test

15:27 clojurebot: First, out of 280000000 results is:

15:27 Speedtest.net by Ookla - The Global Broadband Speed Test

15:27 http://www.speedtest.net/

15:27 Pate_: cool :)

15:27 justin_smith: $HOME exists on win

15:28 Pate_: there is no $HOME, but there is $HOMEPATH, which is at /Users/myuser

15:29 justin_smith: ahh, I guess the canonical thing on win is %USERPROFILE%

15:36 Pate_: justin_smith, I can echo $HOME and get c:/users/myuser

15:37 should I create a .emacs.d folder there?

15:37 justin_smith: yeah, and a file called init.el in that

15:37 and emacs will pick it up

15:37 bbl; lunch

15:37 gfredericks: why is autopromotion slower than overflow detection?

15:42 hyPiRion: gfredericks: I guess it's because there are alu flags for overflow detection?

15:43 I mean, it's probably faster to do a short `jo throw_overflow_exception` in machine code

16:19 edw: My 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:21 rasmusto: amalloy: thanks

16:22 AeroNotix: edw: I occasionally do

16:22 Too busy to look into ti

16:22 it

16:23 edw: AeroNotix: I'd be too busy to look into it too, if it weren't hanging all the time. :P

16:23 AeroNotix: haha

16:24 technomancy: using auto-complete.el or built-in completion?

16:25 edw: Built in, though it was happening when I was using auto-complete and then disabled while troubleshooting.

16:26 technomancy: 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:28 Profpatsch: So 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:28 In Python I’d throw an exception.

16:29 I could do this in Clojure, too, but there has to be a better way.

16:29 amalloy: return nil

16:29 Profpatsch: We’re back to that?

16:29 technomancy: there is a superior way, but it's not the clojure way

16:29 Profpatsch: I thought returning a null pointer was a very bad idea.

16:29 amalloy: yeah, that's about right, technomancy

16:30 Profpatsch: What would be the superior way?

16:30 amalloy: Profpatsch: 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:31 technomancy: Profpatsch: returning [:not-found] | [:ok value] while making the assumption the caller will be pattern matching against the return value

16:31 or throwing an exception

16:31 shep-werk: or a Maybe ;-)

16:31 * shep-werk pokes the Haskell hornet nest

16:32 technomancy: shep-werk: ^ actually is effectively a dynamic Maybe

16:32 Profpatsch: So [:not-found] is not the Clojure way?

16:33 technomancy: Profpatsch: that approach is pretty terrible without pervasive pattern matching

16:33 shep-werk: technomancy: in that case, are you advocating something like core.match? Or somethign more manual?

16:33 chouser: Another potentially nicer way is a condition system like Common Lisp.

16:33 technomancy: shep-werk: I'm saying it's not idiomatic clojure, so I'm not advocating anything =)

16:33 shep-werk: Profpatsch: I'd expect nil, with the optional argument like `get`

16:34 technomancy: haven't used the new actually-working version of core.match yet

16:34 shep-werk: technomancy: oh, it's certainly not idiomatic, but I was hoping you'd tell me how awesome (or not) core.match was ;-)

16:34 rasmusto: technomancy: actually-working?

16:35 technomancy: shep-werk: I can strongly advise against using old versions of core.match; that's all

16:35 rasmusto: old core.match blows up if you use it with AOT

16:35 amalloy: for an even more awful dynamic-maybe: (get-token stream (fn ([] ...no-token...) ([token] ...))

16:35 dnolen_: rasmusto: old versions of core.match had problems with AOT

16:35 rasmusto: dnolen_, technomancy: ah, okay :)

16:36 turbofail: hooray, manual CPS transforms

16:36 amalloy: turbofail: well, it's not really CPS because of the arity stuff

16:36 i'd say it's more like hijacking the arity dispatcher, or like Maybe with an implicit bind

16:38 turbofail: it's basically a success and fail continuation packaged into a "single"-ish function

16:38 amalloy: yeah, i guess that's true

16:40 arrdem: oh good amalloy isn't a bot anymore

16:40 I can still act like programming is NP-hard

16:45 stuartsierra: What's the most direct way to do truncating division of java.util.Longs?

16:46 amalloy: stuartsierra: ##(doc div), i think?

16:46 lazybot: java.lang.RuntimeException: Unable to resolve var: div in this context

16:46 rasmusto: amalloy: oh, your code makes perfect sense, and is faster. Thanks for giving me more use-cases for reduce :)

16:46 amalloy: &(doc quot)

16:46 lazybot: ⇒ "([num div]); quot[ient] of dividing numerator by denominator."

16:46 amalloy: or do you mean in java-land

16:47 rasmusto: amalloy: the double-reduce is a bit strange at first, but it makes sense since its a coll of maps we're dealing with

16:48 stuartsierra: div makes sense, thanks amalloy

16:48 amalloy: stuartsierra: it's actually quot, i was wrong

16:48 stuartsierra: ah

16:49 amalloy: $findfn 10 4 2

16:49 lazybot: [clojure.core/rem clojure.core/unchecked-remainder-int clojure.core/quot clojure.core/unchecked-divide-int clojure.core/mod]

16:49 amalloy: oh, of course mod shows up in that list too :P

16:54 dbasch: what's the right way to validate from input in a compojure app (e.g. emails, numbers)?

16:54 or at least, the easiest way besides doing it myself with regexes

16:55 justin_smith: The only way to reliable and simple way to validate an email is to send an email. The email spec is weird.

16:55 OT I know, just saying

16:55 amalloy: justin_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:55 you can easily say "that can't possibly be a valid email address because it has no @, please check it"

16:56 once all the idiot-tests have passed, you validate it for real

16:56 pyrtsa: Also, there are client-side JS libraries that let you warn the user of probable typos in email addresses, even suggest corrections.

16:59 justin_smith: "very.unusual.@.unusual.com"@example.com http://en.wikipedia.org/wiki/Email_address#Examples

17:01 Pate_: I'm trying to follow this tut: http://clojure-doc.org/articles/tutorials/emacs.html

17:02 but I'm stuck at the "Configuring Emacs" step

17:02 seangrove: What's the clojure metrics plugin?

17:02 I'd like to see LoC, etc.

17:02 Pate_: I found the .emacs.d folder: C:\Users\myuser\AppData\Roaming\.emacs.d\

17:02 justin_smith: Pate_: have you created init.el?

17:03 Pate_: yes, I can put stuff in init.el

17:03 and it seems to run

17:03 now, in the tut it says to put (require 'package) ...

17:03 that works

17:03 justin_smith: OK

17:03 now you can use package to install stuff

17:03 Pate_: then it says to put: (defvar my-packages '(starter-kit...

17:03 should I replace the previous content or append it to init.el?

17:03 I tried both

17:03 justin_smith: append

17:04 Pate_: if I append, Emacs starts up blank

17:04 justin_smith: that stuff won't work without package required

17:04 you may need to wait for it to finish installing things

17:04 Pate_: ah, so no loading indicator?

17:04 justin_smith: that will take a few, it is downloading stuff etc.

17:04 myguidingstar: hi all, I have a corelogic question

17:04 justin_smith: Pate_: not sure, I have not installed things that way, but I would not be surprised if there was no indicator

17:05 you could check the process manager, emacs should be using the network and using some CPU and using the HD

17:05 myguidingstar: ;"reverse" in the Reasoned Sch; 3.98

17:05 (define memberrevo

17:05 (lambda (x l)

17:05 (conde

17:05 ((nullo l) fail)

17:05 (succeed

17:05 (fresh (d)

17:05 (cdro l d)

17:05 (memberrevo x d)))

17:05 (else (eq-caro l x)))))

17:05 amalloy: ~refheap

17:05 clojurebot: https://www.refheap.com/

17:05 myguidingstar: (test-check "3.100"

17:05 (run* (x)

17:05 (memberrevo x `(pasta e fagioli)))

17:05 `(fagioli e pasta))

17:05 Pate_: ok so it finally started to respond

17:06 it seemed to be eating WM_MESSAGE

17:06 alew: myguidingstar: please don't paste code into irc

17:06 myguidingstar: alew, I'm sorry

17:06 technomancy: it's still recommending the starter kit? =/

17:06 alew: as amalloy suggested, use ~refheap

17:06 technomancy: should drum up a pull request

17:06 alew: ~refheap

17:06 clojurebot: https://www.refheap.com/

17:06 Pate_: emacs is complaining about args out of range

17:06 can't select the text to paste

17:07 how do I switch to the bottom window?

17:07 amalloy: Pate_: C-x b *Messages*

17:09 myguidingstar: I tried to "translate" the memberrevo function in The Reasoned Schemer 3.98

17:09 https://www.refheap.com/55936

17:09 but it doesn't work

17:12 Profpatsch: Anyone 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:12 dnolen_: myguidingstar: what result do you get?

17:12 justin_smith: Profpatsch: maybe use in-ns?

17:12 myguidingstar: well, the original list was returned

17:13 Profpatsch: justin_smith: Nah, when re-evaling in Lighttable from my code. I’m not in a repl.

17:14 technomancy: the heck

17:14 the clojure doc guide doesn't even mention paredit

17:15 RickInAtlanta: myguidingstar: where you have (firsto l x) I have eq-caro

17:15 oh,which is just firsto, nm

17:16 dnolen_: myguidingstar: hmm, I don't have an old version of miniKanren to verify the original behavior.

17:16 myguidingstar: dnolen_, okay, so is there any way to do 'reverse' in core logic?

17:17 RickInAtlanta: is it because conde in core.logic is actualy condi in minikanren?

17:17 dnolen_: 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:18 myguidingstar: dnolen_, I got it. I just ask 'how do we do that with core.logic?'

17:18 dnolen_: myguidingstar: also reading it, it doesn't appear to me that the original does what you think it does

17:19 myguidingstar: but again hard for me to confirm

17:20 myguidingstar: dnolen_, ok, forget that book. Please help me with my latest question: how do we do that?

17:21 dnolen_: myguidingstar: https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/bench.clj#L42

17:23 myguidingstar: dnolen_, thanks a lot. You're my hero ;>

18:05 justin_smith: (str str str)

18:05 ,(str str str)

18:05 clojurebot: "clojure.core$str@f4b5c1clojure.core$str@f4b5c1"

18:06 technomancy: buffalo buffalo buffalo

18:06 justin_smith: ,(vector vector vector)

18:06 clojurebot: [#<core$vector clojure.core$vector@81d1ed> #<core$vector clojure.core$vector@81d1ed>]

18:06 AeroNotix: ,(partial partial partial)

18:06 clojurebot: #<core$partial$fn__4196 clojure.core$partial$fn__4196@f300fa>

18:06 justin_smith: nice

18:07 ,(juxt juxt juxt)

18:07 clojurebot: #<core$juxt$fn__4179 clojure.core$juxt$fn__4179@12dea42>

18:07 justin_smith: now to find a context where (juxt juxt juxt) would be in some way useful

18:10 technomancy: juxt praemium suum est

18:11 much like TCO

18:11 justin_smith: indeed

18:14 rasmusto: ,((apply juxt [:a :b :c :d]) {:a 1 :b 2 :c 3 :d 4}) ; am I doing it right?

18:14 clojurebot: [1 2 3 4]

18:14 atyz: Could someone tell me how I might find the fully qualified path for a function?

18:15 amalloy: &(map {:a 1 :b 2 :c 3 :d 4} [:a :b :c :d])

18:15 lazybot: ⇒ (1 2 3 4)

18:15 bbloom: atyz: functions don't have fully qualified paths

18:15 technomancy: atyz: you need a var for that

18:15 rasmusto: ,((apply juxt [:a :b :c :d #(get % :e :baz)]) {:a 1 :b 2 :c 3 :d 4}) ; am I doing it right?

18:15 clojurebot: [1 2 3 4 :baz]

18:16 atyz: Thanks!

18:16 redx543: Is it possible to remove nils from a vector of vectors, for example [nil nil [1 5] nil nil [3 8] nil nil]?

18:17 amalloy: redx543: sure, i mean, there's ##(doc remove)

18:17 lazybot: ⇒ "([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:17 rasmusto: redx543: you almost have it typed out in pseudocode already

18:17 redx543: I already tried that but for some reason it flattens the vector.

18:17 amalloy: but 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:17 S11001001: redx543: don't use for

18:18 redx543: Wait, is for the reason for generating nils inside of the vector?

18:18 amalloy: don't use for??? what is the context for this that i'm missing?

18:18 justin_smith: S11001001 parsed a sentence oddly

18:19 redx543: I don't know, but it's true that I'm generating this in a for loop.

18:19 amalloy: oh, i see

18:19 rasmusto: ,(for [a [nil [1 2] nil [3 4]] b a] [a b])

18:19 clojurebot: ([[1 2] 1] [[1 2] 2] [[3 4] 3] [[3 4] 4])

18:19 amalloy: redx543: why don't you paste your code on refheap or gist? i'm sure someone will see the right way to do it

18:19 rasmusto: is that what we're talking about?

18:20 amalloy: rasmusto: no, i think you're three levels deep into a nested misunderstanding

18:20 everyone abort

18:20 rasmusto: ,for

18:20 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/for, compiling:(NO_SOURCE_PATH:0:0)>

18:20 turbofail: everyone out of the universe!

18:22 S11001001: it's *cosmos* these days.

18:27 justin_smith: ~for

18:27 clojurebot: for is complected

18:28 justin_smith: ~for

18:28 clojurebot: for is complected

18:28 rasmusto: i've seen this a few times ##(#(for [a %] a) [1 2 3])

18:28 lazybot: ⇒ (1 2 3)

18:30 justin_smith: it's less characters than #(map identity %) I guess

18:30 but more than seq

18:30 rasmusto: well, I just pasted the simplest version of it

18:30 justin_smith: ahh, right

18:30 rasmusto: its better than trying to do everything complex using thread-last

18:40 technomancy: is "thread-last" the canonical pronounciation?

18:40 amalloy: technomancy: that's my understanding, yes

18:40 rasmusto: I saw it written somewhere, I just say ->>

18:40 amalloy: i say "double-arrow", but i don't mind being wrong

18:40 technomancy: I call -> "thrush" in my head

18:40 amalloy: rasmusto: out loud? i'd loev to hear that

18:40 technomancy: :((((

18:40 technomancy: I guess I call ->> "thrushush"

18:41 AeroNotix: thread and thread-last here

18:41 rasmusto: hyphengreaterthangreaterthan

18:44 amalloy: technomancy: 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:45 SegFaultAX: (inc amalloy)

18:45 lazybot: ⇒ 89

18:45 technomancy: amalloy: it seems like a natural extension when you move from SKI->lisp though

18:45 I don't call it a combinator, because that's silly

18:45 SegFaultAX: Didn't fogus do a blog post about the thrush operator?

18:45 amalloy: yes, i'm inclined to mostly blame him for the popularity, SegFaultAX

18:46 it doesn't even take functions

18:46 technomancy: thread-first is to lisp forms as the thrush combinator is to SKI

18:47 fogus's post was pretty explicit about -> not being the thrush combinator

18:48 which doesn't imply that -> does not partake in the nature of thrushiness

18:50 amalloy: you're right, i'm definitely wrong in saying the name popularity came from fogus

18:50 danielszmulewicz: seangrove: ping

18:53 dsrx: will company-cider use the complete op from the cider-nrepl middlewares if it's available?

18:53 danielszmulewicz: amalloy: 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:03 RickInAtlanta: I 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:04 (ns om-test.core

19:04 (:require-macros [cljs.core.async.macros :refer [go]])

19:04 (:require [om.core :as om :include-macros true]

19:04 [om.dom :as dom :include-macros true]))

19:04 dsrx: RickInAtlanta: refheap.com

19:05 RickInAtlanta: https://www.refheap.com/56131

19:05 Anderkent: RickInAtlanta: are you running it as clojure or cljs?

19:05 RickInAtlanta: I am trying to run as cljs

19:08 SegFaultAX: amalloy: Sorry, I wasn't clear. I meant fogus wrote a blog post about the actual thrush operator vs. the threading macros in Clojure.

19:09 RickInAtlanta: weird,I try it in LightTable I get 'goog' is not defined

19:11 yarou: which one is thrush? something like: \ab -> ba

19:11 technomancy: yarou: that's S, I think

19:12 danielszmulewicz: Anyone 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:13 yarou: hmm, it might be

19:13 i read raganwald's javascript book a while ago, so i dont remember the combinators too much

19:13 rasmusto: ~thrush

19:13 clojurebot: I don't understand.

19:14 justin_smith: danielszmulewicz: sass is popular around here

19:14 http://sass-lang.com/

19:14 yarou: ah, i see

19:14 -<

19:14 rasmusto: I always thought that (-> blah (#(something %))) felt weird

19:14 yarou: ->

19:15 stcredzero: Any 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:15 amalloy: rasmusto: that's because it's bad

19:15 like, sometimes it's the least-bad alternative

19:16 yarou: lambda a, b: b(a) is that thrush??? in python ofc

19:16 rasmusto: yarou: don't think so

19:16 amalloy: but 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:17 yarou: ok, how about this

19:17 amalloy: i think those are both thrush, yarou. (defn thrush [a b] (b a))

19:18 yarou: a function that takes (possibly) functions a and b as parameters, and returns b applied to a

19:18 amalloy: gotcha

19:20 rasmusto: ,(reduce #(%2 %1) [(range 10) #(map inc %) reverse])

19:20 clojurebot: (10 9 8 7 6 ...)

19:22 danielszmulewicz: justin_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:26 SegFaultAX: danielszmulewicz: The common choices right now are bootstrap and foundation.

19:26 I prefer the latter but lots and /lots/ of people use bootstrap.

19:26 Also, wrapbootstrap.com is a thing.

19:27 seangrove: danielszmulewicz: SASS on top of bootstrap is what you're looking for, most likely

19:27 SegFaultAX: seangrove: Not likely

19:27 Bootstrap is LESS

19:27 Foundation is SASS

19:27 seangrove: SegFaultAX: Yes, yes, but that idea

19:27 SegFaultAX: Unless you're just using .min.css straight up, in which case use whichever you like more.

19:27 :)

19:27 yarou: bootstrap is the devil

19:28 one can only hope we can find god

19:28 SegFaultAX: yarou: Why?

19:28 danielszmulewicz: yarou: That's what I had in mind :-)

19:28 seangrove: Looks like there's a sass-port of bootstrap

19:28 SegFaultAX: danielszmulewicz: Then check out Zurb Foundation.

19:28 seangrove: I'm an atheist, I actively try avoiding religious associations with tech :P

19:28 zspencer: I'm a fan of suzy: http://susy.oddbird.net/

19:28 susy(

19:28 susy*

19:28 danielszmulewicz: The problem of bootstrap is that it breaks the semantic coherence of html by its heavy (mi)suse of classes

19:29 there's semantic ui. Anyone tried it?

19:29 yarou: seangrove: i am an atheist too

19:30 but literary characters are attached to some sentiment or philosophy

19:30 seangrove: yarou: Just a joke ;)

19:30 SegFaultAX: Assuming atheism is defined as lack of belief in god or gods, how can one /be/ atheist.

19:30 danielszmulewicz: zspencer: thanks. I had heard about it.

19:30 zspencer: danielszmulewicz: if you're obsessive about keeping the classes as less mixins it works reasonably ok

19:30 SegFaultAX: Atheism is the default position.

19:30 yarou: geocities

19:30 is our savior

19:30 stcredzero: seangrove: 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:30 seangrove: danielszmulewicz: 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:31 Cr8: SegFaultAX: by fitting that definition, I guess?

19:31 SegFaultAX: Cr8: What other definition could there be?

19:31 yarou: has anyone used luminous or w/e in production ?

19:31 seangrove: stcredzero: One must be careful with sarcasm, heh

19:31 yarou: i'm contemplating porting my rails app to this

19:31 Cr8: of that word? none, but one could *not* fit the definition, and then they wouldn't be

19:31 SegFaultAX: Cr8: "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:32 seangrove: yarou: Certainly could do worse than that

19:32 stcredzero: "Animal House" was a cautionary parody which spawned endless clueless imitators. (Me in my late teens being one of them, admittedly)

19:32 danielszmulewicz: seangrove: BTW, have you had time to look into the externs for om (ReactCSSTransitionGroup)?

19:33 Cr8: that's a thing you could argue, but I feel it's being a bit pendantic ;)

19:33 rasmusto: is pedantic a css framework?

19:33 seangrove: danielszmulewicz: 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:33 danielszmulewicz: Have you tried just using auto-generated externs?

19:34 That was going to be my next attempt

19:34 danielszmulewicz: seangrove: Awesome news. No, I've been stalling.

19:34 Cr8: and then there are noncognitivists, who hold the position that "there are(n't) gods" isn't a belief

19:35 justin_smith: and ignosticism, which contends "is there a God" is an underdefined, and nonsensical question

19:36 SegFaultAX: Cr8: Which makes no sense, since "there are(n't)..." is a claim which must be substantiated with evidence.

19:36 (Irrespective of the claim)

19:36 Cr8: well the position is the stuff after the "..." is not defined in any useful sense

19:36 same as ignosticisim

19:37 so it's useless to make the statement

19:37 tlbakh: is there anyone that i can ask a question about clojure ?

19:37 SegFaultAX: tlbakh: Ignore us, carry on. :)

19:37 Cr8: tlbakh: yes

19:37 zspencer: Only if your say 10 hail-hickey's first.

19:38 SegFaultAX: Haha, hail hickeys.

19:38 "Our father, who art in bytecode, Clojure be thy name..."

19:38 * SegFaultAX shows himself out

19:38 tlbakh: started yesterday to code in clj. The thing is I tried to increment every element of a list by 1 by using map.

19:39 and i wrote a main for it as follows

19:39 SegFaultAX: tlbakh: Wait

19:39 * technomancy only knows the litany against cons

19:39 SegFaultAX: tlbakh: Don't paste code longer than one line to the chat.

19:39 tlbakh: refheap.com or gist.

19:39 tlbakh: i was gonna post gist page

19:39 oh oke then :)

19:39 SegFaultAX: Great! :)

19:41 tlbakh: https://gist.github.com/wishfulpanda/9476787

19:41 here is the link

19:41 and i commented it

19:41 why are these giving different outputs

19:41 is there any relevance with immutable collections?

19:42 akhudek: tlbakh, because everything is immutable in clojure

19:42 SegFaultAX: tlbakh: def is a top-level form. Use let to introduce local bindings.

19:42 justin_smith: tlbakh: inc does not change its argument

19:42 zspencer: when you call `def` you're declaring a n immutable list

19:42 SegFaultAX: ,(let [x 5] (prn x))

19:42 zspencer: print x then just reprints the list

19:42 clojurebot: 5\n

19:42 akhudek: so x is always going to be same, but the map returns a value (that you are not capturing) that represents what you want

19:43 justin_smith: s/inc/#(+ % 1)

19:43 zspencer: Also, let is the preferred nomenclature for declaring locally scoped variables, from what I understand

19:43 tlbakh: im kinda confused right now but thank you so much

19:44 zspencer: Is there a language you're more familiar with I could write an alternate gist for?

19:44 tlbakh: def is not used for what my purpose as far as i understand

19:44 java c++ python

19:44 im just a newbie for fp

19:45 zspencer: Me too :). Let me take a stab at this in python and link you to it

19:45 I'm not a python guru though

19:45 justin_smith: def always adds a binding to a namespace, so using it inside a function is usually wrong

19:45 it does not create any function-local binding

19:45 tlbakh: that makes sens

19:45 sense*

19:45 thank you

19:45 SegFaultAX: tlbakh: Think of it like this: l = [1,2,3]; [n + 1 for n in l]

19:45 tlbakh: zspencer, thank you really appreciated

19:46 SegFaultAX: tlbakh: There is no reason that would modify the original value.

19:46 It just produces a new list.

19:46 tlbakh: SegFaultAX, what if i call it with let?

19:47 SegFaultAX: ,(let [n [1 2 3] n (map inc n)] n)

19:47 clojurebot: (2 3 4)

19:47 SegFaultAX: tlbakh: Let is recursive.

19:47 justin_smith: you can capture the binding with let

19:47 SegFaultAX: (In other words you can access previous bindings in the same let form)

19:47 Or even re-bind them, as above.

19:48 tlbakh: Mind you def and let really have nothing to do with eachother.

19:49 let introduces a local name for a value, def creates a var in the top-level of the current namespace.

19:49 justin_smith: the commonality is they create bindings from symbols in the code to values

19:49 tlbakh: oke so let is the right way to local binding

19:49 i get it

19:49 nightfly: yes

19:52 tlbakh: now i got it worked =)

19:52 thank you guys

19:53 from the point i stand, i have to learn a lot of stuff. whats the best road map that i should follow? any recommendations?

19:53 zspencer: tlbakh: https://gist.github.com/zspencer/9476808

19:53 justin_smith: clojure koans and 4clojure are helpful (but not sufficient)

19:54 tlbakh: im working on 4clojure , its helpful but not enough for a noob

19:54 justin_smith: http://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:54 zspencer: Yea, 4clojure was too hard for me :/

19:55 SegFaultAX: zspencer: Ehhh, map really isn't idiomatic Python so it's probably less useful in examples. Pythonistas tend to prefer comprehensions.

19:55 zspencer: I get to pair everyday with clojure programmers, so that was nice

19:55 yea, the idiomatic is more clojure centered :) I don't know python well

19:55 SegFaultAX: zspencer: [x + 1 for x in [1,2,3]]

19:57 rasmusto: ,(reduce #(%2 %1) [[1 2 3] inc])

19:57 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number>

19:58 rasmusto: ,(reduce #(%2 %1) [[1 2 3] #(map inc %)]) ; my bad

19:58 clojurebot: (2 3 4)

19:58 zspencer: SegFaultAX: list comprehensions don't seem to mutate state

19:58 SegFaultAX: zspencer: They don't, that's the point.

19:58 And neither should map.

19:58 zspencer: Concur

20:01 zoldar: I'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:01 turbofail: don't mutate? lulz. a = [lambda: x for x in range(10)]; a[0]() => 9

20:02 at least in python 2.7.3

20:02 zspencer: Lammmbbbdddaaaaaaaaassssss

20:03 SegFaultAX: turbofail: That isn't mutation, that's a capturing problem.

20:03 amalloy: yeah, exactly. java "solves" that problem by making you promise not to change x before it lets you close over it

20:03 SegFaultAX: Yup, finals all the way down.

20:03 turbofail: well because of its capturing problem it mutates

20:04 SegFaultAX: turbofail: Impure, sure. But mutating?

20:04 turbofail: how is that not mutating?

20:05 it's mutating x

20:05 it has the exact same symptoms that altering a mutable data structure would

20:05 SegFaultAX: turbofail: Because the mutation is not a side effect of the lambda itself.

20:05 rasmusto: ,(let [a 4 a 5] a) ; is mutating?

20:05 clojurebot: 5

20:06 SegFaultAX: The mutation is external to the lambda.

20:06 turbofail: sure, the list comprehension is mutating state, not the lambda

20:06 SegFaultAX: Which 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:06 turbofail: I didn't say you couldn't mutate state with listcomps or map, just that you shouldn't.

20:07 turbofail: Nothing it stopping you from using impure functions (in Python or Clojure), but why would you want to?

20:07 turbofail: all i'm saying is that something that looks like it should be pure isn't

20:08 dsrx: what's that, a list comprehension can't mutate state?

20:08 SegFaultAX: dsrx: s/can't/shouldn't/

20:08 dsrx: :p

20:08 turbofail: well specifically you said they "don't" mutate state

20:08 and it looks like they don't, until they do

20:10 SegFaultAX: turbofail: Fair enough. But then Python is almost entirely imperative.

20:10 turbofail: But "don't capture loop state" is a pretty common thing in lots of languages.

20:11 gfredericks: would 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:11 to avoid doing all the code inlined in a defrecord form

20:12 turbofail: SegFaultAX: sure. but list comprehensions look like they're functional, which is why i find that particularly egregious

20:14 SegFaultAX: turbofail: Yea :(. I have fallen entirely out of love with Python, even though I write it everyday (professionally)

20:14 amalloy: gfredericks: 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:23 mr-foobar: In om, what's the best place to put ajax call for initial data of a component ?

20:31 zoldar: mr-foobar: IWillMount / will-mount , probably

20:33 gfredericks: amalloy: right

20:36 mr-foobar: zoldar: I can fire the ajax in IWillMount, but how do I check if the ajax call has returned ?

20:37 seangrove: mr-foobar: You can use a core.async channel for it

20:38 mr-foobar: seangrove: I want to render the component with the data. Without the data, I'd like to show zilch.

20:39 seangrove: mr-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:40 Amongst another dozen ways, I sure. That's a QND way though

20:41 I would do the ajax calls elsewhere, but if you have to do it in the component, then there you go

20:41 mr-foobar: seangrove: sounds right. thx !

20:51 danielszmulewicz: gf3: ping

20:51 gf3: holla

20:52 danielszmulewicz: gf3: Hi, I was looking for any-matches? in secretary but couldn't find it anymore...

20:52 gf3: danielszmulewicz: It's all been changed

20:52 danielszmulewicz: gf3: :-)

20:52 gf3: danielszmulewicz: The new secretary is much more powerful and robust

20:52 Mostly thanks to noprompt

20:52 danielszmulewicz: gf3: that's nice to hear

20:53 gf3: how do I acheive any-matches? though?

20:53 gf3: danielszmulewicz: You should be able to use `locate-route`

20:53 danielszmulewicz: https://github.com/gf3/secretary/blob/master/src/secretary/core.cljs#L181-L186

20:53 danielszmulewicz: gf3: ah so that's what I'm looking for. Thanks a bunch.

20:54 gf3: oops, it's not exported though

20:54 danielszmulewicz: gf3: private function :-)

20:54 gf3: danielszmulewicz: We can see about opening it up, though

20:54 danielszmulewicz: What's the use-case, if you don't mind me asking?

20:56 danielszmulewicz: gf3: 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:56 ?

20:58 gf3: https://www.refheap.com/56178

20:58 gf3: danielszmulewicz: Ahh cool

20:59 danielszmulewicz: This might even be a good use-case for this → https://github.com/gf3/secretary/issues/21

21:00 stcredzero: Is clojure.java.jdbc db-do-commands vulnerable to SQL injection?

21:00 danielszmulewicz: gf3: Yes, but the API should have a simple boolean check for routes if you don't mind my opinion :-)

21:01 gf3: danielszmulewicz: I agree

21:01 danielszmulewicz: gf3: cool.

21:01 gf3: danielszmulewicz: 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:02 danielszmulewicz: Can you open an issue to make that fn public, and I'll triage it?

21:02 danielszmulewicz: gf3: sure

21:02 gf3: thanks.

21:03 gf3: danielszmulewicz: No, thank you!

21:15 seangrove: $seen noprompt

21:15 lazybot: noprompt was last seen quitting 7 hours and 38 minutes ago.

21:35 gfredericks: what causes clojure.repl to be use'd when I run `lein repl`?

21:55 akurilin2: So I'm looking at http kit here trying to figure out the idea behind async http connections. Why do I want that?

21:56 Is the idea that I'm not keeping a connection open while handling the request?

21:56 noonian: akurilin2: 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:57 akurilin2: So the difference is that you're not having a 1 to 1 thread to connection mapping?

21:57 noonian: you can serve multiple long running connections from a single thread

21:57 right

21:57 akurilin2: Does jetty do thread pooling of any sort?

21:58 I've been oblivious to this eveer since I started using it.

21:59 Not 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:59 noonian: it 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:03 mlb-: How popular is the clojure library incanter?

22:03 I'm playing about with R, but it's been a while and it seems most things with R have moved to ggplot2

22:04 akhudek: mlb-: R has a huge ecosystem and plotting is only a small part of it

22:05 noonian: but if you want something like R thats Clojure, you'd use incanter

22:07 mlb-: 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:08 akhudek: mlb-: 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:11 mlb-: 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:13 akhudek: mlb-: probably the mailing lists?

22:17 mlb-: akhudek: hmm, I'll check those out. Thanks!

22:18 michel_slm: mlb-: there's Stack Overflow too, the R tag is quite active

22:26 bufferloss: so 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:26 s within the local scope

22:26 what am I missing?

22:26 I've gotten through about the first 3rd of this http://java.ociweb.com/mark/clojure/article.html

22:26 (the first, left hand column in the table of contents)

22:27 maybe my understanding of let is incorrect

22:27 dsrx: bufferloss:

22:28 ,(let [x 32] (+ x 10))

22:28 clojurebot: 42

22:28 dsrx: ,((fn [] (let [x 32]) (+ x 10)))

22:28 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)>

22:29 bufferloss: oh, I see, so it creates its own scope

22:29 and you have to use x within the let block, right?

22:29 noonian: yep

22:29 bufferloss: aight cool thx, didn't catch that

22:29 ,(+ 1 2)

22:29 clojurebot: 3

22:31 bufferloss: ,((defn hello (+ 1 2) (def x 4)) hello)

22:31 clojurebot: #<CompilerException java.lang.IllegalArgumentException: Parameter declaration + should be a vector, compiling:(NO_SOURCE_PATH:0:0)>

22:31 bufferloss: ,((defn hello [& args] (+ 1 2) (def x 4)) hello)

22:31 clojurebot: #'sandbox/x

22:32 bufferloss: ,((defn hello [& args] (+ 1 2) (def x 4)) x)

22:32 clojurebot: #'sandbox/x

22:32 bufferloss: is a symbol defined within a function using (def ...) accessible outside the function?

22:32 (I am guessing/hoping no)

22:32 hiredman: yes

22:32 clojure is not like scheme

22:33 bufferloss: I don't know scheme

22:33 hiredman: def/defn always creat/definee a global var

22:33 bufferloss: so how do I define a variable local only to the scope of a function

22:33 hiredman: let

22:33 let and fn arguments are local bindings

22:33 bufferloss: ah, 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:34 hiredman: a "var" is a distinct thing, it is always global

22:34 generally in clojure people don't talk about variables, because locals are immutable and don't vary, and globals are vars

22:34 bufferloss: let all my symbols then

22:35 hiredman: so the bindings of names to values created via let, and via fn application tend be called "locals"

22:35 noonian: the symbols you use in a let will be bound to the value you provide in the let binding form

22:35 hiredman: so you let bind locals

22:35 bufferloss: right, so I can't actually, strictly speaking "declare" a bunch of empty symbols with let and then define them later, right?

22:35 noonian: you can bind them to nil if you want

22:36 hiredman: bufferloss: correct

22:36 noonian: let only takes an even number of forms so you have to give everything a value

22:36 hiredman: bufferloss: but symbols is not the right word either

22:36 nightfly: bindings

22:36 noonian: it binds what the symbols resolve to when they are evaluated

22:36 hiredman: symbols are the datatype that happen to be used in the reader to represent names

22:36 noonian: yea

22:37 hiredman: but they don't have storage associated with them, (let [x 1] x) doesn't somehow stick 1 in some value slot on x

22:38 somewhere there is a thing that locally binds the name x to the value 1, a local binding

22:46 akurilin2: Oh man I need to write down what noonian just said, always wanted to phrase that whole symbol resolution process elegantly :)

22:50 vjktm: I am trying cider in emacs

22:50 I can't get the error highlighting to work, i.e., I don't see the red highlight

22:50 what should I try?

22:54 bufferloss: am I supposed to use * for all my local bindings? e.g. function parameters or let bindings?

22:55 akurilin2: What's *?

22:56 hiredman: bufferloss: 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:56 bufferloss: ,(println *clojure-version*)

22:56 clojurebot: {:interim true, :major 1, :minor 6, :incremental 0, :qualifier master}\n

22:56 noonian: the use of asterisks is a convetion used with dynamic vars to tell you that they are dynamic

22:56 bufferloss: akurilin2, stuff like that as far as I know

22:56 hiredman: it is just a convention to use them though

22:56 bufferloss: noonian, ah ok

22:56 akurilin2: Yeah it's a naming convention for dynamic vars

22:56 Because they're freaky and you should avoid making your own.

23:01 bocaj: Would anyone like to share an extract, transform, load experience with clojure? I'm sick of thick tools.

23:16 seangrove: stcredzero: 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:24 bufferloss: is there an equivalent to "each" aside from (doall (map...))

23:25 noonian: ,(doseq [i (range 10)] (println i))

23:25 clojurebot: 0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n

23:26 noonian: ,(doseq [i (range 10)] (print i))

23:26 clojurebot: 0123456789

23:27 bufferloss: noonian, ah cool

23:27 anyone happen to know how to get the actual SQL error message out of clojure.java.jdbc if a sql error occurs?

23:28 jcromartie: noonian: it's also worth noting: "doall" holds onto the head and keeps the whole seq in memory, while "dorun" and "doseq" do not

23:28 bob2: when 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:28 jcromartie: noonian: i.e. use doall when you care about ALL the seq

23:28 bob2: only when it is require'd

23:29 bob2: cheers

23:30 trptcolin: bbloom: thanks again for the delimc help the other day - i'm getting close to grokking it.

23:30 noonian: jcromartie: but for printing out a seq you don't really care about holding onto the head right?

23:30 jcromartie: noonian: correct

23:31 bbloom: trptcolin: np, did i explain the kernel call metaphore to you? that's my new favorite way to think about it

23:31 noonian: cool, it seemed like bufferloss wasn't trying to hold onto the result with his question

23:33 trptcolin: bbloom: no, i don't think so.

23:34 bbloom: trptcolin: 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:34 trptcolin: 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:35 trptcolin: 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:36 trptcolin: so you delimit a continuation around the system call w/ the stuff you stuck in the registers? :)

23:36 i like it

23:38 bbloom_: trptcolin: shit. i wrote a bunch of stuff, but i got disconnected

23:38 trptcolin: https://www.refheap.com/56255 <- there

23:38 trptcolin: bbloom: :) yeah shift/reset are weird names. i kept thinking shift/reduce initially

23:38 bbloom_: yeah

23:39 i much prefer the handle/raise variant since it maps to how i already understand try/throw

23:39 trptcolin: bbloom_: the metaphor is interesting though

23:40 bbloom_: 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:40 [specifically a nested one]

23:41 technomancy: gfredericks: you know you have commit on lein, right?

23:41 bbloom_: trptcolin: also good: http://www.cs.indiana.edu/l/www/pub/techreports/TR615.pdf

23:42 trptcolin: bbloom_: i have so many tabs of this stuff open, that's in there somewhere :)

23:43 technomancy: trptcolin: so ... are you familiar with the sjacket api?

23:43 trptcolin: technomancy: kinda sorta :)

23:43 technomancy: I noticed reply uses it

23:43 but it doesn't actually have any docs

23:45 trptcolin: technomancy: 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:45 using net.cgrand.sjacket/str-pt on an input string

23:46 i haven't done any of the fancy rewriting stuff

23:49 technomancy: yeah... I want to do stuff like that for lein 2.4

23:49 but yeah. no docs makes it tricky.

23:50 chare: when you guys do something distributed with Clojure like something similar to Erlang what do you do for rpc or mesage passing?

23:51 trptcolin: chare: i'm suddenly seeing irony, because i often use erlang (rabbitmq) for that

23:51 technomancy: most people use a queue like rabbit, yeah

23:51 it's only vaguely erlang-like of course

23:51 chare: what? you guys use clojure with a erlang backbone messaging?

23:52 technomancy: well yeah, use the best tool for the job

23:52 chare: so use rabbitmq except when you're already using erlang?

23:53 and also what happened to javaEE stuff, isn't there suppose to something for rpc/messaging that would make sense to use with clojure

23:53 trptcolin: chare: 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:54 technomancy: 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

Logging service provided by n01se.net