#clojure logs

2014-12-07

00:11rritochandyf: 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.
00:14rritochandyf: 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.
00:15justin_smith&(defn days [month] (int (+ 28 (mod (+ month (Math/floor (/ month 8))) 2) (mod 2 month) (* 2 (Math/floor (/ month))))))
00:15lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
00:15justin_smith,(defn days [month] (int (+ 28 (mod (+ month (Math/floor (/ month 8))) 2) (mod 2 month) (* 2 (Math/floor (/ month))))))
00:15clojurebot#'sandbox/days
00:15justin_smith(days 1)
00:15justin_smith,(days 1)
00:15clojurebot31
00:15justin_smith,(days 2)
00:15clojurebot28
00:15justin_smithw00t
00:15justin_smith,(days 8)
00:15clojurebot31
00:16gfredericks,(map days (range 1 13))
00:16clojurebot(31 28 31 30 31 ...)
00:16gfredericks,(apply str (map days (range 1 13)))
00:16clojurebot"312831303130313130313031"
00:16gfredericks(inc justin_smith)
00:16lazybot⇒ 153
00:16gfredericks,(days 93)
00:16clojurebot30
00:16gfredericks,(days 94)
00:16clojurebot31
00:17gfredericks,(filter #(= 28 (days %)) (range 100))
00:17clojurebot#<ArithmeticException java.lang.ArithmeticException: Divide by zero>
00:17justin_smiththis clearly answers some very important questions about hypothetical months of the future
00:17gfredericks,(filter #(= 28 (days %)) (range 1 100))
00:17clojurebot(2)
00:17gfredericks,(filter #(= 28 (days %)) (range -100 0))
00:17clojurebot()
00:18justin_smithgfredericks: I cannot take credit, I merely translated it from this http://cmcenroe.me/2014/12/05/days-in-month-formula.html
00:21gfredericksI bet there's some cool polynomial and/or sinusoidal expressions that could do it too
00:21justin_smithoh yeah!
00:21justin_smithor a weird lindenmayer system
00:22gfredericksI just remembered there's a doohickey on my website for the polynomial part of that
00:28gfredericks,(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)))
00:28clojurebot#'sandbox/days
00:28gfredericks,(map days (range 1 13))
00:28clojurebot(31N 28N 31N 30N 31N ...)
00:28gfredericks,(days 100)
00:28clojurebot-55834893236621534N
00:28gfredericks,(days 0)
00:28clojurebot1416N
00:40amalloygfredericks: it's van gogh wearing a bowler hat, right?
00:46andyfrritoch: moderated. Regarding the learning, as I said, many people have made proposals for changes to Clojure, but only a relatively small fraction are approved.
00:47trot_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?
00:48justin_smith,((fn fName [n [f & r]] {:n n :f f :r r}) 1 [2 3 4 5 6]) ; trot_
00:48clojurebot{:n 1, :f 2, :r (3 4 5 6)}
00:48justin_smithr can be empty
00:48justin_smith,((fn fName [n [f & r]] {:n n :f f :r r}) 1 [])
00:48clojurebot{:n 1, :f nil, :r nil}
00:49justin_smithf and r can be empty, that is
00:50trot_i didn't quite understand your example
00:50justin_smithwhat part?
00:50trot_what's with the curly braces?
00:50justin_smiththat's a map literal
00:50trot_and the 1 []?
00:50justin_smith1 is a number
00:50justin_smith[] is an empty vector
00:50trot_and the 1?
00:50justin_smiththey are the args to the function
00:50trot_oh
00:51trot_so [f & r] binds to []?
00:51trot_maybe binds is the wrong word to use
00:51justin_smithin that case, yes
00:51rritochandyf: 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.
00:51rritochandyf: They didn't like the idea and suggested I switch to LISP
00:51justin_smithtrot_: it destructures [], so f and r both end up nil, as you can hopefully see
00:53rritochandyf: 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.
00:53trot_yes I can. And so the point of writing [f & r] inside its own square parenthesis, is to allow destruction?
00:53rritochandyf: Lack of namespaces is the main reason why I didn't like Lisp, so you can see why I like clojure.
00:54justin_smithtrot_: exactly, because destructuring is more concise than repeatedly using first / rest etc. or using a let block
00:54rritochandyf: 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.
00:55trot_OK. Thanks :) Think that will be all for now. Trying to decipher https://github.com/stuarthalloway/programming-clojure/blob/master/src/examples/primes.clj
00:56justin_smithin context, the f and r stand for first and rest
00:56rritochAs far as I can tell this patch should work with every existing version of clojure so a fork is possibly the best route anyhow.
00:56rritochandyf: I just don't want the extra responsiblity.
00:56justin_smithbecause they get the same contents that (first arg) and (rest arg) would give
00:57andyfDo you have reason to think that others will want the extra responsibility?
00:57nonubyin cljs which is more idiomatic https://www.refheap.com/94511
00:58nonubyline 7 shoud be .-Compon.. not -Compon..
00:58justin_smithnonuby: definitely the first one - but the nil at the outside of the let block is redundant
00:59justin_smith,(let [a 0])
00:59clojurebotnil
00:59nonubyjustin_smith isn't more than one dot following js/ being dropped? (cant remember where read possibly one of david nolen articles)
00:59justin_smithnonuby: oh, not sure
01:00rritochandyf: If this was done for a large company, like Oracle or IBM, it wouldn't be an issue, but my team is VERY small.
01:00justin_smith(-> js/Ext .-ComponentManager .get "contact-form") maybe, in that case
01:01justin_smitherr
01:01justin_smith(-> js/Ext .-ComponentManager (.get "contact-form"))
01:01rritochAnyhow, it's done, it's working so I can finally rest. This was the biggest stumbling block to developing enterprise apps in clojure.
01:02nonubyyeah drawing similar conclusion, i think it looks the cleanest, but like yourself 1st looks best, Id wish they keep js/X.Y.howevermanydots
01:03rritochEverything else needed is already provided by either clojure, clojurescript, or Java.
01:03justin_smithnonuby: are you reading the book that code goes with?
01:03justin_smithoops, I mean trot_
01:04justin_smithtrot_: are you reading the book that code goes with?
01:04trot_yes
01:04trot_Halloway's
01:04justin_smithhow is it?
01:05trot_It's OK. I feel Section 3.3 jumped the gun abit
01:05nonubywhat book?
01:05trot_but most of it is gentle enough
01:05justin_smithnonuby: programming clojure
01:06trot_so far
01:08justin_smithtrot_: 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
01:09trot_am doing / will do :)
01:09jwmquickly get into a repl/editor environment for sure
01:09jwmthat is what made the difference for me
01:11justin_smithI learned a lot from the little one liners people use to demo things with the bots here
01:11justin_smitheven coming from common lisp / scheme experience
01:12jarjar_primeis there a way to get a value out of core.async (go) block? :-)
01:12justin_smithjarjar_prime: you can send the value to a channel that you read elsewhere
01:13justin_smithand the go block, when created, returns a channel that will get the final return value of that block
01:27jarjar_primejustin_smith: there's no <!! in clojurescript though, hmmm
01:32justin_smithperhaps use take! with the on-caller arg
01:33justin_smithI am not sure though
01:33justin_smithyou could also use <! inside another go block (go blocks all the way down...)
01:41trot_stupid question, but if i want to pass parameter into (zero?(rem % 5)), how would I do this
01:41trot_without making it into a function
01:41amalloytrot_: the question doesn't really make sense. how could it have a parameter if it's not a function?
01:42amalloyand why would you want to avoid making a function?
01:42trot_i guess. I was just wondering if there is a fast way of binding % to a value
01:42trot_without writing out fn ...
01:43trot_and then calling the function
01:45rritochtrot_: I think your talking about the promise feature. https://clojuredocs.org/clojure.core/promise
01:45lasergoattrot_: sounds like you want nested #()s?
01:46rritochtrot_: But you still have to pass the promise into the function, so either way your stuck using partial
01:47lasergoator do you just want to do (#(zero? (rem % 5)) 8)
01:48lasergoat(that showed up as an emoticon on my client, was supposed to say 8 )
01:48trot_no i don't think it's as complicated as that. I don't want to have to write
01:48trot_(defn testf [x] (zero?(rem x 3)) )
01:48trot_and then (testf 5)
01:48trot_I just want to do it in one line
01:48trot_write my function and immediately pass it a parameter
01:48trot_like an anonymous
01:49trot_like an anonymous function*
01:49rritochtrot_: lasergoat's code is what you want then
01:49lasergoatyeah, (#(zero? (rem % 3)) 5)
01:49trot_so what exactly does # do/
01:49trot_I think I did read actually
01:50rritoch,(macroexpand '#(inc 1))
01:50clojurebot(fn* [] (inc 1))
01:50lasergoatthat was just shorthand for ((fn [x] (zero? (rem x 3))) 5)
01:51lasergoat#() is just a macro that does that
01:52trot_excellent. thanks
01:53lasergoatnp
01:58trot_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?
01:59andyftrot_: use map in the function definition
01:59andyfor mapv if it needs to be a vector out
02:00andyf,((fn [v] (map #(zero? (rem % 3)) v) [5 1 3])
02:00clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
02:01lasergoatwell, you want to map the whole thing, not bake it into the function, right? (map #(zero? …) [5 1 3])
02:01dagda1_is there a more concise way to construct this regex than (re-find (re-pattern (str #"\b" className #"\b")) "fade in")
02:01lasergoat,(map #(zero? (rem % 3)) [5 1 3])
02:01clojurebot(false false true)
02:02lasergoat,(mapv #(zero? (rem % 3)) [5 1 3])
02:02clojurebot[false false true]
02:02nonubydagda1_ doesn that create a "\b" regex and then stringify it (seems inefficient)
02:03nonuby(type #"\b")
02:03nonubycheaper to "\\b"?
02:04andyfnonuby: Depends on whether you want cheaper in terms of typing fewer backslashes, which dagda1_'s expression achieves.
02:04trot_andyf: I tried (#(map #(zero? (rem % 3)) v) [1 2]) but that isn't quite correct
02:04andyftrot_: #() expressions cannot be nested
02:04trot_so I would need to fn [] here?
02:04andyfYou can use (fn [args] forms-here) with one or more #() inside, but not nested
02:05andyfI mean (fn ...) can be nested, but #() cannot be.
02:05nonubyat 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?
02:05lasergoattrot_: i’m not sure why ou want a function at all, though; you can just call map
02:05trot_but you nest fn [], right?
02:06andyffn can be nested, yes
02:06lasergoatyou can, yeah
02:06trot_lasergoat: can you give me an example?
02:07lasergoatof nested fns or of why you don’t need it here?
02:07trot_oh
02:07trot_you did
02:07lasergoat:)
02:08andyfdagda1_: 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.
02:08TEttinger,(re-find (re-pattern (str "\\b" "fade" "\\b")) "fade in")
02:08clojurebot"fade"
02:09trot_:)
02:09andyfleading and trailing *pieces of the regex pattern*, not "backslashes"
02:09TEttingerstringifying strings should be easier to work with
02:09trot_thanks all
02:10andyfTEttinger: #"this syntax" is really nice for avoiding typing double backslash characters in regular strings, and many regex patterns have a significant number of htem.
02:10TEttingeryep
02:10nonubyandyf, agreed, but using it in (str ...) simply stringifies the pattern, before building a another pattern, pattern -> string -> pattern,
02:11trot_line 14, https://github.com/stuarthalloway/programming-clojure/blob/master/src/examples/primes.clj, where does the primes symbol come from?
02:12TEttingerline 7, trot_
02:12lasergoati 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”)
02:12TEttingerit's recursive
02:12andyfdagda1_: 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
02:13nonubyi doubt it, a proper reader for quoted stuff would be nice though, also you better hope java.regex.Pattern .toString() isnt doing anything special
02:13andyfThe \Q and \E cause the className to be matched literally
02:13dagda1_I think I'll just go with what I have, thanks guys
02:13trot_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?
02:14TEttingertrot_, it's preferable but this isn't a function
02:14trot_Clearly I was wrong, so what is the point of recur here then?
02:15TEttingerthere is a fn in there though
02:15nonubydoesnt lazy-seq perform some macro magic though to avoid any stackoverflow caused by recursion
02:16TEttingerwhat stuart's doing is some unusual lazyseq thing that involves referencing earlier points in the lazyseq (defined as primes) to get later ones
02:16TEttingerI am not a math guy so I won't try to understand how he's generating primes
02:27lasergoatis 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]]
02:28lasergoat(my luck with inserting accidental emoticons continues unabaited)
02:31trot_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)?
02:33TEttingerwheel is bound to the infinite lazy seq produced by cycle
02:33pdkspin to win
02:33lasergoatthe structure there is (let [primes-fn (fn …) wheel (cycle…)]
02:34Rhainur1I'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
02:34Rhainur1 "base.html" {:content "home.html"}) and that's not working
02:34lasergoatso the fn is bound to primes-fn and (cycle…) is bound to wheel
02:37trot_lasergoat: oh yeah, i read wheel and a function with argument cycle... body is resisting this list processing malarkey
02:37trot_:
02:37trot_:)
02:39Rhainur1nope, 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
03:11lodinAnyone 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.)
03:12lodinI currently use expectations with autexpect and/or speclj with its auto mode.
03:36pepijndevosHow do transients work? Since the transient function call is constant time, and does not modify the original collection...
03:38pepijndevosSo I asume that the initial assoc! will do some path-copying, and that subsequent modifications to the same chunk are mutations?
03:39pepijndevosIn 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.
03:53amalloypepijndevos: hypirion has a series of articles on transients
03:56amalloyi 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
04:11pepijndevosamalloy, it might not be slower, but it will not be a lot faster either.
04:36Morgawr76
04:36Morgawr~,
04:36clojurebotexcusez-moi
04:36Morgawrwhoops
04:36Morgawrsorry, I lagged
04:36Audioburnhi
04:37Morgawranyhow 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?
06:12gargamlHi! 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
06:12gargamldoes anyone try it lately?
06:36profilis it possible to have an inserted ordered map? so I can append keys to the end?
06:38deadghostprofil, array map
06:39profildeadghost: and using assoc to append?
06:41deadghostactually profil ignore me it might be ordered map
06:42deadghostnope array map seems correct
06:47deadghostprofil, https://github.com/flatland/ordered
06:47deadghostdoes that look like what you want?
07:06profildeadghost: maybe..
07:07profildeadghost: how would I use merge or conj to append maps but not overwrite existing values? is it even possible?
07:12deadghostprofil, uhh what kind of map
07:12deadghostand of course it's possible
07:13deadghostat most you just write a function that checks if the key exists before whatever you're doing
07:16deadghostprofil, in the case of merge it says "If a key occurs in more than one map, the mapping from
07:16deadghostthe latter (left-to-right) will be the mapping in the result."
07:17profildeadghost: I want the behaviour of (merge b a), but the keys in b should not be updated if they exist in a
07:17profilhmm
07:17deadghostprofil, uhh (merge a b) instead?
07:17profiland I want the keep the order of the keys
07:18deadghostwhat kind of map is this?
07:18profilarray-map?
07:18deadghostyou might want to check if it maintains order
07:19deadghostsince I've read if you assoc it 10+ times it might turn into a hash map
07:19deadghostif it does you might want to use that lib I linked
07:19deadghostor just use it anyways
07:25profildeadghost: alright, the documentations is a bit minimal, but can I use merge with ordered-map?
07:26deadghostprofil, idk try it
07:29deadghostprofil, if it doesn't it looks like assoc works
07:29deadghostand it's not hard to write your own merge from there
07:54wirrbelI am using lein ring for a pet project for learning clojure. Can I make it autoreload upon source code changes?
07:54wirrbelusing `lein run`
07:58deadghostwirrbel, short answer is yes
07:59deadghostslightly longer answer is I don't remember how I have it set up
08:14wirrbelI found http://howardlewisship.com/io.aviso/documentation/rook/dev.html
08:19hellofunkin Om is it possible render and HTML string as actual HTML?
08:19hellofunk*an HTML string...
08:20deadghosthellofunk, you can also try #clojurescript
08:29hellofunkfound the solution: https://github.com/swannodette/om/wiki/Documentation#props
08:54hyPiRionpepijndevos: Transients are usually more efficient at bulk popping, bulk pushing and sequential updates, so yeah, you're right – They're copied at first modification
08:55hyPiRionpepijndevos: http://hypirion.com/musings/understanding-clojure-transients for the blogpost
08:56hyPiRion*and yeah
09:07lnostdalhttps://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?
09:08lnostdaloh, wait ...it is; sorry ..i'm blind
09:39justin_smithprofil: ##(doc merge-with)
09:39lazybot⇒ "([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)."
09:40justin_smithdeadghost: 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
09:48wirrbeljustin_smith: thank you
09:48wirrbelI have now refactored the code to use lein ring
09:48wirrbeljustin_smith:
09:49wirrbelsry
11:07eraserhdSo, are there any conventions other than 'wrap-*' for naming middleware functions?
11:07justin_smithensure-*
11:08justin_smithcheck-*
11:08eraserhdhrmm
11:09eraserhdI think I should probably have my own convention for this project, then.
11:11justin_smithhow 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:52FriedBobFunny how often when you get ready to ask for help on something, you find the answer
12:53justin_smiththe best one is figuring out the answer in the phrasing of your question
12:55FriedBobI 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:56justin_smiththe answer is likely reduce, if you have some sequence to step over
13:11david56789Hello! 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:12justin_smithdavid56789: ProcessBuilder returns a Process
13:12justin_smithProcess has a .getInputStream that gives you stdout
13:12justin_smith.getErrorStream that gives you stderr
13:13justin_smith.getOutputStream that gives you stdin
13:13justin_smithcheck out the javadoc for java.lang.Process
13:13justin_smith$javadoc java.lang.Process
13:13lazybothttp://docs.oracle.com/javase/6/docs/api/java/lang/Process.html
13:13david56789oh my I'm dumb
13:14david56789I read this line:
13:14david56789If the standard output of the subprocess has been redirected using ProcessBuilder.redirectOutput then this method will return a null input stream.
13:14david56789and thought it always returned a null input stream
13:14david56789Thank you!
13:14justin_smithnp
13:50FriedBobjustin_smith: It looks like reduce will be what I want.. once I figure out he functions to grab the individual oices I need
15:27FrozenlockCan you make a multi arity function with `fn'?
15:27justin_smithabsolutely
15:28FrozenlockAr, I forgot to say that it would be calling itself...
15:28Frozenlocksomething like that ---> (defn my-fn ([x] (my-fn x nil)) ([x y] (str x y)))
15:29justin_smith,(map #(apply (fn ([_] :ONE) ([_ _] :TWO) ([_ _ _] :AH-AH-AH)) %) [[0] [0 0] [0 0 0]])
15:29clojurebot(:ONE :TWO :AH-AH-AH)
15:29justin_smithFrozenlock: (fn my-fn ...)
15:29justin_smiththen it can invoke itself by my-fn
15:30Frozenlockoh wow, I never noticed you could name a fn function o_O
15:31FrozenlockThat would work, thank you very much.
15:32justin_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:32lazybot⇒ (0 0 0)
15:48Rhainur1can someone help me set up cemerick/friend in a luminus app?
15:54gfredericks&((fn self [] self)) ;; function that returns itself
15:54lazybot⇒ #<sandbox6330$eval14481$self__14482 sandbox6330$eval14481$self__14482@7edce77f>
15:54justin_smithRhainur1: have you seen this? http://clojure-yap.blogspot.com/2013/07/setting-up-friend-few-preliminaries.html
15:55Bronsa,((((((fn self [] self))))))
15:55clojurebot#<sandbox$eval25$self__26 sandbox$eval25$self__26@19d8fc2>
15:56justin_smith&((((fn nf [] (fn [] nf))))) ; another variation
15:56lazybot⇒ #<sandbox6330$eval14492$nf__14493$fn__14494 sandbox6330$eval14492$nf__14493$fn__14494@2b7359cf>
15:57Rhainur1justin_smith: yep, but it kinda leaves out a lot. the documentation on github also assumes a lot of knowledge
15:58justin_smithRhainur1: the code in that example should be enough to actually run everything
15:58justin_smithor very close to it
15:59justin_smiththat said, I find friend tricky to understand as well
17:17l3dxhow can I define a function in the user namespace so that it is available from the REPL?
17:17zarkonehello 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:17justin_smithl3dx: all funcitons are available in the repll if you use require
17:17justin_smith*repl *functions
17:17justin_smith*repl *functions
17:17justin_smith*repl *functions
17:17justin_smith*repl *functions
17:18justin_smith*repl *functions
17:18justin_smith*repl *functions
17:18justin_smith*repl *functions
17:18justin_smith*repl *functions
17:18justin_smith(sorry!)
17:18l3dx:)
17:18l3dxyes, I know. what I meant was how can I define a utility function for later use?
17:18justin_smith,(require '[clojure.string :as string])
17:18clojurebotnil
17:18l3dxmaybe it isn't a good idea
17:19l3dxwas thinking of adding some aliases for cljs repl and such
17:19justin_smithl3dx: 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:20justin_smithyou could also define an injection to automatically :use that ns in profiles.clj (similar to what lein does with clojure.repl)
17:25munderwoHI 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:27dnolen_munderwo: I would just set a breakpoint in a debugger
17:27munderworight.. and see the call stack?
17:28l3dxjustin_smith: thanks, sounds good
17:28dnolen_munderwo: yes
17:29munderwohm… the only things in the call stack are anonymous functions. Im using source maps, does that all work correctly
17:30dnolen_munderwo: sourcemaps work
17:30munderwoahhh I worked it out. Its because its a ‘def’ not a ‘defn’ its being evaluated at load time. *faceplam*
17:31justin_smithl3dx: maybe this is what you want? https://github.com/palletops/lein-shorthand
17:31dnolen_munderwo: speaking of which I realized JavaScript "debugger;" is pretty useful
17:31dnolen_I just added a js-debugger macro to master
17:31munderwoand 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:31munderwooooh….
17:32munderwoyeah 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:32munderwoNow if only the console would work with cljs :)
17:34munderwoOoohhh… 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:34munderwodnolen_: what does the js-debugger macro do?
17:37kenrestivohuh, 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:39justin_smithkenrestivo: the compiler can't prove you wouldn't rebind the var
17:40justin_smithvar's make all kind of static analysis hard to do
17:40justin_smith*vars
17:40justin_smithkenrestivo: eastwood will check stuff like that though
17:40kenrestivoooh, good catch, thanks
17:41justin_smitheastwood is underappreciated
17:46munderwojustin_smith: is there something like eastwood or kibit for clojurescript? or can they run on clojurescript code bases as well>
17:47justin_smithmunderwo: not sure, actually
17:47munderwothe readme for eastwood doesnt mention clojurescript AFAIKT
17:59dnolen_munderwo: sets a breakpoint
18:00munderwooh nicde.
18:00munderwo*nide
18:00munderwo*curses his ability to use a keyboard*
18:00munderwo*nice
18:32kenrestivoeastwood found two nasty bugs that would have shown up at runtime, but which compiler did not catch
18:32kenrestivo(inc eastwood)
18:32lazybot⇒ 3
19:22domokatoanyone use the core.typed library?
19:37kenrestivo~anyone
19:37clojurebotJust 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:13helgikrsSo, I was playing around with tranducers and this happened.. Does anyone know whats going on here? http://pastebin.com/VfnLtH49
20:32amalloyhelgikrs: get a real stacktrace, not just the summary message, with (.printStackTrace *e *out*)
20:35helgikrsamalloy: http://pastebin.com/0iFut7sa
20:37helgikrsUsing clojure 1.7.0-alpha4
20:38amalloywow, that is not a very useful stacktracek
20:38amalloyhelgikrs: i dunno, looks like a bug to me but i don't do much core.async or transducers
20:43gfredericksamalloy: hey now I didn't know about that arg to .printStackTrace that is potentially useful
20:43gfredericks(inc amalloy)
20:43lazybot⇒ 202
20:44amalloygfredericks: it's the only way to avoid the insanity that is (pst) if your stdout is not where you want things printed
20:44gfredericksyou bet it isn't
20:44gfredericksI actually use pst most of the time and do okay though
20:45gfredericksI just have to pass it large numbers
20:46amalloydoesn't it still do that horrible thing with trying to print just the root cause?
20:46amalloy~def clojure.repl/pst
20:48amalloyyeah. you have to pass it an exception *and* a number to get non-evil behavior
20:50gfredericksamalloy: I haven't really had to think about the details yet
20:50gfredericksI often dig into exceptions myself though
20:53testhi 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:53testworks
20:54testso every time we all fib
20:54testwe add a new item onto the end of the list a
20:54testbut it's the lazy seq that confuses me
20:55testlet's say
20:55testwe ran (take 2 (fib 1 1))
20:55testthen how exaclty does lazy-seq work here?
20:56justin_smithtest: it creates a thunk, that is a function of no arguments, that will create the next item, plus in turn another thunk, etc.
20:56testhow do we cons the second 1 onto the 1 in a?
20:57justin_smithtest: well, the first args are 1 1, then the next are (fib b (+ b a)) so (fib 1 (+ 1 1))
20:58testjustin_smith: but how does (fib 1 (+ 1 1) cons 1 into a, to make a new sequence [1 1]?
20:59justin_smithtest: 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:59justin_smiththus 1, 1 are the first two elements
20:59justin_smiththey aren't consed onto anything yet, because the whole thing is lazy
21:00justin_smithwe just get another item each time we ask for it, and it's calculated if it hasn't been yet
21:02testjustin_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:02test(cons 1 (lazy-seq (cons 1 (lazy-seq (fib 1 (3))))))
21:02justin_smiththat last part is wrong
21:03testthere shouldn't be another lazy-seq?
21:03test(cons 1 (lazy-seq (cons 1 (lazy-seq (fib 2 (3))))))*
21:03justin_smith(cons 1 (lazy-seq (cons 1 (lazy-seq (fib 2 3)))))
21:03justin_smith(3) is not valid
21:04test(cons 1 (lazy-seq (cons 1 (lazy-seq (fib 2 3))))))*
21:04justin_smithright
21:05justin_smithwe 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:05lazybot⇒ (1 1 2 3)
21:05justin_smithso going through by hand, we can see how each result is derived from the previous two, right?
21:07testthinking..
21:08testwhy the double # ?
21:08test#(cons 1 (lazy-seq (cons 1 (lazy-seq (list 2 3)))))
21:08test\#(cons 1 (lazy-seq (cons 1 (lazy-seq (list 2 3)))))
21:08test##(cons 1 (lazy-seq (cons 1 (lazy-seq (list 2 3)))))
21:08lazybot⇒ (1 1 2 3)
21:08testah
21:08testi see
21:08test##(take 2 (cons 1 (lazy-seq (cons 1 (lazy-seq (list 2 3))))))
21:08lazybot⇒ (1 1)
21:08justin_smiththe double # is how you get lazy bot to evaluate mid message ##(str "like " "this")
21:08lazybot⇒ "like this"
21:08testawesome
21:10testOK i see what is happening. Thanks. But, mapping to what you said before about the thunks... can you elaborate for me
21:10justin_smithlazy-seq creates a zero argument function, that gets invoked when you ask for the first item
21:11justin_smithand in many cases (including this one) that leads to yet another thunk being created, ad infinitum
21:11justin_smiththat's just an implementation detail though, that's how it can be lazy
21:11testand what does this zero argument function do ?
21:11justin_smiththe important part is it only calculates as many values as are accessed
21:11testi get that
21:12justin_smithrealizes one more item of the sequence
21:12testdoes this function(void) just bind to the body of the lazy-seq
21:12justin_smithit's an implementation detail of lazy-seq
21:12justin_smithsuch that asking for the next item calls that function
21:13brucehaumanbbloom: it’s an intersting problem
21:16testOK. 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:17justin_smithI think they get captured from the lexical environment
21:17justin_smithso they are not args per se
21:17testyeah that's a better way of putting it
21:18testunderstood. Thanks alot :)
21:18justin_smithnp
21:25bbloom$mail brucehauman whoops sorry, missed your message here. yeah -- the cljs build story needs a lot of thinking & elbow grease from multiple parties
21:25lazybotMessage saved.
21:31testWhy would this not be valid?
21:31test(map .toUpperCase (str/split "the quick brown fox" #" "))
21:32amalloytest: http://stackoverflow.com/questions/2208865/how-do-i-pass-a-static-method-to-comp-in-clojure
21:35testamalloy: so I have to use # macro
21:53mindbender1(async/go-loop [v 5] (when (pos? v) (println v) (recur (dec v)))) in cljs is reporting "could not resolve var: let"
21:54mindbender1*when not *let
22:00justin_smithtest: 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:03domokatoCan I use a namespace alias without core.typed complaining about it?
22:20gfredericksdomokato: I've only had alias issues when trying to do (t/ann ...) on something from a different namespace
22:20gfrederickswhich I usually only do with libraries or clojure.core stuff
22:43domokatoI get "No such namespace: pm" when I try to alias primitive-math library as pm
22:43domokatoand run lein typed check
23:06gfrederickswoah; I didn't know a record could be metadata
23:09domokatohm, I'm also getting "No such namespace" for an import; that's weird...maybe something's wrong with my setup
23:09justin_smithimport?
23:11justin_smithI 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:19felixfloreswhy is debounce not part of core.async core? https://gist.github.com/swannodette/5888989
23:20felixfloresIs there something else I should be using?
23:21felixfloresI'm aware of dropping-buffer or sliding, etc, but it's not quiet the same as debounce