#clojure log - Sep 01 2012

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

0:02 john2x: why do I get "Unable to find state with key: :tile-count-y" with this? http://pastie.org/4643791(line 15, i'm using Quil)

0:02 http://pastie.org/4643791

0:08 S11001001: john2x: set-state! is not cumulative; it replaces *all* the state

0:09 technomancy: jkkramer: was it a conscious decision to not treat the pom metadata as canonical?

0:09 nesting :description, :url, etc under the :clojars sub-map?

0:09 john2x: S11001001: oooh right.. didn't understand the doc very well.. thanks!

0:11 S11001001: john2x: reading source is your friend; docs will always let you down in the end

0:11 jkkramer: technomancy: in the final graph format?

0:12 technomancy: just tackling read-all-pom-projects for now

0:12 muhoo: is there some way to get nrepl.el to send forms to some ns other than user?

0:13 technomancy: jkkramer: oh, I see where you make a best guess at the top-level description

0:13 jkkramer: technomancy: reconstructing my own thought process here, too. I believe that part merely adds a :clojars key to the project map extracted from the pom

0:13 muhoo: i found nrepl-buffer-ns, but can't figure out how to set it

0:13 technomancy: in build-best-info

0:13 muhoo: the current buffer ns tracking stuff in nrepl.el is a bit wonky

0:13 I tried to get him to read it from the file every time, but that didn't fly =\

0:13 john2x: S11001001: hehe yeah.. just starting out with clojure.. trying to port all Generative Design code samples to clojure as an exercise.. reading the source a bit too intimidating I guess.. I'll keep in mind though. :)

0:14 muhoo: technomancy: is there some hack i could use to get around the wonky?

0:14 technomancy: C-c M-n maybe?

0:15 muhoo: M-n is bound by my wm

0:15 what is the emacs function usually bound to it?

0:15 technomancy: ESC-n is another way to do M-n

0:15 muhoo: M-n is undefined

0:16 ah, i see nrepl-set-ns

0:16 technomancy: right; you have to do C-c first

0:17 muhoo: i found it in nrepl-interaction-mode map.

0:32 nope, nrepl-buffer-ns is not getting sent, anything getting nrepl-intearative-eval'ed is going to #user/ . oh well. thanks anyway.

0:37 john2x: can I use an atom in a let() and change it's value within the let()?

0:39 arohner_: why is there keep-indexed, but not filter-indexed?

0:40 arohner: also strange that keep-indexed returns the result of (f index item), rather than item

0:58 stupid question. Why are keywords not sugar for strings?

0:59 ivan: because keywords are optionally-namespaced symbolic identifiers that implement IFn

0:59 Raynes: (defn filter-indexed [f coll] (keep-indexed #(when (f % %2) %2) coll))

1:00 amalloy: (filter-indexed (fn [i x] (even? i)) (repeat 10 nil)) ;; Raynes

1:00 Raynes: Congratulations.

1:00 ivan: a string is some unicode and is not a symbolic identifier

1:01 arohner: ,(keyword "Π")

1:01 clojurebot: :??

1:01 lazybot: clojurebot: Uh, no. Why would you even ask?

1:01 clojurebot: Huh?

1:02 arohner: works on my machine

1:02 Raynes: Namespaced keywords aren't particularly special. They just have names prefixed with whatever namespace.

1:02 So strings could do the same thing. But strings aren't functions.

1:02 arohner: I like the IFn answer, but that's a limitation of java. if you were writing your own lisp, why care about string vs. keyword?

1:03 Raynes: What does it matter if a keyword is a specialized symbol or a specialized string?

1:03 arohner: I'm trying to understand why you would create the concept, if it didn't exist

1:04 amalloy: keywords guarantee that = provides the same results as identical?

1:04 is one reason they're useful

1:04 arohner: I appreciate the sugar, but making it a different type seems like a mistake Rich doesn't make lightly

1:04 Raynes: A mistake? :\

1:05 arohner: I'm not sure it is a mistake. as I said, I'm trying to understand why you would create the concept if it didn't exist

1:35 muhoo: https://github.com/kingtim/nrepl.el/pull/60 <== already fixed by someone, yay

2:13 trying to run nrepl on a 256MB embeded board is just... not a very practical idea.

2:14 old lein1 with the telnet repl worked fine. new lein2 with nrepl does not.

2:15 guns: muhoo: Running clojure on Raspberry pi?

2:19 muhoo: guns: beagleboard

2:19 guns: muhoo: Ah. And how is that working. Very curious

2:20 muhoo: it worked great with lein1. with lein2, not so much.

2:20 guns: hm. But clojure programs themselves run acceptably?

2:21 muhoo: i suppose i should try aot'ing the app and running it that way. would probably be more successful.

2:21 guns: It seems like such an excessive luxury on an embedded plaform.

2:21 OF course I'm gonna try it when I get my hands on one

2:21 clojurebot: RickInGA: of course :-) *everything* is in Clojure

2:22 guns: I guess 256M RAM stretches the boundaries of "embedded"

2:22 amalloy: surprisingly relevant, clojurebot. well done

2:22 muhoo: i got addicted to being able to do things interactively on it.

2:23 guns: That sounds fantastic; compile-restart doesn't take that long, but commanding the board from the editor sounds like a great time

3:47 john2x: how do I include a jar file I downloaded from the internet in my leiningen 2 project? (where do I place it?)

4:09 tomoj: shouldn't there be a way to fold a vector in reverse?

4:12 should there be a ReduceReversible protocol?

4:21 Raynes: tomoj: (reverse (reduce …)) :P

4:21 Er, backwards.

4:22 Don't mind me, just being an ass.

4:24 amalloy: tomoj: that seems like a nice property, and possible, but i'm not sure how you would fit it into the existing reducers lib

4:25 you basically want rseq as a reducer traansformer

4:36 tomoj: amalloy: yeah

4:36 but

4:36 not exactly

4:36 I mean it can't work on any reducer

4:41 amalloy: right, it has to be a separate protocol

4:49 tomoj: is that different than foldr?

5:03 seems the same on vectors

5:03 but maybe the protocol should be for foldr, like IRightReduce

5:04 then a tree type can get both foldl and foldr even though rseq doesn't make sense

5:25 n00b6502: does clojure have 'tree-like fold' .. its more parallelizable .. (f (f a b)(f c d)) vs (f a (f b ( f c d))))

5:26 tomoj: yes, it's called 'fold'

5:26 new in 1.5.0 (which is still alpha)

5:27 clojure.core.reducers/fold to be specific

5:44 n00b6502: ah so the named default is tree like. neat.

5:52 tomoj: well the normal folding function is `reduce`, `fold` is the parallel version and only works on a subset of the things `reduce` works on

6:56 abp: weavejester: are you around?

7:00 weavejester: I got some crazy ideas about reverse routing in compojure floating in my mind and want to let them wander through yours, to validate. :)

7:00 lytton: any problems with executing Clojure, compojure and cucumber with lein2? When I add cucumber to plugins it fail (user.clj:14)

7:10 weavejester_: abp: I'm around now

7:11 abp: weavejester_: So as a disclaimer: I've not thought this. weavejester: Basically it's just about acquiring a {:name route} map during route-definition via metadata on handlers until a handler is invoked, when it should be assoced back into the request to (reverse request :route params) in handlers.

7:13 weavejester: Okay. Such routing maps would not work in all cases, but might be able to cover the majority.

7:14 abp: weavejester: Which cases would not work? I haven't looked into context by now.

7:15 weavejester: Routes can be chosen according to arbitrary criteria.

7:15 For example

7:15 (if (= :heads (coin-toss)) routes-a routes-b)

7:16 abp: weavejester: Ah okay.

7:17 weavejester: That's partially why I've not added any form of reverse routing, because it seems a little iffy - it's not a guaranteed thing.

7:18 abp: weavejester: Yes, that's really inconvenient, but working without reverse-routing is too.

7:19 weavejester: My thought is that if reverse routing is wanted, then we'd need something on top of Compojure

7:19 e.g. if you create routes with library X, you can reverse route.

7:20 Maybe by defining a resource or something.

7:21 tomoj: what is reverse routing?

7:21 weavejester: Given a var, what URL is it bound to

