#clojure logs

2014-11-22

00:00justin_smithmarcuscreo: it's about midnight on a friday there, you may not find many people who are there on irc
00:00cflemingmarcuscreo: I'm at the conj, but just about to go to bed.
00:01ambrosebscfleming: great talk
00:01cflemingambrosebs: Thanks!
00:01cflemingambrosebs: You're not at the conj, right?
00:01ambrosebscfleming: right
00:02cflemingambrosebs: Actually, I wondered if I'd find you at the Scheme workshop these days :-)
00:02ambrosebscfleming: I had too many conferences lately to even consider it
00:03cflemingambrosebs: Bummer, would have been cool to meet up.
00:03ambrosebsyea definitely
00:10ffwacompeople not smiling in photos is going to be a trend
00:10ffwacomfuck wrong channel
00:22holohi
00:23holojabba question: what's this {} in → 'new ConstraintMapping[] { cm }' and how to interop with it?
00:25amalloyjabbslad: that's a single-element array, whose only element is cm
00:25amalloyer
00:25amalloysorry, holo
00:25holoamalloy, i see
00:28holoI just noticed state of clojure didn't ask if programmer has any java background
00:30holo(inc amalloy)
00:30lazybot⇒ 198
00:30holoinc could have print side effects saying "thanks"
01:08teajoeHey all! When I println, I'm seeing this: #<core$rsc_files boot.core$rsc_files@5401e235>
01:08teajoeis this a java obj?
01:09TEttingeryou are printing some object that doesn't have a toString implemented apparently
01:09TEttingerwhat are you passing to println?
01:10teajoesome object from boot-clj
01:11teajoethey call a juxt with (memfn getPath) on it, so its probably some file object
01:11teajoebut for future reference can i get type info on such a thing
01:17marcuscreo_(+ 1 2 3)
01:17clojurebot*suffusion of yellow*
01:17marcuscreo_(println ‘here")
01:18marcuscreo(+1 2 3)
01:18marcuscreo(+ 1 2 3)
01:18clojurebot*suffusion of yellow*
01:18justin_smithhttp://stackoverflow.com/questions/3987428/what-is-an-initialization-block
01:19justin_smitherr
01:19justin_smithhttp://www.urbandictionary.com/define.php?term=A%20Suffusion%20of%20Yellow that is the one I was looking for
02:05rritochI'm not sure if this is a bug or not, but clojure regular expresions aren't matching #"\s+" to non-breaking spaces... Does anyone know how I can change this to match any whitespace including nonbreaking spaces?
02:09ivanrritoch: stackoverflow says 'It's a non-breaking space. According to the Pattern Javadocs, \\s matches [ \t\n\x0B\f\r], so you'll have to explicitly add \xA0 to your regex if you want to match it.'
02:10rritochivan: Ok, thanks.
02:11rritochivan: Ok #"[\s\xA0]+" worked
02:12rritoch(inc ivan)
02:12lazybot⇒ 1
02:17dysfunwow. after fighting the swift build process for two days, i have a whole new appreciation for clojure
02:17dysfunalso leiningen
02:25TEttingerif you want to be really in-depth, rritoch:
02:25TEttinger,(re-seq #"\pZ|[\f\t\r\n\u000b]" "good\u00a0job !\f\t\r\n\u000b\u3000\u200a")
02:25clojurebot(" " " " "\f" "\t" "\r" ...)
02:25TEttinger\pZ is the category of all unicode separator characters that aren't also control chars
02:26TEttingerso space, nbsp, ideographic space in the CJK asian character block
02:26TEttingerseveral others
02:27TEttinger\f form feed, \r carriage return, \n line feed, \t horizontal tab, \u000b vertical tab don't count for some reason
02:32justin_smithwow - first time ever, I think I deadlocked my repl
02:32justin_smithword of advice - using (locking *out* ...) inside pmap is probably a bad idea
02:32mj-0what is regex for separating words of any language?
02:33rritochTEttinger: Thanks, that was helpful. I changed it to #"(\pZ|\s)+" which seems to be working
02:33luxbockI don't think there exists one for a lot of languages
02:33TEttingerah, that works rritoch!
02:33mj-0I tried "\W+" but for other languages its not working.
02:33TEttingermj-0: in chinese writing, you often don't have spaces at all between characters, right?
02:34TEttingeralso, \w is not so good, it only recognizes latin script
02:34TEttingeryou can use \b to get a word boundary using \w rules, IIRC
02:34mj-0TEttinger: yeah. it doesn't matter to me. I just want to split words.
02:34justin_smithsome info here http://www.regular-expressions.info/unicode.html
02:35luxbockin Thai you separate sentences with a space, but there's nothing that tells you when a word ends other than recognizing what that word is and what its last character is
02:35TEttingerah cool! Java supports Unicode for \b but not for \w.
02:35TEttingerhttp://www.regular-expressions.info/wordboundaries.html
02:35justin_smithnice, just a jump away from the one I found
02:36TEttingerI should bookmark regular-expressions.info's unicode page, it's so helpful
02:36TEttingerthat and just DDG searching for stuff like "feff unicode"
02:37TEttingerhttps://duckduckgo.com/?q=feff+unicode
02:40TEttingerhere's some sinhala that I can't read or print correctly
02:40TEttinger,(re-seq #"\b" "බුදුරජාණන් වහන්සේගේ දන්තධාතූන්")
02:40clojurebot("" "" "" "" "" ...)
02:40TEttingererr
02:41TEttinger&(re-seq #"\B+" "බුදුරජාණන් වහන්සේගේ දන්තධාතූන්")
02:41lazybot⇒ ("" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "")
02:41TEttingererrrrrr
02:41justin_smithTEttinger: yeah, I was trying to make re-seq work with \B / \b and couldn't
02:41justin_smitheven with ascii
02:41TEttinger&(re-seq #"\b.+\b" "බුදුරජාණන් වහන්සේගේ දන්තධාතූන්")
02:41lazybot⇒ ("බුදුරජාණන් වහන්සේගේ දන්තධාතූන්")
02:41TEttinger&(re-seq #"\b.+?\b" "බුදුරජාණන් වහන්සේගේ දන්තධාතූන්")
02:41lazybot⇒ ("බුදුරජ" "ා" "ණන්" " " "වහන්ස" "ේ" "ග" "ේ " "දන්තධ" "ා" "තූන්")
02:41TEttingerthere we go
02:42justin_smithwoah, black magic
02:42TEttinger&(re-seq #"\b.+?\b" "The Quick brown fox jump'd ov'r the lazy dog.")
02:42lazybot⇒ ("The" " " "Quick" " " "brown" " " "fox" " " "jump" "'" "d" " " "ov" "'" "r" " " "the" " " "lazy" " " "dog")
02:42justin_smithTEttinger: speaking of black magic, did you see when SagiCZ1 had a problem with a dataset that got a huge number of boms inserted into the middle of files
02:43justin_smithhe was trying to parse it and getting maddening bugs
02:43justin_smithTEttinger: but thanks to your foolery, I was quickly able to identify his problem
02:43TEttingerlol
02:43TEttingerI did remember that
02:43justin_smith"oh, that's just that thing TEttinger does"
02:43TEttingerhaha
02:43mj-0(re-seq #"\W+\b" "බුදුරජාණන් වහන්සේගේ දන්තධාතූන්")
02:44TEttinger,(let ["even number of forms, eh?" "let's make it even" "or not"])
02:44clojurebot"or not"
02:44TEttingermj-0: \W won't work
02:44justin_smithmj-0: use , or & if you want a bot to evaluate it
02:44TEttingerit finds non-word chars but only knows ascii
02:44mj-0TEttinger: got it.
02:44mj-0&(re-seq #"\W+\b" "බුදුරජාණන් වහන්සේගේ දන්තධාතූන්")
02:44lazybot⇒ ("බුදුරජාණන් වහන්සේගේ දන්තධාතූන්")
02:45mj-0ohh this regex is working for some of the languages
02:45rritochSomeone should petition the international criminal courts to make it a crime to use anything other than UTC
02:45justin_smithhaha
02:45TEttinger&(re-seq #"\b(\S|\PZ)+?\b" "The Quick brown fox jump'd ov'r the lazy dog.")
02:45lazybot⇒ (["The" "e"] ["Quick" "k"] ["brown" "n"] ["fox" "x"] ["jump" "p"] ["'" "'"] ["d" "d"] ["ov" "v"] ["'" "'"] ["r" "r"] ["the" "e"] ["lazy" "y"] ["dog" "g"])
02:46TEttinger&(re-seq #"\b(?:\S|\PZ)+?\b" "The Quick brown fox jump'd ov'r the lazy dog.")
02:46lazybot⇒ ("The" "Quick" "brown" "fox" "jump" "'" "d" "ov" "'" "r" "the" "lazy" "dog")
02:46TEttingerthat looks good
02:46justin_smithrritoch: I was contracting for a company in England recently, and it was actually kind of cool to be keeping UTC hours. It felt authoritative :)
02:46justin_smithrritoch: I reset my computer clock to UTC and everything
02:46TEttinger&(re-seq #"\b(?:\S|\PZ)+?\b" "The Quick brown fox jump'd ov'r the lazy dog. බුදුරජාණන් වහන්සේගේ දන්තධාතූන්")
02:46lazybot⇒ ("The" "Quick" "brown" "fox" "jump" "'" "d" "ov" "'" "r" "the" "lazy" "dog" "බුදුරජ" "ා" "ණන්" "වහන්ස" "ේ" "ග" "දන්තධ" "ා" "තූන්")
02:47TEttingerslick
02:47justin_smith~unicode-wordsplit is #"\b(?:\S|\PZ)+?\b"
02:47clojurebotIn Ordnung
02:47justin_smith~unicode-wordsplit
02:47clojurebotunicode-wordsplit is #"\b(
02:47TEttingerawww
02:47justin_smith:P
02:47TEttingerit doesn't like facts with ?
02:48TEttinger~unicode-wordsplit is just ask TEttinger
02:48clojurebotA nod, you know, is as good as a wink to a blind horse.
02:49justin_smith$learn unicode-wordsplit is #"\b(?:\S|\PZ)+?\b"
02:49lazybotMy memory is more powerful than M-x butterfly. I won't forget it.
02:49justin_smith$whatis unicode-wordsplit
02:49lazybotunicode-wordsplit is is #"\b(?:\S|\PZ)+?\b"
02:49justin_smith(inc lazybot)
02:49lazybot⇒ 36
02:49rritochjustin_smith: Thats cool, I'm in SGT (GMT+8) So at least my development machine has a stable time to work with. I saw in the news that Russia just changed their time system again and I swear they're doing it just to cause trouble for programmers.
02:50rritochEither way, any code dealing with dates properly is virtually incomprehensible now.
02:51mj-0TEttinger: #"\b.+?\b" this also returns spaces, special characters. How can I get only words?
02:51mj-0&(re-seq #"\b.+?\b" " Çarşi En büyük BEŞİKTAŞ gerisi yalan oyunda. super, otesi inanilmaz sariyor Yorumun Tamamı")
02:51lazybot⇒ ("Çarşi" " " "En" " " "büyük" " " "BEŞİKTAŞ" " " "gerisi" " " "yalan" " " "oyunda" ". " "super" ", " "otesi" " " "inanilmaz" " " "sariyor" " " "Yorumun" " " "Tamamı")
02:52TEttinger&(re-seq #"\b(?:\S|\PZ)+?\b" " Çarşi En büyük BEŞİKTAŞ gerisi yalan oyunda. super, otesi inanilmaz sariyor Yorumun Tamamı")
02:52lazybot⇒ ("Çarşi" "En" "büyük" "BEŞİKTAŞ" "gerisi" "yalan" "oyunda" "super" "otesi" "inanilmaz" "sariyor" "Yorumun" "Tamamı")
02:52TEttingerbetter?
02:52mj-0TEttinger: Yep. Looks better now. Thanks!
02:52TEttingerit will still return apostrophes as a separate thing
02:53TEttingerthe meaning of that particular regex: word boundary, followed by at least one non-space, non-separator character, then another word boundary
02:54TEttingeralso, do not store the group of non-space chars, that's what (?:) does
02:54mj-0TEttinger: Okay. I'll look into it.
02:55TEttingerhope it helps!
03:05rritoch,(as-> (java.util.Calendar/getInstance) c (.setTime (int 0)) c)
03:05clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: setTime for class java.lang.Integer>
03:05rritoch,(as-> (java.util.Calendar/getInstance) c (.setTime c (int 0)) c)
03:05clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Date>
03:06rritoch,(as-> (java.util.Calendar/getInstance) c (.setTime (java.util.Date 0)) c)
03:06clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn>
03:06rritoch,(as-> (java.util.Calendar/getInstance) c (.setTime (java.util.Date. 0)) c)
03:06clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: setTime for class java.util.Date>
03:06rritochBa, I just can't win this one
03:08rritoch,(as-> (java.util.Calendar/getInstance) c (.setTime c (java.util.Date. 0)) c)
03:08clojurebotnil
03:08TEttinger,(doto (java.util.Calendar/getInstance) (.setTime (java.util.Date 0)))
03:08clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn>
03:09rritochOk, thats better, how do I get this to return the modified calendar object?
03:09TEttinger,(doto (java.util.Calendar/getInstance) (.setTime (java.util.Date. 0)))
03:09clojurebot#inst "1970-01-01T00:00:00.000+00:00"
03:09TEttingerthere we go
03:09clojurebotHuh?
03:09rritochaah, doto, cool
03:13rritoch,(doto (java.util.Calendar/getInstance) (.setTime (.parse (java.text.SimpleDateFormat. "MM/dd/yyyy") "11/22/2014")))
03:13clojurebot#inst "2014-11-22T00:00:00.000+00:00"
03:13rritochCool, exactly what I need
03:19rritochDoes clojure automatically compare calendar dates correctly?
03:21rritoch,(> (doto (java.util.Calendar/getInstance) (.setTime (java.util.Date. 1))) (doto (java.util.Calendar/getInstance) (.setTime (java.util.Date 0))))
03:21clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn>
03:21rritoch,(> (doto (java.util.Calendar/getInstance) (.setTime (java.util.Date. 1))) (doto (java.util.Calendar/getInstance) (.setTime (java.util.Date. 0))))
03:21clojurebot#<ClassCastException java.lang.ClassCastException: java.util.GregorianCalendar cannot be cast to java.lang.Number>
03:21rritochHmm, guess not
03:23TEttinger,(compare (doto (java.util.Calendar/getInstance) (.setTime (java.util.Date. 1))) (doto (java.util.Calendar/getInstance) (.setTime (java.util.Date. 0))))
03:23clojurebot1
03:24TEttinger,(compare (doto (java.util.Calendar/getInstance) (.setTime (java.util.Date. 1))) (doto (java.util.Calendar/getInstance) (.setTime (java.util.Date. 2))))
03:24clojurebot-1
03:24TEttingerso compare works
03:25rritochTEttinger: Cool, I've never run into compare before, but that's a better option than where I was heading :)
03:25TEttinger(doc compare)
03:25clojurebot"([x y]); Comparator. Returns a negative number, zero, or a positive number when x is logically 'less than', 'equal to', or 'greater than' y. Same as Java x.compareTo(y) except it also works for nil, and compares numbers and collections in a type-independent manner. x must implement Comparable"
03:28rritochdoto + compare almost makes this code readable :)
03:32rritoch,(as-> 1 n (min (compare n 5) (compare 10 n))
03:32clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
03:33rritoch,(as-> 1 n (min (compare n 5) (compare 10 n)))
03:33clojurebot-1
03:33rritoch,(as-> 5 n (min (compare n 5) (compare 10 n)))
03:33clojurebot0
03:33rritoch,(as-> 10 n (min (compare n 5) (compare 10 n)))
03:33clojurebot0
03:33rritoch,(as-> 20 n (min (compare n 5) (compare 10 n)))
03:33clojurebot-1
03:33justin_smith,(compare [1 2] [1 3])
03:33clojurebot-1
03:33justin_smith:)
03:33rritochI want to check if a date is in a range
03:34justin_smithyeah, compare should work directly on date
03:34justin_smith,(compare (java.util.Date.) (java.util.Date.))
03:34clojurebot0
03:34rritochYeah, I just used numbers to test with because it was simpler.
03:34justin_smithright
03:34justin_smithnow I see the scrollback
03:46amalloyrritoch: i bet clj-time compares dates better than some hand-rolled code you or i would write
03:48rritochamalloy: I ended up with (defn in-range [from to item] (< -1 (min (compare item from) (compare to item)))) which is pretty good and more general purpose than just dates.
03:48amalloyrritoch: that is like super-wrong, though
03:49amalloy(< -1 x) is a very bad way to write (neg? x), because it returns false for -1
03:49rritoch1 is the fail case so it should return false
03:49rritocherr, -1 is the fail case
03:50rritochIt's cleaner than (not (neg? x))
03:51amalloyyou're writing (< -1 x) instead of (>= x 0)? in that case it's not wrong, just confusingly hard to read
03:52rritochYes, basically
03:54amalloyso my point re clj-time is that, whether your code is right or not, there are a number of edge cases, and you've had to write code that is not obviously correct at first glance. i have no idea what (min (compare x y) (compare z x)) actually computes, whereas if you used some pre-existing library it's already written, tested, and credible
03:56rritochamalloy: This works, its fast, and doesn't require importing code I don't need, so it's more efficient
03:58rritochamalloy: I'm developing OSGi modules, so bringing in additional code is non-trivial and increases the load time of the OSGi module significantly.
03:59TEttingerI see your point, rritoch. I think this solution isn't bad and if documented well could be fine
04:01rritochWell, I do see amalloy's point also, but while developing these OSGi modules I find myself re-inventing the wheel often to maintain efficiency. It's a nessisary evil.
04:01rritocherr, necessary
04:03amalloyi don't understand osgi. i get the promise behind it: basically it's about saving you from dependency hell, right? because you can have multiple versions of whatever modules on your classpath at once? but it seems to me like the people who use it are even sadder than the people who don't
04:04rritochamalloy: It is about modularization, not only do you avoid conflicts between modules since they have separate classloaders, but they can also export functionality as services to provide shared resources.
04:05rritochamalloy: With OSGi you can load and unload modules at runtime, you can't unload namespaces in a single classloader environment so it is useful.
04:06rritochamalloy: But it does require a lot of additional framework code to keep things working properly and efficiently
04:07rritochamalloy: Getting it to work with clojure also requires jumping through a lot of additional "hoops" but once it's functional it tends to be very stable.
04:33daGrevishi! i have a vector and i want to make a hash-map from it that contains all possibilities how items can map to other items in it. like [:a :b :c] would be {:a :b, :a :c, :b :a, :b :c, :c :a, :c :b}. where do i look?
04:35TEttingerthere may be a combinatorics lib somewhere
04:35daGrevishttps://github.com/clojure/math.combinatorics/blob/67b2e2a38be69fa25e713594c6da74303d52042c/src/main/clojure/clojure/math/combinatorics.clj
04:35daGrevissure
04:36opqdonut,(let [v [:a :b :c]] (into {} (for [x v y v] [x y])))
04:36clojurebot#<CompilerException clojure.lang.ArityException: Wrong number of args (3) passed to: core/for, compiling:(NO_SOURCE_PATH:0:0)>
04:37opqdonutah, right, had a weird nbsp there
04:37opqdonut,(let [v [:a :b :c]] (for [x v y v] [x y]))
04:37clojurebot([:a :a] [:a :b] [:a :c] [:b :a] [:b :b] ...)
04:37opqdonutanyway, maps can't have repeated keys
04:38opqdonutso you can't have {:a :b, :a :c ... }
04:38daGrevisahh right
04:38daGrevisi can go for tuples in vectors then
04:38TEttingeryou are probably after a sequence of sequences yeah
04:38daGrevis*vector
04:39TEttinger&(let [v [:a :b :c]] (for [x v y v :when (not= x y)] [x y]))
04:39lazybot⇒ ([:a :b] [:a :c] [:b :a] [:b :c] [:c :a] [:c :b])
04:39TEttingerif you don't want :a :a
04:39daGrevisthanks!
04:40daGrevisany way that i can use function from math.combinatorics to look cooler?
04:40daGrevis:D
04:40daGrevisaren't these permutations?
04:42opqdonutnope, cartesian product
04:43daGrevisopqdonut, ty
05:39hellofunkwhy can you (conj {} [:k :v]) but not (conj {} '(:k :v)) ? a list satisfies seq? so wouldn't they both work?
05:46donbonifacioanyone sharing clj in java and js? cljx is the way to go?
06:46hellofunkdonbonifacio a lot of people think quite highly of cljx and it seems quite stable
06:54daGreviswhich style is more idiomatic? https://gist.github.com/30d4aba120a475ba7662
06:58hellofunkdaGrevis having closing parens on a line by themselves us not idiomatic
06:58hellofunk*is
06:59daGrevisso v2 is better, right, hellofunk?
06:59hellofunkyes, though whether the opening outside vector is on the top line or not is a stylistic choice, but the closing should not be on its own line, creates more whitespace than most prefer to look at
07:01daGrevisif I put opening paren of vector on the same level as def is, my Vim indents it like this https://gist.github.com/dc420498b93e38b0e720
07:01daGrevisis it okay?
07:02hellofunkdaGrevis: "okay" is really subjective, here. i prefer your secret santa over the others, personally.
07:07daGrevishellofunk, thanks and thanks :D
07:07hellofunkdaGrevis if your pairs-banned is really so small then i'd probably just put the whole thing on one line anyway
07:08daGrevisthat's an possibility too
07:08puppehin a bit string mutation mutation (genetic algorithm), the "probability" the chance that *one* of the digits will be flipped? or is it applied to every digit?
07:08daGrevisbut it can change and get it bigger
07:09hellofunkdaGrevis yes but will those changes happen due to program logic, or are they bigger at the time you define the structure initially?
07:09daGrevishellofunk, people may change it by hand before script is run
07:10daGrevisis it 'by hand' or 'with hand', by the way?
07:11TEttingerpuppeh, I could see it either way, but the generations would make the most sense if it is one bit
07:11hellofunkwhy can you (conj {} [:k :v]) but not (conj {} '(:k :v)) ? a list satisfies seq? so wouldn't they both work?
07:12rurumatecan I give an alias to current namespace using require?
07:12rurumateso I can refer to vars within it the same way I would from other namespaces
07:12puppehTEttinger: so when Implementing such a function, which accepts a bitstring and a probability, what would that probability be about? kinda confused :S
07:13puppehTEttinger: it would be for ex. that at a chance of 20%, at most 1 of the bits will be flipped?
07:14TEttingerdo you have a link to a question that you're trying to solve?
07:14rurumatesay I have a namespace com.foo and I use it in my other namespaces like this (require '[com.foo :as foo]) (foo/bar)
07:15rurumateand bar is also used in other functions in com.foo, is it possible to also refer to com.foo/bar as foo/bar within com.foo
07:15puppehit's a code kata actually, that doesn't give much information, and I'm reading about mutation in order to understand how it works
07:15puppehI only have the function signature and input values
07:16puppehI think I've found the answer though: http://stackoverflow.com/a/5444676/1242778
07:20TEttingerok, this is a bit confusing
07:21TEttinger,(reduce #(if (= %2 42) (reduced %1) (inc %1)) (iterate #(bit-xor % (bit-shift-left 1 (rand-int 8))) 12))
07:21clojurebot670
07:21TEttingerthat works fine, but when I change to reductions to see how it did it...
07:21TEttinger,(reductions #(if (= %2 42) (reduced %1) (inc %1)) (iterate #(bit-xor % (bit-shift-left 1 (rand-int 8))) 12))
07:21clojurebot(12 13 14 15 16 ...)
07:21TEttinger&(reductions #(if (= %2 42) (reduced %1) (inc %1)) (iterate #(bit-xor % (bit-shift-left 1 (rand-int 8))) 12))
07:21lazybotjava.lang.ClassCastException: clojure.lang.Reduced cannot be cast to java.lang.Number
07:22BronsaTEttinger reductions still doens't handle reduced
07:22daGreviswhy isn't this working? :( https://gist.github.com/0050af6586e7f2d05e70
07:23TEttingerdaGrevis, your #() fn accepts two args
07:23BronsadaGrevis: replace [[.. ] [..]] with [..] [..]
07:23TEttingerbut it's getting one, a collection
07:24daGrevisahh, right :@
07:25TEttinger,(map inc nil)
07:25clojurebot()
07:25TEttinger<3 clojure
07:26daGrevisTEttinger, is that a good thing?
07:26TEttingerclojure treats nil as an empty seq if it ends up where it shouldn't
07:26TEttingerit counts as falsy for truthiness tests
07:28daGrevisTEttinger, but I mean... is that a good thing? you know, javascript treats number as string in some cases and vice-versa and it is terrible :)
07:28TEttingerit seems to be, nullpointerexceptions are probably more common in java than clojure
07:29daGrevisahh, yes.
07:29daGrevis,(> 42 nil)
07:29clojurebot#<NullPointerException java.lang.NullPointerException>
07:29Bronsa&*clojure-version*
07:29lazybot⇒ {:major 1, :minor 7, :incremental 0, :qualifier "alpha1"}
07:29BronsaTEttinger reductions supports reduced since alpha2/3
07:29TEttingerlol
07:30TEttinger,*clojure-version*
07:30clojurebot{:interim true, :major 1, :minor 7, :incremental 0, :qualifier "master"}
07:30arav93Hi, does anybody know what miniKanren is?
07:30TEttinger&(clojure.string/join " " (take 40 (reductions #(if (= %2 42) (reduced %1) (inc %1)) (iterate #(bit-xor % (bit-shift-left 1 (rand-int 8))) 12))))
07:30lazybot⇒ "12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51"
07:31TEttingerhm
07:31broquaintarav93: http://minikanren.org/ ?
07:32arav93I saw that link, but could you please tell me what it is? broquaint
07:32TEttinger&(clojure.string/join " " (take 40 (reductions (fn [[ctr oldval] newval] (if (= %2 42) (reduced [ctr oldval]) [(inc ctr) newval])) (iterate #(bit-xor % (bit-shift-left 1 (rand-int 8))) 12))))
07:32lazybotjava.lang.RuntimeException: Unable to resolve symbol: %2 in this context
07:33TEttinger&(clojure.string/join " " (take 40 (reductions (fn [[ctr oldval] newval] (if (= newval 42) (reduced [ctr oldval]) [(inc ctr) oldval])) (iterate #(bit-xor % (bit-shift-left 1 (rand-int 8))) 12))))
07:33lazybotjava.lang.UnsupportedOperationException: nth not supported on this type: Long
07:34broquaintarav93: It provides logic programming facilities, see also core.logic for clojure.
07:35arav93broquaint: Thanks :-)
07:35broquaintnp
07:36hellofunk why does (conj {} [:k :v]) work but not (conj {} '(:k :v)) ? a list satisfies seq? so wouldn't they both work?
07:37Bronsahellofunk: vectors are mapentry, seqs aren't
07:37TEttingerah cool, but puppeh quit
07:37TEttinger[0 12] [1 12] [2 13] [3 141] [4 140] [5 132] [6 164] [7 180] [8 182] [9 150] [10 182] [11 166] [12 38] [13 34] [14 162] [15 170] [16 174] [17 172] [18 140] [19 136] [20 200] [21 202] [22 200] [23 202] [24 206] [25 238] [26 254] [27 222] [28 94] [29 222] [30 94] [31 86] [32 214] [33 246] [34 214] [35 246] [36 182] [37 166] [38 164] [39 36] [40 44] [41 40] [41 42]
07:37hellofunkBronsa, oh I thought all maps were seqs over their keys and values Bronsa, thus any seq could also be used to go the other direction. i guess not, only vectors can become kv pairs?
07:38Bronsahellofunk: correct
07:38TEttingerthat is a sample bit mutation thing that finds 42
07:38hellofunkBronsa I wonder what the reason for restricting map entry into vectors is, when the seq abstraction would seem to make more sense in general
07:39Bronsaactually nevermind about vectors being mapentries, the code for conj explicitely tests for IPersistentVector
07:40hellofunkBronsa and since into uses conj, then making a map out of a seq, whether using conj or into, is only possible if that seq is a vector?
07:41hellofunki guess this is possible (apply hash-map (list 1 2))
07:41hellofunki would think conj would test not for a vector but for a seq in general
07:52rurumate,*ns*
07:52clojurebot#<Namespace sandbox>
07:53rurumate,(alias 'socks 'sandbox)
07:53clojurebotnil
07:53rritochOne step forward... two steps back... I finally have a servlet that serves clj files selected by the URL, but for some reason nothing short of restarting tomcat will update my changes, even with my src folder on the classpath
07:54rurumate,d an alias in the current namespace to another
07:54rurumatenamespace. Arguments are two symbols: the alias to be used, and
07:54rurumatethe symbolic name of the target namespace. Use :as in the ns macro in preference
07:54clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: d in this context, compiling:(NO_SOURCE_PATH:0:0)>
07:54rurumatewhooops
07:54rurumate,(count (ns-publics *ns*))
07:54clojurebot0
07:54rurumate,(def a 1)
07:54clojurebot#'sandbox/a
07:54rurumate,(count (ns-publics *ns*))
07:54clojurebot1
07:55rurumatewill the vars in public be cleared periodically?
07:55rurumate*in sandbox
07:55TEttingeryes
07:55TEttingerevery 10 min or something
07:56rurumateso it can happen that I define something and it gets cleared a second later, because there are fixed intervals?
07:57rurumateor are the 10 minutes a real TTL of each individual var
07:58rurumatenvm I found the source on github
08:01rurumate,(:status (clj-http.client/get "http://www.google.com&quot;))
08:01clojurebot#<CompilerException java.lang.ClassNotFoundException: clj-http.client, compiling:(NO_SOURCE_PATH:0:0)>
08:01rurumate,(require '[clj-http.client :as client])
08:01clojurebot#<FileNotFoundException java.io.FileNotFoundException: Could not locate clj_http/client__init.class or clj_http/client.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.>
08:41rurumateI just watched Tim Baldrige's "Data all the ASTs" video. Apparently ioc/state-machine now uses tools.analyzer for initial AST parsing. But then in ioc/parse-to-state-machine transforms the map-AST to a mix of maps and records. Would it be wrong to say that only some ASTs in core.async were "data'ed"?
08:43hiredmandepends who you ask, I suspect tim would be in the camp that considers records to be data as well
08:45rurumatehiredman: so there are camps on this? can you elaborate what the camps disagree on?
08:46rurumateor point to some resource
09:05SagiCZ1in regex, how do i match "everything until ," ?
09:06SagiCZ1(re-find #"match" "some-string45821:.,hello") --> "some-string45821:.,"
09:07TEttinger,(re-find #".+," "some-string45821:.,hello")
09:07clojurebot"some-string45821:.,"
09:07TEttinger,(re-find #".+," "some-string45821:.,hello,")
09:07clojurebot"some-string45821:.,hello,"
09:07TEttinger,(re-find #".+?," "some-string45821:.,hello,")
09:07clojurebot"some-string45821:.,"
09:07schrottigreetings
09:07TEttingerso you want #".+?," to stop just after reaching a comma
09:07TEttingerhey schrotti
09:07SagiCZ1TEttinger yeah
09:07SagiCZ1+?
09:08schrottii'm trying to create a simple tcp socket and a writer: (def socket (Socket. "hostname" 1234)) and for the writer (def out (io/writer (.getOutputStream socket)))
09:08TEttingerwas that a question, or the actual term?
09:09schrottibut i get an exception: CompilerException java.lang.IllegalArgumentException: No matching method found: getOutputStream for class java.net.Socket
09:09schrottiok my bad :/
09:09TEttingerhm?
09:09schrottiactually had (def out (io/writer (.getOutputStream socket true)))
09:09TEttingeroh ok
09:09schrotti-true works
09:31_segfaultHello ! Is anybody there ?
09:32SagiCZ1_segfault: yup
09:32TimMc_segfault: There are like 500 people in the channel. I bet some of them are at their keyboards. :-)
09:33SagiCZ1we are not sleeping, just merely dozing
09:33_segfaultSagiCZ1: Do use emacs ? I needed some help with respect to emacs ! :)
09:33SagiCZ1SagiCZ1: it's a coincidence that i don't but it seems that everyone else here does
09:33SagiCZ1why am i talking to myself
09:34_segfaultTimMc: Do you use emacs ? :)
09:34boyscaredi do. ask your question
09:34TimMcActually, 750.
09:35_segfaultboyscared: Oh thanks ! I'm on windows & and on emacs 24.3
09:35_segfaultI wanted to use monore repl
09:35TimMc_segfault: Just ask your question, you don't need to find someone to ask it of.
09:35_segfaultinstead of Cider
09:35_segfaultBut Monroe doesnt seem to be able to connect to the repl
09:36boyscaredi use cider, so can't help with that one
09:37_segfaultHere's the steps : I manually start the repl (lein repl in the root of the project), switch to emacs and M-x monroe, I put in host:port and it says "Unable to Connect"
09:39supersymmetryI don't use emacs either.. havent had the time yet to learn :P
09:40supersymmetrydid you provide a host port? else the nrepl is bound to local sockets only
09:41yeahnoobTools is the tool ,not the Target.
09:41_segfaultsupersymmetry: yeah !
09:41supersymmetrynot sure if this was a remote connection or on the same machine, but that had me puzzled for a bit trying to hook up Light Table remote nrepl
09:41supersymmetrykk, just checking ;)
09:49rurumatewatching rich hickey's "Transducers" video, at 13:10 there's this example: (transduce (comp process-bag (mapping weigh-bag)) + 0 pallets)
09:49afhammadhow do you escape characters in a string?
09:50rurumateshouldn't it rather be (transduce (comp (mapping weigh-bag) process-bag) + 0 pallets) ?
09:50rurumateafhammad: same as in java?
09:51afhammadrurumate: i probably should be asking this on the appropriate channel but in clojurescript (str "\"") returns "\""
09:51afhammadrurumate: also not everyone comes from java
09:52rurumatesorry. have you tried writing like you would in javascript?
09:52afhammadrurumate: in js "\"" returns """
09:53rurumatelooks like a bug to me, but such a severe bug should have been found earlier
09:54afhammadrurumate: actually it looks like its a eval bug in lighttable, when i print it to the browser console its fine.
09:54rurumateoh, that's a different story then
09:55afhammadyes, i put too much trust in it
09:57rurumateback to transducers question
10:00rurumatemy intuition about comp would say that (comp process-bag (mapping weigh-bag)) applies process-bag to the result of (mapping weigh-bag), which would not work because (mapping weigh-bag) produces numbers, not bags
10:00rurumatehow can I test the transducers stuff?
10:01rurumateit's not in clojure 1.6 afaik
10:01luxbockrurumate: is this the Strange Loop or the conj talk?
10:02rurumatestrange loop, here's the link: https://www.youtube.com/watch?v=6mTbuzafcII&amp;t=13m10s
10:02luxbockI think he talks about the ordering of transducers in comp a bit later
10:03luxbockyep, at 25:31
10:03luxbockhold onto your seat
10:03rurumateso when will scala get transducers
10:04luxbockthere's https://github.com/knutwalker/transducers-scala
10:04rurumatethis is really funny: https://www.youtube.com/watch?v=6mTbuzafcII&amp;t=9m11s
10:05rurumateamazing. where is this transducers idea coming from? did rich just think this up?
10:06luxbockI think so, in his hammock I'm sure
10:06n0n3suchits an obvious abstraction
10:07mavbozoevolution of reducers
10:10mavbozon0n3such: yeah, It takes a very unusual mind to undertake analysis of the obvious -Whitehead
10:10clojerUsing Yesql and Cheshire to generated some JSON from a Postgres query, ip addresses are returned as :ip #<PGobject 86.148.167.17> which Cheshire doesn't like. What's the best way of dealing with these objects?
10:12legittalonMy main editor is VIM, are there any convincing arguments for switching to Nightcode to do clojure work? I'm not entirely opposed to it. (I'm also new to clojure)
10:12mavbozoclojure: create custom encoder
10:12mavbozoclojer: create custom encoder for cheshire
10:12n0n3such“In all affairs it's a healthy thing now and then to hang a question mark on the things you have long taken for granted.”
10:12n0n3such― Bertrand Russell
10:13clojermavbozo: Ah, just noticed this at the bottom of the docs. Missed it first time round.
10:17mavbozolegittalon: a coworker of mine who's new to clojure and using Windows decided to use Nightcode and still going good
10:18clojure_beginnerhello I have some trouble understandign this function http://pastebin.com/R5N2u8Ne
10:18clojure_beginnerit's recursive. But i want to start at the let binding. It looks unusuall to me
10:19legittalon1I have qualms about switching to an IDE, that I'm willing to question. That and I'm stuck in a Stockholm situation with vim commands I guess I'll just try it out and see what happens.
10:20clojure_beginneror is the order in let binding not important is this the same (let [a [1 2 3]...) (let [ [1 2 3] a..)
10:22clojure_beginneri know that [x & xs] n should say like x is the head and xs is the tail of sequence n
10:22mavbozolegittalon1: why don't you use vim? do you find clojure integration very poor there?
10:22clojure_beginnerbut it looks weird to me.
10:22clojure_beginnerlegittalon, use fireplace plugin for vim
10:23mavbozoclojure_beginner: it's clojure's destructuring argument
10:24legittalon1Oh right, plugins!
10:24clojure_beginnermavbozo..Ahh, I totaly forgot about destructuring.
10:24clojure_beginnerI've beend doing exercises on 4clojure.com and didn't have to use destructuring yet, so i forgot all about it
10:25clojure_beginnerI didn't know zou can use destructuring in let expressions I thought only in fn arguments
10:27mavbozoclojure_beginner: I learn clojure through Clojure Programming book and the authors introduce destructuring through let.
10:28rurumatewill transducers be compatible to reducers framework also?
10:29clojure_beginnermavbozo: I am also using this book. :) Now I need to wrap my head around recursion in this function
10:30clojure_beginnerI think i got it now. The base clause returns empty list
10:31clojure_beginnerand to that list the function compositions "roll out" :)
10:32clojure_beginnerso all the work is done in the :else part
10:32clojure_beginnergod, this thing is beutiful
10:32clojure_beginnerBut I am wondering, is it a clojure way to write recursive functions, or is this not the best practice ?
10:33clojure_beginnerAs I can see so far, you can live without recursion just fine in clojure.
10:34rurumateclojure_beginner: the way it's done in the example you gave is probably not idea
10:34rurumatehave a look at clojure.core/flatten
10:35clojure_beginnerrurumate, I am aware of the flatten function, this was just an exercise from 4clojure :)
10:36rurumateclojure_beginner: writing a recursion can often be avoided by using map or reduce, but these use recursion internally
10:36clojure_beginnerrurumate, could I create a flatten alternative only with for list comprehension ?
10:36rurumateclojure_beginner: when you find you have to recurse, consider using (recur) instead of having the function call itself by name. that way you get tail recursiveness
10:37clojermavbozo: I tried: (add-encoder org.postgresql.util.PGobject encode-str)
10:37clojure_beginnerrurumate, tnx, will do that. I heared about tail recursion not being supported on jvm
10:37rurumateclojure_beginner: no I don't think it can be done with for alone
10:37clojermavbozo: ... but this failed: (encode org.postgresql.util.PGobject. (:ip (first (recent-logs conn "2014-09-16 00:00:00"))))
10:37clojure_beginnerI see.
10:38rurumateclojure_beginner: tail recursion is just a fancy way to write a loop, which sure is supported
10:38clojure_beginnerrurumate: Sorry I meant tail call optimisations.
10:39rurumateisn't that the same thing?
10:39clojerrurumate: I think tail call elimination is different
10:39jaaqoThere's no tail call optimisation. Recursive functions consume stack space like mad. Provided loop/recur forms are exception, which consume static space.
10:40rurumateanyway just remember to try use a (recur) to avoid stack overflow. the other way to avoid stack overflow in a recursion is to use lazy-seq buiit that's kind of advanced
10:41clojure_beginnerrurumate: Yes it's the optimisation of tail recursion, I am not a compiler guy, so I don't know much about this. It's more low level stuff, what jvm enables you and what not.
10:41rurumatealso you don't need a loop to go with the recur. it will recurse to the (defn [...] ) above it by default
10:42clojure_beginneryes, so just (recur with_args_of_defn)
10:42rurumateyes. a good way to think about (recur) is: the compiler will make a while loop out of this. it's really not more than that. nothhing scary :D
10:43rurumateand the compiler will tell you if it can't compile the thing into a while loop
10:44clojure_beginnerrurumate: I know lazy seqs, that is in my opinion one of the best things in clojure i encountered so far.
10:44rurumatebecause you didn't use the (recur) in "tail position"
10:44rurumateyes lazy seqs can be really cool
10:56mavbozoclojer: here's my encoder
10:56mavbozo(add-encoder org.postgresql.util.PGobject
10:56mavbozo (fn [c jsonGenerator]
10:56mavbozo (.writeString jsonGenerator (.toString c))))
10:57mavbozo(encode #<PGobject 86.148.167.17/32>) returns "\"86.148.167.17/32\""
10:58clojermavbozo: thanks. Will try it.
11:02clojermavbozo: Still no luck: (encode (:ip (first (recent-logs conn "2014-09-16 00:00:00"))))
11:02clojurebotExcuse me?
11:02clojer1. Unhandled com.fasterxml.jackson.core.JsonGenerationException Cannot JSON encode object of class: class org.postgresql.util.PGobject: 92.0.164.246
11:03mavbozoclojer: i have a table web_address which has column named ip
11:04mavbozoclojer: i query it (jdbc/query pgdb ["SELECT ip FROM web_address"])
11:04mavbozoclojer: returns ({:ip #<PGobject 86.148.167.17/32>})
11:05mavbozoclojer: suppose i def the result to a var named res (def res *1) in my repl
11:05clojermavbozo: Sorry, real problem is: Unable to resolve symbol: add-encoder in this context
11:06mavbozoclojer: (encode (:ip (first res))) returns "\"86.148.167.17/32\""
11:06clojerBut I have this added to :require [cheshire.generate :refer [add-encoder encode-str remove-encoder]]
11:08mavbozoclojer: different cheshire version?
11:10clojermavbozo: Required repl reboot. Working now.
11:10mavbozoclojer: great
11:11sdegutisI'm using this function in production: https://gist.github.com/sdegutis/b376cf100e337941d826
11:11clojermavbozo: this simpler version now works: (add-encoder org.postgresql.util.PGobject encode-str)
11:12mavbozoclojer: that's greater!
11:14sdegutisIt's very useful, it should be part of clojure.core
11:28justin_smithsdegutis: you should really be doing arglist matching by count. I mean that's what clojure does, matches the arglist by count.
11:28sdegutisjustin_smith: You're right. This is a rough draft of the function, that's why it doesn't have that.
11:28sdegutisjustin_smith: Once I add that in, it should be added to clojure.core for its usefulness.
11:32clojerWhy does the Used Heap size of a dormant app gradually increase? In jvisualvm I hit "Perform GC" and Used Heap drops to next to nothing but not it's over 200MB RAM while the single page app is doing nothing, ie. dev mode on my laptop.
11:33sdegutisAny guesses on what https://github.com/weavejester/clofor/blob/master/src/clofor/core.clj is for yet?
11:33clojerNow at almost 250Mb RAM
11:33clojerHeap size is 1,750Mb
11:51justin_smithclojer: I know the jvm will ask for RAM preemptively (within its limit) so that when it needs it it can utilize it quickly
11:51justin_smithclojer: are you seeing any unexpected growth in used memory?
11:52justin_smithor only in the amount allocated/
11:53clojerjustin_smith: I'm aware that the JVM allocates total heap size but curious as to why used heap increases when nothing is happening to the app
11:53emacshow do you change nick
11:54clojerjustin_smith: I thought total heap size (orange in jvisualvm) was the pre-allocated ram?
11:54justin_smithclojer: look at the threads that are running. There are maintinance loops, that allocate small amounts of memory that is quickly freed. That freed memory is being put back in the pool, not freed from the app.
11:54clojerjustin_smith: It's the increasing (blue) used heap that perplexes me
11:54Guest34275hey, why don't records follow the lispy syntax in examples?
11:55justin_smithclojer: OK. Your answer is in one of those threads, I think I misenterpreted you above.
11:55justin_smithGuest34275: what lispy syntax?
11:55justin_smithand which examples?
11:56Guest34275or naming convetions rather
11:56clojerI notice now, the blue approached the heap size limit then dropped by about 150Mb
11:56justin_smithGuest34275: they create objects that are usable from java
11:56Guest34275http://clojuredocs.org/clojure.core/defrecord
11:56clojerI set a 500Mb limit in this example
11:56justin_smithGuest34275: so they should hve names that make sense from java
11:56Guest34275oh, so thats why they use camelcase
11:56justin_smith,(munge "my-record")
11:56clojurebot"my_record"
11:57justin_smiththat's what the java class name is for my-record
11:57Guest34275oh yeah, java doesn't support dashes and stuff
11:57justin_smithright
11:57justin_smith,(munge "my-record'")
11:57clojurebot"my_record_SINGLEQUOTE_"
11:57clojerjustin_smith: 69 threads started, live: 53, live peak: 64, daemon: 8
11:57justin_smithI'd love to see java code accessing that :P
11:59Guest34275:justin_smith
11:59sharms /allchan chanopt confmode on
11:59clojerjustin_smith: I was running: wrk -c 100 -d 60s -t 2 http://localhost:3000
11:59Guest34275justin_smith: records should be used over structs, right?
12:00justin_smithyeah, structs are depricated I think
12:01justin_smithclojer: oh, so wrk is what was doing it?
12:02justin_smith(well, the request handling that was spawned by wrk)
12:03d0kyhello how can i read file by 2 lines ? i need read file and if i find proper line i need read values from next line but im using line-seq and dont know how to get on next line in cycle ... can someone help ?
12:04justin_smithd0ky: maybe (partition 2 1 (line-seq src))
12:04justin_smiththat gives you every pair of lines
12:04justin_smith,(partition 2 1 (range 10))
12:04clojurebot((0 1) (1 2) (2 3) (3 4) (4 5) ...)
12:04luxbockthere's something demoralizing about solving a tough 4clojure puzzle and then seeing that all the other solutions are 1/3 as short
12:04d0ky(inc justin_smith)
12:04lazybot⇒ 144
12:05d0kythanks it works :)
12:05justin_smithluxbock: that's where half the learning happens :) many of my 4clojure answers are much too long
12:05justin_smithluxbock: though personally, I think the more intelligible answer is better
12:06justin_smithif only "intelligibility" had as clear a metric as "byte count"
12:06luxbockI have yet to come to a solution where my answer would be unique and elegant at the same time
12:07justin_smithluxbock: there are some extremely smart people on 4clojure, treating it as a competition may not be as productive as treating it as a chance to learn...
12:07luxbockyeah, I was just joking around :)
12:07justin_smithluxbock: I will have a sense of humor after I get my coffee, sorry :)
12:08luxbockit's just funny how in that moment I click to see the link for other solutions my feelings go from feeling proud to being humbled
12:08justin_smithit's funny, but also humility can be an important part of learning
12:10luxbockhttps://gist.github.com/luxbock/deebf89b83feaa3fa9e3
12:10luxbockthis is the one I just did
12:13justin_smitheww, regex
12:14justin_smithluxbock: though clearly your loop could be a reduce, and that would be much clearer
12:15luxbocktrue, at first I was toying around with having one more loop-local variable
12:16justin_smithluxbock: you can have a map or vec as an accumulator, in order to effectively have multiple accumulators in a reduce
12:17luxbockis that cleaner? I often wonder about that and end up using a loop in those cases
12:17justin_smith,(reduce (fn [[o e] v] (if (even? v) [o (conj e v)] [(conj o v) e])) [[] []] (range 10))
12:17clojurebot[[1 3 5 7 9] [0 2 4 6 8]]
12:17justin_smithtwo accumulators
12:17justin_smithdestructuring makes it work nicely
12:18luxbockI actually only recently learned about `reduced` from the most recent Hickey transducers talk
12:18justin_smithluxbock: reduced is what makes reduce a general replacement for loops that iterate across a collection
12:18luxbockwhich would make writing most of my loops as reduce-operations more appealing
12:19justin_smithright
12:24luxbockjustin_smith: tried to translate this to using reduce, but got stuck with trying to get the first letter of the next grouping so use with `cmp`
12:25justin_smithluxbock: see my above suggestion of (partion 2 1 col) to d0ky :)
12:25luxbockah hmm
12:26justin_smith(reduce f (partition 2 1 ...))
12:32justin_smithor, more generally (reduce f (take-while not-empty (iterate rest coll)))
12:32justin_smith,(take-while not-empty (iterate rest (range 4)))
12:32clojurebot((0 1 2 3) (1 2 3) (2 3) (3))
12:33justin_smithin fact, that is useful enough to give a name like rests
12:33justin_smithtails?
12:45luxbockpfft, finally: https://gist.github.com/luxbock/deebf89b83feaa3fa9e3
12:46luxbockjustin_smith: yeah that looks cleaner
12:47sdegutis$ lein repl
12:47sdegutisRetrieving org/clojure/clojure/1.3.0/clojure-1.3.0.jar from central
12:47sdegutisUHHH.....
12:48sdegutiswat
12:49luxbocksdegutis: you have a dependency somewhere that was written using 1.3.0, and you don't have it on your machine yet
12:49luxbockit's not a big deal
12:49sdegutisOh.
12:49sdegutisDang.
12:49surrealanalysisDoes anyone know if there is an easy way to pass a variable number of arguments to another function?
12:49surrealanalysisFor example (defn function1 [a & bs] ...)
12:49surrealanalysis(defn function2 [a & bs]
12:49surrealanalysis (function1 a bs)
12:49surrealanalysis)
12:50luxbocksurrealanalysis: apply works
12:51surrealanalysisAh, thanks. I misread it last night, but reading it now makes more sense. Thanks
12:51luxbock,(letfn [(f1 [a & bs] [a bs]) (f2 [a & bs] (apply f1 a bs))] (f2 1 2 3))
12:51clojurebot[1 (2 3)]
12:52surrealanalysisYeah, that worked. Don't know why I missed that. Thanks again luxbock
12:52luxbocknp :)
13:04justin_smithluxbock: just got back from grabbing coffee - did you forget to update the gist?
13:04luxbockit's there but I added it as a new file to the same gist
13:05justin_smithluxbock: as a minor style thing, if you know order is a hash-map by context, (order a) can be better than (get order a)
13:06justin_smithbut that's something not everyone agrees on
13:06justin_smith,(map {:a 0 :b 1 :c 2} (range))
13:06clojurebot(nil nil nil nil nil ...)
13:06justin_smitherr
13:06justin_smith,(map {0 :a 1 :b 2 :c} (range))
13:06clojurebot(:a :b :c nil nil ...)
13:06luxbockI like the explicit get
13:06Bronsait's also safer.
13:07Bronsa,((fn [a] (a :foo)) nil)
13:07clojurebot#<NullPointerException java.lang.NullPointerException>
13:07justin_smithBronsa: the hash map is defined on the preceding line, I did mention context
13:07Bronsaright, I missed that
13:07Bronsathen +1 for not using get
13:08luxbockhmm true, here it's not so needed, but I wrote it there out of habit
13:08justin_smithright, it's not a correctness thing at all
13:08luxbockI just like to be able to tell at a glance when I'm using a function and when I'm retrieving something from a map
13:10justin_smithluxbock: something that changed my mind on this front was reading some higher math, where functions were defined in terms of maps
13:10justin_smithin that sense, a clojure map is more like a real function than most of our functions are
13:11justin_smith"real function" meaning "function as talked about in mathematics" here of course
13:11luxbockright
13:11justin_smithand when I say "functions were defined in terms of maps" I don't mean particular function instances, I mean the very concept of a function started with the concept of a map, and evolved from that.
13:13luxbockI'd definitely like to learn some more high level math, but I need a problem where I can apply it to grok it
13:13luxbockI quit school when I was 19 so there's definitely a lot for me to learn
13:13justin_smithluxbock: I found my clojure experience definitely helped me with category theory
13:13luxbockdoing the Cryptography and Machien Learning courses on Coursera helped quite a bit on that front
13:13justin_smithluxbock: I quit school at 18, and my last real math class was algebra II :)
13:14luxbocknice
13:14justin_smithbut I was a stubborn kid who refused to learn from others, and spent a lot of time teaching myself
13:15justin_smithbut recent stuff I have read about eg. cramming and memory retention makes me think I didn't have it so bad
13:16justin_smithskimmed a book three times over a course of years ~= crammed really hard, took a test, and never thought about it again
13:16luxbockyeah, that's why I think it's important to have a practical problem to work out with the theory for it to stick
13:17luxbockgive those ideas some neural pathways to hold on to
13:17justin_smithluxbock: I found the mental models for category theory very applicable to program design in general.
13:17justin_smiththe general domain / mapping concepts (this is low hanging fruit in that domain, it goes so much further of course)
13:18luxbockI think learning some Haskell might be a good step towards that direction
13:18justin_smithalso, it was nice to know how far haskell is from normal category theory
13:18justin_smithhehe
13:18justin_smiththough maybe if I learned more of both I would see more direct connections
13:19justin_smithmonoids / endofunctors were these quick asides in the ct books I found (though to be fair, functors come up a lot and are used in haskell a lot too)
13:20luxbockthere's a functional programming course that uses Haskell that's running now on edX I believe
13:20luxbockI'd like to take that but I'm a bit too busy at the moment, so will have to leave that for later
13:23engblomHaskell is one of the most nice languages you can learn. Of all languages I have coded in, I have least problem reading other peoples Haskell code.
13:24engblomHowever, there is a big problem: Cabal and hackage. The libraries are changing way to often and whatever you want to take into use by cabal and hackage might not compile because something changed.
13:24engblomLein is so much more robust.
13:25justin_smithengblom: have you tried cabal sandboxes? I have only briefly played with them, but they seem to eliminate most of these issues (maybe all?)
13:25justin_smithengblom: agreed global installs are stupid (hell, at this point I think even shared libraries are a bad idea - RAM is cheaper to come by than my sanity)
13:25engblomjustin_smith: No, I have not been hearing about the sandboxes. I should look it up
13:26justin_smithengblom: my only problem with cabal sandboxes is that they are not the only option available :)
13:26justin_smith(so far...)
13:26justin_smithengblom: it is similar to the lein paradigm, where deps are per-project, as they should be
13:32justin_smithSo I am considering using a template to build the static part of a query (before getting any user input) and then using that as a prepared statement with the user input provided args following (clojure.java.jdbc/query [(build-format) user-arg-a user-b user-c])
13:32justin_smithis this reasonable?
13:33justin_smithbuild-format has embedded loops based on data about the table structure and the fields defined, queried from the db
13:33justin_smith(realistically it would not be called for every query)
13:34justin_smithif only sql were a query api rather than a textual language...
13:36engblomI have not done anything with SQL together with clojure so far... But in all other languages I have used template system. I do not know if it is good or not though. But I would probably do as you are thinking to do, justin_smith
13:39justin_smithengblom: thanks. I know there are a lot of pitfalls with this stuff.
13:39justin_smith(in terms of code correctness and maintainability too, not to mention security)
13:43kenrestivofor implementing a state machine for a network protocol, what's the current best practice? just do it all in a core.async go-loop?
13:44justin_smithkenrestivo: I think ztellman has a nice lib for this
13:45engblomHe seem to have very much of useful libraries. I often stumble upon recommendations to his repositories.
13:45kenrestivoi fear zach's libs. every time i dive in i disappear for days trying to understand them.
13:45engblomYes, documentation seem to not be the strong side for his libraries.
13:45kenrestivoand i eventually discover that what i was trying to do was so straightforward i could have found a much simpler alternative
13:46justin_smithkenrestivo: maybe one of these? https://github.com/ztellman/manifold https://github.com/ztellman/manifold
13:46justin_smitherr
13:46kenrestivoguy's brilliant, just, i'm wary.
13:46justin_smithhttps://github.com/ztellman/lamina
13:46kenrestivoyeah those in particular :-P
13:46justin_smithhehe
13:47kenrestivocore.async makes sense to me. manifold makes my brain melt
13:49engblomA couple of week ago, as an introduction project to Clojure I made it possible to fly Flightgear with two mice. It was a simple program parsing the mouse devices and then controlling flightgear by telnet. Gloss was a good library by ztellman, but his network library (I do not remember the name) was too difficult to get working as the documentation lagged. It was easier to do in other ways.
13:52justin_smithengblom: thanks for the feedback on that - did you end up successfully parsing the event structures with gloss?
13:52justin_smithengblom: iirc I may have even suggested that
13:52engblomjustin_smith: Yes, I got that fully to work. And thanks for recommending gloss!
13:53engblomNow I can use one mouse for ailerons and elevators and the other for rudder, if I want so.
13:53justin_smithsweet!
13:53justin_smithyears ago I wrote a small c program so I could attach N mice, and use one mouse to control each pair of parameters in a puredata audio patch
14:11gfrederickslein plugin idea
14:11gfredericks`lein repl-uberjar` creates an uberjar with all your user/repl deps, and that does something similar to `lein repl` when you run it.
14:12arrdemhum...
14:12arrdemnot convinced that'd ever be useful
14:12gfredericksfor running repls in contexts where leiningen is inconvenient
14:13justin_smithgfredericks: nice idea - doesn't the LEIN_FAST_TRAMPONOLINE option do something effectively similar?
14:13gfredericksI don't know what it does
14:13justin_smithahh, but your idea doesn't use lein at all when run
14:13gfredericksexactly
14:13justin_smithgfredericks: https://github.com/technomancy/leiningen/wiki/Faster
14:14justin_smith"Setting the LEIN_FAST_TRAMPOLINE environment variable causes the bin/lein script to memoize all trampoline calls by saving off the java process invocation to disk upon the first run."
14:14justin_smithit means 'lein now runs really fast (until you change your project.clj)
14:14justin_smith'
14:14luxbockdamnit, 4Clojure seems to be runnning Clojure version < 1.5
14:14luxbockcan't use reduced
14:14justin_smithluxbock: how about take-while and reductions?
14:15justin_smith(not as nice, admittedly)
14:15luxbockyeah that works, I was just excited to use reduced for the first time
14:15justin_smith:)
14:16gfredericks,(nth (iterate reduced 42) 10)
14:16clojurebot#<Reduced@429664: #<Reduced@19fa96d: #<Reduced@12c3c25: #<Reduced@120a5d7: #<Reduced@67e287: #<Reduced@492e19: #<Reduced@719ebf: #<Reduced@16d0dd3: #<Reduced@a6a9d0: #<Reduced@1d6be00: 42>>>>>>>>>>
14:16gfredericks^ protip
14:16justin_smithrofl
14:17gfredericks~protipping is a marginally weirder variant of cowtipping
14:17clojurebotOk.
14:17justin_smith&@@@@@@@@@@(nth (iterate reduced 42) 10)
14:17lazybot⇒ 42
14:18justin_smiththat @ chain tho
14:18gfrederickslightning talk idea: implementing church numerals with reduced
14:19gfredericksprobably titled "You won't believe what this man did with clojure.core/reduced"
14:20justin_smith& (first (drop-while reduced? (iterate deref (nth (iterate reduced 42) 10))))
14:20lazybot⇒ 42
14:20morfeen(+ 1 1)
14:20clojurebot2
14:20morfeencool
14:21gfrederickswas that a clojurebot magic trick?
14:21justin_smithgfredericks: repl is magic
14:21gfredericks(+ 1 1)
14:21clojurebot2
14:21gfredericks(+ 1 1 1)
14:21clojurebot3
14:21gfredericks(* 2 3 7)
14:21clojurebot*suffusion of yellow*
14:21Bronsalol
14:22Bronsa(inc clojurebot)
14:22lazybot⇒ 47
14:22gfredericks(+ 1 1 1 1 1 2 1 1 1 1 1 1 1)
14:22clojurebot*suffusion of yellow*
14:22gfredericksoooookay.
14:22Bronsathat made me laugh way too much
14:22justin_smithgfredericks: the urban dictionary for suffusion of yellow is actually useful and not at all obscene
14:22justin_smithimagine that
14:23gfredericksI was just injesting it
14:23gfredericks(- 2 50)
14:23clojurebot-48
14:23gfredericks((fn [x] x) -3)
14:23gfredericks(- (+ 3 5) 20)
14:23gfredericks(- 2 8888888888888888888888888888888)
14:23gfredericks(- 2 8888888)
14:23clojurebot-8888886
14:24gfredericks(* 2 -3 7)
14:24gfrederickswell this has been an educational experience yet again in #clojure
14:25mavbozo(reduced? [])
14:25justin_smithgfredericks: I think I showed you that super low level clojure code in the pink audio engine - the Steven Yi talk was good, and helped me make a bit more sense of all of it
14:26justin_smithmavbozo: try & or , or ##
14:26mavbozo##(reduced? [])
14:26lazybot⇒ false
14:26mavbozo&(reduced? (seq []))
14:26lazybot⇒ false
14:27justin_smith,(reduced? (reduced []))
14:27clojurebottrue
14:27justin_smith,(reduced? @(reduced []))
14:27clojurebotfalse
14:27justin_smiththe deref gets the value from the reduced
14:28justin_smith@(reduced [])
14:28justin_smith,@(reduced [])
14:28clojurebot[]
14:28justin_smith,(reduced [])
14:28clojurebot#<Reduced@8d9915: []>
14:28gfredericksjustin_smith: pink? what?
14:29mavbozo&(reduced? 1)
14:29lazybot⇒ false
14:29kenrestivo(tan 74)
14:29justin_smithgfredericks: oh, I thought I had shared it with you. pink is Steven Yi's synthesis engine, made in pure clojure. Like overtone without the external supercollider program.
14:29justin_smithkenrestivo: ##(Math/tan 74)
14:29lazybot⇒ -5.737022539278999
14:31gfredericksjustin_smith: interesting
14:31justin_smithgfredericks: Yi is one of the core csound devs, and pink is highly informed by that expertise
14:32justin_smithit's interesting to see super low level / real time code in clojure
14:32justin_smith(and also weird in many places)
14:37rurumate,(reduce ((map inc) conj) () [1 2 3])
14:37clojurebot(4 3 2)
14:38justin_smith(inc transducers)
14:38lazybot⇒ 1
15:18sveriHi, how can I generate sequential uuids in clojure?
15:23justin_smithsveri: isn't sequential contradictory to the point of UUID?
15:23jeremyheilersveri: you can use java.util.UUID and generate the bits yourself
15:24noncomhi! what is the current recommended clojure web stack? i want to deploy a little free webserver on heroku...
15:24justin_smith"Since the identifiers have a finite size, it is possible for two differing items to share the same identifier. The identifier size and generation process need to be selected so as to make this sufficiently improbable in practice. Anyone can create a UUID and use it to identify something with reasonable confidence that the same identifier will never be unintentionally created by anyone to identify something else."
15:24justin_smithsequential generation violates that
15:25jeremyheilerjustin_smith: i think sequential for uuids means there's an order, not that the bits are incremented by one each time
15:25jeremyheilerfor example, time based uuids give you an order so you can sort
15:25justin_smithjeremyheiler: ahh - new concept for me, thanks
15:28jeremyheilersveri: you can also look here: http://commons.apache.org/sandbox/commons-id/uuid.html
15:28jeremyheilerjustin_smith: np
15:33justin_smithI guess I was underinformed, partly because java doesn't support creating the time-sequence based uuids directly
15:33justin_smith(you can construct one from the right bits, but nothing in the java standard libs specifically generates those bits)
15:34SagiCZ1how do i do t his? i want it to return [true false true true]
15:34SagiCZ1,(drop-while #(%) [false false false true false true true])
15:35clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn>
15:35ambrosebsSagiCZ1: #(%) is (fn [%] (%))
15:35justin_smithSagiCZ1: idenitty
15:35SagiCZ1ambrosebs: i know, i just didnt know how to do it
15:35SagiCZ1justin_smith: thanks
15:36justin_smith*identity, of course
15:36SagiCZ1,(drop-while identity [false false false true false true true])
15:36clojurebot(false false false true false ...)
15:36hyPiRionjustin_smith: isn't that the opposite?
15:36gfredericks,(drop-while #(do %) [false false false true false true true])
15:36clojurebot(false false false true false ...)
15:36gfredericks^ or for golfing
15:36SagiCZ1identity seems to do the opposite
15:36hyPiRion,(drop-while false? [false false false true false true true]) ; is completely fine
15:36clojurebot(true false true true)
15:36SagiCZ1hyPiRion: thanks
15:37justin_smith(inc hyPiRion)
15:37lazybot⇒ 55
15:41gfredericksdrop-while-not-non-positive-or-twelve
16:04andyfBronsa: Looking through tools.reader some more, and had some questions about possible small simplifications of code. I can file tickets if you like. These lines look like they could be removed, leaving only the ?else? part of the if: https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader.clj#L159-L162
16:05andyfAnd this line looks like it is already covered by the comment reader in the ?;? key of the map ?macros?: https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader.clj#L747
16:05andyfdang smart quotes
16:05sverijustin_smith: I think its nice to have semi sequential uuids like this: http://docs.datomic.com/javadoc/datomic/Peer.html#squuid%28%29
16:07arrdem&(java.net.uuid/Uuid. 1 1)
16:07lazybotjava.lang.ClassNotFoundException: java.net.uuid
16:07justin_smithsveri: yeah, that concept was new to me
16:07justin_smitharrdem: UUID
16:07justin_smithand it's util
16:08arrdem&(java.util.uuid/UUID. 1 1)
16:08lazybotjava.lang.ClassNotFoundException: java.util.uuid
16:08arrdemthird times' a charm...
16:08arrdem&(java.util.UUID/UUID. 1 1)
16:08lazybotjava.lang.IllegalArgumentException: No matching method: UUID.
16:08arrdemfuckit
16:09hyPiRion,(java.util.UUID. 1 1)
16:10clojurebot#uuid "00000000-0000-0001-0000-000000000001"
16:10justin_smith(inc hyPiRion)
16:10lazybot⇒ 56
16:11hyPiRionSeems like I'm harvesting karma today
16:12justin_smithhyPiRion: you keep having the clear answer to things I try and fail at :)
16:12Bronsaandyf: it's possible that those are fast-paths there for performance reasons, it's been a while since I've worked on t.reader and I honestly don't remember what that does, I'll take a look though
16:13andyfok. There is definitely no bug here that I've found. I can do some performance testing to see if it makes any difference.
16:14Bronsaandyf: looks like the comment-prefix? line can go, let's see the other one
16:15dcunit3dhey whats up guys
16:17dcunit3dfinally got irssi configured again, using the OSX Terminal app for my IRC app and iTerm for my terminal
16:18Bronsaandyf: yeah the read-delimited line looks like it's a microoptimization to avoid an useless unread+read, not sure if that has an actual performance impact though
16:19andyfThe other change might be bad, according to a test case I just found, e.g. "(defn [x ;comment\n ])"
16:22Bronsaandyf: ah right. we can't use read there because `read` needs to read a value and read-comment doesn't return any
16:24andyfgood to know. I won't be filing any tickets :)
16:24andyfwell, unless it is to add test cases for things like that.
16:25justin_smiththis Goetz talk is awesome, and gets me excited for value types
16:35pdurbinjustin_smith: sorry, which talk?
16:36justin_smithbrian goetz talk from the conj
16:37justin_smithhttps://www.youtube.com/watch?v=ADUrGfINXdI from yesterday I think
16:38justin_smithhe ended with "allowing tail recursion in the vm is on the radar, is not a priority but it will happen"
16:45andyfarrdem: It might be nice to get another dump from ClojureDocs.org every few months or so for the parts of Grimoire that originally came from there. I don't think they have the web API set up to pull the new examples from there in an automated fashion yet. I can let you know if/when that happens.
16:46andyfNot sure if that was part of your plans.
16:49arrdemandyf: hum... that's not a bad idea but I should take a look at the legal on ClojureDocs before I continue straight up stealing their data
16:49andyfsure
16:49andyfexplicit permission and/or attribution is good
16:50arrdemyeah. I'll throw that on the todo list for post-0.4.0, but right now getting the API and the new datastore online is the top priority
16:50arrdema friend of mine has a cleaned UI in the works as well
16:50sverijustin_smith: I like it, however, in a "normal" database you ahve id's and timestamps and maybe a UUID column, which together are some kind of a semi sequential UUID pattern
16:51pdurbinjustin_smith: thanks!
16:53justin_smithsveri: we added UUID columns to caribou so that migrations that have to happen in both directions between production / staging could stay sane (we still have timestamps and incremental ids, but content going from one db to another drops the incremental id, and keeps the UUID)
16:54justin_smithsveri: if development stays active, I may even experiment with doing the joins based on UUID rather than numeric incremental id
16:58arrdemandyf: if you've got a minute, I realized earlier today that someday god willing Grimoire will go multi-lingual and that the lib-grimoire API should have lang in there somewhere. Commentary on where would be appreciated.
16:59andyfJust because thalia has a placeholder for lang in there does not mean I have thought deeply about the problem, nor have any experience with multi-lingual apps :)
16:59arrdemhehe
17:00andyfMost of my job coding work never even touches Unicode, believe it or not.
17:00arrdemI mean.. neither does mine. I just thought it'd be a good idea to have it in there somewhere :P
17:03justin_smitharrdem: easter egg idea: provide a hidden Zalgo localization option
17:04arrdemjustin_smith: depending on when I have time to drink and work on Grimoire, text/zalgo may or may not become a supported content type
20:05justin_smith$ping
20:05lazybotjustin_smith: Ping completed in 0 seconds.
20:07kenrestivofinally found what i was looking for http://crossclj.info/ns/com.gearswithingears/async-sockets/0.1.0/project.clj.html tho i might mod it to remove dependency on tools.logging and use timbre instead.
20:08justin_smithkenrestivo: timbre uses tools.logging
20:08justin_smithhttps://github.com/ptaoussanis/timbre/blob/master/project.clj#L28
20:09justin_smitherr wait that's a test time config...
20:09kenrestivoyeah, i was gonna say
20:10justin_smithclearly that indicates they can at least coexist if they have to
20:10kenrestivothe disadvantage to catching exceptions in a library is then logging becomes your problem.
20:10kenrestivoinstead of letting the user choose which logging substrate they want to use
20:10justin_smithkenrestivo: the README for timbre mentions tools.logging support
20:11kenrestivoi vaguely remember it having the ability to use different back-ends
20:11justin_smithkenrestivo: that, and users deal with all sorts of insanity because they don't find out about their basic errors except through odd symptoms
20:12kenrestivonot sure if timbre intercepts tools.logging calls tho. will look into it. if i can avoid hacking/forking someone else's library i'll do that.
20:12justin_smithkenrestivo: someone was having an issue with an environment wrapper lib, and nothing was making sense until we saw a try/catch/nil hiding the fact that their config file was unparsible (and simply returning empty config, with no message)
20:12justin_smithkenrestivo: well, since timbre advertises tools.logging compatibility, I would assume you can start using timbre without removing tools.logging
20:13kenrestivothis crossclj is amazing though. i think i've already said that, but i'm still amazed at how useful it is.
20:13rkneufeld_Feel like I'm going crazy, clj-http is raising a "java.lang.IllegalStateException: Attempting to call unbound fn: #'clj-http.client/update" exception for me when I make a get. Anyone ever run into this?
20:13justin_smithkenrestivo: yeah, it is great
20:14justin_smithrkneufeld_: did you change your project.clj recently? that sounds like a weird interaction between compiled bytecode and a new version of a lib
20:14justin_smithrkneufeld_: can't hurt to exit, run lein clean, and run things again
20:14rkneufeld_justin_smith: it's certainly possible its changed since the last time I made a get. I'll clean (thanks for reminding me)
20:14kenrestivo+1 for lein clean. also lein deps :tree
20:15justin_smithyeah, that is the kind of bizarro symptom old compiled files have (calling code in it's own package that doesn't exist)
20:16rkneufeld_Fixed. Thanks for rubber-ducky-ing with me ;)
20:17justin_smithrkneufeld_: the first 10 times I dealt with that I was totally stumped
20:17justin_smithbut the symptoms are very clear once you know them :)
21:42rritochIs potemkin a viable alternative to gen-class to provide inheritance in clojure?c
22:01kenrestivowhy, other than showing off use of squiggly macro-y things, would one do `(~@path :foo) instead of (-> path vec (conj :foo))
22:02justin_smithor (concat path [foo])
22:02kenrestivoeven better, yeah
22:03amalloykenrestivo: i don't find (-> path vec (conj :foo)) terribly easy to read
22:03kenrestivoi agree. (concat path [foo]) is much better
22:03amalloy`(~@path :foo) is pretty clear about what it's building, because it looks like what it is
22:04amalloy(concat path [:foo]) is fine too
22:04kenrestivomy point is, why would one use swear characters in something like that instead of easy-to-read functions like concat?
22:05kenrestivois there some other good reason i'm missing?
22:05amalloybecause why not? you're starting from this weird assumption that using ~@ is hard to read; from that perspective, of course using it looks dumb
22:07kenrestivoi just find it jarring to see splicing and unquoting occurring in places other than macros. yes it's a personal preference.
22:08amalloykenrestivo: that's a fine personal preference to have, although my advice is that when there's a style that you find hard to read, the answer is to work on that, rather than to request that nobody use it
22:09amalloy` is a great tool for building lists, and it can sometimes yield code that's easier to read than masses of concat and vector literals
22:09kenrestivowasn't requesting that. was asking if my preference is going to get me into trouble, i.e. if using the macro characters is better
22:09amalloykenrestivo: not at all, except that sometimes ~@ is more readable
22:09kenrestivogotcha, thanks.
22:10amalloykenrestivo: after all, the reader converts `(~@x :foo) to (seq (concat x (list ':foo))) or something similar to that
22:10amalloy,'`(~@x :foo)
22:10clojurebot(clojure.core/seq (clojure.core/concat x (clojure.core/list :foo)))
22:11yguanHi, there, get a question about defprotocol. How can I use deftype in another namespace? (ns this.ns (:require [nnss :refer :all])) seems not working
22:11kenrestivohah, cool. it's doing the concat thing under the hood anyway.
22:11amalloyso you can't really be making a technical error by writing it out longhand
22:12amalloyyguan: deftype creates a java class, which you have to import like any other java class (ie, with import)
22:12yguanI see, thanks, amalloy
22:16amalloyi wonder if it would be better for `[~x ~@y ~z] to produce something like (conj (into [x] y) z), instead of (vec (concat [x] y [z])). is there much expense in building those intermediate sequences?
22:17amalloypresumably it doesn't matter because ` is mostly used for macros, but it looks like a free improvement for any runtime uses
22:19amalloyi suppose vec and into aren't available early enough in the bootstrapping phase
22:21amalloykenrestivo: on the topic of "get better at code you find hard to read": years ago, i had trouble thinking of 'if as a statement rather than an expression: writing (f x (if foo y z)) confused me. so, i decided to make an effort to do the confusing thing myself until i had it handled. i think i actually did the same thing with using ` ~ ~@ in non-macro contexts, but i don't recall for sure
22:22kenrestivothanks. macroexpand-1 is helpful, as is '. also i find it helpful when dealing with swear characters to translate them, i.e. (quote (unquote (splice x)))
22:28kenrestivostill takes me extra effort to puzzle the stuff out sometimes though.
23:11kenrestivoany advice for mnemonics to remember which direction <! is versus >! ? keep getting 'em confused, kind of wish they'd been called "put" and "take"
23:11kenrestivo(on the topic of my mental block on special chars)
23:12justin_smithkenrestivo: one comes from the thing on the left, the other goes to it
23:12justin_smiththink about how it looks in a let block
23:13justin_smith(let [received (<! c)] (>! recieved outc))
23:13justin_smitherr I messed up the arg orders on that last one
23:13kenrestivosee what i mean
23:13justin_smithheh
23:13justin_smithI got the syms right, just not the arg order
23:14justin_smithanyway - with <! expect a binding to the left (that's where the data goes)
23:14justin_smithwith >! expect a channel to the right (that's where the data goes)(
23:15kenrestivook, arrow is pointing towards or away from the channel (1st arg), that works.
23:15justin_smithright
23:15justin_smithit's pointing in direction of data's flow
23:15kenrestivoi think i need to watch the talk on swearjure in a loop until i just don't care anymore :-)
23:16justin_smithhaha
23:23amalloykenrestivo: i think of the ! as the channel, and > as drawing a picture: !> looks like taking something out of the channel, and !< like putting something into it
23:24kenrestivothat works too, thanks.
23:24amalloyalthough maybe it's actually >! and <!? i don't actually use core.async; my mnemonic helps me read it, not write it :P
23:25justin_smithamalloy: you mean >! and <! right?
23:25justin_smithheh
23:27kenrestivo,(+ (*) (*))
23:27clojurebot2
23:27kenrestivowho needs numbers. swearjure is amusing.
23:28kenrestivoat some point i will seriously walk through swearjure until my aversion to weird symbols is gone
23:32justin_smith&@@@@@@@@@@(nth (iterate reduced 42) 10)
23:32lazybot⇒ 42
23:34kenrestivoi saw that the other day and lol'ed
23:35kenrestivoback to core.async. is there some way to check if there's anything available, without blocking?
23:35justin_smithspeaking of usage of symbols that approach meaninglessness :)
23:35kenrestivoi'm thinking about a kill-chan, at the top of a go-loop, before doing things, and before recurring, that'll shut down the loop if anything is available in the kill-chan
23:35kenrestivobut obviously i don't want to block.
23:36justin_smithkenrestivo: why not alts on a kill chan and your input at the top of the loop?
23:36justin_smithI think that's the typical way to do it
23:36kenrestivoi guess an alt and a channel that returns immediately would do the trick
23:40justin_smitha typical go loop will have input from a channel at the top anyway, so you just alt that with a poison channel... no need to make a special immediately returning channel for that to work
23:41kenrestivosadly, crossclj has failed me for the first time: "No usages found for clojure.core.async/alts!"
23:49justin_smithyeah, we need to start submitting everything that gets used to crossclj.info
23:55kenrestivooddly, i think it does spider, since my utility lib got added somehow.