#clojure logs

2016-04-02

00:07deepakprasannaHow can I create a lazy sequence containing all the combinations of 0, 1 and 2?
00:07deepakprasannaLike this
00:07deepakprasanna(0 1 2 00 10 20 01 11 21 02 12 22 000 100 200 010 110 210 020 120 220 001 101 201 011 111 211 021 121 221 002 102 202 012 112 212 022 122 222 0000 1000 2000
00:07deepakprasanna.....
00:07Z3nnYin wich language ?
00:07Z3nnYand for wht
00:43troydmis it faster to conj! each element of vector or list performance wise into transient vector?
00:45troydmalso is there a macro that will expand (into! trans [a b c]) into (conj! ((conj! (conj! trans a) b) c) ?
01:28backnforthHi
01:28backnforthHow do I use the repl to run a project?
01:31backnforthi thought it was simply to use the command "lein repl" inside a projects directory
01:35TEttingerbacknforth: to run an application from source you can use lein run, which needs a -main fn defined and specified in project.clj
01:36TEttingerlein repl lets you interactively run fns
01:36backnforthI've used lein repl before to act as lein run but removing the main fn from the project.clj
01:36backnforthi just cant remember how lol
01:37TEttingerI mean, at the repl you can call (-main)
01:37TEttingerit's just a fn (Clojure catchphrase)
01:37backnforth"run -main" ?
01:37TEttingerhm?
01:37backnforthhow so?
01:37TEttingerno, I mean if you have a repl running, you can run main since it's a normal fn
01:37TEttingerhave you used the repl before?
01:37backnforthvery little
01:38backnforthi understand that its great for fn functions
01:38backnforthbut i dont know how to call a projects function with it
01:39backnforthI know I would have to start off with the command "lein repl"
01:39TEttingerdo you mean at the command line, before you get into the repl?
01:39backnforthand thats while im inside the projects directory
01:39backnforthbut i dont know what command to use in the repl
01:39TEttingeroh, the repl is all clojure code
01:40TEttingerthere aren't special commands, really.
01:40TEttingertry this in the repl
01:40TEttinger(println "Hello!")
01:40TEttingershould print the string you gave it and also print nil at the end, where nil is just what println returns
01:42backnforthTEttinger, yes i understand that
01:42backnforthi love that about the repl
01:42TEttingersince -main is a fn, if the repl loaded the same ns as the ns main is in, you can just type (-main) to call it with no args. if you aren't in the same ns, you can use or require the ns that has -main
01:42backnforth,(require ns.core)
01:42backnforthlike that?
01:42clojurebot#error {\n :cause "ns.core"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: ns.core, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.ClassNotFoundException\n :message "ns.core"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[java.net.URLClass...
01:42TEttingerrequire allows you to add :reload at the end of the args, too
01:43TEttingerheh, clojurebot doesn't have your code, but almost
01:44TEttinger(require '[ns.core]) is how I think it expects it, but there's also (require '[ns.core :reload]) for when you changed the code and want to update the code in the running repl
01:44TEttingerI might have the syntax wrong
01:44TEttingerjustin_smith!
01:45backnforth(require 'ns.core) worked for me :D
01:45backnforththis is excellent
01:45backnforthThank you TEttinger
01:46TEttingerwoo, glad it works!
01:46backnforthi feel "repl"ed
01:46backnforthits great
01:56backnforthHey TEttinger
01:56backnforthHow do I go about running the main function afterwards?
02:00TEttingeris it called -main in ns.core?
02:00TEttingerif you required it, I think (core/-main)
02:03backnforthI get a file not found exception with (require 'ns.core/-main)
02:04backnforthand im using the right ns lol
02:06backnforthFileNotFoundException Could not locate _main__init.class or _main.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name. clojure.lang.RT.load (RT.java:456)
02:07backnforthbut it works when i remove /-main
02:07TEttingereh?
02:07TEttingerno, you don't require a fn
02:08TEttingeryou require the whole ns, it has the fn in it
02:08TEttingerthat should let you call -main with either (ns.core/-main) or something else if yous used require with :as
02:08backnforthoh lol
02:08backnforthohh ok
02:08TEttingerI forgot the ns. part
02:09TEttinger,(require '[clojure.string :as st :reload])
02:09clojurebot#error {\n :cause "No value supplied for key: true"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No value supplied for key: true"\n :at [clojure.lang.PersistentHashMap create "PersistentHashMap.java" 77]}]\n :trace\n [[clojure.lang.PersistentHashMap create "PersistentHashMap.java" 77]\n [clojure.core$hash_map invokeStatic "core.clj" 387]\n [clojure.core$hash_map doInvoke "...
02:09TEttingerhm.
02:09TEttinger,(require '[clojure.string :as st] :reload)
02:09clojurebotnil
02:10TEttinger,(st/join ", " (range 5))
02:10clojurebot"0, 1, 2, 3, 4"
02:11TEttinger,(require '[clojure.set])
02:11clojurebotnil
02:11TEttinger,(clojure.set/union #{:a} #{:b})
02:11clojurebot#{:b :a}
02:13backnforthaha
02:13backnforthit works
02:14backnforthThanks TEttinger
02:14backnforthi'm logging off now.
02:14TEttingergreat glad it works
02:14backnforthgn
03:43deepakprasannaI have a function which spits a very long output on the repl.
03:43deepakprasannaHow do I silence the output?
03:43deepakprasannaI want to measure the time, using (time expr).
03:43luma(time (f) nil)
03:43deepakprasannaI tried (time (do (expr) nil))
03:44deepakprasannaluma: Thanks mate.
03:44lumaright, it needs the (do ..)
03:44lumatime only takes one expression
03:44lumaso (time (do (f) nil))
03:44lumaso it returns nil
03:45deepakprasannaluma: ArityException Wrong number of args (2) passed to: core/time clojure.lang.Compiler.macroexpand1 (Compiler.java:6636)
03:45deepakprasannaluma: If I wrap it with (do ...), the expr is not getting evaluated.
03:46lumado evaluates all the expressions inside it
03:46lumais your function returning a lazy sequence?
03:46lumaif it is, try (time (do (doall (expr)) nil))
03:50deepakprasannaluma: Worked, thanks,
04:16narwhal01guys what is the best way to remove maximum key from map?
04:19narwhal01apply max on keys
04:19narwhal01got it
04:19lumawhy do you want to remove the maximum key?
04:20dysfunwhat you probably want is an ordered map and to remove the *last* key
04:20ridcullyfind it and dissoc it
04:24ane,(let [m {12 :a 99 :b 3 :c}] (dissoc m (apply max (keys m))))
04:24clojurebot{12 :a, 3 :c}
04:30kwladykaDid you do OAuth 2 server / client / resource app and can share some experience with me about solutions?
04:37kwladykaIs any good quality solution in Clojure or i should looking in Java?
04:38kwladykaI found mainly 2 solutions https://github.com/pelle/clauth and https://github.com/ddellacosta/friend-oauth2 but i feel something is wrong with them. Just some intuition, but maybe i am in mistake :)
04:39dysfuni've used friend, though not with that plugin and it's alright
04:40kwladykadysfun you use https://github.com/cemerick/friend without https://github.com/ddellacosta/friend-oauth2 ?
04:41dysfunyes
04:41kwladykaand works like that: client <-> authorisation app ; client <-> resource app without any problem?
04:41kwladykado you this on github?
04:42dysfunno, i'm merely saying 'friend is alright' and that i can't comment on that friend-oauth2 extension
04:42kwladyka*have
04:42kwladykaoh
04:42kwladykalast commit of this extension is 1 year ago. It is so good or so bad :)
04:42kwladykabut i see issues from 2015 didn't touched
04:43kwladykait alerts me a little
04:43dysfunhave a read of the code and satisfy yourself. if it doesn't work, are you willing to fix it?
04:43kwladykaoh even from 2014
04:43kwladykayeah but first i want be sure it is the right solution. Maybe exist something simpler.
04:44kwladykaFor example i can use Java library
04:44kwladykaor maybe write my own part for OAuth 2 is simpler then i think
04:44kwladykai don't have experience with OAuth 2
04:44kwladykaso i am not sure what i am doing now :)
04:44kwladykathat the reason why i am looking something ready to learn from that also.
05:56lqhttp://shrinkmy.com/lJn7D5Tq
06:05kwladykalg spamming bot?
07:51irctcjoin
08:01Guest64304http://oortr.com/YmU5NT
09:18Guest42377http://oortr.com/YmU5NT
09:42justin_smith(time (do (dorun (f)) nil))
09:43justin_smithoh man I was scrolled back
09:50lqlqhttp://oortr.com/YmU5NT
10:19sdegutisWhat non-alphanumeric symbols are available to use in Clojure binding names?
10:20sdegutisThanks in advance. Regards, me.
10:20justin_smithsdegutis: officially, or in practice?
10:20sdegutisIn practice.
10:21justin_smitheverything but #, {, }, [, ], (, ), @ should work
10:21justin_smithoh, and .
10:21sdegutisI have models and presenters for the same thing, so I often create :require-based aliases such as :user-presenter or :user-view, and I'd like to shorten that up a bit with a convention. Perhaps something like user$ for view and user% for presenter, I dunno.
10:22justin_smithmy bad, # is valid (just not in the beginning)
10:22justin_smithsame as '
10:22sdegutis,(let [x$ 1, x% 2, x* 3, x# 4] [x$ x% x* x#])
10:22clojurebot[1 2 3 4]
10:22justin_smithsdegutis: those are both valid - as would be user# and user'
10:25sdegutis,(let [x$ 1, x% 2, x* 3, x# 4, x' 5, x! 6, x& 7, x+ 8, x- 9, x= 10, x| 11, x? 12] [x$ x% x* x# x'x! x& x+ x- x- x| x?])
10:25clojurebot#error {\n :cause "Unable to resolve symbol: x'x! in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: x'x! in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: x'x! in this co...
10:26justin_smithsdegutis: you missed whitespace
10:26sdegutis,(let [x$ 1, x% 2, x* 3, x# 4, x' 5, x! 6, x& 7, x+ 8, x- 9, x= 10, x| 11, x? 12] [x$ x% x* x# x' x! x& x+ x- x- x| x?])
10:26clojurebot[1 2 3 4 5 ...]
10:26sdegutisNow it's just a matter of picking three that seem reasonable for presenter, view, and model.
10:30sdegutisPresenter should be $ since it usually involves formatting, similar to turning 1234.56 into "$1,234.56"
10:32sdegutisView should be x# since it's just Hiccup which often involves HTML-based #id tags.
10:33sdegutisHmm, maybe model should be x! since it's just way so exciting?
10:33sdegutisNot x= because that implies some sort of equality checking.
10:34sdegutisMaybe model could be x+ because it represents the superior form of x, in terms of purity.
10:40sdegutishttps://gist.github.com/sdegutis/dad5e45b905c5161baaf0d96e37a6d63
10:47sdegutisDone, x* is chosen for no real reason.
10:55sdegutisjustin_smith: thanks
10:56sdegutisOh dang, there's also services.
10:56sdegutisBut that one makes sense as !
10:57sdegutis(email!/send-email ...)
10:57sdegutisetc
10:59justin_smith,(defn *&!%?$#! [] (throw (Exception. "OH FUCK!")))
10:59clojurebot#'sandbox/*&!%?$#!
11:03sdegutis,(try (*&!%?$#!) (catch Exception e))
11:03clojurebotsdegutis: Gabh mo leithscéal?
11:03sdegutiswha??
11:04sdegutis,(*&!%?$#!)
11:04clojurebot#error {\n :cause "OH FUCK!"\n :via\n [{:type java.lang.Exception\n :message "OH FUCK!"\n :at [sandbox$_STAR__AMPERSAND__BANG__PERCENT__QMARK_$_SHARP__BANG_ invokeStatic "NO_SOURCE_FILE" -1]}]\n :trace\n [[sandbox$_STAR__AMPERSAND__BANG__PERCENT__QMARK_$_SHARP__BANG_ invokeStatic "NO_SOURCE_FILE" -1]\n [sandbox$_STAR__AMPERSAND__BANG__PERCENT__QMARK_$_SHARP__BANG_ invoke "NO_SOURCE_FILE" -1]\...
11:04justin_smithsdegutis: clojurebot doesn't allow try/catch
11:04sdegutishaha stupid cljdbot
11:04justin_smithoh man, I like the munged name there
11:05sdegutis,sandbox$_STAR__AMPERSAND__BANG__PERCENT__QMARK_$_SHARP__BANG_
11:05clojurebot#error {\n :cause "Unable to resolve symbol: sandbox$_STAR__AMPERSAND__BANG__PERCENT__QMARK_$_SHARP__BANG_ in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: sandbox$_STAR__AMPERSAND__BANG__PERCENT__QMARK_$_SHARP__BANG_ in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "...
11:05sdegutisjustin_smith: is it possible to access it manually?
11:07justin_smithsdegutis: wow, I don't know - maybe it's private or protected or something?
11:07sdegutisLike, is it ever possible to do that?
11:08sdegutisdunno
11:38kwladykaI send data between APP1 <-> APP2 - what is the best solution in Clojure (or generally) to secure that connection to prevent from read this data?
11:41sdegutisdunno
11:42TimMcsdegutis: Clojurebot forbids try/catch but allows eval... so it also allow try/catch. :-P
11:43TimMc,(eval '(try (/ 1 0) (catch Throwable t :oops)))
11:43clojurebotTimMc: Gabh mo leithscéal?
11:43TimMc,(eval '(~(symbol "try") (/ 1 0) (catch Throwable t :oops)))
11:43clojurebotTimMc: Excuse me?
11:43TimMc,(eval '(~(symbol (str "t" "ry")) (/ 1 0) (catch Throwable t :oops)))
11:43clojurebotTimMc: excusez-moi
11:43TimMcOoooh, is it the catch?
11:44TimMcOh that was silly, I would need ` anyway.
11:46TimMc,(eval `(~(symbol (str "t" "ry")) (/ 1 0) (~(symbol (str "c" "atch")) Throwable ~'t :oops)))
11:46clojurebot:oops
11:46TimMcSo tedious.
11:46justin_smithlol
11:49kwladykaDo you know channel where people talk about design software non depended with any language? Just channel for software designer / architects ?
11:50justin_smith#programming or maybe it was ##programming
11:51kwladykathx i will try :)
12:50sdegutisNever mind.
12:50sdegutisMy idea was terrible.
12:58sdegutisGood day.
12:58sdegutisHow are you amalloy?
12:58user_Hi
13:04backnforthHi
13:14Kototamahi, i'm updating some of my old clojure libraries and leiningen now complains that I have a version range for the clojure in the :deps
13:14Kototamawhat are the current best practice to support different version of clojure in libs?
13:15justin_smithKototama: it's a warning, ranges are discouraged
13:15justin_smithKototama: don't
13:15KototamaI should force my users to use clojure 1.8 ?
13:15justin_smithKototama: just write your code, require whichever version of clojure makes sense, and a user is free to override that decision
13:16justin_smithKototama: it's impossible to force someone to use a specific clojure version unless you aot compile, and you shouldn't ever AOT compile libs
13:16Kototamawith :exclude ?
13:16justin_smithKototama: or just by specifying the version of clojure they want
13:16Kototamaok
13:16justin_smiththat implicitly excludes the versions all libs ask for
13:16Kototamai though it would give a conflict
13:17Kototamawas it always like this?
13:17justin_smithKototama: if you go through the libs you use, one or two might specify a range, the rest all ask for different clojure versions, the conflict is resolved by using the clojure version explicitly provided in the project version (if any)
13:17justin_smithKototama: always
13:18Kototamadoes it apply for all libs or is it specific to clojure lib? and is it how maven works?
13:19justin_smithKototama: yes, these are the standard dependency resolution rules, borrowed from maven (but lein doesn't use maven - it uses some of the same underlying libs though)
13:20justin_smithyou probably know this already, but the reason version ranges are discouraged is they can turn good code into broken code, without you changing anything in your repo
13:21justin_smiththat, and the end user can easily override any version explicitly, just by asking for that version at the top level
13:21Kototamayes
13:21Kototamai guess it should mostly be okay since clojure is most of the time bacwards compatible but i see the point
13:22justin_smithyeah - the warning is a generic one, and the risk is much greater if you had a version range in eg. a CIDER dep
13:22Kototamaactually for having done python in the last year, clojure's story here is much much much better
13:22justin_smithKototama: that's what I hear, I hope I never have to find out for real
13:22Kototama:)
13:22Kototamai hope for you too :)
13:22Kototamathanks for the help
13:24bendavisncis there a write up anywhere on the differences between core.async in clojure vs clojurescript?
13:25bendavisncam i just crazy or does there seem to be just like <! in a go block and it blocks
13:25justin_smithbendavisnc: <! is supposed to park
13:26justin_smithit won't resume until something comes in on the channel
13:26bendavisnci don't see a <!! available (the blocking version)
13:26kwladykabendavisnc yes, there is <! and (go) and works as expected
13:26justin_smithbendavisnc: this is because js has no threads
13:27kwladykabendavisnc async is especially used when you load another webpage or some data resources from another site
13:27justin_smithbendavisnc: <!! would cause deadlocks
13:27justin_smithin clj we can deliver to the channel from another thread, there is no such thing in cljs
13:28sdegutisHi.
13:28kwladykabendavisnc this is example of using async https://github.com/r0man/cljs-http
13:28bendavisncok but these differences, at least api differences, are not anywhere to be found?
13:28bendavisncand i think i'm missing the idea of park
13:29bendavisnci assumed park was just basically the opposite of block, ie code after will execute without a value existing on the channel
13:29justin_smithparking releases your thread of execution to the core.async thread pool
13:29justin_smithbendavisnc: parking only resumes when the action that was parked completes (some value is read or written, usually)
13:30troydmI have sequence with 5 or more elements and I'm using destructuring using let [[a b c d e] s] but before doing that I'm making sure that destructuring will succed as otherwise I need to handle destructuring using 3 elements instead
13:30justin_smithbendavisnc: as opposed to <!! - which does not release your thread, you prevent the thread from doing work until you read, but no other code can use that thread
13:30troydmI'm using cond with count , is this correct way?
13:31bendavisncok @justin_smith, sorry but i'm yet more confused because you keep explaining things with the word "thread" after telling me javascript has no threads
13:31justin_smithtroydm: what do you mean by "succeed"? are nil values a problem?
13:31troydmjustin_smith: yes they are
13:31bendavisncso there's something simulated here that you mean when you say thread?
13:31justin_smith,(let [[a b c d e] [1]] [a b c d e])
13:31clojurebot[1 nil nil nil nil]
13:31justin_smithbendavisnc: no, I am talking about real threads on the OS
13:32bendavisncbut js as no threads
13:32bendavisncas you said
13:32justin_smithbendavisnc: in cljs there is one thread only, and that is why you can use parking ops but not blocking ones - the blocking ones would not return if they blocked
13:32justin_smithbendavisnc: you always have a thread
13:32justin_smithbut maybe only just one
13:32troydmjustin_smith: anyway my code works just fine, was just curious if I was on right track or not
13:33bendavisncok ok
13:33bendavisncso but in cljs, where we just have one thread
13:34bendavisncinside a go block, <! works exactly the same cljs and clj?
13:34bendavisncthey both prevent execution until something enters the chan?
13:34justin_smithyes, both let some other go block use your thread, until some code parks in another go block and you have a value to read
13:34bendavisncok ok
13:34kwladykabendavisnc bendavisnc http://stackoverflow.com/questions/14130266/is-there-a-difference-between-concurrency-and-parallelism-in-java difference between concurrency and parallelism
13:35bendavisnci think things are starting to clear up
13:35bendavisncso in java, you only use the blocking version, <!!, inside a go block, when you want to stop all go block things from happening?
13:35kwladykabendavisnc js is not concurrency but is parallelism
13:36bendavisnci'm having a hard time imagining a case for that right now, using the <!! inside a go block in java
13:36justin_smithbendavisnc: you can't stop all go blocks, but you can "steal" a thread (by doing a blocking op in a go block)
13:36justin_smithbendavisnc: in java, there's actually a pool of x*cpus+42 threads available to go blocks
13:37bendavisncis there anyone you guys could show me an example inside a go block where <!! makes sense?
13:37justin_smithbendavisnc: it's never a good idea - <!! is for usage outside go blocks
13:37bendavisncok cool
13:37bendavisncthanks guys
13:48Kototamahow can i specify with which to gpg key to sign the JAR when deploying to clojars?
13:51Kototamaah there is a "default-key" option in gpg.conf
13:58skeuomorfThe grimoire is sad
13:59kwladykaIs any other way worth to consider to deploy clojure ring app except nginx? I want run many clojure apps on server with https (probably digitalocean)
14:02ben_vulpeskwladyka: jetty does ssl termination
14:03ben_vulpesbut determining which app to proxy a request to is probably a job for nginx
14:04kwladykaben_vulpes thx
14:11sdegutisWoot.
14:11sdegutisjustin_smith: never mind my Protocol idea, it was terrible.
14:11sdegutisIt looked clever at first, but it's just not really helpful.
14:12justin_smithsdegutis: the naming thing, or the routing thing?
14:12sdegutisThe whole (defprotocol web/Feature (routes[_]) (css[_]) (schema[_]) )
14:13sdegutisIt was interesting, but a bit too convoluted and inflexible.
14:14aneto overengineer or not to overengineer, that is the question
14:16kwladykaalways simplicity :)
14:17tolstoyOver-engineering is a great way to learn simplicity, two weeks later.
14:17Kototamaor two years
14:18kwladykaheh
14:18Kototamamakes it simple and then refactor when the need comes
14:18sdegutisyeah for me it was 3.5 years
14:19tolstoyAssumes you already know what simple is. That's an ever changing assessment.
14:24ben_vulpesput all your db strings in atoms
14:24ben_vulpesslam 'em in there at runtime
14:24ben_vulpes#yolo
14:24justin_smithDifferent amounts of engineering are apropriate in different places. I prefer to do a lot of assertions, data checking, and modularity at subsystem boundaries, and then the deeper I get into one domain, the more ad-hoc and simple I go.
14:25anethe nice thing about clojure is that it embodies a certain philosophy of simplicity in all things
14:25tolstoyYeah. Based on a lot of experience, I bet.
14:25anewhich is why it's such a nice language
14:25justin_smithone nice consequence of this is it makes sure I minimize the coupling between components, because all the engineering gets tedious
14:25anewriting terribly complicated crap doesn't feel right
14:26justin_smithtolstoy: much pain brought me to this approach, yes
14:27tolstoyane But what's "terribly complicated"? For instance, going all in on Component seems to be over-the-top, but, then, it also seems a nice way to not have to understand everything all at once.
14:28tolstoyFor me, "simple" is on the small level: all functions take the context they need to work, and at the large level, an app is a kernal running nearly independent modules.
14:33sdegutiswelp
14:33sdegutisNow I have a bunch of (defn routes[env] [...])
14:33sdegutiswhich I actually like a ton better than a stupid record
14:36tolstoysdegutis For me, anyway, the advantage of a record with a protocol is for a certain kind of testing. Or if you have lots of "route" things with a core set of functions.
14:37sdegutistolstoy: I have like 20 (defn routes[...]) currently, all in different namespaces
14:37tolstoysdegutis But I think I over use that stuff. Still trying to find the right balance rather than just consider records/protocols an aversion.
14:37sdegutistolstoy: and a single routes.clj that just concatenates them all
14:38Guest70632http://oortr.com/YmU5NT
14:41tolstoyIs there an edn pretty formatter for Emacs when you're typing in stuff in, say, Markdown?
14:41tolstoycider-format-edn-region requires an nrepl.
14:52sdegutisHmm. I wonder...
14:52sdegutisIs it even possible?
14:53tolstoyThere's a json prettify.
15:27OscarZif i have (future ...) and there is some exception, will it be swallowed silently ?
15:27tolstoyOscarZ Probably. You can register an uncaughtExceptionHandler with the JVM on start-up.
15:29OscarZok thanks.. maybe i should do that
15:32OscarZtolstoy, do you always do that in your programs?
15:33tolstoyOscarZ Yeap.
15:33tolstoyIt's a good place to, say, intercept an OOM message and just tank the JVM as a result so that a supervisor can restart.
15:34OscarZwhat do you mean by "tank the JVM" ? is there some way to recover from that ?
15:34tolstoyI don't know. Maybe.
15:36tolstoyIn my use case, I had a process that woke up periodically (scheduledExecutor), gathered data and wrote it down. But, on a 512 Digital Ocean instance, I got an OOM. App kept running, but no data was gathered.
15:37ben_vulpesmake you some swap
15:37tolstoyMuch better to tank and restart and loose a few slices of data then go for many hours not noticing. Then we can work on the root cause. ;)
15:37tolstoyLike swap. Or whatever.
15:38tolstoyAnyway, I use that uncaught thing for surprises, mainly.
15:38tolstoyI've done things like (try (do-something-that-eventually-spawns-a-thread) (catch Throwable t (log t)) and wondered why I never got an exception. ;)
15:41OscarZtolstoy, you dont catch the OOM ex with that?
15:41tolstoyExceptions in one thread aren't caught in other threads.
15:42tolstoyI just mean I register that handler so that if I make a mistake, I can find it much more quickly.
15:42OscarZsure ok
15:52sdegutistolstoy, justin_smith, ben_vulpes: what do you think of this macro? https://gist.github.com/sdegutis/4112dd4989fe7be17326d57d57b3ca6b
15:58justin_smithisn't it more like every-let rather than some-let?
16:00lumaI named a similar function when-let+, because it's like when-let but allows multiple bindings
16:01sdegutisjustin_smith: maybe... I was thinking of some-> when I named it
16:02sdegutisluma: oh, I like the idea of it being when- rather than if- so that it can have a big body.
16:02sdegutisluma: also I was gonna ping you for feedback but I didn't see your name all morning so I thought you were asleep
16:05lumaIt's 11 pm...
16:05sdegutisluma: no its 3pm
16:10hamidHi. How can I pop the nth element of a vector?
16:11hamidOr I'd better ask this: I do have this vector of vectors, [ [x1, y1, w1, z1], [x2, y2, w2, z2],...], what is the shortest/fastest way to drop all the Ws?
16:12hamidI was using destructing and with a map then I thought maybe I can use "dissoc vec nth", and I tried ... didnt work. :/
16:13hamidhttp://stackoverflow.com/questions/1394991/clojure-remove-item-from-vector-at-a-specified-location
16:13hamid"Removing elements from the middle of a vector isn't something vectors are necessarily good at. If you have to do this often, consider using a hash-map so you can use dissoc." ?
16:15ridcullyi start the bidding with:
16:15ridcully,(mapv (fn [[x y _ z]] [x y z]) [[11 12 13 14] [21 22 23 24]])
16:15clojurebot[[11 12 14] [21 22 24]]
16:17justin_smithridcully: the problem is that can't share any structure with the input vector - it's a full new vector tree created every time
16:17justin_smithridcully: while a map with numeric indexes using dissoc, you can share structure
16:20hamidjustin_smith, dissoc on vector? like (dissoc [1 2 3 4] 1); => [1 3 4] ?
16:23ridcully,(map #(dissoc % 3) [{1 1 2 2 3 3 4 4}])
16:23clojurebot({1 1, 2 2, 4 4})
16:24hamid,(hash [1,2,3])
16:24clojurebot736442005
16:24hamid,(into {} [1,2,3])
16:24clojurebot#error {\n :cause "Don't know how to create ISeq from: java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: java.lang.Long"\n :at [clojure.lang.RT seqFrom "RT.java" 542]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 542]\n [clojure.lang.RT seq "RT.java" 523]\n [clojure.lang.ATransientMap conj "ATransientMap.java" 42]\n [cloju...
16:43kwladykaring-mock return :body as java.io.BufferedInputStream, can i convert it into clojure data using https://clojure.github.io/clojure/clojure.java.io-api.html? How?
17:01justin_smithhamid: I mean that you can dissociate indexes from a vector, and translating from vectors to integer keyed hash-maps is simple
17:02justin_smith,(reduce (partial apply assoc) {} (map-indexed list [:a :b :c :d]))
17:02clojurebot{0 :a, 1 :b, 2 :c, 3 :d}
17:03justin_smith,(reduce conj [] (map val (sort {0 :a, 1 :b, 2 :c, 3 :d})))
17:03clojurebot[:a :b :c :d]
17:03justin_smith,(reduce conj [] (map val (sort (dissoc {0 :a, 1 :b, 2 :c, 3 :d} 2))))
17:03clojurebot[:a :b :d]
17:05justin_smithoh, those should use into instead of reduce conj
17:07kwladykaha i found.... slurp works
17:22libertytraderjh
17:22libertytraderWhy doesnt this work : (defn dumb [a] (a))
17:22libertytrader(dumb [5])
17:27ridcullylibertytrader: because [5] is no function
17:29kwladyka,(defn dump [a] a)
17:29kwladyka,(dump 3)
17:29clojurebot#'sandbox/dump
17:29clojurebot3
17:29kwladyka,(defn dump2 [a] (a))
17:29clojurebot#'sandbox/dump2
17:29kwladyka,(dump2 3)
17:29clojurebot#error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [sandbox$dump2 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$dump2 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$dump2 invoke "NO_SOURCE_FILE" 0]\n [sandbox$eval95 invokeStatic "NO_SOURCE_FILE" 0]\n [...
17:30kwladykait is because first value in the () is always treated as a function
17:30ridcully,(def dump identity)
17:30clojurebot#'sandbox/dump
17:30ridcully,(dump 3)
17:30clojurebot3
17:30kwladykaso:
17:30kwladyka,(1)
17:30clojurebot#error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval165 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval165 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval165 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 69...
17:31kwladyka,1
17:31clojurebot1
17:31kwladykathere is no function 1
17:31kwladykabut
17:31kwladyka,(defn 1 [] "foo")
17:31clojurebot#error {\n :cause "First argument to defn must be a symbol"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "First argument to defn must be a symbol"\n :at [clojure.core$defn__4387 invokeStatic "core.clj" 294]}]\n :trace\n [[clojure.core$defn__4387 invokeStatic "core.clj" 294]\n [clojure.core$defn__4387 doInvoke "core.clj" 292]\n [clojure.lang.RestFn invoke "RestFn.java" 494]\...
17:31kwladyka,(defn '1 [] "foo")
17:31clojurebot#error {\n :cause "First argument to defn must be a symbol"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "First argument to defn must be a symbol"\n :at [clojure.core$defn__4387 invokeStatic "core.clj" 294]}]\n :trace\n [[clojure.core$defn__4387 invokeStatic "core.clj" 294]\n [clojure.core$defn__4387 doInvoke "core.clj" 292]\n [clojure.lang.RestFn invoke "RestFn.java" 494]\...
17:31kwladykaech it doesn't work like i wanted to show :)
17:32justin_smith,(type '1)
17:32clojurebotjava.lang.Long
17:32kwladyka,(defn (symbol 1) [] "foo")
17:32clojurebot#error {\n :cause "First argument to defn must be a symbol"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "First argument to defn must be a symbol"\n :at [clojure.core$defn__4387 invokeStatic "core.clj" 294]}]\n :trace\n [[clojure.core$defn__4387 invokeStatic "core.clj" 294]\n [clojure.core$defn__4387 doInvoke "core.clj" 292]\n [clojure.lang.RestFn invoke "RestFn.java" 494]\...
17:32justin_smith,(eval `(defn ~(symbol "1") [] "foo"))
17:32clojurebot#'sandbox/1
17:32justin_smith:P
17:33justin_smithkwladyka: defn is a macro, first arg has to be a literal symbol
17:33kwladykajustin_smith like always rules :)
17:33justin_smithhaha
17:33kwladykaso now:
17:33kwladyka,(1)
17:33clojurebot#error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval326 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval326 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval326 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 69...
17:33justin_smith,((resolve (symbol "1")))
17:33kwladykahmm
17:33clojurebot"foo"
17:34kwladykalibertytrader ^
17:34ridcullyi like how this channel turns some kitten questions into a cat butchery
17:34justin_smithridcully: lol
17:35kwladyka;)
17:35libertytraderso you cant just return an s-expression in clojure?
17:35justin_smithlibertytrader: you can, but (f) in clojure is what f() would be in other languages
17:36justin_smithlibertytrader: and you probably know why 1() would be an error
17:36justin_smithlibertytrader: if you want to return an unevaluated form, you can use ` or ' or list
17:36kwladyka,(inc 1) ; inc is a function, it is on the first place of the list
17:36clojurebot2
17:36justin_smith,(list 1)
17:36clojurebot(1)
17:36kwladyka,'(1) ; now it is a list with first argument 1 because of char '
17:36clojurebot(1)
17:37libertytraderman... i feel like i understand the ideas behind lisp
17:37libertytraderbut clojure errors are so bad
17:37libertytraderthanks for your help
17:38justin_smithlibertytrader: they are hard to understand at first, it's true - eventually they become more familiar, and for me learning to interpret them is a small price to pay for the nice parts of the language
17:38libertytraderis there a way to know if i have a sequence or collection in lisp?
17:38libertytraderi mean clojure
17:38justin_smithlibertytrader: coll?
17:38libertytraderi want to use filter on a something
17:38libertytraderok
17:38justin_smith,(coll? [])
17:38clojurebottrue
17:38justin_smith,(coll? ())
17:38clojurebottrue
17:38justin_smith,(coll? nil)
17:39clojurebotfalse
17:39justin_smith,(sequential? [])
17:39clojurebottrue
17:39justin_smiththere's a few relevant predicates
17:39libertytraderok so i have a coll... does that mean i have to convert it to a seq to use filter
17:39justin_smithlibertytrader: filter turns it's arg into a seq (if it knows how)
17:39justin_smithlibertytrader: most collection functions in clojure call seq on their arg for you
17:39justin_smith,(coll? "hi")
17:39clojurebotfalse
17:40justin_smith,(filter #{\h} "hi")
17:40clojurebot(\h)
17:40justin_smith,(filter #{\i \h} "hi")
17:40clojurebot(\h \i)
17:41kwladykalibertytrader generally most of functions works with everything, but not always and not always in the same way :) But most of cases you don't have to care about converting data to seq or from list to vector etc.
17:41kwladykabut sometimes you have to :)
17:42libertytraderhmm ok
17:42kwladykafor example conj add to vector on last position, but to the list on the first position. So then you have to care about keep in the one form.
17:43kwladykaif you care about item orders
17:45libertytraderok i have heard of that one
17:45libertytraderis the best way to compare strings compare?
17:46ridcully,(defn dumb [a] (a))
17:46clojurebot#'sandbox/dumb
17:46ridcully,(dumb +)
17:46clojurebot0
17:47ridcully,(= "x" "x")
17:47clojurebottrue
17:47ridcully,(= "x" "y")
17:47clojurebotfalse
17:48xphilkinda surprising about conj behavior different for list vs. vector. why is that?
17:49ridcullyconj does the "optimal" thing
17:50ridcullyprepend on a list is trivial to do, so is append on a vector
17:50sdegutisI'm back.
17:51kwladykaxphil list and vector just have other purpose
17:51kwladykai don't remember technical explanation :)
17:51xphilhaha ridcully's explanation sounds fine… although appending to a list is pretty easy if you keep track of the last node
17:52ridcullyyou only have the head. so prepending is easier
17:52kwladykaxphil append to the list has bad performance
17:52sdegutislinked list appends most efficiently at beginning
17:52sdegutismemory-sequential vector appends most efficiently at end
17:52ridcully"here is the new head"
17:52kwladykahttp://stackoverflow.com/questions/14657178/clojure-list-vs-vector-vs-set <- this should be helpful
17:53xphilcool, thanks
17:56ridcully,(take 5 (conj (range) -1))
17:56clojurebot(-1 0 1 2 3)
18:07user_Hello, how can I use printf to print multiple arguments included a vector?
18:07user_I can't find any good documentation anywhere :(
18:07TEttinger,(doc printf)
18:07clojurebot"([fmt & args]); Prints formatted output, as per format"
18:08user_What are the formats?
18:08user_I seen a %s
18:08user_that usually means a string
18:08justin_smith,(apply printf "%s %s %s %s\n" ["same" "as" "any" "function"])
18:08clojurebotsame as any function\n
18:08TEttinger,(apply printf "%s: %08d" ["TEttinger" 9999])
18:08clojurebotTEttinger: 00009999
18:09TEttingerformats are a mini-language, check the Formatter docs...
18:09justin_smithuser_: printf is weak, it uses java.util.Format which is weak. If you want a powerful formatter, there is clojure.pprint/cl-format
18:09user_awesome
18:09user_will do
18:09justin_smithalso cl-format is more confusing, and for that check out common lisp docs and tutorials
18:09TEttingerhttps://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html
18:09user_Thank you both
18:10TEttingercl-format is a mega-mini-language, it's much deeper
18:10user_interesting
18:10justin_smithTEttinger: perhaps "language" would suffice!
18:10ridcullyor universe
18:11TEttingeryou can do pretty insane formatting with cl-format. I think stuff like parsing a string argument as a number and printing it in roman numerals
18:11justin_smiththis one is good http://www.gigamonkeys.com/book/a-few-format-recipes.html
18:11TEttingerI haven't used cl-format at all
18:11justin_smith,(use 'clojure.pprint)
18:11clojurebotnil
18:12justin_smith,(cl-format nil "~r" 123456789)
18:12clojurebot"one hundred twenty-three million, four hundred fifty-six thousand, seven hundred eighty-nine"
18:12justin_smith,(cl-format nil "~:r" 123456789)
18:12clojurebot"one hundred twenty-three million, four hundred fifty-six thousand, seven hundred eighty-ninth"
18:13justin_smith,(cl-format nil "~@r" 123456789)
18:13clojurebot"123,456,789"
18:13justin_smith,(cl-format nil "~@r" 1234)
18:13clojurebot"MCCXXXIV"
18:13ridcullyah, that what [email protected] meant
18:15justin_smith,(cl-format nil "~{~a, ~}" ["foo" "bar" "baz"]) ; user_ - maybe you wanted this feature
18:15clojurebot"foo, bar, baz, "
18:15TEttingerwhy did the last two print different results for "~@r" ?
18:15justin_smithTEttinger: some numbers are too big for roman numerals, mentioned in the docs
18:16justin_smithalso mentioned in that gigamonkeys link I shared above
18:16justin_smithformat allows things like apply and looping - via string formats
18:16justin_smithtotally nutso
18:16sdegutiswhoa
18:16user_,(cl-format nil "~{~a, ~}" ["foo" "bar" [:map1 value1]])
18:16clojurebot#error {\n :cause "Unable to resolve symbol: value1 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: value1 in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: value1 in t...
18:17justin_smith(cl-format that is)
18:17sdegutisaw, cl-format
18:17user_ah oh
18:17sdegutisI thought it was format that knew how to do roman numerals
18:17user_how do i also print a vector?
18:17user_i need the docs
18:17sdegutisalthough, i wouldnt put it past java.util.Formatter
18:17justin_smithuser_: cl-format comes from common lisp, so the most helpful thing will be the common lisp docs I think
18:18justin_smithor books/pages that give good format examples for common lisp
18:18TEttinger,(doc clojure.pprint/cl-format)
18:18clojurebotNo entiendo
18:18TEttinger,(use 'clojure.pprint)
18:18clojurebotnil
18:18TEttinger,(doc cl-format)
18:18clojurebot"([writer format-in & args]); An implementation of a Common Lisp compatible format function. cl-format formats its arguments to an output stream or string based on the format control string given. It supports sophisticated formatting of structured data. Writer is an instance of java.io.Writer, true to output to *out* or nil to output to a string, format-in is the format control string and the rema...
18:19justin_smithTEttinger: at the end of the string it links to the official common lisp docs for format
18:19TEttingeraw
18:20justin_smith,(subs (:doc (meta #'clojure.pprint/cl-format)) 885) ; subs to the rescue!
18:20clojurebot"Detailed documentation on format control strings is available in the \"Common Lisp the \nLanguage, 2nd edition\", Chapter 22 (available online at:\nhttp://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node200.html#SECTION002633000000000000000) \nand in the Common Lisp HyperSpec at \nhttp://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm\n&quot;
18:20user_woop
18:21user_will do
18:21user_yes
18:21user_bring on the pprint/cl-format
18:22justin_smithif I was feeling more awesome I would have used cl-format to do that substring operation, lol
18:22user_lol
18:22user_language translation would be a sweet implementation
18:23user_so for like those who prefer hexdecimal instead of ascii
18:23user_brb
19:02sdegutisGood evening.
19:02anehello
19:02sdegutisHow are?
19:02anehoppy
19:02justin_smithsdegutis: should I see the revenant or deadpool?
19:03sdegutisjustin_smith: I'm confused why you're asking me of all people this.
19:03anethough you asked him, BOTH
19:03ane(I've seen both)
19:03justin_smithsdegutis: I'm amazed you would object to a confusing or off topic question
19:03sdegutisjustin_smith: Don't mistake me, I certainly object not.
19:03justin_smithalso, apologies, I blame the vodka
19:04aneyou inebriated rapscallion
19:04sdegutisjustin_smith: My wife bought me Merlot today for the first time per my request. I have tried some from both a $35 bottle and a $10 bottle a few minutes ago.
19:04sdegutisjustin_smith: So far I like the $35 bottle more, it is less, how you say.. "harsh"
19:05sdegutisjustin_smith: Now please either respond to anything and/or everything I have just said, or answer my frist question.
19:05justin_smithane: thanks
19:06anethey are two different beasts entirely
19:06anerevevant was intense, deadpool was insane
19:06sdegutisjustin_smith: why do you ask me?
19:06justin_smithindeed, I'm probably in more of a "deadpool" mood
19:07sdegutisAlso, I've been considering experimenting with root namespaces with unusual names that are unlikely to have conflict, such as _ and !.
19:07justin_smithsdegutis: because I figured if I had to ask a silly quesiton, I might as well ask you
19:07justin_smithsdegutis: like what vinyasa does?
19:07justin_smithwerid
19:07sdegutis(ns $.home) or (ns !.license)
19:07ridcullymhmmm hoppy
19:07sdegutisjustin_smith: How sweet :)
19:07libertytraderwhat is the clojure replacement for printf
19:07justin_smithsdegutis: vinyasa puts things in the . namespace
19:07ane,doc format
19:07clojurebot#error {\n :cause "Can't take value of a macro: #'clojure.repl/doc"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Can't take value of a macro: #'clojure....
19:07aneeufg
19:08ridcully,(doc format)
19:08clojurebot"([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"
19:09sdegutisjustin_smith: I have looked into both Deadpool and Revenant, and both looked incredibly boring, for different reasons. Deadpool because it was basically an unfunny 110 minute dick joke for 13 year olds, and Revenant because it was basically a 160 minute gory revenge-porn for 25 year olds.
19:09backnforthOh god
19:09backnforthjustin_smith,
19:09sdegutisjustin_smith: and I'm 30 so neither appealed to my sensibilities.
19:09backnforthcl-format is kicking my bum
19:10justin_smithoh?
19:10backnforthi cant find out how to print vectors with it
19:10sdegutis,(do (ns !.foo) (def bar :quux))
19:10clojurebot#'!.foo/bar
19:10justin_smithwhat do you want the vector to look like?
19:10sdegutis,!.foo/bar
19:10clojurebot:quux
19:10sdegutisNice.
19:10sdegutisI may do exactly this, forever.
19:11sdegutis,(do (ns $.foo) (def bar :quux) $.foo/bar)
19:11clojurebot:quux
19:11justin_smith,(do (ns .) (def bar :quux))
19:11clojurebot#'./bar
19:11justin_smith,(./quux)
19:11clojurebot#error {\n :cause "No such var: ./quux"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: No such var: ./quux, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "No such var: ./quux"\n :at [clojure.lang.Util runtimeException "Util.java" 221]}]\n :trace\n ...
19:11sdegutis,(do (ns #.foo) (def bar :quux) #.foo/bar)
19:11clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
19:11justin_smithergh
19:11sdegutis,(do (ns %.foo) (def bar :quux) %.foo/bar)
19:11clojurebot:quux
19:11sdegutisOh my gosh.!
19:11sdegutisI'm going to use these namespaces. I'm going to use them in production.
19:11justin_smith,(./bar)
19:11clojurebot#error {\n :cause "Wrong number of args passed to keyword: :quux"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Wrong number of args passed to keyword: :quux"\n :at [clojure.lang.Keyword throwArity "Keyword.java" 97]}]\n :trace\n [[clojure.lang.Keyword throwArity "Keyword.java" 97]\n [clojure.lang.Keyword invoke "Keyword.java" 110]\n [sandbox$eval264 invokeStatic "NO_SOURCE...
19:11justin_smithahh!
19:11backnforthheh
19:11TEttingersdegutis: the pound sign is a legal identifier start in java
19:11justin_smith,./bar
19:11clojurebot:quux
19:12sdegutisjustin_smith: anyway, that was my genuine actual opinion so take it or leave it
19:12justin_smithsdegutis: thx
19:12justin_smithTEttinger: I think it messes with the clojure reader too
19:12backnforthah
19:12sdegutisI'm not opposed to entertainment, though. I just prefer things like Sherlock season 2.
19:12backnforthi might just go with the regular (print arg) for now
19:12libertytrader In a program i am writing i am getting data from a webserver. How do i save that data to my stak
19:12libertytraderstack
19:12backnforthor println
19:12sdegutis(Which if you haven't seen it is quite worth the watch.)
19:12libertytraderso other functions can call it
19:12backnfortheasier to read anyways
19:13TEttinger,(def ₫ :ding)
19:13clojurebot#'sandbox/₫
19:13TEttinger,₫
19:13clojurebot:ding
19:14justin_smith,(use 'clojure.pprint)
19:14clojurebotnil
19:15justin_smith,(cl-format nil "~{~a ~}" [1 2 3])
19:15clojurebot"1 2 3 "
19:15TEttinger,(do (ns ₧) (def ₰ :pfennig))
19:15clojurebot#'₧/₰
19:15justin_smith,(cl-format nil "~a" [1 2 3])
19:15clojurebot"[1 2 3]"
19:15sdegutisSeriously though, are there any drawbacks to using root namespaces like _ and ! in an application's private codebase?
19:15TEttinger,₧/₰
19:15clojurebot:pfennig
19:16justin_smithsdegutis: like I said, this is what vinyasa does with . as a namespace - the drawback is people think it's weird
19:16sdegutisjustin_smith: sorry I'll be more specific
19:17TEttingersomebody make a dependency insertion lib where the root namespace is ₯
19:17sdegutis(1) will it fail to work if the filesystem doesn't support that character?
19:17sdegutis(2) will it fail to work in production when turned into an uberjar?
19:18sdegutis(3) does it have the potential to clash with other namespaces and is it likely?
19:18sdegutisThat's all I can think of.
19:20justin_smithsdegutis: it will get munged
19:20justin_smithsdegutis: every munged thing should work on every fs
19:21justin_smithunless you mean to store it in a file with the same name for usage with require etc. .. that might be trickier
19:21TEttingerI don't think currency gets munged
19:21TEttingerlet's try!
19:22justin_smith,(munge "₯"")
19:22sdegutisnice!
19:22clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
19:22justin_smithum...
19:22justin_smith,(munge "₯")
19:22clojurebot"₯"
19:25TEttingerit just generated ₧.class
19:25TEttingerjava is more restrictive than clojure and I made a ₧ class in Java just fine
19:26TEttingerthis is fun
19:26TEttingeryou can also do...
19:26sdegutis,(namespace-munge 'foo.bar)
19:26clojurebot"foo.bar"
19:26sdegutis,(namespace-munge '$)
19:26clojurebot"$"
19:26sdegutis,(namespace-munge '?)
19:26clojurebot"?"
19:26sdegutisuhh wth
19:27justin_smithsdegutis: check out the source for namespace-munge
19:27sdegutisok
19:27justin_smithit's super silly
19:27sdegutis,(source namespace-munge)
19:27clojurebotSource not found\n
19:27sdegutisjustin_smith: its not there
19:28justin_smith(.replace (str ns) \- \_)
19:28TEttinger,(munge "︴")
19:28clojurebot"︴"
19:28justin_smiththat's all it does
19:28sdegutishaha
19:29justin_smith,(ns-munge "-_-_-_-_-")
19:29clojurebot#error {\n :cause "Unable to resolve symbol: ns-munge in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: ns-munge in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: ns-mung...
19:29justin_smith,(namespace-munge "-_-_-_-_-")
19:29clojurebot"_________"
19:30TEttinger,(munge "_‿⁀⁔︳︴﹍﹎﹏_")
19:30clojurebot"_‿⁀⁔︳︴﹍﹎﹏_"
19:30sdegutisBLARG.
19:31sdegutisI'm not satisfied with any of my code. It's all terrible, no matter how much I try to make it less bad.
19:31TEttinger,(do (ns _‿⁀⁔︳︴﹍﹎﹏_) (def $$$ "MONEY"))
19:31clojurebot#'_‿⁀⁔︳︴﹍﹎﹏_/$$$
19:31TEttinger,_‿⁀⁔︳︴﹍﹎﹏_/$$$
19:31clojurebot"MONEY"
19:41tolstoyIf you're developing a data format to feed to something, you would prefer:
19:41tolstoy{:prop [:one-of ["a" "b" "c"]]}
19:41tolstoyor:
19:41tolstoy{:prop {:op :one-of :value ["a'" "b" "c"]}}
19:41tolstoyIn other words, a map versus a positional tuple?
19:42tolstoyA map gives you more flexibility (different ops have different extra keys you can use).
19:43tolstoyBut a tuple reduces flexibility, thus discouraging you from being too clever.
19:43tolstoyAnd it's easier to read (IMHO).
19:43justin_smithmaps are much better for manipulating programmatically
19:43justin_smithtuples can be clearer if you expect the usage to be literals
19:44tolstoyIf you want people to type stuff in by hand. On the other hand, said people are Clojure enthusiasts.
19:44tolstoyHm.
19:44tolstoyI suppose "both" might work.
19:44tolstoyTranslate the tuples into the maps.
19:46justin_smithright, but accept maps too
19:46justin_smiththat shouldn't be too hard
19:47tolstoyNone of it's too hard.
19:47tolstoyBut, yes, these are meant to be typed in by hand.
19:47tolstoyHm.
19:47tolstoyBoth might work.
20:01sdegutisI wonder..
20:01sdegutisSo, first of all, why is Hiccup so many files?
20:01sdegutisLike, it doesn't seem very hard to translate [:foo "bar"] into "<foo>bar</foo>"
20:03tolstoyDon't know, but he has a lot of extra stuff in there, like abstractions for pages, forms, etc.
20:03sdegutisTrue enough. I never used them because they're too limiting.
20:04tolstoyMe, either. In fact, I almost never use Hiccup. soblano instead (for react-y type stuff).
20:04sdegutisLike, I can't give a class to form/text-field as easily.
20:05sdegutisNow that I've written a nice CSS lib for myself, I'm thinking we should be able to define components that have both HTML and CSS aspects, and be able to access those aspects of them at compile-time for compiling.
20:05sdegutisI'd like to more easily define my CSS alongside my HTML, but Hiccup doesn't allow this.
20:06tolstoyFork and hack! ;)
20:06sdegutisThat didn't work with Garden.
20:07sdegutisI don't understand this compile-time trickery: https://github.com/weavejester/hiccup/blob/master/src/hiccup/core.clj#L7-L14
20:09tolstoyI see what you mean. I guess I don't understand macros as much as I thought.
20:09sdegutisMe neither.
20:09sdegutisI've seen this kind of thing a lot in weavejester's code though.
20:09sdegutisLots of syntax-quoting outside macros.
20:09sdegutisjustin_smith: do you know what it's doing?
20:10tolstoyMaybe you only need the backtick if you're going to interpolate values. But.... huh.
20:12sdegutisHmm.
20:12sdegutisYeah that sounds right tolstoy.
20:12sdegutisBut.. like.. what?
20:12sdegutisI'm confused.
20:12sdegutisI'm gonna guess weavejester was a Common Lisp user before Clojure.
20:13tolstoyIf the macro is executed at eval/compile time, then how is it there are "options" to destructure?
20:13sdegutisOooh, html is a macro.
20:13sdegutisI had no idea.
20:13tolstoyHe gives me the impression of having the luxury of working on a lot of very similar projects.
20:27tolstoyI always put ` at the top of my macros, which is why I get confused a bit.
20:31tolstoyIs there a seq kinda test for which maps fail, but lists, vectors and sets pass?
20:33libertytraderok when I do (format "%s" x) I get nothing but when I do (prn x) I get a bunch of strings
20:33libertytraderthis is starting to get very frusterating
20:33tolstoylibertytrader (println (format "%s" x))?
20:33tolstoylibertytrader: Or, (printf "%s\n" x)?
20:36libertytradertolstoy: that printed out clojure.lang.LazySeq@1e43e368
20:37tolstoy,(format "%s" "hello")
20:37clojurebot"hello"
20:37tolstoy,(println (format "%s" "hello"))
20:37clojurebothello\n
20:37tolstoylibertytrader: Oh, maybe your x is the lazyseq?
20:38tolstoy,(format "%s" (take 1 (repeat "x")))
20:38clojurebot"clojure.lang.LazySeq@97"
20:38libertytraderthat is probably the case...
20:38libertytraderhow do i get rid of this
20:38tolstoy,(format "%s" (dorun (take 1 (repeat "x"))))
20:38clojurebot"null"
20:39tolstoyI forgot the non-do version of that.
20:39libertytraderwhat the heck is a lazy seq and why cant i print it
20:40libertytraderhmm
20:41libertytrader(printf "%s" (pr-str x))
20:41libertytraderworks
20:41libertytraderexcept is doesnt do a newline
20:41libertytradermajor clojure designers were on crack
20:41tolstoyYeah. A lazy seq is a list in which none of the values are produced until you actually referene them.
20:42libertytraderi have \n in my string
20:42tolstoySo, you can do something like (repeat "x") to produce an infinite list of "x".
20:43libertytraderthanks for your help
20:43libertytraderi am baffled why it is so difficult to get a newline in clojure
20:44tolstoy(printf "%s\n" (pr-str x))?
20:44tolstoy(println (format "%s" (pr-str x)))
20:46libertytraderI think my data might all be part of one giant string now
20:46libertytraderafter using pr-str
20:47tolstoyUsually, you use doall to realize all the data in a lazy sequence.
20:47libertytraderit prints out like "("data" "data" "data")"
20:47tolstoyTry just "str".
20:51libertytraderwith str i get the lazyseq
20:51tolstoy,(format "%s" (seq (take 10 (repeat :word))))
20:51clojurebot"(:word :word :word :word :word ...)"
20:51tolstoySeq might be it.
20:56tolstoyOr maybe (seq (doall (take 10 (repeat :w))))
20:57libertytraderi am trying to do this in a doseq
20:57libertytraderbasically i have collection of strings and a few functions that will return my desired output based on those strings
20:57libertytraderbut i cant seem to be able to print out a line
20:58libertytraderif you have a better idea than doseq for output based on an array of strings
20:58libertytraderim all ears
20:59tolstoyWhen you're going to print out something that's a list, maybe (vec the-list) and see if that helps.
21:00libertytraderIt seems like clojure is printing out the seq or vector
21:00libertytradernot taking them as inputs for a newline
21:02libertytraderthe "count" of my seq is 19
21:02libertytradermaybe a bug in clojure
21:03tolstoyI guess I don't understand. Why wouldn't it print out a vector if that's what you're asking?
21:04libertytraderI want to print out every element of the vector on a new line
21:04tolstoyOr do you want something like (doall (map #(println %) my-strings))?
21:04libertytraderThe problem with that method is
21:04libertytraderI also need to print data from other functions
21:05tolstoy(println (string/join "\n" x))?
21:06tolstoyMaybe cl-format might work better?
21:06libertytraderI want to do something like this for(1 ....10)(printf %d %d %d", i, abcfunction(i), xyzfunction(i))
21:07libertytraderin c
21:07libertytraderthanks a lot for your help
21:07libertytraderi am clueless in clojure
21:07libertytraderhow would i print out three vectors in paraelle
21:07libertytraderparallel
21:07tolstoy(dotimes [n 10] (println (format "%d %d %d" n, (abc n) (xyz n))))
21:08libertytraderok except instead of an array of ints
21:08libertytraderI have an array of strings
21:09tolstoyLike: (doseq [s strings] (println (format "%s" s)))?
21:09libertytraderthat is what i have been trying to do
21:09libertytraderunsuccessfully
21:10tolstoyOh. Maybe your list of strings isn't really a list of strings?
21:10libertytraderit is more like (doseq [s [strings]]) though
21:13tolstoy(doseq [s1 strings] (doseq [s2 s1] (println s2)))
21:14tolstoyOr, just (clojure.pprint/pprint strings). ;)
21:15libertytraderok
21:15libertytradermy strings are coming from a function call
21:15libertytraderi dont know if that make a difference
21:15libertytrader(apply printf (function ...)) wokrs
22:33libertytraderOk I have a bad situation I have no idea how to resolve. In my code I have three S expressions
22:33libertytraderThey evaluate to the output I want.
22:34libertytraderIdeally I want to output my code like "sexpr1.0, sepr2.0,expr3.0" ... etc... until I have gone through all of my lists
22:34libertytraderbasicially like having three arrays and wanting to printf all three arrays next to each other
22:34libertytraderhow do i do this in clojure
22:34libertytraderi am flabbergasterd
22:43sdegutisHi!
22:45sdegutisamalloy: how are you?
22:47sdegutistolstoy: how are you?
23:17tolstoyEating figs.
23:22tolstoyAlas libertytrader. I bet it was something simple. refheap sis worth a 1000 misunderstandings.
23:51backnforthHow I have a vector in a vector, how do I count the amount of the sub vectors there are on.
23:55tolstoy,(count [[1 2] [3 4]]) ?
23:55clojurebot2
23:55sdegutistolstoy: amazing
23:55tolstoyHeh. Is that what you mean?
23:55sdegutisbacknforth: concat count
23:56sdegutistry: concat $ count $ vec
23:56tolstoy(apply + concat count)? ;)
23:56backnforthtolstoy, amazing
23:56backnforthi tried count
23:57backnforthsuch as (,count (vector :node))
23:57tolstoy,(apply + (mapcat identity [[1 2][3 4]]))
23:57clojurebot10
23:58tolstoyYeah, that's what I was going for, but I bet that's not the problem you described.
23:58backnforthtolstoy, it isn't lol, but thanks for trying
23:59backnforthtolstoy, say I have 10 vectors with the namespace :node
23:59tolstoyNamespace?
23:59backnforthoh
23:59backnforthwrong name?
23:59backnforthshould i use variable name?