#clojure log - Aug 13 2015

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

0:09 justin_smith: ,(apply str (map {\n 7 \r 2 \e 5 \h 0 \t 5 \u 3} "hunter2"))

0:09 clojurebot: "037552"

1:14 ambrosebs: where does the Clojure compiler convert '1 to be the same as 1 ?

1:20 found it, clojure.lang.Compiler$ConstantExpr/parse

1:23 qracsp: does clojure have list comprehensions

1:23 justin_smith: qracsp: sure, for

1:24 qracsp: i dont think that is a full blown list comprehension equivalent? or am I wrong?

1:24 justin_smith: for doesn't do everything that a haskell lisp comprehension does, but mix it up with range and map and you can get the functionality

1:24 it's the closest we have at least

1:25 Kneiva: haskell lisp comprehension =)

1:26 qracsp: ,(for [x (range 4) y (range 4) :while (< y x)] [x y])

1:26 clojurebot: ([1 0] [2 0] [2 1] [3 0] [3 1] ...)

1:26 qracsp: ,(for [x (range 4) y (range 4) :while (< y x)] (* x y))

1:26 clojurebot: (0 0 2 0 3 ...)

1:26 qracsp: cool.. seems pretty complete to me.. what is it missing? binding values to variables?

1:27 justin_smith: qracsp: x..y type notation

1:27 we have :let for the binding part

1:29 amalloy: justin_smith: i think clojure's for has all the features of a haskell list comprehension, plus :while

1:30 the [1,2..10] thing is a feature that sees use entirely separate from list comprehensions

1:30 justin_smith: amalloy: OK so list comprehension and x..y interpolation are two totally different things I was conflating?

1:30 got it

1:31 amalloy: justin_smith: yeah, for any instance of Enum you can use that range notation in any context to get a list of the legal values

1:31 qracsp: :while filters results?

1:31 amalloy: ['a','c'..'m'] works, for example

1:32 justin_smith: qracsp: :when filters, :while truncates

1:32 qracsp: ah

2:01 luxbock: wait how are :while and :when different?

2:01 ,(= (for [x (range 10) y (range 10) :when (> x y)] [x y]) (for [x (range 10) y (range 10) :while (> x y)] [x y]))

2:01 clojurebot: true

2:02 qracsp: I believe the difference is the same as between take and filter

