#clojure log - Aug 10 2014

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

0:00 lpvb: jeremyheiler: sometimes there's a lot of computations and constants in the let form and I want to declare what I need closer to the functions that need them so putting it directly in the let vector next to them makes it look better to me

0:01 that and also I know whatever has a _ before it is definitely a side effect

0:01 and my nil returns are explicit

0:01 idk

0:01 jeremyheiler: cool. i've done the _ thing with temporary printlns and whatnot

0:02 but i otherwise don't find myself doing a lot of side effecty things in a let

0:02 in a let binding*

2:40 Jaood: amalloy_: did you switch computers?

3:06 amalloy: Jaood: what? when?

3:40 bluesnow: Hi, I installed the counterclockwise plugin for Eclipse, but when I go to File -> New -> Project -> .., I don't see the Clojure Project option.

3:40 Any idea what I might be missing?

4:13 katratxo: bluesnow: it's File > New > Clojure https://i.imgur.com/UuBHZci.png

4:32 mischov: With cond, is there a way to use the value the test returns in the associated expression?

4:34 oskarkv: mischov with condp there is

7:55 wink: hmm, interop question. IllegalArgumentException No matching field found: xx for class xy

7:55 but reflection clearly shows the method is there. calling it with (.. obj xx) or (.xx obj) makes no difference. ideas?

7:56 rweir: is it private

7:56 wink: not according to reflection and docs

7:56 Bronsa: wink: do you have a concrete example?

7:59 wink: http://hastebin.com/edeluzatad.clj

7:59 note that I don't see an error in line 5 (in doto), only when I call it outside

8:00 and apparently you need an animated gif as the input, e.g. http://asset-8.soup.io/asset/7750/5369_87a9.gif

8:00 Bronsa: wink: in the doto you're calling it as a method, passing true as an arg

8:01 wink: doh.

8:01 thanks

8:01 Bronsa: np

8:01 wink: .getNumImages x true works

8:02 silly error message though

8:02 Bronsa: not really, it tells exactly what's going wrong

8:02 you're trying to access a getNumImages field, it doesn't exist

8:02 wink: as from calling you can't differentiate between a method without args and a field

8:03 Bronsa: wink: (.-field obj) is the new syntax that should be prefered for field access

8:03 wink: plus, who uses public fields? :)

8:03 oh?

8:03 Bronsa: (.field obj) is old syntax

8:03 * wink uses an unhealthy mix of clojure 1.3 - 1.6 knowledge

8:04 hyPiRion: you can also do (. obj (method)) for method calls

8:04 Bronsa: or (.method obj ())

8:04 uh, no.

8:04 nevermind.

8:04 hyPiRion: yeah, that would send () as second argument

8:05 Bronsa: yeah I derped

8:05 wink: .- was introduced in 1.4 IIRC

10:31 timothyw: Is there a lein plugin for test.check? It would be nice to auto-run my tests as they’re developed.

10:31 ChouLin: hello, guys. I've post my question on Stackoverflow, how to get trie's leave count. I like the style of second & third answer, but they return slightly bias result. Can anyone modify this ? http://stackoverflow.com/questions/25221646/clojure-a-tail-recursion-to-get-leave-counts-of-a-trie

10:32 reiddraper: timothyw: I'm now aware of one at the moment, would be great to have one though

10:32 ChouLin: a trie out of["aat" "abt" "aac" "a" "b"] has 4 terminals, the code return 2.

10:33 5, typo.

10:33 timothyw: reiddraper, too right… I’m about to write a lein plugin, and was wondering about the semantics

10:34 ie , pass in the ns and number of time to run each test?

10:34 reiddraper: timothyw: awesome. Let me know if you get something published and I'll happily add it to the test.check readme

10:35 timothyw: ok, will do

10:38 mi6x3m: hey clojure, is deinit! a suitable name for a function returned by a function constructing a graphical component and perfoming some deinitialization?

10:39 sh10151: What is deinitialization?

10:39 mi6x3m: sh10151: stopping a webserver for instance

10:41 sh10151: wouldn't that just be 'stop' then?

10:42 mi6x3m: sh10151: this was just an example

10:42 sh10151: hmm what are some other examples, trying to figure out the context

10:42 mi6x3m: sh10151: stopping a server, returning back resources, writing some log files etc.

10:43 it's a general framework with examples of a component suite

10:43 sh10151: That seems really really generic -- I don't usually think of "deinitialization" when writing a log file

10:43 Also it doesn't seem to be restricted to the opposite of whatever "initialization" is?

10:44 mi6x3m: well it's _mostly_ the opposite, but not always yes :)

10:44 perhaps "cleanup"

10:44 sh10151: I think enter/exit are a little more commonly used names for that level of genericity

10:45 see monitor-enter/monitor-exit or python's context manager __enter__/__exit__

10:45 justin_smith: mi6x3m: the rule in the jvm is usually that deinitialization is implicit when a resource leaves scope

10:45 hugod: timothyw: I haven't used, but https://github.com/runoshun/lein-watch looks like it might help you

10:45 mi6x3m: justin_smith: this is a completely different affair for the component is living for far longer than the scope

10:46 justin_smith: mi6x3m: under the jvm, that isn't possible - there is some scope where it is reachable

10:47 unless you expect it to randomly be released / reclaimed

10:47 mi6x3m: justin_smith: wait, I am speaking about a swing component

10:48 justin_smith: OK. finalize?

10:48 or just cleanup

