#clojure log - Dec 07 2014

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

0:11 rritoch: andyf: Ok, the fork is created https://github.com/rritoch/clojure and I've posted it to the clojure mailing list but since it's my first post it's been moderated.

0:14 andyf: You mentioned about "learning", the only thing I really learned from this is clojure really does use a lot of interfaces. A lot of the code probably needs to be changed to use the correct interfaces but that was the biggest difficulty in getting this to work.

0:15 justin_smith: &(defn days [month] (int (+ 28 (mod (+ month (Math/floor (/ month 8))) 2) (mod 2 month) (* 2 (Math/floor (/ month))))))

0:15 lazybot: java.lang.SecurityException: You tripped the alarm! def is bad!

0:15 justin_smith: ,(defn days [month] (int (+ 28 (mod (+ month (Math/floor (/ month 8))) 2) (mod 2 month) (* 2 (Math/floor (/ month))))))

0:15 clojurebot: #'sandbox/days

0:15 justin_smith: (days 1)

0:15 ,(days 1)

0:15 clojurebot: 31

0:15 justin_smith: ,(days 2)

0:15 clojurebot: 28

0:15 justin_smith: w00t

0:15 ,(days 8)

0:15 clojurebot: 31

0:16 gfredericks: ,(map days (range 1 13))

0:16 clojurebot: (31 28 31 30 31 ...)

0:16 gfredericks: ,(apply str (map days (range 1 13)))

0:16 clojurebot: "312831303130313130313031"

0:16 gfredericks: (inc justin_smith)

0:16 lazybot: ⇒ 153

0:16 gfredericks: ,(days 93)

0:16 clojurebot: 30

0:16 gfredericks: ,(days 94)

0:16 clojurebot: 31