2:02 justin_smith: ,(for [x [:a :b :c :d] :when (#{:a :c} x)] x)

2:02 clojurebot: (:a :c)

2:02 justin_smith: ,(for [x [:a :b :c :d] :while (#{:a :c} x)] x)

2:02 clojurebot: (:a)

2:03 qracsp: ,(= (for [x (range 2) y (range 2) :when (> x y)] [x y])

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

2:03 qracsp: ,(for [x (range 2) y (range 2) :when (> x y)] [x y])

2:03 clojurebot: ([1 0])

2:03 qracsp: ,(for [x (range 2) y (range 2) :while (> x y)] [x y])

2:03 clojurebot: ([1 0])

2:04 qracsp: hmm

2:04 justin_smith: it's just coincidence

2:04 it's the first result, also the only one that meets the constraint

2:04 qracsp: ,(for [x (range 2) y (range 2)] [x y])

2:04 clojurebot: ([0 0] [0 1] [1 0] [1 1])

2:04 justin_smith: try chaning the 2s to 3s

2:05 qracsp: so while first drops the elements that don't match, then takes those that do, then stops?

2:05 justin_smith: ,(for [x (range 3) y (range 3) :when (> x y)] [x y])

2:05 clojurebot: ([1 0] [2 0] [2 1])

2:05 justin_smith: ,(for [x (range 3) y (range 3) :while (> x y)] [x y])

2:05 clojurebot: ([1 0] [2 0] [2 1])

2:06 qracsp: ,(for [x (range 3) y (range 3)] [x y])

2:06 clojurebot: ([0 0] [0 1] [0 2] [1 0] [1 1] ...)

2:06 qracsp: I guess I expected while to return [] there

2:06 luxbock: ,(for [x (range 4) y (range 4) :while (even? x)] [x y])

2:06 clojurebot: ([0 0] [0 1] [0 2] [0 3] [2 0] ...)

2:06 luxbock: ,(for [x (range 4) y (range 4) :when (even? x)] [x y])

2:06 clojurebot: ([0 0] [0 1] [0 2] [0 3] [2 0] ...)

2:07 justin_smith: qracsp: oh yeah, that is odd isn't it

2:09 qracsp: yeah.. I don't quite get it

2:10 justin_smith: ,(for [x (range x)] :while (odd? x)] x)

2:10 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>

2:10 justin_smith: ,(for [x (range x) :while (odd? x)] x)

2:10 clojurebot: #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 ...

2:10 justin_smith: ,(for [x (range) :while (odd? x)] x)

2:10 clojurebot: ()

2:10 qracsp: ah

2:10 justin_smith: ,(for [x (range) :when (odd? x)] x)

2:10 clojurebot: (1 3 5 7 9 ...)

2:11 qracsp: so :while stops current iteration on failure, not the entire thing

2:11 justin_smith: ,(for [x (range) y (range) :while (odd? x)] [x y])

2:11 luxbock: I have used :when before but :while never

2:11 clojurebot: ([1 0] [1 1] [1 2] [1 3] [1 4] ...)

2:11 qracsp: (unless entire thing is just a single iteration)

2:12 justin_smith: clearly :while is weird when you have multiple collections

2:14 ,(for [x (range) y (range) :while (odd? y)] [x y])

2:14 clojurebot: eval service is offline

2:16 justin_smith: woah - that is weird

2:16 amalloy: why would the above for comprehension just stall (even in a normal repl where I wrap it in (take 1000 ...))

2:17 where the version testing x instead has :while acting like :when

2:17 has my CPU pegged at 100% on one core

2:18 oh, it's iterating the entirety of the values for x so it can get to the part where y changes

2:19 of course

2:19 lol

2:29 luxbock: justin_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

2:32 amalloy: justin_smith: it gives up on the current y, not the current x

2:32 rather, i guess, the current x, not all xs

2:33 qracsp: ,(for [x (range) y (range 2) :while (odd? x)] [x y])

2:33 clojurebot: ([1 0] [1 1] [3 0] [3 1] [5 0] ...)

2:34 qracsp: so :while breaks inner-most loop

2:34 or all loops but outter-most

2:35 amalloy: the innermost

2:35 qracsp: ,(for [x (range) y '(8) z '(9) :while (odd? x)] [x y])

2:35 clojurebot: ([1 8] [3 8] [5 8] [7 8] [9 8] ...)

2:35 qracsp: ,(for [x (range) y '(8) z '(9) :while (odd? x)] [x y z])

2:35 clojurebot: ([1 8 9] [3 8 9] [5 8 9] [7 8 9] [9 8 9] ...)

2:36 qracsp: ,(for [x (range) y '(8) z '(9 9) :while (odd? x)] [x y z])

2:36 clojurebot: ([1 8 9] [1 8 9] [3 8 9] [3 8 9] [5 8 9] ...)

2:36 qracsp: yeah inner-most

2:45 luxbock: what other interfaces do I have to implement besides ILookup Seqable IPersistentCollection Associative IPersistentMap to have `get` work on my custom deftype?

2:45 I'm getting an AbstractMethodError

2:46 I was following this example: http://david-mcneil.com/post/16535755677/clojure-custom-map

2:46 but that one doesn't actually implement `get`

2:50 amalloy: luxbock: an actual error message and stacktrace is a thousand times more useful than "i'm getting an X error"

2:52 luxbock: the 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

2:53 I have implemented clojure.lang.ILookUp which I thought would be enough

2:53 qracsp: what was the rationale behind using CL-style maros in clojure over scheme's hygienic macros?

2:56 luxbock: here is the whole definition and the stacktrace in case it helps: https://gist.github.com/luxbock/5ed7ad8146f20ee3d425

3:01 hmm 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

3:06 restarting the REPL fixed the issue

5:05 mskoud: How to go from [0 1 2 3 4 5] to [[0 1] [1 2] [2 3] [3 4] [4 5] [5 nil]]

5:09 Macnube: mskoud: probably something like (map cons my-vec (conj (rest my-vec) nil))

5:10 it won't be cons in clojure actually

5:11 maybe vec, any function that takes two things and makes a vector out of them

5:14 amalloy: partition

5:20 Kneiva: ,(partition-all 2 [1 2 3 4 5])

5:20 clojurebot: ((1 2) (3 4) (5))

5:20 Kneiva: almost

5:20 mskoud: ,(partition-all 2 1 [1 2 3 4 5])

5:20 clojurebot: ((1 2) (2 3) (3 4) (4 5) (5))

5:20 mskoud: thx.

5:24 Macnube: thats nice - thanks for that.

5:26 luxbock: I find writing tests with test.check really fun for some reason

5:26 coming up with the right generator is like a fun puzzle

5:39 kwladyka: i 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

5:39 i am asking about all project, also about tests, not only about main code

5:42 luxbock, i didn't use test.check yet, but what i saw it should be very good idea

6:35 Kneiva: kwladyka: have you run your code through some linter?

6:35 kwladyka: Kneiva, linter?

6:36 Olajyd: Hi

6:36 Kneiva: kwladyka: Something like these: https://github.com/jonase/eastwood https://github.com/jonase/kibit

6:37 kwladyka: Kneiva, no i didn't

6:38 Olajyd: how 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!!

6:39 kwladyka: Olajyd, did you try http://clojuredocs.org/clojure.core/subs ?

6:39 Kneiva: kwladyka: Your code seemed pretty clean but I recommend giving those a try.

6:39 kwladyka: Kneiva, thx

6:41 Olajyd: @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?

6:41 *last

6:42 kwladyka: ,(subs "abcd" -3)

6:42 clojurebot: #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 ...

6:42 kwladyka: ,(subs "abcd" 1 -3)

6:42 clojurebot: #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 ...

6:42 kwladyka: mmm i guess not :)

6:43 ,(subs "abcd" -5 3)

6:43 clojurebot: #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 ...

6:44 kwladyka: Olajyd, but you do something like ##(subs "abcd" (- (count "abcd") 2))

6:45 eh i dont know how to speak with lazy-bot

6:45 Olajyd: lolz

6:45 kwladyka: ,(subs "abcd" (- (count "abcd") 2))

6:45 clojurebot: "cd"

6:48 Olajyd: thanks buddie @kwladyka

6:57 clgv: Hi, 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

6:57 ,(defmacro foo [[a, b, c], & ds] (let [f (or (:f c) :g)]))

6:57 clojurebot: #'sandbox/foo

6:57 clgv: ,(foo [1 2 3])

6:57 clojurebot: nil

6:57 clgv: interesting.

6:58 ,(clojure-version)

6:58 clojurebot: "1.8.0-alpha3"

7:00 clgv: there must be some strange interaction in the project repl...

7:12 hyPiRion: clgv: might be technomancy/leiningen#1668

7:12 oh where's lazybot

7:12 https://github.com/technomancy/leiningen/issues/1668

7:22 clgv: hyPiRion: ah well, it was a redefinition of a clojure.core funciton in that namespace :/

7:30 hyPiRion: humm

8:16 wes_ellis: This doesn't work like I expect: (reduce some? [nil nil nil])

8:17 clgv: wes_ellis: what is that supposed to do? did you mean `remove` or `filter` instead of `reduce`?

8:17 ,(doc some?)

8:17 clojurebot: "([x]); Returns true if x is not nil, false otherwise."

8:17 clgv: ^^

8:18 only 1-arity

8:18 wes_ellis: oh

8:21 I'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]

8:22 I want to generate a row in a table only if a crew is on training (when (...) (dom/tr nil ...))

8:22 So I want to check if at least one item in the vec is not nil

8:27 clgv: wes_ellis: does `keep` as a replacement for `map` solve your use case?

8:28 wes_ellis: (when-not (every? nil? [...]) ...)

8:29 thanks

9:34 dabd: ,0

9:34 clojurebot: 0

9:36 dabd: ,08

9:36 clojurebot: #<NumberFormatException java.lang.NumberFormatException: Invalid number: 08>

9:36 dabd: yup anyone noticed this weird bug?

9:36 if you evaluate 08 or 09 on the repl it will throw an exception

9:36 ,07

9:36 clojurebot: 7

9:36 dabd: ,09

9:36 clojurebot: #<NumberFormatException java.lang.NumberFormatException: Invalid number: 09>

9:37 clgv: dabd: octal number format ;)

9:37 ,010

9:37 clojurebot: 8

9:37 dabd: oh

9:38 need to RTFM

9:39 clgv: dabd: it's tricky and not optimal the 8r10 is better readable

9:39 ,8r10

9:39 clojurebot: 8

9:40 clgv: ,16r10

9:40 clojurebot: 16

9:40 jonathanj_: ,10r16

9:40 clojurebot: 16

9:40 clgv: :P

9:42 ,20rH

9:42 clojurebot: 17

9:43 justin_smith: ,(= 8r10 10r8)

9:43 clojurebot: true

9:44 jonathanj_: So how does one re

9:44 Read that?

9:45 justin_smith: jonathanj_: so you wan tto read 080 and get 80 back?

9:45 jonathanj_: I meant read in the English sense

9:46 Bronsa: 10r8 is 8 base 10

9:46 8r10 is 10 base 8

9:46 hyPiRion: ,26repl

9:46 clojurebot: 10135

9:46 Bronsa: hyPiRion: disgusting.

9:46 jonathanj_: But I guess 10r16 means 0x10, not 10 decimal

9:47 justin_smith: jonathanj_: no, that means 16 in base 10

9:47 ,16r10

9:47 clojurebot: 16

9:47 Bronsa: 16r10 is 0x10

9:47 jonathanj_: ,10r10

9:47 clojurebot: 10

9:47 jonathanj_: Err

9:48 That's not what I meant

9:48 Bronsa: ,[0x11 16r11 11r16]

9:48 clojurebot: [17 17 17]

9:48 Bronsa: ◔ ◡ ◔

9:48 jonathanj_: ,16ra

9:48 clojurebot: 10

9:48 Bronsa: ,[0x8 16r8 8r16]

9:49 clojurebot: [8 8 14]

9:49 Bronsa: there

9:49 ambrosebs: Bronsa: why is :val and :form different here (TAJ)? ((juxt :form :val) (analyze {:a ''1})) => [{:a (quote 1)} {:a 1}]

9:49 or where does this happen?

9:50 Bronsa: ambrosebs: looks like a bug

9:50 jonathanj_: justin_smith: and then going the other way, converting decimal to a base?

9:50 justin_smith: jonathanj_: that can be done with format iirc

9:51 Bronsa: ambrosebs: I'll take a look this evening and let you know

9:51 opqdonut: ,(Integer/toString 12 8)

9:51 clojurebot: "14"

9:51 opqdonut: ,(Integer/toString 100 50)

9:51 clojurebot: "100"

9:51 dhtns: ,(Integer/toString 43007316 36)

9:51 clojurebot: "plsno"

9:51 clgv: jonathanj_: converting between bases is a good learning exercise, if anyone is asking for those ;)

9:51 opqdonut: dhtns: heh

9:51 ambrosebs: Bronsa: ok, I'm struggling to reconcile Compiler$ConstantExpr and :quote nodes.

9:51 jonathanj_: dhtns: :)

9:52 dhtns: Can you do this with BigIntegers or floats?

9:52 (I'm new to clojure)

9:53 clgv: dhtns: you can certainly do that - is there an API function? no idea, you got to look that up in the javadocs ;)

9:55 justin_smith: format only does bases 8 and 16, but pprint/cl-format likely does it

9:56 ,(require 'clojure.pprint)

9:56 clojurebot: nil

9:57 justin_smith: ,(clojure.pprint/cl-format nil "dhtns: ~26r" 9999999999999.44)

9:57 clojurebot: "dhtns: 9.99999999999944E12"

9:57 justin_smith: oh wait...

9:57 ,(clojure.pprint/cl-format nil "dhtns: ~26r" 9999999999999)

9:57 clojurebot: "dhtns: 1ln1797e79"

9:58 dhtns: Great, thanks :)

9:58 justin_smith: see that's what I expected

9:58 it seems not to want to do floats in weird radixes

9:59 ,(clojure.pprint/cl-format nil "fun trick: ~r" 9999999999999)

9:59 clojurebot: "fun trick: nine trillion, nine hundred ninety-nine billion, nine hundred ninety-nine million, nine hundred ninety-nine thousand, nine hundred ninety-nine"

9:59 dhtns: Wow that is awesome :)

9:59 hyPiRion: I like the roman numerals better

9:59 justin_smith: I wonder if that is properly localized

10:00 clgv: $source clojure.pprint/cl-format

10:00 justin_smith: ,(clojure.pprint/cl-format nil "for hyPiRion: ~:@r" 9999999999999)

10:00 clojurebot: "for hyPiRion: 9,999,999,999,999"

10:00 justin_smith: err

10:00 hyPiRion: justin_smith: hard limit on 15000 or something

10:00 justin_smith: ,(clojure.pprint/cl-format nil "for hyPiRion: ~:@r" 999)

10:00 clojurebot: "for hyPiRion: DCCCCLXXXXVIIII"

10:01 justin_smith: hyPiRion: is that laziness, or just the domain of roman numerals?

10:01 dhtns: justin_smith: Roman numerals don't have a representation for anything above 1000

10:01 except using a bazillion Ms

10:01 Also, that representation isn't minimal

10:01 clgv: justin_smith: I prefefe CM over DCCCC ;)