10:49 mi6x3m: finalize might be ok yeah

10:50 justin_smith: cleanup! in that case i guess?

10:51 sh10151: I don't like the ! - isn't that for things that are known to be unsafe in STM?

10:52 writing a log file isn't

10:52 justin_smith: sh10151: well I would guess you wouldn't want to retry a cleanup!

10:53 mi6x3m: there will be no retrying here anyway

10:53 justin_smith: goddamn clojure putting punctuation in names making me sound like a middle school student

10:53 timothyw: hugod, yes that does look good. I’m gonna try it out, thanks.

10:53 sh10151: justin_smith: that would depend on the exact nature of the cleanup I think

10:54 justin_smith: this whole affair seems quite astronautical to me

10:54 :)

10:54 mi6x3m: is there a shortcut for calling a function only if it's not nil?

10:54 alternative to when-let

10:54 Bronsa: justin_smith: next time write `cleanup!` and you'll be fine

10:54 timothyw: weavejester also created https://github.com/weavejester/lein-auto

10:54 justin_smith: mi6x3m: fnil maybe?

10:54 (inc Bronsa)

10:54 lazybot: ⇒ 38

10:56 justin_smith: mi6x3m: wait, no, not fnil - ((or f (constantly nil)) arg1 arg2 ... argN) would work, but is not a shortcut

10:56 mi6x3m: justin_smith: yeah not really shorter and way more unreadable :)

10:56 thanks for all the advice though :)

10:56 (inc justin_smith)

10:56 lazybot: ⇒ 59

10:58 justin_smith: mi6x3m: I often have (def nothing (constantly nil))

10:58 ((or f nothing) args)

10:59 and you don't need when-let - you could also use when (when f (f args))

11:16 timothyw: when I try to use `lein release` in one of my projects, I get this error: http://pastebin.com/TrHLJ46D

11:16 what am I missing?

11:19 justin_smith: timothyw: is lein in the path that lein inherits? it seems odd that it wouldn't be, but that is what the message seems to indicate

11:19 rweir: clojure 1.3?

11:20 timothyw: @justin_smith: yes, that’s what I thought too - but `lein` is definitely available from anywhere

11:21 @rweir, my project’s clojure version is [org.clojure/clojure "1.5.1"]

11:36 justin_smith: timothyw: you should turn on pedentic dependency resolution in your project.clj, because something is giving you the wrong clojure version

11:36 :pedantic? :abort

11:36 timothyw: Somehow, when lein does `java.lang.UNIXProcess.forkAndExec`, some library or execution path with `lein` is not available.

11:37 ok, lemme try that

11:37 justin_smith: also, be sure that lein is not only in your path, but also in your exported path

11:38 timothyw: @justin_smith, I put the `:pedantic? :abort` k/v in my project.clj. But the same error occurs

11:38 justin_smith: so not only PATH=... in your shell config, but export PATH=...

11:38 hmm

11:38 timothyw: ok, one sec…

11:40 yep, in .bash_profile, I have “export PATH="$PATH:~/bin/:…”

11:40 lein is in “~/bin/lein”

11:50 justin_smith: OK, lein-release uses clojure 1.3

12:07 timothyw: @justin_smitth, hmm, that’s interesting

12:07 I can get around this issue by running `lein jar` and `lein pom`, manually.

12:08 and logged a bug here: https://github.com/relaynetwork/lein-release/issues/20

12:12 justin_smith: reading the source, it is weird that they are shelling out to lein again, rather than just calling the lein-jar and lein-pom functions

12:16 llasram: The 2.4 Leiningen release series includes a built-in `release` task. Is it possible you could simply use that instead of the `lein-release` plugin?

12:29 timothyw: @justin_smith, yeah, I thought was weird too

12:33 @llasram, I see that, yes. I’ll give that a shot. Thanks :)

12:33 llasram: timothyw: BTW, the convention on IRC to refer to someone is to just use their bare handle. No need for the `@` prefix

12:34 timothyw: cool beans - habits from other IM tools get mixed into here too :)

13:57 gfredericks: ~@

13:57 clojurebot: @ is splicing unquote

13:57 gfredericks: huh.

13:57 ~~@

13:57 clojurebot: Titim gan éirí ort.

13:57 JohnTalent: global state is managed with assoc, dissoc?

13:57 gfredericks: clojurebot: ~@ is splicing unquote

13:57 clojurebot: c'est bon!

13:57 gfredericks: ~~@

13:57 clojurebot: ~@ is different from ~ and different from @

13:58 gfredericks: ~~@

13:58 clojurebot: ~@ is splicing unquote

13:58 gfredericks: clojurebot: forget @ is splicing unquote

13:58 clojurebot: Ok.

13:58 gfredericks: JohnTalent: assoc and dissoc operate on immutable maps

13:58 ~@

13:58 clojurebot: @?

13:58 rweir: JohnTalent, you may be thinking of vars

13:59 gfredericks: global state is usually avoidable

13:59 JohnTalent: rweir: i am a total newb.

14:00 rweir: JohnTalent, what specifically do you want to do?

14:01 andyf: JohnTalent: If an application has global state, immutable maps are often a convenient data structure to use for storing that global state, because of their flexible nature of adding and removing arbitrary keys.

14:02 Regardless of whether a map or some other data structure is used for holding the desired state, it is often 'pointed at' by an atom, and what that atom 'points at' can be changed over time, e.g. to new updated maps.

14:03 JohnTalent: rweir: pass around global state.

