#clojure log - Dec 27 2015

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

2:17 jeaye: How 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?

2:20 ridcully_: (doc partition-by)

2:20 clojurebot: "([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."

2:21 jeaye: Ah, even nicely named.

4:30 cfleming: TEttinger: My pleasure!

4:35 TEttinger: I'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

4:35 (it's a mind-bending experience switching between VS's mostly sane shortcuts and IntelliJ's very odd defaults, like alt-f7)

5:37 lokien: Any good books/courses about cljs? I can't find anything useful

6:27 piotrts: hello

6:27 is 4clojure down right now?

6:32 LuminousMonkey: Looks to be down: http://downforeveryoneorjustme.com/4clojure.com

6:39 piotrts: oh, thanks

10:21 visof: hi guys is clojars.org down?

10:22 beaky: it seems down to me too

10:22 no ping, cant curl, etc

10:24 visof: beaky: no alternatives?

10:24 beaky: i dont know :(

10:24 maven? :D

10:25 Frozenlock: I wonder if it's why I can't run lein in a project...

10:25 visof: Frozenlock: yep

10:26 is there anyone of server maintainers here?

10:26 Frozenlock: surely there's a flag to disable the clojars check -_-

10:29 there's that https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L127

10:33 visof: https://twitter.com/clojars/status/681130080773472256

11:46 jonathanj: is there a convenient way to determine the length of an InputStream?

11:47 justin_smith: jonathanj: InputStream is an interface. I could easily make one that returns the same byte over and over forever.

11:48 .available tells you how many bytes are ready right now

11:48 jonathanj: how about a BufferedImage?

11:48 i'm reading an object from a PDF, all i want to know is how big the object is

11:48 so presumably it's not infinite

11:48 (using PDFBox, in case that's relevant)

11:49 justin_smith: how about getWidth and getHeight?

11:49 those should give you a very good idea of the size in pixels at least

11:49 jonathanj: yes, but that's mostly irrelevant

11:49 justin_smith: but it supports compressed formats, so...

11:49 jonathanj: exactly

11:50 i just want the length of the raw data contained by the object, but i can't figure out how to find that

11:51 the 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:51 justin_smith: once 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:51 jonathanj: which seems like a lot of effort

11:52 https://pdfbox.apache.org/docs/2.0.0-SNAPSHOT/javadocs/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.html

11:52 justin_smith: fair enough, perhaps a BufferedImage is going in the wrong direction then

11:53 justin_smith: jonathanj: you could try (-> pdfimage .createInputStream .available)

11:53 it could be that all of it would be available at once?

11:53 when 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:53 but in this case I think more info is available about it

11:55 jonathanj: it feels like relying on that is a mistake though

11:55 available only dictates how much can be read without blocking

11:55 not how much is available to read in total

11:56 justin_smith: why would it block if all the data is right there in memory already?

11:56 really 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:58 jonathanj: justin_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:58 so i think reading it all in and throwing it away is probably the only bet

11:58 justin_smith: why do you need to know the size?

12:00 jonathanj: i'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:03 okay, 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:05 justin_smith: oh, cool

12:29 lokien_: Is boot any better than leiningen?

12:51 Hello?

12:56 j-pb: It's me.

12:56 justin_smith: no, this is dog

12:56 j-pb: hahaha

12:57 the only real advantage of slack over irc is giphy

12:58 lokien_: It's you I'm looking for, j-pb

12:58 j-pb: whas it it :)?

12:59 lokien_: Are you using boot? :(

12:59 j-pb: nope

12:59 good old leiningen :)

12:59 bood holds some promisies, but it's imperative nature doesn't justify the gains imho

12:59 lokien_: Bu-ut cljs tutorial uses boot and I'm super sad now

13:00 j-pb: yeah, it looks easier at first, but I rather write a bit more config that's declarative than magic imperative stuff :)

13:00 * lokien_ hates imperativeness too

13:00 j-pb: cljsbuild is actually pretty easy to setup in leiningen once you got the hang of it

13:00 all the config options ae dauntig at first but you only need a very small percent of all that

13:01 lokien_: what is it that you're having trouble with :)?

13:01 lokien_: I'll check it out then. Is modern cljs a good tutorial for a noob?

13:02 I wanted to lick some cljs, but I hit a brick wall

13:02 j-pb: to be honest I don't know

13:02 i'd do lein new figwheel myprojectname -- --reagent

13:02 justin_smith: yes, this is patrik

13:02 lokien_: justin_smith to save the day

13:03 As always

13:03 justin_smith: haha

13:03 j-pb: that sets up a figwheel project for you which means nicer dev flow

13:03 and automatically makes it a reagent project as well

13:03 with that you have everything running which is nice and you can do the rest by exploration I think :)

13:03 lokien_: j-pb: where did you learn like.. How to do cljs stuff? It's not the same as in clj an-

13:04 Were you js developer earlier?

13:04 j-pb: time and persistence

13:04 no clojure dev

13:04 never touched js before

13:04 tbh it's not that hard or much :)

13:04 lokien_: Good for you, it's a laxative for brains

13:05 j-pb: the hardest thing is the tooling

13:05 and figwheel does 99% of that for you

13:05 lokien_: I have some troubles with learning. I have to understand something, I'm not able to memorize stuff without understanding the thing

13:06 And I end up with 20 tabs in my browser and a headache

13:06 j-pb: understanding is relative

13:06 you wont' understand the intricasies of the Js or jvm JIT

13:06 but luckily you don't need to

13:06 the gist of cljs is this

13:06 lokien_: Jvm=magic

13:07 I like it to stay this way

13:07 j-pb: cljs --cljs compiler--> js --google closure--> executable js

13:07 lokien_: Yeah, the stuff I know!

13:07 j-pb: cljs has a somewhat naive clj to js compiler and relies on a lot of google closure goodness to optimize it

13:08 lokien_: If it's a bug in my cljs, I won't have to debug js? Just cljs, right?

13:08 j-pb: figwheel is a tool that automatically recompiles and reloads your files to a instance of your web applicatoin running

13:08 lokien_: most of the time

13:08 but not always

13:08 lokien_: Uhm, I think I saw guys making flappy bird with figwheel

13:08 j-pb: yeah

13:08 lokien_: j-pb: so I have to learn some js?

13:09 j-pb: nope

13:09 not explicitly at least

13:09 of course you will learn js, but at least I only learned what was nessecary as I debuged my clojure code

13:09 there is no need to learn vanilla js first

13:09 lokien_: Okay then

13:10 And I can use electron to make pretty gui stuff with it, right?

13:11 j-pb: ah well if you want to do desktop apps yeah :_

13:11 :_

13:11 goddamit :)

