#clojure logs

2014-08-10

00:00lpvbjeremyheiler: 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
00:01lpvbthat and also I know whatever has a _ before it is definitely a side effect
00:01lpvband my nil returns are explicit
00:01lpvbidk
00:01jeremyheilercool. i've done the _ thing with temporary printlns and whatnot
00:02jeremyheilerbut i otherwise don't find myself doing a lot of side effecty things in a let
00:02jeremyheilerin a let binding*
02:40Jaoodamalloy_: did you switch computers?
03:06amalloyJaood: what? when?
03:40bluesnowHi, I installed the counterclockwise plugin for Eclipse, but when I go to File -> New -> Project -> .., I don't see the Clojure Project option.
03:40bluesnowAny idea what I might be missing?
04:13katratxobluesnow: it's File > New > Clojure https://i.imgur.com/UuBHZci.png
04:32mischovWith cond, is there a way to use the value the test returns in the associated expression?
04:34oskarkvmischov with condp there is
07:55winkhmm, interop question. IllegalArgumentException No matching field found: xx for class xy
07:55winkbut reflection clearly shows the method is there. calling it with (.. obj xx) or (.xx obj) makes no difference. ideas?
07:56rweiris it private
07:56winknot according to reflection and docs
07:56Bronsawink: do you have a concrete example?
07:59winkhttp://hastebin.com/edeluzatad.clj
07:59winknote that I don't see an error in line 5 (in doto), only when I call it outside
08:00winkand apparently you need an animated gif as the input, e.g. http://asset-8.soup.io/asset/7750/5369_87a9.gif
08:00Bronsawink: in the doto you're calling it as a method, passing true as an arg
08:01winkdoh.
08:01winkthanks
08:01Bronsanp
08:01wink.getNumImages x true works
08:02winksilly error message though
08:02Bronsanot really, it tells exactly what's going wrong
08:02Bronsayou're trying to access a getNumImages field, it doesn't exist
08:02winkas from calling you can't differentiate between a method without args and a field
08:03Bronsawink: (.-field obj) is the new syntax that should be prefered for field access
08:03winkplus, who uses public fields? :)
08:03winkoh?
08:03Bronsa(.field obj) is old syntax
08:04hyPiRionyou can also do (. obj (method)) for method calls
08:04Bronsaor (.method obj ())
08:04Bronsauh, no.
08:04Bronsanevermind.
08:04hyPiRionyeah, that would send () as second argument
08:05Bronsayeah I derped
08:05Bronsawink: .- was introduced in 1.4 IIRC
10:31timothywIs there a lein plugin for test.check? It would be nice to auto-run my tests as they’re developed.
10:31ChouLinhello, 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:32reiddrapertimothyw: I'm now aware of one at the moment, would be great to have one though
10:32ChouLina trie out of["aat" "abt" "aac" "a" "b"] has 4 terminals, the code return 2.
10:33ChouLin5, typo.
10:33timothywreiddraper, too right… I’m about to write a lein plugin, and was wondering about the semantics
10:34timothywie , pass in the ns and number of time to run each test?
10:34reiddrapertimothyw: awesome. Let me know if you get something published and I'll happily add it to the test.check readme
10:35timothywok, will do
10:38mi6x3mhey clojure, is deinit! a suitable name for a function returned by a function constructing a graphical component and perfoming some deinitialization?
10:39sh10151What is deinitialization?
10:39mi6x3msh10151: stopping a webserver for instance
10:41sh10151wouldn't that just be 'stop' then?
10:42mi6x3msh10151: this was just an example
10:42sh10151hmm what are some other examples, trying to figure out the context
10:42mi6x3msh10151: stopping a server, returning back resources, writing some log files etc.
10:43mi6x3mit's a general framework with examples of a component suite
10:43sh10151That seems really really generic -- I don't usually think of "deinitialization" when writing a log file
10:43sh10151Also it doesn't seem to be restricted to the opposite of whatever "initialization" is?
10:44mi6x3mwell it's _mostly_ the opposite, but not always yes :)
10:44mi6x3mperhaps "cleanup"
10:44sh10151I think enter/exit are a little more commonly used names for that level of genericity
10:45sh10151see monitor-enter/monitor-exit or python's context manager __enter__/__exit__
10:45justin_smithmi6x3m: the rule in the jvm is usually that deinitialization is implicit when a resource leaves scope
10:45hugodtimothyw: I haven't used, but https://github.com/runoshun/lein-watch looks like it might help you
10:45mi6x3mjustin_smith: this is a completely different affair for the component is living for far longer than the scope
10:46justin_smithmi6x3m: under the jvm, that isn't possible - there is some scope where it is reachable
10:47justin_smithunless you expect it to randomly be released / reclaimed
10:47mi6x3mjustin_smith: wait, I am speaking about a swing component
10:48justin_smithOK. finalize?
10:48justin_smithor just cleanup
10:49mi6x3mfinalize might be ok yeah
10:50mi6x3mjustin_smith: cleanup! in that case i guess?
10:51sh10151I don't like the ! - isn't that for things that are known to be unsafe in STM?
10:52sh10151writing a log file isn't
10:52justin_smithsh10151: well I would guess you wouldn't want to retry a cleanup!
10:53mi6x3mthere will be no retrying here anyway
10:53justin_smithgoddamn clojure putting punctuation in names making me sound like a middle school student
10:53timothywhugod, yes that does look good. I’m gonna try it out, thanks.
10:53sh10151justin_smith: that would depend on the exact nature of the cleanup I think
10:54sh10151justin_smith: this whole affair seems quite astronautical to me
10:54sh10151:)
10:54mi6x3mis there a shortcut for calling a function only if it's not nil?
10:54mi6x3malternative to when-let
10:54Bronsajustin_smith: next time write `cleanup!` and you'll be fine
10:54timothywweavejester also created https://github.com/weavejester/lein-auto
10:54justin_smithmi6x3m: fnil maybe?
10:54justin_smith(inc Bronsa)
10:54lazybot⇒ 38
10:56justin_smithmi6x3m: wait, no, not fnil - ((or f (constantly nil)) arg1 arg2 ... argN) would work, but is not a shortcut
10:56mi6x3mjustin_smith: yeah not really shorter and way more unreadable :)
10:56mi6x3mthanks for all the advice though :)
10:56mi6x3m(inc justin_smith)
10:56lazybot⇒ 59
10:58justin_smithmi6x3m: I often have (def nothing (constantly nil))
10:58justin_smith((or f nothing) args)
10:59justin_smithand you don't need when-let - you could also use when (when f (f args))
11:16timothywwhen I try to use `lein release` in one of my projects, I get this error: http://pastebin.com/TrHLJ46D
11:16timothywwhat am I missing?
11:19justin_smithtimothyw: 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:19rweirclojure 1.3?
11:20timothyw@justin_smith: yes, that’s what I thought too - but `lein` is definitely available from anywhere
11:21timothyw@rweir, my project’s clojure version is [org.clojure/clojure "1.5.1"]
11:36justin_smithtimothyw: you should turn on pedentic dependency resolution in your project.clj, because something is giving you the wrong clojure version
11:36justin_smith:pedantic? :abort
11:36timothywSomehow, when lein does `java.lang.UNIXProcess.forkAndExec`, some library or execution path with `lein` is not available.
11:37timothywok, lemme try that
11:37justin_smithalso, be sure that lein is not only in your path, but also in your exported path
11:38timothyw@justin_smith, I put the `:pedantic? :abort` k/v in my project.clj. But the same error occurs
11:38justin_smithso not only PATH=... in your shell config, but export PATH=...
11:38justin_smithhmm
11:38timothywok, one sec…
11:40timothywyep, in .bash_profile, I have “export PATH="$PATH:~/bin/:…”
11:40timothywlein is in “~/bin/lein”
11:50justin_smithOK, lein-release uses clojure 1.3
12:07timothyw@justin_smitth, hmm, that’s interesting
12:07timothywI can get around this issue by running `lein jar` and `lein pom`, manually.
12:08timothywand logged a bug here: https://github.com/relaynetwork/lein-release/issues/20
12:12justin_smithreading 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:16llasramThe 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:29timothyw@justin_smith, yeah, I thought was weird too
12:33timothyw@llasram, I see that, yes. I’ll give that a shot. Thanks :)
12:33llasramtimothyw: BTW, the convention on IRC to refer to someone is to just use their bare handle. No need for the `@` prefix
12:34timothywcool beans - habits from other IM tools get mixed into here too :)
13:57gfredericks~@
13:57clojurebot@ is splicing unquote
13:57gfrederickshuh.
13:57gfredericks~~@
13:57clojurebotTitim gan éirí ort.
13:57JohnTalentglobal state is managed with assoc, dissoc?
13:57gfredericksclojurebot: ~@ is splicing unquote
13:57clojurebotc'est bon!
13:57gfredericks~~@
13:57clojurebot~@ is different from ~ and different from @
13:58gfredericks~~@
13:58clojurebot~@ is splicing unquote
13:58gfredericksclojurebot: forget @ is splicing unquote
13:58clojurebotOk.
13:58gfredericksJohnTalent: assoc and dissoc operate on immutable maps
13:58gfredericks~@
13:58gfredericksclojurebot: @?
13:58rweirJohnTalent, you may be thinking of vars
13:59gfredericksglobal state is usually avoidable
13:59JohnTalentrweir: i am a total newb.
14:00rweirJohnTalent, what specifically do you want to do?
14:01andyfJohnTalent: 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:02andyfRegardless 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:03JohnTalentrweir: pass around global state.
14:03rweirJohnTalent, that's not specific
14:03JohnTalentrweir: yes, because it's a nonissue until i start writing.
14:04JohnTalentandyf: thanks
14:05gfrederickssounds like he might be using an alternate sense of "global state"
14:05rweirindeed
14:05gfredericksi.e., the purely-functional variant of it
14:05gfredericksthe state monad essentially :)
14:06andyfSometimes you just gotta try out various things for yourself to learn their advantages and disadvantages.
14:12JohnTalentandyf: right
14:45meoblast001suppose 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:47gfredericks((fn [] ...))
14:48gfredericks,((fn [] 42))
14:48clojurebot42
14:48meoblast001ah, thanks
14:48gfredericks,(((fn [] (fn [] 42))))
14:48clojurebot42
14:48gfredericks,((((fn [] (fn [] (fn [] 42))))))
14:48clojurebot42
14:48meoblast001i feel like i'm going about this problem the wrong way...
14:49gfredericks,(((((fn [] (fn [] (fn [] (fn [] 42))))))))
14:49clojurebot42
14:49meoblast001i 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:50meoblast001i thought i'd solve this with recursion and filter... but i'm not sure if that'll be clean
14:51gfredericks,(doc partition-by)
14:51clojurebot"([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:51meoblast001omg thanks i love you, gfredericks
14:52meoblast001there'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:52technomancy,(doc partition-all)
14:52clojurebot"([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:53technomancypartition-by is usually the wrong thing
14:53meoblast001well partition-all would work great if i was saying "I want X amount of things in each collection"
14:53meoblast001but 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:53gfredericksmeoblast001: that rule seems to say that each partition has the same timestamp?
14:53gfredericksoooh
14:54gfredericksso it's based on some property of the whole partition together?
14:54gfrederickssort of like starting with a bunch of numbers and splitting them into chunks that sum as high as possible without exceeding X?
14:54meoblast001yeah. it's based on the first entry in the partition
14:55meoblast001so basically if the first item in a partition caries the timestamp "40", i don't want the last one to exceed "70"
14:55meoblast001once it does, start the next part
14:55gfredericksgotcha
14:55gfredericksreduce can do that
14:56meoblast001yeah.. if i throw in a collection i could probably get that.... hm
14:56meoblast001if 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:57justin_smithreduce can do it, you would want some kind of simulated annealing to optimize it though
14:57meoblast001i feel like there's a really good recursive solution to this but can't think of it right now
14:57justin_smithor maybe not...
15:01gfredericksI've got a reduce
15:01gfredericksone sec
15:01meoblast001ah. i came up with a good recursive solution on the toilet!
15:01gfrederickshttps://www.refheap.com/89089
15:01meoblast001i 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:01meoblast001hmm
15:03justin_smithwhy would reduce skip anything?
15:03gfredericks,(defn sorta-reduce "like reduce but skips things sometimes" ...)
15:03clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Parameter declaration ... should be a vector>
15:03meoblast001oh sorry. i was thinking filter, not reduce
15:03meoblast001had reduce on my mind for some reason
15:04justin_smithgfredericks: flaky-reduce
15:04gfredericks(inc flaky-reduce)
15:04lazybot⇒ 1
15:04gfredericksmeoblast001: because I just used it ;-)
15:04meoblast001yup
15:04meoblast001reading yours right now
15:04rpaulo(inc flaky-reduce)
15:04lazybot⇒ 2
15:05gfredericksmeoblast001: 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:05rpaulofor a language that stresses imutability, this seems odd!
15:06gfredericksrpaulo: what's not immutable about this?
15:06meoblast001gfredericks: yup, thanks :)
15:06justin_smithrpaulo: (inc ...) in this channel is just a pseudo-syntax
15:06justin_smiththat is not how inc really works, of course
15:06meoblast001i'm just making sure i understand it before doing that
15:06gfredericksoooh that
15:06rpauloyeah, it was a joke...
15:07justin_smithOK, you forgot to attach the joke metadata, which led to a reader error on my end
15:07rpaulo:)
15:07meoblast001gfredericks: this solution is clever
15:08meoblast001i don't do as much clojure as i wish to, so my solutions are never this clever ;)
15:08meoblast001or.. rarely
15:10gfredericksaw man clojure 1.7 doesn't have update yet
15:10meoblast001peek is an interesting function
15:14justin_smithmy minor reworking of gfredericks' version https://www.refheap.com/89091
15:16meoblast001style question. if i'm doing a really complex expression inside of the [] of a let, how far in should i indent?
15:16justin_smithmeoblast001: exactly as far as emacs auto-indents
15:16meoblast001lol. i'm not using emacs
15:16meoblast001inb4 "that's your problem"
15:16justin_smithheh
15:17wcauchoishey, 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:17wcauchoisHttpServerCodec is definitely an instance of ChannelHandler so i don't understand that
15:17meoblast001justin_smith: how far does your emacs do it?
15:17justin_smithmeoblast001: a multi-line binding in let should be indented exactly as much (relatively) as it would be anywhere else
15:17wcauchoisanyone know what that [L is in front of the type? could that have anything to do with it?
15:17justin_smithwcauchois: are you trying to use a varargs method?
15:17meoblast001so one indent forward from the (let ?
15:18wcauchoisjustin_smith: yes, i am
15:18justin_smithwcauchois: varargs methods are just a java syntactic sugar, we don't have an equivalent in clojure
15:18justin_smithwcauchois: you need to put all the optional arguments into an array
15:19wcauchoisdo i still pass the non-optional arguments regularly, or do i pass the whole thing as an array?
15:19justin_smith(method required-arg (into-array [optional1 optional2 optional3]))
15:19gfredericksjustin_smith: I see your minor reworking and raise you a genericification: https://www.refheap.com/89092
15:19gfredericksmeoblast001: ^
15:19justin_smiththe javadoc should make clear which are required and which are optional
15:19wcauchoisok let me try that
15:19wcauchoisthe function is also overloaded, although i'm calling the 2-arg version which isn't (there are two 3-arg ones)
15:19meoblast001woo
15:20wcauchoiswould clojure dispatch based on the types to the overloaded ones?
15:20justin_smithwcauchois: 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:21justin_smithwcauchois: 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:21justin_smithwcauchois: 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:22wcauchoiswhich you can do with ^Type, correct?
15:22wcauchoisalso 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:23justin_smithwcauchois: 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:23justin_smiththe varargs should be preceded by at least one non-array argument I think, almost always
15:24justin_smithwcauchois: do you have a link to the javadoc for the method in question?
15:24justin_smithgfredericks: very nice
15:24justin_smith(inc gfredericks)
15:24lazybot⇒ 81
15:25oskarkvmeoblast001 gfredericks what about this? https://www.refheap.com/89093
15:25wcauchoisokay, i think it worked by passing the first required arg regularly and then passing the second arg as a singleton array
15:25wcauchoisyess no more exceptions. still not working, but now i'm on to the next bug :)
15:25justin_smithwcauchois: yeah, I think that is pretty much always how it needs to be done
15:25wcauchoisok. thanks for the help!
15:25gfredericksthat's the first time in half a year I've gotten karma for something that wasn't a joke
15:25justin_smithwcauchois: do you have a specific reason to use netty directly instead of using ring?
15:26gfredericksoskarkv: hey cool
15:26gfredericksseems better for being lazy
15:26gfredericksor at least it would be lazy if you had wrapped it in lazy-seq :)
15:26oskarkvyeah :P
15:28wcauchoisjustin_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:29justin_smithwcauchois: oh, nice
15:29wcauchoisthere's aleph, which looks really nice, but it's not ring-compatible
15:29wcauchoisalso i thought maybe this would be a good learning experience? haha
15:30wcauchoistho it seems more like i'm learning about the warts of java interop than actual clojure
15:30wcauchoisoh wait
15:30wcauchoisaleph is ring-compatible, what am i saying
15:30wcauchoisanyway, learning experience etc
15:31justin_smithjava 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:32justin_smiththe 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:01gfrederickschallenge: given a number, try to express it in clojure/java by referencing only the Math class
16:03SagiCZ11,Math/PI
16:03clojurebot3.141592653589793
16:09milos_cohagenam i using the term 'yak shaving' correctly if i used it to describe the last two hours of emacs/pkg/cider woes?
16:10gfredericksprobably depends on how valuable those woes were
16:10justin_smithprobably
16:11justin_smithfor the convenience of anyone considering gfredericks' challenge https://www.refheap.com/89095
16:11gfredericksI was just assembling a similar list
16:11justin_smithtab-complete plus refheap-paste-region :)
16:12gfredericksha
16:14SagiCZ11i guess i dont understand the challenge
16:14justin_smithSagiCZ11: make an arbitrary number, using only functions and constants in java.lang.Math
16:14gfrederickse.g., you can express 23 as ##(Math/floor (Math/exp Math/PI))
16:14lazybot⇒ 23.0
16:15justin_smithhere'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:16SagiCZ11ok but what number should we make?
16:16gfredericks&(rand-int 1000)
16:16lazybot⇒ 860
16:16gfredericksthat one
16:16justin_smithOK
16:17gfredericksyou gotta generate a long, not a double
16:17justin_smithoh, so == is not good enough?
16:17gfredericksah I see what you did there
16:18gfredericks,(Math/round 42.0)
16:18clojurebot42
16:18justin_smithok, that's trivial anyway (which is why I suggested just using == rules, but whatever, no biggie)
16:18gfredericksyeah
16:18gfredericksI guess I don't care :)
16:30gfredericks,(Math/toDegrees (Math/exp (Math/abs Math/E)))
16:30clojurebot868.2752680712246
16:30gfredericksI guess the abs there is redundant :)
16:31justin_smithyeah, toDegrees is a godsend here in general
16:31justin_smithstill, this is very hard
16:31gfredericksI would be further along if this baby hadn't woken up
16:31SagiCZ11i think one could write a script in clojure that goes through the possible functions.. just brute force
16:33justin_smithquestion is, can you write that program faster than one of us can find the solution by hand?
16:33gfredericksI was going the programmatic route
16:34justin_smithgiven the existence of addExact, if you have enough space for the code, you can trivially make any number programatically
16:34justin_smithbut it would be very ugly for most numbers
16:35SagiCZ11i just thought it would be a cool exercise for a beginner like me :)
16:35gfredericksaddExact?
16:41meoblast001when i use a java.lang.Long in a methematical operation, why do i get output like "1307/15" when i print it?
16:42justin_smithmeoblast001: that's a rational - you can coerce it to a double or long if you prefer some other printing format
16:42justin_smith,(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:42clojurebot#<CompilerException java.lang.IllegalArgumentException: No matching method: subtractExact, compiling:(NO_SOURCE_PATH:0:0)>
16:42justin_smithergh
16:42justin_smithworks locally
16:43meoblast001ah, okay
16:43meoblast001i read you can just put a (double ...) around it, and that should work
16:43justin_smithyeah, the rational form carries for precision, but is slightly slower for calculations
16:44justin_smithyou can wrap it in (double ...) or (long ...) or feed it to format if you need to print it differently
16:44justin_smith*carries more precision
16:50nbeloglazovhttps://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:51justin_smithnbeloglazov: when is not a function
16:52nbeloglazovSo macros and so on?
16:52justin_smithdefn/when/let/fn/for etc. should get two space indent, regular functions should get extra arguments lined up with the first
16:52justin_smithit's a special form actually
16:52justin_smitheven macros should generally get aligned with the first function (unless they are things like fn that wrap a special form)
16:53nbeloglazovI would say wording is confusing then
16:53justin_smith*aligned with the first arg
16:53gfredericksjustin_smith: ooh these arithmetic functions are java 7
16:53gfredericksjava 8 I mean
16:53gfredericksI hereby forbid java 8 from the competition
16:53justin_smithgfredericks: ahh, figures
16:53justin_smithlol
16:53justin_smithgive me the java 7 list then
16:53gfredericks$google java 7 math
16:53lazybot[Math (Java Platform SE 7 ) - Oracle Documentation] http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html
16:53justin_smithI did get the correct answer with java 8 though
16:55gfredericksI just got 859
16:55gfrederickswait
16:56gfredericks&(Math/ceil (Math/toDegrees (Math/ceil (Math/expm1 Math/E))))
16:56lazybot⇒ 860.0
16:56gfrederickskaboom
16:56justin_smithdamn
16:56justin_smithnice
16:58gfredericks&(rand-int 10000) ; next target
16:58lazybot⇒ 9578
17:01hyPiRionmake swearjure golfing gogo
17:01hyPiRion/s/make//
17:02gfrederickstechnically you can get to any double by applying nextUp enough times :)
17:03justin_smithgfredericks: even faster if you combine nextUp and ceil
17:03gfrederickswooooah
17:04gfredericksI don't know how to get to -infinity to start with though
17:04caternhaha
17:04caternthat is fun
17:04caternjustin_smith: p. nice idea
17:04justin_smith,(Math/ceil (Math/nextUp (Math/ceil (Math/nextUp (Math/ceil Math/PI)))))
17:04clojurebot6.0
17:04justin_smithad nausium
17:05gfrederickslet's call this game "java math" just to be infuriatingly generic
17:05justin_smithheh
17:05caternhow come you have to do it only with java math, though? why not arbitrary clojure?
17:05justin_smithwith that, plus pow / log you get pretty close to a generic formula
17:05gfredericksI think it'd be fun to work out a function that can find an expression for an arbitrary double quickly
17:06hyPiRiongfredericks: that'd be boring though
17:06gfredericksjustin_smith: hey good point
17:06justin_smithgfredericks: I am sure you can do it with nextUp / ceil / pow / log
17:06hyPiRion,(map (fn [x] (.toString x)) [2.0 3.0 4.0 5.0 6.0])
17:06clojurebot("2.0" "3.0" "4.0" "5.0" "6.0")
17:06gfrederickshyPiRion: huh?
17:07caternhyPiRion: that's numberwang!
17:07hyPiRiongfredericks: oh, I forgot some doubles cannot be printed nevermind
17:07gfrederickswhat does printing have to do with it anyhow?
17:07caterngfredericks: how about calling it javawang
17:08hyPiRiongfredericks: find an expression for an arbitrary double?
17:08gfrederickshyPiRion: oh the rules of java math say you can only use the Math class
17:08hyPiRionoh
17:08gfredericksand you cannot use java 8
17:08gfredericksor 9 or 10
17:08hyPiRiongfredericks: can I fork java and add constants for every double?
17:09gfredericksyou cannot use Java vhyPirion either
17:09justin_smithhyPiRion: just give it a version number smaller than 8
17:09gfredericksyou have to use java 7
17:11JohnTalentanyone want to develop a game with me? action/adventure using clojure, 2d canvas. i can do the art and scripting.
17:17gfredericksjustin_smith: should we say it has to fit in a tweet? :)
17:17gfredericksthat should rule out a lot of trivial solutions
17:30JohnTalenthow do i change my 1.5.1 to 1.6.0?
17:30JohnTalentwhy is this rocket science?
17:30gfredericksJohnTalent: are you using leiningen?
17:33JohnTalentgfredericks: now not, but it's also a problem in leiningen.
17:34gfredericksin leiningen you can change the entry in your project.clj
17:34JohnTalenti did that
17:35gfredericksis this with respect to a plugin?
17:35JohnTalenti'm trying to follow http://astashov.github.io/blog/2014/07/30/perfect-clojurescript-development-environment-with-vim/
17:36JohnTalenti changed 1.5.1 to 1.6.0 in th project file
17:36gfredericksand what's the evidence that it doesn't work?
17:38JohnTalenthold on
17:38JohnTalenthow do i find out which clojurescript that i have?
17:39justin_smithlein deps :tree will show all your dependency versions
17:39justin_smiththere is another command to show all your plugin versions iirc
17:43meoblast001damn do i have a lot of problems today
17:43meoblast001https://gist.github.com/meoblast001/dd0b2d34afd3928381f7
17:43meoblast001i'm getting messages here about this not being tail recursion. is there a way i could fix this?
17:44gfredericksit's not a tail recursive algorithm so you can't use recur
17:44amalloymeoblast001: it looks like you are trying to solve a problem that is better solved by ##(partition 2 1 '(a b c d))
17:44lazybot⇒ ((a b) (b c) (c d))
17:44gfredericksmeoblast001: you're trying to produce something for each pair in the sequence?
17:45gfrederickswhat amalloy said
17:45JohnTalenti just 'lein cljsbuild auto dev'. how can I tell it compiled 1.6.0 and not 1.5.1?
17:45meoblast001hmm. you're right
17:45gfredericks~recursion
17:45clojurebotIt's greek to me.
17:45amalloyme too, clojurebot. me too
17:45meoblast001all of this haskell i'm learning is warping the way i code
17:45meoblast001i'll switch to using partition
17:45amalloyuhhhhh, pretty sure haskellers would zipWith f xs (tail xs)
17:48JohnTalentugh, python isn't serving up a sample page.
17:51justin_smithmeoblast001: 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:51justin_smiththis turns the stack building of non-tail recursion into a heap-building tail recursion
17:53meoblast001oooh
17:53meoblast001i'll look that up in more detail momentarily
17:58michaelrsorting a collection which om is rendering seems to mess everything up
17:58michaelranyone familiar with this issue and workarounds?
17:58dnolen_michaelr: you need to supply keys for everything
17:58dnolen_don't sort the app state either
17:58dnolen_just sort at the presentation layer
18:00SagiCZ11,(for [i [:a :b] j [1 2]] (list i j))
18:00clojurebot((:a 1) (:a 2) (:b 1) (:b 2))
18:00michaelrdnolen_: I have keys.. I'll to move the sorting to the rendering part
18:00SagiCZ11what if i want to iterate both colls in parallel?
18:00michaelrthanks
18:00SagiCZ11and get ((:a 1) (:b 2))
18:01metellus,(map list [:a :b] [1 2])
18:01clojurebot((:a 1) (:b 2))
18:01SagiCZ11metellus: thanks
18:03michaelrdnolen_: works ;)
18:10SagiCZ11,(map inc (take 3 (drop 2 [2 5 4 1 3 6])))
18:10clojurebot(5 2 4)
18:12SagiCZ11,(contains? :a {:a nil :b 2})
18:12clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: contains? not supported on type: clojure.lang.Keyword>
18:12SagiCZ11,(contains? {:a nil :b 2} :a)
18:12clojurebottrue
18:13justin_smithSagiCZ11: just don't expect it to work on anything sequential (at least not the way you would expect)
18:13SagiCZ11(def m {:a nil :b 2})
18:13SagiCZ11,(and (contains? m :a) (nil? m :a))
18:13clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: m in this context, compiling:(NO_SOURCE_PATH:0:0)>
18:14SagiCZ11(do
18:14SagiCZ11(def m {:a nil :b 2})
18:14SagiCZ11(and (contains? m :a) (nil? m :a)))
18:14SagiCZ11darn it
18:14justin_smithSagiCZ11: that call to nil? is wrong
18:15SagiCZ11true
18:15SagiCZ11,(let [m {:a nil :b 2}]
18:15SagiCZ11(and (contains? m :a) (nil? (m :a))))
18:15clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
18:15justin_smith,(let [m {:a nil}] (and (contains? m :a) (nil? (m :a))))
18:15clojurebottrue
18:15SagiCZ11whats wrong with my version?
18:16justin_smithmultiple lines
18:16johnwalkerwhy is the use of :pre and :post idiomatic compared to assert ?
18:16SagiCZ11justin_smith: thanks
18:17johnwalkerthere doesn't appear to be a way to add messages to them
18:18gfredericksjohnwalker: there's a clojure-dev post about that recently; I agree it's a big drawback
18:18johnwalkerahh, thats good to hear
18:33lpvbwhat happens if I put an (int-array) into an atom and mutate the array?
18:34JohnTalentCaused by: java.lang.NullPointerException: core.clj:49 cljs.core/import-macros[fn]
18:35jeremyheilerlpvb: try it out in a repl
18:35justin_smithlpvb: 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:35lazybot⇒ [0 42 0]
18:37JohnTalentgoddamned bugs. it's looking for clj when i want cljs
19:47scheaferhi folks. anybody familiar with cgrand's spreadmap library?
19:48scheaferi'm trying to read a named sheets from a workbook. i can't find the proper incantation
19:52supersymscheafer: (.getName wb ref) ?
19:54scheafersupersym: IllegalArgumentException No matching method found: getName for class net.cgrand.spreadmap.SpreadSheet
19:54supersymEvaluationWorkbook
19:55supersymwould be the type to do it on I guess
19:55supersymhttps://github.com/cgrand/spreadmap/blob/master/src/net/cgrand/spreadmap.clj
19:55supersymim not too familiar with the whole reify deal but its a concrete implementation of abstract concept from what I learned sometime ago
19:56supersymbut the source shall show you the way and perhaps a little tinkering that is :)
19:56scheaferthanks :) i've scanned the source but couldn't find a quick way to construct an evaluation workbook
19:57supersymwell personally what I can make up from it this might not be intented to do so
19:57supersyme.g. your supposed to end up with the final form and workbook is afteral private
19:58supersymI do take it you feed it 2 params?
19:59supersymok I see now
20:00supersymSpreadSheet is the final type indeed, getter and also workbook are application internal use only and so not a public API for yoy
20:00scheaferi think i'll open an issue... thx!
20:10supersymyeah... the french software isnt very familiar for its user-friendliness nor documenting in human readable format what stuff does :P
20:12supersymIm 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:12supersym(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:15blur3djustin_smith: I pushed the arduino dashboard project I’ve been working on to github. https://github.com/blakejakopovic/testdrive
20:33justin_smithblur3d: cool
20:34blur3djustin_smith: It’s still just clojuresript->javascript, but I’m working on a few things that will help it move to node based
20:36blur3dthe 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:36blur3dthe Arduino Firmata library is getting a few required patches, and also adding support for the Spark Core device
20:37blur3dI’ve also ordered a Beaglebone.. so I can play with that also
20:37justin_smithvery nice, yeah
20:38justin_smithwith beagle bone the sensors and the web server could all be on the same board
20:38blur3dBasically, 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:38blur3dhttps://github.com/blakejakopovic/TestDrive/blob/master/src/cljs/testdrive/core.cljs#L255
20:39blur3dyeah, that would be very nice.
21:54prachetasphi does anyone know how to use a keyword that has parentheses in it
21:55prachetaspi am using jdbc to get the last inserted record and I get back {:last_insert_id() 1111}
21:56prachetaspI'm planning on just destructuring it but it made me curious whether it was possible to have parentheses in a keyword
21:58justin_smith,(keyword "foo()")
21:58clojurebot:foo()
21:58justin_smithyup
21:58prachetasp@justin_smith thanks!
21:59prachetaspduh... smh
21:59justin_smithso you can't use that for destructuring, but you can do (get m (keyword "foo()"))
21:59prachetaspor ((keyword "foo()") m)
22:00prachetaspis there any reason to use get?
22:01justin_smithit's more explicit - if neither my keyword or my map is a literal, I like to use get
22:01justin_smithbut that's a style preference, of course
22:02prachetaspmakes sense
22:02prachetaspthanks
22:33rhg135not completely style preference, using get can prevent NPEs
22:36brehaut,(:foo {} 0)
22:36clojurebot0
22:36brehaut,({} :foo 0)
22:36clojurebot0
22:37amalloyonly 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:37JohnTalentwhat does ^{} mean?
22:37brehautJohnTalent: assign the map {} as meta data to the next form read
22:38JohnTalentform read?
22:38brehautthe s-expression structures (forms) read by the reader before they are evaluated
22:39JohnTalentok
22:39JohnTalentthanks
22:39brehaut,(read-string “(foo :bar 1)”)
22:39clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: “ in this context, compiling:(NO_SOURCE_PATH:0:0)>
22:39amalloybrehaut: the smart quotes. it's like 1998 all over again
22:39brehautamalloy: yeah no idea how that happened.
22:40amalloyare you using microsoft word as your irc client, maybe? that could do it
22:40brehauthaha
22:40brehautno im using colloquay which ive used for years with out that madness
22:40brehautit did recently update though'
22:42taliospeople still use colloquay? :)
22:42brehautno i just pretend to
22:42brehauti dont want to own up to using irssi
22:43taliosoh wait - brehaut's not people, soilent green is
22:43taliosat least use weechat from the console man :)
22:43brehauti dont need to be macho about my IRC usage
22:46amalloybrehaut: we should start a club: people who use irc clients designed for little kids
22:46brehautamalloy: lol :)
22:47caternbaby's first irc client
22:47brehautan app that doen't actually connect, but uses markov generators to randomly abuse you and occasionally answer questions with non-sequiters
22:50rhg135hmm
22:51rhg135challange accepted
22:54kristofthis is a bizarre conversation to walk into.
22:55taliosnot the strangest I've seen :)
22:57johnwalkerdoes anyone know of a java project with insane dependencies ?
22:57johnwalkeri'm looking to stress test leiningen
22:58johnwalkertjd and i ran into a stackoverflow working with particularly bad corporate java
23:00danielcomptonI'm trying to create a java Keystore$SecretKeyEntry but I'm not sure how to access the inner class correctly
23:00kristofinner classes... *shudder*
23:01danielcomptonI get CompilerException java.lang.ClassNotFoundException: java.security.Keystore$SecretKeyEntry, when I try
23:01brehautim no java expert, but arent inner classes inner for a reason?
23:01rhg135nope
23:01danielcomptonbrehaut: 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:02danielcomptonbrehaut: the sample code shows it doing that (correct link: http://docs.oracle.com/javase/7/docs/api/java/security/KeyStore.html)
23:03amalloybrehaut: inner classes aren't necessarily private
23:03brehautamalloy: well that would be typically java wouldnt it
23:04brehauti mean, i can understand that you might pass instances of them around
23:04amalloydanielcompton: is there anything specific you're having trouble with? that sample code all looks pretty standard to translate to clojure, at first glance
23:04danielcomptonamalloy: to call it in Clojure, I did (java.security.Keystore$SecretKeyEntry. myks mysecretkey)
23:04danielcomptonamalloy: does that look right?
23:05amalloyi only see one parameter for that constructor. what do you imagine the second is going?
23:06kristofrhg135: I love the implication of that.
23:06amalloyie, http://docs.oracle.com/javase/7/docs/api/java/security/KeyStore.SecretKeyEntry.html#KeyStore.SecretKeyEntry(javax.crypto.SecretKey)
23:07justin_smithI see two constructors - secretkey or secretkey, attributeset
23:07danielcomptonamalloy: I thought I needed to pass the outer class, as the outer class isn't static
23:07justin_smithoh, I was looking at security, not crypto, never mind
23:07mthvedtdanielcompton: that’s only if the inner class isn’t static
23:08danielcomptonamalloy: it doesn't work taking away myks either
23:08mthvedtthese code examples suggest you might need to import the inner class
23:08mthvedtbefore clojure likes the constructor
23:08amalloymthvedt: no
23:08mthvedtbut that’s just a wild guess.
23:08danielcomptonI've imported the inner class too
23:09amalloydanielcompton: 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:09danielcomptonamalloy: I'll put together a failing example other people can run which might reveal the problem
23:19mthvedtdanielcompton: wild guess #2, maybe your import is wrong. that can also cause classnotfound
23:27danielcomptonamalloy: 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:28danielcomptonThanks