14:03 rweir: JohnTalent, that's not specific

14:03 JohnTalent: rweir: yes, because it's a nonissue until i start writing.

14:04 andyf: thanks

14:05 gfredericks: sounds like he might be using an alternate sense of "global state"

14:05 rweir: indeed

14:05 gfredericks: i.e., the purely-functional variant of it

14:05 the state monad essentially :)

14:06 andyf: Sometimes you just gotta try out various things for yourself to learn their advantages and disadvantages.

14:12 JohnTalent: andyf: right

14:45 meoblast001: suppose i define an (fn [] .. ) and i want to call it. do i need to do (apply (fn [] ... ) [ ... ]), or is there a more natural type of syntax?

14:47 gfredericks: ((fn [] ...))

14:48 ,((fn [] 42))

14:48 clojurebot: 42

14:48 meoblast001: ah, thanks

14:48 gfredericks: ,(((fn [] (fn [] 42))))

14:48 clojurebot: 42

14:48 gfredericks: ,((((fn [] (fn [] (fn [] 42))))))

14:48 clojurebot: 42

14:48 meoblast001: i feel like i'm going about this problem the wrong way...

14:49 gfredericks: ,(((((fn [] (fn [] (fn [] (fn [] 42))))))))

14:49 clojurebot: 42

14:49 meoblast001: i basically have times listed in a bunch of hashmaps.. and i'm trying to divide this collection of hashmaps into multiple collections if they fall into time intervals

14:50 i thought i'd solve this with recursion and filter... but i'm not sure if that'll be clean

14:51 gfredericks: ,(doc partition-by)

14:51 clojurebot: "([f] [f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of partitions. Returns a stateful transducer when no collection is provided."

14:51 meoblast001: omg thanks i love you, gfredericks

14:52 there's only one problem.. i need to say "the end of this partition is anything that is no larger than the beginning of this partition"

14:52 technomancy: ,(doc partition-all)

14:52 clojurebot: "([n] [n coll] [n step coll]); Returns a lazy sequence of lists like partition, but may include partitions with fewer than n items at the end. Returns a stateful transducer when no collection is provided."

14:53 technomancy: partition-by is usually the wrong thing

14:53 meoblast001: well partition-all would work great if i was saying "I want X amount of things in each collection"

14:53 but my problem is "I want however many things fit into a 30 second time period in one collection, then start the next collection repeating this process"

14:53 gfredericks: meoblast001: that rule seems to say that each partition has the same timestamp?

14:53 oooh

14:54 so it's based on some property of the whole partition together?

14:54 sort of like starting with a bunch of numbers and splitting them into chunks that sum as high as possible without exceeding X?

14:54 meoblast001: yeah. it's based on the first entry in the partition

14:55 so basically if the first item in a partition caries the timestamp "40", i don't want the last one to exceed "70"

14:55 once it does, start the next part

14:55 gfredericks: gotcha

14:55 reduce can do that

14:56 meoblast001: yeah.. if i throw in a collection i could probably get that.... hm

14:56 if i throw in a [[]], and always add each item to the last collection within this collection.... then always compare with the first item without the last collection

14:57 justin_smith: reduce can do it, you would want some kind of simulated annealing to optimize it though

14:57 meoblast001: i feel like there's a really good recursive solution to this but can't think of it right now

14:57 justin_smith: or maybe not...

15:01 gfredericks: I've got a reduce

15:01 one sec

15:01 meoblast001: ah. i came up with a good recursive solution on the toilet!

15:01 gfredericks: https://www.refheap.com/89089

15:01 meoblast001: i just need something like a take-until... not like reduce where it just skips an entry if it fails a condition, but one where it finishes iteration when it fails a condition

15:01 hmm

15:03 justin_smith: why would reduce skip anything?

15:03 gfredericks: ,(defn sorta-reduce "like reduce but skips things sometimes" ...)

15:03 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Parameter declaration ... should be a vector>

15:03 meoblast001: oh sorry. i was thinking filter, not reduce

15:03 had reduce on my mind for some reason

15:04 justin_smith: gfredericks: flaky-reduce

15:04 gfredericks: (inc flaky-reduce)

15:04 lazybot: ⇒ 1

15:04 gfredericks: meoblast001: because I just used it ;-)

15:04 meoblast001: yup

15:04 reading yours right now

15:04 rpaulo: (inc flaky-reduce)

15:04 lazybot: ⇒ 2

15:05 gfredericks: meoblast001: a slight modification to my function could make it take an arbitrary predicate for a candidate group, and you should be able to use that to get the specific logic you want

15:05 rpaulo: for a language that stresses imutability, this seems odd!

15:06 gfredericks: rpaulo: what's not immutable about this?

15:06 meoblast001: gfredericks: yup, thanks :)

15:06 justin_smith: rpaulo: (inc ...) in this channel is just a pseudo-syntax

15:06 that is not how inc really works, of course

15:06 meoblast001: i'm just making sure i understand it before doing that

15:06 gfredericks: oooh that

15:06 rpaulo: yeah, it was a joke...

15:07 justin_smith: OK, you forgot to attach the joke metadata, which led to a reader error on my end

15:07 rpaulo: :)

15:07 meoblast001: gfredericks: this solution is clever

15:08 i don't do as much clojure as i wish to, so my solutions are never this clever ;)

15:08 or.. rarely

15:10 gfredericks: aw man clojure 1.7 doesn't have update yet