13:11 lokien_: :D

13:12 j-pb: however I found that it's somewhat nice to have a server running somewhere and then just use the browser

13:12 lokien_: My girlfriend is savage about my cli clojure apps, so I have to

13:12 justin_smith: lokien_: " I'm not able to memorize stuff without understanding the thing" -- yet you speak English!

13:12 or at least write it well

13:13 lokien_: were you trying to use clojure in the cli via lein?

13:13 lokien_: justin_smith: but my head ached for like 7 months, reading my first english books

13:14 justin_smith: I've made some programs that ran in terminal

13:15 TEttinger: the JVM Clojure lib called seesaw, with the "insubstantial" styling stuff, isn't bad-looking

13:15 lokien_: I'm intrigued by quil

13:16 j-pb: not for gui stuff

13:16 TEttinger: yeah, quil doesn't do uh common anything for GUIs. I think you'd need your own text input boxes, copy/paste support...

13:17 play-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:18 (it will however outperform swing if you ever do anything animated)

13:18 (swing is the main java GUI lib)

13:19 I think JS on the desktop using electron or the like is a decent way to go.

13:19 there's also CEF

13:19 not sure if there's a decent clojure binding

13:20 lokien_: What is cef?

13:23 Uh, chromium embedded framework, in c++

13:23 * lokien_ gags

13:25 TEttinger: huh, this looks not bad https://github.com/karad/lein_template_descjop

13:25 lokien_: you'd be surprised how many apps use it

13:26 there's a binding for Java, wasn't sure if there was one for Clojure

13:26 lokien_: TEttinger: pretty logo, I'm sold

13:26 TEttinger: it'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:27 lokien_: Never used any of thiss stuff

13:27 But reagent looks good

13:28 kenrestivo: it's got a learning curve, but it's very powerful

13:29 lokien_: That's what they said about emacs

13:29 hlolli: TEttinger, 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:30 TEttinger: I have never used Om or anything like it. paging justin_smith, justin_smith to the channel

13:31 lokien_: I've just googled "justin smith clojure" and man, those sideburns

13:32 justin_smith: hello

