#clojure logs

2015-08-24

02:31amalloyTEttinger: j.u.regex.Pattern/quote
02:31TEttinger(inc amalloy)
02:31lazybot⇒ 294
02:44KneivaYay, lazybot is back.
03:24degWhat is an idiomatic/efficient way to generate, e.g. (1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, ...) from (0, 3, 4, 9, ...)? That is: my input is a sequence of integers, unbounded but sorted, representing the positions that should be 1 in my output.
03:29oddcully,(let [there? #{0 3 9}] (map there? (range 10))
03:29clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
03:29oddcullyoho
03:30oddcully,(let [there? #{0 3 9}] (map there? (range 10)))
03:30clojurebot(0 nil nil 3 nil ...)
03:30opqdonutnice
03:32degBut, my input is potentially infinite.
03:33opqdonutthen you need to type out the recursive lazy-seq definition yourself
03:34degI'm not sure what you mean.
03:35degI think I need to take advantage of the fact that the list is sorted. Naively, in an imperative language, I would iterate the integers, and check if each one matched the head of the input list. If not, continue; if yes, output the value and pop the head of the input list. But, I'm not sure how to write that elegantly in Clojure.
03:36opqdonut(defn f [ind inds] (if (= ind (first inds)) (cons 1 (lazy-seq (f (inc ind) (rest inds)))) (cons 0 (lazy-seq (f (inc ind) inds)))))
03:36opqdonutyou recursively define a lazy seqnence
03:36opqdonutwith that definition, for example (take 20 (f 0 [0 3 4 9])) evaluates to (1 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0)
03:37opqdonutin general the functional equivalent of a loop that has variables x, y, z is a recursive function with arguments x, y, z
03:37degThanks. I need to wrap my head around that for a minute, but it looks good.
03:37opqdonutand returning a lazy sequence corresponds to an imperative generator (e.g. using python's yield)
03:38opqdonutjust indent the code nicely and it should be fairly obvious
03:38opqdonut"inds" is the list of indexes for 1s, "ind" is the current index we're at
03:38gilliardopqdonut: nice.
03:39opqdonutI just banged out that function in one go, it's quite natural once you've done this sort of thing a couple of times
03:40opqdonutcode would probably be more efficient if one used repeat and concat instead of cons
03:41degYup, I see it now. By, using repeat, you mean to look at the size of the gap, rather than iterating over all the intermediate values?
03:41opqdonutyep
03:42opqdonuthmm
03:42degYup. For my purposes, that extra efficiency is not needed, and would probably make the code less readable. But, point taken.
03:44opqdonutbtw here's one more approach:
03:44opqdonut,(let [inds [0 3 4 9] intervals (map - (rest inds) inds)] (mapcat #(cons 1 (repeat (dec %) 0)) intervals))
03:44clojurebot(1 0 0 1 1 ...)
03:45opqdonutneeds some additional code to take care of the position of the first 1
03:47degNot bad! A little bit harder for me to grok than the first one, but still understandable. The difference is that (at my current level of experience) your first version is immediately readable; the second would require me to add some comments in order to understand it later.
03:49opqdonutyeah, I find it that for non-trivial tasks it's clearer to write out the recursion instead of gluing together sequence functions
03:50degYup. I'm not used to lazy seqs today, because I'm coming back to Clojure after nearly a year away. But, in general, I always have trouble scanning complicated combinations of sequence functions.
03:51degWhat would you say is the community consensus for which approach is more idiomatic?
04:54ely-sedo people actually use core.typed?
05:08vijaykiranely-se: I didn't see enough usage in the wild
05:12ely-se"Type Error (saftcof/fridge.clj:24:4) Unannotated var clojure.core/update"
05:12ely-sebleh
05:15TEttingerely-se: is it updated to clojure 1.7?
05:15ely-seupdate-in gives a similar error anyway :p
05:18ely-sehttps://github.com/clojure/core.typed/wiki/clojure.core-Annotations
05:19ely-seyes, rewriting it to use assoc works
05:22ely-seugly but worth it
05:33ely-seit already caught a bug I just wrote :p
05:51newpmHello
05:57newpmI've recently taken over a team that develops SaaS apps in java and flex. I haven't coded in about 10 years, but even when I did, it was simple stuff like implementing quicksort in C etc. Given that I'm going to be working with a whole bunch of devs and testers, I'd like to learn a new programming language - one that helps me understand programming
05:57newpm, but from a non C/Java POV (so I can have the pleasure of relearning programming as well). Do you gurus have any recommendations for me?
05:57clojurebot#error {\n :cause "Unable to resolve symbol: but in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: but 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: but in this conte...
05:59TEttingernewpm: clojure's a good very-different kind of language
06:00newpmYes. I've been fascinated by functional programming paradigms - I've heard people say great things about it, esp from a foundational perspective.
06:00TEttingerother choices that might be useful in a similar way to Clojure would be haskell, possibly erlang, or maybe in a different functional approach, one of the newer science-y languages like Julia
06:00newpmI just don't want it to be TOO removed from what my team does and thinks in terms of programming philosophy
06:00TEttingeryeah if you're on the JVM, Clojure has great integration
06:01newpmI am posing the same questions in those two other channels, TEttinger. Ideally, I'd spend a month on each language and decide for myself but I don't know if I have that time
06:01tdammersif you're looking for an easier transition, I hear people use Scala with some success
06:01TEttinger,(doto (java.util.TreeMap.) (.put "a" 1) (.put 8 "b"))
06:01clojurebot#error {\n :cause "java.lang.String cannot be cast to java.lang.Long"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to java.lang.Long"\n :at [java.lang.Long compareTo "Long.java" 50]}]\n :trace\n [[java.lang.Long compareTo "Long.java" 50]\n [java.util.TreeMap put "TreeMap.java" 560]\n [sandbox$eval48 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eva...
06:01tdammersit's not as nice from a FP point of view, but the transition can be a little less painful
06:02TEttinger,(doto (java.util.TreeMap.) (.put "a" 1) (.put "b" 8))
06:02clojurebot{"a" 1, "b" 8}
06:02TEttingerhuh, it is statically typed even with erasure
06:02TEttingerI'm not a huge fan of scala
06:03tdammersme neither, but I've heard success stories of people getting it into shops that were previously deeply rooted in Java
06:03gilliardTEttinger: Because the treemap is trying to sort its keys and long.compareTo(string) doesn't work.
06:03tdammerssomething like clojure or, gasp, Haskell, wouldn't have flown
06:04TEttingerit seems like you either go all-in on the functional stuff and have to deal with a mountain of complex APIs, or you go to the simpler OOP stuff and basically have slightly slower java with worse IDE integration
06:04TEttinger(in scala)
06:04tdammersin all fairness, if you want IDE integration, it's near impossible to beat Java
06:05TEttingerdid you mean C#, the language that is borderline unusable without VS? :P
06:05jeayeWho says so?
06:05TEttingerthere is XS and monodevelop now
06:05TEttingerbut it's such a huge difference working with large files in VS
06:06TEttingerjeaye: if you wanted to find all usages in a C# project in vim?
06:06TEttingerall usages of a particular method overload
06:06jeayeYup, can do.
06:06TEttingerhow?
06:06tdammersback when I was still using C#, I settled for using VS for most stuff, and hooking vim into it for mass edits
06:06clojurebotwith style and grace
06:07TEttingerin VS that's ctrl-k r
06:07newpmThat is another additional overhead i would like to ideally avoid - learning ohw to use vim or emacs :)
06:08TEttingerclojure works well with IntelliJ IDEA's Cursive plugin
06:08TEttingeryour team may want to use Eclipse or IntelliJ
06:08jeayeTEttinger: You're familiar with vim, I hope; it has a _very_ extensive plugin community with thousands of plugins across many languages.
06:09jeayeTEttinger: Aside from project-based completion (including external references, etc), there is functionality for the whole suite of refactoring tricks, snippets, etc. All you'd want.
06:09TEttingerI don't know what those plugins do or if any will, say, erase my file if I press the wrong key
06:09jeayehah
06:09jeayeWell, if you're not a vim user, you'd likely think that way. Still, my point isn't to get you to use vim/emacs/whatever. My point is just that your claims about the state of editing C# are uninformed.
06:10jeayeOr misinformed, anyway.
06:10ely-seI already love core.typed.
06:10TEttingerdoes it have breakpoint debugging for C#?
06:10TEttingerdoes it have breakpoint debugging for Clojure?
06:10ely-seI hope it won't turn out to be a disaster.
06:10oddcullyTEttinger: who say, that cursive is not raining nukes on some country while you type?
06:11TEttingeras long as it's like murderer alley, sure cursive go right ahead
06:11ely-seTEttinger: can it handle Unix line endings?
06:12TEttingerI think VS can. I've never encountered issues with that outside of the stupidest programs like notepad
06:13jeayeTEttinger: Not sure about either since 1) I don't need the first; 2) I'm too new to clojure to've needed the second. Vim has a slime-like plugin, slimv, which is certainly usable (not gonna compare it to emacs, the proper lisp editor).
06:14jeayeI've enjoyed using it for CL work, anyway.
06:14TEttingerah ok
06:14newpmthanks everyone!
06:48cflemingoddcully: TEttinger: As far as I'm aware, Cursive does not rain nukes on any country while you're typing. If you believe this to be the case, please file an issue in the tracker.
06:56oddcullycfleming: that was a joke and not aimed at cursive. each and every piece of software has the potential of wrecking havoc on your computer. intellij plugins are not more or less safe than vim/emacs/... plugins
06:56cflemingoddcully: I know, my response was a joke too :-)
06:58cflemingIf Cursive actually were raining nukes, I'm not sure an issue in the tracker would be an appropriate response level, especially given how long it takes me to fix issues.
06:58oddcullywhat if the server with the issue tracker is the target of the nuke?
07:01cflemingThat would be sneaky. I'm not sure if Github issues are adequately distributed.
07:07pseudonymousWhile technically working in a repl, I have a question (maybe even a few) - after much experimentation, I've found that (require 'path.to.clj-file)(in-ns 'path.to.clj-file) at least allows me to refer to the functions defined within. However, now I can't access general (core?) functions such as doc. Is there a tutorial or something which covers working with the repl, namespaces & such ?
07:19kwladykapseudonymous, use (require 'namespace :reload-all)
07:19kwladykapseudonymous, and (namespace/foo ...) or (use namespace) if you preffer
07:31the-kennyThere is no support for :pre and :post in `defprotocol', right?
07:31the-kennyI would like to add some constraints to protocol functions, applying to *all* implementations.
08:00pseudonymouskwladyka: Also found out that *ns* points to my current namespace and by going back to the initial NS via in-ns all is well :)
08:04SigmundLhmm slack group too? lot's of messaging apps now :-)
08:09kwladykaI wrote http://clojure.wladyka.eu/posts/2015-08-24-how-to-improve-algorithm-speed.html connected with https://github.com/kwladyka/chess-challenge about how to improve algorithm speed in Clojure. I am sharing that with you and i will be very grateful if you can give me feedback about article.
08:09kwladykaAnyway where can i share article like this about Clojure?
08:10kwladykapseudonymous, for me my solution is much more comfortable, but i also started with in-ns at first day in REPL ;)
08:10kwladykaespecially intellij remember history of commands and you can easy run them again when you open your project. It is much more usability then.
08:24shrayasrHello everyone
08:24shrayasrI'm having a little problem understanding and taming timestamps
08:24shrayasris anyone around to help?
08:24shrayasr(i'm using clj-time)
08:25oddcully~ask
08:25clojurebotThe Ask To Ask protocol wastes more bandwidth than any version of the Ask protocol, so just ask your question.
08:27shrayasrthe server i'm hosting on is in the GMT timezone.
08:27shrayasrbut I want to store timestamps in another timezone (Say X)
08:27shrayasrI'm able to get the string representation of the timestamp in the "X" timezone
08:28shrayasrBut to insert into the DB (regular jdbc)
08:28shrayasrI need it to be in the "timestamp" type
08:29shrayasrwhich I can get via the clj-time.coerce/to-sql-time function
08:29shrayasrBut then the coerce/to-sql-time function doesn't take the time zone into consideration
08:29shrayasrSooooo. I'm stuck
08:30the-kennyLet me check how I handled it
08:30shrayasrSounds great, thanks @the-kenny
08:32shrayasrI see that we can start the JVM with a specified timezone, Any reason I *shouldn't* be doing this?
08:32shrayasrI assume if I do this, then it is straightforward for me
08:33the-kennyshrayasr: Hm, my code just extends jdbc/ISQLValue and calls `clj-time.coerce/to-timestamp'. That doesn't seem to handle timezones either
08:34the-kennyI'm quite sure I have a snippet which does some more (by manually creating the value with `ISQLParameter')
08:35the-kennyThat might have been postgres-specific though
08:39the-kennyshrayasr: By extending ISQLParameter for org.joda.time.DateTime (or some other class/record) you should be able to set the type of the PGobject to 'TIMESTAMP WITH TIME ZONE' and the value to some string lile: "2004-10-19 10:23:54+02"
08:40the-kennyas seen here: http://www.postgresql.org/docs/9.1/static/datatype-datetime.html#AEN5777
08:44en590clojure!
08:50gfrederi`clojure!
08:59dstocktonclojure!
08:59snowellclojure?
08:59clojurebotclojure is a language to use if you want to up your game
08:59en590well that's exactly what I want to do
09:00en590i've found two books that look good to learn it, 'living clojure' and 'clojure in action 2nd edition'
09:00en590are these good
09:02pseudonymousSo I finally came to a point where I need to reload something. While (require '[<my namespace> :as <short-hand>] :reload-all) doesn't yield any error, I still can't access anything from the NS (not even the old functions). I see references to "clojure.tools.namespace.repl" but including it fails (Could not locate.....) - what do people do ? Reopning the REPL constantly *sucks*
09:05en590_sorry i d/c
09:17en590_I'm on linux what environment do you all use to develop in?
09:17en590_like ide or whatever
09:18akabanderI've been using IntelliJ with the Cursive plugin. I'm normally an Emacs/command-line coder, but IntelliJ has some nice features.
09:19schmiren590_: I'm using emacs, but that may be a bit too hard when you're learning clojure at the same time.
09:19schmiremacs with cider
09:20akabanderI'm on Linux and OS X, our target platform is Linux-y though.
09:31kwladykaen590_, i also recommend intellij
09:31kwladykawith own shortcuts i super great
09:31snowellI use Light Table, FWIW
09:32kwladykalight table is crap unfortunately, it has so big potential but if i know author abandon project to care about new one
09:32kwladykaand for today light table doesn't work enough good for me
09:34snowellI tried getting IntelliJ/Cursive set up once and hit problems
09:35snowellI'm not against trying it again...
09:35cflemingsnowell: Let me know if you have problems, I'm always interested in trying to make it easier.
09:36akabanderThe only issue I had with Cursive was that it didn't seem to be able to create keymappings for the structural editing commands, I had to create them manually.
09:37cflemingakabander: You should be able to - not sure when you tried it, but that's been in there for a while now (https://cursiveclojure.com/userguide/keybindings.html)
09:38akabandercfleming: I gather you work on Cursive? The pages are pretty coy about who the author(s) are.
09:38cflemingakabander: I do - I'm the only developer.
09:39akabanderOh, well... Thanks for your efforts, it's a terrific plugin and makes my days pretty pleasant!
09:39cflemingThanks! That's always good to hear.
09:43kwladykasnowell, what kind of problems?
09:44snowellI don't really remember. I'm actually trying it again atm
09:45cflemingsnowell: Cool, I'll be around for a couple of hours if you're having issues.
09:46snowellIt may have been as dumb as Light Table's rainbow parens were brighter
09:46snowellI am a fickle man :)
09:47cflemingFortunately I recently changed Cursive's rainbow parens to be quite garish :-)
09:48snowellIt doesn't seem to want to read my project.clj. This could be because it starts with a let instead of defproject
09:48cflemingThat shouldn't be a problem, but it is a problem if you're doing things like slurping a version.txt file or something like that?
09:49kwladykaif you want use intellij cursive i strongly recommend shortcut for slurp forward and barf forwards
09:50akabanderI get weird looks when I ask people if their editor can slurp and barf.
09:50snowellI'm unfamiliar with barf
09:50snowellI thought it was spit
09:50akabanderI think it's the same thing but harder to confuse with split
09:51cflemingThey're two different things. Slurp/Barf refer to paredit (structural editing) and slurp/spit are functions for reading/creating files.
09:51akabander#dadjokefail
09:51cflemingBa-doom-*tschhh*
09:57snowellYeah, cfleming, it must have been me being stupid about colors. Looks like it's working OK outside of yelling at me that it can't load my project.clj
09:58snowellI'll keep using it and report back on its awesomeness
09:58cflemingI also accept reports on non-awesomeness :)
09:58cflemingAre you able to show me your project.clj?
09:58snowellProbably not, though I did just submit a report through the IDE
09:59snowellIt's just (let [blah blah] (defproject normal "stuff"))
09:59cflemingWeird, that should work. I'll see if I can reproduce with a simple case.
10:01snowellAt the base, it seems to be a NPE
10:01cflemingAre you using lein-sub?
10:02shrayasrthe-kenny: Had to go AFK. Sorry about that.
10:03snowellNo?
10:04cflemingsnowell: Can you paste the stacktrace to refheap?
10:07en590_i love function programing so much
10:09snowellcfleming, You know what, I might actually be able to see what it's NPE'ing on
10:09en590_have you guys completed most of 4clojure? this site is amazing
10:10wasamasafeels like a third to me
10:14en590_could anyone reccomend a resource for learning about functional programming in general?
10:15shrayasren590_: I found this 3 part series to be a lovely intro to FP: http://miles.no/blogg/why-care-about-functional-programming-part-1-immutability
10:18en590_ok neat thank you
10:18en590_clojure is 1 of the most beautiful languages ive seen
10:18en590_i guess thats true for all the lisps
10:19snowellcfleming: Looks like the problem is with a :repositories key in defproject
10:20cflemingsnowell: That should work - lots of Cursive users are using custom repos
10:20cflemingIs it a problem with GPG or something similar?
10:23shrayasren590_: No problem. Enjoy :)
10:24kwladykaWhat questions did you have on clojure interview?
10:26en590_wait there are real clojure jobs?
10:26jeayehah
10:26jeayeQuite a few.
10:26justin_smithyes, I'm a full time clojure dev, there are many others around here
10:27justin_smithdozens, there are dozens of us!
10:27akabanderI'm a professional Clojure dev -- convinced my boss that my piece of the project should use Clojure...
10:27snowellI do clojure at work despite the efforts of many of our clients :)
10:27en590_dang the world is a great place
10:28akabanderAnd at some point I'll probably need a minion or two, or somone at my level.
10:29jeayeakabander: May I PM you?
10:29snowellcfleming: https://www.refheap.com/108673
10:30snowellSorry about the delay, had to clean it up / anonymize it :D
10:30rsenioren590_: job market is good for Clojure folks
10:31en590_yah i believe it the language is just a joy
10:32arkhif compiling clojurescript with leiningen + cljsbuild works with all :optimzations except for :none, what could I be doing wrong? I've tried including a <script> reference to goog/base.js as well as taking everything made in target/cljsbuild-compiler-0/ and putting it in the webservers js folder so relative link references would be happy. Looks like the
10:32arkhbrowser is just loading my js, base.js and deps.js only so far
10:33snowellcfleming: Grr. The NPE should have been obvious, as I recently deleted JARS_HOME. I feel very bad that I'm getting paid to code and can't see that
10:33cflemingsnowell: Ah :-)
10:34snowellOf course fixing that led to a different error: https://www.refheap.com/108674
10:34cflemingSometimes it's hard to see the wood for the trees, for sure.
10:34kwladykado you know good video (prefer) / article about how to use macros? But not about how to use it technically, how to use it to write super code :)
10:34cflemingsnowell: Is JARS_HOME an absolute path?
10:35snowellYeah, it was. And I deleted that folder
10:36en590_I'm a linux noob trying to install leiningen. it says Place it on your $PATH where your shell can find it (eg. ~/bin)
10:36en590_how do I do this? I downloaded the lein script to my desktop
10:36cflemingsnowell: So Cursive currently has an issue (to be fixed shortly) where it runs lein in-process, so CWD is always set to somewhere in the IntelliJ bin directory
10:36en590_do i do 'sudo copy lein.txt ~/bin'
10:37gilliarden590_: you don't need sudo
10:37cflemingIf you're slurping or calling File. or something similar, it won't work properly because the CWD is bad.
10:37snowellWell it's not a relative path
10:37gilliarden590_: make sure there is a directory ~/bin first, then "mv ~/Downloads/lein ~/bin". ~ is just shorthand for your home dir.
10:37en590_i'm confused what does the ~ stand for
10:37cflemingI suspect there's something like that going on, but I can't see it from your project file. I've never seen that negative bytes error before.
10:38gilliarden590_: You can do "ls ~" etc
10:38kwladykaok i found, it looks good enough http://www.lispcast.com/when-to-use-a-macro
10:38snowellIt might be that some of the jars I need only existed in JARS_HOME
10:38en590_I don't see a /bin in my home folder
10:38en590_there is one in the root folder
10:38cflemingI'd expect a FileNotFound or similar in that case, though.
10:39gilliarden590_: There often isn't one on a new install. "mkdir ~/bin" will create one.
10:40snowellWell I'm getting that error just doing `lein deps` on the CLI. So I don't think it's a cursive problem
10:40en590_ok got it working
10:40en590_thank you
10:40cflemingsnowell: Googling around, that message does seem to be a glorified FNF
10:40en590_linux is very cool
10:42cflemingsnowell: Thinking about it, you're likely to have a problem in Cursive since you won't be able to set env vars where lein can see them.
10:42cflemingWhen it's run in-process, I mean.
10:42cflemingI'll add that to my list of things to fix - I'm actually planning a major lein update to fix all this sort of thing soon.
10:46snowellWell, something must have just been screwy in my local env. I reverted the changes, updated jars-home to exist, and now it works :/
10:47snowellThanks for at least making me look critically at it though, and for the willingness to help out :D
10:47cflemingNo worries, glad it's working!
10:47cflemingI'm going to get all those lein fixes in in probably the release after next - perhaps a month or so.
12:11en590is (conj '(1 2) 3) equally efficient as (cons '(1 2) 3)
12:11justin_smithen590: it's (cons 3 '(1 2)), the second arg to cons must be sequential
12:12justin_smithen590: cons is what conj ends up invoking for lists (you'll notice that conj on vectors behaves differently)
12:14justin_smithen590: depending on your use case, you might want a vector rather than list (which is part of why it is good to use conj rather than cons, so that remains flexible)
12:14justin_smithbut yes, conj on a list and cons on a list should be the same in perf
12:26en590hey i have a problem in my irc client whenever my internet craps out for a few seconds then returns, the irc doesnt connect again
12:26en590this has happened in hexchat and also quassel irc
12:27philth-irssien590, probably a client setting.
12:27philth-irssiiirc, x-chat had a "Number of reconnet attempts" option.
12:28philth-irssidon't know about hexchat or quassel tho'
12:31en590ok idisabled ping timeout stuff
12:31en590maybe it works
12:32en590why is (= 1 1.0) false but (== 1 1.0) true
12:33oddcully(doc ==)
12:33clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums all have the equivalent value (type-independent), otherwise false"
12:33snowellen590: because == is type-independent
12:34en590yeah makes sense just seems like the two should be switched
12:34en590i expected opposite behavior
12:35ely-seplease no :(
12:35ely-seIMO = on different types should even fail with an exception
12:36rhg135, (= '(1) [1])
12:36clojurebottrue
12:37ely-se:'(
12:37philth-irssi, (= 1 1.0)
12:37clojurebotfalse
12:37rhg135Sad indeed
12:37philth-irssi, (= [1] '(1))
12:37clojurebottrue
12:37philth-irssiwtf?
12:38akabanderBecause they are equivalent seq's?
12:38philth-irssi, (== [1] '(1))
12:38clojurebot#error {\n :cause "clojure.lang.PersistentVector cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentVector cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers equiv "Numbers.java" 208]}]\n :trace\n [[clojure.lang.Numbers equiv "Numbers.java" 208]\n [sandbox$eval141 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval14...
12:39oddcully(= 1N 1)
12:39oddcullyerm
12:39oddcully,(= 1N 1)
12:39clojurebottrue
12:39philth-irssiStop this madness.
12:39oddcully,(= 1M 1)
12:39clojurebotfalse
12:39philth-irssibigints are ints?
12:40philth-irssi, (type 1M)
12:40clojurebotjava.math.BigDecimal
12:40philth-irssiOoh
12:41philth-irssi(= (type 1) (type 1N))
12:41philth-irssi,(= (type 1) (type 1N))
12:41clojurebotfalse
12:42agarmanis it appropriate to ask datomic questions here?
12:43snowellYou'd probably have better luck in #datomic :)
12:44agarmansnowell: good call...it's a mix of Clojure + datomic, but I'll ask there first.
12:47en590i'm in the repl and when i tried to do (clojure.set/union #{:a} #{:b})
12:47en590i got the error ClassNotFoundException clojure.set java.net.URLClassLoader$1.run (URLClassLoader.java:366)
12:47en590do i have to load in this module
12:48philth-irssi(require 'clojure.set)
12:48oddcullyen590: yes require it
12:48philth-irssi,(require 'clojure.set)
12:48clojurebotnil
12:48philth-irssi,(require 'clojure.set) (union #{a} #{b})
12:48clojurebotnil
12:48philth-irssi,(do (require 'clojure.set) (union #{a} #{b}) )
12:48clojurebot#error {\n :cause "Unable to resolve symbol: union in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: union 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: union in this...
12:49en590neat thank you
12:49philth-irssi,(do (require 'clojure.set) (clojure.set/union #{a} #{b}) )
12:49clojurebot#error {\n :cause "Unable to resolve symbol: a in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: a 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: a in this context"\n ...
12:49philth-irssiffs
12:49philth-irssianyways it works in real repl.
12:49philth-irssi,(do (require 'clojure.set) (clojure.set/union #{"a"} #{"b"}) )
12:49clojurebot#{"a" "b"}
12:49philth-irssiAh-ha!
12:53iwohey, anyone here familiar with prismatic schema? I'd like to define a schema that says a value must be a function, I can't seem to find a way to do this
12:54iwoI was imagining just something like: {:f s/Fn}
12:54iwo(i.e. map must have a key :f with a value that's a function)
12:54rhg135(s/=>...)
12:55rhg135There's a => function to make function schemas
12:56iwoah okay, so I need to define the arity of the expected fn?
12:57rhg135I think so
12:57akabander,(doc =>)
12:57clojurebotIt's greek to me.
12:57iwothanks!
12:58iwolooks good.
12:58rhg135Np
12:58ely-seclojurebot: in that case I want my money back.
12:58clojurebotNo entiendo
12:58ely-seD:
12:58rhg135clojurebot is lacking
12:59snowellclojurebot: Don't listen to him
12:59clojurebotExcuse me?
12:59rhg135Did you try turning off and on again?
13:00en590,(+ 1 1)
13:00clojurebot2
13:00ely-se,(System/exit 0)
13:00clojurebot#error {\n :cause "denied"\n :via\n [{:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__849 invoke "sandbox.clj" 69]}]\n :trace\n [[clojurebot.sandbox$enable_security_manager$fn__849 invoke "sandbox.clj" 69]\n [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkExit nil -1]\n [java.lang.Runtime exit "Runtime.java" 1...
13:00ely-serhg135: I tried but failed.
13:00en590,"clojurebot is a good bot"
13:00clojurebot"clojurebot is a good bot"
13:01philth-irssiAw
13:01ely-seher :p
13:01rhg135I'm a he :-P
13:02rhg135Ambiguity
13:02philth-irssiWhat do they sandbox clojurebot with?
13:03rhg135Jvm sandboxing iirc
13:03ely-seoooh
13:04ely-seI see. :p
13:04ely-sephilth-irssi: the JDK has facilities for that.
13:04rhg135The pronoun has two possible targets
13:04rhg135Because English
13:05philth-irssirhg135, ely-se, Ah, thanks!
13:06ely-sewho is Ah?
13:06rhg135It may also use something else. You can check the source.
13:06philth-irssirhg135, ely-se, "Ah, thanks!"
13:06philth-irssiambiguity :P
13:06rhg135English!
13:06philth-irssiYea, I just found the github.
13:06ely-sethe misinterpretation was intentional :p
13:07rhg135We should just speak lisp with English words
13:07ely-se(ok)
13:07rhg135It's a midway point
13:08philth-irssiyou mean lithp
13:08ely-se(= :cool rhg135)
13:08rhg135(not (take-off this))
13:13ely-seI want to implement a data structure that wraps a set together with a collection of (function, map) pairs that can be used to find elements in the set quickly (like RDBMS indices)
13:18justin_smithely-se: that sounds a lot like a hash-map
13:18ely-seno, it's different
13:18wasamasaif your hashmap doesn't allow to find elements quickly, URDOINITRONG
13:18ely-sewait, I'll implement it
13:19justin_smithely-se: typically the right way to do pairs with quick lookup in clojure is a hash-map
13:19justin_smithnot to say that's the entirety of what would be implemented... but it should be the core of it
13:20ely-seyes, I know, but that's not what I'm looking for
13:21ely-sea hashmap has only a single index
13:21ely-seand you have to make sure you consistently manage the keys
13:21justin_smithwhat does "consistently manage the keys" mean?
13:22wasamasasounds like something a programmer shouldn't be bothered with
13:22wasamasamost likely staying with one data type for the keys
13:23justin_smithely-se: I'm thinking most of us don't actually understand what you are trying to do here
13:23ely-seagain, let me implement it
13:26wasamasaa quick search indicates that using more than one index on a database can be problematic with regards to performance
13:26wasamasabecause the way they usually go at it is looking for all matches for the first index, looking for all matches for the second index, then combining these and returning the results
13:27tcrayford____Query planners though
13:29hiredman,(doc clojure.set/index)
13:29clojurebotExcuse me?
13:29hiredmanjerk
13:30hiredmananyway, clojure.set/index exists, and even if you don't use it, a read through the source should be useful
13:30philth-irssi,(do (require 'clojure.set) (doc clojure.set/index))
13:30clojurebot"([xrel ks]); Returns a map of the distinct values of ks in the xrel mapped to a set of the maps in xrel with the corresponding values of ks."
13:30philth-irssiTa-da
13:32hiredmanclojure.set/index can build single key and multi key indices, and you can generally keep all the indices in a single map
13:34en590in a 'let' expression why are the bindings done in a vector and not a map?
13:34justin_smithen590: they are ordered and can refer to previous bindings
13:34justin_smithen590: also maps only allow keys to happen once, let bindings allow re-binding that shadows a previous key
13:35justin_smith,(let [a 0 b (inc a) b (inc b)] b)
13:35clojurebot2
13:35justin_smiththere's two reasons that would not work with a hash-map
13:36en590ok very neat thank you
13:36oddcully,(inc justin_smith)
13:36clojurebot#error {\n :cause "Unable to resolve symbol: justin_smith in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: justin_smith 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:...
13:36oddcullyomg
13:36justin_smithwithout the ,
13:36oddcullyi am so used to that not working...
13:36oddcully(inc justin_smith)
13:36lazybot⇒ 287
13:37oddcullyyeah i knew, then i forgot
13:37oddcullynow i unforgot
13:37en590(inc justin_smith)
13:37lazybot⇒ 288
13:38en590i love the inc function it is very explicit
13:39rhg135Gasp, you passed him
13:39en590but yeah justin that was an intense answer it was like perfect
13:40en590my mind just expanded
13:40ely-sejustin_smith: https://ideone.com/c4FGGC
13:40justin_smithely-se: I hope you saw hiredman 's remarks above
13:41ely-seoh
13:41ely-sehiredman: cool I'll look at it
13:41ely-sethat has no insertion, though
13:43hiredmanthey are clojure datastructures
13:43ely-seyou can use arbitrary functions as keys, add and remove elements, etc
13:43hiredmaninsertion is indexing a single record or records, and then merge-with into the existing db
13:43ely-ses/keys/indices/
13:44ely-sebrb; dinner
13:44hiredmanas written, no, you cannot use arbitrary functions as keys
13:47en590How much clojure do I need to get hired as a junior clojure dev?
13:48en590and what kind of project would be good to show I know the language decently
13:49sdegutisHow does reader macros like #db/id[:db.part/db] work?
13:49sdegutisDo they expand at compile time?
13:50justin_smithsdegutis: get ready to have your mind blown
13:50sdegutisI noticed that putting #db/id[:db.part/db] in a loop always resolves to the exact same constant at every interval in the loop.
13:50justin_smithsdegutis: they are expanded when reading
13:50sdegutisjustin_smith: no that can't be it it's too simple and makes too much sense
13:50rhg135Lol
13:51sdegutisjustin_smith++
13:53en590how long have you all been clojuring i want to be amazing at this language
13:53justin_smiththree or four years I think
13:53sdegutisen590: You will be amazing at it in 10 years by definition.
13:53sdegutisen590: There's a law of physics that says it takes 10 years to be amazing at a thing.
13:53en590there is just so much cool stuff I feel like I learn so much with a lisp language
13:54sdegutisAlso I've probably been doing it 1 day short of justin_smith's duration, I think I started the day after him.
13:54sdegutisWhich means by definition I'll always know 1 less fact about Clojure than justin_smith.
13:54en590What kind of projects did you work on starting out?
13:54en590I'm reading a book about the basics but I can't think of anything to actually make
13:54sdegutisen590: don't worry the high fades and then you sober up and realize Lisp is really just JavaScript all along.
13:54justin_smithen590: I got hired to work on a rapid application development web platform
13:54sdegutisjustin_smith: wait just like me?
13:55justin_smithI guess so? must have been something going around back in 2012 or so?
13:55sdegutisjustin_smith: does this.. does this mean we're twins?
13:55justin_smithsoul-mates, surely
13:55sdegutisjustin_smith: ok so what's our bank PIN btw
13:56justin_smithhunter2
13:56justin_smithdon't tell anyone
13:56sdegutisdon't worry it just shows up as ******* to everyone else
13:57sdegutisonly I can see it cuz soulmates
13:57rhg135I thought it'd be justin
13:57sdegutisAh crap, I didn't realize the reader-macro thing means I can't use it in a helper function.
13:57rhg135Or your bod
13:57rhg135Dob*
13:57sdegutisrhg135: its from a website that had quotes from IRC, its before your time, see IRC was Slack back before there was Slack
13:58rhg135sdegutis: tempid is a function
13:58sdegutisah right then I'll just keep using (tempid)
13:58sdegutisthanks
13:58rhg135Np
13:59sdegutisDatomic has changed so much in the last 2.5 years, I need to restructure all my code now to take full advantage of all the new awesomeness.
14:00sdegutisMost (if not all) of my helper functions are completely obsoleted by new Datomic features.
14:00sdegutis(Although not really "new" anymore.)
14:00rhg135I didn't use datomic till last year
14:01rhg135I feel like I wasted my mind's db budget
14:06en590,(def a (fn [] (str "hey"))
14:06clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
14:07en590,((fn [] ("hi")))
14:07clojurebot#error {\n :cause "java.lang.String cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval47$fn__48 invoke "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval47$fn__48 invoke "NO_SOURCE_FILE" 0]\n [sandbox$eval47 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval47 invoke "NO_SOURCE_FILE...
14:07en590why does this not work and I have to put str before the "hi" ?
14:07en590is it trying to use "hi" as the function
14:07akabanderBecause there's no function named "hi"
14:08en590what if I just wanted to return "hi"
14:08philth-irssiremove the parens
14:08philth-irssi,((fn [] "hi"))
14:08clojurebot"hi"
14:08philth-irssiyou can't call a string.
14:09philth-irssistr is a function you can call, with the arg "hi".
14:09philth-irssiwhich return "hi"
14:09en590yeah thank you
14:09justin_smithen590: the misunderstanding here might have been what parens do
14:09justin_smithin most languages they group things, in clojure they invoke things
14:09en590yah i get it know i think, first element in parens is the function
14:09justin_smithright
14:09philth-irssi(inc justin_smith)
14:09lazybot⇒ 289
14:10justin_smithor a macro, or special form - something you can invoke at least
14:10snowelllazybot is back!
14:10spiedenis there a command line nrepl client with fast startup? (non-jvm)
14:11spiedenthought maybe that's how gretch worked but now i can't find it -- maybe spelling wrong
14:11justin_smithspieden: grench
14:11spiedenah!
14:11spiedengratsi
14:11justin_smithnp
14:15en590clojure is like a dream language
14:15en590u dont even had to do math you just inc stuff
14:16en590,(inc (inc 0))
14:16clojurebot2
14:16justin_smith,(nth (iterate inc 0) 1000000)
14:16clojurebot1000000
14:17luxbockI'm writing a library that wraps a native library via JNA, and to safeguard myself from segfaults I'm keeping track of the state of the native library in an atom, so that my functions can throw if they get passed arguments that are in conflict with the state
14:17en590is that lazy iteration or whatever?
14:17luxbocknow stylistically, I'm wondering if I should create a record for the library, where the field points to the atom
14:17justin_smithen590: iterate generates a lazy seq of repeated calls to the first arg, with the second arg as the first input
14:18luxbockor if my CLJ side API functions should just be referring to the atom itself
14:18en590,(nth (iterate dec 0) 100)
14:18clojurebot-100
14:18luxbocklike on one hand it feels right that functions that need to make calls to the library should take something (i.e. the record) as their arguments
14:18luxbockbut on the other hand it feels a bit silly to have a record that can only ever be instantiated once
14:19en590,(iterate dec 0)
14:19clojurebot(0 -1 -2 -3 -4 ...)
14:19en590ok i get it
14:20en590(iterate count (iterate inc 0))
14:20en590,(iterate count (iterate inc 0))
14:20clojurebot#<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>
14:20en590haha get heaped java
14:20justin_smithen590: a fun example from the other day ##(iterate #(apply map list %) '((a b)(c d)(e f)))
14:20lazybotExecution Timed Out!
14:20justin_smithhrm
14:21justin_smith,(iterate #(apply map list %) '((a b)(c d)(e f)))
14:21clojurebot(((a b) (c d) (e f)) ((a c e) (b d f)) ((a b) (c d) (e f)) ((a c e) (b d f)) ((a b) (c d) (e f)) ...)
14:23en590wow apply and map in the same function
14:23en590i cant handle that
14:24rhg135You soon will
14:25bja(partial apply ....) is another good one
14:25en590so i'm applying a mapping of the list of the argument in the code above?
14:26bjayou're taking in a sequence of things you want to turn into a sequence of lists
14:27bjamap is will take from multiple sequences at a higher arity
14:27en590so map does the (a b)(c d)(e f) part and apply does the(a c e)(b d f) part?
14:28bjaso stuff like `(map list (range 3) (range 3))` => '((0 0) (1 1) (2 2))
14:28bjayeah
14:28en590,(map '(1 2 3) '(1 2 3))
14:29clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn>
14:29en590,(map list( '(1 2 3) ) '(1 2 3))
14:29bja(map f [a1 b1] [a2 b2] [c1 c2]) gives you '((f a1 b1 c1) (f a2 b2 c2))
14:29clojurebot#error {\n :cause "clojure.lang.PersistentList cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentList cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval49 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval49 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval49 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler ...
14:29justin_smithen590: you almost had it, too many parens though
14:29bja,(map list (range 3) (range 3))
14:29clojurebot((0 0) (1 1) (2 2))
14:30justin_smith,(map list '(1 2 3) '(1 2 3)) ; en590
14:30clojurebot((1 1) (2 2) (3 3))
14:30en590oh map takes its first argument as another function without any parens ok neat
14:31en590,(apply list '(1 2 3) '(1 2 3))
14:31clojurebot((1 2 3) 1 2 3)
14:31bjayeah, map just takes a fn, either one that already exists on one that you specify inline via (fn ...) or #(...)
14:31sdegutisrhg135: datomic is excessively cool
14:32sdegutisen590: the fundamental rule of all lisp syntax is dead simple: a(b,c,d) = (a b c d), that's it
14:32sdegutisen590: now you fully understand all of lisp.
14:32sdegutiseverything else about lisp is identical to javascript.
14:33en590,(inc 1)
14:33clojurebot2
14:33en590,(inc(1))
14:33clojurebot#error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval169 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval169 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval169 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 69...
14:34sdegutisen590: (1) is the same as 1() in another language, which makes no sense
14:34sdegutisen590: do you understand that?
14:34akabanderTrying to invoke a literal again?
14:34en590yes i get it now
14:34sdegutisawesome
14:34sdegutisim not joking, thats literally all there is to understanding lisp
14:34akabander(map inc '(1 2 3))
14:35akabander,(map inc '(1 2 3))
14:35clojurebot(2 3 4)
14:35en590,(map list '(1 2 3) '(1 2 3)) ;ok i dont quite get this one
14:35clojurebot((1 1) (2 2) (3 3))
14:36en590i understand map with one function argument and one data argument
14:36en590but not with one function argument and two data arguments
14:36justin_smithen590: with two or more lists, the function will get two or more args
14:36akabanderWith multiple collections, map invokes fn with each element of each list as arguments.
14:36sdegutisen590: two data arguments acts like a list-comprehension in python/haskell
14:36sdegutisen590: it'll do (list 1 1) then (list 2 2) etc
14:36akabander,(map vec '(1 2 3 4) '("a" "b" "c" "d"))
14:36clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/vec>
14:36sdegutis,(map vector [1 2 3] [:a :b :c])
14:36clojurebot([1 :a] [2 :b] [3 :c])
14:37akabanderYeah, thanks
14:37sdegutisthat should demonstrate it a little clearer
14:37akabanderThat's what I was going for :)
14:37sdegutisakabander: oh sorry I didn't mean clearer than what you said
14:37sdegutisI meant clearer than '(1 2 3) '(1 2 3)
14:37akabanderClearer or not, yours ran :)
14:37sdegutis:P
14:38sdegutisI often get vec and vector mixed up in #clojure
14:38akabanderWe were both shooting for the same thing, you just aimed better.
14:38sdegutisBecause in production code I more often use (->> ... (vec))
14:38en590,(map + '(1 2 3) '(1 2 3))
14:38clojurebot(2 4 6)
14:38sdegutisSo it's a habit to go for that one.
14:38akabander(Is it too obvious I'm American? :)
14:38sdegutisakabander: haha is it that I am?
14:38en590,(apply vector [1 2 3] [:a :b :c])
14:38clojurebot[[1 2 3] :a :b :c]
14:38sdegutishold on let me finish my red bull then ill ask again
14:38sdegutisen590: apply is different, I try to avoid it as much as possible
14:38akabanderNext I'll use a football metaphor
14:39en590so apply does the entire first argument to the entire second ?
14:39sdegutisI wonder...
14:39akabanderYeah, I think of apply as "unlisting" the arguments
14:39justin_smithen590: apply takes any number of args and the last must be a collection
14:39sdegutis,(reduce str ["this " "is " "a " "sentence."])
14:39clojurebot"this is a sentence."
14:39sdegutishaha!
14:39justin_smithen590: the first arg is used as a function, the rest are taken as args, with every element of the final collection appended
14:40sdegutisThe only time I've ever needed apply in production code is for (apply = [...])
14:40sdegutisWhich is totally cheating but meh.
14:40justin_smith,(apply str "hello" [", " "world"])
14:40clojurebot"hello, world"
14:40sdegutis(I consider any Clojure code that can't be done just as simply in Haskell to be cheating.)
14:40justin_smithsdegutis: I use apply when I know what the first arg will be, and want to build a collection for the rest of the args
14:41sdegutisjustin_smith: got concrete example?
14:41irctchello everyone!
14:41justin_smithgeneralize "first" to "first N" actually
14:41clojurebotGabh mo leithscéal?
14:41sdegutisI've used (apply concat ...) a few times, sadly.
14:41irctci have an issue and i was wondering if anyone had a few minutes to help?
14:41oddcullyirctc: please go ahead
14:41en590,(apply + "one plus one is " (+ 1 1))
14:41clojurebot#error {\n :cause "Don't know how to create ISeq from: java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: java.lang.Long"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.lang.RT cons "RT.java" 655]\n [clojure.core$cons__4090 in...
14:41sdegutisirctc: you'd have way better chances if you just ask without asking to ask
14:41sdegutisirctc: otherwise we're likely to say "no" or something, when otherwise we would have just answered
14:42justin_smithsdegutis: anywhere where I would otherwise use partial, but it's an operation I am only doing once, so I just use apply instead
14:42sdegutisjustin_smith: ahh interesting
14:42irctcthank you! so im having an issue compiling uberjars using leiningen v 2.5.1
14:42justin_smithen590: + does not work on strings in clojure
14:42sdegutisHmm. I'm using Lein 2.5.2
14:42sdegutisWorks fine for me. Upgrade I guess.
14:42sdegutisAlso try `lein clean`.
14:42irctcfor some reason, when i am using the 'lein run' command, all my dependancies are included properly
14:42oddcullyalso the last argument is no seq
14:42justin_smithen590: also the last arg to apply must be a collection
14:43en590is there a reason for that?
14:43akabander,(apply str "one plus one is " (+ 1 1))
14:43irctci have both profiles :debug and :uberjar the exact same
14:43clojurebot#error {\n :cause "Don't know how to create ISeq from: java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: java.lang.Long"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.lang.RT cons "RT.java" 655]\n [clojure.core$cons__4090 in...
14:43sdegutisjustin_smith: also, technically (apply str ...) is faster than (reduce str ...) because of magic.
14:43sdegutisI think amalloy_ taught me that.
14:43justin_smithsdegutis: not magic, StringBuilder :)
14:43irctcThere are some external jars that im including in my project that i suspect arent being added to the project
14:43sdegutisjustin_smith: that's technically magic, i.e. hidden optimizations
14:44en590,(str "hi " (str 5))
14:44clojurebot"hi 5"
14:44justin_smithen590: that's fine, but the last arg of apply must be a collection
14:44oddcully,(str "hi" 5)
14:44clojurebot"hi5"
14:44sdegutis,"hi5"
14:44clojurebot"hi5"
14:44sdegutismines shortest what i do i win
14:44justin_smith,(apply str "one plus one is" [(+ 1 1)]) ; en590
14:44clojurebot"one plus one is2"
14:44TEttinger,'hi5
14:44clojurebothi5
14:44irctcbut anywho, when i attempt to compile an uberjar and run the jar that was created, i get an ExceitionInInInitializerError
14:44irctcand its from a ClassNotFoundExceitpion
14:45irctca class that im attempting to use
14:45irctcbut if i use a normal 'lein run' it works perfect
14:45TEttingerirctc: interesting.
14:45TEttingerwhat's your project.clj like? can you put it on refheap?
14:45irctcor a 'lein with-profile uberjar run' it works as well
14:45justin_smithirctc: also, what is the specific class, that might be helpful as a clue
14:46irctcyea one moment
14:46en590,(apply + '(1 2 3) '(1 2 3))
14:46clojurebot#error {\n :cause "clojure.lang.PersistentList cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentList cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers add "Numbers.java" 128]}]\n :trace\n [[clojure.lang.Numbers add "Numbers.java" 128]\n [clojure.core$_PLUS_ invokeStatic "core.clj" 962]\n [clojure.core$_PLUS_ do...
14:46en590whoops
14:46TEttinger,map + '(1 2 3) '(1 2 3))
14:46clojurebot#object[clojure.core$map 0x57622de3 "clojure.core$map@57622de3"]
14:46en590,(apply + '(1 2 3) '(1 2 3)))
14:46clojurebot#error {\n :cause "clojure.lang.PersistentList cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentList cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers add "Numbers.java" 128]}]\n :trace\n [[clojure.lang.Numbers add "Numbers.java" 128]\n [clojure.core$_PLUS_ invokeStatic "core.clj" 962]\n [clojure.core$_PLUS_ do...
14:46TEttinger,(map + '(1 2 3) '(1 2 3))
14:46clojurebot(2 4 6)
14:46justin_smithen590: you can't use + on a list directly
14:46irctchttps://www.refheap.com/108683
14:46TEttingerapply takes only one collection too.
14:47sdegutisPop quiz. Given {:nums [1 1] :words {1 "one", 2 "two"}} derive the string "one plus one is two".
14:47en590,(apply + 5 '(1 2 3)))
14:47clojurebot11
14:47justin_smith,(apply map + [[1 2 3] [1 2 3]]) ; en590 compare this to what TEttinger did
14:47clojurebot(2 4 6)
14:47irctcSo its the RTAClient.jar that isnt getting added
14:47oddcullyor ,(apply + 1 '(2 3 4))
14:47TEttingerirctc: and this jar isn't available on clojars or maven central I imagine?
14:47irctcbut if i run the project using 'lein run' there are no issues and the libraries classes are accessable and do what they were designed to do
14:48irctcTEttinger: no its in house
14:48justin_smithirctc: I am suspicious about explicitly putting a jar on the classpath via :resource-paths - is this something you generally have success with in uberjars?
14:49irctcalso i found this, someone else seems to have had the same problem.
14:49irctchttp://stackoverflow.com/questions/31197792/leiningen-bug-in-producing-uberjars-or-misunderstanding
14:49en590,(apply map + [[1 2 3] [1 2 3]]) ;could you explain the steps this takes to work?
14:49clojurebot(2 4 6)
14:49justin_smithirctc: I think the best fix is to use maven or lein to "install" the jars to your local .m2 cache and then add to :dependencies
14:50irctcjustin_smith: It has worked so far. Im relatively new to clojure. Is there another way i should be including it?
14:50justin_smithirctc: the issue is combining this technique with uberjar, I am not confident that it's compatible
14:51irctcjustin_smith: So there is some technique within leiningen that allows you to "install" a jar into some directory that will allow you to have it be accessable across the entire system? If so, how would i go about doing that?
14:52TEttingeryep, that would be mvn install IIRC
14:52TEttingererr, jar hm.
14:52justin_smithirctc: yeah, lein-localrepo plugin does it
14:52justin_smithirctc: there is also a mvn command that will do it
14:52TEttingerhttps://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
14:52akabanderen590: I think (apply map + [[1 2 3] [1 2 3]]) is equivalent to (map + [1 2 3] [1 2 3])
14:53irctcjustin_smith: Thank you so much! ill give it a shot and if it doesnt work ill head back here and let you know how it goes.
14:53irctcTEttinger: thank you as well! ill look into this.
14:53TEttinger^ that's the mvn command btw, no problem
14:53akabanderBut I'm probably over-simplifying in my naivate
14:53justin_smithakabander: it is definitely 100% the same
14:54akabanderYay I got one! :)
14:54en590so whenever i apply a map i remove the outer layer of vector?
14:54TEttingerakabander: they're very similar. one has one more step it does of course, since it calls apply. but behavior is identical
14:54justin_smiththe only missing part is that (apply map + [1 2 3] [[1 2 3]]) is also the same - apply allows extra args preceding the final coll
14:55akabanderAh yes that detail is important, otherwise more complex things could be confusing!
14:56en590(reduce + '(1 2))
14:56TEttingeren590: apply takes a function and turns the last argument, which should be some kind of collection, from a collection to potentially multiple arguments to the function. like justin_smith is saying, you can have other args before the last one that also get passed to the function, unaltered
14:56en590,(reduce + '(1 2))
14:56clojurebot3
14:56oddcullyen590: for beginners it might be easer to grok the std case: (apply f [1 2 3]) - this does (f 1 2 3)
14:57TEttinger,(*)
14:57clojurebot1
14:57TEttinger,(apply * [])
14:57clojurebot1
14:57ely-seI should find a nice usecase for Clojure.
14:57ely-seWriting software applications for tracking contents of fridges is boring.
14:58justin_smith,(apply * nil)
14:58clojurebot1
14:58en590,(apply + '(1 2 3))
14:58clojurebot6
14:59en590,(map + '(1 2 3))
14:59clojurebot(1 2 3)
14:59oddcully,(+ 3)
14:59clojurebot3
14:59TEttingerely-se: probably something that would benefit from, say, futures, lots of data operations at once, maybe java interop too
14:59en590cool thank you oddcully
14:59en590and justin_smith
14:59en590and akabander
15:00en590and TEttinger
15:00snowellen590: apply will give you a value. map will give you a collection
15:00TEttingermap, apply, filter, and reduce are pretty central to daily clojure
15:00snowell,(map inc '(1 2 3))
15:00clojurebot(2 3 4)
15:01akabanderI am learning too; helping you teaches me. :)
15:01en590ah oddcully I see so mapping + to '(1 2 3) is just like list((+ 1) (+ 2) (+ 3))
15:02en590but the inc actually does something to each one
15:02justin_smithen590: move one paren over, but sure :)
15:02snowellWell the + does something too. It adds the value to nil ;)
15:02ely-seTEttinger: I'd use Go or Erlang or Haskell if I wanted to do concurrency.
15:02en590,(list (+ 1) (+ 2) (+ 3))
15:02clojurebot(1 2 3)
15:03oddcully,(+)
15:03clojurebot0
15:03oddcully,(+ 1)
15:03clojurebot1
15:03oddcully,(+ 1 2)
15:03clojurebot3
15:03en590(* nil nil)
15:03en590,(* nil nil)
15:03clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.NullPointerException\n :message nil\n :at [clojure.lang.Numbers ops "Numbers.java" 1013]}]\n :trace\n [[clojure.lang.Numbers ops "Numbers.java" 1013]\n [clojure.lang.Numbers multiply "Numbers.java" 148]\n [sandbox$eval145 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval145 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.j...
15:03justin_smithsnowell: it doesn't add to nil though
15:03en590,(+ 1 nil)
15:03clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.NullPointerException\n :message nil\n :at [clojure.lang.Numbers ops "Numbers.java" 1013]}]\n :trace\n [[clojure.lang.Numbers ops "Numbers.java" 1013]\n [clojure.lang.Numbers add "Numbers.java" 128]\n [clojure.lang.Numbers add "Numbers.java" 3640]\n [sandbox$eval169 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval169 invoke "NO_SOURCE_FILE" -...
15:03justin_smithit's just the arity of + for one arg
15:03snowellI thought I might get called on that
15:03justin_smithheh
15:03justin_smith,(+ :a)
15:03clojurebot#error {\n :cause "Cannot cast clojure.lang.Keyword to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "Cannot cast clojure.lang.Keyword to java.lang.Number"\n :at [java.lang.Class cast "Class.java" 3176]}]\n :trace\n [[java.lang.Class cast "Class.java" 3176]\n [clojure.core$cast invokeStatic "core.clj" 338]\n [clojure.core$_PLUS_ invokeStatic "core.clj" 952]\n [c...
15:03justin_smith:P
15:04snowell,(* 6)
15:04clojurebot6
15:04akabanderEly-se but what if you want good concurrency support and interop with other JVM languages? Please don't say "Scala".
15:04en590that multiplies 6 by 1
15:04oddcully,(*)
15:04clojurebot1
15:05en5901 is the idempotentiaionary value of the * operation
15:05justin_smith,(/ 6)
15:05clojurebot1/6
15:05justin_smithdivides 1 by 6
15:05snowellMy brain exploded when I saw that word. If that's a real word I'm using it every day from now on
15:05philth-irssi,(+)
15:05clojurebot0
15:05akabanderSpecifically 1 is the identity cofactor of the multiplication operation
15:05philth-irssi,(*)
15:05clojurebot1
15:05philth-irssi:D
15:06akabanderAnd 0 is the identity cofactor of the addition operation.
15:06en590(+ (+) (*) (*))
15:06en590,(+ (+) (*) (*))
15:06clojurebot2
15:06justin_smith,(> 0)
15:06clojurebottrue
15:06en590lol
15:07akabander,(< 0)
15:07clojurebottrue
15:07justin_smithen590: it answers the existential question "is 0 greater than?"
15:07oddcully(> 666)
15:07oddcully,(> 666)
15:07clojurebottrue
15:07justin_smith,(> :not-even-a-number)
15:07clojurebottrue
15:08justin_smithsilliness
15:08akabander"(> 0)"... "I'll take late 80s movies for $100, Alex"
15:08akabander"(< 0)"... "I'll take late 80s movies for $100, Alex"
15:08akabanderdarn, whiffed it
15:08oddcully,(= 42)
15:08clojurebottrue
15:08en590what the shit
15:08akabander,(== 42)
15:08clojurebottrue
15:09en590unconsionable
15:09philth-irssiWhoa
15:09TEttinger,(= Double/NaN)
15:09clojurebottrue
15:09TEttinger,(= Double/NaN Double/NaN)
15:09clojurebotfalse
15:09akabander,(source =)
15:09clojurebotSource not found\n
15:09oddcullyoh yeah! NaNs arviing. this will be fun
15:10akabanderBut if you look, the definition includes ([x] true)
15:10akabanderSo arity one is always true
15:11en590how do you prounounce arity irl
15:11en590air ity or are ity
15:11akabanderRhymes with parity
15:11TEttinger,(let [nan (/ 0.0 0.0)] [(= nan nan) (= nan (/ 0.0 0.0))])
15:11clojurebot[false false]
15:11philthair-it-tee
15:11TEttinger,(let [nan Double/NaN] [(= nan nan) (= nan (/ 0.0 0.0))])
15:11clojurebot[false false]
15:11TEttinger,(let [nan (identity Double/NaN)] [(= nan nan) (= nan (/ 0.0 0.0))])
15:11clojurebot[true false]
15:12TEttingerwho put that true here?
15:12akabanderBecause a always equals a... Read your Ayn Rand.
15:13opqdonutTEttinger: I'm intrigued
15:14TEttingeropqdonut: it's a quirk of = and NaN's non-equality-to-self
15:14TEttinger= does reference equality for objects, and identity returns a Double in this case
15:15TEttinger,(let [nan (identity Double/NaN)] [(= nan nan) (= nan (/ 0.0 0.0)) (== nan nan)])
15:15clojurebot[true false false]
15:15en590So clojure converts to java then runs in the jvm?
15:15en590is that why the error messages are so crazy
15:15TEttingeren590, not quite. it does run on the JVM
15:15TEttingerit generates the same format that java compiles to
15:15TEttinger.class files, what .jar files use
15:16akabander,(= Double/NaN Double/NaN)
15:16clojurebotfalse
15:16akabander,(let [nan Double/NaN] (= nan nan)
15:16clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
15:16akabander,(let [nan Double/NaN] (= nan nan))
15:16clojurebotfalse
15:16en590why do the error messages mention java.lang.Number and stuff
15:17TEttingerthe error messages are so crazy because yes, it's running between java-library-land, clojure-library-land, and your-clojure-code-land
15:17TEttinger,(type "hello!")
15:17clojurebotjava.lang.String
15:17TEttingerstrings are java strings and can be passed off to java no problem
15:17en590will they ever fix it so there are no more crazy java stuff
15:17TEttingerthat's clojurescript :)
15:17TEttingerit has crazy JS stuff instead
15:18en590yah was about to ask lol
15:18en590i much prefer javascript
15:18en590it is a much much smaller language right
15:18TEttinger...sorta
15:18en590mostly b/c java has tons of libraries ?
15:18TEttingerjavascript has a lot more oddities at the language level and cross-browser problems
15:18akabanderBut you're better of doing (map? my-thing) than (= (type {}) my-thing)
15:19en590yeah i like the javascript oddities
15:19oddcullyyou are the first one then
15:19TEttingeryep, if you know javascript you'd find clojurescript rather easy
15:19en590it's endearing
15:19en590javascript is like little brother who has to support entire internet
15:20TEttingeroddcully: heh I like the lua oddities myself. "aww how cute you don't have regexes you have your own little thing that thinks its a regex"
15:20oddcullyTEttinger: array start with index 1, because that is how we count!
15:20en590is clojurescript the exact same syntax as clojure?
15:20opqdonutTEttinger: ah, yeah
15:21snowellen590: It's not exact, but it's very similar
15:21en590it is a superset of clojure for dom stuff?
15:21TEttingerthere's a subset that works on both, that's cljx right?
15:22TEttingerit's sorta its own language, since it has a different runtime. I wouldn't say it's a superset or subset of JVM clojure
15:22snowellen590: Clojure: (println "foo"), Cljs: (.log js/console "Foo")
15:22snowellIt also introduces the wonderful mutability of native JS objects if you want it to
15:22snowellSpoiler alert: You really don't want it to
15:22TEttinger,(.println System/out "foo")
15:23clojurebotnil
15:23en590what do you mean mutablity of objects? cant you change them in vanilla js already?
15:23TEttinger,(.println System/err "foo")
15:23clojurebotnil
15:23TEttingerhm
15:23snowellTEttinger: I'm sure it's working; you're just getting the return values
15:23TEttingeren590: introduces to clojure. clojure has mutable Java objects
15:24oddcully,(doto (java.util.HashMap.) (.put "a" 1))
15:24clojurebot{"a" 1}
15:24en590why does clojure still allow java crap to be used?
15:24TEttingerthey're harder to access unintentionally in JVM clojure I think
15:25TEttingerbecause there are a ton of java libs
15:25TEttingerand java still performs better on certain tasks by a large margin
15:25TEttinger(for loops on multi-dimensional arrays come to mind)
15:25en590oh so kind of like using c in certain parts of python programs?
15:26TEttingeryeah, if C had a library for pretty much everything
15:26en590haha
15:26snowellen590: Being able to interact with java systems is not a small thing
15:26TEttingerpdfs? there are several java pdf libs, just call into one of those like you're writing java or use/make a wrapper
15:26akabanderIf it wasn't for the easy Java interop, I wouldn't have been able to justify Clojure to management.
15:27snowell+1 on that, akabander
15:27snowellSame with Clojurescript and JS interop
15:27TEttingerwriting a pdf lib is not a small task, that's something you reallllllly want a lib for if you need it!
15:27en590_sorry i d/c
15:28TEttingerhey again
15:28TEttingerthe main reason you want java interop or JS interop is to avoid rewriting non-trivial existing code
15:29wasamasapracticality trumps idealism
15:29TEttingerwe're coders, we need to be practical to get stuff done :)
15:29akabanderYou can always write "pure clojure" if you really want to.
15:32en590_yes this makes perfect sense
15:33en590_it also allows portions of existing java code to slowly be ported to clojure?
15:33en590_or is a complete rewrite generally done
15:33TEttingermore commonly, you write a wrapper
15:33TEttingerlike seesaw is a good example
15:34en590_what is a wrapper
15:34TEttingerSwing is a massive part of the java standard lib. it's unpleasant to use from java, much less clojure. https://github.com/daveray/seesaw Seesaw makes it very nice to use from clojure, all the hard work is done
15:35sdegutisjustin_smith: thanks 4 all ur help in here btw all these years
15:36TEttingerseesaw makes it so you don't need the crazy anonymous inner class stuff that the java lib expects for things like event handling. you pass a clojure function and it turns it into what the java expects
15:36TEttingerit also adds features that swing doesn't have, like selectors to access classes like they're HTML divs with ids and classes
15:36TEttinger*to access widgets
15:36sdegutisSpeaking of which, how is tbaldridge's port of Clojure going?
15:37TEttingerpixie? I think it's past the port stage :)
15:38en590_ok thanks for the explanation TEttinger
15:38sdegutisTEttinger: meaning it's stable or it's nothing like clojure?
15:40TEttingersdegutis: I don't think it's considered stable yet but is definitely starting to move away from direct port stuff (lib is built around transducers from the start, IIRC)
15:40sdegutisoh nice
15:40sdegutisi'd love to use that for scripting since fast startup
15:41TEttingerI should really get back to my Lua Clojure-like idea
15:42akabanderAnyone have experience creating "isomorphic" libs for Clojure/Clojurescript?
15:43TEttingerthere's only a handful of properties that I wish clojure had now and doesn't, and "lightning fast startup time" is totally something that should be feasible on a scripting language VM
15:43wasamasawhat would that even mean?
15:43wasamasacljc?
15:43TEttingercljx?
15:43akabanderI don't know what it would look like, I think I saw a project that claims to be a module that can be used by both Clojure and Clojurescript transparently.
15:44TEttingeryeah, that's one of the things that's become easier with 1.7
15:44wasamasahttp://dev.clojure.org/display/design/Reader+Conditionals
15:44en590_shouldn't cljs be the exact same as clojure but minus the java stuff and plus the javascript stuff?
15:44wasamasain an ideal world
15:44oddcullyTEttinger: there is (was) cljsscript-lua - i tried that some time ago and it did not work
15:45oddcullyTEttinger: something salvageable there?
15:45wasamasaen590_: in reality there's a number of differences
15:45TEttingermaybe! I was going to try using LuaJIT-lang-toolkit
15:45wasamasaen590_: like, it not really having a character type
15:45TEttingerhttps://github.com/franko/luajit-lang-toolkit/
15:45akabanderwasamasa: I think that's where I should start looking, thanks
15:46wasamasaakabander: cljx is a community project, cljc files are the official variant supported in newer clojure releases
15:46TEttingeroddcully: this one? https://github.com/raph-amiard/clojurescript-lua
15:47TEttingerah, thanks wasamasa I wasn't clear
15:47oddcullyTEttinger: i ask, because in some (long time not touched sadly) game stuff i have lua used alot. and the only "repl"-like fealing i had then was beeing able to have glsl shaders to reload
15:47akabandercljc yields some interesting results... Church of the Lord Jesus Christ is probably not what I'm looking for.
15:47wasamasaakabander: it is shown in the page I've linked
15:47oddcullyTEttinger: yet seeing the e.g. the grimrock editor had my hopes up, that reloading lua stuff would work too quite reasonable
15:47akabanderI saw it, just looking around and got a chuckle from the results.
15:48TEttingeroddcully: huh, I actually didn't get to the repl part when I worked on my stuff in lua, I could eval lisp strings from lua
15:49TEttingerit was uh fast with luajit, despite a really bad interpreter that I screwed up all by myself :)
15:57bearjack,(try (+ "1 2 3") (catch Exception e (.getMessage e)))
15:57clojurebotbearjack: I don't understand.
15:57bearjackIs anyone up on the magic behind catch?
15:58bearjackI'm just working through simple cases, but when I try to catch an exception for casting one type to another, no problem.
15:58kwladykabearjack, http://clojuredocs.org/clojure.core/catch ?
15:59kwladykai mean what is your problem exactly?
16:00bearjackI'm trying to send emails. And I'm testing the exception catching on a machine with no sendmail. So I'm getting a nullpointerexception, but no message returned.
16:00bearjackEven though when I do it in the repl there's a message
16:00bearjackNullPointerException java.lang.ProcessBuilder.start (ProcessBuilder.java:1010)
16:00bearjackI'm just confused by what gets caught and what doesn't.
16:01kwladykabearjack, *testing - do you mean clojure.test or manual try use it?
16:01bearjackkwladyka, manually trying to use it in the repl
16:03kwladykabearjack, .getMessage is from Java ( http://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html ) so it works the same like in Java
16:03kwladykai am not it is helping you :)
16:04irctchello again!
16:04bearjackI don't know much about java, I was hoping to avoid it. oh well, thanks :)
16:06irctconce you have used 'lein localrepo' to create a new entry with the jars you want included, how do you tell leiningen to search your local maven? it seems to only be search ing on central and clojuars
16:07bearjackirctc, did you use install? that should put it in your local .m2
16:07irctcif i run a 'lein localrepo list' i can see that the items have been added
16:07akabanderexit
16:07irctcbearjack: yes i did
16:07bearjackwhat are you trying to achieve?
16:08justin_smithirctc: it will always check your local cache first
16:09irctcbearjack: i have some local jars that i need to include into my project. before when i added them within :resource-paths, my application worked properly when i did a 'lein run' but when i attempted to create an uberjar, it would state that some dependancies were missing.
16:09irctcheres what my project.clj looks like now
16:09irctchttps://www.refheap.com/108686
16:10irctci added RTAClient, log4j, and spread using 'lein localrepo install'
16:12irctcjustin_smith: any ideas? im getting an error that states "could not find artifiact in"
16:13irctcjustin_smith: is there some particular directory i should be running the install within? i did it from within my project root.
16:15justin_smithirctc: you just need to make sure the install can see the jar you want installed
16:16irctcjustin_smith: what do you mean by the install? and how can i go about doing that?
16:16justin_smithirctc: the command that puts it in your local repo
16:17justin_smithwhether that's lein localrepo or mvn install or whatever
16:17irctcso i did that
16:17irctcbut its saying that it cant be found
16:17justin_smithirctc: if you follow a file path mirroring your group/artifact do you find the jar?
16:18irctccan i print out the path somehow using localrepo?
16:18justin_smithirctc: yes, but it's also a simple transform
16:18irctcjustin_smith: no idea how to go about doing that
16:19justin_smitheg. clojure1.7.jar gets put in .m2/repository/org/clojure/clojure/1.7/clojure-1.7.jar
16:19justin_smithsince the org/artifact is org.clojure/clojure
16:20irctcdoes .m2 live within the project root repo?
16:20irctcor within ~/.lein?
16:20justin_smithit is in ~
16:20kwladykasomebody know any really good example of using macro? example from real world
16:21kwladykai am talking about practical use not technical side
16:22irctcyes it is! figured it out though. i guess it was a simple spelling error -_-
16:22irctcnow its time to test if an uberjar gets compiled properly
16:22bearjackirctc, good show! that's how I solve all my problems
16:23irctcYES
16:23irctckilled it
16:23irctcthank you justin_smith. you are a bro
16:24snowell(inc justin_smith) ; Being a bro
16:24lazybot⇒ 290
16:26kwladykasnowell, in that way i should do something like (def justin_smith (+ 100 justin_smith)) ;)
16:27snowellMost of the times he's helped me lazybot has been dead, so I owe him a few myself
16:29w33tjust btw, this is irctc. gonna stick around for a little while.
16:31TEttingerw33t: heh, I guessed it was you from the github username in your project.clj
16:32TEttingerkwladyka: a good one is when you have ugly interop and don't want to write it by hand.
16:33w33tTEttinger: Yea i really need to get better at hiding my identity. And the user im logged into as on this machine gives you my full name too... im really bad at this whole anonymous thing.
16:34TEttingerkwladyka: https://github.com/daveray/seesaw/blob/develop/src/seesaw/event.clj#L30-L32
16:44kwladykaTEttinger, so when i want use mix of Java and Clojure and it looks like a monster? :)
16:49TEttingerkwladyka, that's a definite improvement when you use it though
16:50TEttingerthe mapcat in the highlighted section and the ~@ before it means you just saved a ton of manual typing :)
16:55sdegutisgit is one of those things that does its job and does it well and just keeps silently getting better in the background
17:27sh10151Any enlive users here? I'm trying to learn it and I can't figure out how to simplify this repetitive code: http://pastebin.com/edFbc4FH
17:27sh10151Basically I have an html "data-key" attribute that I want to match a key in a Clojure map supplying the dynamic data to render
17:28sh10151Seems like there should be a way to generate selector/transformation pairs and apply them all at once without hardcoding specific html attribute names
17:43en590hi what is the difference between ["a" "b" "c"] and [:a :b :c] ?
17:44oddcully"a" is a string, :a is a keyword
17:44sdegutis,(:a 2)
17:44clojurebotnil
17:44sdegutishaha silly clojure
17:44en590what are keywords used for in vectors or lists
17:44oddcully,(name :a)
17:44clojurebot"a"
17:44hiredmanhttp://clojure.org/data_structures#Data%20Structures-Keywords
17:45sdegutis,({:a 2} (:a 2))
17:45clojurebotnil
17:45oddcullykeywords are used as keywords. using it in a vector like this has no relevance
17:45oddcullybut keywords can be applied like functions on maps ,(:a {:a 1})
17:46en590ok thank you
18:01sdegutis,((:a 2) {:a 2} (:a 2))
18:01clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.NullPointerException\n :message nil\n :at [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6943]\n [clojure.lang.Compiler eval "Compiler.java" 6906]\n [clojure.core$eval invokeStatic "core...
18:01sdegutiswait what
18:03sdegutis,(:a {:b 2} 3)
18:03clojurebot3
18:03sdegutis,(:a {:b 2} nil)
18:03clojurebotnil
18:03sdegutis,(nil {:b 2} nil)
18:03clojurebot#error {\n :cause "Can't call nil"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.IllegalArgumentException\n :message "Can't call nil"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6876]}]\n :t...
18:03sdegutiswhat??
18:03sdegutis,(nil {:b 2})
18:03clojurebot#error {\n :cause "Can't call nil"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.IllegalArgumentException\n :message "Can't call nil"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6876]}]\n :t...
18:03sdegutisoh
18:03sdegutishahahahaha
18:04lazybotsdegutis: What are you, crazy? Of course not!
18:04sdegutislazybot: LAZYBOT< YOURE ALIVE!!!
18:04sdegutisITS REALLY YOU!!
18:07dxlr8rman, back to python for scripting some stuff. feels like going back to the stone age :/
18:16uptowntheir stupid tricks are worse than our stupid tricks
18:21justin_smithuptown: the real question is which programming community has the best stupid tricks - my bet is on assembler
18:22justin_smiththe difference is, when you are programming assembler, "stupid tricks" are also known as "programming"
18:22xemdetiaflat memory model! tricks your boss will /hate/!
18:22justin_smithhaha
18:25uptownof course, but it's messy down there by definition
18:26eriktjacobsenor extremely clean :) Always know where every byte of memory is and exactly what instructions are running. Higher level is way messier in that respect. Simple loop might end up invoking thousands of objects and silly subroutines
18:27eriktjacobsenThere is some comfort in having basically 100% confidence (assuming you understand your system calls) of whats going on
18:29sdegutisWe are now fully upgraded for Datomic in Production and get to use all the fun new features <3
18:30xemdetiaeriktjacobsen, I think my favourite thing is going through java trace files
18:31xemdetiaor finding a jvm stacktrace cut off after 200 lines with 160 trimmed
18:32uptowneriktjacobsen: sure, but you only use that perfect knowledge to start abstracting away messy details so you can write in peace
19:12{blake}What controls which lein profile is used?
19:13{blake}Ooh. lein/default, huh...
19:17en590Hi is it correct to think about maps and sets as unordered, and vectors and lists as ordered?
19:17jsonp__unless you're using an ordered set ;)
19:17{blake}en590: Yes. Although there are ordered versions of set.
19:20en590thank you
19:31en590what does \a mean for example
19:31amalloy&(class \a)
19:31lazybot⇒ java.lang.Character
19:31justin_smith,(set "hello")
19:31clojurebot#{\e \h \l \o}
19:32en590neat
19:32en590,(hash-map "hello")
19:32clojurebot#error {\n :cause "No value supplied for key: hello"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No value supplied for key: hello"\n :at [clojure.lang.PersistentHashMap create "PersistentHashMap.java" 77]}]\n :trace\n [[clojure.lang.PersistentHashMap create "PersistentHashMap.java" 77]\n [clojure.core$hash_map invokeStatic "core.clj" 374]\n [clojure.core$hash_map doInvoke...
19:32en590,(hash-map "hello" "ok")
19:32clojurebot{"hello" "ok"}
19:33en590,("hello" {"hello" "ok"})
19:33clojurebot#error {\n :cause "java.lang.String cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval97 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval97 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval97 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6...
19:33en590,(:hello {:hello "ok"})
19:33clojurebot"ok"
19:33justin_smithen590: the special syntax where :key can act as a function is a special thing about :keywords
19:34justin_smithen590: the compiler always starts with what's in the calling position to figure out what to do - so even though the arg is a hash-map that doesn't make the string do a lookup
19:34justin_smith,(ifn? :OK)
19:34clojurebottrue
19:34justin_smith,(ifn? "OK")
19:34clojurebotfalse
19:35justin_smiththat's the difference - one follows the function interface, the other does not
19:35en590,(let [:a #(+ 1 1)] (:a)
19:35clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
19:35en590,(let [:a #(+ 1 1)] (:a))
19:35clojurebot#error {\n :cause "Unsupported binding key: :a"\n :via\n [{:type java.lang.Exception\n :message "Unsupported binding key: :a"\n :at [clojure.core$destructure invokeStatic "core.clj" 4300]}]\n :trace\n [[clojure.core$destructure invokeStatic "core.clj" 4300]\n [clojure.core$let invokeStatic "core.clj" 4312]\n [clojure.core$let doInvoke "core.clj" -1]\n [clojure.lang.RestFn invoke "RestFn.jav...
19:36en590,(let [:a (#(+ 1 1))] (:a))
19:36clojurebot#error {\n :cause "Unsupported binding key: :a"\n :via\n [{:type java.lang.Exception\n :message "Unsupported binding key: :a"\n :at [clojure.core$destructure invokeStatic "core.clj" 4300]}]\n :trace\n [[clojure.core$destructure invokeStatic "core.clj" 4300]\n [clojure.core$let invokeStatic "core.clj" 4312]\n [clojure.core$let doInvoke "core.clj" -1]\n [clojure.lang.RestFn invoke "RestFn.jav...
19:37en590,(let [:a 2] (:a))
19:37clojurebot#error {\n :cause "Unsupported binding key: :a"\n :via\n [{:type java.lang.Exception\n :message "Unsupported binding key: :a"\n :at [clojure.core$destructure invokeStatic "core.clj" 4300]}]\n :trace\n [[clojure.core$destructure invokeStatic "core.clj" 4300]\n [clojure.core$let invokeStatic "core.clj" 4312]\n [clojure.core$let doInvoke "core.clj" -1]\n [clojure.lang.RestFn invoke "RestFn.jav...
19:38en590,(let ["a" 2] (:a))
19:38clojurebot#error {\n :cause "Unsupported binding form: a"\n :via\n [{:type java.lang.Exception\n :message "Unsupported binding form: a"\n :at [clojure.core$destructure$pb__4924 invoke "core.clj" 4291]}]\n :trace\n [[clojure.core$destructure$pb__4924 invoke "core.clj" 4291]\n [clojure.core$destructure$process_entry__4940 invoke "core.clj" 4297]\n [clojure.core$reduce1 invokeStatic "core.clj" 912]\n [c...
19:38en590,(let [a 2] (:a))
19:38clojurebot#error {\n :cause "Wrong number of args passed to keyword: :a"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Wrong number of args passed to keyword: :a"\n :at [clojure.lang.Keyword throwArity "Keyword.java" 97]}]\n :trace\n [[clojure.lang.Keyword throwArity "Keyword.java" 97]\n [clojure.lang.Keyword invoke "Keyword.java" 110]\n [sandbox$eval303 invokeStatic "NO_SOURCE_FILE"...
19:38en590,(let [a 2] a)
19:38clojurebot2
19:38en590yay
19:39en590,(let [:a 2] :a)
19:39clojurebot#error {\n :cause "Unsupported binding key: :a"\n :via\n [{:type java.lang.Exception\n :message "Unsupported binding key: :a"\n :at [clojure.core$destructure invokeStatic "core.clj" 4300]}]\n :trace\n [[clojure.core$destructure invokeStatic "core.clj" 4300]\n [clojure.core$let invokeStatic "core.clj" 4312]\n [clojure.core$let doInvoke "core.clj" -1]\n [clojure.lang.RestFn invoke "RestFn.jav...
19:39en590hmm why doesn't this work?
19:42amalloyen590: only symbols can be bound to values
19:42amalloyit's like (let [5 2] 5) - 5 is a value, not a name
19:43amalloylikewise :a
19:43en590how are keywords values and not names?
19:44amalloywell. most stuff in clojure is values
19:45amalloysymbols are values too, but constructs like let and fn allow you to use them as names for locals
19:46en590ok neat thank you
21:13neoncontrailsI'm curious... why is set/union so much slower than brute force in this case? http://pastebin.com/NEZ94hsY
21:13en590Hi how do I use seq to check if array is not empty?
21:13en590,(every? seq '(1 2 3))
21:14clojurebot#error {\n :cause "Don't know how to create ISeq from: java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: java.lang.Long"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.core$seq__4116 invokeStatic "core.clj" 137]\n [clojure.co...
21:15merl1n,(seq '(1 2 3))
21:15clojurebot(1 2 3)
21:15merl1n,(seq '())
21:15clojurebotnil
21:15merl1n(I have no idea what I am doing btw)
21:15neoncontrails(some? (seq? '(1 2 3)))
21:15neoncontrails,(some? (seq? '(1 2 3)))
21:15clojurebottrue
21:15en590I read that seq is how you test if collection is not empty
21:17neoncontrailswhoops, I made a typo
21:17neoncontrails,(some? (seq '(1 2 3))
21:17clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
21:17neoncontrails,(some? (seq '(1 2 3)))
21:17clojurebottrue
21:18justin_smith,(some? :anything)
21:18clojurebottrue
21:18justin_smith,(some? even (range))
21:18clojurebot#error {\n :cause "Unable to resolve symbol: even in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: even 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: even in this co...
21:18justin_smith,(some? even? (range))
21:18clojurebot#error {\n :cause "Wrong number of args (2) passed to: core/some?"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (2) passed to: core/some?"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 36]\n [sandbox$eval214 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval21...
21:18justin_smithnever mind
21:18justin_smith,(some even? (range))
21:18clojurebottrue
21:19justin_smiththat's what I had it confused with
21:22neoncontrailsStill curious why brute force is significantly more efficient than set/union here... can anyone explain? http://pastebin.com/NEZ94hsY
21:22en590how do i check if collection is not empty?
21:22justin_smith,(boolean (not-empty ""))
21:22clojurebotfalse
21:22justin_smith,(boolean (not-empty "a"))
21:22clojurebottrue
21:22neoncontrailsalso (some? [coll])
21:23surtn,(seq "")
21:23clojurebotnil
21:23surtn,(seq {})
21:23clojurebotnil
21:24en590ah so if i convert anything that's not empty or nil into boolean value...it comes back true?
21:24en590,(boolean 5)
21:24clojurebottrue
21:24en590,(boolean '())
21:24clojurebottrue
21:24en590=(
21:24justin_smithen590: that's why I used not-empty
21:24justin_smith,(boolean (not-empty ()))
21:24clojurebotfalse
21:25en590(not-empty '())
21:25en590,(not-empty '())
21:25clojurebotnil
21:26surtnyou genearally don't need to force things to booleans - lots of those functions (like not-empty or seq), return nil or truthy values
21:26neoncontrails@en590 I'm just a clojure n00b, but I think (some? [coll]) is a better predicate for that
21:26neoncontrails,(some? '())
21:26clojurebottrue
21:26justin_smith,(some? ())
21:26clojurebottrue
21:26neoncontrailsoh wait
21:26justin_smithneoncontrails: which is not what you want :)
21:26neoncontrailsno, nevermind, that's terrible
21:26neoncontrailshaha yes. Good call ;)
21:26en590,(true? '())
21:26clojurebotfalse
21:26justin_smith,(some? [])
21:26clojurebottrue
21:26en590,(false? '())
21:26clojurebotfalse
21:27justin_smithso you definitely want not-empty, and maybe the explicit boolean cast too
21:27neoncontrailsTIL. Thanks!
21:27justin_smithseq has the same consequences, but if what I am testing for is non-emptiness I find that not-empty is quite explicit about that
21:27en590,(boolean (boolean( not-empty ( '())))
21:27clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
21:28en590,(boolean (boolean( not-empty ( '()))))
21:28clojurebot#error {\n :cause "clojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval263 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval263 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval263 invoke "NO_SOURCE_FILE" -1]\n ...
21:28justin_smithen590: too many () on that
21:28justin_smith,(boolean (not-empty ()))
21:28clojurebotfalse
21:28en590,(boolean (true))
21:28clojurebot#error {\n :cause "java.lang.Boolean cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Boolean cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval311 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval311 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval311 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.ja...
21:28justin_smithen590: remember () is not for grouping!
21:28justin_smithand true is not a function
21:29en590(boolean true)
21:29en590,(boolean true)
21:29clojurebottrue
21:29neoncontrailsSo wait. Follow up question: why (not-empty [seq]) instead of (empty? [seq])
21:29en590oh yeah thats right
21:29neoncontrails,(empty? '())
21:29clojurebottrue
21:29justin_smithneoncontrails: well if you wanted to test for the opposite condition, sure
21:29neoncontrailsIt seems like the explicit boolean cast would be useful usually, wouldn't it?
21:30justin_smiththough I guess (not (empty? x)) might be better then (boolean (not-empty x))
21:30en590,(not-empty [1 2 3])
21:30clojurebot[1 2 3]
21:30neoncontrails(and closer to idiomatic scheme/lisp too in my experience, for what it's worth)
21:30en590according to the website it says use seq for the opposite of empty?
21:31en590but that isn't explicit and seems like shit
21:31en590'Please use the idiom (seq x) rather than (not (empty? x))'
21:32en590,(seq [1 2 3])
21:32clojurebot(1 2 3)
21:32neoncontrailsThat's extremely interesting. There must be a reason why (seq x) is preferred, but I don't see one
21:32merl1n,(not (empty? [1 2 3]))
21:32clojurebottrue
21:33en590why isn't there a not-empty?
21:33merl1nhmm, how is that the same?
21:33merl1n(empty? [1 2 3])
21:33merl1n,(empty? [1 2 3])
21:33clojurebotfalse
21:34surtnneoncontrails: it's so you can use it once you determine it's not empty
21:34surtn,(when-let [stuff [1 2 3]] (reduce + stuff))
21:34clojurebot6
21:34surtn,(when-let [stuff []] (reduce + stuff))
21:34clojurebot0
21:34merl1nhow is seq opposite of empty when it doesn't return boolean
21:35neoncontrailsI think this might be a lispy thing. You don't really need the opposite of a boolean predicate, you just (if [pred? seq] #true-case #false-case) to dispatch on the false case
21:36surtnseq isn't the opposite of empty? it's just you can use it for that type of thing. Idiom, for sure. There's more than one way to do it.
21:36neoncontrails(if (seq '()) 1 2))
21:37neoncontrails,(if (seq '()) 1 2))
21:37clojurebot2
21:37merl1n(not (empty? ..)) seems more readable though
21:37surtndepends what you're used to, I suppose
21:37en590sorryi dc
21:38surtn(not (empty? c)) will just return a boolean though - not very useful
21:38merl1nit is useful if that is what you need
21:38surtnok, sure, say you were writing a predicate function
21:39surtnwhy do you check a collection for emptiness though? often it's to do something with that collection.
21:40en590,(if (seq '()) "is true/not empty" "is false/empty, because seq returned nil")
21:40clojurebot"is false/empty, because seq returned nil"
21:41merl1n,(filter (comp not empty?) [[1 2] [] [3 4]])
21:41clojurebot([1 2] [3 4])
21:41en590,(if (seq '(1 2 3)) "is true/not empty" "is false/empty, because seq returned nil")
21:41clojurebot"is true/not empty"
21:42TEttinger,(filter seq [[1 2] [] [3 4]])
21:42clojurebot([1 2] [3 4])
21:43merl1nI think (comp not empty) conveys the intent better
21:43TEttinger,(filter seq [[1 2] 0 [3 4]]) ; fails too
21:43jeayeAgreed
21:43clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
21:43TEttinger,(filter (comp not emoty?) [[1 2] 0 [3 4]]) ; fails too
21:43clojurebot#error {\n :cause "Unable to resolve symbol: emoty? in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: emoty? 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: emoty? in t...
21:43neoncontrailsen590: okay got it. Contrast the following:
21:44TEttinger,(filter (comp not empty?) [[1 2] 0 [3 4]])
21:44clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
21:44TEttingerhm
21:44neoncontrails,((fn [x] (if (empty? x) (reduce + x))) [1 2 3])
21:44clojurebotnil
21:44neoncontrails,((fn [x] (if (empty? x) (reduce + x))) [])
21:44clojurebot0
21:44TEttingerinteresting
21:44neoncontrails,((fn [y] add1 [x] (if (seq x) (reduce + x))) [1 2 3])
21:45clojurebot#error {\n :cause "Unable to resolve symbol: add1 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: add1 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: add1 in this co...
21:45TEttinger,((fn [x] (if (empty? x) (reduce #(* %1 %2) x))) [])
21:45clojurebot#error {\n :cause "Wrong number of args (0) passed to: sandbox/eval51/fn--52/fn--53"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (0) passed to: sandbox/eval51/fn--52/fn--53"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 28]\n [clojure.lang.PersistentVector r...
21:45TEttingerneed parens around arg grounds, neoncontrails
21:45TEttingerarg groups
21:45neoncontrailsSorry, this is more confusing. I'll just give you the two defs and you can play with them
21:45neoncontrails(defn add1 [x] (if (empty? x) (reduce + x)))
21:46TEttinger,(defn add1 [x] (if (empty? x) (reduce + x)))
21:46clojurebot#'sandbox/add1
21:46TEttingeryou can def here :)
21:46TEttingerit lasts 10 minutes or so
21:46neoncontrails,(defn add1-good [x] (if (seq x) (reduce + x)))
21:46clojurebot#'sandbox/add1-good
21:46TEttingerand you may have wanted not empty?
21:46neoncontrails,(defn add1-bad [x] (if (empty? x) (reduce + x)))
21:46clojurebot#'sandbox/add1-bad
21:46neoncontrails(add1-bad [])
21:47TEttinger,(add1-bad [])
21:47clojurebot0
21:47TEttinger,(add1-good [])
21:47clojurebotnil
21:47justin_smith,(reduce + nil)
21:47clojurebot0
21:47justin_smith,(reduce * nil)
21:47clojurebot1
21:47jeayeseq and empty? are negated here, neoncontrails
21:47merl1nis there a comp equivalent that composes functions in reverse?
21:47en590mann you guys are so smart
21:47neoncontrailsjeaye: pardon, can you elaborate?
21:47en590i am copy pasting all this code to look over tomorrow morning lol
21:48TEttinger,(defn pmoc [& args] (apply comp (reverse args)))
21:48clojurebot#'sandbox/pmoc
21:48surtnen590: you shouldn't confuse smart with familiar :)
21:48TEttinger,(filter (pmoc empty? not) [1 2 3])
21:48clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
21:48TEttinger,(filter (pmoc empty? not) [[1 2 3]])
21:48clojurebot([1 2 3])
21:49TEttingerI think I screwed up somehwere
21:49TEttinger,(filter (pmoc empty? not) [[1 2 3] [] [1 2]])
21:49clojurebot([1 2 3] [1 2])
21:49neoncontrailsTEttinger: what's the English translation of 'pmoc'?
21:50jeayecomp reversed
21:50neoncontrailsOkay I don't normally LOL, but... LOL. :)
21:50neoncontrailsGood one, Rich
21:53TEttingerI think PMOC is likely one of the many perl-related acronyms, like CPAN
21:53TEttingeror perl 6's current GLR (great list refactoring)
21:53justin_smithTEttinger: pmoc is for mocking in drug testing scenarios (employee is on drugs? substitute this clean mock)
21:53neoncontrailsThat wouldn't surprise me. Larry Wall is weirdly hilarious
21:54TEttingerI think it's kinda entertaining that perl 6 code interleaves normal-looking perl code with stuff like .WHAT and .HOW
21:55justin_smithTEttinger: much code .WOW
21:55TEttingerbut there's some serious brilliance/madness in the unicode handling. that stuff is impressive.
21:55TEttinger\c[SIGN OF THE HORNS] is the same as typing in a literal unicode emoji introduced in Unicode standard 8.0. Java 9 will be on Unicode 7.0 next year.
21:57TEttinger\c[APOSTROPHE] is the same as an escaped ' but behaves correctly even in misbehaving syntax highlighters
21:57TEttingerthen again... Visual Studio 2015 is literally incapable of compiling one of the unicode data files that this implementation of perl 6 needs. it stack overflows in the parser.
21:59neoncontrailsMy favorite morsel of perl trivia is this poem
21:59neoncontrailshttps://en.wikipedia.org/wiki/Black_Perl
21:59TEttingeroh and did you all know that openjdk 9 actually isn't that hard to compile anymore, even on windows?
21:59TEttingerit's kinda shocked me
21:59en590hey just for fun is there a clearer way to increment all the values of a collection than this:
22:00en590,(map #(inc %) [1 2 3])
22:00clojurebot(2 3 4)
22:00TEttinger,(map inc [1 2 3])
22:00clojurebot(2 3 4)
22:00en590shit lol thank you
22:01TEttingerI have several versions of a probably now-outdated openjdk 9 for windows x86 and x64, and yes, it actually does start up faster than java 8
22:01TEttingerthey're... they're actually doing something good with core java. I'm as stunned as you are.
22:01TEttingerafter like 5 years on java 6... I had lost all hope
22:03en590dang function programming is amazing
22:03justin_smithsure is
22:03en590after seeing solution to problem it usually seems obvious and in my face lol
22:03justin_smiththat could mean you are learning
22:03neoncontrailsThat's a really common feeling in FP
22:04en590if i can just learn all the core functions i will be unstoppable
22:05justin_smithen590: have you looked at http://conj.io ?
22:05justin_smithen590: if you can learn that page, and a few libs for your domain... you're going to be pretty much set
22:06neoncontrailsThat's a little easier said than done, I think. Mastery of FP primitives lies in figuring out how to compose them, which takes a helluvalot of practice
22:06neoncontrails(this is my own personal opinion)
22:07en590i like this page it has a good ui
22:07en590thank u justin_smith
22:08justin_smithen590: the page was made by our friend arrdem
22:08justin_smith(inc arrdem)
22:08lazybot⇒ 46
22:09neoncontrailsheh
22:09neoncontrails(arrdem)
22:09neoncontrails,(arrdem)
22:09clojurebot#error {\n :cause "Unable to resolve symbol: arrdem in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: arrdem 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: arrdem in t...
22:09neoncontrails,arrdem
22:09clojurebot#error {\n :cause "Unable to resolve symbol: arrdem in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: arrdem 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: arrdem in t...
22:10justin_smithneoncontrails: it's a pseudo-syntax for lazybot
22:10justin_smith(identity arrdem)
22:10lazybotarrdem has karma 46.
22:10justin_smith(identity justin_smith)
22:10lazybotjustin_smith has karma 290.
22:10justin_smith(identity amalloy)
22:10lazybotamalloy has karma 294.
22:10en590(identify en590)
22:10neoncontrailsHaha, I'm liking this community more and more.
22:10justin_smithen590: it's identity
22:11en590(identity eno789)
22:11lazyboteno789 has karma 0.
22:11neoncontrails(inc eno789)
22:11lazybot⇒ 1
22:12en590(inc eno789)
22:12lazybot⇒ 2
22:14en590all is right in the world now ok thank you everyone cya
22:16justin_smitharrdem: we were admiring your work
22:16arrdemyes yes but you were admiring the WRONG WORK
22:16justin_smithis this a thing we can all use?
22:16arrdemif you want to deal with skummet
22:17arrdemI need to start my own clojure fork with just that change
22:17neoncontrailsarrdem: what's the case for using a strictly-tagged subset of Clojure versus, say, Haskell?
22:18arrdemneoncontrails: strictly tagged clojure is just a compilation mode for better interop performance, it isn't a real type system like Haskell.
22:19neoncontrailsOoh, that makes sense. Got it.
22:19justin_smitharrdem: so tl;dr I can use strictly tagged clojure and that would mean writing less of my perf-critical code in java?
22:19arrdemjustin_smith: that was the idea
22:19justin_smithv. cool
22:23TEttingerI personally don't mind writing perf-critical code in java. it gives me a chance to be stupid and still program
22:23neoncontrailsRandom question, is there a Clojure analog of Java's abstract classes? (e.g. "abstract class Foo { ... }")
22:24TEttinger"hm, I could rewrite this ridiculous loop to use multiple functions... nah, labeled break/continue should be fine and this 200 line loop should do A-OK"
22:24neoncontrailsI learned Java immediately after SICP, and I could never figure out how abstract classes related to anything I was familiar with from Scheme
22:25TEttingerthere's protocols, which correspond to interfaces I suppose
22:25TEttingerI have never honestly written a protocol
22:25arrdemprotocols are pretty neat
22:34arrdemA little late, but wrt writing Java for perf, Clojure interop is already practically Java in sexprs so I don't personally see a compelling reason to use a different tool when we have all the same type information available
22:37TEttingerarrdem: I'm not entirely sure why, but some of the algorithms that I have written in both clojure and java seem to have significant perf differences. the type of algorithm is 2d-array-based, using primitive doubles
22:37TEttingerit's possible clojure has caught up now
22:38TEttinger(it's still kinda annoying to need type hints everywhere and need to avoid local assignment to avoid boxing)
22:38arrdemTEttinger: with amalloy and my strictly tagged changes, strictly hinted Clojure code should almost be byte for byte the same as Java implementations.
22:38TEttingerbadass.
22:39TEttingeris it planned for 1.8 in however many years?
22:39arrdemwell 1.8 is supposed to be this fall or something
22:39arrdembut no we've gotten no "this is release candidate material" or otherwise feedback.
22:40neoncontrailsSpeaking of efficiency/imperative interop
22:40neoncontrails(defn answer2 [maxrange]
22:40neoncontrails (reduce + (filter #(or (zero? (mod % 3))
22:40neoncontrails (zero? (mod % 5)))
22:40neoncontrails (range maxrange))))
22:40neoncontrailserr
22:40arrdemneoncontrails: STOP PASTING USE REFHEEAP
22:41arrdem*refheap.com
22:41neoncontrailsOKAY SORRY
22:41arrdemsorry for caps, wanted to catch you before you retried :P
22:41arrdemwe have an ad-hoc one line paste limit around here
22:41scriptorfizzbuzz?
22:41neoncontrailshttps://www.refheap.com/108694
22:42neoncontrailsEhh, kinda. Project Euler #1
22:42neoncontrailsWhich is basically fizzbuzz, but with an added reduce() step
22:43neoncontrailsI'm curious, did I goof something in my answer3 defn, or is set/union actually a lot slower than brute forcing it?
22:46TEttinger,(let [maxrange 100] (reduce + (distinct (concat (range 3 maxrange 3) (range 5 maxrange 5)))))
22:46clojurebot2318
22:46neoncontrailsAnecdotally, I've noticed set/union in Python is approximately an order of magnitude faster than reducing a filtered generator
22:47TEttinger,(let [maxrange 1000] (reduce + (distinct (concat (range 3 maxrange 3) (range 5 maxrange 5)))))
22:47clojurebot233168
22:47neoncontrailsOh wow, that's costly
22:48neoncontrails,(time (let [maxrange 1000] (reduce + (distinct (concat (range 3 maxrange 3) (range 5 maxrange 5))))))
22:48clojurebot"Elapsed time: 23.881238 msecs"\n233168
22:48TEttinger,(let [maxrange 1000] (reduce + (distinct (into [] (range 3 maxrange 3) (range 5 maxrange 5)))))
22:48clojurebot#error {\n :cause "clojure.lang.LongRange cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.LongRange cannot be cast to clojure.lang.IFn"\n :at [clojure.core$transduce invokeStatic "core.clj" 6575]}]\n :trace\n [[clojure.core$transduce invokeStatic "core.clj" 6575]\n [clojure.core$into invokeStatic "core.clj" 6591]\n [clojure.core$into...
22:48TEttinger,(let [maxrange 1000] (reduce + (distinct (into (range 3 maxrange 3) (range 5 maxrange 5)))))
22:48clojurebot233168
22:48TEttinger,(time (let [maxrange 1000] (reduce + (distinct (into (range 3 maxrange 3) (range 5 maxrange 5))))))
22:48clojurebot"Elapsed time: 24.208726 msecs"\n233168
22:48neoncontrails,(defn answer3 [maxrange] (reduce + (cs/union (set (range 3 maxrange 3)) (set (range 5 maxrange 5)))))
22:48clojurebot#error {\n :cause "No such namespace: cs"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: No such namespace: cs, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "No such namespace: cs"\n :at [clojure.lang.Util runtimeException "Util.java" 221]}]\n :tr...
22:48TEttingerha slower
22:49TEttingerneed to type it out or require here, not sure if require works
22:49neoncontrails,(defn answer3 [maxrange] (reduce + (clojure.set/union (set (range 3 maxrange 3)) (set (range 5 maxrange 5)))))
22:49clojurebot#error {\n :cause "clojure.set"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.ClassNotFoundException\n :message "clojure.set"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[ja...
22:49neoncontrailsnevermind, I'll REPL it
22:50TEttinger,(require 'clojure.set)
22:50clojurebotnil
22:50TEttinger,(defn answer3 [maxrange] (reduce + (clojure.set/union (set (range 3 maxrange 3)) (set (range 5 maxrange 5)))))
22:50clojurebot#'sandbox/answer3
22:50TEttinger,(answer3 1000)
22:50clojurebot233168
22:50TEttinger,(time (answer3 1000))
22:50clojurebot"Elapsed time: 3.914105 msecs"\n233168
22:50TEttingerwoah
22:50neoncontrailsOkay yeah, wow
22:50TEttingerthis also depends on the JIT
22:51TEttingerwhich is very hard to measure
22:51TEttingerwe've definitely hit the JIT compiler limit for some of range's internal stuff
22:51neoncontrailsMy local test says it's about an order of magnitude slower (4.29ms vs. 0.49ms)
22:51TEttingerit's possible the range just is getting JITed now
22:52TEttinger,(time (let [maxrange 1000] (reduce + (distinct (into (range 3 maxrange 3) (range 5 maxrange 5))))))
22:52clojurebot"Elapsed time: 13.266595 msecs"\n233168
22:52TEttingeryep
22:52TEttingerremember that was 24 earlier?
22:52TEttingerwelcome to JVM benchmarking crazyland
22:52neoncontrailsInteresting
22:53neoncontrailsThe question in my mind remains, so, this appears to be comparable to the brute-force solution, efficiency-wise
22:53TEttingerthe JIT is top-notch for long-running functions, but microbenchmarks are very hard to predict
22:53neoncontrailswhy is it not faster?
22:57camm_v222Hi guys, I want to create an app on Clojure for Android, but I have a few problems trying to download Android SDK (for Fedora GNU/Linux). I can't download the SDK!!! I know it sounds silly but I just get on a loop trying to download it from here ( https://developer.android.com/intl/zh-cn/sdk/installing/index.html?pkg=tools ). May you help me, please?
23:02TEttingercamm_v222: just curious, are you intentionally downloading the chinese version, and could there be uh blockage issues?
23:04TEttingercamm_v222: there's some link confusion on their site. https://developer.android.com/intl/zh-cn/sdk/index.html#Other
23:08camm_v222TEttinger Yeah, I see, and I don't know what to do. It's the only official page that I've found to download the Android SDK.
23:09TEttingerI wonder if Fedora has it in a non-free repo
23:09TEttingeror even a free repo
23:10camm_v222Well, I'm going to search a repo for Fedora, it's my last chance. Thanks TEttinger.
23:11TEttingerhm not quite actually
23:11TEttingerI'm downloading it and I think I may be able to host the (large) archive somewhere, like mega or some other large-file host
23:14arrdemwould be happy to host shasums or something else
23:46andyfI'm using some low-level library that shows details of memory layout inside of Java objects, and can also return the current address of a Java object. I know Java objects can be moved during garbage collection, but I'm seeing evidence that either (a) when you use the -XX:+PrintGCDetails command line option to Oracle's JVM, it doesn't print every time a GC occurs, or (b) objects can move even when no GC has occurred. Anyone have an
23:47andyfThat is really a more Java-specific rather than Clojure-specific question, but the context is that I'm working on some utilities in Clojure to help calculate the size in memory of data structures.
23:49TEttingeryour question cut off, andyf
23:49TEttinger...no GC has occurred. Anyone have an <cut off>
23:49TEttingerandyf, this sounds very useful btw
23:50andyfSorry, that was long. Ending was "Anyone have any knowledge of this?"
23:51justin_smithandyf: is hotspot allowed to move data around?
23:51andyfIt scratches an itch of mine. Path-copying in immutable data structures is useful, but it is nice to be able to quantify "how much sharing usually happens between x and (conj x y), or between my-map and (assoc my-map x y)?"
23:52andyfjustin_smith: Any time there is a compacting garbage collector involved, data can move during a collection. And that is the default for most JVMs, I think.
23:52andyfIt is invisible to any program running on the JVM, as long as you don't use some unsafe method to peek at the addresses.
23:52justin_smithandyf: I mean the optimization process, aside from gc
23:53justin_smithI understand the concept of compacting gc, yes
23:53andyfjustin_smith: Not sure I understand your question, then. Do you mean: is hotspot allowed to reformat the internals of instances of a particular class while it is running?
23:54justin_smithandyf: I could imagine an optimizer that says "these things in the heap will be used near each other, we can help cache performance by putting them near each other"
23:54justin_smithandyf: this would move things while gc is not occuring, is why I ask
23:55andyfjustin_smith: I'm not aware of anything like that done intentionally by any existing GCs. Compacting collectors may end up doing that by accident, or by the fact that objects allocated near each other in time might be more likely to have references to each other.
23:55justin_smithandyf: I am not talking about the gc, I am talking about the hotspot optimizer
23:56justin_smithandyf: you said "things moved when gc did not occur"
23:56justin_smithI suggested another reason a thing might move in the heap (hypothetically)
23:57andyfjustin_smith: Got your meaning now. I've not heard of such a feature.
23:58justin_smithandyf: OK. IIRC this is one of the big optimization features OCaml uses. I find OCaml interesting because their optimizations are powerful while not being very clever (contrast Haskell)
23:59TEttingermight also be useful to check every java version you can to see how they perform differently, once you get this working