15:10 meoblast001: peek is an interesting function

15:14 justin_smith: my minor reworking of gfredericks' version https://www.refheap.com/89091

15:16 meoblast001: style question. if i'm doing a really complex expression inside of the [] of a let, how far in should i indent?

15:16 justin_smith: meoblast001: exactly as far as emacs auto-indents

15:16 meoblast001: lol. i'm not using emacs

15:16 inb4 "that's your problem"

15:16 justin_smith: heh

15:17 wcauchois: hey, i'm trying to use netty in clojure and i'm getting a pretty weird exception: Cannot cast io.netty.handler.codec.http.HttpServerCodec to [Lio.netty.channel.ChannelHandler

15:17 HttpServerCodec is definitely an instance of ChannelHandler so i don't understand that

15:17 meoblast001: justin_smith: how far does your emacs do it?

15:17 justin_smith: meoblast001: a multi-line binding in let should be indented exactly as much (relatively) as it would be anywhere else

15:17 wcauchois: anyone know what that [L is in front of the type? could that have anything to do with it?

15:17 justin_smith: wcauchois: are you trying to use a varargs method?

15:17 meoblast001: so one indent forward from the (let ?

15:18 wcauchois: justin_smith: yes, i am

15:18 justin_smith: wcauchois: varargs methods are just a java syntactic sugar, we don't have an equivalent in clojure

15:18 wcauchois: you need to put all the optional arguments into an array

15:19 wcauchois: do i still pass the non-optional arguments regularly, or do i pass the whole thing as an array?

15:19 justin_smith: (method required-arg (into-array [optional1 optional2 optional3]))

15:19 gfredericks: justin_smith: I see your minor reworking and raise you a genericification: https://www.refheap.com/89092

15:19 meoblast001: ^

15:19 justin_smith: the javadoc should make clear which are required and which are optional

15:19 wcauchois: ok let me try that

15:19 the function is also overloaded, although i'm calling the 2-arg version which isn't (there are two 3-arg ones)

15:19 meoblast001: woo

15:20 wcauchois: would clojure dispatch based on the types to the overloaded ones?

15:20 justin_smith: wcauchois: concrete example I answered recently on so http://stackoverflow.com/questions/25145550/how-to-instantiate-path-object-using-clojure/25145835?noredirect=1#comment39155787_25145835

15:21 wcauchois: notice in that case, java.nio.file.Paths/get needs a single string arg (in order to do the dispatch properly), and then all other args needed to be in an array

15:21 wcauchois: in this kind of case it's not really clojure dispatching, it's the jvm dispatching - you need to provide the right classes in the clojure invocation so that the jvm knows which method to dispatch to

15:22 wcauchois: which you can do with ^Type, correct?

15:22 also now i'm getting no matching method found. i passed (into-array Object []) as the last argument (again, i'm calling the 2-arg version and there are other 3-arg overloads)

15:23 justin_smith: wcauchois: well ^Type helps resolution at runtime, but the real issue is that you need the right signature for the method call to resolve (which is why all the args above were strings, but one had to be outside the array)

15:23 the varargs should be preceded by at least one non-array argument I think, almost always

15:24 wcauchois: do you have a link to the javadoc for the method in question?

15:24 gfredericks: very nice

15:24 (inc gfredericks)

15:24 lazybot: ⇒ 81

15:25 oskarkv: meoblast001 gfredericks what about this? https://www.refheap.com/89093

15:25 wcauchois: okay, i think it worked by passing the first required arg regularly and then passing the second arg as a singleton array

15:25 yess no more exceptions. still not working, but now i'm on to the next bug :)

15:25 justin_smith: wcauchois: yeah, I think that is pretty much always how it needs to be done

15:25 wcauchois: ok. thanks for the help!

15:25 gfredericks: that's the first time in half a year I've gotten karma for something that wasn't a joke

15:25 justin_smith: wcauchois: do you have a specific reason to use netty directly instead of using ring?

15:26 gfredericks: oskarkv: hey cool

15:26 seems better for being lazy

15:26 or at least it would be lazy if you had wrapped it in lazy-seq :)

15:26 oskarkv: yeah :P

15:28 wcauchois: justin_smith: errr i was planning on writing my own adapter. i want to use websockets as well. i found a ring netty adapter but it didn't look like it supported websockets.

15:29 justin_smith: wcauchois: oh, nice

15:29 wcauchois: there's aleph, which looks really nice, but it's not ring-compatible

15:29 also i thought maybe this would be a good learning experience? haha

15:30 tho it seems more like i'm learning about the warts of java interop than actual clojure

15:30 oh wait

15:30 aleph is ring-compatible, what am i saying

15:30 anyway, learning experience etc

15:31 justin_smith: java interop is not so bad once you get used to it, the rules are few in number and very consistent - and aleph is much more than a netty adapter

15:32 the trick is realizing which parts of java are really fictions of the compiler (like generics and varargs) so that you can provide the version without said fiction (which clojure will not support)

16:01 gfredericks: challenge: given a number, try to express it in clojure/java by referencing only the Math class

16:03 SagiCZ11: ,Math/PI

16:03 clojurebot: 3.141592653589793

16:09 milos_cohagen: am i using the term 'yak shaving' correctly if i used it to describe the last two hours of emacs/pkg/cider woes?

16:10 gfredericks: probably depends on how valuable those woes were

16:10 justin_smith: probably

16:11 for the convenience of anyone considering gfredericks' challenge https://www.refheap.com/89095

16:11 gfredericks: I was just assembling a similar list

16:11 justin_smith: tab-complete plus refheap-paste-region :)