10:01 justin_smith: I guess "a bazillion Ms" is left as an exercise for the reader

10:02 ,(clojure.pprint/cl-format nil "for clgv: ~@r" 999)

10:02 clojurebot: "for clgv: CMXCIX"

10:02 clgv: *prefer

10:02 hehe

10:02 justin_smith: where is that cryptic syntax explained?

10:02 hyPiRion: $google cl format documentation

10:03 clgv: ok some common lisp docs ;)

10:03 hyPiRion: clgv: http://www.gigamonkeys.com/book/a-few-format-recipes.html is a good starting point

10:03 justin_smith: ,(clojure.pprint/cl-format nil "~[a~;b~;c~]" 2)

10:03 clojurebot: "c"

10:04 justin_smith: there is also, of course, the authoritative clhs

10:05 dhtns: ,(clojure.pprint/cl-format nil "~36r" 671422091632103965497663578811235974322835963177842)

10:05 clojurebot: "allworkandnoplaymakesjackadullboy"

10:05 dhtns: heh

10:05 justin_smith: lol

10:07 Bronsa: ambrosebs: committed a fix in t.a, was a bug in the pass that transforms constant :map/:vector/:set nodes into :const nodes

10:09 ambrosebs: Bronsa: thanks!

10:09 tmtwd: i'm having trouble with this question http://clojurescriptkoans.com/#functions/7