7:21 abp: weavejester: Hm, probably, but light-weight, stateless reverse-routing would fit compojure, I think. Everything else would have that "bolted on" feel, because it is. :)

7:21 weavejester: Instead of normal routing, which is, given a URL, which var should I use as a handler

7:22 abp: It wouldn't be bolted on. It would be a new layer

7:22 The problem with reverse routing at the Compojure level is that Compojure allows you to write routes that are impossible to reverse.

7:23 And I don't like the idea of a fuzzy reverse route

7:23 But if there was a library on top of Compojure that constrained which routes were allowed, you could get more information.

7:26 Maybe a library that used a data structure of routes

7:28 abp: weavejester: Yeah, I will think a little more this.

7:29 *about this.

7:30 weavejester: Good luck :)

7:33 abp: weavejester: Thanks. :) I recently watched the recording of your neat introductory talk about ring and compojure from functional web architecture. How are your "next steps" (content negotiation and the like) going? :)

7:34 pyykkis: weavejester: just out of curiosity, did you end up with capitalized http verbs based on the http protocol or what? Seemed a little odd first given the clojure naming conventions and sinatra api from ruby world.

7:34 ..how did you end up..

7:35 weavejester: abp: Currently stalled, I'm afraid. I'm currently working on migrations (via ragtime) and thinking about distributed computing

7:36 pyykkis: HTTP verbs are usually capitalized, and it seemed like a good way of distinguishing them from a normal Clojure function. This was 4 years ago, however, and if I were going to do it again, I might rethink things.

7:37 pyykkis: That said… (GET "/foo/:id" [id] …) is perhaps more obvious as to its function than (r/get "/foo/:id [id] …)

7:38 abp: weavejester: Ok, doesn't sound bad either.

7:39 weavejester: pyykkis: At least it is to me. I've been conditioned to see GET and POST and PUT etc. as HTTP verbs if they're capitalized

7:40 casion: especially since get is already used in core

7:42 weavejester: Yeah, though it could have been (route/get "/" [] ...)

7:42 But to me that stands out less.

7:43 pyykkis: weavejester: ok, thanks for the answer. I guess I'm conditioned for the Sinatras lowercases :) Anyways, both compojure and ring get my smiling for happiness every time. Just the right level of abstraction without loads accidential complexity.

7:44 quite refreshing after rails & co

7:44 casion: ah, that's a good point

7:45 weavejester: Yeah, we couldn't ever have (get "/foo" [] …) like in sinatra

7:45 Well… not without a (:refer-clojure :exclude (get)) :)

7:45 pyykkis: It's good to hear you're enjoying it.

7:45 rhickey: lein q: can :pom-addition be used to bring in e.g. the clojure-maven-plugin into the generated pom? It needs to merge into the build branch

7:46 I've tried but it seems to be a no-op

7:46 pyykkis: haha, requiring people to exclude get woud've surely be confusing :)