16:12 gfredericks: ha

16:14 SagiCZ11: i guess i dont understand the challenge

16:14 justin_smith: SagiCZ11: make an arbitrary number, using only functions and constants in java.lang.Math

16:14 gfredericks: e.g., you can express 23 as ##(Math/floor (Math/exp Math/PI))

16:14 lazybot: ⇒ 23.0

16:15 justin_smith: here's an idea: have a bot generate a random integer between 0 and 1000, first person to make an == number using java.lang.Math wins?

16:16 SagiCZ11: ok but what number should we make?

16:16 gfredericks: &(rand-int 1000)

16:16 lazybot: ⇒ 860

16:16 gfredericks: that one

16:16 justin_smith: OK

16:17 gfredericks: you gotta generate a long, not a double

16:17 justin_smith: oh, so == is not good enough?

16:17 gfredericks: ah I see what you did there

16:18 ,(Math/round 42.0)

16:18 clojurebot: 42

16:18 justin_smith: ok, that's trivial anyway (which is why I suggested just using == rules, but whatever, no biggie)

16:18 gfredericks: yeah

16:18 I guess I don't care :)

16:30 ,(Math/toDegrees (Math/exp (Math/abs Math/E)))

16:30 clojurebot: 868.2752680712246

16:30 gfredericks: I guess the abs there is redundant :)

16:31 justin_smith: yeah, toDegrees is a godsend here in general

16:31 still, this is very hard

16:31 gfredericks: I would be further along if this baby hadn't woken up

16:31 SagiCZ11: i think one could write a script in clojure that goes through the possible functions.. just brute force

16:33 justin_smith: question is, can you write that program faster than one of us can find the solution by hand?

16:33 gfredericks: I was going the programmatic route

16:34 justin_smith: given the existence of addExact, if you have enough space for the code, you can trivially make any number programatically

16:34 but it would be very ugly for most numbers

16:35 SagiCZ11: i just thought it would be a cool exercise for a beginner like me :)

16:35 gfredericks: addExact?

16:41 meoblast001: when i use a java.lang.Long in a methematical operation, why do i get output like "1307/15" when i print it?

16:42 justin_smith: meoblast001: that's a rational - you can coerce it to a double or long if you prefer some other printing format

16:42 ,(Math/subtractExact (Math/addExact (Math/subtractExact (Math/round (Math/toDegrees (Math/exp Math/E))) (Math/round (Math/pow (Math/floor Math/PI) (Math/floor Math/E)))) (Math/round (Math/floor Math/E))) (Math/round (Math/floor (Math/getExponent Math/PI))))

16:42 clojurebot: #<CompilerException java.lang.IllegalArgumentException: No matching method: subtractExact, compiling:(NO_SOURCE_PATH:0:0)>

16:42 justin_smith: ergh

16:42 works locally

16:43 meoblast001: ah, okay

16:43 i read you can just put a (double ...) around it, and that should work

16:43 justin_smith: yeah, the rational form carries for precision, but is slightly slower for calculations

16:44 you can wrap it in (double ...) or (long ...) or feed it to format if you need to print it differently

16:44 *carries more precision

16:50 nbeloglazov: https://github.com/bbatsov/clojure-style-guide#two-spaces What is the difference between first and second bullets? When should one align using 2 spaces?

16:51 justin_smith: nbeloglazov: when is not a function

16:52 nbeloglazov: So macros and so on?

16:52 justin_smith: defn/when/let/fn/for etc. should get two space indent, regular functions should get extra arguments lined up with the first

16:52 it's a special form actually

16:52 even macros should generally get aligned with the first function (unless they are things like fn that wrap a special form)

16:53 nbeloglazov: I would say wording is confusing then

16:53 justin_smith: *aligned with the first arg

16:53 gfredericks: justin_smith: ooh these arithmetic functions are java 7

16:53 java 8 I mean

16:53 I hereby forbid java 8 from the competition

16:53 justin_smith: gfredericks: ahh, figures

16:53 lol

16:53 give me the java 7 list then

16:53 gfredericks: $google java 7 math

16:53 lazybot: [Math (Java Platform SE 7 ) - Oracle Documentation] http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html

16:53 justin_smith: I did get the correct answer with java 8 though

16:55 gfredericks: I just got 859

16:55 wait

16:56 &(Math/ceil (Math/toDegrees (Math/ceil (Math/expm1 Math/E))))

16:56 lazybot: ⇒ 860.0

16:56 gfredericks: kaboom

16:56 justin_smith: damn

16:56 nice

16:58 gfredericks: &(rand-int 10000) ; next target

16:58 lazybot: ⇒ 9578

17:01 hyPiRion: make swearjure golfing gogo

17:01 /s/make//

17:02 gfredericks: technically you can get to any double by applying nextUp enough times :)

17:03 justin_smith: gfredericks: even faster if you combine nextUp and ceil

17:03 gfredericks: wooooah

17:04 I don't know how to get to -infinity to start with though

17:04 catern: haha

17:04 that is fun

17:04 justin_smith: p. nice idea

17:04 justin_smith: ,(Math/ceil (Math/nextUp (Math/ceil (Math/nextUp (Math/ceil Math/PI)))))

17:04 clojurebot: 6.0

17:04 justin_smith: ad nausium

17:05 gfredericks: let's call this game "java math" just to be infuriatingly generic