10:10 I want to do (= 9 (((fn [] ) (fn [ a b] (+ a b))) 4 5)) but I get a wrong number of args exception

10:10 (its supposed to be true)

10:12 justin_smith: what is (fn [] ) doing in there?

10:12 ,(= 9 ((fn [a b] (+ a b)) 4 5))

10:12 clojurebot: true

10:13 justin_smith: if you take the (fn []) out it works as expected

10:13 perhaps you wanted ##(= 9 ((fn [] ((fn [a b] (+ a b)) 4 5))))

10:14 ,(= 9 ((fn [] ((fn [a b] (+ a b)) 4 5))))

10:14 clojurebot: true

10:16 tmtwd: justin_smith, its for the sake of the exercise, but it may have been poorly written

10:16 justin_smith: tmtwd: (fn []) takes 0 args and returns nil, so it seems out of place in your code

10:17 tmtwd: i see

10:21 (= 25 ( ________ square)) what would I put in here to make it return true?

10:22 opqdonut: ,(= 25 (or 25 square)) -- :P

10:22 clojurebot: #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:23 clgv: Short 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:25 hefesto: Hi :) 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:25 clgv: example LA = (A1 A2 A3), LB = (B1 B2 B3 B4 B5 B6) => desired result ([A1 (B1 B4)] [A2 (B2 B3)] [A3 (B1 B5)])

