#clojure logs

2012-09-01

00:02john2xwhy do I get "Unable to find state with key: :tile-count-y" with this? http://pastie.org/4643791(line 15, i'm using Quil)
00:02john2xhttp://pastie.org/4643791
00:08S11001001john2x: set-state! is not cumulative; it replaces *all* the state
00:09technomancyjkkramer: was it a conscious decision to not treat the pom metadata as canonical?
00:09technomancynesting :description, :url, etc under the :clojars sub-map?
00:09john2xS11001001: oooh right.. didn't understand the doc very well.. thanks!
00:11S11001001john2x: reading source is your friend; docs will always let you down in the end
00:11jkkramertechnomancy: in the final graph format?
00:12technomancyjust tackling read-all-pom-projects for now
00:12muhoois there some way to get nrepl.el to send forms to some ns other than user?
00:13technomancyjkkramer: oh, I see where you make a best guess at the top-level description
00:13jkkramertechnomancy: reconstructing my own thought process here, too. I believe that part merely adds a :clojars key to the project map extracted from the pom
00:13muhooi found nrepl-buffer-ns, but can't figure out how to set it
00:13technomancyin build-best-info
00:13technomancymuhoo: the current buffer ns tracking stuff in nrepl.el is a bit wonky
00:13technomancyI tried to get him to read it from the file every time, but that didn't fly =\
00:13john2xS11001001: 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. :)
00:14muhootechnomancy: is there some hack i could use to get around the wonky?
00:14technomancyC-c M-n maybe?
00:15muhooM-n is bound by my wm
00:15muhoowhat is the emacs function usually bound to it?
00:15technomancyESC-n is another way to do M-n
00:15muhooM-n is undefined
00:16muhooah, i see nrepl-set-ns
00:16technomancyright; you have to do C-c first
00:17muhooi found it in nrepl-interaction-mode map.
00:32muhoonope, nrepl-buffer-ns is not getting sent, anything getting nrepl-intearative-eval'ed is going to #user/ . oh well. thanks anyway.
00:37john2xcan I use an atom in a let() and change it's value within the let()?
00:39arohner_why is there keep-indexed, but not filter-indexed?
00:40arohneralso strange that keep-indexed returns the result of (f index item), rather than item
00:58arohnerstupid question. Why are keywords not sugar for strings?
00:59ivanbecause keywords are optionally-namespaced symbolic identifiers that implement IFn
00:59Raynes(defn filter-indexed [f coll] (keep-indexed #(when (f % %2) %2) coll))
01:00amalloy(filter-indexed (fn [i x] (even? i)) (repeat 10 nil)) ;; Raynes
01:00RaynesCongratulations.
01:00ivana string is some unicode and is not a symbolic identifier
01:01arohner,(keyword "Π")
01:01clojurebot:??
01:01lazybotclojurebot: Uh, no. Why would you even ask?
01:01clojurebotHuh?
01:02arohnerworks on my machine
01:02RaynesNamespaced keywords aren't particularly special. They just have names prefixed with whatever namespace.
01:02RaynesSo strings could do the same thing. But strings aren't functions.
01:02arohnerI like the IFn answer, but that's a limitation of java. if you were writing your own lisp, why care about string vs. keyword?
01:03RaynesWhat does it matter if a keyword is a specialized symbol or a specialized string?
01:03arohnerI'm trying to understand why you would create the concept, if it didn't exist
01:04amalloykeywords guarantee that = provides the same results as identical?
01:04amalloyis one reason they're useful
01:04arohnerI appreciate the sugar, but making it a different type seems like a mistake Rich doesn't make lightly
01:04RaynesA mistake? :\
01:05arohnerI'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
01:35muhoohttps://github.com/kingtim/nrepl.el/pull/60 <== already fixed by someone, yay
02:13muhootrying to run nrepl on a 256MB embeded board is just... not a very practical idea.
02:14muhooold lein1 with the telnet repl worked fine. new lein2 with nrepl does not.
02:15gunsmuhoo: Running clojure on Raspberry pi?
02:19muhooguns: beagleboard
02:19gunsmuhoo: Ah. And how is that working. Very curious
02:20muhooit worked great with lein1. with lein2, not so much.
02:20gunshm. But clojure programs themselves run acceptably?
02:21muhooi suppose i should try aot'ing the app and running it that way. would probably be more successful.
02:21gunsIt seems like such an excessive luxury on an embedded plaform.
02:21gunsOF course I'm gonna try it when I get my hands on one
02:21clojurebotRickInGA: of course :-) *everything* is in Clojure
02:22gunsI guess 256M RAM stretches the boundaries of "embedded"
02:22amalloysurprisingly relevant, clojurebot. well done
02:22muhooi got addicted to being able to do things interactively on it.
02:23gunsThat sounds fantastic; compile-restart doesn't take that long, but commanding the board from the editor sounds like a great time
03:47john2xhow do I include a jar file I downloaded from the internet in my leiningen 2 project? (where do I place it?)
04:09tomojshouldn't there be a way to fold a vector in reverse?
04:12tomojshould there be a ReduceReversible protocol?
04:21Raynestomoj: (reverse (reduce …)) :P
04:21RaynesEr, backwards.
04:22RaynesDon't mind me, just being an ass.
04:24amalloytomoj: that seems like a nice property, and possible, but i'm not sure how you would fit it into the existing reducers lib
04:25amalloyyou basically want rseq as a reducer traansformer
04:36tomojamalloy: yeah
04:36tomojbut
04:36tomojnot exactly
04:36tomojI mean it can't work on any reducer
04:41amalloyright, it has to be a separate protocol
04:49tomojis that different than foldr?
05:03tomojseems the same on vectors
05:03tomojbut maybe the protocol should be for foldr, like IRightReduce
05:04tomojthen a tree type can get both foldl and foldr even though rseq doesn't make sense
05:25n00b6502does clojure have 'tree-like fold' .. its more parallelizable .. (f (f a b)(f c d)) vs (f a (f b ( f c d))))
05:26tomojyes, it's called 'fold'
05:26tomojnew in 1.5.0 (which is still alpha)
05:27tomojclojure.core.reducers/fold to be specific
05:44n00b6502ah so the named default is tree like. neat.
05:52tomojwell the normal folding function is `reduce`, `fold` is the parallel version and only works on a subset of the things `reduce` works on
06:56abpweavejester: are you around?
07:00abpweavejester: I got some crazy ideas about reverse routing in compojure floating in my mind and want to let them wander through yours, to validate. :)
07:00lyttonany problems with executing Clojure, compojure and cucumber with lein2? When I add cucumber to plugins it fail (user.clj:14)
07:10weavejester_abp: I'm around now
07:11abpweavejester_: 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.
07:13weavejesterOkay. Such routing maps would not work in all cases, but might be able to cover the majority.
07:14abpweavejester: Which cases would not work? I haven't looked into context by now.
07:15weavejesterRoutes can be chosen according to arbitrary criteria.
07:15weavejesterFor example
07:15weavejester(if (= :heads (coin-toss)) routes-a routes-b)
07:16abpweavejester: Ah okay.
07:17weavejesterThat's partially why I've not added any form of reverse routing, because it seems a little iffy - it's not a guaranteed thing.
07:18abpweavejester: Yes, that's really inconvenient, but working without reverse-routing is too.
07:19weavejesterMy thought is that if reverse routing is wanted, then we'd need something on top of Compojure
07:19weavejestere.g. if you create routes with library X, you can reverse route.
07:20weavejesterMaybe by defining a resource or something.
07:21tomojwhat is reverse routing?
07:21weavejesterGiven a var, what URL is it bound to
07:21abpweavejester: Hm, probably, but light-weight, stateless reverse-routing would fit compojure, I think. Everything else would have that "bolted on" feel, because it is. :)
07:21weavejesterInstead of normal routing, which is, given a URL, which var should I use as a handler
07:22weavejesterabp: It wouldn't be bolted on. It would be a new layer
07:22weavejesterThe problem with reverse routing at the Compojure level is that Compojure allows you to write routes that are impossible to reverse.
07:23weavejesterAnd I don't like the idea of a fuzzy reverse route
07:23weavejesterBut if there was a library on top of Compojure that constrained which routes were allowed, you could get more information.
07:26weavejesterMaybe a library that used a data structure of routes
07:28abpweavejester: Yeah, I will think a little more this.
07:29abp*about this.
07:30weavejesterGood luck :)
07:33abpweavejester: 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? :)
07:34pyykkisweavejester: 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.
07:34pyykkis..how did you end up..
07:35weavejesterabp: Currently stalled, I'm afraid. I'm currently working on migrations (via ragtime) and thinking about distributed computing
07:36weavejesterpyykkis: 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.
07:37weavejesterpyykkis: That said… (GET "/foo/:id" [id] …) is perhaps more obvious as to its function than (r/get "/foo/:id [id] …)
07:38abpweavejester: Ok, doesn't sound bad either.
07:39weavejesterpyykkis: 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
07:40casionespecially since get is already used in core
07:42weavejesterYeah, though it could have been (route/get "/" [] ...)
07:42weavejesterBut to me that stands out less.
07:43pyykkisweavejester: 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.
07:44pyykkisquite refreshing after rails & co
07:44pyykkiscasion: ah, that's a good point
07:45weavejesterYeah, we couldn't ever have (get "/foo" [] …) like in sinatra
07:45weavejesterWell… not without a (:refer-clojure :exclude (get)) :)
07:45weavejesterpyykkis: It's good to hear you're enjoying it.
07:45@rhickeylein 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
07:46@rhickeyI've tried but it seems to be a no-op
07:46pyykkishaha, requiring people to exclude get woud've surely be confusing :)
07:46@rhickey :pom-addition [:build [:plugins [:plugin ...
07:49xeqirhickey: no, adding maven plugins doesn't work
07:58@rhickeyxeqi: thanks
08:05xeqirhickey: 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 :\
08:16samrati'm trying to use clj-oauth with Instapaper's xauth API, but its a bit confusing because "there is no request-token/authorize workflow"
08:22pyykkishm..is there a way reload nrepl session started with nrepl-jackin?
09:03weavejesterHm, that's annoying. Clojure 1.5.0-alpha4 is compiled against 1.6.
09:28voland62_2What's the difference between -> and ->> macroses?
09:38xeqi&(-> 1 (- 3))
09:38lazybot⇒ -2
09:38xeqi&(->> 1 (- 3))
09:38lazybot⇒ 2
09:39xeqi-> inserts the first argument, ->> uses inserts the last arguments
09:41casionI'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?
09:42casionpassing the correct arg is no problem, but getting the filled array is beyond me atm
09:45xeqi(doc into-array)
09:45clojurebot"([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."
09:46RonnieDk, (re-find #"<span id=\"yfs_184_carl-b.co"
09:46RonnieDk "<span id=\"yfs_l84_carl-b.co")
09:46clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
09:47casionxeqi: I'm not sure how to apply that info.. if read() returned the array then I get it, but it returns the bytes read
09:48RonnieDkis there a way to repeat the last expression entered nrepl? Without copy/paste
09:50jkkramercasion: the byte array is mutable, so bind it with let, then just refer to the same binding after the read call
09:51casionjkkramer: that's what I thought, but it's not working… so I assume I"m doing something else wrong
09:51casionI will work under that assumption then, thank you
09:51xeqicasion: yeah.. I think you just want to do something like (let [b (byte-array array-size)] (.read inputstream b) ..)
09:51xeqithen you could (slurp b) to get a string, but I'm sure theres something different you want to do to it
09:52casionit's telling me that it's read the whole stream, then the byte-array is still empty
09:52casionI'll work through it, at least I have the concept correct :)
09:52casionthanks again
09:54xeqicasion: how are you trying to get data out? (aget b 0), (seq b), etc
09:54casionI'm just checking with alength atm
09:54casionwhich it would seem to mean that the array isn't getting set to the right size to begin with
09:55casionahhhh
09:56casionInputStream.available() was returning 0, and that's what I was using to create the byte-array
09:57casionread wasn't throwing an exception when passing a 0 length array though :\
09:59casionand everything works now :)
10:14@rhickeyIs there a way to get lein to use a local jar not in any repo (as a dep)?
10:19xeqirhickey: you could use https://github.com/kumarshantanu/lein-localrepo to inject the jar into your local maven cache
10:20xeqibut lein tries to encourage repeatability, so doesn't have a mechanism for jars outside repos
10:20xeqi~repeatability
10:20clojurebotrepeatability is crucial for builds, see https://github.com/technomancy/leiningen/wiki/Repeatability
10:21@rhickeyrepeatability should not get in the way of experimentation when things are new, as all of this artifact-based stuff does
10:21tmciverxeqi: 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@rhickeyI don't want in in a repo, I know how to do that
10:22SgeoWould bundling a jar with your code prevent repeatability somehow?
10:23@rhickeyxeqi: thanks for the info
10:24jonasenI'm using lein install with lein2 and it works for me
10:25xeqiSgeo: it could work, but then your sticking jars in the version control system
10:25xeqilein accepts file:// repos, so it can be done, just ugly to get it all setup in the format maven likes
10:31samrati'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:32samratif I do add [clj-http "0.5.3"] as a dependency I start getting errors
10:39xeqisamrat: 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:39xeqihttps://github.com/r0man/oauth-clj looks like it uses the clj-http mentioned
10:45ssiderishello. if bytes in java go from -128 to 127, shouldn't this code return "ff"?
10:45ssideris(format "%02x" (byte 127))
10:46ssideris&(format "%02x" (byte 127))
10:46lazybot⇒ "7f"
10:46samratxeqi: will try that. how do i add my own fork to a project? do I have to upload it to clojars?
10:46ssideris(which as you can see it doesn't)
10:47xeqi&(format "%02x" (byte 255))
10:47lazybotjava.lang.IllegalArgumentException: Value out of range for byte: 255
10:47ssiderissamrat: there is also this: https://github.com/tobyhede/lein-git-deps
10:47ziltissideris: The hex system doesn't get changed just because Java only supports "byte" up to 127. 7f means 127
10:48zilti* means byte-value 127
10:49samratssideris: yeah, but I mean during developing locally?
10:49xeqisamrat: change the group name to something like org.clojars.samrat; lein install in your fork will make it work locally
10:50ssideriszilti: 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:50xeqiuploading to clojars is prolly the easiest to make it work on multiple machines
10:50tmciverssideris: if you don
10:50ssideriswhen (class (.get data 0)) is also a jaba byte
10:50ssiderisjava
10:51tmciverif you don't cast to byte, it works ##(format "%02x" 255)
10:51lazybot⇒ "ff"
10:52dhofstethow does one submit typo fixes for the API docs? Creating a pull request on Github?
10:53samratxeqi: did lein install, but how do I specify in project.clj that I want the local repo and not from clojars?
10:54ssiderissamrat: there is also the option of having a checkouts dir in your project
10:54ziltiI'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:55ssideriszilti: look into zippers
10:57samratmattrepl: hi, any plans on upgrading clj-oauth? i was having some troubles
10:59xeqisamrat: 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:00xeqidhofstet: for clojure or a contrib library?
11:00dhofstetxeqi: clojure
11:01mattreplsamrat: 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:04ziltihmm 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:04xeqidhofstet: I think you have to sign a CA and make a ticket in jira, clojure uses github as more of a mirror
11:04xeqizilti: https://github.com/kingtim/nrepl.el/issues/86 ; it works sometimes
11:10dhofstetxeqi: hm, seems a bit overkill for such a trivial fix
11:11seancorfieldthe CA etc provides legal protection for the Clojure project which is important if the language is to gain wider acceptance in industry
11:11seancorfieldnearly all open source language projects require a CA these days for licensing reasons
11:12seancorfieldsee http://clojure.org/contributing for more details
11:12ziltiok so nREPL is totally broken at the moment... too bad
11:13seancorfield(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:13cshell_Yeah, Sun was doing it with all of their os projects - doesn't seem that out of line
11:14dhofstetseancorfield: I understand that, but for removing three spaces from the docs it is just not worth going through this process
11:15seancorfielddhofstet: agreed for that - you could just open a ticket in jira about it i believe without needing any paperwork
11:15seancorfieldsomeone with a CA on file will be happy to make that change i expect :)
11:15dhofstetseancorfield: ok, will do
11:16xeqiseancorfield: ah, I wasn't sure if you needed a CA to open a ticket
11:17seancorfieldonly for submitting a patch - but you probably need to create a jira account to open a ticket
11:18seancorfieldbasically 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:18seancorfieldso patches only, from folks with CAs
11:20wmealing_i dont understand why a CA for a language would be different than requiring a CA for a program
11:20wmealing_not my pony though.
11:20wmealing_it cant be any more GPL, and by working on a project, its not up to a project to be complicit with licencing
11:20wmealing_its up to the contributor to understand
11:21seancorfieldwmealing_: not saying there's a difference between language project and program project...
11:23wmealing_other software has got along fine for the longest time
11:23wmealing_imagine gcc.
11:25wmealing_so, if i wanted to add properties like value="n" to a drop-down in hiccup, is that possible ?
11:26wmealing_http://weavejester.github.com/hiccup/hiccup.form.html#var-drop-down <-- for the docs.. if anyone thinks i'm going mad.
11:28xeqiI thought gcc wanted copyright assignement too http://gcc.gnu.org/contribute.html
11:28xeqi*the fsf
11:29wmealing_i commited, never had any kind of CA..
11:29wmealing_maybe someone fudged it.
11:29wmealing_ah.. employee disclaimer
11:29wmealing_employer rather
11:29wmealing_thats why
11:30wmealing_and perhaps "Small changes can be accepted without a copyright disclaimer or a copyright assignment on file"
11:30seancorfieldCAs weren't as common back in the day, before the US became so darned litigation-happy :(
11:31seancorfieldhaving been thru a corporate audit of open source software licenses (at adobe), i know how paranoid many large companies can be
11:32pyykkisEven though I understand the reasoning, CA and Jira are the worst of clojure world, i must say :/
11:33wmealing_we tolerate evil and pay the consequences of doing so.
11:33wmealing_instead of solving the problem and revolting on it, we turn a blind eye to the larger cancer.
11:34seancorfieldlarger cancer = corporate litigation, i assume? (and i agree, fwiw)
11:34wmealing_yes.
11:35wmealing_i'm not smart enough to solve it, but i know the collective we.. is.
11:35pyykkisas 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:35bosiepyykkis: CA?
11:35seancorfieldpyykkis: yes, CA / JIRA are the worst of the Clojure world, and if that's the worst, then we're in pretty good shape :)
11:36seancorfieldnode.js has a CA: http://nodejs.org/cla.html
11:36bosieok
11:37pyykkisseancorfield: oh, lol :D I didn't even be aware of that
11:38pyykkisseancorfield: 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:39seancorfieldruby is GPL yes? not surprised that a GPL project doesn't require a CA... bunch of tree-hugging hippies :)
11:40seancorfielda lot of large corporates won't use GPL unless they can buy a closed source commercial edition (which ruby / rails offers i believe?)
11:41seancorfieldwhen 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:41bosieseancorfield: are you using clojure exlusively these days at work?
11:42seancorfieldbosie: for the back end, almost exclusively yes
11:42wmealing_one has to take it seriously
11:42wmealing_its what licences are
11:42seancorfieldfor the front end, railo - a jboss community project - that provides a fast, free implementation of cfml
11:43seancorfieldbosie: my blog talks about the cfml / clojure integration we do - http://corfield.org
11:44seancorfieldi think we got distracted wmealing_
11:45seancorfieldi haven't used that part of hiccup so i can't answer, i'm afraid
11:46wmealing_maybe enlive might be more useful
11:46seancorfieldis the q that you want to add a new option after the select has been generated?
11:47technomancyruby has a custom license
11:47technomancythey don't need a CA to make contributing a huge PITA; the language barrier is enough
11:47wmealing_nah, i can't generate the additional key=value sub options of the drop-down box
11:48wmealing_i'd like <select> <option name="test">testing 123</a>
11:48wmealing_oops, bad closing tag.. sorry its late here
11:49wmealing_the name=test part, i can't seem to do easily.
11:49jkkramerwmealing_: I think you can pass a vector for each option… [["testing 123" "test"] ["foobar" "foo"], ...]
11:50pandeirowmealing_: jkkramer: [:select (for [opt options] [:option {:name (:name opt)} (:title opt)])]
11:51jkkramerpandeiro: that gets tedious if you have to check for the selected value
11:52jkkrameron the other hand, writing your own helper function is pretty easy if drop-down isn't cutting it
11:53samratmattrepl: 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:53jkkramertechnomancy: 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:53wmealing_both work.. thanks..
11:53ssiderisis anyone else getting ^M at the end of lines in the swank repl in emacs in windows?
11:54seancorfield(drop-down :foo [[:test "testing 123"]]) works wmealing_
11:54seancorfieldi had to update my version of hiccup to test that... didn't realize i was on such an old version :(
11:55jkkramerseancorfield: saw your work on jsql. I have a project that may interest you… https://github.com/jkk/honeysql
11:56jkkramerseancorfield: 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:02seancorfieldjkkramer: nice... looks like it would combine well with java.jdbc for more complex sql expressions
12:07jkkramerseancorfield: yeah. and it really comes in handy when progressively composing/adjusting queries
12:10seancorfieldjkkramer: 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:15jkkramerseancorfield: 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:15ziltiThere 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:18nbeloglazovzilti: do you need :use or :require?
12:18ziltinbeloglazov: What's the alternative?
12:19ziltiwriting the full path?
12:20nbeloglazovzilti: check this article: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
12:21nbeloglazovzilti: it seems that you really need :require because you specified aliases via :as for namespaces
12:21ziltinbeloglazov: Which gives me a "next already refers to: #'clojure.zip/next in namespace: orgparser.core" error
12:27ziltiHmm ok a restart fixes this
12:27pandeirothere's no autocomplete functionality in source code buffers with nrepl.el + ac-nrepl.el ?
12:27pandeiroonly in the nREPL buffer?
12:29pandeiroi enabled auto-complete-mode but it doesn't complete fns from clojure.core
12:33Frozenlo`"Phil Hagelberg has some thought-provoking advice on this matter." What's this usage of real name? Tssss...
13:53RonnieDkA bit of regex trouble. How come (re-find #"yfs_184" "yfs_l84") return nil?
13:55nbeloglazov&(re-find #"yfs_184" "yfs_184")
13:55lazybot⇒ "yfs_184"
13:55RonnieDknot in my nrepl
13:55nbeloglazovRonnieDk: your strings have differences
13:56nbeloglazovRonnieDk: 1 in the pattern and l in the string
13:57RonnieDknbeloglazov: but how there be a difference? It's two simple strings
13:57nbeloglazov&(= "yfs_184" "yfs_l184")
13:57lazybot⇒ false
13:57nbeloglazov&(= "yfs_184" "yfs_l84")
13:57lazybot⇒ false
14:01samfloreswhich is that character after the underline in the second string?
14:02RonnieDksamflores: Damn ... you're right.
14:02samflores:p
14:02nbeloglazov:(
14:05FrozenlockIn 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:48borkdudehas anyone used https://github.com/adamwynne/twitter-api/? I'm trying (profile-image-for-user :params {:screen_name "Borkdude"}) but...
14:48borkdudeI get this nasty msg: JSON error (unexpected character): <
14:48borkdude [Thrown class java.lang.Exception]
14:53borkdudemaybe it expects the body to be encoded?
14:53samratwhat does this error mean https://www.refheap.com/paste/4793 ?
14:54gfrederickssamrat: what's your ns form look like?
14:55ziltiI'm trying to get zippers working, but that doesn't work: https://gist.github.com/3583132, why?
14:57samratgfredericks: https://www.refheap.com/paste/4794
14:59gfrederickssamrat: the quote on line 2 could be messing it up
15:00gfredericksyeah that seems to be the case
15:00samratgfredericks: thanks
15:00michaelr`hello
15:05borkdudehow can you reset an alias in a namespace?
15:07borkdudefound i
15:07borkdudet
15:08ziltiAll I get is a NullPointerException without a message, so I have no idea what's wrong
15:28borkdudeis there a "switch repl to namespace visited in this file" in emacs (swank-clojure) like "Switch REPL to files namespace" in Counterclockwise?
15:29ziltiborkdude: C-x M-p
15:30borkdudezilti undefined
15:32borkdudezilti C-c M-p, tnx
15:32ziltiborkdude: Oh, yes. Sorry
15:44pandeiroinside of a typical nested src directory structure, what is the default filepath?
15:44pandeiroin the past i thought doing (read-file "project.clj") worked from anywhere inside the src/... structure
15:53SegFaultAXIs there a range-like that can produce an infinite sequence starting from a number other than 0?
15:54ziltiI'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:54SegFaultAX,((fn range-from [n] (cons n (lazy-seq (range-from (inc n))))) 10)
15:54clojurebot(10 11 12 13 14 ...)
15:54SegFaultAX,(take 10 ((fn range-from [n] (cons n (lazy-seq (range-from (inc n))))) 10))
15:54clojurebot(10 11 12 13 14 ...)
15:55xeqi#(doc range)
15:56xeqi(doc range)
15:56clojurebot"([] [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:56xeqihmm, I guess it only takes an end
15:56arrdem,(inc xeqi)
15:56clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: xeqi in this context, compiling:(NO_SOURCE_PATH:0)>
15:56arrdem(inc xeqi)
15:56lazybot⇒ 3
15:56SegFaultAXBut I don't want to give an end, just a start.
15:56xeqi,(map #(+ 10 %) (range))
15:56clojurebot(10 11 12 13 14 ...)
15:56SegFaultAXAnd obviously ##(range 3) aint it.
15:56lazybot⇒ (0 1 2)
15:57alpheusI 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:57SegFaultAXxeqi: So the answer is no, then? Such a thing doesn't already exist?
15:58xeqiSegFaultAX: nothing built in that I'm aware of
15:58SegFaultAXxeqi: Cool, thanks mate.
15:59xeqiSegFaultAX: ##(iterate inc 10)
15:59lazybotExecution Timed Out!
15:59xeqi,(iterate inc 10)
15:59clojurebot(10 11 12 13 14 ...)
15:59xeqiforgot about iterate for a moment
16:00xeqialpheus: I assume `slurp`-ing the inputstream won't work?
16:01alpheusxeqi: no, slurp corrupts binary data. spit, too.
16:01arrdem(doc slurp)
16:01clojurebot"([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:02alpheusI've been using clojure.java.io/copy to copy to a file and then using Unix cmp (for my tests)
16:02arrdemyeah that'll break binary data...
16:02alpheusAlso, I can't figure out what "opts" is for slurp.
16:03arrdemalpheus: 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:04xeqiperhaps something like (let [x (bytearray (.available inputstream))] (.read inputstream x) (is (= (seq x) expected))) ?
16:05xeqi* byte-array
16:10alpheusxeqi: thanks
16:14FrozenlockIs it possible to have multiple browser windows in the same 'environment'
16:15FrozenlockFor example, if I declare a variable from the REPL, I would like all of them to have it.
16:16goodieboyi'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:17dnolenFrozenlock: I think Brenton Ashworth was working on that, but I don't know if there's been much progress recently.
16:17weavejesterYou'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:18goodieboyweavejester: 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:18pandeiroweavejester: could you show me how i would rig a compojure route to modify a ring session map?
16:19Frozenlockdnolen: I don't see anything on his github. I suppose it's really still an experiment.
16:20weavejestergoodieboy: 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:20goodieboyweavejester: oh is that the bultitude thing?
16:20goodieboyhttps://github.com/Raynes/bultitude/ ?
16:20weavejesterpandeiro: (-> (response "whatever") (assoc-in [:session :your-key] "some-value"))
16:20xeqihttps://github.com/cemerick/pomegranate
16:20goodieboyweavejester: wait, you can dynamically load a jar?
16:20dnolenFrozenlock: it's a ClojureScript branch on the main repo
16:21xeqigoodieboy ^
16:21weavejestergoodieboy: Yeah, you can create a new classloader with a new classpath to execute your jar in
16:21goodieboyxeqi: ahh ok, i've heard of that. i'll have a look thanks!
16:22goodieboyweavejester: i didn't know you could do that, nice
16:22weavejestergoodieboy: 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:23goodieboyit does sound tricky
16:23xeqihttps://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:23pandeirois there a way to reload all buffers with nrepl.el?
16:24goodieboyxeqi: very cool
16:26weavejestergoodieboy: Actually, you probably want this: https://github.com/flatland/classlojure
16:27weavejesterGet someone to upload an uberjar of the plugin (i.e. a jar with all deps included)
16:27xeqi(inc weavejester)
16:27lazybot⇒ 4
16:27weavejesterThen use classojure to call API methods
16:27xeqithat would be a better way
16:28xeqithen you don't have to worry about dependencies on different versions of the same library
16:29goodieboynice, i'll have a play with that as well
16:29weavejesterAlthough...
16:29weavejesterIf you have a web app
16:30weavejesterThen plugins are usually done through a web API
16:30weavejesteri.e. plugin developer hosts a web app
16:30weavejesterregisters it with your system
16:30weavejesterand then your system calls specific URIs on the plugin app
16:32goodieboyhmm, 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:32weavejesterIf it's an open source app then I guess jars might work best
16:33goodieboybasically, a way to hook into the app without modifying the source
16:41pandeiromuhoo: are you using couch-session still?
16:49bloudermilkAre records less efficient than maps with regard to persistence/structural sharing?
17:00FrozenlockI 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:02weavejesterFrozenlock: lein deps :tree should show you everything
17:03goodieboyweavejester: hey i'm thinking about using dynamodb for a project and ran across rotary. Does it support the async client?
17:03Frozenlockweavejester: Thank you.
17:04FrozenlockI'm starting to think it's a soft/hard dependency issue https://github.com/technomancy/leiningen/blob/master/doc/FAQ.md
17:04weavejestergoodieboy: No, but the library is in an early state.
17:04goodieboyweavejester: ok just checking. Love the name btw.
17:04weavejestergoodieboy: Thanks
17:05weavejestergoodieboy: Also, is there a point to use the async client in Clojure?
17:05dnolengetting warmer https://github.com/clojure/clojurescript/commit/48bb400838a7e45daa776a8afb817910c54d3a8c
17:06goodieboyweavejester: you mean, because we have agents etc.?
17:06Frozenlockdnolen: May I ask to what? :)
17:06weavejestergoodieboy: The async client returns futures… I guess it's not using them with threads, but with nio or something
17:07goodieboyweavejester: yeah that's what i thought too
17:08weavejestergoodieboy: It might be worth in a future version to switch to the async client if it's using nio
17:08weavejestergoodieboy: Have it return something deref-able.
17:08goodieboyweavejester: yeah exactly
17:08goodieboyi'm looking for the docs now
17:10emezeskeFrozenlock: I think cljs is getting closer to having source map support, so you can debug it in a browser much more easily
17:18FrozenlockI 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:21casionis there any short way to convert a java byte-array to a seq (other recursion + conj)
17:21casionother than*
17:22aperiodicyou can just call seq on it
17:22aperiodic,(seq (byte-array 1 (byte 42)))
17:22clojurebot(42)
17:24samflores'(doc seq)
17:24samflores,(doc seq)
17:24clojurebot"([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:24casionthanks aperiodic
17:31xeqiFrozenlock: 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:33Frozenlockxeqi: looks really neat! Thanks!
17:49aperiodicemezeske: 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:49aperiodicemezeske: should i open an issue, or just refrain from doing such uncouth things?
17:50emezeskeaperiodic: What is pygments?
17:51emezeskeaperiodic: And was the link "x.cljs -> x.clj" or "x.clj -> x.cljs" ?
17:51aperiodicemezeske: pygments is a syntax highlighting tool, and the link was x.clj -> x.cljs
17:53emezeskeWell, 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:54emezeskeAlthough without :require-macros I don't know why it would even look at that file
17:54emezeskeRefheap of the choking stack trace?
17:54emezeskeMaybe it broke when trying to get the mtime of a symlink
17:58aperiodicemezeske: 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:59aperiodici'd expect the build to just fail
17:59emezeskeWell, that's the compiler crashing, which cljsbuild doesn't try to catch
17:59emezeskecljsbuild just catches builds that fail
18:01aperiodicare you opposed to catching compiler crashes?
18:02emezeskeI 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:03aperiodicthen 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:03emezeskeActually, that's not even the compiler crashing
18:03emezeskeThat's the clojure compiler crashing
18:04emezeskeYou do make a fine point
18:05emezeskeOpen an issue and link that stack trace, I think it would be easy to just wrap the clojure reloader in a try
18:05aperiodicsounds good!
18:06emezeskeNow that I think about it, that really should be caught. I'll stop being stubborn now. :)
18:12aperiodicissue opened
18:12aperiodicthanks for being convinced :)
18:12emezeskeGood job convincing me!
18:12emezeske:)
18:24n00b6502i like the way clojure makes maps,vectors callable functions to lookup their contents.. is this unique to clojure??
18:24lazybotn00b6502: Definitely not.
18:24n00b6502is that automated
18:25emezesken00b6502: Definitely not.
18:26emezeskeHaha, lazybot is such a jerk :)
18:26emezeskeI don't know the answer to your question.
18:27SegFaultAXWhat's the easiest way to insert something into the middle of a list?
18:28SegFaultAXLike if I want to insert :foo into [:a :b] to yield [:a :foo :b]
18:28SegFaultAX,(assoc [:a :b] 1 :foo)
18:28clojurebot[:a :foo]
18:28emezeskeSegFaultAX: You can (concat [first part of list] [element] [last part of list])
18:29SegFaultAXThat's the easiest way?
18:29emezeske,(let [x [1 2 4 5]] (concat (take 2 x) [3] (drop 2 x)))
18:29clojurebot(1 2 3 4 5)
18:30emezeskeI make no claims about it being the easiest way.
18:30hughfdjacksonthis is a .. language design question more than anything
18:30hughfdjacksonit strikes me as risky that dividing by 0 throws an exception
18:30hughfdjacksonsince you may derive the from user input, and therefore have to always put extra gaurds in place
18:31hughfdjackson:p A) do people concur, B) why does clojure make the exception choice?
18:31emezeskehughfdjackson: Definitely do not concur.
18:31emezeskehughfdjackson: It would be risky *not* to throw an exception when dividing by zero
18:32emezeskehughfdjackson: Much better to find out about a problem in the input than to silently produce corrupt results
18:32xeqia) no. b) host environment made the choice
18:32hughfdjackson:D fair enough
18:33emezeskehughfdjackson: If your program takes user input, you have to validate it, plain and simple
18:33arrdememezeske beat me to it
18:33emezeske:P
18:33hughfdjacksoni could be wrong in imagining that it could be more handily solved by an 'infinity' value for which *, +, -, / all return the value supplied
18:34hughfdjackson:D but if it doesn't strike others as strange, maybe i'm the strange one on this
18:34emezeskex/0 != infinity
18:34clojurebotis too infinity +1!
18:34emezeskex/0 = NaN if anything
18:34arrdemyeah...
18:34emezeskeAnything divided by zero is not defined, it is definitely not infinity.
18:34gfredericks&(/ 7.3 0)
18:34lazybot⇒ Infinity
18:34emezeskegfredericks: Why!!!
18:34arrdememezeske: because floating point
18:35emezeske&(/ 7.3 0.0)
18:35lazybot⇒ Infinity
18:35arrdem&(/ 7 0)
18:35lazybotjava.lang.ArithmeticException: Divide by zero
18:35arrdemsee? it's just a Floating Point POS
18:35gfredericksrationals ftw
18:35emezeske,(/ 7.3F 0.0F)
18:35clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 7.3F>
18:35hughfdjackson:p well, that underminds some of my basic assumptions
18:35emezeskegfredericks: But.. but!
18:36arrdemhughfdjackson: 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:36gfredericksemezeske: no exceptions
18:36emezeskegfredericks: Rationals, you say. I'm sure there's a reason for it, but that answer is plain wrong
18:36gfredericksemezeske: cuz of perf?
18:36emezeskegfredericks: That's usually the answer
18:37hughfdjacksonhehe, turns out haskell returns infinity for 1/0
18:37hughfdjacksonthere's a turn up for the books
18:37gfrederickswell you're the one who said i was wrong
18:37emezeskegfredericks: No, I didn't mean *you* were wrong
18:37WuHoUnitedDoes anybody know how RT.loadResourceScript behave if it is called from different threads in the same application?
18:37emezeskegfredericks: I meant that the answer returned by / was wrong
18:37gfredericksooh
18:37emezeskelol :)
18:38gfredericksemezeske: I was recommending using rationals instead of floating point
18:38WuHoUnitedie: is it as if each of the threads loaded the script independently?
18:38emezeskegfredericks: Ooooh, gotcha!
18:40tomojI can't seem to find any reasons for the ieee float spec to include infinity
18:40amalloyemezeske: (/ 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:40emezesketomoj: Infinity is handy for certain algorithms
18:41gfredericks(inc amalloy)
18:41lazybot⇒ 29
18:41emezesketomoj: Like implementing max(), you can set the current max to negative infinity and then compare successive values to that
18:41arrdem(inc amallot)
18:41lazybot⇒ 1
18:41arrdem(inc amalloy)
18:41lazybot⇒ 30
18:41arrdem(dec amallot) ; NO FREE KARMA HERE
18:41lazybot⇒ 0
18:42gfredericksamallot: yeah, earn it the hard way like the rest of us
18:42emezeskeamalloy: 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:42arrdemamallot: damnit man...
18:42emezeskeamallot: Or, rather believe in any exact value
18:42amalloti hereby claim all future karma proceeds on this account
18:42gfredericksemezeske: I believe in zero no matter what those biased biologists say
18:42emezeskegfredericks: lol
18:42arrdem(inc amallot) ; for making my day
18:42lazybot⇒ 1
18:43gfredericks(inc amallot-of-fun)
18:43lazybot⇒ 1
18:43emezeske(inc amallard)
18:43lazybot⇒ 1
18:43amalloywhat have i done!
18:43arrdemgfredericks: what you did there... I see it.
18:43emezeskeYou've unleashed the floodgates of useless karma
18:44gfredericksI was about to say something about not knowing how the name "amalloy" is really pronounced before remembering it wasn't a name
18:55yankovis there a built-in function to take a sublist from the list. say I need only elements from 10 to 17.
18:55yankovlike ruby's array[10..17]
18:55WuHoUnitedsubvec would work for vectors
18:55WuHoUnitedmight work for seqs also
18:55gfredericksit oughtn't
18:55arrdem,(drop 10 (take 17 (range 100))
18:55clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
18:55Raynes&(take 7 (drop 10 (range 20))
18:55lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
18:55Raynes&(take 7 (drop 10 (range 20)))
18:55lazybot⇒ (10 11 12 13 14 15 16)
18:55arrdem,(drop 10 (take 17 (range 100)))
18:55clojurebot(10 11 12 13 14 ...)
18:56Raynestake 17?
18:56Raynes:p
18:56arrdemRaynes: I derped
18:56arrdemIT GETS THE SAME PLACE
18:56RaynesSo did I.
18:56RaynesAnyways, he sees the point, I'm sure.
18:56Raynes<3
18:58yankovthanks guys
18:58arrdemno problem
19:00arrdem,(println "foo")
19:00clojurebotfoo
19:00arrdem,(println "/nick silly-bot")
19:00clojurebot/nick silly-bot
19:00arrdemdang.
19:01gfredericksthat bot is so clever
19:02ohokthanks bot. thot.
19:03gfredericks(inc ohok)
19:03lazybot⇒ 1
19:04antifuchs,(println (format "%cACTION%c slaps around antifuchs with a large trout" (char 1) (char 1))
19:04clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
19:04antifuchsawww
19:05arrdemyou dropped an rparen
19:05antifuchs(forgive me, but I have to try again)
19:05antifuchs,(println (format "%cACTION%c slaps around antifuchs with a large trout" (char 1) (char 1)))
19:05antifuchsthis wasn't very effective ):
19:06antifuchsmust have forgotten my CTCP syntax. oh well (:
19:11metellus,(println (str (char 1) "ACTION" (char 1) "attempts an action"))
19:17tomoj&(#(vector %1.999999999999999 %1.9999999999999999) 3 4)
19:17lazybot⇒ [3 4]
19:18nbeloglazovtomoj: how does it work?
19:19tomoj&(= 1.9999999999999999 2.0)
19:19lazybot⇒ true
19:19nbeloglazov&(1.999999999999999 1.0)
19:19lazybotjava.lang.ClassCastException: java.lang.Double cannot be cast to clojure.lang.IFn
19:20amalloymore like ##(read-string "1.999999999999999"), i think
19:20lazybot⇒ 1.999999999999999
19:20amalloyhm. guessed that would return 2.0
19:20tomoj&(read-string "1.9999999999999999")
19:20lazybot⇒ 2.0
19:20tomojI see
19:20tomojthe weird thing is really that %args can be floats
19:22tomoja vec's rseq isn't chunked :(
19:23amalloytomoj: it's parsed with read, then cast to Number, then intValue is called
19:37yankovis this a stupid way to _append_ to a list? (flatten (list '(1 2 3 4) 5))
19:38arrdemyankov: ... yes. you should (conj) if that's what you want
19:38xeqi&(conj '(1 2 3 4) 5)
19:38lazybot⇒ (5 1 2 3 4)
19:38arrdemherum
19:38arrdem(doc append)
19:38amalloy&(doc concat)
19:38lazybot⇒ "([] [x] [x y] [x y & zs]); Returns a lazy seq representing the concatenation of the elements in the supplied colls."
19:38clojurebotNo entiendo
19:38yankovyes, but that will prepend
19:38xeqi&(concat '(1 2 3 4) '(5))
19:39lazybot⇒ (1 2 3 4 5)
19:39yankovog
19:39yankovnice
19:39amalloybut, in general, don't append to lists
19:39yankovbetter use vectors for that?
19:39xeqi(conj [1 2 3 4] 5)
19:39xeqi&(conj [1 2 3 4] 5)
19:39lazybot⇒ [1 2 3 4 5]
19:39Frozenlo`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:40arrdemxeqi: thanks I knew I wasn't totally off-base
19:40hughfdjacksonFrozenlo`: re-query the DOM
19:40hughfdjacksonwhoops
19:40hughfdjacksonthought we were in ##javascript
19:41arrdemhughfdjackson: (eq? #javascript ##javacript)
19:46Frozenlo`Is there a cljs equivalent to re-querying the DOM?
19:48xeqiwonder if goog.dom/getParentElement could work
19:55FrozenlockTrying now... getting a bunch of errors
19:55FrozenlockMust be a requiring issue.
20:16Frozenlock(goog.dom/getElement my-var) returns the same #<[object HTMLDivElement]> as before :(
20:17FrozenlockAnd goog.dom/getParentElement is not a valid method for the object.
20:17xeqiyeah, the api says it returns the dom node if passed one
20:17Frozenlocko_O
20:18xeqitry (.parent dom-node) ?
20:18xeqioh (.-parent dom-node)
20:18xeqiblah
20:18xeqi(.-parentNode dom-node)
20:19FrozenlockOh wait I don't get an error on this one
20:19FrozenlockIt works!
20:20xeqi&"hurray!"
20:20lazybot⇒ "hurray!"
20:20FrozenlockI owe you a drink :)
20:26FrozenlockI wonder if this should be in domina.
20:33mpanIs there an equivalent to use/require for static Java methods?
20:34mpane.g. I want to write parseInt and have it be Integer/parseInt
20:34mpanor am I just supposed to (def parseInt Integer/parseInt)
20:35mpan(whoops, just tried that and it doesn't work like I think)
20:36gfredericks&(doc memfn)
20:36lazybot⇒ "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:36gfredericksoh wait static
20:37gfredericksno I don't think there's any sugar for static methods
20:37mpancurrently I've got... (def parseInt #(Integer/parseInt %))
20:37mpanit feels a bit strange to be honest
20:37mpanall right, thanks
20:37gfredericks I think most people just keep the Integer/parseInt inline
20:40arrdembrb nesting in tmux
20:42mpan&"test"
20:42lazybot⇒ "test"
20:42mpanyay
20:42mpan&(println "test")
20:42lazybot⇒ test nil
21:24ziltiWith Clojure.zip what's the best way to move directly to a newly appended child?
21:27tomoj(comp rightmost down)?
21:28tomojwell (comp rightmost down #(append-child % foo))
21:29ziltihmm okay
21:30tomojthe only other way I can think of is (comp right #(insert-right % foo) rightmost down)
21:30ziltiI thought there's maybe a special function for that
21:31ziltiBut looking at the docs, it says the child is always added as the rightmost, so (-> zip (append-child child) down rightmost) is it
21:32bbloomi always forget clojure.zip exists. super cool little lib
21:51tomojis it possible to have a persistent/transient pair of deftypes in the same file?
21:51tomojwhere asTransient and persistent use the other constructors
21:53tomojyou can forward-declare a function that calls the latter constructor :/
21:58bbloomtomoj: you mean with the same name?
21:58tomojno, different names
21:58S11001001n00b6502: the answer to your question is "definitely not"
21:58bbloomi don't understand. why wouldn't that be possible?
21:58bbloomyou could use extend-protocol
21:59tomojbecause the constructor for the latter deftype will not be defined yet when the former is evaluated
21:59n00b6502defintely not - no other lisp allows a collection to be "called" for acess ?
21:59bbloomrather than the forward declaration
21:59n00b6502i need to make my own lisp dialect with every feature i like cherrypicked hehe
21:59tomojwell, I{Transient,Editable}Collection aren't protocols on the jvm
21:59S11001001n00b6502: I think you said language, but even among lisps the feature is not unique (Arc also does it)
21:59tomojthat would work on cljs though?
21:59bbloomah yes, i forgot. *shrug* go with the forward declaration. that's what they are there for!
22:00S11001001s,said,implied,
22:00n00b6502oh sorry "not unique" not "not elseqhere"... i forgot how i worded it
22:00tomojjust sort of wish I could forward-declare a constructor
22:00tomojthough I have no good reason to want that
22:00S11001001n00b6502: "is this unique to clojure??"
22:00n00b6502ok not unique .. great.
22:01n00b6502over on #lisp they think its dysfunctional
22:01n00b6502misfeature
22:01S11001001among JVM-intended languages, Scala also has sequences, sets, and maps as function subtypes
22:02amalloytomoj: https://github.com/flatland/ordered/blob/develop/src/ordered/map.clj is basically the best you can do
22:02bbloomn00b6502: why do they think it is a misfeature?
22:03n00b6502i 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:03bbloomn00b6502: learn to love the -> macro
22:04n00b6502i got more responses of "thats a dumb idea" on #lisp for various reasons i couldn't be bothered to remember
22:04S11001001n00b6502: keep at it and you'll switch to (member object)
22:04n00b6502bbloom: 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:04bbloom,(doc ->)
22:04clojurebot"([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:04bbloom,(doc ->>)
22:04clojurebot"([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:05n00b6502yeah. i wrote that and called it "pipe". they told me "ner ner ner thats not idiomatic lisp ner ner ner"
22:05bbloom*shrug* it's idiomatic clojure.
22:05mpanthe way most java libraries are set up, you'd want that for convenience for interop if nothing else?
22:05n00b6502cool :)
22:06bbloomconsider deeply nested associative structures:
22:06bbloom,(-> {:x {:y {:z [1 2 3]}}} :x :y :z)
22:06clojurebot[1 2 3]
22:06n00b6502saves th last line of your function being ))))))))))))))))))))))))
22:06bbloomsuper useful.
22:06mpanalso feels nicer to read them in the order you think about them
22:07gfredericksinteresting constrained form of clojure: every function must end in exactly 24 close-parens
22:07gfredericksI guess that's pretty trivial with a macro
22:07mpanyou could cheat by defining a pass-through macro, and that would be the only real constrained writing?
22:08gfredericksjinx
22:08mpan=p
22:08mpanidk what to think of this, it just feels so different from other languages I've used
22:08amalloybbloom: that's a terrible example of -> -- it's exactly what you should use get-in for
22:08bbloomthat's a good thing!
22:08bbloomamalloy: d'oh, you're right. i just needed an example
22:09mpanOH!
22:09n00b6502(defmacro pipe (&rest args) (reduce (lambda (a b) (append b (list a))) args))
22:09n00b6502
22:09mpanthat's actually really useful for what I was going to do
22:09casionfinally have a basic DSP setup working in clojure
22:09mpanget-in would save me a lot of the stuff I was going to type
22:10casionjavax.sound.sampled is just retardedly complicated :|
22:10bbloom,(-> [:a :b :c] second name string/upper-case)
22:10clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: string, compiling:(NO_SOURCE_PATH:0)>
22:11bbloom,(-> [:a :b :c] second name clojure.string/upper-case)
22:11clojurebot"B"
22:11bbloomamalloy: n00b6502: there you go
22:11bblooma decent example of -> :-)
22:12tomojcasion: do you have it working?
22:12casiontomoj: yes
22:13casionright now I can get a seq of floats/ints/doubles as appropriate from any audio file supported
22:13casionand from there most dsp is trivial
22:14n00b6502ah -> and ->> 'thread' the results as first or last argument
22:14mpanI keep getting confused which is which
22:14n00b6502->> is my 'pipe'
22:16n00b6502so that kind of reads like "[:a,:b,:c].second().name().upper-case()"
22:16tomojcasion: cool
22:16tomojthe seq isn't lazy, is it?
22:17casiontomoj: not yet… I'm getting heap overflows with lazy-seqs atm
22:17casionI think it's because of how I'm sizing the buffer for the read
22:17tomojI have some code sitting around that takes a filename and a function and calls the function with each frame
22:17tomojlooking at it now, it seems like that should be a reducer
22:18mpan:/ the doc examples showcase where -> and ->> are interchangeable
22:18casionconverting the frame->sample conversion to a reducer is my next step
22:19casionright now it's just a list comprehension that grabs (/ frameLength channels) and bit twiddles that into a proper value
22:21bbloommpan: which docs?
22:22bbloomhttp://clojuredocs.org/clojure_core/clojure.core/-%3E%3E
22:22bbloomand http://clojuredocs.org/clojure_core/clojure.core/-%3E
22:22bbloomhave good examples
22:22mpanam I mistaken or are the first example on those two pages interchangeable?
22:23bbloommpan: you're mistaken
22:23bbloomthe examples of r->> thread through the LAST argument
22:23bbloom,(doc map)
22:23clojurebot"([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:23bbloomnotice that coll is after f
22:23bbloom,(macroexpand '(-> x (f y)))
22:23clojurebot(f x y)
22:24bbloom,(macroexpand '(->> x (f y)))
22:24clojurebot(f y x)
22:24mpanoh!
22:24mpanthank you
22:26tomojcasion: 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:26casionpartition by framelength, then partition by channels
22:26n00b6502(defn lerp [lo hi f] (->> (- hi lo)(* f)(+ lo))) (lerp 5 10 0.5)
22:26n00b6502,(defn lerp [lo hi f] (->> (- hi lo)(* f)(+ lo))) (lerp 5 10 0.5)
22:26clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
22:27bbloomn00b6502: can't def w/ clojurebot
22:27casionor you can just pull out the channels I guess
22:27bbloom((fn [lo hi f] (->> (- hi lo)(* f)(+ lo))) 5 10 0.5)
22:27bbloom,((fn [lo hi f] (->> (- hi lo)(* f)(+ lo))) 5 10 0.5)
22:27clojurebot7.5
22:27casionI've been partitioning by framelength, converting to the appropriate type, then partitioning by channels
22:28casionI suspect there's a better way. Most of today has been fighting the awful java docs on this stuff
22:30casionright now, partition doesn't exactly work well with larger files (runs out of heap space, and it's super slow anyway)
22:36n00b6502is a clojure literal map a mutable colleciton
22:36gfredericksno
22:36n00b6502so its more like an immutable adhoc object perhaps
22:37gfredericksI'm not sure what you meant by changing "collection" to "object"
22:37gfredericksit's just an immutable map datastructure
22:38n00b6502for multiple return values do you just use a vector literal
22:38gfrederickssure
22:38gfredericksor a map if you want to give them names
22:39n00b6502whats the best way to bind elements of a vector to symbols .. (i'm thinking of multiple-value-bind in CL)
22:39bbloomdestructuring
22:39gfredericks+1
22:40bbloom,(let [[x y & zs] (range 10)] {:foo x :bar y :baz zs})
22:40clojurebot{:foo 0, :bar 1, :baz (2 3 4 5 6 ...)}
22:41bbloomalso works with maps & other fun stuff. see the let for on here: http://clojure.org/special_forms
23:25FrozenlockIf nothing refers to an atom anymore, is it discarded?
23:29bbloomFrozenlock: why wouldn't it?
23:31Sgeobbloom, because in some languages, they... oh, wait, "atom" in Erlang means something else
23:32Frozenlockbbloom: I just don't suppose things anymore.
23:33bbloomheh. yeah. erlang atom is similar to a symbol or keyword. but JVM clojure *does* garbage collect those by leveraging weak references
23:33FrozenlockAnd cljs?
23:33bbloomcljs (currently) encodes keywords and symbols into strings
23:33bbloomwhich the underlying javascript engine will certainly garbage collection
23:34bbloomhowever, javascript doesn't provide weakreferences
23:34bbloomsadly....
23:34mpanspeaking of which, what is the purpose of keywords that symbols don't already fulfill?
23:35bbloomkeywords are like symbols that always refer to themselves
23:36bbloom:foo is always :foo. but 'foo could refer to a local, or a function, or something else entirely
23:38bbloom,`(class :foo)
23:38bbloomhmm...
23:38bbloom,(identity `(class :foo))
23:38bbloomwhere's clojure bot when you need him
23:38clojurebot(clojure.core/class :foo)
23:38clojurebot(clojure.core/class :foo)
23:38bbloomah there we go
23:38bbloomanyway
23:38bbloomnotice how "class", a symbol, was resolved
23:38bbloombut :foo remained unchanged
23:39bbloomthere is no lookup process for a keyword. if you have the keyword, you have all that it represents
23:39bbloomif 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:42bbloommake sense?
23:42mpaner, but like, what's to stop people from using symbol literals?
23:42mpanlike, explicitly quoted symbol literals?
23:42bbloomnothing
23:42bbloomand that's what the common lisp folks do, right?
23:42mpandunno
23:42bbloom(i'm not a common lisper, i dunno for sure)
23:43bbloomof course you can quote symbols:
23:43bbloom,`('class :foo)
23:43clojurebot((quote clojure.core/class) :foo)
23:43mpanoh, wait
23:43bbloombut it still get resolved!
23:43mpanbut then it tries to figure out which "class" you mean?
23:43bbloomso you need to do some trickery
23:43bbloom,`(~'class :foo)
23:43clojurebot(class :foo)
23:44bbloomand, indeed, that's sometimes (although rarely) useful
23:44mpanyou're allowed to use that outside macro defs?
23:44mpanoh wow
23:44bbloomhaha sure!
23:44bbloom:-)
23:44mpanall right thanks
23:45mpanI guess I'm trying to stay away from the meta bits until I need them
23:45bbloomyeah, i've been contributing to the clojurescript compiler
23:45bbloomwhere it's not so much meta, as it is … um… something less than meta ;-)