17:05 justin_smith: heh

17:05 catern: how come you have to do it only with java math, though? why not arbitrary clojure?

17:05 justin_smith: with that, plus pow / log you get pretty close to a generic formula

17:05 gfredericks: I think it'd be fun to work out a function that can find an expression for an arbitrary double quickly

17:06 hyPiRion: gfredericks: that'd be boring though

17:06 gfredericks: justin_smith: hey good point

17:06 justin_smith: gfredericks: I am sure you can do it with nextUp / ceil / pow / log

17:06 hyPiRion: ,(map (fn [x] (.toString x)) [2.0 3.0 4.0 5.0 6.0])

17:06 clojurebot: ("2.0" "3.0" "4.0" "5.0" "6.0")

17:06 gfredericks: hyPiRion: huh?

17:07 catern: hyPiRion: that's numberwang!

17:07 hyPiRion: gfredericks: oh, I forgot some doubles cannot be printed nevermind

17:07 gfredericks: what does printing have to do with it anyhow?

17:07 catern: gfredericks: how about calling it javawang

17:08 hyPiRion: gfredericks: find an expression for an arbitrary double?

17:08 gfredericks: hyPiRion: oh the rules of java math say you can only use the Math class

17:08 hyPiRion: oh

17:08 gfredericks: and you cannot use java 8

17:08 or 9 or 10

17:08 hyPiRion: gfredericks: can I fork java and add constants for every double?

17:09 gfredericks: you cannot use Java vhyPirion either

17:09 justin_smith: hyPiRion: just give it a version number smaller than 8

17:09 gfredericks: you have to use java 7

17:11 JohnTalent: anyone want to develop a game with me? action/adventure using clojure, 2d canvas. i can do the art and scripting.

17:17 gfredericks: justin_smith: should we say it has to fit in a tweet? :)

17:17 that should rule out a lot of trivial solutions

17:28 * gfredericks is about to give up

17:30 JohnTalent: how do i change my 1.5.1 to 1.6.0?

17:30 why is this rocket science?

17:30 gfredericks: JohnTalent: are you using leiningen?

17:33 JohnTalent: gfredericks: now not, but it's also a problem in leiningen.

17:34 gfredericks: in leiningen you can change the entry in your project.clj

17:34 JohnTalent: i did that

17:35 gfredericks: is this with respect to a plugin?

17:35 JohnTalent: i'm trying to follow http://astashov.github.io/blog/2014/07/30/perfect-clojurescript-development-environment-with-vim/

17:36 i changed 1.5.1 to 1.6.0 in th project file

17:36 gfredericks: and what's the evidence that it doesn't work?

17:38 JohnTalent: hold on

17:38 how do i find out which clojurescript that i have?

17:39 justin_smith: lein deps :tree will show all your dependency versions

17:39 there is another command to show all your plugin versions iirc

17:43 meoblast001: damn do i have a lot of problems today

17:43 https://gist.github.com/meoblast001/dd0b2d34afd3928381f7

17:43 i'm getting messages here about this not being tail recursion. is there a way i could fix this?

17:44 gfredericks: it's not a tail recursive algorithm so you can't use recur

17:44 amalloy: meoblast001: it looks like you are trying to solve a problem that is better solved by ##(partition 2 1 '(a b c d))

17:44 lazybot: ⇒ ((a b) (b c) (c d))

17:44 gfredericks: meoblast001: you're trying to produce something for each pair in the sequence?

17:45 what amalloy said

17:45 JohnTalent: i just 'lein cljsbuild auto dev'. how can I tell it compiled 1.6.0 and not 1.5.1?

17:45 meoblast001: hmm. you're right

17:45 gfredericks: ~recursion

17:45 clojurebot: It's greek to me.

17:45 amalloy: me too, clojurebot. me too

17:45 meoblast001: all of this haskell i'm learning is warping the way i code

17:45 i'll switch to using partition

17:45 amalloy: uhhhhh, pretty sure haskellers would zipWith f xs (tail xs)

17:48 JohnTalent: ugh, python isn't serving up a sample page.

17:51 justin_smith: meoblast001: in general, you can convert a non-tail recursion to a tail recursion by adding an accumulator argument (and sometimes this also means a reduction as your last step)

17:51 this turns the stack building of non-tail recursion into a heap-building tail recursion

17:53 meoblast001: oooh

17:53 i'll look that up in more detail momentarily

17:58 michaelr: sorting a collection which om is rendering seems to mess everything up

17:58 anyone familiar with this issue and workarounds?

17:58 dnolen_: michaelr: you need to supply keys for everything

17:58 don't sort the app state either

17:58 just sort at the presentation layer

18:00 SagiCZ11: ,(for [i [:a :b] j [1 2]] (list i j))

18:00 clojurebot: ((:a 1) (:a 2) (:b 1) (:b 2))

18:00 michaelr: dnolen_: I have keys.. I'll to move the sorting to the rendering part

18:00 SagiCZ11: what if i want to iterate both colls in parallel?

18:00 michaelr: thanks

18:00 SagiCZ11: and get ((:a 1) (:b 2))

18:01 metellus: ,(map list [:a :b] [1 2])

18:01 clojurebot: ((:a 1) (:b 2))

18:01 SagiCZ11: metellus: thanks

18:03 michaelr: dnolen_: works ;)

18:10 SagiCZ11: ,(map inc (take 3 (drop 2 [2 5 4 1 3 6])))