10:27 I 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:28 reiddraper: ping?

10:29 reiddraper: clgv: sounds like fmap is what you want

10:29 clgv: reiddraper: but fmap returns values and not generators

10:30 reiddraper: then gen/bind if you want to return a generator

10:31 clgv: reiddraper: ok, right that's where I am (gen/bind (gen/tuple A-gen B-gen) (fn [[LA, LB]] ...))

10:32 reiddraper: now the tricky part remains, which map like generator exists that can use the above (fn [A LB] ...)?

10:34 in principle I know the single element generators that I need and require a generator that just concatenates those

10:34 the distinct element generators

10:37 reiddraper: looking at the source of gen/vector it seems like gen-seq->seq-gen could be interesting

10:38 reiddraper: clgv: 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:38 then zip those together

10:40 justin_smith: opqdonut: or (fn [f] (f 5))

10:41 clgv: reiddraper: I think I'd need something like (gen/return-list (map (fn [A] (gen/tuple (gen/return A) (gen/random-subset LB))) LA)

10:56 ha, I ended up reimplementing `gen/tuple`, so (apply gen/tuple ...) is what I have been looking for

11:10 hefesto: I 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:33 ambrosebs: Bronsa: 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:33 the former I'm talking about Compiler$KeywordInvoke

11:35 Bronsa: ambrosebs: yeah, that's a small difference in how temj compiles stuff vs how Compiler.java does it

