#clojure logs

2014-04-21

00:02ddellacostayedi: how are you deploying the uberjar?
00:02yedii'm just using lein uberjar and then copying the uberjar from my local machine to the remote server
00:03ddellacostayedi: seems like you'd need to compile the cljs and include it in the uberjar beforehand, no? Actually not sure how else you'd do it
00:05owl-v-(or) is nil, and (and) is true???
00:05lazybotowl-v-: Yes, 100% for sure.
00:06ddellacostaowl-v-: makes sense
00:06ddellacosta,(or nil nil)
00:06clojurebotnil
00:06dbaschyedi: I have two profiles, dev and prod
00:06ddellacosta,(and nil nil)
00:06clojurebotnil
00:07ddellacostawhoops
00:07ddellacosta...would have expected that to be true.
00:07dbaschyedi: before I build the uberjar, I do lein cljsbuild once prod
00:10amalloyddellacosta: why would (and nil nil) be true?
00:10ddellacostaamalloy: you're right, I realized my mistake just this moment. :-(
00:10amalloy&('#and nil nil) ;; bestest parlor trick
00:10lazybotjava.lang.RuntimeException: No reader function for tag and
00:10amalloy&(#'and nil nil)
00:10lazybot⇒ true
00:10owl-v-if (nil) is treated as false then (and false false) would be false
00:11ddellacostaamalloy: wat
00:11ddellacostaamalloy: what is going on there?
00:12amalloyddellacosta: macros take two additional implicit arguments, &form and &env. calling through the var gets at the underlying function, and lets you pass those yourself
00:12amalloy&(#'and 1 2 'asdf 'anything)
00:12lazybot⇒ (clojure.core/let [and__3822__auto__ asdf] (if and__3822__auto__ (clojure.core/and anything) and__3822__auto__))
00:13amalloyso (#'and 'anything 'whatever) really a silly way of calling (macroexpand '(and))
00:13TEttingerheh neat
00:13ddellacostaamalloy: huh, thanks for the explanation
00:14ddellacostalearn something new (about Clojure especially) every day
00:14owl-v-,(#'and true false)
00:14clojurebottrue
00:14yedidbasch: so just build the prod one right before building the uberjar, and then resume auto building the dev profile while developing?
00:15TEttinger,(#'and nil nil nil nil)
00:15clojurebot(clojure.core/let [and__3973__auto__ nil] (if and__3973__auto__ (clojure.core/and nil) and__3973__auto__))
00:15owl-v-,(and true false)
00:15clojurebotfalse
00:15dbaschyedi: yes, I have a prod.sh script that does that. It cleans everything and builds the prod profile and then the uberjar
00:15TEttinger,(#'and nil nil nil)
00:15clojurebotnil
00:15TEttingerwaaaaah
00:17amalloyTEttinger: because (and x) expands to x
00:17TEttingereven with the other implicit args?
00:17TEttinger,(#'and 3 nil nil)
00:17clojurebotnil
00:18rgrinbergis there a way to play with clojure apps without creating a new project? for example i'd like to try out gorilla repl or incanter
00:18TEttingeruhhh you sure about that?
00:18`szx$google lein-try
00:18lazybot[rkneufeld/lein-try · GitHub] https://github.com/rkneufeld/lein-try
00:18`szx^ rgrinberg
00:19owl-v-(#'and nil nil ture)
00:19owl-v-(#'and true nil nil)
00:19rgrinberg`szx: cool
00:19owl-v-,(#'and nil nil ture)
00:19clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ture in this context, compiling:(NO_SOURCE_PATH:0:0)>
00:19owl-v-(#'and nil nil true)
00:19owl-v-,(#'and nil nil true)
00:19clojurebottrue
00:19TEttingermy brain
00:19owl-v-,(#'and true nil nil)
00:19clojurebotnil
00:21owl-v-,(and nil nil true)
00:21clojurebotnil
00:21owl-v-,(#'and nil nil true)
00:21clojurebottrue
00:23amalloyi think you guys must have missed the lesson here. (#'and x y z) always expands to z, for any x, y, or z
00:23owl-v-,(and 1 2)
00:23clojurebot2
00:23owl-v-,(and 2 1)
00:23clojurebot1
00:24amalloyit's not useful in any real program, except that it gives you a better understanding of how macroexpansion works
00:31jwmanyone care to help explain the add-watch first example
00:32jwmhow can you pass nil to add-watch for key
00:33seancorf`,(doc add-watch)
00:33clojurebot"([reference key fn]); Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Whenever the reference's state might have been changed, any registered watches will have their functions called. The watch fn will be called synchronously, on the agent's thread if an agent, before any pending sends if agent or re...
00:33seancorf`hmm, cut off
00:34jwmyeah I understand add-watch
00:35jwmhttp://clojuredocs.org/clojure_core/clojure.core/add-watch
00:35jwmI just needed help understanding the first example
00:35jwmhow does it get away with using nil in the form
00:36seancorf`nil is just a key
00:36seancorf`as long as the keys of various watchers are all unique, it doesn't matter what their values actually are
00:36seancorf`per the docs, Keys... are otherwise considered opaque by the watch mechanism.
00:37jwmso its just a placeholder in an example
00:37seancorf`Well, it's the key for that watcher
00:37seancorf`you could remove it using nil as the key
00:37jwmyeah
00:38jwmkind of a weird example
00:38jwmwouldn't you want to pass the key into watch-agent
00:38seancorf`if you only want to add one watcher (via this function), it doesn't matter what the key is
00:39seancorf`the key could be 0, or :foo, or ""
00:39seancorf`or nil
00:40jwmhow about the partial, I assumed partial took the arguments after the call
00:41owl-v-how do i express imaginary number???
00:41lazybotowl-v-: Oh, absolutely.
00:41seancorf`right... so watch-fn takes five args, and the partial supplies the context
00:41owl-v-,(Math/sqrt 2)
00:41clojurebot1.4142135623730951
00:41owl-v-,(Math/sqrt -4)
00:42clojurebotNaN
00:42seancorf`and add-watch expects a function of four args - which is what is left
00:42owl-v-,(Math/sqrt -1)
00:42clojurebotNaN
00:42seancorf`owl-v-: you'll need a library that handles complex numbers
00:47seancorf`jwm: does that clarify?
00:47jwmI'm still kind of at a loss
00:47jwmnot sure why
00:48jwmwhat does context mean in this regard
00:48jwmnot sure why this is so hard for me to understand I already have smtp, mongodb, http, uberjar, nrepl + lighttable going
00:48jwmhehe
00:48jwmI just let myself get stuck and it gets irritating :)
00:48seancorf`Could be a label to display
00:49seancorf`It could be a snapshot of state from wherever the watcher was added
00:49jwmok so context just gets passed to the anonymous function
00:49jwmbut where do the rest of the arguments get passed in from
00:50seancorf`add-watch takes a function of four args, (partial watch-fn context) is a function of four args
00:50seancorf`so when the item changes, the system calls the function (with four args)
00:57jwmyou know where I went wrong
00:57jwmI didn't think in my head that add-watch was calling the function with the rest of the arguments
00:57jwmI'm a dildo
00:58jwmheh
00:58jwmthe nil thing also through me off
00:58jwmthat should be changed to some random key like :example :)
00:58jwmthrew*
00:59seancorf`:context-watcher would probably be a better key for that example
00:59jwmyeah
00:59jwmthe nil made me think somehow partial worked backwards also lol
00:59jwmI overthought it
01:02jwmI probably wont be using agents
01:02jwmthey seem to fail in my environment
01:03seancorf`oh?
01:03jwmone last question any good tools to stop memory creeping
01:04jwmI'm running my code as an uberjar and it started at 96mb
01:04jwmno addition of data and its at 350 now
01:04jwmI plan to add a lot of introspection later down the road but I have a stupid deadline by tuesday
01:04seancorf`Have you used JVM-based languages before?
01:05jwmno, just in administration
01:05jwmI put off for two decades now because the jvm used so much memory :)
01:06jwmbut now that we have gigs upon gigs..
01:06seancorf`The JVM starts with a minimum heap size and allocates more memory as it needs it up until the max heap size you specify
01:06jwmI've got a crapload of dependencies though so I imagine that isnt much memory at this point in time
01:06seancorf`A lot of people who've never used the JVM find the memory use surprising
01:07seancorf`We run servers with heap size set to 8GB :)
01:07jwmhehe
01:07jwmgone 64bit?
01:07seancorf`I usually run local JVM processes on my laptop with 1GB heap
01:07jwmI am running this code 64bit
01:07seancorf`heh, haven't had a 32bit system for years
01:08jwmI'm actually transitioning over from nodejs
01:08jwmgetting off the imperative bandwagon since I am trying to get into more r&d type stuff
01:09seancorf`I've been using JVM-based systems for 17 years now
01:09jwmthat is cool
01:10jwmI was an asm coder and then went to javascript lol
01:10jwmfigured if I was going to use a vm might as well use a really good one :)
01:11TEttingerLLVM?
01:11seancorf`The JVM is certainly battle-tested
01:11jwmI did not get comfortable with llvm yet
01:11jwmbut its sick how embeddable it is
01:11TEttingerI'll give Julia a shot
01:13jwmhow's openjdk doing
01:13jwmI haven't tried running clojure on it yet
01:14seancorf`Clojure and its contrib libraries are all tested against OpenJDK
01:14seancorf`for example http://build.clojure.org/job/clojure-test-matrix/
01:15seancorf`and you can see how contrib libraries are tested against both multiple JVMs and multiple Clojure versions http://build.clojure.org/job/java.jdbc-test-matrix/
01:16jwmhttp://openjdk.java.net/projects/jdk8/
01:16jwmyeah, tested against 1.6 on that page
01:16jwmyour page rather
01:18seancorf`I'm running Java 8 locally for all my testing now... and we're on Java 7 in production right now... We've tended to go to production with RCs of Clojure for a while as well... We first went to production with Clojure 1.3 alpha 7 or alpha 8
01:19jwmI must be a bad guy then I run everything at one level shy of beta
01:19jwmhehe
01:20seancorf`we test locally against master so we're always ready for the alphas and betas as they appear
01:20jwmI work for a cable company though so it's not exactly life threatening stuff
01:25jwmI really like lighttable
01:26jwmI've used emacs/slime/etc in the past but lighttable is really nice so far
01:27seancorf`I used Emacs for Clojure for about two years, before switching to LightTable when 0.6.0 came out
01:29jwmcool, do you try to stay up to date with git?
01:29jwmI tried updating once a couple weeks ago but it didn't want to start after that hehe
01:29jwmI've got my css to do transparency and a nice image bg
01:29jwmand font shadows
01:30seancorf`With LT you mean? No, I just use the official releases since I used it for all my work and need it to behave...
01:31jwmI finally got my project to a point I can just run the nrepl separate and jar it off and put it on the server.. it seems to run faster now
01:33yedi(inc dbasch)
01:33lazybot⇒ 2
01:34seancorf`We tend to run an nREPL server inside our processes now, so we can connect into processes from LightTable and run diagnostics... or even update the code while it's running.
01:36jwmyep!
01:36jwmthat is exactly what I wanted
01:37jwmreally exciting
01:45jwmclojure.data/diff is nice
01:46Frozenlo`seancorf`: While the cljs/LT is pretty sweet, I stil feel more confortable in emacs.
01:47Frozenlo`But boy do I miss the magic connection between LT and the browser
01:47Frozenlo`Doing the same thing in Emacs is such a pain...
01:48seancorf`Frozenlo`: that pain is why I'll deal with LT and its quirks :)
01:48jwmyeah that is what I like the most out of LT.. it's kind of like sublime
01:48jwmit reads your mind on how you want to do things
01:49jwmI got clojurescript going in lt and the frontend to this project
01:49jwmnext thing I want to try is nrepl from browser and nrepl from lighttable at the same time if possible hehe
01:55seancorf`LT can certainly connect into both client and server and eval code live into both. We do that.
01:57jwmyeah, I already have both repls going at once. I mean have something outside of lt running in browser
01:57jwmso when I am on the go I can just login and change some code from the web
01:58FrozenlockIs there a function to make a range that 'sometimes' skip a number? Like `(from 0 to 500 in 400 steps)'
01:58Frozenlock--> with only int
01:58jwmI know they already have browser based repls I just would like both options. I had to load up the nrepl lt middleware so I would need two separate repl sessions if possible
02:00seancorf`jwm: what you change in the browser is only transient - for that browser and only until you reload the page
02:00seancorf`you need to be able to push updated source as well, and run lein cljsbuild auto on the server :)
02:00jwmyeah I run auto on the server
02:01jwmbut if it is a nrepl in browser wouldn't it update clojure?
02:01seancorf`Frozenlock: range has a step argument
02:02seancorf`jwm: if your repl is connected to the browser, it's only affecting the running JS image - in the browser
02:02seancorf`the repl to the server will modify the (shared) server image, until the process is restarted
02:02Frozenlockseancorf`: I know, but it won't skip a step if needed.
02:03seancorf`Frozenlock: oh i see, you want the [0,500) divided by 400 and the nearest int used?
02:03dbasch,(range 10 100 20)
02:03clojurebot(10 30 50 70 90)
02:04seancorf`jwm: whenever you reload the browser, you'll lose any repl-made changes - unless you've also pushed them in source to the server (which is what we plan to do)...
02:04jwmyeah, if you have an nrepl from the browser console to your server though
02:04jwmyou're actually evaling into the clojure nrepl connection
02:04dbaschFrozenlock: do it for a multiple and then divide
02:04seancorf`ah, that wasn't what i thought you meant
02:04jwmof course then when you restart the server it would lose changes
02:05yedidbasch: i'm guessing adding a `lein clean` to the start of this would be ideal? https://github.com/yedi/reasoned-rhymer/blob/master/deploy.sh
02:05dbaschyedi: yes, mine does a clean first
02:05jwm I played with bodil's catnip a bit
02:05seancorf`jwm: why use a browser-based login for the repl-to-server setup? why not just use LightTable and a VPN? :)
02:06jwmhaha
02:06jwmyeah I do that now (vpn.. well autossh)
02:06dbasch,(range 1 100 (quot 100 13))
02:06clojurebot(1 8 15 22 29 ...)
02:06jwmseancorf`: I want to go to session based coding in the future
02:06jwmfor my own personal ide project :)
02:06seancorf`anyways, late here ... bed time...
02:07jwmsame here night thanks for the help
02:08jwmactually they could make lighttable semi-embeddable into browser
02:08ontoillogicalhello all, I'm trying to use this Java library in clojure and I'm having trouble importing it https://clojars.org/org.clojars.smallrivers/simplecaptcha/versions/1.2.1 . The class I want to use is nl.captcha.Captcha
02:08jwmthat would be pretty meta
02:09ontoillogicalI can't figure out how to require it, (require 'org.clojars.smallrivers.simplecaptcha.Captcha) doesn't work, neither does (require 'nl.captcha.Captcha)
02:11jwmit would just be org.clojars.smallrivers no?
02:12ontoillogicaljwm: (require 'org.clojars.smallrivers.Captcha) and (require 'org.clojars.smallrivers.nl.captcha.Captcha) both fail :(
02:14jwmwhat about org.clojars.smallrivers
02:14amalloyyou don't use require to talk to java classes. you import them
02:14jwmthis is on maven though no?
02:16ontoillogicalamalloy: ohhhhhh
02:16jwm(import '[org.clojars.smallrivers Captcha])
02:17ontoillogicalimport!
02:17ontoillogicalthanks all
02:17jwmhehe I got stumbled by that on a few of the ones without docs
02:18ontoillogicalso it looks like this is a library on clojars that just contains the java classes, no clj wrapper. Is this common?
02:18dbaschontoillogical: yes
02:19ontoillogicaldbasch: is there a need to repackage java libraries for clojure, or is this just to make pulling them down from clojars using lein or what not convenient?
02:20dbaschconvenience, people do it all the time
02:20dbaschespecially for the ones out of github that are not on maven
02:21dbaschI’m guilty of that myself: https://clojars.org/org.clojars.dbasch/bip38
02:22jwmI use org.clojars.subethasmtp
02:27jwmI didnt know you could make a vector as a key
02:29jwm{[:spool :web] {:test 234},
02:29jwmthat looks terrible
02:29jwmhehe
02:48sm0keweird literal tag behaviour
02:48sm0keif i pass a fucntion to a literal tag, it converts it to a symbol
02:51owl-v-is (reduce) == (apply) ???
02:51lazybotowl-v-: Yes, 100% for sure.
02:51dbaschowl-v-: no
02:51owl-v-haha
02:52owl-v-lazybot~
02:53owl-v-i can't tell difference between (reduce) and (apply)
02:53dbaschfor one, reduce applies to two-argument functions
02:54dbaschapply uses a list as arguments to a function
02:56dbasche.g.
02:56dbasch(defn f [a b c] (println (+ a (* 10 b) (* 30 c))))
02:56dbasch(apply f [1 2 3])
02:56dbaschthat won’t work with reduce, it would be meaningless
02:59magopiandbasch: owl-v-: i guess the confusion comes from functions that accept any number of arguments, like "str"
03:00magopian(i'm a noob and keep getting confused about that myself)
03:00dbaschmagopian: sometimes you can get the same result with reduce or apply, but you should know what you’re doing and why
03:01dbaschreduce keeps “carrying” a result and computing the operation with the next value
03:01magopian,(reduce str ["a" "b"])
03:01clojurebot"ab"
03:02magopian,(apply str ["a" "b"])
03:02clojurebot"ab"
03:03magopianwith reduce, however, you can do nice things like specify a starting point
03:03magopian,(reduce str "starting point" ["a" "b"])
03:03clojurebot"starting pointab"
03:03Frozenlockdbasch: seancorfield: That's what I settled with. It never returns more than the number of steps asked, and strech the range as much as it can. https://www.refheap.com/78060
03:05owl-v-,(apply str "starting point" ["a" "b"])
03:05clojurebot"starting pointab"
03:06owl-v-,(apply str "starting point" ["a" "b"] " fun")
03:06clojurebot"starting point[\"a\" \"b\"] fun"
03:06owl-v-,(reduce str "starting point" ["a" "b"] " fun")
03:06clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core/reduce>
03:07owl-v-(apply) > (reduce) ???
03:07lazybotowl-v-: How could that be wrong?
03:11dbasch,(map (comp #(Math/round %) float) (range 0 20 (/ 20 18)))
03:11clojurebot(0 1 2 3 4 ...)
03:11dbaschFrozenlock: would that work?
03:13dbaschor
03:13dbasch,(map (comp int #(Math/floor %) float) (range 0 20 (/ 20 18)))
03:13clojurebot(0 1 2 3 4 ...)
03:13Frozenlock,(count (map (comp #(Math/round %) float) (range 0 100 (/ 100 90))))
03:13clojurebot90
03:14Frozenlocklooking now :-p
03:15jonasenowl-v-: (apply f [x y z]) -> (f x y z)
03:15jonasen(reduce f [x y z]) -> (f (f (f x) y) z)
03:16jonasensorry, it's actually (reduce f [x y z]) -> (f (f x y) z)
03:16Frozenlockdbasch: I'd say it works o_O
03:16FrozenlockWow I'm terrible
03:17FrozenlockI see, you steps in fraction and turn it into integers only when finished
03:17jonasenand with an initial value: (reduce f init [x y z]) -> (f (f (f init x) y) z)
03:18dbaschFrozenlock: the same thing happens to me when looking at the best 4clojure solutions
03:19Frozenlockdbasch: the 'wow I'm terrible' part?
03:19dbaschFrozenlock: yes
03:19FrozenlockKeeps your ego in check :)
03:20owl-v-,(apply (fn [n m] (Math/pow n m)) [2 3 4])
03:20clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: sandbox/eval79/fn--80>
03:20owl-v-,(reduce (fn [n m] (Math/pow n m)) [2 3 4])
03:20clojurebot4096.0
03:21owl-v-:-)
03:22jonasenowl-v-: you see the difference now? ((Math/pow 2 3) 4) vs. (Math/pow 2 3 4). The latter throws an ArityException
03:22owl-v-it does :)
03:22TEttinger,(reduce (memfn Math/pow) [3N 4N 5N])
03:22clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: sandbox/eval131/fn--133>
03:23owl-v-thanks
03:23jonasenThat first one should ofcourse be (Math/pow (Math/pow 2 3) 4)
03:27dbaschFrozenlock: btw, (map int (range…))) works fine, I was just trying to get closer to the numbers in your example
03:28dissipatewhich approach to polymophism is considered more 'idiomatic' in clojure? protocols, multimethods or just plain old functions as parameters?
03:29dissipatei seeing quite a few open source projects using protocols a lot. but it reminds me more of OO style programming
03:30dbaschdissipate: multimethods http://clojure.org/runtime_polymorphism
03:30jonasendissipate: I usually start with plain functions (polymorphism isn't always needed). If I do need polymorphism I'd go with multimethods first. They are more flexible and often efficient enough
03:31dbasch(inc jonasen)
03:31lazybot⇒ 1
03:31Frozenlockdbasch: I see that. I think at the beginning I wanted to avoid duplicates in case of steps <1 and got lost from there.
03:32dbaschFrozenlock: well, with steps < 1 you have to use floats or fractions
03:32Frozenlock(distinct (map int (range..))) is way simpler anyway
03:34dbaschFrozenlock: steps < 1 means you want more than the range, or else just use 1
03:35dissipatejonasac, my situation is that i want to write some functions that are going to kick off and keep track of some running tasks, but i want to create an 'interface' so that i can easily swap out for a different implementation if needed later. for instance, i want to do 'start-task', 'stop-task' etc.
03:35FrozenlockThere, fool(me)-proof (map int (range from to (max 1 (/ to in-n-steps))))
04:07ptcekexit
04:14owl-v-if i have function (defn filter-red [image] (filter-color image "red")) will i have copy of image inside of the function 'filter-red'?
04:25dissipateowl-v-, depends on what you mean by 'copy', but 'image' will be bound locally to whatever is passed in to that function as that param
04:27owl-v-image as array of pixels
04:29dissipateowl-v-, you mean a vector? or a list?
04:29owl-v-(let [image (get-image-from-camera 0)] (filter-red image))
04:29owl-v-list/vector matters?
04:30dissipateowl-v-, not really, but 2 different data structures
04:31owl-v-all i want to know is does image in the function have duplicated image or not?
04:33dissipateowl-v-, it will be bound to the list/vector, yes. lists and vectors are persistent data structures, which means that essentially what you get is a 'copy' of the data structure when the function is called.
04:34dissipateowl-v-, more on that here: http://clojure.org/data_structures
04:35owl-v-is there way to pass reference?
04:36dissipateowl-v-, yep, instead of a list/vector, it could be a ref. more on those here: http://clojure.org/refs
04:48owl-v-how do i update value just like c or python?; 'a = 0' -> 'a = 1'
04:49owl-v-if i don't want to have old value?
04:53dissipateowl-v-, it depends on what you are trying to do
04:53owl-v-y?
04:54owl-v-(def a 0) and then (def a 1) ?
04:54dissipateowl-v-, because in Clojure, mutation is managed. and there are different ways of managing mutation depending on what you are doing.
04:55dissipateowl-v-, atoms are one of the simplest ways of doing mutation in clojure. but there are also transients.
04:57dissipateowl-v-, http://clojure.org/atoms
04:59dissipateowl-v-, this blog post gives more of an overview: http://blog.fogus.me/2011/07/12/no-stinking-mutants/
05:06owl-v-the reason i need to remove old value is because i need to get image forever~
05:06owl-v-a new image for each iteration
05:07perseshello, i just tried jiraph lib, and when i did lein run, i got http://sprunge.us/FciM
05:07persesis there anybody help pleasE?
05:07owl-v-start (get image) (filter image) (display image) loop
05:09owl-v-if i don't get rid of old images, stack overflow may occur.
05:10dissipateowl-v-, sounds like you could use a lazy sequence: http://clojuredocs.org/clojure_core/clojure.core/lazy-seq
05:11dissipateowl-v-, set up a function that generates the images and then use 'lazy-seq' so you can keep getting images from it
05:21persesplease anybody here can help
05:21perseshttp://sprunge.us/FciM , how may i fix this?
05:33persesi changed the version to the recent and i got another errors http://sprunge.us/WUPO
05:39jonasenperses: Is jiraph in your :dependencies vector in project.clj?
05:42persesjonasen: http://sprunge.us/FbDS
05:44jonasenperses: looks ok
05:44persesjonasen: what maybe cause this ?
05:47jonasenperses: what does your (:require ..) form look like? I think you should require the flatland.jiraph.graph namespace
05:51persesjonasen: http://sprunge.us/iNXI
05:52jonasenperses: Try removing (use 'jiraph.graph)
05:57persesjonasen: check usage section https://github.com/ninjudd/jiraph , i need to define use stuff to can use the methods there, when i tried without it i got undefined
06:01jonasenperses: I think the usage section might be outdated. I can find no jiraph.graph namespace in the source code.
06:01jonasenmaybe they have reorganized the namespace structure or something
06:05owl-v-how do i use java api?
06:06jonasenowl-v-: which one?
06:06owl-v-java gui
06:07owl-v-java.awt
06:09jonasenowl-v-: you import the classes you want to use and use them with Clojure's Java interop support: http://clojure.org/java_interop
06:10persesjonasen: http://sprunge.us/FQYH i tried simple example from usage but without use 'jiraph.graph with require part you mentioned, and got this error
06:10maveneaglehey folks, are there any forum where i can find recent whitepapers about computer science and software development in general? hacker news is good but not all whitepapers makes its way to hacker news..
06:13jonasenperses: You'll probably have to study the source code if the usage examples are out of date. My guess is the namespace jiraph.masai-layer has been renamed to flatland.jiraph.layer.masai
06:14persesah ok
06:30kraswhat is the difference between filter and remove?
06:30kras,(doc filter)
06:30clojurebot"([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-effects."
06:30kras,(doc remove)
06:30clojurebot"([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns false. pred must be free of side-effects."
06:31llasramkras: false vs true from the pred
06:31krasoops, overlooked it
06:31krasthanks
06:32krasfn names are little confusing though
06:32krasfilter-if filter-if-not sounds better, no?
06:54owl-v-why can't i call java class? https://www.refheap.com/78079
07:00owl-v-class not found exception; https://www.refheap.com/78080
07:01penthiefowl-v-: Dunno, can you call the constuctor with the package name included? (org.opencv.objdetect.CascadeClassifier. ...) If not, then my guess is its not on the path. Does "ps -wef|grep java" show the relevant library?
07:07penthiefI don't much like, nor understand why add-watch agent functions are called about 3 times instead of once, because I was hoping that I could use an add-watch function as an async callback for a send-off IO operation.
07:28Frozenlock_sleepThat's weird... congomongo just started giving me back strings instead of joda DateTime
07:31jwmis there a good way to output the contents of a ref straight to a file
07:31jwmthat has mix and match content (mime file types, buffered data byte streams, etc)
08:04petronhey peeps. I need some help with my Clojure workflow. I can't believe how hard it is to not wait 3 seconds every time I run "lein test".
08:04petronI'm not an Emacs user.
08:04petronI like Light Table, but maybe it's the wrong IDE.
08:04petronI just want to run tests every time I change my source or test files, without restarting the repl each time.
08:04agarmanI suggest prism
08:05beamsohttps://github.com/jakemcc/lein-test-refresh or https://github.com/dakrone/lein-autotest ?
08:05agarmanhttps://github.com/aphyr/prism
08:05agarmanI've tried them all...prism just runs tests relevant to the namespace
08:06petronthx, I'll try that
08:06beamsocan you use prism without using midge?
08:06beamsos/midge/midje/
08:06agarmanI'm not using midje
08:06agarmanso probably :-)
08:07beamsoha. okay.
08:07agarmanI checked prism's dependencies...it's not pulling in midje, so I can give a definitive yes
08:08petronprism exits
08:08petronif I run "lein prism", it runs tests once, and exits
08:08petron(I'm on Windows, if that matters)
08:08beamsooh. i've misread an "inspired by midje's excellent autotest".
08:08agarmanno, it's that you have to reference it in your deps
08:09agarmanin my lein profile :user { :dependencies [com.aphyr/prism "0.1.2" :scope "test"]
08:09petronI followed the instructions on the GitHub repo and placed the plugins and dependencies lines in my ~/.lein/profiles.clj file.
08:10agarmanit may be a windows thing then...I'm on a mac and also use this on an ubuntu machine
08:11petronprism 0.12 seems to work, even without the :scope "test" thing
08:11petronI was on prism 0.11
08:11petronit did not auto-watch
08:11agarmanah, ok
08:11petronso I'm presuming 0.12 may have a fix for windows
08:11agarmanthe :scope test is to keep the dep from getting to production
08:12petronnow I'm getting a "failed to reload..."
08:12petronmy project is called "b"
08:13petronwhen I change b/src/core.clj, I get "java.io.FileNotFoundException: Could not locate \path\to\b\src\b\core__init.class"
08:13petrondo I need :gen-class somewhere maybe?
08:13agarmanno
08:14agarmanit could be an issue with windows still
08:14yedii think it should be b/src/b.core.clj
08:14yedii think it should be b/src/b/core.clj *
08:16petronit appears to be watching the right folders
08:16petronand my source is at b/src/b/core.clj
08:18petronoh nm I have a typo in my project.clj
08:19agarman@petron it all working now?
08:20petronhmmm no :\ fixed project.clj, but still getting "Could not locate \b\src\b\core__init.class or \b\src\b\core.clj on classpath: ..."
08:21petronI don't have :classpath in project.clj, but it must be inferring it correctly because it shows "Watching *\b\src *\b\test" when I run "lein prism".
08:21petronwhere * is /path/to/parent-directory/
08:23agarmanyou can always fall back to https://github.com/jakemcc/lein-test-refresh
08:27petronthx agarman, lein test-refresh is working
08:27petronthis is great
08:28petronright now it's wayyy to hard to get these simple things working and I hope leiningen becomes better at automatically pulling in plugins or something, for newbies.
08:31agarmansomething like lein-try for plugins?
08:38krashow do I pass a seq of args to a macro
08:39kras(apply fn args) doesn;t seem to take macro for a fn
08:39kras,(apply and [true false])
08:39clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/and, compiling:(NO_SOURCE_PATH:0:0)>
08:40gfrederickskras: you don't -- what do you actually want to do?
08:40kras(defn xor [& xs] (and (and xs) (or xs)))
08:41krasI am trying to see if I can make this function work as expected
08:41krasunfortunatley and with a seq doesn;t work as expected
08:41kras,(and [true false])
08:41clojurebot[true false]
08:41gfrederickswell if this is for serious, you'd want to write a macro instead so that it can short-circuit like and/or do
08:42gfredericksbut if you don't care about short-circuiting you can implement the required logic with reduce
08:44krasany of the higher order functions won;t take a macro I guess since it gets unwrapped
08:44gfredericksyou also might want to look at every? and some for function-based analogs of and/or
08:45gfredericksI guess a proper xor can't short-circuit anyhow
08:45gfredericksso you could just do
08:45gfredericks,(defn xor [& xs] (reduce #(cond-> %1 %2 not) false xs))
08:45clojurebot#'sandbox/xor
08:45gfredericks,(xor true true true)
08:45clojurebottrue
08:45gfredericks,(xor true true)
08:45clojurebotfalse
08:46gfredericks,(xor true false false false true)
08:46clojurebotfalse
08:46gfredericks,(xor)
08:46clojurebotfalse
08:48krasgfredericks: thanks, never used cond-> will lookup
08:48gfredericksslightly longer without it: #(if %2 (not %1) %1)
08:52oskarth,(doc cond->)
08:52clojurebot"([expr & clauses]); Takes an expression and a set of test/form pairs. Threads expr (via ->) through each form for which the corresponding test expression is true. Note that, unlike cond branching, cond-> threading does not short circuit after the first true test expression."
09:47jwmis there an easy way to serial a map to a file that contains mime/stream data?
09:47jwmserialize*
09:47jwmseems like a hard task to solve
09:50arrdemyou can't generally stream a map..
09:50arrdemyou have to impose some constraint like ordered keys or fully known keys
09:51jwmyeah I was hoping there would be a library that does it
09:51jwmlike right now I store emails in a map "spool"
09:51jwmbasically just keyworded map for inboxes
09:51jwmemails have mime and base64 encoded data which gets to become a base64decodestream
09:51jwmprobably due to subetha doing that for me
09:52jwmI was hoping I could just take the map and serialize it to disk
10:01jwmcool just found Nippy
10:01jwmserializing library
10:05jwmguess I'll worry about serialization later
10:23ssqqWhen a string match a regexp, How to get the location of the matched substring?
10:26bbloomssqq: you probably need to use re-matcher
10:27ssqqbbloom: Maybe, I try it.
10:28bbloomssqq: i'd probably just use the facilities of java.util.regex direclty for more specialized use cases
10:29ssqqbbloom: Thanks.
10:46wildeyesHello
10:46wildeyesAnybody here?
10:47AeroNotixNo
10:47wildeyesSup aero
10:51joegallono one is here
10:51jwmwhats a good pattern for doing something every few minutes in clojure?
10:52coventryA core.async go block which waits on an async/timeout channel.
10:53bbloomjwm: on the jvm, you can just use a timer class
10:53joegallojava.util.concurrent is full of nice things for that, too
10:53jwmhmm too many choices
10:53jwm:)
10:53joegalloand, of course, there's quartz
10:53jwmfigured as much
11:01llasramFor an in-between there's https://github.com/overtone/at-at
11:01wildeyesLala
11:02xwildeyesHello?
11:02bbloomdnolen_: i spent > 2 days trying to fix that damn bug. today, i fixed it in 20 minutes
11:03bbloomPSA: take a fucking break everyonce in a while guys, debugging is mentally taxing & you need your beauty rest.
11:03hfaafbdoesn't necessarily mean those > 2 days weren't required :)
11:05bbloomhfaafb: i'll tell myself that so that i feel better about it, thanks :-P
11:05coventrybbloom: If only it were possible to grind away at a perplexing bug without getting frustrated, maybe it wouldn't be so taxing.
11:06tuddbbloom: state-transition, both in code and in person. Mix up your environment. put your computer somewhere else. change _something_ about your physical state. change in mental state follows. hard bugs become "obvious" how to fix.
11:08coventry(Didn't mean that as advice, don't know an easy answer.)
11:09xwildeyesGood thing clojures functional or mind perplexing would have been almost like a death sentence :p
11:09xwildeyesSay, who's here doing some cljs?
11:10jwmhehe quartz would take me a week to learn/use
11:18BobSchackxwildeyes I'm doing some clojurescript and the is the clojurescript irc channel
11:18devn,(require '[clojure.walk :as walk])
11:18clojurebotnil
11:19devn(map #(-> (zipmap ["a" "b" "c"] %) walk/keywordize-keys) (repeat 3 [1 2 3]))
11:19devn,(map #(-> (zipmap ["a" "b" "c"] %) walk/keywordize-keys) (repeat 3 [1 2 3]))
11:19clojurebot({:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1})
11:20devnwalk/keywordize-keys uses postwalk, postwalk consumes seqs "as with doall" -- does that mean the right hand side above will be realized with doall? no right? just each sub seq, right?
11:25coventry,(time (do (map #(-> (zipmap ["a" "b" "c"] %) walk/keywordize-keys) (repeat [1 2 3])) 1))
11:25clojurebot"Elapsed time: 0.145169 msecs"\n1
11:26coventry,(time (map #(-> (zipmap ["a" "b" "c"] %) walk/keywordize-keys) (repeat [1 2 3])))
11:26clojurebot"Elapsed time: 0.142967 msecs"\n({:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} ...)
11:26devnannnndd that is my answer
11:26devnthanks coventry
11:26devni cant brane gud today
11:41arrdemdevn: it's okay, just get some coffee and we'll be here when you can function again :D
12:03shiranaihitowhat's the most common mistake that causes an AbstractMethodError when trying to implement clojure.lang.IFn for a record? -It blows up from Compiler.eval() at fn.applyTo(..) .. do i need to somehow implement "applyTo" in addition to "invoke"?
12:03llasramshiranaihito: Yes -- when implementing IFn, you always need to implement applyTo
12:03shiranaihitohm
12:04llasramIt's not difficult to express in terms of your invoke implementations though
12:04shiranaihitollasram: alrighty, thanks :p and is there something special to implementing it? .. oh, so i can just delegate to "invoke" by calling the "this" given to applyTo?
12:05llasramyep
12:05shiranaihitook, cool, let's see..
12:05shiranaihitommm the explosion went away :P
12:06shiranaihitollasram: is implementing IFn a sign of trouble in general, though? .. or just business as usual?
12:07llasramIt depends on why you're doing it. In my experience it isn't common, but sometimes is really useful
12:08llasramUsually when I think "I'd like a thing which I can call as a function," what I really want is a function :-)
12:08shiranaihito:P
12:09shiranaihitowell, i've got a record that acts as a placeholder for a couple of values, and participates in a protocol, aaaaand now implements IFn
12:10shiranaihitoif i haven't done anything dirty, then i guess this is just a good example of why Clojure is awesome :P
12:10llasramIn your case, what's the benefit of the record also being a function vs producing closures over the records when you need them?
12:10shiranaihitoat least using it this way will result in neatness for what i'm doing
12:11shiranaihitoclosures over the records?
12:11llasramkk
12:11shiranaihito:P
12:11shiranaihitoyou're confusing me :p
12:11llasramOh, like (partial mk-my-record-fn record)
12:12shiranaihitobut the record kind of represents both "state" _and_ something to call.. it's supposed to act like a ring handler, and ofc, it's like a part of a web-application too
12:12llasramI see
12:12shiranaihitohmm, well, i guess i'll just continue and see how it goes.. looks promising so far
12:12shiranaihitothanks for the tip!
12:24btcNeverSleepshey all, I'm trying to learn macro and I want to try to write a macro which can take either 1 or 2 argument, but which should fail if there are 0 or 3 arguments passed to the macro. Is (defmacro sample [a & [b & c]] ...) the way to go?
12:25sirbtcNeverSleeps: or sir you could do two bodies, one with one arg, one with two
12:25sirbtcNeverSleeps: sir that would likely be the cleanest way
12:26btcNeverSleepssir: so macros, just like functions, can accept multiple arities?
12:26sirbtcNeverSleeps: yes sir
12:26btcNeverSleepssir: thank you sir!
12:26sirbtcNeverSleeps: you're welcome sir
12:27hyPiRionI thought #clojure suddenly turned extremely polite, then I realised sir is a nickname.
12:28btcNeverSleepsseems to be the nickname of someone extremely polite ^ ^
12:29sirbtcNeverSleeps: why thank you sir
12:29hyPiRionsir, your nickname makes everyone so polite. So magical.
12:30dkinzer:)
12:33btcNeverSleepsdoes this look correct to you: (defmacro sample ([a] `(uch ~a nil)) ([a b] `(do (println "a: " '~a " b: " '~b) ~a ~b))) (trying to write a macro with arity either 1 or 2, but not 0 nor 3+)
12:33btcNeverSleepsoops
12:33btcNeverSleeps(defmacro sample ([a] `(sample ~a nil)) ([a b] `(do (println "a: " '~a " b: " '~b) ~a ~b)))
12:33sirbtcNeverSleeps: seems right to me sir
12:34hyPiRionhumm, is Eastwood/some other linter able to detect poor usage of transients?
12:34sir-or-maambtcNeverSleeps: You can test it with commands like (macroexpand '(sample arg1 arg2 arg3))
12:36justin_smithhyPiRion: if they don't one would think it would be easy to add
12:37justin_smithhyPiRion: https://github.com/jonase/eastwood/search?q=transient&amp;ref=cmdform
12:38sirbtcNeverSleeps: only way to find out is to try it and see sir
12:38hyPiRionjustin_smith: hrm, doesn't look too comprehensive
12:38sirbtcNeverSleeps: also, try to never use macros
12:38sirbtcNeverSleeps: macros are almost never ever worth it
12:40justin_smithhttps://github.com/jonase/eastwood/blob/266a76732da84d829de21ab3e3ad50b50e826adc/resource/var-info.edn hyPiRion a search for ! in this ns finds the transient ops, plus "warn-if-ret-val-unused" on all of them
12:40justin_smithwhich should be what we would want
12:41justin_smith*in this resource edn file
12:41hyPiRionjustin_smith: That's part of it, but it should complain if I do e.g. (do (conj! a 1) (conj! a 2))
12:42justin_smithwouldn't "warn-if-ret-val-unused" complain about that?
12:42justin_smithor do I misunderstand that flag?
12:42hyPiRionjustin_smith: alright, perhaps this is a better example
12:42btcNeverSleepssir: I'm writing a macro which spawns a thread (consuming from a queue) which shall should stay active for the lifecycle of the app and which shall take care of logging should an exception happen (otherwise if I never deref the future I may miss the exception). So I need to "wrap" code in a try / catch block.
12:43hyPiRion(let [a (transient! #{1 2}) b (conj! a 3) c (conj! a 4)] [a b c]) is very bad
12:43btcNeverSleepssir: don't know if I should do it with a function or a macro
12:43justin_smithoh yeah...
12:43hyPiRionSo a linter should invalidate multiple transient calls on the same transient.
12:43justin_smithhyPiRion: that requires some higher order logic for sure - more than we seein in Eastwood I think
12:43sirbtcNeverSleeps: it'd be significantly better to write it as a function that takes a (possibly anonymous) function sir
12:43justin_smithright
12:43hyPiRionjustin_smith: probably
12:44hyPiRionI haven't looked too much at Eastwood, which is why I asked in the first place :p
12:44sirbtcNeverSleeps: the only legitimate reason for writing macros is to "extend" the language in an extremely generic and unspecific way, like ->> and -> do, for example
12:44btcNeverSleepssir: it'd be significantly better because macros would be avoided?
12:45sirbtcNeverSleeps: yes, macros are significantly less flexible than functions and should be avoided mostly.
12:45sirbtcNeverSleeps: the good news is that your original question still applies even to writing functions, so your learning this morning has not been in vain sir
12:45btcNeverSleepssir: it's late afternoon on this side of the pond sir! ; )
12:46justin_smithbtcNeverSleeps: it may help to ask yourself "will making this a macro offer anything a function wouldn't?" - if no, functions are simpler and easier to reason about and to use
12:46hyPiRion~UGT
12:46clojurebotUGT is Universal Greeting Time http://www.total-knowledge.com/~ilya/mips/ugt.html
12:46sirbtcNeverSleeps: ugt is intended to fix that, but which has flaws of its own
12:47sirUGT is the Go of sociality.
12:47btcNeverSleepsI like it, UGT looks nice.
12:47sirSo did Go.
12:47btcNeverSleepsso now I learned two things this morning!
12:47hyPiRionhehe
12:47hyPiRionIt's always morning on IRC
12:47sirSounds like a good time to call it a day and pack it up.
12:48justin_smith{{greeting-for time-of-day}} {{time-of-day}} everyone!
12:48Averellthis morning (ugt)?
12:49btcNeverSleepsback to my question: if I write a function (instead of a macro), then I now have to pass one (or two) function(s) as argument(s). Doesn't using functions instead of macros lead to code with lots of (anonymous) functions? (at least when your macro/functions plans to "wrap" code)?
12:50sirbtcNeverSleeps: yes, and that's good
12:50sirbtcNeverSleeps: anonymous functions are not that hard or ugly to create in Clojure, and very flexible too.
12:50hyPiRionnot sure what you mean
12:51hyPiRion,(defn foo ([a] (foo a 1)) ([a b] (+ a b)))
12:51clojurebot#'sandbox/foo
12:51sirbtcNeverSleeps: look at the API for compojure, it works almost entirely on anonymous functions
12:51sirbtcNeverSleeps: actually don't look at it
12:51hyPiRion,[(foo 1) (foo 1 2)]
12:51clojurebot[2 3]
12:52sirhyPiRion: sir he seems more concerned about it being verbose if he doesn't hide the creation of anonymous fns for the end-user
12:52hyPiRionoh right, in the macro he created
12:52btcNeverSleepsI'll give an example
12:52sirbtcNeverSleeps: use refheap.com sir
12:55btcNeverSleeps,(defmacro tm [code] (let [t (gensym)] `(try ~code (catch Throwable ~t (println "doing logging here")))))
12:55clojurebotbtcNeverSleeps: Gabh mo leithscéal?
12:55hyPiRionnot allowed, I'm afraid
12:55btcNeverSleepsmacros aren't allowed?
12:55hyPiRionnot in clojurebot
12:56btcNeverSleepsI see, I'll use refheap
12:56hyPiRionOr perhaps it's the try catch statement
12:56justin_smithbtcNeverSleeps: why not use & code / ~@code to allow an arbitrary body of expressions (which try already supports)
12:57justin_smithalso t# ... ~t#
12:58justin_smithand maybe (let [t# (gensym "ErrorCaught") ...
13:03btcNeverSleepshttps://www.refheap.com/78308
13:04btcNeverSleepsthe goal is both to solve my issue and to learn how (and when to use or not) macros ^ ^
13:06btcNeverSleepsI don't want to have to manually call try / catch and add specific logging code everytime I'll run producers / consumers that shall live for the lifecycle of the app
13:07btcNeverSleepsso instead of doing (future ...) I want to do something like (spawn-with-logging-if-exception-caught ...) [name is facetious], but which acts like a future, excepts that exceptions are transparently caught and logged
13:07btcNeverSleepsbecause I've had the case where exceptions in future would "magically" disappear (I've seen both blogs entries and talks about Clojure mentioning that "feature" )
13:07btcNeverSleepsfor example, at the REPL:
13:08btcNeverSleeps,(future (/ 0 0))
13:08clojurebot#<SecurityException java.lang.SecurityException: no threads please>
13:08btcNeverSleepsok well... at the REPL this give a "division by zero"
13:08btcNeverSleepsbut
13:08justin_smithbtcNeverSleeps: my suggestion for the macro (tested and works in my repl) https://www.refheap.com/78309
13:08btcNeverSleeps(future (do (Thread/sleep 1000) (/ 0 0)))
13:08btcNeverSleeps(future (do (Thread/sleep 1000) (/ 0 0))) <-- exception is now nowhere to be seen, magically disappeared once a small delay is introduced
13:09justin_smithbtcNeverSleeps: is this in emacs?
13:09justin_smithyou will see it if you have the repl running in a terminal (this is why I avoid the *-jack-in commands actually)
13:09sirIt's like I always say: use it up, wear it out, make do, or do without.
13:10btcNeverSleepsjustin_smith: yup, in Emacs
13:10justin_smiththere will likely be a *<foo>-messages* buffer that catches some if not all of that stuff
13:10btcNeverSleepsah damn
13:10justin_smithyeah, that is why I don't use the jack-in stuff - just connect to a repl in a terminal, the extra step adds clarity
13:11btcNeverSleepsjustin_smith: do you connect to a repl in a terminal from inside Emacs? (say from an eshell Emacs buffer) Or directly in a "real" terminal, without using Emacs for the REPL at all?
13:11justin_smithI start the repl in a terminal, and it opens a repl listener, I connect to that via emacs
13:12justin_smithsome things print in the emacs repl, some print in that terminal, but nothing goes missing (or so it seems)
13:12btcNeverSleepsjustin_smith: ah, that's interesting, so I do, say "lein repl" and then what do I need to do from Emacs?
13:12justin_smithdo you use cider or nrepl?
13:12btcNeverSleepscider
13:12justin_smithM-x cider
13:13justin_smithgive it the port name that lein repl printed
13:13btcNeverSleepsgotcha... cider, without -jack-in
13:13justin_smithyeah
13:13justin_smithbonus, you can kill emacs without losing the repl, and visa versa
13:13justin_smith(or more easily do these things)
13:14btcNeverSleepsI'll probably do that too from now on... In addition to that I'm using timbre/{debug,info,warn,error} logging for my app and have a terminal constantly doing a "tail -F logfile"
13:14btcNeverSleepsjustin_smith: sounds great, definitely trying it ASAP
13:14justin_smithyou can think of it as connecting the repl and editor, rather than trying to combine them (with all kinds of leaky abstraction); "decomplecting", as they say
13:15justin_smithbtcNeverSleeps: another option is that emacs has a tail mode
13:15justin_smithM-x auto-revert-tail-mode
13:15justin_smith(on the log file buffer, of course)
13:15btcNeverSleepsI like timbre's ANSI logging (for exceptions it is really quite clear and helpful, the colored output really helps). I also configured my Emacs / cider buffer so that ANSI escapes are converted to colors.
13:16justin_smithcool
13:16btcNeverSleepsjustin_smith: I'll check auto-revert-tail-mode too
13:16owl-v-I'm having some difficult time getting the concept of (lazy-seq)
13:17btcNeverSleepsowl-v-: takes some time to get used to, best is probably to try to write some and things should become clearer
13:17justin_smithowl-v-: it is the only way to create something lazy, as far as I know
13:19btcNeverSleepsowl-v-: funny that Rich Hickey's only answer on SO is about lazy seqs and doall: http://stackoverflow.com/questions/1641626/how-to-convert-lazy-sequence-to-non-lazy-in-clojure
13:19coventryowl-v-: You're not supposed to learn from clojure.core, but you might have a look at these functions: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2618
13:22coventryowl-v-: It's useful to take those and redefine them with (println)s in the beginnings of the functions and the (when) blocks and see how they behave as you take elements from the seqs they create.
13:28dbaschcoventry: btw, I solved my cljs config for dev/prod with different paths to config.cljs in profiles. I prefer avoiding macros for those things.
13:28dbaschin fact I prefer avoiding macros period :)
13:29coventryI have a weakness for macros, but that sounds like a good arrangement. :-)
13:29justin_smithdbasch: what we do is to have resources/config/production.clj resources/config/development.clj etc. (really they are edn files we should fix the naming0
13:29justin_smithand then a runtim var decides which config to load
13:29justin_smithso the same artifact can be run locally, on staging, or on prod
13:31dbaschjustin_smith: the problem is that for cljs you have one extra level of indirection
13:31justin_smithoh yeah, the artifact creation (and you may want to create a different js artifact based on config...)
13:34dbaschowl-v-: do the 4clojure exercises about lazy sequences, that forces you to learn
13:35sandwichmakerhttp://technomancy.us/161
13:35sandwichmaker*oops* sorry for that one, at least wasn't a password or a secret formula for success
13:36sirsandwichmaker: Yes you accidentally pasted that from #emacs sir.
13:37sandwichmakersir: yeah, I clicked the mouse wheel by accident after selecting the url you wrote there :)
13:38sirsandwichmaker: I don't use linux anymore so I don't have that happen anymore fortunately.
13:39justin_smithMiddle button paste is like my favorite thing. You may want to remap the scroll wheel button not to be button 2 though :)
13:39sandwichmakersir: lol , I can understand that, I continually switch between OSX and Linux. I love them both, I hate them both :(
13:39sirsandwichmaker: sir I feel the same way
13:40sandwichmakerjustin_smith: good advice
13:40justin_smithin .Xmodmap: pointer = 1 7 3 4 5 6 8 9 10 11 12 13 (not middle button is a back button in your web browser)
13:40justin_smith*now
13:40sandwichmaker:)
13:41justin_smithoh, sorry, 8 is the one for back in a browser
13:41justin_smithmutatis mutandis
13:41hyPiRionhaha
13:52owl-v-dbasch: thanks
14:02holohi
14:02holois there any way to build clojurescript on the REPL?
14:05holoI mean like lein cljsbuild once
14:06sirAre there any theories on the declining popularity of Clojure?
14:07sirPerhaps it could be due to Scala having a more familiar syntax and semantics to Java and Ruby than Clojure, which is more Lisp like and thus off-putting?
14:07hyPiRiondeclining? I thought it was steadily increasing, at least from what I gather from the Clojure surveys
14:07llasramsir: Yeah -- what suggests there is a declining popularity to Clojure?
14:08holoI converted a human to clojure recently :)
14:08mi6x3mhey clojure, I need some explanation about metadata
14:08gtraksir: I've never heard this argument :-)
14:08mi6x3mit is the var that caries the metadata, right?
14:08mi6x3mnot the symbol
14:08mi6x3mbut on the otherhand, the symbol is bound to the var
14:08amalloymi6x3m: i mean, you can put metadata on symbols and on vars. on lots of things, really
14:08mi6x3munless I miss something and there's a way to create a 2nd reference to a var
14:08mi6x3mamalloy: but is it the same?
14:09siramalloy: but not consistently, such as not any kind of seq, only some kinds
14:09hyPiRionScala came out earlier than Clojure, and they've been working more heavily on marketing Scala for the enterprise afaik. So it follows that it is more popular than Clojure right now
14:09amalloywell, only metadata on vars typically has stuff like :arglists, :tag, :added
14:09amalloythat's added by the defn macro
14:09llasrammi6x3m: I mean, if you use `def`/`defn`, at run-time the metadata ends up on the Var
14:09technomancyholo: what did you do with the body when you were done?
14:09llasram But you can p
14:09amalloybut you could in principle put it on a symbol too if you wanted
14:09llasramack
14:09hyPiRionAlthough I don't know if the growth decreases or increases relative to Scala's growth.
14:10mi6x3mamalloy: ok, I see
14:10amalloyand you can certainly have many symbols referencing the same var
14:10holotechnomancy haha :}
14:10mi6x3mso var and symbol are different in terms of metadata
14:10gtrakwe have 770 folks in the IRC channel here, and #scala has 470, just a data-point, maybe clojurists like IRC more :-)
14:10llasrammi6x3m: Well, when you have metadata on a symbol, it is on *that instance* of the symbol with a particular name
14:11technomancyholo: I'm imagining something like http://makerbot-blog.s3.amazonaws.com/wp-content/uploads/2012/06/TronTeleport.jpg
14:11mi6x3mllasram: symbols have instances?
14:11mi6x3mwat
14:11holoI heard rumours 2014 was the year that #clojure overcomes #ruby
14:11llasram,(identical? 'foo 'foo)
14:11mi6x3misn't a symbol just itself
14:11clojurebotfalse
14:11llasram,(identical? :foo :foo)
14:11clojurebottrue
14:12mi6x3mllasram: I see
14:12llasramTHat self-identity is what keywords are for, and is part of why keywords don't support metadata
14:12sirhyPiRion: Scala has a much more familiar syntax and semantics, being naturally imperative and line-based, with only a small part of functionality programming embedded
14:12Bronsami6x3m: unlike keywords, symbols are not interned.
14:12mi6x3mBronsa: but how come
14:12mi6x3mwhat is the motivation of this
14:12llasramWell for one thing it lets you have different metadata on different instances of a symbol :-)
14:12Bronsami6x3m: metadata
14:12gtraksir: you should try ruby, it sounds right for you.
14:13mi6x3monly this reason ?
14:13mi6x3minteresting
14:13Bronsami6x3m: I don't know of any other
14:13llasramgtrak: Hey, keep it clean. No need for insults
14:13sirgtrak: sir thank you for the suggestion it is not my intention to switch languages I am merely asking the question to provoke thought within the intellects
14:13sirgtrak: there is no better way to growth within the community continuous learning
14:15holothey invented the Continuous Integration, the Continuous Deployment, now the Continuous Learning. what next? :D
14:15mi6x3mBronsa: so evaluating "foo" creates a new instance of this symbol ?
14:17gtrakllasram: was curious if parkour can do sorts
14:17gtrakcursory examination said no.
14:18llasramgtrak: In what sense? Generally Hadoop sorts for you
14:18llasramThere's some tricks you can do to get what's called a "total order sort", which Hadoop comes with some utility classes to setup
14:19llasramI've never needed it, so have not yet integrated that into Parkour, but it should be usable via interop
14:19amalloymi6x3m: i mean, you have to be careful, because "foo" is a string, not a symbol. and if you actually evaluate the symbol foo, you get whatever the value of foo is in the current context. only when the reader reads the string "foo", or you evaluate 'foo, or you evaluate something like (symbol "foo"), is an instance of Symbol created
14:20gtrakah yea? maybe I'll give it a try. Just thinking through a problem, my experience is with cascading mostly, but I wouldn't use that to actually use hadoop :-).
14:20llasramgtrak: Cool. Feel free to ping me if you've got any questions
14:21gtrakthanks!
14:24tpopegtrak: :argslist-str should probably be "" rather than "nil" if there's no arglists
14:25tpopealmost opened an issue but I feel weird popping up in emacs land
14:26gtrakah, I can fix that :-)
14:26amalloytpope: there's no visa requirements at the border. you're welcome to visit
14:27gtraktpope: do you need the key to be there at all in that case? I bet that could happen for normal vars and namespaces.
14:27tpopenah
14:34tpopegtrak: I'm also wondering if you could provide a home for a "classpath" op, if I implemented it. you've already got a java.classpath dependency so it should be a trivial addition
14:35gtrakyea, that sounds reasonable
14:35tpopeawesome, it's my last significant eval
14:35tpopethe rest is just bs like require and macroexpand-1
14:36gtrakwhat do you use the classpath for?
14:37tpopegtrak: heuristically determining which repl connection to use, jump to source, and populating vim's 'path' option, which enables assorted built-in behavior
14:38bbloomtpope: you're practically a vim ambassador in the lisp embassy at this point. you should totally just go chill in #emacs
14:38gtrakah, interesting.
14:38bbloom(i know nothing about diplomats, i'm sure that makes no sense)
14:38tpopelol
14:40justin_smithalso you will have diplomatic immunity vs. any charges of trolling
14:40justin_smithif you get ambassador status, that is
14:41gtraktpope: ah, that's why you want the relative path.
14:41gtraknot sure we handle jump-to-def on remote repls, but it would need something like this.
14:43tpopeyeah admittedly it's still mostly a hypothetical for me. but I was thinking about this use case from the start
14:43gtrakso, you grab the classpath, and I'm guessing you could mirror it in the local maven repo? peel off the right prefix?
14:44gtrakthat's assuming the project is running in lein with maven classpaths.
14:44tpopegtrak: I guess you could, but right now I just ignore the classpath from any repl that appears to be remote
14:45gtrakyou'd be able to see the project's CLJ files, but nothing more in that case.
14:45tpopeand another plugin optionally provides a fallback of `lein classpath` if there's not a local repl
14:46gtrakah
14:47tpopeI figure the common use case is just to have an implicit local connection from .nrepl-port, and then any remote connection will shadow that for most things
14:51danno(def counter (agent 0)) \n (send counter inc) \n (println @counter) hangs when run on the command line
14:51dannoAny ideas?
14:51amalloyyour repl is broken, danno. that works fine
14:52dannoamalloy: not using REPL
14:52amalloyoh. you're talking about running that from the actual unix shell?
14:53amalloy$google clojure shutdown-agents stackoverflow
14:53dannoyes. ;)
14:53lazybot[clojure - Restart agent thread-pool after calling ... - Stack Overflow] http://stackoverflow.com/questions/2944900/restart-agent-thread-pool-after-calling-shutdown-agents
14:53amalloybah
14:53amalloy~shutdown-agents
14:53clojurebotCool story bro.
14:53justin_smith~agents
14:53clojurebotagents put it on a queue and call it George
14:53amalloyanyway, the point is thread pools are confusing
14:53dannoha.
14:54dannostill not using a REPL though.
14:54amalloydanno: agents have a thread pool, with threads that hang around for a couple minutes in case you have more work for them
14:54technomancyamalloy: wait, wouldn't thread pool shutdown just cause that to print zero?
14:54dannoit prints 0, but hangs
14:54amalloytechnomancy: no, the point is it's printing (either 0 or 1), and *then* hanging
14:54amalloyhe just didn't actually say that
14:54technomancyoh, well that's different then
14:54dannoyeah, that's right
14:54amalloyi had to use my psychic powers :)
14:54dannohaha
14:55llasramI love psychic debugging
14:55justin_smithcold reading is an art
14:55dannoIll try (shutdown-agents) even though I am not running on REPL
14:55dannonice
14:55dannothanks amalloy
14:55amalloyyou need to shutdown agents *because* you're not using the repl
14:55technomancyllasram: "I sense ... deep pain. I sense... using def inside a function definition. Such suffering."
14:56justinholguindanno: FWIW, I ran that code with lein exec and it exited after printing
14:56justinholguinno (shutdown-agents)
14:56amalloywhat's your *clojure-version*, danno? i don't recall having run into this problem in recent versions; maybe it's fixed?
14:56dannoamalloy: ohhhhhhhh
14:57dannoamalloy: clojure-1.7.0-master-SNAPSHOT.jar
14:57amalloywell, that's recent all right
14:57dannoI just fetch recent updates now and then from github and use that
14:57amalloywow, running from source?
14:57dannoamalloy: yes
14:58amalloylike, you can do that, but it sounds like a lot of work
14:58dannoamalloy: Not too bad. mvn clean package and go
14:58amalloysure, but why bother? lein is so much easier
14:58justin_smithclojure has some of the best dependency management in the programming world, so forgoing it is an interesting choice
14:59dannoI hadn't gotten around to that yet, picked up language in January
14:59dannojustin_smith: Just my maturity with the language at this point
15:00dannojustin_smith: Just learning right now, nothing where I require dependencies etc.
15:00justin_smithfair enough, IME lein will make things easier, with very few exceptions
15:00justin_smitheven if your only dep is clojure itself
15:00amalloyyeah, lein makes everything easier
15:00dannoI am sure if I am doing a project with dependencies, etc. lein would be where I first go to.
15:00technomancyeven without lein, not using a repl is pretty handicapping
15:01justin_smithdanno: even with only clojure as a dep, lein simplifies things (ie. lein jar / lein uberjar / lein check / lein test / lein compile ...)
15:01dannojustin_smith, amalloy, technomancy: Also this is my project: https://github.com/dhinojosa/language-matrix/tree/master/clojure
15:02dannoI am just using this as learning and creating small samples of 10 languages that I know, or are trying to learn
15:02technomancybut if you've only used the repl that ships with clojure I can see why you would think repls aren't worth bothering with =\
15:02dannotechnomancy: My interest is piqued.
15:02technomancydanno: part of the point of lisp is interactive programming
15:02dannoI like REPLs. I found that Clojure's doesn't have tab completion
15:02technomancya big part
15:03dannoAm I wrong?
15:03justin_smithdanno: lein repl has it, at least
15:03technomancyyeah, clojure's built-in repl is more of a proof-of-concept than something that people actually use
15:03justin_smithdunno about naked clojure repl
15:03llasramYou can wrap it in rlwrap, but there's usually little need to
15:03dannooh, I get the lein thing then
15:03technomancyjustin_smith: iirc the built-in one doesn't even have arrow support
15:03amalloyjustin_smith: the naked repl has like nothing. for all features x, clojure.jar's repl does not include x
15:04dannopart of its power is its repl
15:04amalloytechnomancy: right you are
15:04technomancyit's pretty stone-age
15:04llasramamalloy: Can it read, evaluate, print, or loop?
15:04justin_smithlol
15:04amalloyllasram: allegedly. i never manage to type in a form correctly on the first try, and i can't use readline or arrow-key stuff to edit, so i just give up before i finish a form
15:04dannoliasram: The basic REPL does that. My strength is with Scala and Java. Scala's REPL is pretty nice.
15:04llasramI'll agree it lacks literally all non-essential features of a REPL though :-)
15:05dannoI was comparing the Clojure Basic with Scala's.
15:05justin_smithdanno: also, ns-publics, clojure.repl/apropos, clojure.repl/doc and clojure.repl/source
15:05llasramamalloy: Haha. Good point.
15:05justin_smithare godsends
15:05dannoBut sounds like a better match would be with lein
15:05dannoI do love doc and source
15:05dannothat is fancy goods right there
15:06amalloyanyway, danno, neat project. now imagine if instead of a million little files with their own :main, it was one file you just load into your repl and type (for-example), eh?
15:06amalloyyou wouldn't have to keep tearing down and restarting the jvm and the clojure runtime
15:07dannoamalloy: I will look into that. (for-example)
15:07dannoamalloy: Not sure if I will go with that, because this project will have equivalent C, C++, Java, Clojure, Scala, etc.
15:07dannoand all that is command line, and don't expect anyone who finds value in it, to load lein
15:08amalloyi look forward to reading the equivalent MacroExample.java
15:08dannobut as someone who is interested in more of the language, I am interested in it for other projs.
15:08dannothanks amalloy
15:10dannoI think by end of May I will have most of what I need to know about Clojure in this cranium of mine. Ha
15:10justin_smithamalloy: (throw (UnsupportedOperationException.)) <- just translate this to java
15:16dannoSo another question to all: You work on clojure full time for a living?
15:16justin_smithyes
15:16rberdeendanno: not yet
15:17justin_smith(well sometimes I have to mess with devops and stuff but technically I am a clojure programmer)
15:17llasramdanno: Most-of-the-time. We have some mostly-legacy stuff in other languages, some devops, etc. But pretty much all new code in Clojure
15:17dannoVery interesting, I bet tons of fun
15:18justin_smithI would definitely consider myself spoiled for other languages for the most part, at this point
15:19dannojustin_smith: I would never consider a mutable preferred language anymore.
15:20tbaldridge+1 to that
15:20justin_smithagreed
15:20gtrakoiy.. yea, not sure what the next lang I'll learn will be, or when.
15:20tbaldridgeIf I had to pick a language other than clojure (and couldn't write my own), I'd probably pick F#
15:20gtrakelisp with reluctance..
15:20justin_smith(except those same special cases where I would use mutability in clojure: things with such great real time data processing needs that I truly need mutation).
15:20tbaldridgeit's static typed, but the syntax is so minimal that it approaches lisps in simplicity
15:21justin_smithtbaldridge: how would you compare it to OCaml?
15:21tbaldridgejustin_smith: I only know a minimal amount of OCaml, but F# is more OOP than OCaml.
15:22technomancyF# actually has concurrency, which is kinda great
15:22gtrakI've heard really good things about F#
15:22justin_smiththat is nice
15:22tbaldridgejustin_smith: it differs really only in interop syntax.
15:22technomancyI mean, depending on what you're doing
15:23justin_smithalso CLR language means better lib options via interop I assume (or at least better / easier integration of libs)
15:24justin_smithI tried to make OCaml bindings once upon a time - made the mistake of picking a lib that was implicitly mp which made a bunch of "this should really be working" type bugs happen.
15:27tbaldridgejustin_smith: yeah the interop story on the CLR is better if you have a static typed lang. Clojure on the CLR is...interesting due to the lack of type erasure.
15:29amalloytechnomancy: is there a lein profile that's active only when i'm connected via jack-in?
15:29amalloy(using swank still)
15:29technomancyamalloy: no
15:29llasramamalloy: !!!!
15:29amalloyllasram: i've tried nrepl/cider a few times. have not been impressed
15:29technomancyamalloy: you can change your command to lein with-profile +swank swank
15:29justin_smithhe's trying to win a long-haired-yak competition
15:30amalloyah, that makes sense. thanks
15:30technomancynp
15:30llasramamalloy: OOC what do you find is missing vs swank?
15:31gtrakamalloy: cider's getting a bunch of new features lately, we don't have a real release of it yet..
15:31technomancygtrak: no problem just use melpa
15:31llasramho ho ho
15:31gtrakgtrak: sure. :-)
15:31technomancythen instead of just having cider break, you can have everything break
15:31gtraktechnomancy: sure :-)
15:32gtrakdidn't I mention I was learning elisp reluctantly?
15:32gtrakthe package story is a massive headache.
15:32amalloyllasram: mostly i found the behavior around exceptions pretty intolerable
15:32technomancygtrak: it's really not that bad if you stick to stable releases
15:32technomancygtrak: it's the people who insist on "SNAPSHOT ALL THE THINGS" that cause the headaches
15:33amalloyi don't really remember the details; i always block it out of my mind, and re-discover what's wrong next time i reluctantly give it a try
15:33llasramamalloy: Huh. I have personally found no problems in that sphere
15:33gtraktechnomancy: yea, I feel like I've got little control over the packages at this point, but I am running melpa, everything's not updated all the time, though.
15:33technomancyamalloy: you have to turn on "actually display stack traces" for whatever reason, which is dumb. but once you do that it's ok.
15:34gtraktechnomancy: really I just want to see how many projects we can destroy by either making cider itself provide the needed functionality.
15:35gtraksorry, spurious either*
15:35technomancygtrak: code deletion is the best thing
15:36gtrakevery related or dependent project is still evaling clojure code.. either we need to define a real API for cider, or subsume/ignore them :-).
15:36gtrakon the elisp-side..
15:37technomancyreplacing slamhound.el with nrepl-discover.el was a pretty smooth process
15:37gtrakyea, I'd like to get there, I feel like I have a working understanding now.
15:54whodidthishow do i (distinct) a vector of maps by specific keys of the maps
16:03dbaschwhodidthis: what’s the use case? why can’t you just merge all the maps?
16:03dbaschwhodidthis: the obvious way would be to loop over the maps, keep a set of the keys and ignore maps for keys you’ve seen
16:04ivanis there a better way to do (-> policy (assoc :path (if (:path policy) (i/as-path (:path policy))))) without extending as-path over nil?
16:06bbloomivan: update-in and fnil ?
16:07ivanbbloom: thanks! I'll give that a try
16:10ivanfnil still calls f on the replacement value?
16:11bbloomivan: yeah
16:11bbloom(doc fnil)
16:11clojurebot"([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched."
16:11ivananything built-in that doesn't?
16:12bbloomivan: what about something like this...
16:13bbloom,(update-in {:x 1} [:x] #(and % (inc %)))
16:13clojurebot{:x 2}
16:13bbloom,(update-in {:x 1} [:y] #(and % (inc %)))
16:13clojurebot{:y nil, :x 1}
16:13ivanbbloom: aha, thank you!
16:16whodidthisdbasch: ignoring duplicate File's in cljs by file name and size because user added file objects arent going to be equal for the same files. but yeah probably better to check if duplicate before conjing those bad boys
16:28dbaschwhodidthis: do your maps have multiple, possibly overlapping keys?
16:31whodidthisim trying to find out duplicate-by-name-and-size from [{:name "a" :size 5 :file Obj} {:name "b" :size 6 :file Obj} {:name "a" :size 5 :file Obj} ...]
16:33dbaschwhodidthis: you could do (group-by keys maps) and then pick the first of each group
16:33rasmustowhodidthis: (group-by #(select-keys % ...) maps) maybe
16:34dbaschwhodidthis: yes, what rasmusto says if you want to restrict it to name and size
16:34whodidthisoh sweet, kind of like in sql
16:34whodidthisthank you
16:42arrdemBronsa: gsoc accepted I assume?
16:46Bronsaarrdem: yes, you too?
16:55tuftwhat projects are you guys doing?
17:00sdegutistuft: I'm working on work.
17:00sdegutistuft: it's a web app mostly written in Datomic
17:01sdegutistuft: with a lot of Compojure though too
17:34kenrestivomystery function. needs a name, and, also, does this already exist somewhere else in another library maybe? https://www.refheap.com/78333
17:38amalloykenrestivo: i think that's clojure.walk/walk
17:39amalloyclose to it, anyway
17:39coventryOnly does one level, though.
17:39amalloycoventry: so does walk
17:39coventryGood point.
17:40kenrestivohmm, i must have stolen the "outer"/"inner" terminology from walk
17:41kenrestivoi'll play around with it and see if i could replace that with walk, thanks.
17:42kenrestivotho, what i was trying to accomplish was to not have outer be a #(assoc-in % [:x] y), but rather to take all those as & args as a convenience
17:50tuftsdegutis: cool -- i was referring to arrdem and Bronsa's gsoc projects, but nice to hear. =)
17:50tuftsdegutis: i'm doing a hobby project with datomic. no front-end yet
17:51tuftsdegutis: one of my favorite features so far is passing seqs of triples as the dbval during testing, and verifying properties of the transaction returned. so much better than loading fixtures into some ORM thing and checking for side-effects.
17:52Bronsatuft I'll be working on porting the cljs analyzer to tools.analyzer & more work on tools.analyzer[.jvm]
17:53sdegutisOh.
17:53sdegutistuft: neat
17:53sdegutistuft: I had not even thought of doing that. I am testing side-effects.
17:54sdegutistuft: Have you written any blog post about this yet? It seems like a good alternative to how we do it now.
17:59tuftsdegutis: i should, there were gotchas and scant info involved
17:59sdegutis:)
17:59sdegutistuft: I'm sure the mailing list would love to hear when you've written it.
18:03tuftBronsa: cool. is this for static analysis of clojure code in clojure?
18:09Bronsatuft: the AST can be used for static analysis, yes, but also as a backend for compilers (tools.emitter.jvm being one)
18:11bbloomBronsa: s/backend/frontend ? middle end? IR?
18:11justin_smithjust watch 20 custom readers all targetting that ast come out as soon as that is done
18:11bbloom:-P
18:12hiredmanjustin_smith: seems unlikely
18:12Bronsabbloom: yeah definitely not backend. I always mix those.
18:13bbloomBronsa: back vs front is all a perspective thing anyway. analyzer can be the backend from the perspective of somebody's parser :-)
18:17tuftBronsa: moments later i'm coincidentally listening to dnolen mention you and explain more on cognicast #054 =)
18:17gtrakBronsa: hopefully it's just as easy to support auto-complete/info with the new analyzer..
18:18gtrakin a cljs repl
18:18Bronsatuft: baader-meinhof hits again
18:19gtrak(also looking forward to when we get a clj-in-clj repl :-)
18:22gtrakI hope cider-nrepl will support these in a unified way
18:30rasmustois this bad? I want a side-effecty function to output something to /resources so I can put it into an uberjar
18:31justin_smithso a side effect you want specifically during jar build time?
18:32rasmustojustin_smith: yeah, that sounds right
18:32justin_smithyou could add an injection to the :production profile in project.clj (or maybe there is a profile like "build")
18:33hiredmanrasmusto: it is easy to screw that kind of thing up
18:33justin_smithdefinitely easy to screw up, yeah
18:33hiredmanrasmusto: maybe look at https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md#hooks
18:33rasmustoa little more context: it's a bunch of edn files that are essentially a cache of some slurp+set calls
18:33technomancyrasmusto: can you write to target/classes?
18:34technomancythat gets put on the classpath and included in jars and stuff
18:34rasmustotechnomancy: I could. How is that different than resources + (resource "foo") ?
18:35technomancyrasmusto: it's already properly .gitignored, and it's easily exposed via the "clojure.compile.path" system property
18:35technomancyplus lein clean will nuke it
18:36technomancykeeping input paths segregated from output paths just seems like a good idea
18:36rasmustowhen/how should I output to target/classes? Right now I have code in a (comment) that does it :p
18:37technomancyI don't really know what you're doing with it
18:40arrdemBronsa: yep :D
18:40arrdemBronsa: dis gon b gud
18:40Bronsaarrdem: awesome!
18:41arrdemonly question is how much of Clojure I'm allowed to optimize out :P
18:45danlamannaanyone help me out with a dependency not seeming to be on my classpath with lein run? https://gist.github.com/danlamanna/11159002
18:49rasmustotechnomancy: when I run (System/getProperty "clojure.compile.path") in my uberjar it gives me nil, am I doing something wrong? (I know I'm going in circles a little bit)
18:50justin_smithdanlamanna: ns forms already have their require clause quoted
18:50justin_smithso you should take out the '
18:50justin_smithalso you probably want digest.core, or whatever ns digest defines
18:50amalloyif you have spare time, you should also murder the rascal who chose a single-segment namespace
18:50amalloyjustin_smith: no, i just checked, it's really digest
18:51justin_smithwell that's quaint
18:51amalloyhttps://github.com/tebeka/clj-digest/blob/master/src/digest.clj
18:51danlamannajustin_smith: you were right, thanks :)
18:51technomancyrasmusto: no, that's normal. if you run outside lein you need to set that stuff up yourself.
18:52justin_smithdanlamanna: "quote/digest__init.class " - that's how it parsed 'digest
18:52rasmustotechnomancy: ok, that's what I thought. Since /resources seems like a bit of a hack, I'll just set up a common directory to store my "cached" edn files
18:52justin_smithof course there is no ns called quote/digest so it won't find it
18:53danlamannajustin_smith: makes sense
18:53justin_smiththat gives me a terrible terrible idea to create a "quote" project, and fuck with people's heads by requiring it by using an extraneous '
18:55amalloyjustin_smith: quote.lincoln defines a string containing the gettysburg address?
18:55justin_smithhah
18:55arrdemamalloy: haha
18:56justin_smith(inc amalloy)
18:56lazybot⇒ 100
18:56rasmustofour__PLUS_7yearsago
18:56arrdem(inc rasmusto)
18:56lazybot⇒ 9
18:56justin_smithouch
18:56justin_smith(inc rasmusto)
18:56lazybot⇒ 10
18:57amalloyoh...oh dear. that joke is too bad
18:57rasmustobring on the decs
18:57amalloyi need to sit down
19:04arrdem,(symbol "quote.quote/'")
19:04clojurebotquote.quote/'
19:05arrdemjustin_smith: ^ get on this
19:06justin_smitharrdem: will do, lol
19:06justin_smiththat is so evil
19:08justin_smithhaha, I just got (require ''lincoln) to load the quote.lincoln ns - it feels so dirty
19:08arrdem(dec justin_smith) ;; you earned that
19:08lazybot⇒ 33
19:09arrdemterrible terrible person
19:09Bronsajustin_smith: that's.. horrible
19:09justin_smithI know!
19:09justin_smithbut it works
19:09arrdemI wish I didn't have homework so I could drown my horror at that require...
19:10rasmusto,(macroexpand-1 (quote (quote lincoln)))
19:10clojurebot(quote lincoln)
19:10justin_smithof course that will be full of macros that alter atoms and def inside defn...
19:10Bronsarasmusto: that works because of prefix lists in require
19:13arrdemjustin_smith: should make extensive use of this... justin_smith: should make extensive use of this...
19:13arrdemjustin_smith: https://github.com/fredericksgary/qubits
19:14justin_smithhah
19:14amalloyjustin_smith: i think ''lovecraft should contain (alter-var-root #'defmacro (constantly (fn [& args] `(quote ~(rand-nth '#{various lovecraftian horrors|)))))
19:14justin_smithouch
19:14amalloyor something like it, anyawy
19:14justin_smithyeah
19:15justin_smithmaybe ''necronomicon would be the better name for it
19:16amalloyor you could mutate one of the interned Number instances
19:17amalloyreally there are a lot of deep horrors you could put into a lovecraft library
19:18justin_smithindeed
19:19justin_smithstack traces generated using https://github.com/prismofeverything/zalgo
19:21rasmustoforgive me: z̷̼͖̰̜̣̗̝̞͚̹̪͛̂̚͟็็ạ̶̹͔็l̀̄͌̈̐ͫg̉̊̐͑ͮͦȏ̉̏̿̿ͩ̓ï̞̗͓̮̮͙̠͇̭͎͖̺͖̠̃̄̚็z̞̗͍̖̖̮͖̞̃͆̐͆͊̄̚็็็e͗ͣ̔ͣ
19:21arrdemjustin_smith: what have you done...
19:21amalloyhuh. clojurebot's sandbox allows you to actually do what i just said
19:21amalloy,5
19:21clojurebot2
19:21justin_smithwoah...
19:21amalloyi'll go put things back together now
19:23amalloyuhhhhhh, i can't put it back. 5 is 2 now. even if you add 1 and 4 you get 2. so there's no longer a 5 to reset 5 to
19:23amalloyhopefully clojurebot's regular sandbox-resetting takes care of that
19:23rasmusto,(dec 5)
19:23clojurebot1
19:23arrdemamalloy: what have you done...
19:23rasmustoseems to work
19:23arrdem,(+ 3 5)
19:23clojurebot2
19:23justin_smithrofl
19:23justin_smith,(= 5 2)
19:23clojurebottrue
19:23justin_smithROFL
19:23arrdemI don't even have a gif for this level of wat...
19:24justin_smith(inc amalloy)
19:24lazybot⇒ 101
19:24rasmusto,(range 6)
19:24clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
19:24arrdemAHAHAHAHA
19:24rasmustowhat
19:24arrdem(inc amalloy)
19:24lazybot⇒ 102
19:24justin_smithlol
19:24justin_smith(take 10 (range 6))
19:24justin_smith,(take 10 (range 6))
19:24clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
19:24arrdemamalloy: I want to see the source for this...
19:24arrdem,6
19:24clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
19:24arrdemWHAT THE hahaha
19:24amalloyoh, it's not hard. (let [field (nth (.getDeclaredFields Long) 3)] (.setAccessible field true) (.set field 5 2))
19:24rasmusto,7 ;plz?
19:24clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
19:24justin_smith,7
19:24clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
19:25amalloyi think i broke all the numbers when i tried to put it back together
19:25rasmustoah okay.
19:25arrdemwow.. that crowbar usage...
19:25danlamannait seems if an nREPL command (in emacs) isn't responding, there's no way to just C-c C-c out of it, huh?
19:25rasmustoC-c C-b iirc
19:25justin_smithclearly the 'adams ns will turn every number up to N into 42
19:26justin_smithdanlamanna: sometimes it takes a while, but for me C-c C-c works
19:26amalloyyou can try C-g too, in case it's client-side emacs code that's not responding
19:27btcNeverSleepsre all... I read a comment here previously about Emacs and stack traces "inside" cider: <technomancy> amalloy: you have to turn on "actually display stack traces" for whatever reason, which is dumb. but once you do that it's ok.
19:27btcNeverSleepsCan someone tell me how you turn on "actually display stack traces"?
19:29amalloyhiredman: is clojurebot's auto-reload going to reload java.lang as well, or just clojurey bits?
19:30XeHow do you import functions from another clojure file?
19:30XeSay I have main.clj and foo.clj
19:30gtrakXe: namespaces
19:30technomancybtcNeverSleeps: M-x apropos-variable cider.*stacktrace
19:31hiredmanamalloy: that is an interesting question
19:31Xegtrak: How do I use it once I have a namespace?
19:31gtrakXe: the (ns ..) form and (require ..)
19:31Xeso it would be
19:31gtrakhttp://clojuredocs.org/clojure_core/1.2.0/clojure.core/ns
19:31hiredmaninstead of trying to answer it I killed the evaluator service, and it got restarted, so *shrug*
19:32arrdemiiinteresting. tbaldridge, can I get a DL on the other accepted Lean Clojure project? we seem to be going for the same thing, unless his is atop the existing Java compiler.
19:32gtrakXe: here it uses :require [clojure.string :as str] http://clojuredocs.org/clojure_core/1.2.0/clojure.core/ns#example_527
19:36dbaschgtrak: as str… pretty unfortunate example
19:36gtrakdbasch: still works :-)
19:36gtrak(str ) is str, str/ is the ns
19:36arrdemyou didn't really want clojure.core/str anyway :P
19:36gtrakdoesn't it?
19:36justin_smith:as [str] will not make str unusable
19:37Xegtrak: what am I doing wrong? https://gist.github.com/2309529ee383916f2e7b
19:37arrdem,(require '[clojure.string :as str])
19:37clojurebotnil
19:37arrdem,(str 1 2 3)
19:37clojurebot"123"
19:37gtrakXe: I can't tell what that's supposed to do.
19:37arrdem,(str/capitalize "a")
19:37clojurebot"A"
19:37rasmusto,(str 5)
19:37clojurebot"5"
19:37Xegtrak: import the functions in constellation.atheme
19:37gtrakyour require looks fine but weird.
19:37Xewell it doesn't work
19:38gtrakXe: ah, you'll want to alias the ns, that's what :as is for.
19:38justin_smithXe: that is not how you do unqualified import
19:38gtrak:refer :all will import all the symbols, if that's what you need.
19:38justin_smithalso unqualified import is bad
19:38Xejustin_smith: then how am I supposed to do it?
19:38gtrak[constellation.atheme :refer :all]
19:38justin_smithwhich is bad
19:38justin_smith:P
19:39btcNeverSleepstechnomancy: thanks
19:39gtrakhey, I'm just handing out guns..
19:39gtrakfootguns
19:39justin_smithheh
19:39gtrakI need to make a lib called that..
19:40justin_smithit makes me imagine a foot with arms coming out (said arms having oversized biceps)
19:40gtrakfootgun - a utility library
19:40arrdemgtrak: you already have knr what more do you need
19:40gtrakyea, exactly.
19:40arrdemgtrak: knr is footgun
19:41arrdemgtrak: thinking of which... why the hell did you build knr
19:41gtrakI was satisfied with building it once I successfully crashed the JVM. but ztellman's vertigo is a completion of the idea.
19:41arrdemgtrak: I's cute and I enjoyed reading it... but what the hell
19:41Xegtrak: I see now, thanks
19:41gtrakarrdem: he also said the unsafe isn't much faster than bytebuffers..
19:42arrdemoooh boy
19:42arrdempart of me wants to start using both of these libraries
19:42arrdemand the rest of me likes not writing C
19:42gtrakknr doesn't actually work... I'm making a note on the githubs :-)
19:42gtrakit's half-completed
19:43justin_smithhey, half-complete knr, complete footgun, who would know the difference except for a few symbols and filenames?
19:43amalloygtrak: 1/2 completed is the same as 1/5 completed, actually
19:43arrdemvertigo is evil. I love it...
19:43arrdemamalloy: quiet you
19:43justin_smithlol
19:43jwmis it safe to do a for on a nil object?
19:43justin_smith,(for [a nil] a)
19:43clojurebot()
19:44gtrakamalloy: I think I'm missing something subtle there :-)
19:44gtrakor is it 80/20?
19:44arrdemalso gtrak. meajure is now a thing. you're entirely to blame for the name.
19:44gtrakhehe
19:44amalloygtrak: no, i was referring to my recent clojurebot hack
19:44justin_smithgtrak: search up for ,(= 5 2)
19:44arrdem,(= 5 2)
19:44clojurebotfalse
19:44arrdemgood. clojurebot is no longer horked
19:44rasmusto,(range 6)
19:44clojurebot(0 1 2 3 4 ...)
19:44rasmustowhere's 5????
19:45TEttingerrasmusto: ##(range 6)
19:45lazybot⇒ (0 1 2 3 4 5)
19:45justin_smith,5
19:45clojurebot5
19:45rasmusto:)
19:45TEttingerone of the bots trims output
19:45justin_smithwe were just kind of worried about 5 and hoping 5 was OK
19:45rasmustoTEttinger: gotcha, was making a reference to ,(= (dec 5) 1) earlier
19:45TEttingerheh wha
19:46justin_smithprobably the best clojure wat I have seen so far
19:47amalloyi figured out how i broke clojurebot the second time
19:47justinholguin,(= (dec 5) 1)
19:47clojurebotfalse
19:47justinholguinphew
19:47amalloyi was trying to set 5 back to 5, but instead i set 2 to 5. so looking up the third item in an array caused you to look up the sixth item instead. thus all the ArrayIndexOutOfBoundsException problems
19:47gtrakhow'd you do that in the first place? I didn't see it in the scroll-up
19:47TEttinger,(def 5 4)
19:47clojurebot#<CompilerException java.lang.RuntimeException: First argument to def must be a Symbol, compiling:(NO_SOURCE_PATH:0:0)>
19:48justin_smithanother good name for an intentionaly messed up lib would be angkor (named for the world's biggest Wat)
19:48amalloygtrak: it's not hard. (let [field (nth (.getDeclaredFields Long) 3)] (.setAccessible field true) (.set field 5 2))
19:48justin_smithgtrak: amalloy pasted it, by setting some properties of Long I think
19:48justinholguin(inc justin_smith)
19:48lazybot⇒ 34
19:48justin_smithoh, there it is again
19:48gtrakah, ye old integer cache
19:49justin_smithprobably will call for some new sandbox rules
19:49TEttinger(let [field (nth (.getDeclaredFields Long) 3)] (.setAccessible field true) (.set field (rand-int 100) 101))
19:49TEttinger,(let [field (nth (.getDeclaredFields Long) 3)] (.setAccessible field true) (.set field (rand-int 100) 101))
19:49clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Can not set final long field java.lang.Long.value to java.lang.Integer>
19:49TEttingeraw
19:49rasmustojustin_smith: glad someone else shares my taste for puns
19:49amalloyiit turns out you have to do a bit more work to set it back
19:50amalloy(let [five (long (int (+ (int 1) (int 4)))), field (nth (.getDeclaredFields Long) 3)] (.setAccessible field true) (.set field five (int (+ (int 1) (int 4))))) ;; actually worked to recover my repl
19:50rasmustoamalloy: is this idiomatic code?
19:50rasmustoer, does it at least show how to use java interop properly?
19:51TEttingerthere's nothing proper here
19:51arrdemrasmusto: do you see that crowbar? do you see it?
19:51arrdemrasmusto: that's almost as [good|bad] as the reader macros with crowbars hack
19:51amalloysure, just like carrying a chainsaw with you at all times is the idiomatic way to get into doors you really shouldn't be getting into
19:51gtrakarrdem: I also take credit for the name 'reagent'
19:52rasmustohrm, trying to grok the long/int thing
19:52hiredmanhttp://bldgblog.blogspot.com/2010/01/nakatomi-space.html
19:55TEttinger,(count (range 100))
19:55clojurebot94
19:55arrdemhiredman: interesting...
19:56rasmusto,(apply str (range 100))
19:56clojurebot"0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899"
19:56TEttingeraww someone fixed it
19:56jwmhehe took my 8 hours to write this function today in a functional manner
19:56jwmI so suck
19:56justin_smith,(count (range 100))
19:56clojurebot100
19:56jwm:)
19:56justin_smithjwm: maybe you are learning
19:57jwmI am
19:57jwmI only used one for in it
19:57jwmgot rid of ifs, another for
19:57rasmustoifs and for are functional
19:57amalloyjwm: 'for is great
19:58jwmmap is nicer I think
19:58gtrakfor is way better
19:58arrdemfor does really badly in -> tho...
19:58jwmI still use for but I got rid of like 7-8 lines of code
19:58amalloyit's context-dependent
19:58justinholguinYeah, in the functional hierarchy I think if is fairly low
19:59jwmthank god let takes multiple bindings :)
19:59rasmustojwm: for is cool when you need to unroll nesting
19:59justin_smithand also the _ idiom, if you need to sneak a side effect in
19:59justinholguin'for is great if you can't replace it with map or filter
20:00amalloyarrdem: i don't find that piling together great chains of ->> or -> makes anybody's code more readable. the fact that for isn't easy to fit into such a pipeline is perhaps a reminder that those pipelines aren't an end in themselves
20:00jwmI was wondering what _ did
20:00rasmustojwm: ##(let [_ 1] (inc _))
20:00lazybot⇒ 2
20:00rasmustoits just a normal symbol
20:00jwmahh figured it was
20:01jwmI used it for underscore in nodejs :)
20:01arrdem_ is just a symbol used for "I don't care about this value"
20:01jwmuntil I realized one of the functions was blasted by an internal usage in nodejs so I renamed it __
20:01arrdemI've seen (let [[a _ b _ c & rest] seq] ..) before..
20:01rasmusto,(let [$_ 1] (inc $_))
20:01clojurebot2
20:01amalloyspeaking of which, i was surprised to discover that haskell actually doesn't treat _ as an ordinary symbol. it's only valid in a pattern-matching context, not a value context, so this fails: let _ = 1 in _
20:02arrdemweird.
20:02jwm :v (triml (apply str (map (partial second) (filter #(= (first %) "Vehicle Name") parted))))
20:02jwmyou guys think you could make that shorter
20:02amalloy(partial second) => second
20:03jwmyeah that would be one thing :)
20:03jwmno, doesnt work
20:03hiredman(for [[k v] parted :when (= k "Vehicle Name"))] (str v))
20:03amalloyyeah. that
20:04jwmnice
20:04amalloysee how nice 'for is?
20:04justin_smith#(= (first %) "Vehicle Name") is (fn [[n]] (= n "Vehicle Name"))
20:04justin_smiththe later is a little nicer I think
20:04amalloyjustin_smith: i don't like the second one much at all
20:04amalloythe first is fine, or i'd write (comp #{"Vehicle Name"} first)
20:04jwmI just didnt want to use regex
20:04jwmprobably could do my entire program in one regex statement
20:07amalloythere are two things i don't like about (fn [[n]] (= n "Vehicle Name")). (1) it implies that there's only one item in the vector you're destructuring. obviously it doesn't *prove* that, but reading that code that would be my first guess. (2) it makes you pick a name for the first item in the tuple. that's fine, except that you picked a useless name like n, which suggests you'd rather not name it
20:08justin_smithfair points
20:09jwmwell the top of the code is 4 lines
20:09jwm (for [msg (mailspool :reports)]
20:09jwm(when (.startsWith (msg :subject) "MCO Alert")
20:10jwm(let [content (string/split-lines (.getContent (msg :message)))
20:10jwm parted (map #(split % #":") content)]
20:10rasmusto~refheap
20:10clojurebothttps://www.refheap.com/
20:10jwmhehe, sorry
20:10rasmusto<3
20:10jwmI figured 4 lines was below the barrier for that :)
20:11rasmustono, that's fine, just figured it'd be easier to paste the whole thing (and give readers some context or sample output)
20:11justin_smithit's polite to at least attempt to make it a one liner - we know how to make a four liner out of that if we are interested
20:12justin_smithalso, you could probably turn the when block into a :when in the for bindings?
20:14jwmwell, I am just doing this for chatting purposes.. I know it'll probably be another few months before I get decent at clojure
20:14jwmprobably a stupid idea to switch languages for a 2 week deadline on a big project
20:14jwmhaha
20:15jwmyou guys like the idea of using yyyymmdd dates for keys?
20:15jwmits temporary storage anyway
20:16justin_smith,(java.util.Date.) why not use this format?
20:16clojurebot#inst "2014-04-22T00:12:43.774-00:00"
20:16justin_smithit's what clojure already uses after all
20:20jwmyyyymmdd is the smallest/largest you can store a unique date in an int
20:20jwmwithout time of course
20:20rasmustofamous last words
20:20jwmits just habit
20:20dbaschI know all of you are desperate to base58encode / decode Bitcoin stuff. https://github.com/dbasch/base58/
20:22n_bWhy is a star required before the exception identifier in the following code (where the future throws an exception)? I've never seen it in Clojure code before and it doesn't seem to be mentioned in the Java interop or reader sections: http://stackoverflow.com/questions/9325492/why-does-clojure-wrap-checked-exceptions-with-unchecked-exceptions
20:22n_bOh, never mind. I see now. *e at the REPL refers to the last exception, right?
20:22justin_smithyeah, * is not special, it is just part of certain names by convention
20:23justin_smithsee also *1, *2, etc.
20:23justin_smith,*1
20:23clojurebot#<Unbound Unbound: #'clojure.core/*1>
20:23justin_smitherm...
20:23dbasch,*e
20:23clojurebot#<Unbound Unbound: #'clojure.core/*e>
20:23dbaschanyway, type *e into your repl
20:23justin_smith,*1
20:23clojurebot#<Unbound Unbound: #'clojure.core/*1>
20:23justin_smithyeah
20:24coventry,(throw (Exception. "Does this work?"))
20:24clojurebot#<Exception java.lang.Exception: Does this work?>
20:24coventry,*e
20:24clojurebot#<Unbound Unbound: #'clojure.core/*e>
20:24justin_smithI think clojurebot does not handle *{e,1,2,...} normally
20:24justin_smith,(pst)
20:24clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable>
20:25justin_smith,(pst)
20:25clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable>
20:25n_bYup, had a true facepalm moment when I clicked through to make sure it was the right link and realised it was all done at the REPL
20:26n_b*after* I had hit enter of course – I suppose there's an adage on how asking the question to yourself can avoid you bothering IRC floating around bash.org somewhere
20:26justin_smithsee also rubber duck debugging
20:27justin_smithhttp://en.wikipedia.org/wiki/Rubber_duck_debugging
20:28amalloyjustin_smith: well, he handles them semi-normally. it's just that those things are set! thread-locally, and he evaluates in a fresh dynamic context each time, i think
20:28justin_smithahh
20:28amalloyunlike in a repl, where you do everything inside the same top-level binding form
20:29justin_smith,(do 22 *1)
20:29clojurebot#<Unbound Unbound: #'clojure.core/*1>
20:29justin_smithoh that wouldn't work anyway, never mind
20:29amalloy,(do (set! *1 22) *1)
20:29clojurebot#<IllegalStateException java.lang.IllegalStateException: Can't change/establish root binding of: *1 with set>
20:30amalloyoh, he doesn't even bind it at all. that must be something clojure.repl does
20:30justin_smithin my repl: user> `*1 => clojure.core/*1
20:30justin_smith,`*1 actually
20:30clojurebotclojure.core/*1
20:31amalloyuh huh...
20:31justin_smithhmm
20:31amalloyi mean, those are indeed defined in clojure.core
20:31danlamannais it common to filter based on a list of functions? i.e. i have a list of items, they need to return true for every function in a list to remain in the list of items
20:31amalloybut the code for setting them lives in clojure.main
20:32amalloy(filter (every-pred f1 f2 f3) xs)
20:32justin_smith(doc every-pred) danlamanna
20:32clojurebot"([p] [p1 p2] [p1 p2 p3] [p1 p2 p3 & ps]); Takes a set of predicates and returns a function f that returns true if all of its composing predicates return a logical true value against all of its arguments, else it returns false. Note that f is short-circuiting in that it will stop execution on the first argument that triggers a logical false result against the original predicates."
20:32justin_smith,(doc every-pred) danlamanna
20:32clojurebot"([p] [p1 p2] [p1 p2 p3] [p1 p2 p3 & ps]); Takes a set of predicates and returns a function f that returns true if all of its composing predicates return a logical true value against all of its arguments, else it returns false. Note that f is short-circuiting in that it will stop execution on the first argument that triggers a logical false result against the original predicates."
20:32justin_smithoops
20:32amalloyhope you brought your galoshes, cause it's flooding in here!
20:33amalloythank you folks, the puns will be here all week. no need to applaud
20:40devnI wonder if something like claypoole could be brought into clojure.core at some point.
20:43amalloyi can't imagine that making it into clojure.core
20:44amalloya contrib library is more realistic, although i don't personally see the value it brings
20:45devnit brings value to pmap
20:45devnand has an unordered pmap
20:46devnpmap without control over threadpool size makes it less than useful in many of the situations people first set out to use it
20:47nDuffwhew!
20:48jwmwatch is pretty cool
20:48justin_smithjwm: like the unix command, or add-watch?
20:48coventrynduff: What happens?
20:51amalloydevn: for sure, pmap is pretty useless. but i don't think the answer is a version of pmap with purportedly-better defaults, it's to understand what's going on
20:51nDuffcoventry, a race condition wherein the last element fed into a channel going through a mix can be lost when the function doing the writes, on exit, calls close! on the mix's output channel --- which surprises me since all channels involved are unbuffered, so I'd expect the writes to block.
20:52nDuffOhh. Now that I'm explaining it, I see what's going on...
20:52justin_smith(inc rubberduck)
20:52lazybot⇒ 1
20:53nDuff...there's actually some computation going on in the pipeline between input channel and the mix, and that's where the relevant behavior is coming from.
20:53nDuff...question now is how to fix it, while still closing my output channel on completion.
20:54nDuffIf a mix could be configured to close its output channel after all input channels were unmixed, that would solve the problem nicely. :)
20:57nDuff(hmm; strikes me as a reasonably straightforward patch...)
21:00haolehow do I change Clojure's classpath? in my environment it seems to be ignoring the -cp argument passed to Java
21:00haoleI've asked it to print the classpath with the following snippet: (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))
21:00gfrederickshaole: how are you starting clojure?
21:01haolebut I get only a single dir there, which is clojure's .jar dir
21:01haolegfredericks: java -cp /my/classpath/dir -jar clojure.jar <myprog.clj>
21:01gfrederickshaole: I think -jar precludes -cp
21:01amalloygfredericks: right
21:01gfrederickstry java -cp /my/classpath/dir:clojure.jar clojure.main <myprog.clj>
21:02amalloyhaole: lein is way better at starting clojure than you are, or i am. it's easier, even for projects that don't need exciting dependencies managed
21:02jwmjustin_smith: add-watch
21:02jwmI added a watch to my main ref a few days ago
21:02jwmstill running strong :)
21:02gfredericksclojurebot: leiningen is better at starting clojure than amalloy is
21:02clojurebotOk.
21:03haoleamalloy: lein seems nice indeed but I'll have to collaborate with vanilla Java devs so I'm starting with Maven
21:03haolewill probably migrate to lein as soon as I get all the pieces together
21:03amalloywell, note that lein cooperates with maven. it fetches deps from ordinary maven repos, and so on
21:03gfredericksI support haole's desire to know wtf is going on
21:04haolegfredericks: heh yeah
21:04justin_smithand creates artifacts maven can use and find etc.
21:04amalloyclojurebot: amalloy |can| probably pass the turing test
21:04haolegfredericks: I've tried the following command without success: java -cp "/home/user/.m2/repository:/home/user/sources/clojure:clojure.jar" clojure.main tutorial.clj
21:04clojurebotc'est bon!
21:04haoleI it complains that it can't find clojure.main
21:04amalloyhaole: putting .m2/repo in your classpath isn't going to help - you need individual jars on the path
21:05haoleouch
21:05amalloygive the full path for clojure.jar, and you'll find it
21:05haoleyeah, it worked now... I guess this is one of the reasons lein exists
21:07haolemaven is pretty nice too! I've been able to put a lot of really dumb programmers to help me with some project in like 5 minutes lol
21:07haolewith a private repo and easy IDE integration
21:08gfredericksI don't know if I've ever had the thought "I could get this project done in time if only I had a lot of really dumb programmers"
21:08technomancygfredericks: maybe it's time to try a new tactic
21:08justin_smithgfredericks: spoken like someone with a limited supply of monkeys
21:09coventryhaole: Curious what sort of application you're developing.
21:10haolegfredericks: the idea is to get them to not be so dumb in the future... maybe dumb is a strong word... I meant beginners :)
21:10haolecoventry: artificial intelligence
21:10haolehence lisp :)
21:10amalloyjustin_smith: i read a story a little while ago about someone who actually gave typewriters to a bunch of monkeys
21:10coventryhilarious!
21:11gfrederickshaole: very good; I'm a big user of dysphemisms myself
21:11justin_smithamalloy: that actually sounds interesting, I am sure it at least led to some good photos
21:11gfredericksamalloy: was this some popular science gimmick?
21:11amalloymostly they got four pages of "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", and then a lot of monkey urine, followed by smashed typewriters
21:12gfredericksI wonder if the most likely monkey-shakespeare scenario involves the keys accidentally getting pressed while the monkey smashes the typewriter
21:12amalloyhttp://www.theguardian.com/uk/2003/may/09/science.arts
21:12bbloomamalloy: 6 monkeys is a long long way away from infinite
21:13bbloomamalloy: what did they expect?
21:13amalloybbloom: well, given an infinite amount of time 6 is fine
21:14gfrederickshttp://bottledchicken.blogspot.com/2008/07/scientific-discoveries.html
21:14amalloygfredericks: wait what is the deal with the links on that page?
21:15amalloyis this some weird joke?
21:15coventryhaole: Are your collaborators are basically entering a lot of domain-specific knowledge, or something like that?
21:15gfredericksamalloy: this was me six years ago
21:15gfredericksamalloy: so...yes?
21:16amalloyhumor is ever inexplicable
21:16gfredericksamalloy: I'd forgotten all about the links; mostly I just remember "The MacBeth Exception" being rather catchy
21:24amalloyit's always exciting for me when i forget that `cat *.csv > combined.csv` doesn't do what i want
21:25dbaschamalloy: what did you expect?
21:26amalloydbasch: to concat together the N csv files currently in a directory together
21:27bbloomheaders get in the way? :-/
21:27ravalsHello - I’m having trouble using clojure.contrib/mock. I’m trying to mock out a function call use expect, line 11 here: https://gist.github.com/sidraval/11162258 — I’m getting a “Can't dynamically bind non-dynamic var: gol-clojure.core/sum-excluding-middle” error when I run lein test. Would love some help :)
21:27amalloybbloom: no, try it and see! this command, run in a directory with 1 or more nonempty CSV files, will consume all available disk
21:28amalloyi had actually written `(for f in *.csv; do tail -n+2 $f; done) > combined.csv`, because i'm clever and thought about headers already
21:28bbloomamalloy: you're saying the cat resolves the * after the > creates it?
21:28bbloomamalloy: i'm skeptical....
21:28amalloymaybe the simpler version with cat doesn't break. it does do something weird, as i recall
21:29danlamannacan i inspect the result of a function that returns a function? by inspect i mean "view source"
21:29amalloybut if you use this subshell/for thing, you definitely cat a file into itself
21:29bbloomamalloy: yeah that's b/c the pipe is evaluated before the subshell call
21:29bbloomit's not an issue w/o a subshell
21:29amalloyyeah
21:30amalloyi take it back, everyone, unix is still smarter than me
21:31bbloomamalloy: why did you do the subshell thing at all?
21:31amalloybbloom: what if you create a file foo.txt containing foo, and then run `cat foo.txt>foo.txt"? on linux that complains, but i vaguely recall that maybe bsd/osx let you do it?
21:31coventrydanlamanna: Not really. E.g., if you want to know exactly what (partial myfn) is doing, you have to go look at the source for partial and piece it together from that.
21:31bbloomwhy not just put the > on the tail line?
21:31bbloomuse >>
21:32bbloomamalloy: i get "file exists" complaint
21:32dbaschjust do (for f in *.csv; do tail -n+2 $f; done) > foo ; mv foo combined.csv
21:32bbloombut that's a shell config if i recall
21:32bbloomnoclobber
21:32amalloybbloom: >> would have been fine, but it felt more natural to build one stream with all the output rather than N streams with some of it
21:33amalloystill thinking functionally, even in the shell
21:33bbloomamalloy: well that's your mistake right there
21:33bbloomyou expected your shell to be natural
21:33bbloomtisk tisk
21:36dbaschI must be the only person working on cryptocurrency stuff in Clojure, there’s almost no bitcoin code out there
21:36coventryThere was someone talking about it here a few months ago. I think they wanted to make a BTC client.
21:38coventrydobry-den.
21:39dbaschfound it: http://clojure-log.n01se.net/date/2013-11-08.html
21:41arrdemdbasch: why do anything in Clojure when you can just use bitcoin-rpc
21:41arrdemdbasch: or dogecoin rpc, or shitcoin rpc
21:41dbascharrdem: I built my site/app in Clojure
21:42dbascharrdem: the actual communication with the daemon was the trivial part, building the rest of the application is the work
21:42arrdemdbasch: I hear you there..
21:42dbascharrdem: here it’s what I have so far https://cointipping.com
21:49danlamannatrying to write a function which returns a function to be passed to filter, produces 0 results though, perhaps i'm doing it wrong? https://gist.github.com/11162744
21:50bbloom,(= "-" \-)
21:50clojurebotfalse
21:50bbloom,(class "-")
21:50clojurebotjava.lang.String
21:50bbloom,(class \-)
21:50clojurebotjava.lang.Character
21:50bbloomdanlamanna: ^^
21:51bbloomdanlamanna: also: ##(doc int)
21:51lazybot⇒ "([x]); Coerce to int"
21:51bbloomdanlamanna: and ##(doc alength)
21:51lazybot⇒ "([array]); Returns the length of the Java array. Works on arrays of all types."
21:52danlamannabbloom: i see where i messed up with = and int, where would alength come into play?
21:52bbloomdanlamanna: instead of .length
21:52danlamannabbloom: oh .length is java io file .length
21:52danlamannabbloom: as in, the length of the File object in bytes
21:53bbloom,(map #(get {\- <, \+ >} (first %) =) ["+1 "2" "-3"])
21:53clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
21:54bbloom,(map #(get {\- <, \+ >} (first %) =) ["+1" "2" "-3"])
21:54clojurebot(#<core$_GT_ clojure.core$_GT_@54919e> #<core$_EQ_ clojure.core$_EQ_@84fa6a> #<core$_LT_ clojure.core$_LT_@1abb81e>)
21:54bbloomdanlamanna: you can avoid repeated the majority of the code by doing something like:
21:55bbloom,(defn size-filter [size-str] (let [cmp (get {\- <, \+ >} (first size-str) =)] (fn [f (cmp (alength f) (int (rest size-str)))))
21:55clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
21:55bbloom,(defn size-filter [size-str] (let [cmp (get {\- <, \+ >} (first size-str) =)] (fn [f (cmp (alength f) (int (rest size-str))))
21:55clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
21:55bbloombut you get the idea
21:55bbloom,(Integer/parseInt "123")
21:56clojurebot123
21:56bbloom,(Integer/parseInt "+123")
21:56clojurebot#<NumberFormatException java.lang.NumberFormatException: For input string: "+123">
21:56bbloomwhoa weird, that works locally
21:56bbloom,(Integer/parseInt "-123")
21:56clojurebot-123
21:56bbloom,(Integer/parseInt "+123")
21:56clojurebot#<NumberFormatException java.lang.NumberFormatException: For input string: "+123">
21:58TEttingerclojure's number parser has mo' powah ##(print 36rZAMBONI)
21:58lazybot⇒ 76829540238nil
21:59bbloomwat
22:00bbloomi guess i shouldn't be surprised that clojure's reader is too permissive
22:01arrdemhttp://i3.kym-cdn.com/photos/images/newsfeed/000/615/442/089.png
22:02beamsoangry doge
22:04nightflySearching for SDL on clojars gives nothing, are there really no useful SDL/OpenGL wrappers?
22:05TEttingerbbloom, it is useful for stuff like ##(print 2r1111)
22:05lazybot⇒ 15nil
22:05TEttingernightfly, sure. take a look at play-clj if you're doing idiomatic clojure game dev
22:05bbloomTEttinger: oh yeah, duh. i misread that as the RADIX was zamboni
22:05bbloomheh
22:06bbloomnightfly: LWJGL is mostly static methods, so it's pretty straightforward to use from clojure directly
22:06TEttingerindeed, play-clj I think is a nice wrapper around the java bits of LWJGL
22:07nightflyTEttinger bbloom awesome! ty
22:07TEttingererr I was mistaken
22:08TEttingerit's a wrapper around libgdx, which wraps lwjgl
22:08TEttingerso many acronyms
22:08bbloomso many wrappers
22:09TEttingerwhich wraps OpenGL yes
22:09TEttingerbut play-clj is all well-documented pretty much
22:09TEttingershould get better now that libgdx is stable at 1.0
22:10TEttingeralso, nightfly: #lispgames has some good tips I bet
22:21jwm(mailspool :reports first read-message :body second :body slurp pprint)
22:21jwmI love macros
22:21jwmhehe
22:22Pupnikthere is also this handy play-clj video https://www.youtube.com/watch?v=9ilUe7Re-RA
22:36zspencerIs there an "opposite" of get-in
22:36zspencerI.e. (foo :key :key :key map)
22:37arrdemwat?
22:37arrdemzspencer: clarify input and output please
22:37zspencerI'm doing (get-in map :key-a :key-b) to get the nested hash-maps key-b
22:37zspencerI want something that reverses the order of inputs
22:38zspencer,(get-in { :foo { :bar 5 } :foo :bar)
22:38clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
22:38zspencer,(get-in { :foo { :bar 5 } } :foo :bar)
22:38clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword>
22:38zspencer,(get-in { :foo { :bar 5 } } [:foo :bar])
22:38clojurebot5
22:38zspencersorry my syntax is horrible
22:38zspencerI want ,(get-from [:foo :bar] { :foo { :bar 5 } })
22:39arrdemwhy....? -> is for solving that problem
22:39arrdemor as->
22:39zspencermore for readability than anything
22:39zspencerIt's for a test where I'm ensuring that this and only this attribute has value x
22:39arrdem,(defn rget-in [ks m] (get-in m ks))
22:39clojurebot#'sandbox/rget-in
22:39arrdem~next
22:40arrdemstill ignored by bots. right.
22:40zspencerso nothing built in for reversing arguments?
22:40arrdemnope.
22:40zspencerk
22:40zspencerclojure is wide as hell. So many things I don't know exist.
22:42zspencer(inc arrdem)
22:42lazybot⇒ 24
23:13leif-pHi. Any Storm users around?
23:16beppuhttps://github.com/apache/incubator-storm ?
23:17fowlslegsWhat is the easiest modification I can make to https://github.com/weavejester/crypto-random/blob/master/src/crypto/random.clj if I want to generate 512-bit strings?
23:17arrdem,(/ 512 8)
23:17clojurebot64
23:18arrdemfowlslegs: just kick out 64 random bytes
23:18arrdemfowlslegs: no library hacking required
23:20fowlslegsarrdem: I guess I meant to ask how I can get that into a binary string.
23:22leif-pbeppu: yes
23:23dbaschfowlslegs: what do you mean by a 512-bit string?
23:25fowlslegsdbasch: I'm not familiar with working with binary strings/ byte arrays. I'm essentially trying to generate 512 random bits, which I want to split into 16 32-bit words.
23:26arrdemokay... so just generate 16 random ints from the getgo
23:26dbaschfowlslegs: from that library, just do (bytes 32)
23:27fowlslegsThe only function I found was Integer/toBinaryString and that produces variable length results instead of consistently 8-bit strings
23:27dbaschfowlslegs: that’s 512 random bits
23:27dbaschbtw, do you need them to be cryptographically strong?
23:30fowlslegsdbasch: Yes.
23:30dbaschfowlslegs: (partition 4 (crypto.random/bytes 32))
23:32dbaschfowlslegs: although, given that you’re not familiar with binary strings and need cryptographically strong bits I have to ask
23:32dbaschwhat are you really trying to do?
23:32arrdemdbasch: openssl implementation
23:33fowlslegsEvolve a compression function for a cryptographic hash function.
23:34arrdemwat.
23:34dbaschfowlslegs: are you creating your own cryptographic hash function?
23:35fowlslegshttp://www.seg.inf.uc3m.es/papers/2008recsi2.pdf
23:37dbaschis that for fun, or do you have a specific application in mind?
23:39fowlslegsFun. I wouldn't use a cryptographic hash I made myself.
23:41fowlslegsWith (partition 4 (crypto.random/bytes 64)) I still have the problem of how to implement bit-xor on two of the 16 32-bit words.
23:42fowlslegsWait maybe (map bit-xor (25 ...) (-112 ...)) would work.
23:43fowlslegsYup.
23:44fowlslegsI'm a bit rusty with Clojure, I'll try to search/ remember before asking another easy question.