7:46 rhickey: :pom-addition [:build [:plugins [:plugin ...

7:49 xeqi: rhickey: no, adding maven plugins doesn't work

7:58 rhickey: xeqi: thanks

8:05 xeqi: rhickey: actually, reading it again I would expect it to work with -preview8 or later; though if there multiple src directories it would end up with 2 <build>s :\

8:16 samrat: i'm trying to use clj-oauth with Instapaper's xauth API, but its a bit confusing because "there is no request-token/authorize workflow"

8:22 pyykkis: hm..is there a way reload nrepl session started with nrepl-jackin?

9:03 weavejester: Hm, that's annoying. Clojure 1.5.0-alpha4 is compiled against 1.6.

9:28 voland62_2: What's the difference between -> and ->> macroses?

9:38 xeqi: &(-> 1 (- 3))

9:38 lazybot: ⇒ -2

9:38 xeqi: &(->> 1 (- 3))

9:38 lazybot: ⇒ 2

9:39 xeqi: -> inserts the first argument, ->> uses inserts the last arguments

9:41 casion: I'm working on java interop learning, and I'm a bit lost with how one would work with InputStream.read(byte[] b). How do I pass and 'get' the byte-array to it?

9:42 passing the correct arg is no problem, but getting the filled array is beyond me atm

9:45 xeqi: (doc into-array)

9:45 clojurebot: "([aseq] [type aseq]); Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."

9:46 RonnieDk: , (re-find #"<span id=\"yfs_184_carl-b.co"

9:46 "<span id=\"yfs_l84_carl-b.co")

9:46 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

9:47 casion: xeqi: I'm not sure how to apply that info.. if read() returned the array then I get it, but it returns the bytes read

9:48 RonnieDk: is there a way to repeat the last expression entered nrepl? Without copy/paste

9:50 jkkramer: casion: the byte array is mutable, so bind it with let, then just refer to the same binding after the read call

9:51 casion: jkkramer: that's what I thought, but it's not working… so I assume I"m doing something else wrong

9:51 I will work under that assumption then, thank you

9:51 xeqi: casion: yeah.. I think you just want to do something like (let [b (byte-array array-size)] (.read inputstream b) ..)

9:51 then you could (slurp b) to get a string, but I'm sure theres something different you want to do to it

9:52 casion: it's telling me that it's read the whole stream, then the byte-array is still empty

9:52 I'll work through it, at least I have the concept correct :)

9:52 thanks again

9:54 xeqi: casion: how are you trying to get data out? (aget b 0), (seq b), etc

9:54 casion: I'm just checking with alength atm

9:54 which it would seem to mean that the array isn't getting set to the right size to begin with

9:55 ahhhh

9:56 InputStream.available() was returning 0, and that's what I was using to create the byte-array

9:57 read wasn't throwing an exception when passing a 0 length array though :\

9:59 and everything works now :)

10:14 rhickey: Is there a way to get lein to use a local jar not in any repo (as a dep)?

10:19 xeqi: rhickey: you could use https://github.com/kumarshantanu/lein-localrepo to inject the jar into your local maven cache

10:20 but lein tries to encourage repeatability, so doesn't have a mechanism for jars outside repos

10:20 ~repeatability

10:20 clojurebot: repeatability is crucial for builds, see https://github.com/technomancy/leiningen/wiki/Repeatability

10:21 rhickey: repeatability should not get in the way of experimentation when things are new, as all of this artifact-based stuff does

10:21 tmciver: xeqi: I know you could (in lein 1.x) run 'lein install' in a local project to install a jar in the local maven repo.

10:21 rhickey: I don't want in in a repo, I know how to do that

10:22 Sgeo: Would bundling a jar with your code prevent repeatability somehow?

10:23 rhickey: xeqi: thanks for the info

10:24 jonasen: I'm using lein install with lein2 and it works for me

10:25 xeqi: Sgeo: it could work, but then your sticking jars in the version control system

10:25 lein accepts file:// repos, so it can be done, just ugly to get it all setup in the format maven likes

10:31 samrat: i'm using clj-oauth, which uses clj-http 0.2.7 but I need to use clj-http 0.5.3(latest), what do I do?

10:32 if I do add [clj-http "0.5.3"] as a dependency I start getting errors

10:39 xeqi: samrat: I think your choices are fork clj-oauth and fix the errors, and make a pull request upstream; or use a different oauth lib

10:39 https://github.com/r0man/oauth-clj looks like it uses the clj-http mentioned

10:45 ssideris: hello. if bytes in java go from -128 to 127, shouldn't this code return "ff"?

10:45 (format "%02x" (byte 127))

10:46 &(format "%02x" (byte 127))

10:46 lazybot: ⇒ "7f"

10:46 samrat: xeqi: will try that. how do i add my own fork to a project? do I have to upload it to clojars?

10:46 ssideris: (which as you can see it doesn't)

10:47 xeqi: &(format "%02x" (byte 255))

10:47 lazybot: java.lang.IllegalArgumentException: Value out of range for byte: 255

10:47 ssideris: samrat: there is also this: https://github.com/tobyhede/lein-git-deps

10:47 zilti: ssideris: The hex system doesn't get changed just because Java only supports "byte" up to 127. 7f means 127

10:48 * means byte-value 127

10:49 samrat: ssideris: yeah, but I mean during developing locally?

10:49 xeqi: samrat: change the group name to something like org.clojars.samrat; lein install in your fork will make it work locally

10:50 ssideris: zilti: ok, but the puzzling thing is that if I map a jpeg file to a MappedByteBuffer, then do (format "%02x" (.get data 0)) I get "ff"

10:50 xeqi: uploading to clojars is prolly the easiest to make it work on multiple machines

10:50 tmciver: ssideris: if you don

10:50 ssideris: when (class (.get data 0)) is also a jaba byte

10:50 java

10:51 tmciver: if you don't cast to byte, it works ##(format "%02x" 255)

10:51 lazybot: ⇒ "ff"

10:52 dhofstet: how does one submit typo fixes for the API docs? Creating a pull request on Github?

10:53 samrat: xeqi: did lein install, but how do I specify in project.clj that I want the local repo and not from clojars?

10:54 ssideris: samrat: there is also the option of having a checkouts dir in your project

10:54 zilti: I'm looking for a way to "move" inside a nested map which has potentially indefinitely many levels. I need to be able to somehow "jump" to a position and I need to be able to move "upwards". What do I best use for this and is there a good example/tutorial?

10:55 ssideris: zilti: look into zippers

10:57 samrat: mattrepl: hi, any plans on upgrading clj-oauth? i was having some troubles

10:59 xeqi: samrat: if you changed the group name in the fork, then change the group name in the :dependencies. make sure the versions line up too; if you didn't change the group name, then just make sure the versions match

11:00 dhofstet: for clojure or a contrib library?

11:00 dhofstet: xeqi: clojure

11:01 mattrepl: samrat: yeah, had you messaged me on github about that? there's an outstanding request I haven't made time for (brb, toggling between afk)

11:04 zilti: hmm could it be nrepl.el is broken? Does it live-compile? because each time I try to type I get the message "Unable to resolve symbol: if-let in this context" even though I don't use it

11:04 xeqi: dhofstet: I think you have to sign a CA and make a ticket in jira, clojure uses github as more of a mirror

11:04 zilti: https://github.com/kingtim/nrepl.el/issues/86 ; it works sometimes

11:10 dhofstet: xeqi: hm, seems a bit overkill for such a trivial fix

11:11 seancorfield: the CA etc provides legal protection for the Clojure project which is important if the language is to gain wider acceptance in industry

11:11 nearly all open source language projects require a CA these days for licensing reasons

11:12 see http://clojure.org/contributing for more details

11:12 zilti: ok so nREPL is totally broken at the moment... too bad

11:13 seancorfield: (sorry if this seems like a hot button for me but i've been doing open source software development for twenty years and i'm always surprised when people object to signing an IP agreement)

11:13 cshell_: Yeah, Sun was doing it with all of their os projects - doesn't seem that out of line

11:14 dhofstet: seancorfield: I understand that, but for removing three spaces from the docs it is just not worth going through this process

11:15 seancorfield: dhofstet: agreed for that - you could just open a ticket in jira about it i believe without needing any paperwork

11:15 someone with a CA on file will be happy to make that change i expect :)

11:15 dhofstet: seancorfield: ok, will do

11:16 xeqi: seancorfield: ah, I wasn't sure if you needed a CA to open a ticket

11:17 seancorfield: only for submitting a patch - but you probably need to create a jira account to open a ticket

11:18 basically clojure & contribs cannot accept any code from someone without a CA on file - and won't accept pull requests because of the (potential) issues tracking down all contributors to a repo and all the CAs for them

11:18 so patches only, from folks with CAs

11:20 wmealing_: i dont understand why a CA for a language would be different than requiring a CA for a program

11:20 not my pony though.

11:20 it cant be any more GPL, and by working on a project, its not up to a project to be complicit with licencing

11:20 its up to the contributor to understand

11:21 seancorfield: wmealing_: not saying there's a difference between language project and program project...

11:23 wmealing_: other software has got along fine for the longest time

11:23 imagine gcc.

11:25 so, if i wanted to add properties like value="n" to a drop-down in hiccup, is that possible ?

11:26 http://weavejester.github.com/hiccup/hiccup.form.html#var-drop-down <-- for the docs.. if anyone thinks i'm going mad.

11:28 xeqi: I thought gcc wanted copyright assignement too http://gcc.gnu.org/contribute.html

11:28 *the fsf

11:29 wmealing_: i commited, never had any kind of CA..

11:29 maybe someone fudged it.

11:29 ah.. employee disclaimer

11:29 employer rather

11:29 thats why

11:30 and perhaps "Small changes can be accepted without a copyright disclaimer or a copyright assignment on file"

11:30 seancorfield: CAs weren't as common back in the day, before the US became so darned litigation-happy :(

11:31 having been thru a corporate audit of open source software licenses (at adobe), i know how paranoid many large companies can be

11:32 pyykkis: Even though I understand the reasoning, CA and Jira are the worst of clojure world, i must say :/

11:33 wmealing_: we tolerate evil and pay the consequences of doing so.

11:33 instead of solving the problem and revolting on it, we turn a blind eye to the larger cancer.

11:34 seancorfield: larger cancer = corporate litigation, i assume? (and i agree, fwiw)

11:34 wmealing_: yes.

11:35 i'm not smart enough to solve it, but i know the collective we.. is.

11:35 pyykkis: as I'm playing around with node.js and ruby quite a bit, MIT licences and dead simple pull request policies seems to be quite a factor for building a community

11:35 bosie: pyykkis: CA?

11:35 seancorfield: pyykkis: yes, CA / JIRA are the worst of the Clojure world, and if that's the worst, then we're in pretty good shape :)

11:36 node.js has a CA: http://nodejs.org/cla.html

11:36 bosie: ok

11:37 pyykkis: seancorfield: oh, lol :D I didn't even be aware of that

11:38 seancorfield: and yeah, that's true. If that's the worst, everything is quite ok :] Most of the people contribute to the specific projects anyways and not to the language core itself. And most of the projects are anyways with open licences in github

11:39 seancorfield: ruby is GPL yes? not surprised that a GPL project doesn't require a CA... bunch of tree-hugging hippies :)

11:40 a lot of large corporates won't use GPL unless they can buy a closed source commercial edition (which ruby / rails offers i believe?)

11:41 when i was at adobe, we had to ask a project to change from LGPL to some other license due to a legal concern with the reach of LGPL and how the project generated code that code intermingle with our own... (some) companies take this very seriously, for good or bad

11:41 bosie: seancorfield: are you using clojure exlusively these days at work?

11:42 seancorfield: bosie: for the back end, almost exclusively yes

11:42 wmealing_: one has to take it seriously

11:42 its what licences are

11:42 seancorfield: for the front end, railo - a jboss community project - that provides a fast, free implementation of cfml

11:43 bosie: my blog talks about the cfml / clojure integration we do - http://corfield.org

11:43 * wmealing_ ponders if his hiccup question is insanely easy, or i asked the wrong question.

11:44 seancorfield: i think we got distracted wmealing_

11:45 i haven't used that part of hiccup so i can't answer, i'm afraid

11:45 * wmealing_ nods

11:46 wmealing_: maybe enlive might be more useful

11:46 seancorfield: is the q that you want to add a new option after the select has been generated?

11:47 technomancy: ruby has a custom license

11:47 they don't need a CA to make contributing a huge PITA; the language barrier is enough

11:47 wmealing_: nah, i can't generate the additional key=value sub options of the drop-down box

11:48 i'd like <select> <option name="test">testing 123</a>

11:48 oops, bad closing tag.. sorry its late here

11:49 the name=test part, i can't seem to do easily.

11:49 jkkramer: wmealing_: I think you can pass a vector for each option… [["testing 123" "test"] ["foobar" "foo"], ...]

11:50 * wmealing_ tests

11:50 pandeiro: wmealing_: jkkramer: [:select (for [opt options] [:option {:name (:name opt)} (:title opt)])]

11:51 jkkramer: pandeiro: that gets tedious if you have to check for the selected value

11:52 on the other hand, writing your own helper function is pretty easy if drop-down isn't cutting it

11:53 samrat: mattrepl: just bumping up clj-http's version seems to solve my problem for the time being, but I'm not really sure I know what I'm doing

11:53 jkkramer: technomancy: FYI, I ran the clojuresphere fetcher last night and it took way longer than it used to - apparently there's way, way more projects now. I screwed up my jvm before it finished, though, so fetching again...

11:53 wmealing_: both work.. thanks..

