#clojure logs

2015-08-13

00:09justin_smith,(apply str (map {\n 7 \r 2 \e 5 \h 0 \t 5 \u 3} "hunter2"))
00:09clojurebot"037552"
01:14ambrosebswhere does the Clojure compiler convert '1 to be the same as 1 ?
01:20ambrosebsfound it, clojure.lang.Compiler$ConstantExpr/parse
01:23qracspdoes clojure have list comprehensions
01:23justin_smithqracsp: sure, for
01:24qracspi dont think that is a full blown list comprehension equivalent? or am I wrong?
01:24justin_smithfor doesn't do everything that a haskell lisp comprehension does, but mix it up with range and map and you can get the functionality
01:24justin_smithit's the closest we have at least
01:25Kneivahaskell lisp comprehension =)
01:26qracsp,(for [x (range 4) y (range 4) :while (< y x)] [x y])
01:26clojurebot([1 0] [2 0] [2 1] [3 0] [3 1] ...)
01:26qracsp,(for [x (range 4) y (range 4) :while (< y x)] (* x y))
01:26clojurebot(0 0 2 0 3 ...)
01:26qracspcool.. seems pretty complete to me.. what is it missing? binding values to variables?
01:27justin_smithqracsp: x..y type notation
01:27justin_smithwe have :let for the binding part
01:29amalloyjustin_smith: i think clojure's for has all the features of a haskell list comprehension, plus :while
01:30amalloythe [1,2..10] thing is a feature that sees use entirely separate from list comprehensions
01:30justin_smithamalloy: OK so list comprehension and x..y interpolation are two totally different things I was conflating?
01:30justin_smithgot it
01:31amalloyjustin_smith: yeah, for any instance of Enum you can use that range notation in any context to get a list of the legal values
01:31qracsp:while filters results?
01:31amalloy['a','c'..'m'] works, for example
01:32justin_smithqracsp: :when filters, :while truncates
01:32qracspah
02:01luxbockwait how are :while and :when different?
02:01luxbock,(= (for [x (range 10) y (range 10) :when (> x y)] [x y]) (for [x (range 10) y (range 10) :while (> x y)] [x y]))
02:01clojurebottrue
02:02qracspI believe the difference is the same as between take and filter
02:02justin_smith,(for [x [:a :b :c :d] :when (#{:a :c} x)] x)
02:02clojurebot(:a :c)
02:02justin_smith,(for [x [:a :b :c :d] :while (#{:a :c} x)] x)
02:02clojurebot(:a)
02:03qracsp,(= (for [x (range 2) y (range 2) :when (> x y)] [x y])
02:03clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
02:03qracsp,(for [x (range 2) y (range 2) :when (> x y)] [x y])
02:03clojurebot([1 0])
02:03qracsp,(for [x (range 2) y (range 2) :while (> x y)] [x y])
02:03clojurebot([1 0])
02:04qracsphmm
02:04justin_smithit's just coincidence
02:04justin_smithit's the first result, also the only one that meets the constraint
02:04qracsp,(for [x (range 2) y (range 2)] [x y])
02:04clojurebot([0 0] [0 1] [1 0] [1 1])
02:04justin_smithtry chaning the 2s to 3s
02:05qracspso while first drops the elements that don't match, then takes those that do, then stops?
02:05justin_smith,(for [x (range 3) y (range 3) :when (> x y)] [x y])
02:05clojurebot([1 0] [2 0] [2 1])
02:05justin_smith,(for [x (range 3) y (range 3) :while (> x y)] [x y])
02:05clojurebot([1 0] [2 0] [2 1])
02:06qracsp,(for [x (range 3) y (range 3)] [x y])
02:06clojurebot([0 0] [0 1] [0 2] [1 0] [1 1] ...)
02:06qracspI guess I expected while to return [] there
02:06luxbock,(for [x (range 4) y (range 4) :while (even? x)] [x y])
02:06clojurebot([0 0] [0 1] [0 2] [0 3] [2 0] ...)
02:06luxbock,(for [x (range 4) y (range 4) :when (even? x)] [x y])
02:06clojurebot([0 0] [0 1] [0 2] [0 3] [2 0] ...)
02:07justin_smithqracsp: oh yeah, that is odd isn't it
02:09qracspyeah.. I don't quite get it
02:10justin_smith,(for [x (range x)] :while (odd? x)] x)
02:10clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
02:10justin_smith,(for [x (range x) :while (odd? x)] x)
02:10clojurebot#error {\n :cause "Unable to resolve symbol: x in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: x in this context"\n ...
02:10justin_smith,(for [x (range) :while (odd? x)] x)
02:10clojurebot()
02:10qracspah
02:10justin_smith,(for [x (range) :when (odd? x)] x)
02:10clojurebot(1 3 5 7 9 ...)
02:11qracspso :while stops current iteration on failure, not the entire thing
02:11justin_smith,(for [x (range) y (range) :while (odd? x)] [x y])
02:11luxbockI have used :when before but :while never
02:11clojurebot([1 0] [1 1] [1 2] [1 3] [1 4] ...)
02:11qracsp(unless entire thing is just a single iteration)
02:12justin_smithclearly :while is weird when you have multiple collections
02:14justin_smith,(for [x (range) y (range) :while (odd? y)] [x y])
02:14clojureboteval service is offline
02:16justin_smithwoah - that is weird
02:16justin_smithamalloy: why would the above for comprehension just stall (even in a normal repl where I wrap it in (take 1000 ...))
02:17justin_smithwhere the version testing x instead has :while acting like :when
02:17justin_smithhas my CPU pegged at 100% on one core
02:18justin_smithoh, it's iterating the entirety of the values for x so it can get to the part where y changes
02:19justin_smithof course
02:19justin_smithlol
02:29luxbockjustin_smith: I just tried (for [x (range 1 10) y (range 1 100 x)] [x y]) and a few variations of it and got the same thing
02:32amalloyjustin_smith: it gives up on the current y, not the current x
02:32amalloyrather, i guess, the current x, not all xs
02:33qracsp,(for [x (range) y (range 2) :while (odd? x)] [x y])
02:33clojurebot([1 0] [1 1] [3 0] [3 1] [5 0] ...)
02:34qracspso :while breaks inner-most loop
02:34qracspor all loops but outter-most
02:35amalloythe innermost
02:35qracsp,(for [x (range) y '(8) z '(9) :while (odd? x)] [x y])
02:35clojurebot([1 8] [3 8] [5 8] [7 8] [9 8] ...)
02:35qracsp,(for [x (range) y '(8) z '(9) :while (odd? x)] [x y z])
02:35clojurebot([1 8 9] [3 8 9] [5 8 9] [7 8 9] [9 8 9] ...)
02:36qracsp,(for [x (range) y '(8) z '(9 9) :while (odd? x)] [x y z])
02:36clojurebot([1 8 9] [1 8 9] [3 8 9] [3 8 9] [5 8 9] ...)
02:36qracspyeah inner-most
02:45luxbockwhat other interfaces do I have to implement besides ILookup Seqable IPersistentCollection Associative IPersistentMap to have `get` work on my custom deftype?
02:45luxbockI'm getting an AbstractMethodError
02:46luxbockI was following this example: http://david-mcneil.com/post/16535755677/clojure-custom-map
02:46luxbockbut that one doesn't actually implement `get`
02:50amalloyluxbock: an actual error message and stacktrace is a thousand times more useful than "i'm getting an X error"
02:52luxbockthe stacktrace is basically just RT.java: clojure.lang.RT/get giving the AbstractMethodError, which I know happens when I haven't implemented the right interface
02:53luxbockI have implemented clojure.lang.ILookUp which I thought would be enough
02:53qracspwhat was the rationale behind using CL-style maros in clojure over scheme's hygienic macros?
02:56luxbockhere is the whole definition and the stacktrace in case it helps: https://gist.github.com/luxbock/5ed7ad8146f20ee3d425
03:01luxbockhmm appears that (deftype Foo [x] clojure.lang.ILookup (valAt [this k] x)) actually is enough so I must be doing something else that's wrong
03:06luxbockrestarting the REPL fixed the issue
05:05mskoudHow to go from [0 1 2 3 4 5] to [[0 1] [1 2] [2 3] [3 4] [4 5] [5 nil]]
05:09Macnubemskoud: probably something like (map cons my-vec (conj (rest my-vec) nil))
05:10Macnubeit won't be cons in clojure actually
05:11Macnubemaybe vec, any function that takes two things and makes a vector out of them
05:14amalloypartition
05:20Kneiva,(partition-all 2 [1 2 3 4 5])
05:20clojurebot((1 2) (3 4) (5))
05:20Kneivaalmost
05:20mskoud,(partition-all 2 1 [1 2 3 4 5])
05:20clojurebot((1 2) (2 3) (3 4) (4 5) (5))
05:20mskoudthx.
05:24Macnubethats nice - thanks for that.
05:26luxbockI find writing tests with test.check really fun for some reason
05:26luxbockcoming up with the right generator is like a fun puzzle
05:39kwladykai will be glad if somebody can give me code review (code is short) https://github.com/kwladyka/chess-challenge and pull request if somebody prefer https://github.com/kwladyka/chess-challenge/pull/1
05:39kwladykai am asking about all project, also about tests, not only about main code
05:42kwladykaluxbock, i didn't use test.check yet, but what i saw it should be very good idea
06:35Kneivakwladyka: have you run your code through some linter?
06:35kwladykaKneiva, linter?
06:36OlajydHi
06:36Kneivakwladyka: Something like these: https://github.com/jonase/eastwood https://github.com/jonase/kibit
06:37kwladykaKneiva, no i didn't
06:38Olajydhow can i implement clojure substring to use a negateive offset? I want to get the last 4 string in a given string, somthing like (substring “clojure” -1 4) will give something like “jur” ? somebody help!!
06:39kwladykaOlajyd, did you try http://clojuredocs.org/clojure.core/subs ?
06:39Kneivakwladyka: Your code seemed pretty clean but I recommend giving those a try.
06:39kwladykaKneiva, thx
06:41Olajyd@kwladyka: yes I have, I want to know if its possible to use a negative index to get the past postion of a given string?
06:41Olajyd*last
06:42kwladyka,(subs "abcd" -3)
06:42clojurebot#error {\n :cause "String index out of range: -3"\n :via\n [{:type java.lang.StringIndexOutOfBoundsException\n :message "String index out of range: -3"\n :at [java.lang.String substring "String.java" 1871]}]\n :trace\n [[java.lang.String substring "String.java" 1871]\n [clojure.core$subs invokeStatic "core.clj" 4783]\n [clojure.core$subs invoke "core.clj" -1]\n [sandbox$eval25 invokeStatic ...
06:42kwladyka,(subs "abcd" 1 -3)
06:42clojurebot#error {\n :cause "String index out of range: -4"\n :via\n [{:type java.lang.StringIndexOutOfBoundsException\n :message "String index out of range: -4"\n :at [java.lang.String substring "String.java" 1911]}]\n :trace\n [[java.lang.String substring "String.java" 1911]\n [clojure.core$subs invokeStatic "core.clj" 4784]\n [clojure.core$subs invoke "core.clj" -1]\n [sandbox$eval49 invokeStatic ...
06:42kwladykammm i guess not :)
06:43kwladyka,(subs "abcd" -5 3)
06:43clojurebot#error {\n :cause "String index out of range: -5"\n :via\n [{:type java.lang.StringIndexOutOfBoundsException\n :message "String index out of range: -5"\n :at [java.lang.String substring "String.java" 1904]}]\n :trace\n [[java.lang.String substring "String.java" 1904]\n [clojure.core$subs invokeStatic "core.clj" 4784]\n [clojure.core$subs invoke "core.clj" -1]\n [sandbox$eval73 invokeStatic ...
06:44kwladykaOlajyd, but you do something like ##(subs "abcd" (- (count "abcd") 2))
06:45kwladykaeh i dont know how to speak with lazy-bot
06:45Olajydlolz
06:45kwladyka,(subs "abcd" (- (count "abcd") 2))
06:45clojurebot"cd"
06:48Olajydthanks buddie @kwladyka
06:57clgvHi, I am currently puzzled by the following strange NPE: (defmacro foo [[a, b, c], & ds] (let [f (or (:f c) :g)])) (foo [1 2 3]) => NullPointerException user/foo
06:57clgv,(defmacro foo [[a, b, c], & ds] (let [f (or (:f c) :g)]))
06:57clojurebot#'sandbox/foo
06:57clgv,(foo [1 2 3])
06:57clojurebotnil
06:57clgvinteresting.
06:58clgv,(clojure-version)
06:58clojurebot"1.8.0-alpha3"
07:00clgvthere must be some strange interaction in the project repl...
07:12hyPiRionclgv: might be technomancy/leiningen#1668
07:12hyPiRionoh where's lazybot
07:12hyPiRionhttps://github.com/technomancy/leiningen/issues/1668
07:22clgvhyPiRion: ah well, it was a redefinition of a clojure.core funciton in that namespace :/
07:30hyPiRionhumm
08:16wes_ellisThis doesn't work like I expect: (reduce some? [nil nil nil])
08:17clgvwes_ellis: what is that supposed to do? did you mean `remove` or `filter` instead of `reduce`?
08:17clgv,(doc some?)
08:17clojurebot"([x]); Returns true if x is not nil, false otherwise."
08:17clgv^^
08:18clgvonly 1-arity
08:18wes_ellisoh
08:21wes_ellisI've got maps that may or may not have a kv pair. I collect them in a vec (map :training [yesterday today tomorrow]) => [nil nil nil] or [x nil y] or [x x x]
08:22wes_ellisI want to generate a row in a table only if a crew is on training (when (...) (dom/tr nil ...))
08:22wes_ellisSo I want to check if at least one item in the vec is not nil
08:27clgvwes_ellis: does `keep` as a replacement for `map` solve your use case?
08:28wes_ellis(when-not (every? nil? [...]) ...)
08:29wes_ellisthanks
09:34dabd,0
09:34clojurebot0
09:36dabd,08
09:36clojurebot#<NumberFormatException java.lang.NumberFormatException: Invalid number: 08>
09:36dabdyup anyone noticed this weird bug?
09:36dabdif you evaluate 08 or 09 on the repl it will throw an exception
09:36dabd,07
09:36clojurebot7
09:36dabd,09
09:36clojurebot#<NumberFormatException java.lang.NumberFormatException: Invalid number: 09>
09:37clgvdabd: octal number format ;)
09:37clgv,010
09:37clojurebot8
09:37dabdoh
09:38dabdneed to RTFM
09:39clgvdabd: it's tricky and not optimal the 8r10 is better readable
09:39clgv,8r10
09:39clojurebot8
09:40clgv,16r10
09:40clojurebot16
09:40jonathanj_,10r16
09:40clojurebot16
09:40clgv:P
09:42clgv,20rH
09:42clojurebot17
09:43justin_smith,(= 8r10 10r8)
09:43clojurebottrue
09:44jonathanj_So how does one re
09:44jonathanj_Read that?
09:45justin_smithjonathanj_: so you wan tto read 080 and get 80 back?
09:45jonathanj_I meant read in the English sense
09:46Bronsa10r8 is 8 base 10
09:46Bronsa8r10 is 10 base 8
09:46hyPiRion,26repl
09:46clojurebot10135
09:46BronsahyPiRion: disgusting.
09:46jonathanj_But I guess 10r16 means 0x10, not 10 decimal
09:47justin_smithjonathanj_: no, that means 16 in base 10
09:47justin_smith,16r10
09:47clojurebot16
09:47Bronsa16r10 is 0x10
09:47jonathanj_,10r10
09:47clojurebot10
09:47jonathanj_Err
09:48jonathanj_That's not what I meant
09:48Bronsa,[0x11 16r11 11r16]
09:48clojurebot[17 17 17]
09:48Bronsa◔ ◡ ◔
09:48jonathanj_,16ra
09:48clojurebot10
09:48Bronsa,[0x8 16r8 8r16]
09:49clojurebot[8 8 14]
09:49Bronsathere
09:49ambrosebsBronsa: why is :val and :form different here (TAJ)? ((juxt :form :val) (analyze {:a ''1})) => [{:a (quote 1)} {:a 1}]
09:49ambrosebsor where does this happen?
09:50Bronsaambrosebs: looks like a bug
09:50jonathanj_justin_smith: and then going the other way, converting decimal to a base?
09:50justin_smithjonathanj_: that can be done with format iirc
09:51Bronsaambrosebs: I'll take a look this evening and let you know
09:51opqdonut,(Integer/toString 12 8)
09:51clojurebot"14"
09:51opqdonut,(Integer/toString 100 50)
09:51clojurebot"100"
09:51dhtns,(Integer/toString 43007316 36)
09:51clojurebot"plsno"
09:51clgvjonathanj_: converting between bases is a good learning exercise, if anyone is asking for those ;)
09:51opqdonutdhtns: heh
09:51ambrosebsBronsa: ok, I'm struggling to reconcile Compiler$ConstantExpr and :quote nodes.
09:51jonathanj_dhtns: :)
09:52dhtnsCan you do this with BigIntegers or floats?
09:52dhtns(I'm new to clojure)
09:53clgvdhtns: you can certainly do that - is there an API function? no idea, you got to look that up in the javadocs ;)
09:55justin_smithformat only does bases 8 and 16, but pprint/cl-format likely does it
09:56justin_smith,(require 'clojure.pprint)
09:56clojurebotnil
09:57justin_smith,(clojure.pprint/cl-format nil "dhtns: ~26r" 9999999999999.44)
09:57clojurebot"dhtns: 9.99999999999944E12"
09:57justin_smithoh wait...
09:57justin_smith,(clojure.pprint/cl-format nil "dhtns: ~26r" 9999999999999)
09:57clojurebot"dhtns: 1ln1797e79"
09:58dhtnsGreat, thanks :)
09:58justin_smithsee that's what I expected
09:58justin_smithit seems not to want to do floats in weird radixes
09:59justin_smith,(clojure.pprint/cl-format nil "fun trick: ~r" 9999999999999)
09:59clojurebot"fun trick: nine trillion, nine hundred ninety-nine billion, nine hundred ninety-nine million, nine hundred ninety-nine thousand, nine hundred ninety-nine"
09:59dhtnsWow that is awesome :)
09:59hyPiRionI like the roman numerals better
09:59justin_smithI wonder if that is properly localized
10:00clgv$source clojure.pprint/cl-format
10:00justin_smith,(clojure.pprint/cl-format nil "for hyPiRion: ~:@r" 9999999999999)
10:00clojurebot"for hyPiRion: 9,999,999,999,999"
10:00justin_smitherr
10:00hyPiRionjustin_smith: hard limit on 15000 or something
10:00justin_smith,(clojure.pprint/cl-format nil "for hyPiRion: ~:@r" 999)
10:00clojurebot"for hyPiRion: DCCCCLXXXXVIIII"
10:01justin_smithhyPiRion: is that laziness, or just the domain of roman numerals?
10:01dhtnsjustin_smith: Roman numerals don't have a representation for anything above 1000
10:01dhtnsexcept using a bazillion Ms
10:01dhtnsAlso, that representation isn't minimal
10:01clgvjustin_smith: I prefefe CM over DCCCC ;)
10:01justin_smithI guess "a bazillion Ms" is left as an exercise for the reader
10:02justin_smith,(clojure.pprint/cl-format nil "for clgv: ~@r" 999)
10:02clojurebot"for clgv: CMXCIX"
10:02clgv*prefer
10:02clgvhehe
10:02clgvjustin_smith: where is that cryptic syntax explained?
10:02hyPiRion$google cl format documentation
10:03clgvok some common lisp docs ;)
10:03hyPiRionclgv: http://www.gigamonkeys.com/book/a-few-format-recipes.html is a good starting point
10:03justin_smith,(clojure.pprint/cl-format nil "~[a~;b~;c~]" 2)
10:03clojurebot"c"
10:04justin_smiththere is also, of course, the authoritative clhs
10:05dhtns,(clojure.pprint/cl-format nil "~36r" 671422091632103965497663578811235974322835963177842)
10:05clojurebot"allworkandnoplaymakesjackadullboy"
10:05dhtnsheh
10:05justin_smithlol
10:07Bronsaambrosebs: committed a fix in t.a, was a bug in the pass that transforms constant :map/:vector/:set nodes into :const nodes
10:09ambrosebsBronsa: thanks!
10:09tmtwdi'm having trouble with this question http://clojurescriptkoans.com/#functions/7
10:10tmtwdI want to do (= 9 (((fn [] ) (fn [ a b] (+ a b))) 4 5)) but I get a wrong number of args exception
10:10tmtwd(its supposed to be true)
10:12justin_smithwhat is (fn [] ) doing in there?
10:12justin_smith,(= 9 ((fn [a b] (+ a b)) 4 5))
10:12clojurebottrue
10:13justin_smithif you take the (fn []) out it works as expected
10:13justin_smithperhaps you wanted ##(= 9 ((fn [] ((fn [a b] (+ a b)) 4 5))))
10:14justin_smith,(= 9 ((fn [] ((fn [a b] (+ a b)) 4 5))))
10:14clojurebottrue
10:16tmtwdjustin_smith, its for the sake of the exercise, but it may have been poorly written
10:16justin_smithtmtwd: (fn []) takes 0 args and returns nil, so it seems out of place in your code
10:17tmtwdi see
10:21tmtwd(= 25 ( ________ square)) what would I put in here to make it return true?
10:22opqdonut,(= 25 (or 25 square)) -- :P
10:22clojurebot#error {\n :cause "Unable to resolve symbol: square in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: square in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: square in t...
10:23clgvShort Clojure test.check question: I have a generator that produce two list, one containing things of type A and one containing things of type B, now I want to combine them to a generator that returns a list containing tuples for each element A and a random selection from the list of Bs
10:25hefestoHi :) I am having trouble using import. When I do "(import '(com.bm.bmi.antlr DateExprLexer))" on my repl I get a java.lang.ClassNotFoundException. My DateExprLexer.java is on the package com.bm.bmi.antlr and this is my file structure: https://gist.github.com/hhefesto/dd544c52865dade99455
10:25clgvexample LA = (A1 A2 A3), LB = (B1 B2 B3 B4 B5 B6) => desired result ([A1 (B1 B4)] [A2 (B2 B3)] [A3 (B1 B5)])
10:27clgvI need some generator constructor that maps over LA that could return (fn [A, LB] (gen/tuple (gen/return A) (gen/random-subset LB))) - is there such a generator constructor in test.check?
10:28clgvreiddraper: ping?
10:29reiddraperclgv: sounds like fmap is what you want
10:29clgvreiddraper: but fmap returns values and not generators
10:30reiddraperthen gen/bind if you want to return a generator
10:31clgvreiddraper: ok, right that's where I am (gen/bind (gen/tuple A-gen B-gen) (fn [[LA, LB]] ...))
10:32clgvreiddraper: now the tricky part remains, which map like generator exists that can use the above (fn [A LB] ...)?
10:34clgvin principle I know the single element generators that I need and require a generator that just concatenates those
10:34clgvthe distinct element generators
10:37clgvreiddraper: looking at the source of gen/vector it seems like gen-seq->seq-gen could be interesting
10:38reiddraperclgv: i would probably bind twice, the (fn [A LB] (gen/tuple (gen/return a) (gen/vector (gen/random-subset LB) (count A))), or something
10:38reiddraperthen zip those together
10:40justin_smithopqdonut: or (fn [f] (f 5))
10:41clgvreiddraper: I think I'd need something like (gen/return-list (map (fn [A] (gen/tuple (gen/return A) (gen/random-subset LB))) LA)
10:56clgvha, I ended up reimplementing `gen/tuple`, so (apply gen/tuple ...) is what I have been looking for
11:10hefestoI solved my import problem :) I just changed the file structure to coincide with my package name structure. But I am still unsure of where on my lein file structure I should put my java classes and how to import them (i.e. what should the java package name should be and should the import reference the file structure or the package tree).
11:33ambrosebsBronsa: it seems like KeywordInvoke nodes are only created in the body of functions (eg. #(:a %)), but TAJ always converts to :keyword-invoke when it can, even outside a function eg. (:a %). Is that right?
11:33ambrosebsthe former I'm talking about Compiler$KeywordInvoke
11:35Bronsaambrosebs: yeah, that's a small difference in how temj compiles stuff vs how Compiler.java does it
11:35ambrosebsok cool
11:35Bronsaambrosebs: temjvm always compiles, compiler.java sometimes interprets
11:35ambrosebsahk
11:36Bronsaambrosebs: no big difference if a :keyword-invoke is an :invoke btw
11:36ambrosebsgood to know
11:37BronsaI woulnd't waste your time trying to make the AST 100% the same, a valid and equivalent AST is fine
11:38Bronsaambrosebs: just as you shouldn't bother trying to make the tags the same -- saw your comment in code about APM vs PAM
11:39ambrosebsnice
11:40ambrosebsI'm guessing which is more expensive: reflective calls to getJavaClass or using a TAJ pass
11:40ambrosebstrying the former for now
12:15firevolttrying to learn clojure makes me feel like I should have gone to school lol
12:18clgvhefesto: you can organize them separately as you like, see :source-paths and :java-source-paths
14:11AxisOfEvalAnyone on the new clojure 1.7.0? I think I might have found a bug... Either that, or I'm not doing something right...
14:23clarkencieldoes anyone know of sound synthesis/analysis work done in clojure?
14:27aengelbergAxisOfEval: I've been using it for a while with no issues :) what seems to be the bug?
14:30justin_smithclarkenciel: yes! check out kunstmusic/pink for example
14:30justin_smithclarkenciel: for dsp in pure clojure
14:31AimHereclarkenciel, Rich Hickey, the clojure creator, did a talk a couple years back at one of the conjs about some musical work he was doing in clojure. Can't remember the details as to what he was doing though
14:31justin_smithclarkenciel: overtone is more popular, but all its dsp is done in supercollider
14:32justin_smithAimHere: iirc that was using overtone - the sad thing to me is that the interesting stuff is all being done in c++
14:38clarkencieljustin_smith: I'll check those out, particularly kunstmusic
14:39clarkencieliirc even supercollider is mostly c++ anyway
14:39justin_smithclarkenciel: kunstmusik is the org (I spelled it wrong, sorry), pink is the project https://github.com/kunstmusik/pink
14:39clarkencielat least the neat chaotic synths
14:40clarkencielahhh thanks
14:40justin_smithclarkenciel: that was my point - the interesting stuff is offloading to supercollider
14:41justin_smithI mean if all you want is algorithmic composition, and you don't care about the processing/DSP part, then yeah overtone is good, but if you're interested in implementing novel processing in clojure, pink is the one to use
14:41clarkencielboth would be the ideal right? :)
14:41justin_smithyeah - pink has a composition library too, but less mature than overtone
14:42justin_smitherr, kunstmusic has score to go with pink for composition that is https://github.com/kunstmusik/score
14:42clarkencielI'm coming from ChucK and a little bit of extempore so I'm used to building a lot of my own stuff
14:42justin_smithcool
14:43oddcullyjustin_smith: musik is music. and kunst here is a little play on words. it means either art or artificial
14:43justin_smithclarkenciel: steven yi who does pink and score is one of the lead csound devs
14:43justin_smithoddcully: yeah, I just get the german spelling wrong :)
14:43justin_smithoddcully: he is definitely coming from the art-music school of composition too
14:52clarkencielscore has Xenakis sieves built in!? be still my heart!
14:52justin_smith:)
14:52justin_smithI should re-read that book again soon, I've learned a lot of math since I last tried
14:52justin_smith(Xenakis' Formalized Music that is - lots of awesome higher math / composition crossover there)
14:53clarkencielit blew my mind the first time through. It doesn't seem to be taught as widely as it should be
14:53justin_smithdefinitely not
14:53justin_smithclarkenciel: this kind of stuff was what got me into programming actually - I started with experimental music
14:54justin_smithwhich of course is why I ended up with wacky languages like clojure
14:54clarkencielsame!
14:56justin_smithI try to let the weird music stuff tag along, so am now brainstorming ways to use distributed computation (what I am doing at work) for live audio processing
14:56justin_smitheg. doing heavy signal processing on AWS or digital ocean during a live performance...
14:57clarkencieland then simply streaming the results into the composition environment?
14:58justin_smithclarkenciel: idea being that I would build a sytem for live processing that has some element of batched / delayed results
14:59justin_smithclarkenciel: for example send the raw audio, have the cluster collaborate to generate variations, that are pushed back to the live environment and triggered or pulled in later
14:59justin_smithclarkenciel: kind of blurring the event / signal distinction in this (as a stylistic choice)
15:00clarkencieljustin_smith: ahh, v. cool. sounds like a kind of automated telemusic (is that the term)?
15:00justin_smiththat sounds about right, yeah
15:01justin_smithclarkenciel: and there's some nice conceptual rhyme between granular techniques (xenakis intended that they emulate the physics of clouds) and cloud computing :)
15:02clarkencieljustin_smith: haha indeed! it also sounds similar, but on a larger scale, to some of the work that the HUB did back in the day.
15:02justin_smithHUB?
15:02oddcullyhubbard?
15:03clarkencieloddcully: lol yeah, Freddie's computer music group!
15:03clarkencieljustin_smith: the HUB were a live programming group from the 90s from SoCal that focused on networked performance. Mark Trayle and some other guys.
15:04justin_smithahh
15:04clarkencielhttps://en.wikipedia.org/wiki/The_Hub_(band)
15:06justin_smithclarkenciel: I know Bischoff and Niblock (but not well enough to have known HUB), looks interesting
15:07clarkencieljustin_smith: some of it sounds like a 90s computer game gone awry, but the organizations of some of the pieces are compelling.
15:08justin_smithclarkenciel: I just paused a Kevin Drumm album, so I'm open minded about the computer game noises
15:09oddcullyand i thought i know them all,,, now there is "drone metal"
15:10justin_smithoddcully: I really wouldn't call drumm metal (I am sure he wouldn't use the term)
15:10justin_smithI mean it's loud distorted guitar, but that's not enough to make it metal
15:12clarkencieljustin_smith: haven't heard of Kevin Drumm, recommendations?
15:13justin_smithoooh... Sheer Hellish Miasma - youtube clips from that album are easy to find. It's less cerebral than the stuff we've been talking about, I was making the timbre/texture comparison.
15:13oddcullythat is what wikipedia said. so from context i assumed some SID coder
15:14justin_smithclarkenciel: https://www.youtube.com/watch?v=276by41fHIk
15:14oddcullyyet... this goes OT :*)
15:14justin_smithoddcully: very much so, apologies
15:14oddcullynp. i helped
15:15clarkencieloh this is v. nice
15:37sdegutisHi.
15:56{blake}I have unsuccessfully tried to use conjure for mocking and stubbing.
15:56{blake}Anyone have other suggestions?
15:56sdegutisConjure? Link?
15:56sdegutis{blake}: (proxy) is usually good at that
15:56sdegutis(doc proxy)
15:56clojurebot"([class-and-interfaces args & fs]); class-and-interfaces - a vector of class names args - a (possibly empty) vector of arguments to the superclass constructor. f => (name [params*] body) or (name ([params*] body) ([params+] body) ...) Expands to code which creates a instance of a proxy class that implements the named class/interface(s) by calling the supplied fns. A single class, if provided, must be first. If not provided it default
15:57{blake}sdegutis: https://github.com/amitrathore/conjure
15:57{blake}It looks good, but it doesn't seem to work much beyond the very simple example.
15:58{blake}Proxy, eh?
15:59{blake}Like, I literally took the exact example there and had a function sum the results of xx and yy and it raised an exception.
16:00sdegutisamalloy or justin_smith: can you please show this fine gentleman a simple yet powerful example of proxy in action
16:01Bronsasdegutis: how exactly would proxy help with his problem?
16:01sdegutisMocking.
16:02sdegutisAnd maybe stubbing.
16:02sdegutisBronsa: whatever im internetfamous now i dont need your approval anymore all of reddit loves me now
16:02Bronsadid I miss something or he never mentioned anything that would suggest he's doing interop?
16:03{blake}I am not interopping.
16:03amalloyplease don't ping me for conversations i am not in and that aren't somehow related to me personally. if i'm able and interested in answering questions, i'll do so
16:03Bronsasdegutis: I'm honestly getting tired of your filling this channel with noise and nonsensical/unrelated stuff
16:04sdegutisWelp, you're the boss. Cya.
16:04oddcully /ignorance is bliss
16:05blkcatvi con
16:05blkcatoops
16:06{blake}I suppose I could switch to midje.
16:13justin_smith{blake}: I find the classic function approach with mutable / side effecting things on the outside and immutable functional things on the inside makes this much easier
16:14justin_smithso I make a functional core (easy to test, uses parameterization or first class functions instead of mocking) and then a mutable / side effecting wrapper on the outer layer
16:14justin_smiththe thinner that outer layer, the less you have to worry about actually testing any of it
16:17{blake}justin_smith: Sound advice. This is pretty thin: I've got a routine that calls a database routine, and I'm trying to just capture what was sent.
16:17{blake}(Arguably it doesn't need testing.)
16:23justin_smith{blake}: with the approach I am describing, the database call would be a function you pass in (which would be passed in by the actual code used in production), and it would be so thin that it's test would belong in the db lib's code, and during testing you pass in something that collects its input
16:24justin_smithso you'd have like (def do-the-thing [collector & args] ...) then in the real code you have (do-the-thing db-call a b c) and in the test code you have (do-the-thing #(swap! collected conj %&) a b c)
16:25{blake}justin_smith: Oh, yeah, I get it. I always struggle with the whole designing-code-to-make-testing-easy thing.
16:25justin_smithit is so much easier than the mocking stuff though in the long run
16:26justin_smithand it's not just to make testing easy, it is also to cleanly separate the real world from the purely functional part of the code
16:26justin_smitheww real-world-cooties
16:26{blake}I know, right? The real-world has destroyed so much of my beautiful code.
16:27justin_smith{blake}: concrete example from the code I am working on right this very moment - I have various graph manipulating code, and then I pass in "transmit" which is a function that gets called to send intermediate results as available to the client
16:27justin_smithin the real code it will be a very thin function that either calls kafka or sente for http sockets
16:28justin_smiths/http/tcp
16:28justin_smithin the test code it can be whatever is convenient for verifying what is coming out (without having to construct or mock a full message system to run tests)
16:29{blake}Yeah, it may be my aversion to this comes from experience in less functional languages.
16:30justin_smith{blake}: recall that OO wants you to do the opposite - hide the ugly stuff in the core, and put a clean abstract layer around it
16:30justin_smithbut in my experience swapping out the outer shells is much simpler than swapping out the inner meat of things
16:31{blake}justin_smith: Oh, yeah.
16:35clausewitchI'm looking for the name of this problem: assume any hierarchy with unique parents, and a selection of elements in this hierarchy. When all children elements for an element is selected, the canconical representation would be to select the parent instead and "discard" the childrens status. Example: Selecting files in a filesystem, where selecting a directory means that all childrens are selected recursively. There mu
16:35clausewitchst be a well known algorithm for finding the canonical (most "parenty") selection of this hierarchy, but what is the name of it? (and is it already implemented in clojure.contrib or similar?)
16:37clausewitchIt feels like a problem suitable for clojure.walk, with a simple representation of the hierarchy as a nested map..
16:37{blake}clausewitch: How do you represent selected?
16:37{blake}I mean, you could use "every?" right?
16:38clausewitch{blake} a set, #{:europe :france} => #{:europe}
16:39{blake}So, you find a key, and then put all the key's children in the set?
16:39justin_smithclausewitch: we actually have heirarchies! including anonymous local heirarchies
16:39justin_smith(doc make-heirarchy)
16:40clausewitchOne way to do it would be to start with the root-node, and for every parent selected, remove its children from the selection. done.
16:40clojurebotHuh?
16:40justin_smith(doc make-hierarchy)
16:40clojurebot"([]); Creates a hierarchy object for use with derive, isa? etc."
16:40justin_smithclausewitch: https://clojuredocs.org/clojure.core/make-hierarchy
16:40{blake}oh, ha! There it is.
16:40{blake}(inc justin_smith)
16:41justin_smithclausewitch: and it has things like ancestors
16:42clausewitchjustin_smith: indeed, but not children.
16:42justin_smithclausewitch: depending on what you are doing, you could either use derive etc. directly and use the implicit global hierarchy of namespaced keywords, or use an anonymous local hierarchy
16:42{blake}inc justin_smith
16:42{blake}I've forgotten how to karma. =(
16:42justin_smith{blake}: I appreciate the sentiment, I don't think lazybot is around
16:42{blake}Huh. Well, it's a very cool thing I was previously unaware of. So: Thanks.
16:43justin_smith{blake}: np
16:44justin_smithclausewitch: actually you can get children https://clojuredocs.org/clojure.core/descendants
16:44clausewitchthe hierarchy have :parents :descendants and :ancestors, so a crude (but decent!) algorithm would be to take the selection (the set) and for each element in this set, remove the descendants looked up in the hierarchy as a reduce.
16:44justin_smithclausewitch: see my link
16:44clausewitchdescendants != children
16:44clausewitchbut it doesn't matter, thanks.
16:46clausewitchI can find the canonical representation by doing reduce over the selected set, and remove all descendants for each (remaining) item in the set. I don't know if there could be an optimal order for doing the reduce, but I don't think it matters for my problem anyway. Thanks :)
16:49clausewitchIt would be nice if the clojure.set could use the PersisentHashMap/Set indexes for it's set operations, like datascripts BT-operations by the way. Well well.
16:51amalloyclausewitch's problem sounds interesting. shame i just missed him
16:54justin_smithI would have liked to have gotten that descendents / children distinction
17:00amalloyi thought the problem description was fairly clear, wasn't it? given a tree with some nodes on it marked and some not marked, you want to convert every instance of "parent not marked, all children marked" to "parent marked, no children marked"
17:00justin_smithso a child is more specific then descendent in terms of being a direct leaf?
17:01amalloy(recursively percolating changes up towards the root)
17:01amalloyyes
17:01amalloyer, leaf?
17:01justin_smiththat's what I missed - sorry, bad choice
17:01justin_smithdirect downward link
17:01amalloyyes
17:01amalloythat is the usual thing in trees
17:02justin_smithahh, this could also be done with a post-walk (depending on how the rules would cascade...)
17:15arkhwill this be on the test?
17:16amalloyjustin_smith: yeah, exactly
18:55firevoltplease tell me there's a better way to do this: (#(str (:first %) " " (:last %)) {:first "Bob" :last "Smith"})
18:59amalloy(clojure.string/join " " (map m [:first :last])) would be my choice
19:00justin_smiththat map could also be ((juxt :first :last) m)
19:05amalloyit could. but i like mapping the map, because people forget you can do that. nobody ever forgets juxt
19:05firevoltcoworker's proposal: (reduce str (for [x {:first "Bob" :middle " " :last "Smith"}] (second x)))
19:05firevoltlol
19:06justin_smithfirevolt: that will get the order wrong quite easily
19:06justin_smith,apply format "%s %s" ((juxt :first :last) {:first "Bob" :last "Smith"}))
19:06clojurebot#object[clojure.core$apply 0x269a0e41 "clojure.core$apply@269a0e41"]
19:06justin_smith,(apply format "%s %s" ((juxt :first :last) {:first "Bob" :last "Smith"}))
19:06clojurebot"Bob Smith"
19:07firevoltInteresting
19:08firevoltI didn't even think about mapping the map. Those are both clever solutions. Haha thanks
19:11firevoltalso I guess format isn't in cljs
19:11justin_smithoh it isn't?
19:11firevoltGuess not
19:11justin_smiththat's too bad, I guess then use a string/join
19:11firevoltcrashed in LightTable, worked in lein repl
19:11firevoltI was more just interested in implementation than actually using it
19:12justin_smith,(clojure.string/join " " ((juxt :first :last) {:first "Bob" :last "Smith"}))
19:12clojurebot"Bob Smith"
19:12firevoltYeah that seems like the cleanest one
19:12justin_smithI only suggested format because the overal task might expand out to formatting an input better than joining one in the bigger picture
19:15amalloyyeah, it's funny how printf is still the crowning glory of string formatting
19:15justin_smithI had hoped that cl-format would have some extension for keys of a hash map
19:16justin_smithit would be a cool feature, but cl-format is lispy in an old school way, and old school lisp doesn't play with associatives
19:16justin_smitha syntax like "~::first ~::last" would be cool (actual syntax up for debate)
19:28amalloyold lisp had alists. i bet cl-format has a syntax for looking stuff up in them, and the clojure port might use maps instead of alists
19:29justin_smithamalloy: I checked, maybe not deeply enough...
19:29justin_smithamalloy: http://stackoverflow.com/questions/1263775/how-might-i-format-an-alist-in-common-lisp
19:30amalloywell, at least it supports roman numerals. no time for niche features like alists
19:30justin_smithhalf the answers are "just use a real list"
19:30justin_smithhaha
19:31tmtwd(= 5 (do ________ @atomic-clock)) what do I need to do here to return true?
19:31tmtwdusing swap! (i think http://clojurescriptkoans.com/#atoms/4)
19:41shokytmtwd you can use reset! too
19:42tmtwdshoky, oh thats right :)
19:46amalloywell the problem seems to suggest it wants you to use swap
19:46amalloyin which case something like (swap! atomic-clock + 5) would be the easy choice
19:51amalloyhaha justin_smith, i was just installing clisp so i can test out one of the answers to that question, and i noticed this line that brew uses to build it: ulimit -s 16384 && make
20:25justin_smiththat's a bit small for a stack isn't it/
20:26justin_smithor wait, no, that's not small at all...
20:29amalloyi don't know what the units are, but i presumed that nobody would bother to lower the stack size before calling make
20:29justin_smithd'oh, right :)
20:29justin_smithyeah, it's in k, so that is huge actually for a stack
21:40weebzHi, I'm wondering if this code to iterate through a sequence along with its index number is idiomatic clojure, or if there's a better way to do it
21:40weebzhttp://paste2.org/bBgGL5Ih
21:43justin_smithweebz: I would repleace (partition 2 (interleave (range (count file-lines)) file-lines) with (map list (range) file-lines)
21:43justin_smith,(map list (range) [:a :b :c])
21:43clojurebot((0 :a) (1 :b) (2 :c))
21:44weebz@justin_smith: I would agree that's much better, thank you :)!
21:55TEttinger(inc justin_smith)
21:55TEttingeraww lazybot