13:35 hlolli: hello 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:35 it just sits in the .jar file in .m2 subdirectory, not much use if the user can't edit it.

13:44 justin_smith: hlolli: 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:45 hlolli: or you can just expect them to make the file available, and tell them what should be in it

13:46 this is what lazybot does, for example

13:46 hlolli: yes, 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:46 justin_smith: exactly

13:47 hlolli: ok sounds like a solution.

13:58 justin_smith: TIL C has better support for static initialization of data structures with inline literals than java does

14:03 domgetter: When 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:04 BRODUS: domgetter: i think CIDER for emacs has support for this

14:04 domgetter: BRODUS: Ah so I can't just do it with any IDE/text editor?

14:05 BRODUS: you could send a form to the repl or you could overlay the result into the buffer

14:05 domgetter: other than copy-pasting the form, what do you mean "send a form to the repl"

14:06 BRODUS: like evalute the expression immediately behind my cursor and show the output in the repl

14:07 assuming you have two views open, one is the file youre editing and the other is the repl

14:07 ridcully_: i'd assume, that any editor, that "support" clojure, can do this

14:07 domgetter: "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:07 ridcully_: in vim-fireplace it's :Eval and cpp

14:08 justin_smith: domgetter: what you wwant to look for, generally, is "nrepl bindings", this is how most editors interact with clojure inside the editor.

14:08 BRODUS: i was speaking about emacs, but there should be something similar in a clojure supported IDE

14:08 domgetter: Also I have no idea what "overlay the result into the buffer" means. Do you have any resources I could read up on?

14:08 justin_smith: domgetter: cursive, emacs, light-table, and vim are the best working examples of this I know of

14:10 BRODUS: domgetter: sorry for the confusion, in emacs a 'buffer' is a view, its usually filled with the text you're editiing

14:11 domgetter: BRODUS: yea, I'm coming at this with zero knowledge of emacs.

14:12 Thank you for your input, everyone :)

14:13 jonathanj: using transducers with maps seems a bit awkward