18:10 clojurebot: (5 2 4)

18:12 SagiCZ11: ,(contains? :a {:a nil :b 2})

18:12 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: contains? not supported on type: clojure.lang.Keyword>

18:12 SagiCZ11: ,(contains? {:a nil :b 2} :a)

18:12 clojurebot: true

18:13 justin_smith: SagiCZ11: just don't expect it to work on anything sequential (at least not the way you would expect)

18:13 SagiCZ11: (def m {:a nil :b 2})

18:13 ,(and (contains? m :a) (nil? m :a))

18:13 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: m in this context, compiling:(NO_SOURCE_PATH:0:0)>

18:14 SagiCZ11: (do

18:14 (def m {:a nil :b 2})

18:14 (and (contains? m :a) (nil? m :a)))

18:14 darn it

18:14 justin_smith: SagiCZ11: that call to nil? is wrong

18:15 SagiCZ11: true

18:15 ,(let [m {:a nil :b 2}]

18:15 (and (contains? m :a) (nil? (m :a))))

18:15 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

18:15 justin_smith: ,(let [m {:a nil}] (and (contains? m :a) (nil? (m :a))))

18:15 clojurebot: true

18:15 SagiCZ11: whats wrong with my version?

18:16 justin_smith: multiple lines

18:16 johnwalker: why is the use of :pre and :post idiomatic compared to assert ?

18:16 SagiCZ11: justin_smith: thanks

18:17 johnwalker: there doesn't appear to be a way to add messages to them

18:18 gfredericks: johnwalker: there's a clojure-dev post about that recently; I agree it's a big drawback

18:18 johnwalker: ahh, thats good to hear

18:33 lpvb: what happens if I put an (int-array) into an atom and mutate the array?

18:34 JohnTalent: Caused by: java.lang.NullPointerException: core.clj:49 cljs.core/import-macros[fn]

18:35 jeremyheiler: lpvb: try it out in a repl

18:35 justin_smith: lpvb: you get an atom with a mutated array in it, I think ##(let [a (int-array 3 0) t (atom a)] (aset a 1 42) (into [] @t))

18:35 lazybot: ⇒ [0 42 0]

18:37 JohnTalent: goddamned bugs. it's looking for clj when i want cljs

19:47 scheafer: hi folks. anybody familiar with cgrand's spreadmap library?

19:48 i'm trying to read a named sheets from a workbook. i can't find the proper incantation

19:52 supersym: scheafer: (.getName wb ref) ?

19:54 scheafer: supersym: IllegalArgumentException No matching method found: getName for class net.cgrand.spreadmap.SpreadSheet

19:54 supersym: EvaluationWorkbook

19:55 would be the type to do it on I guess

19:55 https://github.com/cgrand/spreadmap/blob/master/src/net/cgrand/spreadmap.clj

19:55 im not too familiar with the whole reify deal but its a concrete implementation of abstract concept from what I learned sometime ago

19:56 but the source shall show you the way and perhaps a little tinkering that is :)

19:56 scheafer: thanks :) i've scanned the source but couldn't find a quick way to construct an evaluation workbook

19:57 supersym: well personally what I can make up from it this might not be intented to do so

19:57 e.g. your supposed to end up with the final form and workbook is afteral private

19:58 I do take it you feed it 2 params?

19:59 ok I see now

20:00 SpreadSheet is the final type indeed, getter and also workbook are application internal use only and so not a public API for yoy

20:00 scheafer: i think i'll open an issue... thx!

20:10 supersym: yeah... the french software isnt very familiar for its user-friendliness nor documenting in human readable format what stuff does :P

20:12 Im just running it in my own windows lighttable environment now to see how you are supposed to pull that data out of teh main objects

20:12 (sheet-index spreadmap Valueable SheetMisc ->SpreadSheet value formula-tokens CellMisc fm=) are publics anyway so those should be able to do it, or it isn't possible

20:15 blur3d: justin_smith: I pushed the arduino dashboard project I’ve been working on to github. https://github.com/blakejakopovic/testdrive

20:33 justin_smith: blur3d: cool

20:34 blur3d: justin_smith: It’s still just clojuresript->javascript, but I’m working on a few things that will help it move to node based

20:36 the fimata library will be converted to cljx, so it will support clojurescript, and it is getting support for different types of adapters (serial/tcp.. both java based and nodejs)

20:36 the Arduino Firmata library is getting a few required patches, and also adding support for the Spark Core device

20:37 I’ve also ordered a Beaglebone.. so I can play with that also

20:37 justin_smith: very nice, yeah

20:38 with beagle bone the sensors and the web server could all be on the same board

20:38 blur3d: Basically, I hope to keep the dashboard fairly generic.. so it will just be a dumb terminal.. and as long as you send it messages with the right format, it should work fine

20:38 https://github.com/blakejakopovic/TestDrive/blob/master/src/cljs/testdrive/core.cljs#L255

20:39 yeah, that would be very nice.

21:54 prachetasp: hi does anyone know how to use a keyword that has parentheses in it

21:55 i am using jdbc to get the last inserted record and I get back {:last_insert_id() 1111}

21:56 I'm planning on just destructuring it but it made me curious whether it was possible to have parentheses in a keyword

21:58 justin_smith: ,(keyword "foo()")

21:58 clojurebot: :foo()

21:58 justin_smith: yup

21:58 prachetasp: @justin_smith thanks!

21:59 duh... smh