0:17 gfredericks: ,(filter #(= 28 (days %)) (range 100))

0:17 clojurebot: #<ArithmeticException java.lang.ArithmeticException: Divide by zero>

0:17 justin_smith: this clearly answers some very important questions about hypothetical months of the future

0:17 gfredericks: ,(filter #(= 28 (days %)) (range 1 100))

0:17 clojurebot: (2)

0:17 gfredericks: ,(filter #(= 28 (days %)) (range -100 0))

0:17 clojurebot: ()

0:18 justin_smith: gfredericks: I cannot take credit, I merely translated it from this http://cmcenroe.me/2014/12/05/days-in-month-formula.html

0:21 gfredericks: I bet there's some cool polynomial and/or sinusoidal expressions that could do it too

0:21 justin_smith: oh yeah!

0:21 or a weird lindenmayer system

0:22 gfredericks: I just remembered there's a doohickey on my website for the polynomial part of that

0:28 ,(defn days [x] (letfn [(f [n d e] (apply * (/ n d) (repeat e x)))] (+ (- (f 11 907200 11)) (f 163 181440 10) (- (f 37 1260 9)) (f 13481 24192 8) (- (f 2055371 302400 7)) (f 240683 4320 6) (- (f 28268521 90720 5)) (f 85774775 72576 4) (- (f 446998571 151200 3)) (f 46351537 10080 2) (- (f 221017 56 1)) 1416)))

0:28 clojurebot: #'sandbox/days

0:28 gfredericks: ,(map days (range 1 13))

0:28 clojurebot: (31N 28N 31N 30N 31N ...)

0:28 gfredericks: ,(days 100)

0:28 clojurebot: -55834893236621534N

0:28 gfredericks: ,(days 0)

0:28 clojurebot: 1416N

0:32 * gfredericks realizes he can't parse #"[]-_]" and goes to bed

0:40 amalloy: gfredericks: it's van gogh wearing a bowler hat, right?

0:46 andyf: rritoch: moderated. Regarding the learning, as I said, many people have made proposals for changes to Clojure, but only a relatively small fraction are approved.

0:47 trot_: if i have a function def like fnName [n [f & r]] , does that mean n is paired with a [f & r], where an [f & r] could be one or more elements long?

0:48 justin_smith: ,((fn fName [n [f & r]] {:n n :f f :r r}) 1 [2 3 4 5 6]) ; trot_

0:48 clojurebot: {:n 1, :f 2, :r (3 4 5 6)}

0:48 justin_smith: r can be empty

0:48 ,((fn fName [n [f & r]] {:n n :f f :r r}) 1 [])

0:48 clojurebot: {:n 1, :f nil, :r nil}

0:49 justin_smith: f and r can be empty, that is

0:50 trot_: i didn't quite understand your example

0:50 justin_smith: what part?

0:50 trot_: what's with the curly braces?

0:50 justin_smith: that's a map literal

0:50 trot_: and the 1 []?

0:50 justin_smith: 1 is a number

0:50 [] is an empty vector

0:50 trot_: and the 1?

0:50 justin_smith: they are the args to the function

0:50 trot_: oh

0:51 so [f & r] binds to []?

0:51 maybe binds is the wrong word to use

0:51 justin_smith: in that case, yes

0:51 rritoch: andyf: This isn't my first time around this block. It is why I switched to clojure. I suggested to Pike that operators should be overridable in the master object.

0:51 andyf: They didn't like the idea and suggested I switch to LISP

0:51 justin_smith: trot_: it destructures [], so f and r both end up nil, as you can hopefully see

0:53 rritoch: andyf: That didn't directly lead to the switch though. I wasn't aware of clojure until I was hired to program in it based on my LISP and Java experience.

0:53 trot_: yes I can. And so the point of writing [f & r] inside its own square parenthesis, is to allow destruction?

0:53 rritoch: andyf: Lack of namespaces is the main reason why I didn't like Lisp, so you can see why I like clojure.

0:54 justin_smith: trot_: exactly, because destructuring is more concise than repeatedly using first / rest etc. or using a let block

0:54 rritoch: andyf: Either way, as far as I can tell this is the only reliable way to maintain isolated namespaces which is a feature needed in many applications. I've also submitted the patch to the company I work with for review so I may simply end up needing to maintain this fork. Something I really wanted to avoid.

0:55 trot_: OK. Thanks :) Think that will be all for now. Trying to decipher https://github.com/stuarthalloway/programming-clojure/blob/master/src/examples/primes.clj

0:56 justin_smith: in context, the f and r stand for first and rest

0:56 rritoch: As far as I can tell this patch should work with every existing version of clojure so a fork is possibly the best route anyhow.

0:56 andyf: I just don't want the extra responsiblity.

0:56 justin_smith: because they get the same contents that (first arg) and (rest arg) would give

0:57 andyf: Do you have reason to think that others will want the extra responsibility?

0:57 nonuby: in cljs which is more idiomatic https://www.refheap.com/94511

0:58 line 7 shoud be .-Compon.. not -Compon..

0:58 justin_smith: nonuby: definitely the first one - but the nil at the outside of the let block is redundant

0:59 ,(let [a 0])

0:59 clojurebot: nil

0:59 nonuby: justin_smith isn't more than one dot following js/ being dropped? (cant remember where read possibly one of david nolen articles)

0:59 justin_smith: nonuby: oh, not sure

1:00 rritoch: andyf: If this was done for a large company, like Oracle or IBM, it wouldn't be an issue, but my team is VERY small.

1:00 justin_smith: (-> js/Ext .-ComponentManager .get "contact-form") maybe, in that case

1:01 err

1:01 (-> js/Ext .-ComponentManager (.get "contact-form"))

1:01 rritoch: Anyhow, it's done, it's working so I can finally rest. This was the biggest stumbling block to developing enterprise apps in clojure.

1:02 nonuby: yeah drawing similar conclusion, i think it looks the cleanest, but like yourself 1st looks best, Id wish they keep js/X.Y.howevermanydots

1:03 rritoch: Everything else needed is already provided by either clojure, clojurescript, or Java.

1:03 justin_smith: nonuby: are you reading the book that code goes with?

1:03 oops, I mean trot_

1:04 trot_: are you reading the book that code goes with?

1:04 trot_: yes

1:04 Halloway's

1:04 justin_smith: how is it?

1:05 trot_: It's OK. I feel Section 3.3 jumped the gun abit

1:05 nonuby: what book?

1:05 trot_: but most of it is gentle enough

1:05 justin_smith: nonuby: programming clojure

1:06 trot_: so far

1:08 justin_smith: trot_: best of luck. one thing I would add is use the repl, try things out, try to predict what will work, and what won't, and why, and figure out why the things that suprised you work the way they do

1:09 trot_: am doing / will do :)

1:09 jwm: quickly get into a repl/editor environment for sure

1:09 that is what made the difference for me

1:11 justin_smith: I learned a lot from the little one liners people use to demo things with the bots here

1:11 even coming from common lisp / scheme experience

1:12 jarjar_prime: is there a way to get a value out of core.async (go) block? :-)

1:12 justin_smith: jarjar_prime: you can send the value to a channel that you read elsewhere

1:13 and the go block, when created, returns a channel that will get the final return value of that block

1:27 jarjar_prime: justin_smith: there's no <!! in clojurescript though, hmmm

1:32 justin_smith: perhaps use take! with the on-caller arg

1:33 I am not sure though

1:33 you could also use <! inside another go block (go blocks all the way down...)

1:41 trot_: stupid question, but if i want to pass parameter into (zero?(rem % 5)), how would I do this