11:53 ssideris: is anyone else getting ^M at the end of lines in the swank repl in emacs in windows?

11:54 seancorfield: (drop-down :foo [[:test "testing 123"]]) works wmealing_

11:54 i had to update my version of hiccup to test that... didn't realize i was on such an old version :(

11:55 jkkramer: seancorfield: saw your work on jsql. I have a project that may interest you… https://github.com/jkk/honeysql

11:56 seancorfield: I'm using that as the basis for a higher-level lib that handles relational abstractions. but honeysql does purely clojure data -> sql, no abstraction or jdbc stuff

12:02 seancorfield: jkkramer: nice... looks like it would combine well with java.jdbc for more complex sql expressions

12:07 jkkramer: seancorfield: yeah. and it really comes in handy when progressively composing/adjusting queries

12:10 seancorfield: jkkramer: yeah, the jsql stuff is just meant to provide some basics that make java.jdbc easier to use - and will be folded into java.jdbc soon - but because the DB operations just take SQL, it would be easy to use any other sql-generator library with it

12:15 jkkramer: seancorfield: cool, that's what I've been doing, and am pretty happy with. If there's anything in honeysql you'd like to pilfer for jsql, feel free - it's a solo project, and I've signed a CA. if not, no biggie, just thought i'd bring it to your attention

12:15 zilti: There seems to be something wrong in the way I'm using the ns macro: https://gist.github.com/3578863 The Stacktrace is from loading the file in the slime-repl.

12:18 nbeloglazov: zilti: do you need :use or :require?

12:18 zilti: nbeloglazov: What's the alternative?

12:19 writing the full path?

12:20 nbeloglazov: zilti: check this article: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html

12:21 zilti: it seems that you really need :require because you specified aliases via :as for namespaces

12:21 zilti: nbeloglazov: Which gives me a "next already refers to: #'clojure.zip/next in namespace: orgparser.core" error

12:27 Hmm ok a restart fixes this

12:27 pandeiro: there's no autocomplete functionality in source code buffers with nrepl.el + ac-nrepl.el ?

12:27 only in the nREPL buffer?

12:29 i enabled auto-complete-mode but it doesn't complete fns from clojure.core

12:33 Frozenlo`: "Phil Hagelberg has some thought-provoking advice on this matter." What's this usage of real name? Tssss...

13:53 RonnieDk: A bit of regex trouble. How come (re-find #"yfs_184" "yfs_l84") return nil?

13:55 nbeloglazov: &(re-find #"yfs_184" "yfs_184")

13:55 lazybot: ⇒ "yfs_184"

13:55 RonnieDk: not in my nrepl

13:55 nbeloglazov: RonnieDk: your strings have differences

13:56 RonnieDk: 1 in the pattern and l in the string

13:57 RonnieDk: nbeloglazov: but how there be a difference? It's two simple strings

13:57 nbeloglazov: &(= "yfs_184" "yfs_l184")

13:57 lazybot: ⇒ false

13:57 nbeloglazov: &(= "yfs_184" "yfs_l84")

13:57 lazybot: ⇒ false

14:01 samflores: which is that character after the underline in the second string?

14:02 RonnieDk: samflores: Damn ... you're right.

14:02 samflores: :p

14:02 nbeloglazov: :(

14:05 Frozenlock: In Domina, is there a way to change the 'hover' css? For normal css: (domina/set-styles! {:position "fixed".... but what if I want to change what would usually be in 'div-id:hover'?

14:48 borkdude: has anyone used https://github.com/adamwynne/twitter-api/? I'm trying (profile-image-for-user :params {:screen_name "Borkdude"}) but...

14:48 I get this nasty msg: JSON error (unexpected character): <

14:48 [Thrown class java.lang.Exception]

14:53 maybe it expects the body to be encoded?

14:53 samrat: what does this error mean https://www.refheap.com/paste/4793 ?

14:54 gfredericks: samrat: what's your ns form look like?

14:55 zilti: I'm trying to get zippers working, but that doesn't work: https://gist.github.com/3583132, why?

14:57 samrat: gfredericks: https://www.refheap.com/paste/4794

14:59 gfredericks: samrat: the quote on line 2 could be messing it up

15:00 yeah that seems to be the case

15:00 samrat: gfredericks: thanks

15:00 michaelr`: hello

15:05 borkdude: how can you reset an alias in a namespace?

15:07 found i

15:07 t

15:08 zilti: All I get is a NullPointerException without a message, so I have no idea what's wrong

15:28 borkdude: is there a "switch repl to namespace visited in this file" in emacs (swank-clojure) like "Switch REPL to files namespace" in Counterclockwise?

15:29 zilti: borkdude: C-x M-p

15:30 borkdude: zilti undefined

15:32 zilti C-c M-p, tnx

15:32 zilti: borkdude: Oh, yes. Sorry

15:44 pandeiro: inside of a typical nested src directory structure, what is the default filepath?

15:44 in the past i thought doing (read-file "project.clj") worked from anywhere inside the src/... structure

15:53 SegFaultAX: Is there a range-like that can produce an infinite sequence starting from a number other than 0?

15:54 zilti: I'm trying to get zippers working, but that doesn't work: https://gist.github.com/3583132, why? All I get is a NullPointerException without a message, so I have no idea what's wrong

15:54 SegFaultAX: ,((fn range-from [n] (cons n (lazy-seq (range-from (inc n))))) 10)

15:54 clojurebot: (10 11 12 13 14 ...)

15:54 SegFaultAX: ,(take 10 ((fn range-from [n] (cons n (lazy-seq (range-from (inc n))))) 10))

15:54 clojurebot: (10 11 12 13 14 ...)

15:55 xeqi: #(doc range)

15:56 (doc range)

15:56 clojurebot: "([] [end] [start end] [start end step]); Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0, step to 1, and end to infinity."

15:56 xeqi: hmm, I guess it only takes an end

15:56 arrdem: ,(inc xeqi)

15:56 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: xeqi in this context, compiling:(NO_SOURCE_PATH:0)>

15:56 arrdem: (inc xeqi)

15:56 lazybot: ⇒ 3

15:56 SegFaultAX: But I don't want to give an end, just a start.

15:56 xeqi: ,(map #(+ 10 %) (range))

15:56 clojurebot: (10 11 12 13 14 ...)

15:56 SegFaultAX: And obviously ##(range 3) aint it.

15:56 lazybot: ⇒ (0 1 2)

15:57 * arrdem pounds desk "THE NUMBER OF BOTS IN THIS CHAN IS TOO <beep> HIGH"

15:57 alpheus: I have a function that locates a file and returns a java.io.FileInputStream for the file. I want to test the contents of the FileInputStream against my expected value (possibly arbitrary binary data). How can I do this?

15:57 SegFaultAX: xeqi: So the answer is no, then? Such a thing doesn't already exist?

15:58 xeqi: SegFaultAX: nothing built in that I'm aware of

15:58 SegFaultAX: xeqi: Cool, thanks mate.

15:59 xeqi: SegFaultAX: ##(iterate inc 10)

15:59 lazybot: Execution Timed Out!

15:59 xeqi: ,(iterate inc 10)

15:59 clojurebot: (10 11 12 13 14 ...)

15:59 xeqi: forgot about iterate for a moment

16:00 alpheus: I assume `slurp`-ing the inputstream won't work?

16:01 alpheus: xeqi: no, slurp corrupts binary data. spit, too.

16:01 arrdem: (doc slurp)

16:01 clojurebot: "([f & opts]); Opens a reader on f and reads all its contents, returning a string. See clojure.java.io/reader for a complete list of supported arguments."

16:02 alpheus: I've been using clojure.java.io/copy to copy to a file and then using Unix cmp (for my tests)

16:02 arrdem: yeah that'll break binary data...

16:02 alpheus: Also, I can't figure out what "opts" is for slurp.

16:03 arrdem: alpheus: if you go on clojuredocs or clojure.org and look at the source the opts are passed to the java.io.reader creation call

16:04 xeqi: perhaps something like (let [x (bytearray (.available inputstream))] (.read inputstream x) (is (= (seq x) expected))) ?

16:05 * byte-array

16:10 alpheus: xeqi: thanks

16:14 Frozenlock: Is it possible to have multiple browser windows in the same 'environment'

16:15 For example, if I declare a variable from the REPL, I would like all of them to have it.

16:16 goodieboy: i'd like to build a ring application, and provide a way for people to add plugins for certain features. Any ideas for dealing with "plugins" within clojure and ring?

16:17 dnolen: Frozenlock: I think Brenton Ashworth was working on that, but I don't know if there's been much progress recently.

16:17 weavejester: You'd need to decide what the plugin would do - whether it's just a page, or if it has any interactions with your APIs.

16:18 goodieboy: weavejester: yeah, i think i know what would be needed in terms of an interface, but just don't know how you'd plugin, the plugins :)

