#clojure logs

2015-12-27

02:17jeayeHow can I partition [1 2 3 4 5 6] into [[1 2 3] [4 5 6]] such that anything < 4 goes into one side and all else goes into another?
02:20ridcully_(doc partition-by)
02:20clojurebot"([f] [f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of partitions. Returns a stateful transducer when no collection is provided."
02:21jeayeAh, even nicely named.
04:30cflemingTEttinger: My pleasure!
04:35TEttingerI'm mostly using IntelliJ for Java these days, but I have really gotten quite used to the IDE. it will be very nice not to have to learn a new one once I go back to large clojure projects
04:35TEttinger(it's a mind-bending experience switching between VS's mostly sane shortcuts and IntelliJ's very odd defaults, like alt-f7)
05:37lokienAny good books/courses about cljs? I can't find anything useful
06:27piotrtshello
06:27piotrts is 4clojure down right now?
06:32LuminousMonkeyLooks to be down: http://downforeveryoneorjustme.com/4clojure.com
06:39piotrtsoh, thanks
10:21visofhi guys is clojars.org down?
10:22beakyit seems down to me too
10:22beakyno ping, cant curl, etc
10:24visofbeaky: no alternatives?
10:24beakyi dont know :(
10:24beakymaven? :D
10:25FrozenlockI wonder if it's why I can't run lein in a project...
10:25visofFrozenlock: yep
10:26visofis there anyone of server maintainers here?
10:26Frozenlocksurely there's a flag to disable the clojars check -_-
10:29Frozenlockthere's that https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L127
10:33Frozenlockvisof: https://twitter.com/clojars/status/681130080773472256
11:46jonathanjis there a convenient way to determine the length of an InputStream?
11:47justin_smithjonathanj: InputStream is an interface. I could easily make one that returns the same byte over and over forever.
11:48justin_smith.available tells you how many bytes are ready right now
11:48jonathanjhow about a BufferedImage?
11:48jonathanji'm reading an object from a PDF, all i want to know is how big the object is
11:48jonathanjso presumably it's not infinite
11:48jonathanj(using PDFBox, in case that's relevant)
11:49justin_smithhow about getWidth and getHeight?
11:49justin_smiththose should give you a very good idea of the size in pixels at least
11:49jonathanjyes, but that's mostly irrelevant
11:49justin_smithbut it supports compressed formats, so...
11:49jonathanjexactly
11:50jonathanji just want the length of the raw data contained by the object, but i can't figure out how to find that
11:51jonathanjthe best i can come up with is clojure.java.io/copy the object's inputstream to a ByteArrayOutputStream and determine the size of the resulting array and then discard everything
11:51justin_smithonce it's a BufferedImage I don't think you have the raw input any more? BufferedImage has a raster (totally uncompressed version) of the image
11:51jonathanjwhich seems like a lot of effort
11:52jonathanjhttps://pdfbox.apache.org/docs/2.0.0-SNAPSHOT/javadocs/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.html
11:52jonathanjjustin_smith: fair enough, perhaps a BufferedImage is going in the wrong direction then
11:53justin_smithjonathanj: you could try (-> pdfimage .createInputStream .available)
11:53justin_smithit could be that all of it would be available at once?
11:53justin_smithwhen you asked about inputstreams, well those can be connected to something like a network connection, you can't know how much data will come in until it comes in
11:53justin_smithbut in this case I think more info is available about it
11:55jonathanjit feels like relying on that is a mistake though
11:55jonathanjavailable only dictates how much can be read without blocking
11:55jonathanjnot how much is available to read in total
11:56justin_smithwhy would it block if all the data is right there in memory already?
11:56justin_smithreally though, just read all the data and throw it away if you need to know the exact size, that's the only reliable way to know
11:58jonathanjjustin_smith: well, if it's on disk the implementation might choose to lazily stream it, i mean there's no real guarantee that everything is actually in memory
11:58jonathanjso i think reading it all in and throwing it away is probably the only bet
11:58justin_smithwhy do you need to know the size?
12:00jonathanji'm implementing a pdf crushing function, i'd like to start crushing the largest objects first, so i need to be able to determine which are the largest
12:03jonathanjokay, actually digging through the inheritance i found that `PDImageXObject`'s base class implements `getStream` which returns a `COSStream` which has a `getLength` method, i originally thought this method would return an InputStream
12:05justin_smithoh, cool
12:29lokien_Is boot any better than leiningen?
12:51lokien_Hello?
12:56j-pbIt's me.
12:56justin_smithno, this is dog
12:56j-pbhahaha
12:57j-pbthe only real advantage of slack over irc is giphy
12:58lokien_It's you I'm looking for, j-pb
12:58j-pbwhas it it :)?
12:59lokien_Are you using boot? :(
12:59j-pbnope
12:59j-pbgood old leiningen :)
12:59j-pbbood holds some promisies, but it's imperative nature doesn't justify the gains imho
12:59lokien_Bu-ut cljs tutorial uses boot and I'm super sad now
13:00j-pbyeah, it looks easier at first, but I rather write a bit more config that's declarative than magic imperative stuff :)
13:00j-pbcljsbuild is actually pretty easy to setup in leiningen once you got the hang of it
13:00j-pball the config options ae dauntig at first but you only need a very small percent of all that
13:01j-pblokien_: what is it that you're having trouble with :)?
13:01lokien_I'll check it out then. Is modern cljs a good tutorial for a noob?
13:02lokien_I wanted to lick some cljs, but I hit a brick wall
13:02j-pbto be honest I don't know
13:02j-pbi'd do lein new figwheel myprojectname -- --reagent
13:02justin_smithyes, this is patrik
13:02lokien_justin_smith to save the day
13:03lokien_As always
13:03justin_smith haha
13:03j-pbthat sets up a figwheel project for you which means nicer dev flow
13:03j-pband automatically makes it a reagent project as well
13:03j-pbwith that you have everything running which is nice and you can do the rest by exploration I think :)
13:03lokien_j-pb: where did you learn like.. How to do cljs stuff? It's not the same as in clj an-
13:04lokien_Were you js developer earlier?
13:04j-pbtime and persistence
13:04j-pbno clojure dev
13:04j-pbnever touched js before
13:04j-pbtbh it's not that hard or much :)
13:04lokien_Good for you, it's a laxative for brains
13:05j-pbthe hardest thing is the tooling
13:05j-pband figwheel does 99% of that for you
13:05lokien_I have some troubles with learning. I have to understand something, I'm not able to memorize stuff without understanding the thing
13:06lokien_And I end up with 20 tabs in my browser and a headache
13:06j-pbunderstanding is relative
13:06j-pbyou wont' understand the intricasies of the Js or jvm JIT
13:06j-pbbut luckily you don't need to
13:06j-pbthe gist of cljs is this
13:06lokien_Jvm=magic
13:07lokien_I like it to stay this way
13:07j-pbcljs --cljs compiler--> js --google closure--> executable js
13:07lokien_Yeah, the stuff I know!
13:07j-pbcljs has a somewhat naive clj to js compiler and relies on a lot of google closure goodness to optimize it
13:08lokien_If it's a bug in my cljs, I won't have to debug js? Just cljs, right?
13:08j-pbfigwheel is a tool that automatically recompiles and reloads your files to a instance of your web applicatoin running
13:08j-pblokien_: most of the time
13:08j-pbbut not always
13:08lokien_Uhm, I think I saw guys making flappy bird with figwheel
13:08j-pbyeah
13:08lokien_j-pb: so I have to learn some js?
13:09j-pbnope
13:09j-pbnot explicitly at least
13:09j-pbof course you will learn js, but at least I only learned what was nessecary as I debuged my clojure code
13:09j-pbthere is no need to learn vanilla js first
13:09lokien_Okay then
13:10lokien_And I can use electron to make pretty gui stuff with it, right?
13:11j-pbah well if you want to do desktop apps yeah :_
13:11j-pb:_
13:11j-pbgoddamit :)
13:11lokien_:D
13:12j-pbhowever I found that it's somewhat nice to have a server running somewhere and then just use the browser
13:12lokien_My girlfriend is savage about my cli clojure apps, so I have to
13:12justin_smithlokien_: " I'm not able to memorize stuff without understanding the thing" -- yet you speak English!
13:12justin_smithor at least write it well
13:13justin_smithlokien_: were you trying to use clojure in the cli via lein?
13:13lokien_justin_smith: but my head ached for like 7 months, reading my first english books
13:14lokien_justin_smith: I've made some programs that ran in terminal
13:15TEttingerthe JVM Clojure lib called seesaw, with the "insubstantial" styling stuff, isn't bad-looking
13:15lokien_I'm intrigued by quil
13:16j-pbnot for gui stuff
13:16TEttingeryeah, quil doesn't do uh common anything for GUIs. I think you'd need your own text input boxes, copy/paste support...
13:17TEttingerplay-clj has scene2D.ui as part of its wrapper around the java game lib libGDX. that has text input but not the best OS integration
13:18TEttinger(it will however outperform swing if you ever do anything animated)
13:18TEttinger(swing is the main java GUI lib)
13:19TEttingerI think JS on the desktop using electron or the like is a decent way to go.
13:19TEttingerthere's also CEF
13:19TEttingernot sure if there's a decent clojure binding
13:20lokien_What is cef?
13:23lokien_Uh, chromium embedded framework, in c++
13:25TEttingerhuh, this looks not bad https://github.com/karad/lein_template_descjop
13:25TEttingerlokien_: you'd be surprised how many apps use it
13:26TEttingerthere's a binding for Java, wasn't sure if there was one for Clojure
13:26lokien_TEttinger: pretty logo, I'm sold
13:26TEttingerit's electron based, that descjop, but you can choose reagent or Om for how to handle whatever those are used for. react.js stuff
13:27lokien_Never used any of thiss stuff
13:27lokien_But reagent looks good
13:28kenrestivoit's got a learning curve, but it's very powerful
13:29lokien_That's what they said about emacs
13:29hlolliTEttinger, one fundemental question about Om. Is om next compleatly different from om. If so, would you recommend newcommer to learn om or om-next only?
13:30TEttingerI have never used Om or anything like it. paging justin_smith, justin_smith to the channel
13:31lokien_I've just googled "justin smith clojure" and man, those sideburns
13:32justin_smithhello
13:35hlollihello Justin, I did the edn config file yesterday. Was wondering if you knew how to make leiningen extract the edn file to resources folder when you require a project from clojars in a fresh clojure project?
13:35hlolliit just sits in the .jar file in .m2 subdirectory, not much use if the user can't edit it.
13:44justin_smithhlolli: the common way to do this is to have a default inside the jar, use io/resource and spit in order to make a copy on disk on startup if it doesn't exist yet, then you load it if present
13:45justin_smithhlolli: or you can just expect them to make the file available, and tell them what should be in it
13:46justin_smiththis is what lazybot does, for example
13:46hlolliyes, thougt so. Yes I can write io spit. But I guess I have to make a check that only to spit if file does not exist already.
13:46justin_smithexactly
13:47hlolliok sounds like a solution.
13:58justin_smithTIL C has better support for static initialization of data structures with inline literals than java does
14:03domgetterWhen I watch conference talks about Clojure, I often see speakers evaluate a form in their text editor, and the result is shown in the repl. What do I need to look into to learn how to do this?
14:04BRODUSdomgetter: i think CIDER for emacs has support for this
14:04domgetterBRODUS: Ah so I can't just do it with any IDE/text editor?
14:05BRODUSyou could send a form to the repl or you could overlay the result into the buffer
14:05domgetterother than copy-pasting the form, what do you mean "send a form to the repl"
14:06BRODUSlike evalute the expression immediately behind my cursor and show the output in the repl
14:07BRODUSassuming you have two views open, one is the file youre editing and the other is the repl
14:07ridcully_i'd assume, that any editor, that "support" clojure, can do this
14:07domgetter"like evalute the expression immediately behind my cursor and show the output in the repl " Are you still talkinga bout what can be done with CIDER for emacs, or are you speaking generally?
14:07ridcully_in vim-fireplace it's :Eval and cpp
14:08justin_smithdomgetter: what you wwant to look for, generally, is "nrepl bindings", this is how most editors interact with clojure inside the editor.
14:08BRODUSi was speaking about emacs, but there should be something similar in a clojure supported IDE
14:08domgetterAlso I have no idea what "overlay the result into the buffer" means. Do you have any resources I could read up on?
14:08justin_smithdomgetter: cursive, emacs, light-table, and vim are the best working examples of this I know of
14:10BRODUSdomgetter: sorry for the confusion, in emacs a 'buffer' is a view, its usually filled with the text you're editiing
14:11domgetterBRODUS: yea, I'm coming at this with zero knowledge of emacs.
14:12domgetterThank you for your input, everyone :)
14:13jonathanjusing transducers with maps seems a bit awkward
14:14jonathanjlike, if you want to filter by some property of the value, you have to write all your xforms like (filter (fn [[_ v]] (regular-predicate v))) to "lift" the value out of the map
14:15justin_smithjonathanj: or (filter (fn [e] (predicat (val e)))
14:15justin_smithor (filter (comp predicate val))
14:15jonathanjthat is a little nicer but still
14:16jonathanjthat works for filter, but what about map?
14:16jonathanjlike if you want to preserve the key but alter the value
14:16justin_smithreally depends on what you want the map to return - more entries?
14:16justin_smithsorry, lag here
14:17justin_smithso yeah, then you can destructure, or use key / val - what is the easy and convenient alternative that clojure isn't doing? is there another syntax that would be better?
14:17domgetterjustin_smith: So I told LightTable to connect to an existing nrepl at localhost:54525 but when I evaluate (println "hello"), nothing happens in the repl in my command prompt.
14:17jonathanjso if you want to only transform the values it gets ugly because you need to add (into {}) in too
14:18justin_smithdomgetter: typically with nrepl your result is visible on the client side, not the server side
14:18jonathanji'm surprised because i would have expected this to be pretty common and usually Clojure is really good about making common things easy or obvious
14:18justin_smithjonathanj: maybe it's just stockholm syndrome but I'm not picturing the easier thing - what would it look like?
14:19domgetterjustin_smith: In the conference talks, they're evaluating forms in their text editor, and the result is magically appearing in the repl, not the text editor
14:19justin_smiththis isn't a repl inside their editor?
14:20domgetterI ran lein repl in a command prompt, and told LightTable to connect to the nrepl server that lein made
14:20domgetteror are you talking about the conf speakers
14:20justin_smithdomgetter: I didn't ask what you did, I asked what they did
14:20jonathanjjustin_smith: well the xf would maybe look something like: (comp (filter (comp this-one? val)) (map-vals inc))
14:20domgetterjustin_smith: https://www.youtube.com/watch?v=enwIIGzhahw&amp;t=6m6s
14:20justin_smithdomgetter: typically people have a repl inside the editor
14:21domgetterokay so they were never connecting to an external repl AND evaluating forms that showed up in it?
14:21justin_smithdomgetter: yeah, that repl is part of his editor
14:21domgetterah okay. That was my fundamental confusion
14:22justin_smithdomgetter: well, the weird part is that they ARE connected to an nrepl server
14:22justin_smithbut usually it is implicitly started, and all results show up in their editor
14:22jonathanj,(sequence (map (comp inc val)) {:a 1})
14:22clojurebot(2)
14:22domgetterokay, okay
14:22domgetterawesome, thank you for clearing that up for me
14:22justin_smithdomgetter: light table makes it very easy to eval clojure code inside the editor - it's a bit clumsy at some stuff, but that is something it is very good at
14:23jonathanjlooks like (sequence) turns it into a sequence
14:23justin_smithjonathanj: right, and your (comp inc val) ensures you wont get the full entry, just the val
14:24justin_smith,(
14:24clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
14:24justin_smith,,(into {} (map (juxt key (comp inc val))) {:a 1})
14:24clojurebot{:a 2}
14:25justin_smithseems like a "transduce-val" would help there, yeah
14:26justin_smithjonathanj: "sequence" basically exists because (into () ...) reverses
14:26justin_smithafaik
14:28jonathanjand if i wanted to transform my map from {:a 1} to {:a [1 (inc 1)]}?
14:28jonathanjmaybe i'm trying to do this the wrong way around, but i don't really see a better option
14:29domgetter,(into {} (map (fn [[k v]] [k [v (inc v)]]) {:a 1 :b 2}))
14:29clojurebot{:a [1 2], :b [2 3]}
14:29domgetterIs that the output you want?
14:29jonathanjyes, but not the syntax i want
14:30justin_smith,(defn map-vals [f] (map (juxt key (com f val))))
14:30clojurebot#error {\n :cause "Unable to resolve symbol: com in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: com in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: com in this conte...
14:31justin_smith,(defn map-vals [f] (map (juxt key (comp f val))))
14:31clojurebot#'sandbox/map-vals
14:31justin_smith,(into {} (map-vals inc) {:a 0 :b 21})
14:31clojurebot{:a 1, :b 22}
14:32justin_smithit becomes less flexible if you bake the into part in too, imho
14:38jonathanji think i ask this pretty often
14:38jonathanjwhat's the most efficient way to get the last element of something?
14:38domgetter,(transduce (map (fn [[k v]] [k [v (inc v)]])) conj {} {:a 4 :b 5 :c 6})
14:38clojurebot{:a [4 5], :b [5 6], :c [6 7]}
14:39domgetterjonathanj: is that syntax still "bad"?
14:39justin_smithjonathanj: for a vector, it's peek
14:39jonathanjjustin_smith: and a list? `last`?
14:39justin_smith"best" "only" meh
14:40justin_smithif you have to look at the last thing, avoid using a list / seq
14:40jonathanjmaybe it's best to construct my thing in reverse then
14:40jonathanjputting something at the head of a list/vec is efficient and is always `cons`?
14:41justin_smithputting something at the head of a list is efficient, putting something at the end of a vec is efficient
14:41domgetterjonathanj: putting at the head of list is constant and you can do it with cons or conj. putting at the tail of a vec is constant and you use conj
14:41domgetter*near constant
14:42jonathanj,(first (conj (list 4 5 6) 1))
14:42clojurebot1
14:42domgetteri.e. technically logarithmic but with a branching factor of 32
14:42jonathanj,(first (conj (vector 4 5 6) 1))
14:42clojurebot4
14:42domgetterjonathanj: conj adds into a collection however it is efficient to do so
14:42TEttingerso who's been looking at the CHAMP tries for clojure...
14:43domgetterso for lists it's at the front, for vecs it's at the end
14:43domgetterand of course, for sets and maps, it's wherever because there's no order
14:51jonathanjhow do i reverse the sort order of sort or sort-by?
14:53ridcully_,(sort-by identity #(compare %2 %1) [42 23 666])
14:53clojurebot(666 42 23)
14:54jonathanjthanks
14:54TEttingernice choices all around
14:55jonathanjfound this too, which goes a little further: https://groups.google.com/forum/#!msg/clojure/VVVa3TS15pU/9WrN_9Mfao4J
14:59justin_smith,(sort (comp - compare) [1 2 42 3 4 -1]) ; easiest reverse sort, I think
14:59clojurebot(42 4 3 2 1 ...)
15:00justin_smithsorry, I'm doing some C for a personal project, so my clojure code's gonna be nothing but juxt, comp, partial...
15:04TEttinger,(sort #(compare %2 %) [42 23 666])
15:04clojurebot(666 42 23)
15:05TEttinger,(sort-by > compare [42 23 666])
15:05clojurebot(42 23 666)
15:05TEttingerno idea what that does
15:05justin_smithTEttinger: clearly nothing useful
15:05TEttinger(doc sort-by)
15:05clojurebot"([keyfn coll] [keyfn comp coll]); Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array."
15:06TEttinger(doc sort)
15:06clojurebot"([coll] [comp coll]); Returns a sorted sequence of the items in coll. If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array."
15:06TEttinger,(sort-by - [42 23 666])
15:06clojurebot(666 42 23)
15:06TEttingergolf win!
15:06justin_smithonly works on numbers though
15:07TEttinger,(sort-by - ["A" "B" "c"])
15:07clojurebot#error {\n :cause "java.lang.String cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers minus "Numbers.java" 104]}]\n :trace\n [[clojure.lang.Numbers minus "Numbers.java" 104]\n [clojure.core$_ invokeStatic "core.clj" 1018]\n [clojure.core$_ invoke "core.clj" -1]\n [clo...
15:07TEttingeraw
15:07TEttingerI thought it would call compare
15:08sdegutisHi
15:08sdegutis!
15:08jonathanjis there a cider command to set the previously executed repl command as the current repl text?
15:09jonathanjthe only way i know how to do it is position my cursor on the previous command and hit enter
15:09hlolliIm trying to access this resource: /home/hlolli/.m2/repository/org/clojars/hlolli/panaeolus/0.2.0-RELEASE/panaeolus-0.2.0-RELEASE.jar/samples/kicks/kick1.wav but obviously from my API (csound) wont find it trough /src/samples/kicks/kick1.wav how would I best go about accessing this .wav file?
15:09TEttinger,(rseq(sort["A" "B" "c"]))
15:09clojurebot#error {\n :cause "clojure.lang.ArraySeq cannot be cast to clojure.lang.Reversible"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.ArraySeq cannot be cast to clojure.lang.Reversible"\n :at [clojure.core$rseq invokeStatic "core.clj" 1513]}]\n :trace\n [[clojure.core$rseq invokeStatic "core.clj" 1513]\n [clojure.core$rseq invoke "core.clj" -1]\n [sandbox$eval169 invokeS...
15:09jonathanj(which is awful)
15:09TEttingergah
15:09TEttingerhlolli: looks like that's a resource
15:10TEttingerhttp://clojuredocs.org/clojure.java.io/resource
15:10hlolliyes, this is a resource, and cloujre will find it. But my api will not.
15:11TEttingerwhat do you mean?
15:11TEttingerwhat are you trying to do, first
15:11TEttingerare you making an API for csound?
15:12hlolliSo this is an audio sample that I need csound to load into a table. I already am able to load it in my devel project, but now I want to create a clojar for my friends to use, just by using :dependencies.
15:13hlolliso when I do $lein new project and add :dependencies, the folder tree of course will look entirely different from ex. pulling from github.
15:13TEttingerso you want to make the resource available to people using your library?
15:13TEttingerI think by default it is
15:13hlolliyes
15:13TEttingerthey need to know where it is in the jar I guess
15:14TEttingerit's simple enough to expose the resource with a "getter" like fn
15:14TEttinger(assuming you can modify the lib)
15:15TEttinger(basically as long as there isn't some final version up I mean)
15:15hlolliwell, these are many many samples. Im leaning towards not including the audio samples in clojar and make a script to download it specifically.
15:16hlolliOr just copy it from the clojar, then users will have two copies, not cool disk efficiency. Using directly trough to jar file would be ideal.
15:28TEttingerhlolli: maybe the samples could be in separate dependencies, grouped by some quality (which instrument maybe?)
15:30hlolliok, I think I've found what my misunderstanding was. So I use io.resource for extracting the string, and as far as I see, it will start with "jar:file...etc.." if the resource is from jar otherwise normally from git pull folder.
15:30justin_smithhlolli: that's just the printed form of the resource handle - but when you read from it you will get the contents of the file
15:31TEttingeryour "git pull folder" should have a resources directory, where these samples are
15:31hlolliyes, but this path here would work fine? "jar:file:/home/hlolli/.m2/repository/org/clojars/hlolli/panaeolus/0.2.1-alpha/panaeolus-0.2.1-alpha.jar!/samples/kicks/kick1.wav"
15:32TEttingerthat !/ is a bit odd
15:32hlolliit's from non-dev repl (prn (io/resource "samples/kicks/kick1.wav"))
15:33hlolliwell, only one way to find out if this path functions
15:33TEttingerprn is going to print the string representation, not necessarily a valid path
15:33TEttingerI have no idea if you can reconstruct a file from what pr prints
15:34hlolliyes say (str "this is a csound string that needs path: " (io/resource "samples/...etc"))
15:35hlollino I take the prn out of course :)
15:35TEttingeruh hm. there, you're calling .toString on the resource when you use str
15:35TEttingerwhich may give different output from what pr prints
15:35hlolli(io/resource "samples/kicks/kick1.wav") returns #object[java.net.URL 0x5f32e673 "jar:file:/home/hlolli/.m2/repository/org/clojars/hlolli/panaeolus/0.2.1-alpha/panaeolus-0.2.1-alpha.jar!/samples/kicks/kick1.wav"]
15:36TEttinger,(print {:a 1 :b "\\\""})
15:36clojurebot{:a 1, :b \"}
15:36hlolliyes, I sure dont want this #object crap around it.
15:36TEttinger,(pr {:a 1 :b "\\\""})
15:36clojurebot{:a 1, :b "\\\""}
15:36TEttingeryeah, you're trying to print a file
15:36justin_smithTEttinger: in a repl started from /home/justin/bench.jar this returns the full ns contents as expected (slurp "jar:file:/home/justin/bin/bench.jar!/clojure/java/io.clj")
15:37TEttingerwoo justin_smith
15:37justin_smiththat returns the full text of the namespace
15:37justin_smithso yeah, hlolli, that path string looks good, for accessing something inside a jar
15:37TEttingerok, pr-str should get you a path string
15:37TEttingerprint won't I think, it will do that #object literal
15:38justin_smithslurp won't be the right thing, since it's not a text file - but you can read from it and then write to a file
15:38hlolliyes, I give it a try, of course just returning a string is what I want, don't print anything
15:38TEttinger,(count (pr-str {:a 1 :b "\\\""}))
15:38clojurebot17
15:39justin_smithhlolli: this gist shows how to extract files from a jar - you should be able to use some of what's demonstrated there to write out a wav file from a jar
15:39justin_smithhttps://gist.github.com/noisesmith/b4a57a3154b736e2f9c1
15:39hlolliok cool, now I slurped the wav file, emacs frozen :)
15:40justin_smithas I said, slurp won't work properly because it's not a text file
15:40justin_smithand emacs hates lines that long, they make it freeze up
15:40hlollihehe, no harm in this case
15:51sdegutisHi!
16:30BRODUSsay if i had (transduce (comp (filter odd?) (map inc)) + (range 5)), does transduce send the elements of its collection one by one through supplied transducer and accumulates with +, or does it pass the whole collection through each transducer then perform a final reduce operation?
16:40scottmsulIn clojure, "partial" curries arguments from the left. Is it possible to curry arguments from the right? It wouldn't be hard to write, just wondering if clojure has a built-in function.
16:41justin_smiththat isn't built in, and partial is not the same as currying
16:41justin_smith(there are also libs that provide currying)
16:42TEttinger,(defmacro ??????
16:42clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
16:49TEttingersighing... I don't understand the sandbox for clojurebot
16:49TEttingerany macro macro seems to fail
16:49TEttinger,(defmacro חֶלקִי [f & args] (fn [& args2] true))
16:49clojurebot#'sandbox/חֶלקִי
16:49TEttinger,((חֶלקִי map [1 2 3]) inc)
16:49clojurebot#error {\n :cause "EvalReader not allowed when *read-eval* is false."\n :via\n [{:type java.lang.ExceptionInInitializerError\n :message nil\n :at [sun.reflect.NativeConstructorAccessorImpl newInstance0 "NativeConstructorAccessorImpl.java" -2]}\n {:type java.lang.RuntimeException\n :message "EvalReader not allowed when *read-eval* is false."\n :at [clojure.lang.Util runtimeException "Util....
16:49firstdayonthejobis there any way to set the anti-forgery token in ring from client-side using plain jquery for a POST?
16:52justin_smithTEttinger: yeah, works locally, must be some bot weirdness
16:53TEttingerI mean, I'm very happy hiredman has figured out how to allow defmacro at all! I just wish I understood how it worked a bit better
16:57hlolliWell Justin, I've hit a wall in this path quest. I think your extract function will be ideal solution. But how can I locate the path the the dependency .jar file from maven repositories that can be located from all users with different setup.
16:58hlolliMaybe I say fuck this, add a wget-ish function to just download the samples to a subdirectory.
16:59hlolliwell, nevermind. I think I will just do that. The obvious thing that I missed out, that when a file is inside a .jar it's not a useable file.
16:59hlolli(from other sources than java/clojure)
17:08justin_smithhlolli: you wouldn't need that whole extract function - really it's just a loop that reads a buffer from your resource then writes it to a file. You just can't use the character oriented methods, you need the binary ones.
17:19TEttinger,(sort ‍[1 2 3 4 5])
17:19clojurebot(5 4 3 2 1)
17:19TEttinger,(sort [1 2 3 4 5])
17:19clojurebot(1 2 3 4 5)
17:20TEttinger,(sort ‍"ABC")
17:20clojurebot(\C \B \A)
17:21TEttingerjustin_smith: more fun with unicode
17:23justin_smith~TEttinger is a gaslighting unicode monster.
17:23clojurebotA nod, you know, is as good as a wink to a blind horse.
17:25TEttingerjustin_smith: I'm looking into http://unicode.org/reports/tr51/#Emoji_Modifiers_Table for when java 9 gets emoji support
17:26justin_smithTEttinger: some of those diagrams are really odd taken out of context
17:30ridcully_that will be glorious! :darmok:&:jalad:@:tanagra:
17:31TEttinger,(reduce 💋‍ [1 2 3])
17:31clojurebot6
17:37TimMcThe Unicode Consortium should just cancel emoji. :-/
17:38TimMcI'm all for the selectable skin color *if* we're going to have little pictures, but do they not realize how complicated this is going to get later?
17:39TEttinger,(🐷 💋‍ 1 2 3 4)
17:39clojurebotOink. 10
17:40TimMcSomeone's going to want the money bag to show a yen symbol instead of $; someone will want the calendar to show a specific date; someone will want the clocks to allow more precision.
17:40TEttinger24-hour clocks
17:40TimMcyou know it
17:40justin_smithTimMc: skip to the year 2050, unicode consortium is defining a standard for puppy gifs as part of a character set. Kitten gifs are already fully implemented and widely supported.
17:41TEttingerTimMc: http://www.ebay.com/itm/RUSSIAN-WATCH-SOUVENIR-USSR-STALIN-NEW-24HOURS-WA-67-/301819647052?hash=item4645da544c:g:MkcAAOxygKZSRqAD
17:41TEttingerjustin_smith: doge standard
17:41TimMc2060: 3 deaths have been attributed to a fight over whether :jackdaw: and :crow: should be merged.
17:42TEttinger2062: the unicode consortium is threatened by civil war.
17:42justin_smithhaha
17:43TimMcTEttinger: I saw a 24 hr analog clock when I was visiting Akamai.
17:43TEttingerAbrahim Linc💋‍ln stands little hope of reuniting with the punicode confederacy.
17:43TEttingerwhat is akamai's business again? trackers?
17:44TEttingeror were they like cloudflare?
17:44TimMcCDN and caching
17:44TEttingerah ok
17:44justin_smithTEttinger: I think they did caching
17:44justin_smithyeah
17:44TimMcVery big player.
17:45TEttingerapparently cloudflare is taking over luajit now that mike pall is leaving (or so he says)
18:05ahhhhttps://doyle.ninja/limechat-crash.gif
18:18noncom|2all fun is that emoji hassle
18:19noncom|2cool if by 2050 we'll have a symbolic alphabet to describe almost anything
18:19noncom|2does not it look like history repeats itself with all the hieroglyphic things ?
18:20p_l... reminds me of a sci-fi story where a linguistic experts talks about how "letter 'L', which means to load into computer, used to be part of the word 'load'"
18:20noncom|2honestly, i think that a refined set of pictograms would do for better intefaces
18:20noncom|2p_l: haha, yeah
18:21noncom|2also reminds me of Blindsight (the novel by Peter Watts) :D
18:22noncom|2actually, emojis serve as a means for the quest of the structure of consciousness and intellect.
18:22noncom|2what if a real AI can only be programmed with emojis ?
18:32ridcully_wasn't it l,shift-o to shortcut load on the c64?
19:19ben_vulpesblindsight was amazing
19:50noncom|2yeah, i'm going through echopraxia now :) it's going to be a trilogy btw
19:51BRODUShow would I type this shortcut?
19:51BRODUSnvm wrong channel
21:31breezeliany one here?
21:31domgetterI'm here
21:33breezelii just start learning clojure ,read book clojure programing
21:34breezeliAn example does not understand
21:34breezeliCan you help me to disassemble it
21:34domgetterI can try. What's the problem?
21:35breezeliWait a moment
21:36breezeli(reduce
21:36breezeli (fn [m v]
21:36breezeli (assoc m v (* v v)))
21:36breezeli {}
21:36breezeli [1 2 3 4])
21:36breezelithis
21:38breezeliCan you help me to disassemble it,Turn into no "reduce" format
21:38domgetterThat does something like the following: (assoc (assoc (assoc (assoc {} 1 (* 1 1)) 2 (* 2 2)) 3 (* 3 3)) 4 (* 4 4)) which would make {1 1 2 4 3 9 4 16}
21:39domgetterit associates each value with its square
21:39domgetterbreezeli: what language are you most familiar with?
21:40breezeliChinese
21:40breezelithank you Let me think about it.
21:41domgetterbreezeli: I meant what programming language. I can write it in a different programming language to help you understand
21:41breezelic# or java
21:42breezelihoho! Clojure is hard to get
21:42justin_smithit's a lot like for(i in [1 2 3 4]) { m.put(i, i*i);}
21:42justin_smithexcept our maps are not mutable, so you can't actually do that
21:43breezelithank you
21:43justin_smithbreezeli: the important difference is you don't mutate the values in reduce - you return a new value for each step
21:43domgetterbreezeli: Here is something to help you understand reduce: (reduce + [1 2 3 4]) == (((1 + 2) + 3) + 4)
21:45breezeliI try to understand, this book is too jumping
21:45domgetterYou can have an "initial value" (reduce + 0 [1 2 3 4]) == ((((0 + 1) + 2) + 3) + 4)
21:45breezelithank all
21:48breezeliNow clear! thank all,i love you
21:48domgetterbreezeli: Here is some java that is similar: https://gist.github.com/domgetter/93609123c0b8155220e8
21:49breezelithanks you
22:49domgetterWhat's the best way to remove the last character from a string?
22:49justin_smith,(let [s "hello, worldo"] (subs s 0 (dec (count s))))
22:49clojurebot"hello, world"
22:50domgetterI'll go look up subs. Thank you
22:50justin_smithcount s is constant time (since strings are a counted type), so that should be the fastest option
22:50domgetteroh it's just the substring. Got it, derrr
22:52domgetterHow would you recommend I address the edge case of an empty string?
22:52domgetter(subs "" 0 (dec count "")) is a StringIndexOutOfBoundsException. Just wrap in an if?
22:52justin_smith(subs "" 0 (max 0 (dec count "")))
22:52justin_smithkind of ugly, but works
22:52domgetterah ha!
22:52justin_smithand not slow
22:53domgetterI prefer the declarative route when I can. Thanks!
22:53justin_smithalso, it doesn't handle nil
22:54domgetterI'll keep that in mind. In this case, the atom is always a string, but you never know...
22:54justin_smith(some-> ...) is good for short circuiting nil
22:56domgetterIs (apply str (butlast "hello")) slower?
22:56justin_smithyes, by at least 100x
22:56justin_smithI mean if that doesn't matter, it doesn't matter
22:56domgetterright
22:56domgetterbut is it slower due to constant factors or linear sequence generation
22:57domgettercause it would seem like both solutions are "linear"
22:57justin_smithallocation churn, lazy sequence, constructing a large number of short lived Char objects...
22:57justin_smithit's a linear factor of about 100x
23:05justin_smithdomgetter: some hard numbers to back up what I was saying https://gist.github.com/noisesmith/71b0c6c8d48c91fcb30d
23:06justin_smith,(/ 2565.0, 62.72)
23:06clojurebot40.89604591836735
23:07justin_smithOK, so not quite a hundred time slower
23:07justin_smithonly 40 times slower :P
23:11domgetterYea I did a few in a repl and the butlast version grew linearly but the count version stayed around the same time no matter the input length
23:12justin_smithsounds about right
23:12domgetterso it's probably logarithmic
23:12justin_smithstrings are immutable, but subs can still pull some magic with the underlying java stuff
23:12domgetterI know of the #_ reader macro to ignore the next form. Is there one to ignore the next two forms for maps and bindings?
23:12domgetterlike #__ or something?
23:12justin_smith#_#_
23:13justin_smith,(+ #_#_ dog cat 2 2)
23:13domgetterawesome. I was putting #_ individually
23:13clojurebot4
23:13domgetterdo they stack?
23:13justin_smithdomgetter: some people really don't like stacked #_, but I think in a hash map it makes sense
23:13justin_smithyes
23:13domgettercan I put an arbitrary number?
23:13justin_smithplease don't
23:13justin_smithreaders will hate you
23:13domgetterI'll stick to two, I promise :P
23:14domgetterI have a cond and I'm testing things so I'm ignoring pairs
23:15justin_smithmakes sense, yeah, #_#_ is handly for that, or a ky / val in a map
23:15justin_smithor in let
23:15domgetteryea and loop bindings
23:15domgetterBut I usually don't go too hogwild in those
23:16justin_smithin unrelated news, I finished a project in C this weekend - a GUI display that runs on the linux framebuffer (or in an X window) as an output-only display for a synth running on the raspberry pi
23:41domgetterThat sounds pretty neat. Are you using it for debug purposes at first?