1:41 without making it into a function

1:41 amalloy: trot_: the question doesn't really make sense. how could it have a parameter if it's not a function?

1:42 and why would you want to avoid making a function?

1:42 trot_: i guess. I was just wondering if there is a fast way of binding % to a value

1:42 without writing out fn ...

1:43 and then calling the function

1:45 rritoch: trot_: I think your talking about the promise feature. https://clojuredocs.org/clojure.core/promise

1:45 lasergoat: trot_: sounds like you want nested #()s?

1:46 rritoch: trot_: But you still have to pass the promise into the function, so either way your stuck using partial

1:47 lasergoat: or do you just want to do (#(zero? (rem % 5)) 8)

1:48 (that showed up as an emoticon on my client, was supposed to say 8 )

1:48 trot_: no i don't think it's as complicated as that. I don't want to have to write

1:48 (defn testf [x] (zero?(rem x 3)) )

1:48 and then (testf 5)

1:48 I just want to do it in one line

1:48 write my function and immediately pass it a parameter

1:48 like an anonymous

1:49 like an anonymous function*

1:49 rritoch: trot_: lasergoat's code is what you want then

1:49 lasergoat: yeah, (#(zero? (rem % 3)) 5)

1:49 trot_: so what exactly does # do/

1:49 I think I did read actually

1:50 rritoch: ,(macroexpand '#(inc 1))

1:50 clojurebot: (fn* [] (inc 1))

1:50 lasergoat: that was just shorthand for ((fn [x] (zero? (rem x 3))) 5)

1:51 #() is just a macro that does that

1:52 trot_: excellent. thanks

1:53 lasergoat: np

1:58 trot_: OK, so if I wanted to pass a vector of arguments in the macro and have it return a vector e.g. (#(zero? (rem % 3)) [5 1 3]) to return false false true, how do I bind % to take each in the vector in turn?

1:59 andyf: trot_: use map in the function definition

1:59 or mapv if it needs to be a vector out

2:00 ,((fn [v] (map #(zero? (rem % 3)) v) [5 1 3])

2:00 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

2:01 lasergoat: well, you want to map the whole thing, not bake it into the function, right? (map #(zero? …) [5 1 3])

2:01 dagda1_: is there a more concise way to construct this regex than (re-find (re-pattern (str #"\b" className #"\b")) "fade in")

2:01 lasergoat: ,(map #(zero? (rem % 3)) [5 1 3])

2:01 clojurebot: (false false true)

2:02 lasergoat: ,(mapv #(zero? (rem % 3)) [5 1 3])

2:02 clojurebot: [false false true]

2:02 nonuby: dagda1_ doesn that create a "\b" regex and then stringify it (seems inefficient)

2:03 (type #"\b")

2:03 cheaper to "\\b"?

2:04 andyf: nonuby: Depends on whether you want cheaper in terms of typing fewer backslashes, which dagda1_'s expression achieves.

2:04 trot_: andyf: I tried (#(map #(zero? (rem % 3)) v) [1 2]) but that isn't quite correct

2:04 andyf: trot_: #() expressions cannot be nested

2:04 trot_: so I would need to fn [] here?

2:04 andyf: You can use (fn [args] forms-here) with one or more #() inside, but not nested

2:05 I mean (fn ...) can be nested, but #() cannot be.

2:05 nonuby: at the expense of creating two redundant regex Patterns? I dont think (str #"") was inteneded to be used as a magic quoting reader, but I havent tested how expense creating Patterns are?

2:05 lasergoat: trot_: i’m not sure why ou want a function at all, though; you can just call map

2:05 trot_: but you nest fn [], right?

2:06 andyf: fn can be nested, yes

2:06 lasergoat: you can, yeah

2:06 trot_: lasergoat: can you give me an example?

2:07 lasergoat: of nested fns or of why you don’t need it here?

2:07 trot_: oh

2:07 you did

2:07 lasergoat: :)

2:08 andyf: dagda1_: I don't know a more concise way to construct that regex. (re-pattern (str "\\b" className "\\b")) is the same number of characters, but if there were multiple things with \ in the leading and trailing backslashes, then #"re" wins for conciseness.

2:08 TEttinger: ,(re-find (re-pattern (str "\\b" "fade" "\\b")) "fade in")

2:08 clojurebot: "fade"

2:09 trot_: :)

2:09 andyf: leading and trailing *pieces of the regex pattern*, not "backslashes"

2:09 TEttinger: stringifying strings should be easier to work with

2:09 trot_: thanks all

2:10 andyf: TEttinger: #"this syntax" is really nice for avoiding typing double backslash characters in regular strings, and many regex patterns have a significant number of htem.

2:10 TEttinger: yep

2:10 nonuby: andyf, agreed, but using it in (str ...) simply stringifies the pattern, before building a another pattern, pattern -> string -> pattern,

2:11 trot_: line 14, https://github.com/stuarthalloway/programming-clojure/blob/master/src/examples/primes.clj, where does the primes symbol come from?

2:12 TEttinger: line 7, trot_

2:12 lasergoat: i wonder if that’s a general pattern in clojure, where you really want the string at the end of the day, like (str #”crap this\ has a\ lot of \ backslashes in \ it”)

2:12 TEttinger: it's recursive

2:12 andyf: dagda1_: Can className have regex-special characters in it like "." ? If so, you might want something like (str "\\b\\Q" className "\\E\\b"). It would be nice if you could use the #"" syntax there, but a regex can't end in \Q or begin with \E

2:13 nonuby: i doubt it, a proper reader for quoted stuff would be nice though, also you better hope java.regex.Pattern .toString() isnt doing anything special

2:13 andyf: The \Q and \E cause the className to be matched literally

2:13 dagda1_: I think I'll just go with what I have, thanks guys

2:13 trot_: i thought that, but at the same time I thought you don't invoke recursion that way in clojure. I though you explicitly write recur?

2:14 TEttinger: trot_, it's preferable but this isn't a function

2:14 trot_: Clearly I was wrong, so what is the point of recur here then?

2:15 TEttinger: there is a fn in there though

2:15 nonuby: doesnt lazy-seq perform some macro magic though to avoid any stackoverflow caused by recursion

2:16 TEttinger: what stuart's doing is some unusual lazyseq thing that involves referencing earlier points in the lazyseq (defined as primes) to get later ones

2:16 I am not a math guy so I won't try to understand how he's generating primes

2:27 lasergoat: is there something like split-at that takes more than one split point? like (split-lots [1 3] [:a :b :c :d]) -> [[:a] [:b :c] [:d]]

2:28 (my luck with inserting accidental emoticons continues unabaited)

2:31 trot_: TEttinger: am I right in thinking from that example I posted before, the let bindings if [primes-from fn [] wheel]? Doesn't the let bindings need to have even arity (i.e. primes-from maps to the function, but what maps to wheel)?

2:33 TEttinger: wheel is bound to the infinite lazy seq produced by cycle

2:33 pdk: spin to win

2:33 lasergoat: the structure there is (let [primes-fn (fn …) wheel (cycle…)]

2:34 Rhainur1: I'm trying to understand how to use Selmer. if I have a base layout template called "base.html", how can I pass in a "content" template file...right now I'm trying (layout/render

2:34 "base.html" {:content "home.html"}) and that's not working

2:34 lasergoat: so the fn is bound to primes-fn and (cycle…) is bound to wheel

2:37 trot_: lasergoat: oh yeah, i read wheel and a function with argument cycle... body is resisting this list processing malarkey

2:37 :

2:37 :)

2:39 Rhainur1: nope, figured it out, turns out I was going about it the wrong way entirely. I should have extended the template and written an override for the content block

3:11 lodin: Anyone know if there is any graphical test runner for clojure? Like http://i1-linux.softpedia-static.com/screenshots/GTestRunner_1.png . (Text-based GUI also works of course.)

3:12 I currently use expectations with autexpect and/or speclj with its auto mode.

3:36 pepijndevos: How do transients work? Since the transient function call is constant time, and does not modify the original collection...

3:38 So I asume that the initial assoc! will do some path-copying, and that subsequent modifications to the same chunk are mutations?

3:39 In which case modifying a few keys in a large map might not actually be faster, since it's likely that all of them require copying.

3:53 amalloy: pepijndevos: hypirion has a series of articles on transients

3:56 i think it's implemented in a sufficiently clever way that you shouldn't worry about whether transient/assoc!/persistent! will actually be slower than just assoc

4:11 pepijndevos: amalloy, it might not be slower, but it will not be a lot faster either.

4:36 Morgawr: 76

4:36 ~,

4:36 clojurebot: excusez-moi

4:36 Morgawr: whoops

4:36 sorry, I lagged

4:36 Audioburn: hi

4:37 Morgawr: anyhow I have a question, I built a clojurescript library and I want to implement an application on it, how do I package the clojurescript library so that I can import it in my clojurescript application and use it?

6:12 gargaml: Hi! I'm trying Clojure and I'd like to develop a project using the Qt library, I've heard about the QtJambi binding but can't find any recent info

6:12 does anyone try it lately?

6:36 profil: is it possible to have an inserted ordered map? so I can append keys to the end?

6:38 deadghost: profil, array map

6:39 profil: deadghost: and using assoc to append?

6:41 deadghost: actually profil ignore me it might be ordered map

6:42 nope array map seems correct

6:47 profil, https://github.com/flatland/ordered

6:47 does that look like what you want?

7:06 profil: deadghost: maybe..

7:07 deadghost: how would I use merge or conj to append maps but not overwrite existing values? is it even possible?

7:12 deadghost: profil, uhh what kind of map

7:12 and of course it's possible

7:13 at most you just write a function that checks if the key exists before whatever you're doing

7:16 profil, in the case of merge it says "If a key occurs in more than one map, the mapping from

7:16 the latter (left-to-right) will be the mapping in the result."

7:17 profil: deadghost: I want the behaviour of (merge b a), but the keys in b should not be updated if they exist in a

7:17 hmm

7:17 deadghost: profil, uhh (merge a b) instead?

7:17 profil: and I want the keep the order of the keys

7:18 deadghost: what kind of map is this?

7:18 profil: array-map?

7:18 deadghost: you might want to check if it maintains order

7:19 since I've read if you assoc it 10+ times it might turn into a hash map

7:19 if it does you might want to use that lib I linked

7:19 or just use it anyways

7:25 profil: deadghost: alright, the documentations is a bit minimal, but can I use merge with ordered-map?

7:26 deadghost: profil, idk try it

7:29 profil, if it doesn't it looks like assoc works

7:29 and it's not hard to write your own merge from there

7:54 wirrbel: I am using lein ring for a pet project for learning clojure. Can I make it autoreload upon source code changes?

7:54 using `lein run`

7:58 deadghost: wirrbel, short answer is yes

7:59 slightly longer answer is I don't remember how I have it set up

8:14 wirrbel: I found http://howardlewisship.com/io.aviso/documentation/rook/dev.html

8:19 hellofunk: in Om is it possible render and HTML string as actual HTML?

8:19 *an HTML string...

8:20 deadghost: hellofunk, you can also try #clojurescript

8:29 hellofunk: found the solution: https://github.com/swannodette/om/wiki/Documentation#props

8:54 hyPiRion: pepijndevos: Transients are usually more efficient at bulk popping, bulk pushing and sequential updates, so yeah, you're right – They're copied at first modification

8:55 pepijndevos: http://hypirion.com/musings/understanding-clojure-transients for the blogpost

8:56 *and yeah

9:07 lnostdal: https://github.com/ptaoussanis/clojure-web-server-benchmarks .. so, aleph is faster than http-kit now? .. that's interesting .. i see http-kit isn't even listed in the latest benchmark?

9:08 oh, wait ...it is; sorry ..i'm blind

9:39 justin_smith: profil: ##(doc merge-with)

9:39 lazybot: ⇒ "([f & 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(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."

9:40 justin_smith: deadghost: wirrbel: the auto-reload is the default if you use the lein-ring plugin. But if you want your handler to reload, pass the var not the function to the server #'handler

9:48 wirrbel: justin_smith: thank you

9:48 I have now refactored the code to use lein ring

9:48 justin_smith:

9:49 sry

11:07 eraserhd: So, are there any conventions other than 'wrap-*' for naming middleware functions?

11:07 justin_smith: ensure-*

11:08 check-*

11:08 eraserhd: hrmm

11:09 I think I should probably have my own convention for this project, then.

11:11 justin_smith: how much does a convention for naming middleware even help? the name should indicate what the middleware does, but the context of usage should make it clear it is a middleware

12:52 FriedBob: Funny how often when you get ready to ask for help on something, you find the answer

12:53 justin_smith: the best one is figuring out the answer in the phrasing of your question

12:55 FriedBob: I still don't have this figured out, but have some ideas to try. Kinda struggling to get my head around building a hash without using nested lopps + a mutating counter to extract the xml data

12:56 justin_smith: the answer is likely reduce, if you have some sequence to step over

13:11 david56789: Hello! I'm wondering how to capture the stdin and stdout of a process that I've spawned with Processbuilder. I've searched around but I don't really understand how to do it

13:12 justin_smith: david56789: ProcessBuilder returns a Process

13:12 Process has a .getInputStream that gives you stdout

13:12 .getErrorStream that gives you stderr

13:13 .getOutputStream that gives you stdin

13:13 check out the javadoc for java.lang.Process

13:13 $javadoc java.lang.Process

13:13 lazybot: http://docs.oracle.com/javase/6/docs/api/java/lang/Process.html

13:13 david56789: oh my I'm dumb

13:14 I read this line:

13:14 If the standard output of the subprocess has been redirected using ProcessBuilder.redirectOutput then this method will return a null input stream.

13:14 and thought it always returned a null input stream

13:14 Thank you!

13:14 justin_smith: np

13:50 FriedBob: justin_smith: It looks like reduce will be what I want.. once I figure out he functions to grab the individual oices I need

15:27 Frozenlock: Can you make a multi arity function with `fn'?

15:27 justin_smith: absolutely

15:28 Frozenlock: Ar, I forgot to say that it would be calling itself...

15:28 something like that ---> (defn my-fn ([x] (my-fn x nil)) ([x y] (str x y)))

15:29 justin_smith: ,(map #(apply (fn ([_] :ONE) ([_ _] :TWO) ([_ _ _] :AH-AH-AH)) %) [[0] [0 0] [0 0 0]])

15:29 clojurebot: (:ONE :TWO :AH-AH-AH)

15:29 justin_smith: Frozenlock: (fn my-fn ...)

15:29 then it can invoke itself by my-fn

15:30 Frozenlock: oh wow, I never noticed you could name a fn function o_O

15:31 That would work, thank you very much.

15:32 justin_smith: &((fn mine ([] (mine 0)) ([a] (mine a 0)) ([a b] (mine a b 0)) ([a b c & args] (conj args c b a))))

15:32 lazybot: ⇒ (0 0 0)

15:48 Rhainur1: can someone help me set up cemerick/friend in a luminus app?

15:54 gfredericks: &((fn self [] self)) ;; function that returns itself

15:54 lazybot: ⇒ #<sandbox6330$eval14481$self__14482 sandbox6330$eval14481$self__14482@7edce77f>

15:54 justin_smith: Rhainur1: have you seen this? http://clojure-yap.blogspot.com/2013/07/setting-up-friend-few-preliminaries.html

15:55 Bronsa: ,((((((fn self [] self))))))

15:55 clojurebot: #<sandbox$eval25$self__26 sandbox$eval25$self__26@19d8fc2>

15:56 justin_smith: &((((fn nf [] (fn [] nf))))) ; another variation

15:56 lazybot: ⇒ #<sandbox6330$eval14492$nf__14493$fn__14494 sandbox6330$eval14492$nf__14493$fn__14494@2b7359cf>

15:57 Rhainur1: justin_smith: yep, but it kinda leaves out a lot. the documentation on github also assumes a lot of knowledge

15:58 justin_smith: Rhainur1: the code in that example should be enough to actually run everything

15:58 or very close to it

15:59 that said, I find friend tricky to understand as well

17:17 l3dx: how can I define a function in the user namespace so that it is available from the REPL?

17:17 zarkone: hello all. I've created new app with lein new app course and then cider-jack-in. It's all OK when i use REPL, i compile can all buffer with C-c C-k, but when i do `lein run` i get Unable to resolve symbol: begin in this context, compiling:(NO_SOURCE_PATH:48:3)

17:17 justin_smith: l3dx: all funcitons are available in the repll if you use require

17:17 *repl *functions

17:17 *repl *functions

17:17 *repl *functions

17:17 *repl *functions

17:18 *repl *functions

17:18 *repl *functions

17:18 *repl *functions

17:18 *repl *functions

17:18 (sorry!)

17:18 l3dx: :)

17:18 yes, I know. what I meant was how can I define a utility function for later use?

17:18 justin_smith: ,(require '[clojure.string :as string])

17:18 clojurebot: nil

17:18 l3dx: maybe it isn't a good idea

17:19 was thinking of adding some aliases for cljs repl and such

17:19 justin_smith: l3dx: I think the best plan for that is to create a utility library, and add it to your :development profile in ~/.lein/profiles.clj

17:20 you could also define an injection to automatically :use that ns in profiles.clj (similar to what lein does with clojure.repl)

17:25 munderwo: HI all. I have a reagent clojurescript app. and one of my functions is being called, but im not sure by what. Is there a way in clojurescript to print out the function that called the current function?

17:27 dnolen_: munderwo: I would just set a breakpoint in a debugger

17:27 munderwo: right.. and see the call stack?

17:28 l3dx: justin_smith: thanks, sounds good

17:28 dnolen_: munderwo: yes

17:29 munderwo: hm… the only things in the call stack are anonymous functions. Im using source maps, does that all work correctly

17:30 dnolen_: munderwo: sourcemaps work

17:30 munderwo: ahhh I worked it out. Its because its a ‘def’ not a ‘defn’ its being evaluated at load time. *faceplam*

17:31 justin_smith: l3dx: maybe this is what you want? https://github.com/palletops/lein-shorthand

17:31 dnolen_: munderwo: speaking of which I realized JavaScript "debugger;" is pretty useful

17:31 I just added a js-debugger macro to master

17:31 munderwo: and thats why its call stack is pretty much empty. because nobdy called it, it was evaluated (im pretty sure im not using the right terminology.

17:31 oooh….

17:32 yeah I totally forgot about the awsome js debugger in chrome. Im using node-webkit and was like “Man I really would lie a debugger right about now” and then remembered I had one. It makes the repl being a bit more of a pain to setup with cljs a little less painful.

17:32 Now if only the console would work with cljs :)

17:34 Ooohhh… so it looks like there is a coffeescript console extension that allows you to run coffeescript in the chrome browser. which means in theory you could do that but for clojurescript… that would be awsome.

17:34 dnolen_: what does the js-debugger macro do?

17:37 kenrestivo: huh, that's interesting. just got a "Wrong number of args (3) passed" exception at runtime instead of compile time. i'd think the compiler would have caught that, but i guess not

17:39 justin_smith: kenrestivo: the compiler can't prove you wouldn't rebind the var

17:40 var's make all kind of static analysis hard to do

17:40 *vars

17:40 kenrestivo: eastwood will check stuff like that though

17:40 kenrestivo: ooh, good catch, thanks

17:41 justin_smith: eastwood is underappreciated

17:46 munderwo: justin_smith: is there something like eastwood or kibit for clojurescript? or can they run on clojurescript code bases as well>

17:47 justin_smith: munderwo: not sure, actually

17:47 munderwo: the readme for eastwood doesnt mention clojurescript AFAIKT

17:59 dnolen_: munderwo: sets a breakpoint

18:00 munderwo: oh nicde.

18:00 *nide

18:00 *curses his ability to use a keyboard*

18:00 *nice

18:31 * kenrestivo ncurses his occasional need to use gui apps

18:32 kenrestivo: eastwood found two nasty bugs that would have shown up at runtime, but which compiler did not catch

18:32 (inc eastwood)

18:32 lazybot: ⇒ 3

19:22 domokato: anyone use the core.typed library?

19:37 kenrestivo: ~anyone

19:37 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

20:13 helgikrs: So, I was playing around with tranducers and this happened.. Does anyone know whats going on here? http://pastebin.com/VfnLtH49

20:32 amalloy: helgikrs: get a real stacktrace, not just the summary message, with (.printStackTrace *e *out*)

20:35 helgikrs: amalloy: http://pastebin.com/0iFut7sa

20:37 Using clojure 1.7.0-alpha4

20:38 amalloy: wow, that is not a very useful stacktracek

20:38 helgikrs: i dunno, looks like a bug to me but i don't do much core.async or transducers

20:43 gfredericks: amalloy: hey now I didn't know about that arg to .printStackTrace that is potentially useful

20:43 (inc amalloy)

20:43 lazybot: ⇒ 202

20:44 amalloy: gfredericks: it's the only way to avoid the insanity that is (pst) if your stdout is not where you want things printed

20:44 gfredericks: you bet it isn't

20:44 I actually use pst most of the time and do okay though

20:45 I just have to pass it large numbers

20:46 amalloy: doesn't it still do that horrible thing with trying to print just the root cause?

20:46 ~def clojure.repl/pst

20:48 yeah. you have to pass it an exception *and* a number to get non-evil behavior

20:50 gfredericks: amalloy: I haven't really had to think about the details yet

20:50 I often dig into exceptions myself though

20:53 test: hi there. I'm looking at lazy sequences, for example. I can roughly see how: (defn fib [a b] (cons a (lazy-seq (fib b (+ b a)))))

20:53 works

20:54 so every time we all fib

20:54 we add a new item onto the end of the list a

20:54 but it's the lazy seq that confuses me

20:55 let's say

20:55 we ran (take 2 (fib 1 1))

20:55 then how exaclty does lazy-seq work here?

20:56 justin_smith: test: it creates a thunk, that is a function of no arguments, that will create the next item, plus in turn another thunk, etc.

20:56 test: how do we cons the second 1 onto the 1 in a?

20:57 justin_smith: test: well, the first args are 1 1, then the next are (fib b (+ b a)) so (fib 1 (+ 1 1))

20:58 test: justin_smith: but how does (fib 1 (+ 1 1) cons 1 into a, to make a new sequence [1 1]?

20:59 justin_smith: test: there is never a sequence [1 1] - we get 1 as the first element (via cons), next time through we get 1 again (1 1 ...)

20:59 thus 1, 1 are the first two elements

20:59 they aren't consed onto anything yet, because the whole thing is lazy

21:00 we just get another item each time we ask for it, and it's calculated if it hasn't been yet

21:02 test: justin_smith: i understand the idea behind lazy-seq, but I'm still not seeing how it works here. Sticking with (take 2 (fib 1 1)), do you agree that it expands to

21:02 (cons 1 (lazy-seq (cons 1 (lazy-seq (fib 1 (3))))))

21:02 justin_smith: that last part is wrong

21:03 test: there shouldn't be another lazy-seq?

21:03 (cons 1 (lazy-seq (cons 1 (lazy-seq (fib 2 (3))))))*

21:03 justin_smith: (cons 1 (lazy-seq (cons 1 (lazy-seq (fib 2 3)))))

21:03 (3) is not valid

21:04 test: (cons 1 (lazy-seq (cons 1 (lazy-seq (fib 2 3))))))*

21:04 justin_smith: right

21:05 we can even do this by hand, replacing fib with list for the moment ##(cons 1 (lazy-seq (cons 1 (lazy-seq (list 2 3)))))

21:05 lazybot: ⇒ (1 1 2 3)

21:05 justin_smith: so going through by hand, we can see how each result is derived from the previous two, right?

21:07 test: thinking..

21:08 why the double # ?

21:08 #(cons 1 (lazy-seq (cons 1 (lazy-seq (list 2 3)))))

21:08 \#(cons 1 (lazy-seq (cons 1 (lazy-seq (list 2 3)))))

21:08 ##(cons 1 (lazy-seq (cons 1 (lazy-seq (list 2 3)))))

21:08 lazybot: ⇒ (1 1 2 3)

21:08 test: ah

21:08 i see

21:08 ##(take 2 (cons 1 (lazy-seq (cons 1 (lazy-seq (list 2 3))))))

21:08 lazybot: ⇒ (1 1)

21:08 justin_smith: the double # is how you get lazy bot to evaluate mid message ##(str "like " "this")

21:08 lazybot: ⇒ "like this"

21:08 test: awesome

21:10 OK i see what is happening. Thanks. But, mapping to what you said before about the thunks... can you elaborate for me

21:10 justin_smith: lazy-seq creates a zero argument function, that gets invoked when you ask for the first item

21:11 and in many cases (including this one) that leads to yet another thunk being created, ad infinitum

21:11 that's just an implementation detail though, that's how it can be lazy

21:11 test: and what does this zero argument function do ?

21:11 justin_smith: the important part is it only calculates as many values as are accessed

21:11 test: i get that

21:12 justin_smith: realizes one more item of the sequence

21:12 test: does this function(void) just bind to the body of the lazy-seq

21:12 justin_smith: it's an implementation detail of lazy-seq

21:12 such that asking for the next item calls that function

21:13 brucehauman: bbloom: it’s an intersting problem

21:16 test: OK. I think I get it. So everytime the thunk is called, it returns the next value and creates another thunk. Out of interest do these subsequent thunks actually store the arguments passed into the thunk (a and b in this case)?

21:17 justin_smith: I think they get captured from the lexical environment

21:17 so they are not args per se

21:17 test: yeah that's a better way of putting it

21:18 understood. Thanks alot :)

21:18 justin_smith: np

21:25 bbloom: $mail brucehauman whoops sorry, missed your message here. yeah -- the cljs build story needs a lot of thinking & elbow grease from multiple parties

21:25 lazybot: Message saved.

21:31 test: Why would this not be valid?

21:31 (map .toUpperCase (str/split "the quick brown fox" #" "))

21:32 amalloy: test: http://stackoverflow.com/questions/2208865/how-do-i-pass-a-static-method-to-comp-in-clojure

21:35 test: amalloy: so I have to use # macro

21:53 mindbender1: (async/go-loop [v 5] (when (pos? v) (println v) (recur (dec v)))) in cljs is reporting "could not resolve var: let"

21:54 *when not *let

22:00 justin_smith: test: you don't strictly need to use #() - you could also use its expansion which is (fn [x] ...), or any of the other constructs that can return a function that invoke a method internally

22:03 domokato: Can I use a namespace alias without core.typed complaining about it?

22:20 gfredericks: domokato: I've only had alias issues when trying to do (t/ann ...) on something from a different namespace

22:20 which I usually only do with libraries or clojure.core stuff

22:43 domokato: I get "No such namespace: pm" when I try to alias primitive-math library as pm

22:43 and run lein typed check

23:06 gfredericks: woah; I didn't know a record could be metadata

23:09 domokato: hm, I'm also getting "No such namespace" for an import; that's weird...maybe something's wrong with my setup

23:09 justin_smith: import?

23:11 I mean, I assume you mean require or maybe the low level refer or alias, but import is a function that does something else entirely

23:19 felixflores: why is debounce not part of core.async core? https://gist.github.com/swannodette/5888989

23:20 Is there something else I should be using?

23:21 I'm aware of dropping-buffer or sliding, etc, but it's not quiet the same as debounce

Logging service provided by n01se.net