16:18 pandeiro: weavejester: could you show me how i would rig a compojure route to modify a ring session map?

16:19 Frozenlock: dnolen: I don't see anything on his github. I suppose it's really still an experiment.

16:20 weavejester: goodieboy: They could upload a jar that you could dynamically load in. Isn't there a library around for dynamic classpath managing? I think Lein2 uses it?

16:20 goodieboy: weavejester: oh is that the bultitude thing?

16:20 https://github.com/Raynes/bultitude/ ?

16:20 weavejester: pandeiro: (-> (response "whatever") (assoc-in [:session :your-key] "some-value"))

16:20 xeqi: https://github.com/cemerick/pomegranate

16:20 goodieboy: weavejester: wait, you can dynamically load a jar?

16:20 dnolen: Frozenlock: it's a ClojureScript branch on the main repo

16:21 xeqi: goodieboy ^

16:21 weavejester: goodieboy: Yeah, you can create a new classloader with a new classpath to execute your jar in

16:21 goodieboy: xeqi: ahh ok, i've heard of that. i'll have a look thanks!

16:22 weavejester: i didn't know you could do that, nice

16:22 weavejester: goodieboy: It's kinda tricky to do it with Java, though. I believe it's pomegranate that is a library for loading deps on the fly....

16:23 goodieboy: it does sound tricky

16:23 xeqi: https://github.com/cemerick/pomegranate/blob/master/src/main/clojure/cemerick/pomegranate.clj#L72 for random jars; there's an equivalent for getting hten from mavne repos as well

16:23 pandeiro: is there a way to reload all buffers with nrepl.el?

16:24 goodieboy: xeqi: very cool

16:26 weavejester: goodieboy: Actually, you probably want this: https://github.com/flatland/classlojure

16:27 Get someone to upload an uberjar of the plugin (i.e. a jar with all deps included)

16:27 xeqi: (inc weavejester)

16:27 lazybot: ⇒ 4

16:27 weavejester: Then use classojure to call API methods

16:27 xeqi: that would be a better way

16:28 then you don't have to worry about dependencies on different versions of the same library

16:29 goodieboy: nice, i'll have a play with that as well

16:29 weavejester: Although...

16:29 If you have a web app

16:30 Then plugins are usually done through a web API

16:30 i.e. plugin developer hosts a web app

16:30 registers it with your system

16:30 and then your system calls specific URIs on the plugin app

16:32 goodieboy: hmm, would need to think about that. it is a webapp, but my plan was to open source the app, and make it easy/safe for developers to create their own plugins, but upgrading the core would be painless, and not mess with customizations done via plugins

16:32 weavejester: If it's an open source app then I guess jars might work best

16:33 goodieboy: basically, a way to hook into the app without modifying the source

16:41 pandeiro: muhoo: are you using couch-session still?

16:49 bloudermilk: Are records less efficient than maps with regard to persistence/structural sharing?

17:00 Frozenlock: I suspect lein to be using another version than the one I asked for in my project.clj. How can I check which one is used?

17:02 weavejester: Frozenlock: lein deps :tree should show you everything

17:03 goodieboy: weavejester: hey i'm thinking about using dynamodb for a project and ran across rotary. Does it support the async client?

17:03 Frozenlock: weavejester: Thank you.

17:04 I'm starting to think it's a soft/hard dependency issue https://github.com/technomancy/leiningen/blob/master/doc/FAQ.md

17:04 weavejester: goodieboy: No, but the library is in an early state.

17:04 goodieboy: weavejester: ok just checking. Love the name btw.

17:04 weavejester: goodieboy: Thanks

17:05 goodieboy: Also, is there a point to use the async client in Clojure?

17:05 dnolen: getting warmer https://github.com/clojure/clojurescript/commit/48bb400838a7e45daa776a8afb817910c54d3a8c

17:06 goodieboy: weavejester: you mean, because we have agents etc.?

17:06 Frozenlock: dnolen: May I ask to what? :)

17:06 weavejester: goodieboy: The async client returns futures… I guess it's not using them with threads, but with nio or something

17:07 goodieboy: weavejester: yeah that's what i thought too

17:08 weavejester: goodieboy: It might be worth in a future version to switch to the async client if it's using nio

17:08 goodieboy: Have it return something deref-able.

17:08 goodieboy: weavejester: yeah exactly

17:08 i'm looking for the docs now

17:10 emezeske: Frozenlock: I think cljs is getting closer to having source map support, so you can debug it in a browser much more easily

17:18 Frozenlock: I need to look at this REPL thingy more closely. I could not live without it, yet I have no clue to what's happening under the hood :(

17:21 casion: is there any short way to convert a java byte-array to a seq (other recursion + conj)

17:21 other than*

17:22 aperiodic: you can just call seq on it

17:22 ,(seq (byte-array 1 (byte 42)))

17:22 clojurebot: (42)

17:24 samflores: '(doc seq)

17:24 ,(doc seq)

17:24 clojurebot: "([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable."

17:24 casion: thanks aperiodic

17:31 xeqi: Frozenlock: if you suspect a hard vs soft deps problem, you might try https://github.com/xeqi/lein-pedantic and see what it tells you

17:33 Frozenlock: xeqi: looks really neat! Thanks!

17:49 aperiodic: emezeske: so, i symlinked a cljs file as .clj in my source directory (in order to please pygments), and lein-cljsbuild choked so badly when trying to compile the symlink that i had to kill it and rerun cljsbuild auto

17:49 emezeske: should i open an issue, or just refrain from doing such uncouth things?

17:50 emezeske: aperiodic: What is pygments?

17:51 aperiodic: And was the link "x.cljs -> x.clj" or "x.clj -> x.cljs" ?

17:51 aperiodic: emezeske: pygments is a syntax highlighting tool, and the link was x.clj -> x.cljs

17:53 emezeske: Well, cljsbuild is just going to interpret that as a clojure file that has the exact same contents of a clojurescript file. I guess it doesn't seem weird to me that that would cause problems

17:54 Although without :require-macros I don't know why it would even look at that file

17:54 Refheap of the choking stack trace?

17:54 Maybe it broke when trying to get the mtime of a symlink

17:58 aperiodic: emezeske: sure, it just seems suboptimal to me that doing this crashes cljsbuild auto. it looks like it crashed when trying to call use-macros, actually: https://www.refheap.com/paste/4796

17:59 i'd expect the build to just fail

17:59 emezeske: Well, that's the compiler crashing, which cljsbuild doesn't try to catch

17:59 cljsbuild just catches builds that fail

18:01 aperiodic: are you opposed to catching compiler crashes?

18:02 emezeske: I guess I just don't see it being very important. In your case, even if cljsbuild did catch that error, it's not like the build is going to work

18:03 aperiodic: then only reason to do it would be to save the user having to notice the crash and then manually kill & restart cljsbuild auto (it doesn't actually kill cljsbuild auto, just makes it stop building)

18:03 emezeske: Actually, that's not even the compiler crashing

18:03 That's the clojure compiler crashing

18:04 You do make a fine point

18:05 Open an issue and link that stack trace, I think it would be easy to just wrap the clojure reloader in a try

18:05 aperiodic: sounds good!

18:06 emezeske: Now that I think about it, that really should be caught. I'll stop being stubborn now. :)

18:12 aperiodic: issue opened

18:12 thanks for being convinced :)

18:12 emezeske: Good job convincing me!

18:12 :)

18:24 n00b6502: i like the way clojure makes maps,vectors callable functions to lookup their contents.. is this unique to clojure??

18:24 lazybot: n00b6502: Definitely not.

18:24 n00b6502: is that automated

18:25 emezeske: n00b6502: Definitely not.

18:26 Haha, lazybot is such a jerk :)

18:26 I don't know the answer to your question.