11:35 ambrosebs: ok cool

11:35 Bronsa: ambrosebs: temjvm always compiles, compiler.java sometimes interprets

11:35 ambrosebs: ahk

11:36 Bronsa: ambrosebs: no big difference if a :keyword-invoke is an :invoke btw

11:36 ambrosebs: good to know

11:37 Bronsa: I woulnd't waste your time trying to make the AST 100% the same, a valid and equivalent AST is fine

11:38 ambrosebs: just as you shouldn't bother trying to make the tags the same -- saw your comment in code about APM vs PAM

11:39 ambrosebs: nice

11:40 I'm guessing which is more expensive: reflective calls to getJavaClass or using a TAJ pass

11:40 trying the former for now

12:15 firevolt: trying to learn clojure makes me feel like I should have gone to school lol

12:18 clgv: hefesto: you can organize them separately as you like, see :source-paths and :java-source-paths

14:11 AxisOfEval: Anyone 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:23 clarkenciel: does anyone know of sound synthesis/analysis work done in clojure?

14:27 aengelberg: AxisOfEval: I've been using it for a while with no issues :) what seems to be the bug?

14:30 justin_smith: clarkenciel: yes! check out kunstmusic/pink for example

14:30 clarkenciel: for dsp in pure clojure

14:31 AimHere: clarkenciel, 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:31 justin_smith: clarkenciel: overtone is more popular, but all its dsp is done in supercollider

14:32 AimHere: iirc that was using overtone - the sad thing to me is that the interesting stuff is all being done in c++

14:38 clarkenciel: justin_smith: I'll check those out, particularly kunstmusic

14:39 iirc even supercollider is mostly c++ anyway

14:39 justin_smith: clarkenciel: kunstmusik is the org (I spelled it wrong, sorry), pink is the project https://github.com/kunstmusik/pink

14:39 clarkenciel: at least the neat chaotic synths

14:40 ahhh thanks

14:40 justin_smith: clarkenciel: that was my point - the interesting stuff is offloading to supercollider

14:41 I 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:41 clarkenciel: both would be the ideal right? :)

14:41 justin_smith: yeah - pink has a composition library too, but less mature than overtone

14:42 err, kunstmusic has score to go with pink for composition that is https://github.com/kunstmusik/score

14:42 clarkenciel: I'm coming from ChucK and a little bit of extempore so I'm used to building a lot of my own stuff

14:42 justin_smith: cool

14:43 oddcully: justin_smith: musik is music. and kunst here is a little play on words. it means either art or artificial

14:43 justin_smith: clarkenciel: steven yi who does pink and score is one of the lead csound devs

14:43 oddcully: yeah, I just get the german spelling wrong :)

14:43 oddcully: he is definitely coming from the art-music school of composition too

14:52 clarkenciel: score has Xenakis sieves built in!? be still my heart!

14:52 justin_smith: :)

14:52 I should re-read that book again soon, I've learned a lot of math since I last tried

14:52 (Xenakis' Formalized Music that is - lots of awesome higher math / composition crossover there)

14:53 clarkenciel: it blew my mind the first time through. It doesn't seem to be taught as widely as it should be

14:53 justin_smith: definitely not

14:53 clarkenciel: this kind of stuff was what got me into programming actually - I started with experimental music

14:54 which of course is why I ended up with wacky languages like clojure

14:54 clarkenciel: same!

14:56 justin_smith: I 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:56 eg. doing heavy signal processing on AWS or digital ocean during a live performance...

14:57 clarkenciel: and then simply streaming the results into the composition environment?

14:58 justin_smith: clarkenciel: idea being that I would build a sytem for live processing that has some element of batched / delayed results

14:59 clarkenciel: 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:59 clarkenciel: kind of blurring the event / signal distinction in this (as a stylistic choice)

15:00 clarkenciel: justin_smith: ahh, v. cool. sounds like a kind of automated telemusic (is that the term)?

15:00 justin_smith: that sounds about right, yeah

15:01 clarkenciel: and there's some nice conceptual rhyme between granular techniques (xenakis intended that they emulate the physics of clouds) and cloud computing :)

15:02 clarkenciel: justin_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:02 justin_smith: HUB?

15:02 oddcully: hubbard?

15:03 clarkenciel: oddcully: lol yeah, Freddie's computer music group!

15:03 justin_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:04 justin_smith: ahh

15:04 clarkenciel: https://en.wikipedia.org/wiki/The_Hub_(band)

15:06 justin_smith: clarkenciel: I know Bischoff and Niblock (but not well enough to have known HUB), looks interesting

15:07 clarkenciel: justin_smith: some of it sounds like a 90s computer game gone awry, but the organizations of some of the pieces are compelling.

15:08 justin_smith: clarkenciel: I just paused a Kevin Drumm album, so I'm open minded about the computer game noises

15:09 oddcully: and i thought i know them all,,, now there is "drone metal"

15:10 justin_smith: oddcully: I really wouldn't call drumm metal (I am sure he wouldn't use the term)