21:59 justin_smith: so you can't use that for destructuring, but you can do (get m (keyword "foo()"))

21:59 prachetasp: or ((keyword "foo()") m)

22:00 is there any reason to use get?

22:01 justin_smith: it's more explicit - if neither my keyword or my map is a literal, I like to use get

22:01 but that's a style preference, of course

22:02 prachetasp: makes sense

22:02 thanks

22:33 rhg135: not completely style preference, using get can prevent NPEs

22:36 brehaut: ,(:foo {} 0)

22:36 clojurebot: 0

22:36 brehaut: ,({} :foo 0)

22:36 clojurebot: 0

22:37 amalloy: only if there's any possibility that the thing you're looking up could be nil, rhg135. and if what you're looking up is accidentally nil, an NPE is not the worst thing that could happen

22:37 JohnTalent: what does ^{} mean?

22:37 brehaut: JohnTalent: assign the map {} as meta data to the next form read

22:38 JohnTalent: form read?

22:38 brehaut: the s-expression structures (forms) read by the reader before they are evaluated

22:39 JohnTalent: ok

22:39 thanks

22:39 brehaut: ,(read-string “(foo :bar 1)”)

22:39 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: “ in this context, compiling:(NO_SOURCE_PATH:0:0)>

22:39 amalloy: brehaut: the smart quotes. it's like 1998 all over again

22:39 brehaut: amalloy: yeah no idea how that happened.

22:40 amalloy: are you using microsoft word as your irc client, maybe? that could do it

22:40 brehaut: haha

22:40 no im using colloquay which ive used for years with out that madness

22:40 it did recently update though'

22:42 talios: people still use colloquay? :)

22:42 brehaut: no i just pretend to

22:42 i dont want to own up to using irssi

22:43 talios: oh wait - brehaut's not people, soilent green is

22:43 at least use weechat from the console man :)

22:43 brehaut: i dont need to be macho about my IRC usage

22:46 amalloy: brehaut: we should start a club: people who use irc clients designed for little kids

22:46 brehaut: amalloy: lol :)

22:47 catern: baby's first irc client

22:47 brehaut: an app that doen't actually connect, but uses markov generators to randomly abuse you and occasionally answer questions with non-sequiters

22:50 rhg135: hmm

22:51 challange accepted

22:54 kristof: this is a bizarre conversation to walk into.

22:55 talios: not the strangest I've seen :)

22:57 johnwalker: does anyone know of a java project with insane dependencies ?

22:57 i'm looking to stress test leiningen

22:58 tjd and i ran into a stackoverflow working with particularly bad corporate java

23:00 danielcompton: I'm trying to create a java Keystore$SecretKeyEntry but I'm not sure how to access the inner class correctly

23:00 kristof: inner classes... *shudder*

23:01 danielcompton: I get CompilerException java.lang.ClassNotFoundException: java.security.Keystore$SecretKeyEntry, when I try

23:01 brehaut: im no java expert, but arent inner classes inner for a reason?

23:01 rhg135: nope

23:01 danielcompton: brehaut: I agree, however I think they're required to store a secret key in a java keystore. http://docs.oracle.com/javase/7/docs/api/javax/crypto/SecretKeyFactory.html#getInstance(java.lang.String)

23:02 brehaut: the sample code shows it doing that (correct link: http://docs.oracle.com/javase/7/docs/api/java/security/KeyStore.html)

23:03 amalloy: brehaut: inner classes aren't necessarily private

23:03 brehaut: amalloy: well that would be typically java wouldnt it

23:04 i mean, i can understand that you might pass instances of them around

23:04 amalloy: danielcompton: is there anything specific you're having trouble with? that sample code all looks pretty standard to translate to clojure, at first glance

23:04 danielcompton: amalloy: to call it in Clojure, I did (java.security.Keystore$SecretKeyEntry. myks mysecretkey)

23:04 amalloy: does that look right?

23:05 amalloy: i only see one parameter for that constructor. what do you imagine the second is going?

23:06 kristof: rhg135: I love the implication of that.

23:06 amalloy: ie, http://docs.oracle.com/javase/7/docs/api/java/security/KeyStore.SecretKeyEntry.html#KeyStore.SecretKeyEntry(javax.crypto.SecretKey)

23:07 justin_smith: I see two constructors - secretkey or secretkey, attributeset

23:07 danielcompton: amalloy: I thought I needed to pass the outer class, as the outer class isn't static

23:07 justin_smith: oh, I was looking at security, not crypto, never mind

23:07 mthvedt: danielcompton: that’s only if the inner class isn’t static

23:08 danielcompton: amalloy: it doesn't work taking away myks either

23:08 mthvedt: these code examples suggest you might need to import the inner class

23:08 before clojure likes the constructor

23:08 amalloy: mthvedt: no

23:08 mthvedt: but that’s just a wild guess.

23:08 danielcompton: I've imported the inner class too

23:09 amalloy: danielcompton: you may have any number of *other* problems, but the only thing i can tell from "here is a line of code, it doesn't work" is that you definitely don't want to pass the keystore argument in

23:09 danielcompton: amalloy: I'll put together a failing example other people can run which might reveal the problem

23:19 mthvedt: danielcompton: wild guess #2, maybe your import is wrong. that can also cause classnotfound

23:27 danielcompton: amalloy: rubber duckying it in the repl seems to have fixed it. It works for me now, not sure what I had typed wrong that was causing the issues

23:28 Thanks

Logging service provided by n01se.net