18:27 SegFaultAX: What's the easiest way to insert something into the middle of a list?

18:28 Like if I want to insert :foo into [:a :b] to yield [:a :foo :b]

18:28 ,(assoc [:a :b] 1 :foo)

18:28 clojurebot: [:a :foo]

18:28 emezeske: SegFaultAX: You can (concat [first part of list] [element] [last part of list])

18:29 SegFaultAX: That's the easiest way?

18:29 emezeske: ,(let [x [1 2 4 5]] (concat (take 2 x) [3] (drop 2 x)))

18:29 clojurebot: (1 2 3 4 5)

18:30 emezeske: I make no claims about it being the easiest way.

18:30 hughfdjackson: this is a .. language design question more than anything

18:30 it strikes me as risky that dividing by 0 throws an exception

18:30 since you may derive the from user input, and therefore have to always put extra gaurds in place

18:31 :p A) do people concur, B) why does clojure make the exception choice?

18:31 emezeske: hughfdjackson: Definitely do not concur.

18:31 hughfdjackson: It would be risky *not* to throw an exception when dividing by zero

18:32 hughfdjackson: Much better to find out about a problem in the input than to silently produce corrupt results

18:32 xeqi: a) no. b) host environment made the choice

18:32 hughfdjackson: :D fair enough

18:33 emezeske: hughfdjackson: If your program takes user input, you have to validate it, plain and simple

18:33 arrdem: emezeske beat me to it

18:33 emezeske: :P

18:33 hughfdjackson: i could be wrong in imagining that it could be more handily solved by an 'infinity' value for which *, +, -, / all return the value supplied

18:34 :D but if it doesn't strike others as strange, maybe i'm the strange one on this

18:34 emezeske: x/0 != infinity

18:34 clojurebot: is too infinity +1!

18:34 emezeske: x/0 = NaN if anything

18:34 arrdem: yeah...

18:34 emezeske: Anything divided by zero is not defined, it is definitely not infinity.

18:34 gfredericks: &(/ 7.3 0)

18:34 lazybot: ⇒ Infinity

18:34 emezeske: gfredericks: Why!!!

18:34 arrdem: emezeske: because floating point

18:34 * emezeske pukes a little.

18:35 emezeske: &(/ 7.3 0.0)

18:35 lazybot: ⇒ Infinity

18:35 * emezeske jumps off a bridge.

18:35 arrdem: &(/ 7 0)

18:35 lazybot: java.lang.ArithmeticException: Divide by zero

18:35 arrdem: see? it's just a Floating Point POS

18:35 * arrdem hauls emezeske back out

18:35 gfredericks: rationals ftw

18:35 emezeske: ,(/ 7.3F 0.0F)

18:35 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 7.3F>

18:35 hughfdjackson: :p well, that underminds some of my basic assumptions

18:35 emezeske: gfredericks: But.. but!

18:36 arrdem: hughfdjackson: Okay. floating point... has all kinds of weirdness in the spec where floating point was involved. I spent an un-fun week last semester learning that crap.

18:36 gfredericks: emezeske: no exceptions

18:36 emezeske: gfredericks: Rationals, you say. I'm sure there's a reason for it, but that answer is plain wrong

18:36 gfredericks: emezeske: cuz of perf?

18:36 emezeske: gfredericks: That's usually the answer

18:37 hughfdjackson: hehe, turns out haskell returns infinity for 1/0

18:37 there's a turn up for the books

18:37 gfredericks: well you're the one who said i was wrong

18:37 emezeske: gfredericks: No, I didn't mean *you* were wrong

18:37 WuHoUnited: Does anybody know how RT.loadResourceScript behave if it is called from different threads in the same application?

18:37 emezeske: gfredericks: I meant that the answer returned by / was wrong

18:37 gfredericks: ooh

18:37 emezeske: lol :)

18:38 * emezeske goes back to not dividing things by zero.

18:38 gfredericks: emezeske: I was recommending using rationals instead of floating point

18:38 WuHoUnited: ie: is it as if each of the threads loaded the script independently?

18:38 emezeske: gfredericks: Ooooh, gotcha!

18:39 * gfredericks is a fan of exact arithmetic

18:40 tomoj: I can't seem to find any reasons for the ieee float spec to include infinity

18:40 amalloy: emezeske: (/ 1.0 0.0) as infinity makes some sense because floating point is just an approximation: ie, you probably got zero by a rounding error, and not an actual exact zero, so it's really more like an infinitesimal

18:40 emezeske: tomoj: Infinity is handy for certain algorithms

18:41 gfredericks: (inc amalloy)

18:41 lazybot: ⇒ 29

18:41 emezeske: tomoj: Like implementing max(), you can set the current max to negative infinity and then compare successive values to that

18:41 arrdem: (inc amallot)

18:41 lazybot: ⇒ 1

18:41 arrdem: (inc amalloy)

18:41 lazybot: ⇒ 30

18:41 arrdem: (dec amallot) ; NO FREE KARMA HERE

18:41 lazybot: ⇒ 0

18:42 gfredericks: amallot: yeah, earn it the hard way like the rest of us

18:42 emezeske: amalloy: That's reasonable I guess. It's not like when one is using floats that one can even believe in a zero value anyway

18:42 arrdem: amallot: damnit man...

18:42 emezeske: amallot: Or, rather believe in any exact value

18:42 amallot: i hereby claim all future karma proceeds on this account

18:42 gfredericks: emezeske: I believe in zero no matter what those biased biologists say

18:42 emezeske: gfredericks: lol

18:42 arrdem: (inc amallot) ; for making my day

18:42 lazybot: ⇒ 1

18:43 gfredericks: (inc amallot-of-fun)

18:43 lazybot: ⇒ 1

18:43 emezeske: (inc amallard)

18:43 lazybot: ⇒ 1

18:43 amalloy: what have i done!

18:43 arrdem: gfredericks: what you did there... I see it.

18:43 emezeske: You've unleashed the floodgates of useless karma

18:43 * gfredericks imagines an exponentially increasing crowd of people muttering about juxt

18:44 gfredericks: I was about to say something about not knowing how the name "amalloy" is really pronounced before remembering it wasn't a name

18:55 yankov: is there a built-in function to take a sublist from the list. say I need only elements from 10 to 17.

18:55 like ruby's array[10..17]

18:55 WuHoUnited: subvec would work for vectors

18:55 might work for seqs also

18:55 gfredericks: it oughtn't