15:10 I mean it's loud distorted guitar, but that's not enough to make it metal

15:12 clarkenciel: justin_smith: haven't heard of Kevin Drumm, recommendations?

15:13 justin_smith: oooh... 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:13 oddcully: that is what wikipedia said. so from context i assumed some SID coder

15:14 justin_smith: clarkenciel: https://www.youtube.com/watch?v=276by41fHIk

15:14 oddcully: yet... this goes OT :*)

15:14 justin_smith: oddcully: very much so, apologies

15:14 oddcully: np. i helped

15:15 clarkenciel: oh this is v. nice

15:37 sdegutis: Hi.

15:56 {blake}: I have unsuccessfully tried to use conjure for mocking and stubbing.

15:56 Anyone have other suggestions?

15:56 sdegutis: Conjure? Link?

15:56 {blake}: (proxy) is usually good at that

15:56 (doc proxy)

15:56 clojurebot: "([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 It looks good, but it doesn't seem to work much beyond the very simple example.

15:58 Proxy, eh?

15:59 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:00 sdegutis: amalloy or justin_smith: can you please show this fine gentleman a simple yet powerful example of proxy in action

16:01 Bronsa: sdegutis: how exactly would proxy help with his problem?

16:01 sdegutis: Mocking.

16:02 And maybe stubbing.

16:02 Bronsa: whatever im internetfamous now i dont need your approval anymore all of reddit loves me now

16:02 Bronsa: did I miss something or he never mentioned anything that would suggest he's doing interop?

16:03 {blake}: I am not interopping.

16:03 amalloy: please 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:03 Bronsa: sdegutis: I'm honestly getting tired of your filling this channel with noise and nonsensical/unrelated stuff

16:04 sdegutis: Welp, you're the boss. Cya.

16:04 oddcully: /ignorance is bliss

16:05 blkcat: vi con

16:05 oops

16:06 {blake}: I suppose I could switch to midje.