14:14 like, 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:15 justin_smith: jonathanj: or (filter (fn [e] (predicat (val e)))

14:15 or (filter (comp predicate val))

14:15 jonathanj: that is a little nicer but still

14:16 that works for filter, but what about map?

14:16 like if you want to preserve the key but alter the value

14:16 justin_smith: really depends on what you want the map to return - more entries?

14:16 sorry, lag here

14:17 so 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:17 domgetter: justin_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:17 jonathanj: so if you want to only transform the values it gets ugly because you need to add (into {}) in too

14:18 justin_smith: domgetter: typically with nrepl your result is visible on the client side, not the server side

14:18 jonathanj: i'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:18 justin_smith: jonathanj: maybe it's just stockholm syndrome but I'm not picturing the easier thing - what would it look like?

14:19 domgetter: justin_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:19 justin_smith: this isn't a repl inside their editor?

14:20 domgetter: I ran lein repl in a command prompt, and told LightTable to connect to the nrepl server that lein made

14:20 or are you talking about the conf speakers

14:20 justin_smith: domgetter: I didn't ask what you did, I asked what they did

14:20 jonathanj: justin_smith: well the xf would maybe look something like: (comp (filter (comp this-one? val)) (map-vals inc))

14:20 domgetter: justin_smith: https://www.youtube.com/watch?v=enwIIGzhahw&t=6m6s

14:20 justin_smith: domgetter: typically people have a repl inside the editor

14:21 domgetter: okay so they were never connecting to an external repl AND evaluating forms that showed up in it?

14:21 justin_smith: domgetter: yeah, that repl is part of his editor

14:21 domgetter: ah okay. That was my fundamental confusion

14:22 justin_smith: domgetter: well, the weird part is that they ARE connected to an nrepl server

14:22 but usually it is implicitly started, and all results show up in their editor

14:22 jonathanj: ,(sequence (map (comp inc val)) {:a 1})

14:22 clojurebot: (2)

14:22 domgetter: okay, okay

14:22 awesome, thank you for clearing that up for me

14:22 justin_smith: domgetter: 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:23 jonathanj: looks like (sequence) turns it into a sequence

14:23 justin_smith: jonathanj: right, and your (comp inc val) ensures you wont get the full entry, just the val

14:24 ,(

14:24 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

14:24 justin_smith: ,,(into {} (map (juxt key (comp inc val))) {:a 1})

14:24 clojurebot: {:a 2}

14:25 justin_smith: seems like a "transduce-val" would help there, yeah

14:26 jonathanj: "sequence" basically exists because (into () ...) reverses

14:26 afaik

14:28 jonathanj: and if i wanted to transform my map from {:a 1} to {:a [1 (inc 1)]}?

14:28 maybe i'm trying to do this the wrong way around, but i don't really see a better option

14:29 domgetter: ,(into {} (map (fn [[k v]] [k [v (inc v)]]) {:a 1 :b 2}))

14:29 clojurebot: {:a [1 2], :b [2 3]}

14:29 domgetter: Is that the output you want?

14:29 jonathanj: yes, but not the syntax i want

14:30 justin_smith: ,(defn map-vals [f] (map (juxt key (com f val))))

14:30 clojurebot: #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:31 justin_smith: ,(defn map-vals [f] (map (juxt key (comp f val))))

14:31 clojurebot: #'sandbox/map-vals

14:31 justin_smith: ,(into {} (map-vals inc) {:a 0 :b 21})

14:31 clojurebot: {:a 1, :b 22}

14:32 justin_smith: it becomes less flexible if you bake the into part in too, imho

14:38 jonathanj: i think i ask this pretty often

14:38 what's the most efficient way to get the last element of something?

14:38 domgetter: ,(transduce (map (fn [[k v]] [k [v (inc v)]])) conj {} {:a 4 :b 5 :c 6})

14:38 clojurebot: {:a [4 5], :b [5 6], :c [6 7]}

14:39 domgetter: jonathanj: is that syntax still "bad"?

14:39 justin_smith: jonathanj: for a vector, it's peek

14:39 jonathanj: justin_smith: and a list? `last`?

14:39 justin_smith: "best" "only" meh

14:40 if you have to look at the last thing, avoid using a list / seq

14:40 jonathanj: maybe it's best to construct my thing in reverse then

14:40 putting something at the head of a list/vec is efficient and is always `cons`?

14:41 justin_smith: putting something at the head of a list is efficient, putting something at the end of a vec is efficient

14:41 domgetter: jonathanj: 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:41 *near constant

14:42 jonathanj: ,(first (conj (list 4 5 6) 1))

14:42 clojurebot: 1

14:42 domgetter: i.e. technically logarithmic but with a branching factor of 32

14:42 jonathanj: ,(first (conj (vector 4 5 6) 1))

14:42 clojurebot: 4

14:42 domgetter: jonathanj: conj adds into a collection however it is efficient to do so

14:42 TEttinger: so who's been looking at the CHAMP tries for clojure...

14:43 domgetter: so for lists it's at the front, for vecs it's at the end

14:43 and of course, for sets and maps, it's wherever because there's no order

14:51 jonathanj: how do i reverse the sort order of sort or sort-by?

14:53 ridcully_: ,(sort-by identity #(compare %2 %1) [42 23 666])

14:53 clojurebot: (666 42 23)

14:54 jonathanj: thanks

14:54 TEttinger: nice choices all around

14:55 jonathanj: found this too, which goes a little further: https://groups.google.com/forum/#!msg/clojure/VVVa3TS15pU/9WrN_9Mfao4J

14:59 justin_smith: ,(sort (comp - compare) [1 2 42 3 4 -1]) ; easiest reverse sort, I think

14:59 clojurebot: (42 4 3 2 1 ...)

15:00 justin_smith: sorry, I'm doing some C for a personal project, so my clojure code's gonna be nothing but juxt, comp, partial...

15:04 TEttinger: ,(sort #(compare %2 %) [42 23 666])

15:04 clojurebot: (666 42 23)

15:05 TEttinger: ,(sort-by > compare [42 23 666])

15:05 clojurebot: (42 23 666)

15:05 TEttinger: no idea what that does

15:05 justin_smith: TEttinger: clearly nothing useful

15:05 TEttinger: (doc sort-by)

15:05 clojurebot: "([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:06 TEttinger: (doc sort)

15:06 clojurebot: "([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:06 TEttinger: ,(sort-by - [42 23 666])

15:06 clojurebot: (666 42 23)

15:06 TEttinger: golf win!

15:06 justin_smith: only works on numbers though

15:07 TEttinger: ,(sort-by - ["A" "B" "c"])

15:07 clojurebot: #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:07 TEttinger: aw

15:07 I thought it would call compare

15:08 sdegutis: Hi

15:08 !

15:08 jonathanj: is there a cider command to set the previously executed repl command as the current repl text?

15:09 the only way i know how to do it is position my cursor on the previous command and hit enter

15:09 hlolli: Im 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:09 TEttinger: ,(rseq(sort["A" "B" "c"]))

15:09 clojurebot: #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:09 jonathanj: (which is awful)

15:09 TEttinger: gah

15:09 hlolli: looks like that's a resource

15:10 http://clojuredocs.org/clojure.java.io/resource

15:10 hlolli: yes, this is a resource, and cloujre will find it. But my api will not.

15:11 TEttinger: what do you mean?

15:11 what are you trying to do, first

15:11 are you making an API for csound?

15:12 hlolli: So 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:13 so when I do $lein new project and add :dependencies, the folder tree of course will look entirely different from ex. pulling from github.

15:13 TEttinger: so you want to make the resource available to people using your library?

15:13 I think by default it is

15:13 hlolli: yes

15:13 TEttinger: they need to know where it is in the jar I guess

15:14 it's simple enough to expose the resource with a "getter" like fn

15:14 (assuming you can modify the lib)

15:15 (basically as long as there isn't some final version up I mean)

15:15 hlolli: well, these are many many samples. Im leaning towards not including the audio samples in clojar and make a script to download it specifically.

15:16 Or 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:28 TEttinger: hlolli: maybe the samples could be in separate dependencies, grouped by some quality (which instrument maybe?)

15:30 hlolli: ok, 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:30 justin_smith: hlolli: 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:31 TEttinger: your "git pull folder" should have a resources directory, where these samples are

15:31 hlolli: yes, 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:32 TEttinger: that !/ is a bit odd

15:32 hlolli: it's from non-dev repl (prn (io/resource "samples/kicks/kick1.wav"))

15:33 well, only one way to find out if this path functions

15:33 TEttinger: prn is going to print the string representation, not necessarily a valid path

15:33 I have no idea if you can reconstruct a file from what pr prints

15:34 hlolli: yes say (str "this is a csound string that needs path: " (io/resource "samples/...etc"))

15:35 no I take the prn out of course :)

15:35 TEttinger: uh hm. there, you're calling .toString on the resource when you use str

15:35 which may give different output from what pr prints

15:35 hlolli: (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:36 TEttinger: ,(print {:a 1 :b "\\\""})

15:36 clojurebot: {:a 1, :b \"}

15:36 hlolli: yes, I sure dont want this #object crap around it.

15:36 TEttinger: ,(pr {:a 1 :b "\\\""})

15:36 clojurebot: {:a 1, :b "\\\""}

15:36 TEttinger: yeah, you're trying to print a file

15:36 justin_smith: TEttinger: 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:37 TEttinger: woo justin_smith

15:37 justin_smith: that returns the full text of the namespace

15:37 so yeah, hlolli, that path string looks good, for accessing something inside a jar

15:37 TEttinger: ok, pr-str should get you a path string

15:37 print won't I think, it will do that #object literal

15:38 justin_smith: slurp 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:38 hlolli: yes, I give it a try, of course just returning a string is what I want, don't print anything

15:38 TEttinger: ,(count (pr-str {:a 1 :b "\\\""}))

15:38 clojurebot: 17

15:39 justin_smith: hlolli: 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:39 https://gist.github.com/noisesmith/b4a57a3154b736e2f9c1

15:39 hlolli: ok cool, now I slurped the wav file, emacs frozen :)

15:40 justin_smith: as I said, slurp won't work properly because it's not a text file

15:40 and emacs hates lines that long, they make it freeze up

15:40 hlolli: hehe, no harm in this case

15:51 sdegutis: Hi!

16:30 BRODUS: say 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:40 scottmsul: In 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:41 justin_smith: that isn't built in, and partial is not the same as currying

16:41 (there are also libs that provide currying)

16:42 TEttinger: ,(defmacro ??????

16:42 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

16:49 TEttinger: sighing... I don't understand the sandbox for clojurebot

16:49 any macro macro seems to fail

16:49 ,(defmacro חֶלקִי [f & args] (fn [& args2] true))

16:49 clojurebot: #'sandbox/חֶלקִי

16:49 TEttinger: ,((חֶלקִי map [1 2 3]) inc)

16:49 clojurebot: #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:49 firstdayonthejob: is there any way to set the anti-forgery token in ring from client-side using plain jquery for a POST?

16:52 justin_smith: TEttinger: yeah, works locally, must be some bot weirdness

16:53 TEttinger: I 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:57 hlolli: Well 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:58 Maybe I say fuck this, add a wget-ish function to just download the samples to a subdirectory.

16:59 well, 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:59 (from other sources than java/clojure)

17:08 justin_smith: hlolli: 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:19 TEttinger: ,(sort ‍[1 2 3 4 5])

17:19 clojurebot: (5 4 3 2 1)

17:19 TEttinger: ,(sort [1 2 3 4 5])

17:19 clojurebot: (1 2 3 4 5)

17:20 TEttinger: ,(sort ‍"ABC")

17:20 clojurebot: (\C \B \A)

17:21 TEttinger: justin_smith: more fun with unicode

17:23 justin_smith: ~TEttinger is a gaslighting unicode monster.

17:23 clojurebot: A nod, you know, is as good as a wink to a blind horse.

17:25 TEttinger: justin_smith: I'm looking into http://unicode.org/reports/tr51/#Emoji_Modifiers_Table for when java 9 gets emoji support

17:26 justin_smith: TEttinger: some of those diagrams are really odd taken out of context

17:30 ridcully_: that will be glorious! :darmok:&:jalad:@:tanagra:

17:31 TEttinger: ,(reduce 💋‍ [1 2 3])

17:31 clojurebot: 6

17:37 TimMc: The Unicode Consortium should just cancel emoji. :-/

17:38 I'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:39 TEttinger: ,(🐷 💋‍ 1 2 3 4)

17:39 clojurebot: Oink. 10

17:40 TimMc: Someone'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:40 TEttinger: 24-hour clocks

17:40 TimMc: you know it

17:40 justin_smith: TimMc: 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:41 TEttinger: TimMc: http://www.ebay.com/itm/RUSSIAN-WATCH-SOUVENIR-USSR-STALIN-NEW-24HOURS-WA-67-/301819647052?hash=item4645da544c:g:MkcAAOxygKZSRqAD

17:41 justin_smith: doge standard

17:41 TimMc: 2060: 3 deaths have been attributed to a fight over whether :jackdaw: and :crow: should be merged.

17:42 TEttinger: 2062: the unicode consortium is threatened by civil war.

17:42 justin_smith: haha

17:43 TimMc: TEttinger: I saw a 24 hr analog clock when I was visiting Akamai.

17:43 TEttinger: Abrahim Linc💋‍ln stands little hope of reuniting with the punicode confederacy.

17:43 what is akamai's business again? trackers?

17:44 or were they like cloudflare?

17:44 TimMc: CDN and caching

17:44 TEttinger: ah ok

17:44 justin_smith: TEttinger: I think they did caching

17:44 yeah

17:44 TimMc: Very big player.

17:45 TEttinger: apparently cloudflare is taking over luajit now that mike pall is leaving (or so he says)

18:05 ahhh: https://doyle.ninja/limechat-crash.gif

18:18 noncom|2: all fun is that emoji hassle

18:19 cool if by 2050 we'll have a symbolic alphabet to describe almost anything

18:19 does not it look like history repeats itself with all the hieroglyphic things ?

18:20 p_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:20 noncom|2: honestly, i think that a refined set of pictograms would do for better intefaces

18:20 p_l: haha, yeah

18:21 also reminds me of Blindsight (the novel by Peter Watts) :D

18:22 actually, emojis serve as a means for the quest of the structure of consciousness and intellect.

18:22 what if a real AI can only be programmed with emojis ?

18:32 ridcully_: wasn't it l,shift-o to shortcut load on the c64?

19:19 ben_vulpes: blindsight was amazing

19:50 noncom|2: yeah, i'm going through echopraxia now :) it's going to be a trilogy btw

19:51 BRODUS: how would I type this shortcut?

19:51 nvm wrong channel

21:31 breezeli: any one here?

21:31 domgetter: I'm here

21:33 breezeli: i just start learning clojure ,read book clojure programing

21:34 An example does not understand

21:34 Can you help me to disassemble it

21:34 domgetter: I can try. What's the problem?

21:35 breezeli: Wait a moment

21:36 (reduce

21:36 (fn [m v]

21:36 (assoc m v (* v v)))

21:36 {}

21:36 [1 2 3 4])

21:36 this

21:38 Can you help me to disassemble it,Turn into no "reduce" format

21:38 domgetter: That 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:39 it associates each value with its square

21:39 breezeli: what language are you most familiar with?

21:40 breezeli: Chinese

21:40 thank you Let me think about it.

21:41 domgetter: breezeli: I meant what programming language. I can write it in a different programming language to help you understand

21:41 breezeli: c# or java

21:42 hoho! Clojure is hard to get

21:42 justin_smith: it's a lot like for(i in [1 2 3 4]) { m.put(i, i*i);}

21:42 except our maps are not mutable, so you can't actually do that

21:43 breezeli: thank you

21:43 justin_smith: breezeli: the important difference is you don't mutate the values in reduce - you return a new value for each step

21:43 domgetter: breezeli: Here is something to help you understand reduce: (reduce + [1 2 3 4]) == (((1 + 2) + 3) + 4)

21:45 breezeli: I try to understand, this book is too jumping

21:45 domgetter: You can have an "initial value" (reduce + 0 [1 2 3 4]) == ((((0 + 1) + 2) + 3) + 4)

21:45 breezeli: thank all

21:48 Now clear! thank all,i love you

21:48 domgetter: breezeli: Here is some java that is similar: https://gist.github.com/domgetter/93609123c0b8155220e8

21:49 breezeli: thanks you

22:49 domgetter: What's the best way to remove the last character from a string?

22:49 justin_smith: ,(let [s "hello, worldo"] (subs s 0 (dec (count s))))

22:49 clojurebot: "hello, world"

22:50 domgetter: I'll go look up subs. Thank you

22:50 justin_smith: count s is constant time (since strings are a counted type), so that should be the fastest option

22:50 domgetter: oh it's just the substring. Got it, derrr

22:52 How would you recommend I address the edge case of an empty string?

22:52 (subs "" 0 (dec count "")) is a StringIndexOutOfBoundsException. Just wrap in an if?

22:52 justin_smith: (subs "" 0 (max 0 (dec count "")))

22:52 kind of ugly, but works

22:52 domgetter: ah ha!

22:52 justin_smith: and not slow

22:53 domgetter: I prefer the declarative route when I can. Thanks!

22:53 justin_smith: also, it doesn't handle nil

22:54 domgetter: I'll keep that in mind. In this case, the atom is always a string, but you never know...

22:54 justin_smith: (some-> ...) is good for short circuiting nil

22:56 domgetter: Is (apply str (butlast "hello")) slower?

22:56 justin_smith: yes, by at least 100x

22:56 I mean if that doesn't matter, it doesn't matter

22:56 domgetter: right

22:56 but is it slower due to constant factors or linear sequence generation

22:57 cause it would seem like both solutions are "linear"

22:57 justin_smith: allocation churn, lazy sequence, constructing a large number of short lived Char objects...

22:57 it's a linear factor of about 100x

23:05 domgetter: some hard numbers to back up what I was saying https://gist.github.com/noisesmith/71b0c6c8d48c91fcb30d

23:06 ,(/ 2565.0, 62.72)

23:06 clojurebot: 40.89604591836735

23:07 justin_smith: OK, so not quite a hundred time slower

23:07 only 40 times slower :P

23:11 domgetter: Yea 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:12 justin_smith: sounds about right

23:12 domgetter: so it's probably logarithmic

23:12 justin_smith: strings are immutable, but subs can still pull some magic with the underlying java stuff

23:12 domgetter: I know of the #_ reader macro to ignore the next form. Is there one to ignore the next two forms for maps and bindings?

23:12 like #__ or something?

23:12 justin_smith: #_#_

23:13 ,(+ #_#_ dog cat 2 2)

23:13 domgetter: awesome. I was putting #_ individually

23:13 clojurebot: 4

23:13 domgetter: do they stack?

23:13 justin_smith: domgetter: some people really don't like stacked #_, but I think in a hash map it makes sense

23:13 yes

23:13 domgetter: can I put an arbitrary number?

23:13 justin_smith: please don't

23:13 readers will hate you

23:13 domgetter: I'll stick to two, I promise :P

23:14 I have a cond and I'm testing things so I'm ignoring pairs

23:15 justin_smith: makes sense, yeah, #_#_ is handly for that, or a ky / val in a map

23:15 or in let

23:15 domgetter: yea and loop bindings

23:15 But I usually don't go too hogwild in those

23:16 justin_smith: in 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:41 domgetter: That sounds pretty neat. Are you using it for debug purposes at first?

Logging service provided by n01se.net