18:55 arrdem: ,(drop 10 (take 17 (range 100))

18:55 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

18:55 Raynes: &(take 7 (drop 10 (range 20))

18:55 lazybot: java.lang.RuntimeException: EOF while reading, starting at line 1

18:55 Raynes: &(take 7 (drop 10 (range 20)))

18:55 lazybot: ⇒ (10 11 12 13 14 15 16)

18:55 arrdem: ,(drop 10 (take 17 (range 100)))

18:55 clojurebot: (10 11 12 13 14 ...)

18:56 Raynes: take 17?

18:56 :p

18:56 arrdem: Raynes: I derped

18:56 IT GETS THE SAME PLACE

18:56 Raynes: So did I.

18:56 Anyways, he sees the point, I'm sure.

18:56 <3

18:58 yankov: thanks guys

18:58 arrdem: no problem

19:00 ,(println "foo")

19:00 clojurebot: foo

19:00 arrdem: ,(println "/nick silly-bot")

19:00 clojurebot: /nick silly-bot

19:00 arrdem: dang.

19:01 gfredericks: that bot is so clever

19:02 ohok: thanks bot. thot.

19:03 gfredericks: (inc ohok)

19:03 lazybot: ⇒ 1

19:04 antifuchs: ,(println (format "%cACTION%c slaps around antifuchs with a large trout" (char 1) (char 1))

19:04 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

19:04 antifuchs: awww

19:05 arrdem: you dropped an rparen

19:05 antifuchs: (forgive me, but I have to try again)

19:05 ,(println (format "%cACTION%c slaps around antifuchs with a large trout" (char 1) (char 1)))

19:05 this wasn't very effective ):

19:06 must have forgotten my CTCP syntax. oh well (:

19:07 * arrdem drags out the clojurebot manual in hopes of better success in the fish-slapping department

19:11 metellus: ,(println (str (char 1) "ACTION" (char 1) "attempts an action"))

19:17 tomoj: &(#(vector %1.999999999999999 %1.9999999999999999) 3 4)

19:17 lazybot: ⇒ [3 4]

19:18 nbeloglazov: tomoj: how does it work?

19:19 tomoj: &(= 1.9999999999999999 2.0)

19:19 lazybot: ⇒ true

19:19 nbeloglazov: &(1.999999999999999 1.0)

19:19 lazybot: java.lang.ClassCastException: java.lang.Double cannot be cast to clojure.lang.IFn

19:20 amalloy: more like ##(read-string "1.999999999999999"), i think

19:20 lazybot: ⇒ 1.999999999999999

19:20 amalloy: hm. guessed that would return 2.0

19:20 tomoj: &(read-string "1.9999999999999999")

19:20 lazybot: ⇒ 2.0

19:20 tomoj: I see

19:20 the weird thing is really that %args can be floats

19:22 a vec's rseq isn't chunked :(

19:23 amalloy: tomoj: it's parsed with read, then cast to Number, then intValue is called

19:37 yankov: is this a stupid way to _append_ to a list? (flatten (list '(1 2 3 4) 5))

19:38 arrdem: yankov: ... yes. you should (conj) if that's what you want

19:38 xeqi: &(conj '(1 2 3 4) 5)

19:38 lazybot: ⇒ (5 1 2 3 4)

19:38 arrdem: herum

19:38 (doc append)

19:38 amalloy: &(doc concat)

19:38 lazybot: ⇒ "([] [x] [x y] [x y & zs]); Returns a lazy seq representing the concatenation of the elements in the supplied colls."

19:38 clojurebot: No entiendo

19:38 yankov: yes, but that will prepend

19:38 xeqi: &(concat '(1 2 3 4) '(5))

19:39 lazybot: ⇒ (1 2 3 4 5)

19:39 yankov: og

19:39 nice

19:39 amalloy: but, in general, don't append to lists

19:39 yankov: better use vectors for that?

19:39 xeqi: (conj [1 2 3 4] 5)

19:39 &(conj [1 2 3 4] 5)

19:39 lazybot: ⇒ [1 2 3 4 5]

19:39 Frozenlo`: How does one can check if a dom element exists? When I check the value of a variable bound to a DIV that I've just erased, I get: #<[object HTMLDivElement]>. I was expecting nil :(

19:40 arrdem: xeqi: thanks I knew I wasn't totally off-base

19:40 hughfdjackson: Frozenlo`: re-query the DOM

19:40 whoops

19:40 thought we were in ##javascript

19:41 arrdem: hughfdjackson: (eq? #javascript ##javacript)

19:46 Frozenlo`: Is there a cljs equivalent to re-querying the DOM?

19:48 xeqi: wonder if goog.dom/getParentElement could work

19:55 Frozenlock: Trying now... getting a bunch of errors

19:55 Must be a requiring issue.

20:16 (goog.dom/getElement my-var) returns the same #<[object HTMLDivElement]> as before :(

20:17 And goog.dom/getParentElement is not a valid method for the object.

20:17 xeqi: yeah, the api says it returns the dom node if passed one

20:17 Frozenlock: o_O

20:18 xeqi: try (.parent dom-node) ?

20:18 oh (.-parent dom-node)

20:18 blah

20:18 (.-parentNode dom-node)

20:19 Frozenlock: Oh wait I don't get an error on this one

20:19 It works!

20:20 xeqi: &"hurray!"

20:20 lazybot: ⇒ "hurray!"

20:20 Frozenlock: I owe you a drink :)

20:26 I wonder if this should be in domina.

20:33 mpan: Is there an equivalent to use/require for static Java methods?

20:34 e.g. I want to write parseInt and have it be Integer/parseInt

20:34 or am I just supposed to (def parseInt Integer/parseInt)

20:35 (whoops, just tried that and it doesn't work like I think)

20:36 gfredericks: &(doc memfn)

20:36 lazybot: ⇒ "Macro ([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn."

20:36 gfredericks: oh wait static

20:37 no I don't think there's any sugar for static methods

20:37 mpan: currently I've got... (def parseInt #(Integer/parseInt %))

20:37 it feels a bit strange to be honest

20:37 all right, thanks

20:37 gfredericks: I think most people just keep the Integer/parseInt inline

20:40 arrdem: brb nesting in tmux

20:42 mpan: &"test"

20:42 lazybot: ⇒ "test"

20:42 mpan: yay

20:42 &(println "test")

20:42 lazybot: ⇒ test nil

21:24 zilti: With Clojure.zip what's the best way to move directly to a newly appended child?

21:27 tomoj: (comp rightmost down)?

21:28 well (comp rightmost down #(append-child % foo))

21:29 zilti: hmm okay

21:30 tomoj: the only other way I can think of is (comp right #(insert-right % foo) rightmost down)

21:30 zilti: I thought there's maybe a special function for that

21:31 But looking at the docs, it says the child is always added as the rightmost, so (-> zip (append-child child) down rightmost) is it

21:32 bbloom: i always forget clojure.zip exists. super cool little lib

21:51 tomoj: is it possible to have a persistent/transient pair of deftypes in the same file?

21:51 where asTransient and persistent use the other constructors

21:53 you can forward-declare a function that calls the latter constructor :/

21:58 bbloom: tomoj: you mean with the same name?

21:58 tomoj: no, different names

21:58 S11001001: n00b6502: the answer to your question is "definitely not"

21:58 bbloom: i don't understand. why wouldn't that be possible?

21:58 you could use extend-protocol

21:59 tomoj: because the constructor for the latter deftype will not be defined yet when the former is evaluated

21:59 n00b6502: defintely not - no other lisp allows a collection to be "called" for acess ?

21:59 bbloom: rather than the forward declaration

21:59 n00b6502: i need to make my own lisp dialect with every feature i like cherrypicked hehe

21:59 tomoj: well, I{Transient,Editable}Collection aren't protocols on the jvm

21:59 S11001001: n00b6502: I think you said language, but even among lisps the feature is not unique (Arc also does it)

21:59 tomoj: that would work on cljs though?

21:59 bbloom: ah yes, i forgot. *shrug* go with the forward declaration. that's what they are there for!

22:00 S11001001: s,said,implied,

22:00 n00b6502: oh sorry "not unique" not "not elseqhere"... i forgot how i worded it

22:00 tomoj: just sort of wish I could forward-declare a constructor

22:00 though I have no good reason to want that

22:00 S11001001: n00b6502: "is this unique to clojure??"

22:00 n00b6502: ok not unique .. great.

22:01 over on #lisp they think its dysfunctional

22:01 misfeature

22:01 S11001001: among JVM-intended languages, Scala also has sequences, sets, and maps as function subtypes

22:02 amalloy: tomoj: https://github.com/flatland/ordered/blob/develop/src/ordered/map.clj is basically the best you can do

22:02 bbloom: n00b6502: why do they think it is a misfeature?

22:03 n00b6502: i mean pure and simple moving from C like languages, I can handle prefix maths just fine but its object-acessor where the prefix syntax begins to grate. (object member) instead of (slot-value object member) helps a lot :)

22:03 bbloom: n00b6502: learn to love the -> macro

22:04 n00b6502: i got more responses of "thats a dumb idea" on #lisp for various reasons i couldn't be bothered to remember

22:04 S11001001: n00b6502: keep at it and you'll switch to (member object)

22:04 n00b6502: bbloom: my first question on #lisp was how to make a macro for passing a value along... i called it "pipe" .. they said "its a dumb idea". but i gather clojure actually has it ?

22:04 bbloom: ,(doc ->)

22:04 clojurebot: "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."

22:04 bbloom: ,(doc ->>)

22:04 clojurebot: "([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."

22:05 n00b6502: yeah. i wrote that and called it "pipe". they told me "ner ner ner thats not idiomatic lisp ner ner ner"

22:05 bbloom: *shrug* it's idiomatic clojure.

22:05 mpan: the way most java libraries are set up, you'd want that for convenience for interop if nothing else?

22:05 n00b6502: cool :)

22:06 bbloom: consider deeply nested associative structures:

22:06 ,(-> {:x {:y {:z [1 2 3]}}} :x :y :z)

22:06 clojurebot: [1 2 3]

22:06 n00b6502: saves th last line of your function being ))))))))))))))))))))))))

22:06 bbloom: super useful.

22:06 mpan: also feels nicer to read them in the order you think about them

22:07 gfredericks: interesting constrained form of clojure: every function must end in exactly 24 close-parens

22:07 I guess that's pretty trivial with a macro

22:07 mpan: you could cheat by defining a pass-through macro, and that would be the only real constrained writing?

22:08 gfredericks: jinx

22:08 mpan: =p

22:08 idk what to think of this, it just feels so different from other languages I've used

22:08 amalloy: bbloom: that's a terrible example of -> -- it's exactly what you should use get-in for

22:08 bbloom: that's a good thing!

22:08 amalloy: d'oh, you're right. i just needed an example

22:09 mpan: OH!

22:09 n00b6502: (defmacro pipe (&rest args) (reduce (lambda (a b) (append b (list a))) args))

22:09

22:09 mpan: that's actually really useful for what I was going to do

22:09 casion: finally have a basic DSP setup working in clojure

22:09 mpan: get-in would save me a lot of the stuff I was going to type

22:09 * casion wipes brow

22:10 casion: javax.sound.sampled is just retardedly complicated :|

22:10 bbloom: ,(-> [:a :b :c] second name string/upper-case)

22:10 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: string, compiling:(NO_SOURCE_PATH:0)>

22:11 bbloom: ,(-> [:a :b :c] second name clojure.string/upper-case)

22:11 clojurebot: "B"

22:11 bbloom: amalloy: n00b6502: there you go

22:11 a decent example of -> :-)

22:12 tomoj: casion: do you have it working?

22:12 casion: tomoj: yes

22:13 right now I can get a seq of floats/ints/doubles as appropriate from any audio file supported

22:13 and from there most dsp is trivial

22:14 n00b6502: ah -> and ->> 'thread' the results as first or last argument

22:14 mpan: I keep getting confused which is which

22:14 n00b6502: ->> is my 'pipe'

22:16 so that kind of reads like "[:a,:b,:c].second().name().upper-case()"

22:16 tomoj: casion: cool

22:16 the seq isn't lazy, is it?

22:17 casion: tomoj: not yet… I'm getting heap overflows with lazy-seqs atm

22:17 I think it's because of how I'm sizing the buffer for the read

22:17 tomoj: I have some code sitting around that takes a filename and a function and calls the function with each frame

22:17 looking at it now, it seems like that should be a reducer

22:18 mpan: :/ the doc examples showcase where -> and ->> are interchangeable

22:18 casion: converting the frame->sample conversion to a reducer is my next step

22:19 right now it's just a list comprehension that grabs (/ frameLength channels) and bit twiddles that into a proper value

22:21 bbloom: mpan: which docs?

22:22 http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E

22:22 and http://clojuredocs.org/clojure_core/clojure.core/-%3E

22:22 have good examples

22:22 mpan: am I mistaken or are the first example on those two pages interchangeable?

22:23 bbloom: mpan: you're mistaken

22:23 the examples of r->> thread through the LAST argument

22:23 ,(doc map)

22:23 clojurebot: "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."

22:23 bbloom: notice that coll is after f

22:23 ,(macroexpand '(-> x (f y)))

22:23 clojurebot: (f x y)

22:24 bbloom: ,(macroexpand '(->> x (f y)))

22:24 clojurebot: (f y x)

22:24 mpan: oh!

22:24 thank you

22:26 tomoj: casion: so if you have a seq of samples, you partition by a frame length and send each partition through a R2R fft to get the spectrogram of the audio?

22:26 casion: partition by framelength, then partition by channels

22:26 n00b6502: (defn lerp [lo hi f] (->> (- hi lo)(* f)(+ lo))) (lerp 5 10 0.5)

22:26 ,(defn lerp [lo hi f] (->> (- hi lo)(* f)(+ lo))) (lerp 5 10 0.5)

22:26 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

22:27 bbloom: n00b6502: can't def w/ clojurebot

22:27 casion: or you can just pull out the channels I guess

22:27 bbloom: ((fn [lo hi f] (->> (- hi lo)(* f)(+ lo))) 5 10 0.5)

22:27 ,((fn [lo hi f] (->> (- hi lo)(* f)(+ lo))) 5 10 0.5)

22:27 clojurebot: 7.5

22:27 casion: I've been partitioning by framelength, converting to the appropriate type, then partitioning by channels

22:28 I suspect there's a better way. Most of today has been fighting the awful java docs on this stuff

22:30 right now, partition doesn't exactly work well with larger files (runs out of heap space, and it's super slow anyway)

22:36 n00b6502: is a clojure literal map a mutable colleciton

22:36 gfredericks: no

22:36 n00b6502: so its more like an immutable adhoc object perhaps

22:37 gfredericks: I'm not sure what you meant by changing "collection" to "object"

22:37 it's just an immutable map datastructure

22:38 n00b6502: for multiple return values do you just use a vector literal

22:38 gfredericks: sure

22:38 or a map if you want to give them names

22:39 n00b6502: whats the best way to bind elements of a vector to symbols .. (i'm thinking of multiple-value-bind in CL)

22:39 bbloom: destructuring

22:39 gfredericks: +1

22:40 bbloom: ,(let [[x y & zs] (range 10)] {:foo x :bar y :baz zs})

22:40 clojurebot: {:foo 0, :bar 1, :baz (2 3 4 5 6 ...)}

22:41 bbloom: also works with maps & other fun stuff. see the let for on here: http://clojure.org/special_forms

23:25 Frozenlock: If nothing refers to an atom anymore, is it discarded?

23:29 bbloom: Frozenlock: why wouldn't it?

23:31 Sgeo: bbloom, because in some languages, they... oh, wait, "atom" in Erlang means something else

23:32 Frozenlock: bbloom: I just don't suppose things anymore.

23:33 bbloom: heh. yeah. erlang atom is similar to a symbol or keyword. but JVM clojure *does* garbage collect those by leveraging weak references

23:33 Frozenlock: And cljs?

23:33 bbloom: cljs (currently) encodes keywords and symbols into strings

23:33 which the underlying javascript engine will certainly garbage collection

23:34 however, javascript doesn't provide weakreferences

23:34 sadly....

23:34 mpan: speaking of which, what is the purpose of keywords that symbols don't already fulfill?

23:35 bbloom: keywords are like symbols that always refer to themselves

23:36 :foo is always :foo. but 'foo could refer to a local, or a function, or something else entirely

23:38 ,`(class :foo)

23:38 hmm...

23:38 ,(identity `(class :foo))

23:38 where's clojure bot when you need him

23:38 clojurebot: (clojure.core/class :foo)

23:38 (clojure.core/class :foo)

23:38 bbloom: ah there we go

23:38 anyway

23:38 notice how "class", a symbol, was resolved

23:38 but :foo remained unchanged

23:39 there is no lookup process for a keyword. if you have the keyword, you have all that it represents

23:39 if you have a symbol, you need to know how to interpret it, like that syntax quote does, by looking up the function in scope with that symbol for a name

23:42 make sense?

23:42 mpan: er, but like, what's to stop people from using symbol literals?

23:42 like, explicitly quoted symbol literals?

23:42 bbloom: nothing

23:42 and that's what the common lisp folks do, right?

23:42 mpan: dunno

23:42 bbloom: (i'm not a common lisper, i dunno for sure)

23:43 of course you can quote symbols:

23:43 ,`('class :foo)

23:43 clojurebot: ((quote clojure.core/class) :foo)

23:43 mpan: oh, wait

23:43 bbloom: but it still get resolved!

23:43 mpan: but then it tries to figure out which "class" you mean?

23:43 bbloom: so you need to do some trickery

23:43 ,`(~'class :foo)

23:43 clojurebot: (class :foo)

23:44 bbloom: and, indeed, that's sometimes (although rarely) useful

23:44 mpan: you're allowed to use that outside macro defs?

23:44 oh wow

23:44 bbloom: haha sure!

23:44 :-)

23:44 mpan: all right thanks

23:45 I guess I'm trying to stay away from the meta bits until I need them

23:45 bbloom: yeah, i've been contributing to the clojurescript compiler

23:45 where it's not so much meta, as it is … um… something less than meta ;-)

Logging service provided by n01se.net