16:13 justin_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:14 so 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:14 the 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 (Arguably it doesn't need testing.)

16:23 justin_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:24 so 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:25 justin_smith: it is so much easier than the mocking stuff though in the long run

16:26 and 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:26 eww real-world-cooties

16:26 {blake}: I know, right? The real-world has destroyed so much of my beautiful code.

16:27 justin_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:27 in the real code it will be a very thin function that either calls kafka or sente for http sockets

16:28 s/http/tcp

16:28 in 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:30 justin_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:30 but 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:35 clausewitch: I'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:35 st 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:37 It 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 I mean, you could use "every?" right?

16:38 clausewitch: {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:39 justin_smith: clausewitch: we actually have heirarchies! including anonymous local heirarchies

16:39 (doc make-heirarchy)

16:40 clausewitch: One 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:40 clojurebot: Huh?

16:40 justin_smith: (doc make-hierarchy)

16:40 clojurebot: "([]); Creates a hierarchy object for use with derive, isa? etc."

16:40 justin_smith: clausewitch: https://clojuredocs.org/clojure.core/make-hierarchy

16:40 {blake}: oh, ha! There it is.

16:40 (inc justin_smith)

16:41 justin_smith: clausewitch: and it has things like ancestors

16:42 clausewitch: justin_smith: indeed, but not children.

16:42 justin_smith: clausewitch: 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 I've forgotten how to karma. =(

16:42 justin_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:43 justin_smith: {blake}: np

16:44 clausewitch: actually you can get children https://clojuredocs.org/clojure.core/descendants

16:44 clausewitch: the 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:44 justin_smith: clausewitch: see my link

16:44 clausewitch: descendants != children

16:44 but it doesn't matter, thanks.

16:46 I 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:49 It 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:51 amalloy: clausewitch's problem sounds interesting. shame i just missed him

16:54 justin_smith: I would have liked to have gotten that descendents / children distinction

17:00 amalloy: i 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:00 justin_smith: so a child is more specific then descendent in terms of being a direct leaf?

17:01 amalloy: (recursively percolating changes up towards the root)

17:01 yes

17:01 er, leaf?

17:01 justin_smith: that's what I missed - sorry, bad choice

17:01 direct downward link

17:01 amalloy: yes

17:01 that is the usual thing in trees

17:02 justin_smith: ahh, this could also be done with a post-walk (depending on how the rules would cascade...)

17:15 arkh: will this be on the test?

17:16 amalloy: justin_smith: yeah, exactly

18:55 firevolt: please tell me there's a better way to do this: (#(str (:first %) " " (:last %)) {:first "Bob" :last "Smith"})

18:59 amalloy: (clojure.string/join " " (map m [:first :last])) would be my choice

19:00 justin_smith: that map could also be ((juxt :first :last) m)

19:05 amalloy: it could. but i like mapping the map, because people forget you can do that. nobody ever forgets juxt

19:05 firevolt: coworker's proposal: (reduce str (for [x {:first "Bob" :middle " " :last "Smith"}] (second x)))

19:05 lol

19:06 justin_smith: firevolt: that will get the order wrong quite easily

19:06 ,apply format "%s %s" ((juxt :first :last) {:first "Bob" :last "Smith"}))

19:06 clojurebot: #object[clojure.core$apply 0x269a0e41 "clojure.core$apply@269a0e41"]

19:06 justin_smith: ,(apply format "%s %s" ((juxt :first :last) {:first "Bob" :last "Smith"}))

19:06 clojurebot: "Bob Smith"

19:07 firevolt: Interesting

19:08 I didn't even think about mapping the map. Those are both clever solutions. Haha thanks

19:11 also I guess format isn't in cljs

19:11 justin_smith: oh it isn't?

19:11 firevolt: Guess not

19:11 justin_smith: that's too bad, I guess then use a string/join

19:11 firevolt: crashed in LightTable, worked in lein repl

19:11 I was more just interested in implementation than actually using it

19:12 justin_smith: ,(clojure.string/join " " ((juxt :first :last) {:first "Bob" :last "Smith"}))

19:12 clojurebot: "Bob Smith"

19:12 firevolt: Yeah that seems like the cleanest one

19:12 justin_smith: I only suggested format because the overal task might expand out to formatting an input better than joining one in the bigger picture

19:15 amalloy: yeah, it's funny how printf is still the crowning glory of string formatting

19:15 justin_smith: I had hoped that cl-format would have some extension for keys of a hash map

19:16 it 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:16 a syntax like "~::first ~::last" would be cool (actual syntax up for debate)

19:28 amalloy: old 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:29 justin_smith: amalloy: I checked, maybe not deeply enough...

19:29 amalloy: http://stackoverflow.com/questions/1263775/how-might-i-format-an-alist-in-common-lisp

19:30 amalloy: well, at least it supports roman numerals. no time for niche features like alists

19:30 justin_smith: half the answers are "just use a real list"

19:30 haha

19:31 tmtwd: (= 5 (do ________ @atomic-clock)) what do I need to do here to return true?

19:31 using swap! (i think http://clojurescriptkoans.com/#atoms/4)

19:41 shoky: tmtwd you can use reset! too

19:42 tmtwd: shoky, oh thats right :)

19:46 amalloy: well the problem seems to suggest it wants you to use swap

19:46 in which case something like (swap! atomic-clock + 5) would be the easy choice

19:51 haha 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:25 justin_smith: that's a bit small for a stack isn't it/

20:26 or wait, no, that's not small at all...

20:29 amalloy: i don't know what the units are, but i presumed that nobody would bother to lower the stack size before calling make

20:29 justin_smith: d'oh, right :)

20:29 yeah, it's in k, so that is huge actually for a stack

21:40 weebz: Hi, 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:40 http://paste2.org/bBgGL5Ih

21:43 justin_smith: weebz: I would repleace (partition 2 (interleave (range (count file-lines)) file-lines) with (map list (range) file-lines)

21:43 ,(map list (range) [:a :b :c])

21:43 clojurebot: ((0 :a) (1 :b) (2 :c))

21:44 weebz: @justin_smith: I would agree that's much better, thank you :)!

21:55 TEttinger: (inc justin_smith)

21:55 aww lazybot

Logging service provided by n01se.net