Re: ANN: Gloss, a byte-format DSL
The later. The string in my example is \n terminated, so it should read past the \0, and then the outer list should terminate on the last \0. My point is that I need to parse recursive structures, which of course contain the same terminator as the outer one. What if I wanted to parse null terminated lists of null terminated lists of ... of bytes? Like so: abc\0def\0\0 def\0ghi\0jkl\0\0 \0 Your implementation would just make the outer list read to the first \0 and call it a day. What I need is that it only checks for a terminator on the outer list after reading a full inner list, and keep doing that, until it finds a terminator right after the inner list. Pepijn On Jan 6, 7:17 am, Zach Tellman wrote: > I'm confused by what you expect the decoded value for that string to > look like. Is it: > > [["blabla" "hi hi" "jg"] [" g"]] > > or > > [["blabla" "hi hi" "jg\0 g"]] > > Zach > > On Jan 5, 3:36 am, "pepijn (aka fliebel)" > wrote: > > > > > > > > > Nothing :( > > > $ lein repl > > "REPL started; server listening on localhost:32399." > > user=> (use '[gloss core io]) > > nil > > user=> (defcodec t (repeated (string :utf-8 :delimiters > > ["\n"]) :delimiters ["\0"])) > > #'user/t > > user=> (decode t (.getBytes "blabla\nhihi\njg\0 g\n\0")) > > java.lang.Exception: Cannot evenly divide bytes into sequence of > > frames. (NO_SOURCE_FILE:0) > > > What I think is happening is that repeated reads up to the first \0 > > and then tries to fit the subframes inside of that. What I think it > > *should* do is, check the next byte for a delimiter, if not, read a > > subframe, rinse and repeat. > > > Pepijn > > > On Jan 2, 7:38 pm, Zach Tellman wrote: > > > > There was a bug in repeated, which is fixed now. Pull the latest from > > > github or clojars and let me know how it goes. > > > > Zach > > > > On Jan 2, 3:29 am, "pepijn (aka fliebel)" > > > wrote: > > > > > Okay, clicked send to early. The header also contains 0-bytes, so the > > > > repeated stops 'mid-sentence' and tries to balance things. Is there > > > > any wayGlosscan handle nested structures like this? > > > > > On Jan 2, 12:20 pm, "pepijn (aka fliebel)" > > > > wrote: > > > > > > Hi, > > > > > > Thanks for helping out. After using codecs rather than frames, I get > > > > > even weirder errors. > > > > > > My code now gives me: java.lang.Exception: Cannot evenly divide bytes > > > > > into sequence of frames. > > > > > > Hard coding the header followed by a terminating :byte works as it > > > > > should: > > > > > > (decode (compile-frame [tag tstring (header tag (memoize #(compile- > > > > > frame [(name %) tstring (get-tag %)])) (comp symbol first)) :byte]) > > > > > data) > > > > > [:compound "hello world" ["string" "name" "Bananrama"] 0] > > > > > > So the problem seems to be with the repeated. Investigating that, I > > > > > copied an example from the introduction page, and this is the result: > > > > > (defcodec t (repeated (string :utf-8 :delimiters ["\n"]) :delimiters > > > > > ["\0"])) > > > > > (encode t ["foo" "bar" "baz"]) > > > > > java.lang.IllegalArgumentException: Don't know how to create ISeq > > > > > from: java.nio.HeapByteBuffer > > > > > ((# > > > > > #) > > > > > (# > > > > > #) > > > > > > But on the other hand: > > > > > (decode t (.getBytes "blabla\nhihi\ng\n\0")) > > > > > ["blabla" "hihi" "g"] > > > > > > This gives me the same error as my code, but since the header in my > > > > > code seems correct, I don't see why it has leftover bytes. > > > > > (decode t (.getBytes "blabla\nhihi\ng\0")) > > > > > java.lang.Exception: Cannot evenly divide bytes into sequence of > > > > > frames. > > > > > > By the way, is there an easy way to get something readable out of > > > > > encode? Like Unix hexdump, or even just a seq of integers. Debugging > > > > > is a weak point inGlossso far, if you ask me. > > > > > > Thanks! > > > > > > Pepijn de Vos > > > > > > On Jan 1, 10:47 pm, Zach Tellman wrote: > > > > > > > The header->body function in (header ...) must return a codec, so > > > > > > you > > > > > > need to call compile-frame on the vector you're generating. Since > > > > > > you > > > > > > don't want to call compile-frame every time you decode a frame, you > > > > > > can memoize the function. A version that does both can be found > > > > > > athttps://gist.github.com/762031. > > > > > > > I agree that the way the enumeration and types are blurred in your > > > > > > code is a little confusing. You could create a stronger distinction > > > > > > by calling your enumerated types :tag-byte, :tag-int32, etc, and > > > > > > then > > > > > > defining a map from those tags onto :byte, :int32, and so on. > > > > > > > Zach > > > > > > > On Jan 1, 1:01 pm, "pepijn (aka fliebel)" > > > > > > wrote: > > > > > > > > Hey, > > > > > > > > I am tryingGlossfor reading NBT [1] files. > > > > > > > > First thing I did like is that it seems to make things real easy. > > > > > > > First thing I did not like i
Re: which IDEs are you all using?
Hi, 2011/1/9 Alex Baranosky > Hi, > > I'm most used to using Intellij, since it is what I use everyday at work > programming in Java. So my first forays into Clojure have been using > LaClojure. Some things I like about using Intellij for Clojure development > are: > >- I can click on a piece of code and have Intellij take me to the file >where that code is defined, even if I didn't write it; this means I can >click right through into clojure.core and read the source. >- It also has a nice rainbow parens feature which I find helps with >visually parsing the Clojure code. >- And of course Intellij has a LOT of keyboard shortcuts to help with >manipulating the text. >- I also like to change the color scheme, I assume emacs allows you to >use a self-created color scheme? > > I've been considering switching to Emacs because it seems to be the de > facto standard for the community. Just for the record: saying "Emacs seeming to be the de facto standard for the community" does not sound right to me. Cheers, -- Laurent > Does emacs have the equivalent of these four features? If not, does it > have their equivalents? > > On another note, I'd also love to hear what features Emacs would give me > that LaClojure doesn't enable. > > All the Best, > Alex > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Gloss, a byte-format DSL
On Mon, Jan 10, 2011 at 4:52 AM, pepijn (aka fliebel) wrote: > The later. The string in my example is \n terminated, so it should > read past the \0, and then the outer list should terminate on the last > \0. > > My point is that I need to parse recursive structures, which of course > contain the same terminator as the outer one. > > What if I wanted to parse null terminated lists of null terminated > lists of ... of bytes? Like so: > > abc\0def\0\0 > def\0ghi\0jkl\0\0 > \0 > > Your implementation would just make the outer list read to the first > \0 and call it a day. What I need is that it only checks for a > terminator on the outer list after reading a full inner list, and keep > doing that, until it finds a terminator right after the inner list. That's not going to work unless all leaves are at the same depth and there are no empty lists at any depth. If the leaves are all at the same depth: (defn unflatten ([in-seq sentinel] (unflatten (seq in-seq) sentinel [[]] 0)) ([in-seq sentinel stack height] (if in-seq (let [[f & r] in-seq] (if (= f sentinel) (let [h (inc height) l1 (get stack h) l1 (if l1 l1 []) l2 (get stack height) s1 (assoc stack h (conj l1 l2)) s2 (assoc s1 height [])] (recur r sentinel s2 (inc height))) (let [l1 (get stack 0) s1 (assoc stack 0 (conj l1 f))] (recur r sentinel s1 0 (peek stack user=> (unflatten [1 2 0 3 4 0 0 5 6 0 7 8 0 0] 0) [[[1 2] [3 4]] [[5 6] [7 8]]] Otherwise you're going to need to have a start-of-list delimiter as well as an end-of-list delimiter: (defn unflatten ([in-seq start-del end-del] (unflatten (seq in-seq) start-del end-del (list []))) ([in-seq s e stack] (if in-seq (let [[f & r] in-seq] (condp = f e (let [[x y & z] stack] (if y (recur r s e (conj z (conj y x))) (throw (Error. s (recur r s e (conj stack [])) (let [[x & y] stack] (recur r s e (conj y (conj x f)) (if (> (count stack) 1) (throw (Error.)) (first stack) user=> (unflatten "(((ab)(cd))(ef)(g(hi)))" \( \)) \a \b] [\c \d]] [\e \f] [\g [\h \i -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Metadata on symbols differ with caret reader
Hi Meikel, On 10 Jan., 01:09, Meikel Brandmeyer wrote: > Because 'o expands to (quote o) and you actually hint this list. You might > try (meta ' ^:k o). Very interesting, this works! I did not know that syntax and none of my books or the reader section of clojure.org mentioned it. Thanks a lot, Marc -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
Nobody mentions Eclipse clojure plugin, I use this. Good enough with clojure's REPL. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Metadata on symbols differ with caret reader
Interesting. My downloaded version of clojure 1.2.0 acts exactly as you describe. However my basic lein project with only (defproject prj "1.0.0-SNAPSHOT" :dependencies [[org.clojure/clojure "1.2.0"]]]) acts differently. Well as I said, I can never sure about anything :) Cheers Tim On Jan 9, 11:40 pm, Meikel Brandmeyer wrote: > Hi, > > On 10 Jan., 04:17, Tim Robinson wrote: > > > How does this happen when :tag is not even in the expression? > > If you launch a brand new repl and run it what happens? > > What I posted in the previous email is exactly a fresh repl session > and what happens there with 1.2. And in fact, that it is what I would > expect. > > ^String is a short-hand notation for ^{:tag String}. There was a > change planned for using ^ with keywords, namely that ^:foo is short- > hand for ^{:foo true}. But I don't know whether this change made it > into 1.3. > > Sincerely > Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
vim tmux & slime. You can find slime for tmux here or here: - https://github.com/kikijump/tslime.vim - http://www.vim.org/scripts/script.php?script_id=3023 Tim Washington twash...@gmail.com 416.843.9060 On Mon, Jan 10, 2011 at 2:54 AM, jamesqiugm wrote: > Nobody mentions Eclipse clojure plugin, I use this. Good enough with > clojure's REPL. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Metadata on symbols differ with caret reader
Hi, On 10 Jan., 14:36, Tim Robinson wrote: > Interesting. Suspicious, I'd say. > My downloaded version of clojure 1.2.0 acts exactly as you describe. > > However my basic lein project with only > > (defproject prj "1.0.0-SNAPSHOT" > :dependencies [[org.clojure/clojure "1.2.0"]]]) > > acts differently. Sounds like some kind of bug with lein? > Well as I said, I can never sure about anything :) Indeed. :) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
Hi, so if we name now all the alternatives: VimClojure for Vim. :) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Metadata on symbols differ with caret reader
Hi, I can't verify that a REPL created by lein behaves differently. Did you perhaps update an old project.el without running lein deps? In addition to that: your defproject has too many ]'s Regards, Stefan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: ClojureQL 1.0.0 now released
You're very welcome - and thanks to everybody who's tried it out! Lau Tim Robinson wrote: > Thank you for making this. > It's a great idea and really enjoyable to use. > Tim > > On Jan 5, 7:14 am, LauJensen wrote: > > Hey everybody, > > > > Just a quick heads up that ClojureQL 1.0.0 is now released. All > > interfaces should be final and there are no known bugs. Works out of > > the box with PostgreSQL and MySQL but the compiler is a multimethod so > > you can implement your own backend if you need to work with other > > database backends. If you do so, please consider contributing it to > > ClojureQL :) > > > > All the info is found onhttp://www.clojureql.orgbut for those of you > > who haven't tried it out yet, I recommend watching this (dated) > > video:http://vimeo.com/16958466 > > > > Big thanks to everybody who has helped make this happen, > > Lau -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
On Jan 10, 2011, at 2:54 AM, jamesqiugm wrote: > Nobody mentions Eclipse clojure plugin, I use this. Good enough with > clojure's REPL. FWIW I've been using this (Eclipse/Counterclockwise) both for my own work and for teaching an undergraduate class last fall, and I think it is quite good. My one serious lingering complaint, which is leading me to explore other options again, is the way Eclipse does (or doesn't) handle dependencies and builds. Leiningen and/or Cake seem to make many things easy that are a pain in the Eclipse world. If I could combine these things in some reasonably smooth way then I'd be very happy. As it is I'm now playing with Cake/Textmate as a possible replacement. (Also FWIW I started with emacs, having used that for a long time in other contexts, but don't find that to be a good long-term approach for a variety of reasons that I won't belabor here.) -Lee -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: only 3 benchmarks game tasks still have no Clojure programs
I notice that the fastest Java version of pidigits uses a native library named "jpargmp". Is there documentation somewhere that spells out how and when you are allowed to use native libraries and still claim to be written in language X? Stu > Only 3 tasks on the computer language benchmarks game still have no > Clojure programs - > > > 1) meteor-contest > > http://shootout.alioth.debian.org/u32q/benchmark.php?test=meteor > > > 2) chameneos-redux > > http://shootout.alioth.debian.org/u32q/benchmark.php?test=chameneosredux > > > 3) pidigits > > http://shootout.alioth.debian.org/u32q/benchmark.php?test=pidigits > > > http://shootout.alioth.debian.org/help.php#stepbystep > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
Indeed, I use Eclipse + counterclockwise as well -- to the point of contributing to it of late. IMVHO, the Eclipse + counterclockwise combination is the one that has the most potential in the IDE space (for those of us that can't bear to work with emacs). Check out the v0.2.0 RC[1] that went out a little while ago that includes a vastly-improved network-capable REPL (based on the new nREPL project[2]). Now's the time to give it a roll and provide feedback on the users list[3] or in irc (you can bug me or Laurent [lpetit]). :-) - Chas [1] http://code.google.com/p/counterclockwise/wiki/ReleaseNotes#Version_0.2.0.RC1 [2] http://github.com/clojure/tools.nrepl [3] http://groups.google.com/group/clojuredev-users On Jan 10, 2011, at 2:54 AM, jamesqiugm wrote: > Nobody mentions Eclipse clojure plugin, I use this. Good enough with > clojure's REPL. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Multidimensional Float arrays
Hi, Can anybody explain to me how to create a multidimensional array of floats such as: [[1.0 1.0 2.0 2.0] [3.0 2.2 4.0 0.0]] Anything I try gives me errors. Bill -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Multidimensional Float arrays
2011/1/10 WoodHacker : > Hi, > > Can anybody explain to me how to create a multidimensional array of > floats such as: > > [[1.0 1.0 2.0 2.0] [3.0 2.2 4.0 0.0]] > > Anything I try gives me errors. user=> (doc make-array) - clojure.core/make-array ([type len] [type dim & more-dims]) Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE. nil user=> (make-array Double/TYPE 2 8) # user=> (count (aget *1 0)) 8 -- http://albert.rierol.net -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Is there anything like GroovyServlet for Clojure?
Is there anything like GroovyServlet ( http://groovy.codehaus.org/Groovlets ) for Clojure? I think if there is something like that, it will be easy and fun to test & practice Clojure with small web code snippets(Not for real world application). Thanks, KwonNam -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Is there anything like GroovyServlet for Clojure?
Hello, Try ring with ring-java-servlet : https://github.com/laurentpetit/ring-java-servlet or ring with lein-ring : https://github.com/weavejester/lein-ring or plain old ring + run-jetty and ring.middleware.reload : https://github.com/mmcgrana/ring HTH, -- Laurent 2011/1/10 KwonNam Son > Is there anything like GroovyServlet ( > http://groovy.codehaus.org/Groovlets ) for Clojure? > > I think if there is something like that, it will be easy and fun to test > & practice Clojure with small web code snippets(Not for real world > application). > > Thanks, > KwonNam > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN: lein-cdt 1.0.0 - a leiningen plugin for the Clojure Debugging Toolkit
Hi folks I'd like to announce the first stable release of lein-cdt, a leiningen plugin that makes running George Jahad's excellent Clojure Debugging Toolkit a little easier. George has been polishing CDT over the past couple weeks and we both hope that this plugin will help others start to use and provide feedback on this tool: https://github.com/travis/lein-cdt http://clojars.org/lein-cdt This release includes: lein cdt - a leiningen task to start a CDT REPL that will automatically connect to a running debug JVM lein cdt-emacs - a leiningen task that will download necessary binary and source dependencies to a central location and print instructions for setting up emacs integration with CDT Nota bene: * The 1.0.0 status of lein-cdt implies that lein-cdt's API is relatively stable - easy to do because it's not a lot of code. It does not imply anything with regards to CDT itself. * Some important limitations are noted on the GitHub page - please be sure to read through these before reporting issues. Comments, questions and contributions welcome! Travis -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: only 3 benchmarks game tasks still have no Clojure programs
On Jan 10, 6:27 am, Stuart Halloway wrote: > I notice that the fastest Java version of pidigits uses a native library > named "jpargmp". Is there documentation somewhere that spells out how and > when you are allowed to use native libraries and still claim to be written in > language X? If the standard language X implementation wraps the native library, are the programs you write in language X using the wrapped functionality of the native library written in language X? If the standard language implementation for language X wraps a native library, providing that functionality to all language X programs, why should language Y programs be prevented from using that same native library? "In addition to language specific multiprecision arithmetic, we will accept programs that use GMP." http://shootout.alioth.debian.org/u32/performance.php?test=pidigits#about -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
Last time I tried to use this, I found the plugin for some reason could not see the clojure source jar. It was a real bummer, since I had been hoping to find a nice IDE that would let me debug into clojure's internal classes as well, to get some insight into what was going on. On Jan 10, 6:37 am, Chas Emerick wrote: > Indeed, I use Eclipse + counterclockwise as well -- to the point of > contributing to it of late. IMVHO, the Eclipse + counterclockwise > combination is the one that has the most potential in the IDE space (for > those of us that can't bear to work with emacs). > > Check out the v0.2.0 RC[1] that went out a little while ago that includes a > vastly-improved network-capable REPL (based on the new nREPL project[2]). > Now's the time to give it a roll and provide feedback on the users list[3] or > in irc (you can bug me or Laurent [lpetit]). :-) > > - Chas > > [1]http://code.google.com/p/counterclockwise/wiki/ReleaseNotes#Version_0... > [2]http://github.com/clojure/tools.nrepl > [3]http://groups.google.com/group/clojuredev-users > > On Jan 10, 2011, at 2:54 AM, jamesqiugm wrote: > > > > > Nobody mentions Eclipse clojure plugin, I use this. Good enough with > > clojure's REPL. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Gloss, a byte-format DSL
Oh, right. My code does have a start and an end. I'm using header for the start. So the only way Gloss could do this is with a fn that combines header and repeated into one? On Jan 10, 12:29 pm, Ken Wesson wrote: > On Mon, Jan 10, 2011 at 4:52 AM, pepijn (aka fliebel) > > > > > > > > > > wrote: > > The later. The string in my example is \n terminated, so it should > > read past the \0, and then the outer list should terminate on the last > > \0. > > > My point is that I need to parse recursive structures, which of course > > contain the same terminator as the outer one. > > > What if I wanted to parse null terminated lists of null terminated > > lists of ... of bytes? Like so: > > > abc\0def\0\0 > > def\0ghi\0jkl\0\0 > > \0 > > > Your implementation would just make the outer list read to the first > > \0 and call it a day. What I need is that it only checks for a > > terminator on the outer list after reading a full inner list, and keep > > doing that, until it finds a terminator right after the inner list. > > That's not going to work unless all leaves are at the same depth and > there are no empty lists at any depth. If the leaves are all at the > same depth: > > (defn unflatten > ([in-seq sentinel] > (unflatten (seq in-seq) sentinel [[]] 0)) > ([in-seq sentinel stack height] > (if in-seq > (let [[f & r] in-seq] > (if (= f sentinel) > (let [h (inc height) > l1 (get stack h) > l1 (if l1 l1 []) > l2 (get stack height) > s1 (assoc stack h (conj l1 l2)) > s2 (assoc s1 height [])] > (recur r sentinel s2 (inc height))) > (let [l1 (get stack 0) > s1 (assoc stack 0 (conj l1 f))] > (recur r sentinel s1 0 > (peek stack > > user=> (unflatten [1 2 0 3 4 0 0 5 6 0 7 8 0 0] 0) > [[[1 2] [3 4]] > [[5 6] [7 8]]] > > Otherwise you're going to need to have a start-of-list delimiter as > well as an end-of-list delimiter: > > (defn unflatten > ([in-seq start-del end-del] > (unflatten (seq in-seq) start-del end-del (list []))) > ([in-seq s e stack] > (if in-seq > (let [[f & r] in-seq] > (condp = f > e (let [[x y & z] stack] > (if y > (recur r s e (conj z (conj y x))) > (throw (Error. > s (recur r s e (conj stack [])) > (let [[x & y] stack] > (recur r s e (conj y (conj x f)) > (if (> (count stack) 1) > (throw (Error.)) > (first stack) > > user=> (unflatten "(((ab)(cd))(ef)(g(hi)))" \( \)) > \a \b] [\c \d]] > [\e \f] > [\g [\h \i -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
I do exactly that occasionally -- debugging Java source is decidedly in the domain of Eclipse (which does such things very, very well), so ccw is likely not the impediment there. I'd encourage you to head over to the mailing list (http://groups.google.com/group/clojuredev-users); I'm sure we could get you on your way without much trouble. - Chas On Jan 10, 2011, at 2:15 PM, Paul Mooser wrote: > Last time I tried to use this, I found the plugin for some reason > could not see the clojure source jar. It was a real bummer, since I > had been hoping to find a nice IDE that would let me debug into > clojure's internal classes as well, to get some insight into what was > going on. > > On Jan 10, 6:37 am, Chas Emerick wrote: >> Indeed, I use Eclipse + counterclockwise as well -- to the point of >> contributing to it of late. IMVHO, the Eclipse + counterclockwise >> combination is the one that has the most potential in the IDE space (for >> those of us that can't bear to work with emacs). >> >> Check out the v0.2.0 RC[1] that went out a little while ago that includes a >> vastly-improved network-capable REPL (based on the new nREPL project[2]). >> Now's the time to give it a roll and provide feedback on the users list[3] >> or in irc (you can bug me or Laurent [lpetit]). :-) >> >> - Chas >> >> [1]http://code.google.com/p/counterclockwise/wiki/ReleaseNotes#Version_0... >> [2]http://github.com/clojure/tools.nrepl >> [3]http://groups.google.com/group/clojuredev-users >> >> On Jan 10, 2011, at 2:54 AM, jamesqiugm wrote: >> >> >> >>> Nobody mentions Eclipse clojure plugin, I use this. Good enough with >>> clojure's REPL. >> > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
2011/1/10 Chas Emerick > I do exactly that occasionally -- debugging Java source is decidedly in the > domain of Eclipse (which does such things very, very well), so ccw is likely > not the impediment there. I'd encourage you to head over to the mailing > list (http://groups.google.com/group/clojuredev-users); I'm sure we could > get you on your way without much trouble. > Actually Paul did provide feedback on the ml, but at the time (2010/10/13) did not get much help (we were busy preparing / frightening ourselves with the upcoming talks at the clojure conj :-). Paul, hum, your email is still deep in my inbox, and maybe *you* have given up on an eventual answer for you ... but I haven't given up on working on this ... > > - Chas > > On Jan 10, 2011, at 2:15 PM, Paul Mooser wrote: > > > Last time I tried to use this, I found the plugin for some reason > > could not see the clojure source jar. It was a real bummer, since I > > had been hoping to find a nice IDE that would let me debug into > > clojure's internal classes as well, to get some insight into what was > > going on. > > > > On Jan 10, 6:37 am, Chas Emerick wrote: > >> Indeed, I use Eclipse + counterclockwise as well -- to the point of > contributing to it of late. IMVHO, the Eclipse + counterclockwise > combination is the one that has the most potential in the IDE space (for > those of us that can't bear to work with emacs). > >> > >> Check out the v0.2.0 RC[1] that went out a little while ago that > includes a vastly-improved network-capable REPL (based on the new nREPL > project[2]). Now's the time to give it a roll and provide feedback on the > users list[3] or in irc (you can bug me or Laurent [lpetit]). :-) > >> > >> - Chas > >> > >> [1] > http://code.google.com/p/counterclockwise/wiki/ReleaseNotes#Version_0... > >> [2]http://github.com/clojure/tools.nrepl > >> [3]http://groups.google.com/group/clojuredev-users > >> > >> On Jan 10, 2011, at 2:54 AM, jamesqiugm wrote: > >> > >> > >> > >>> Nobody mentions Eclipse clojure plugin, I use this. Good enough with > >>> clojure's REPL. > >> > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Clojure" group. > > To post to this group, send email to clojure@googlegroups.com > > Note that posts from new members are moderated - please be patient with > your first post. > > To unsubscribe from this group, send email to > > clojure+unsubscr...@googlegroups.com > > For more options, visit this group at > > http://groups.google.com/group/clojure?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: only 3 benchmarks game tasks still have no Clojure programs
On Jan 10, 6:27 am, Stuart Halloway wrote: > I notice that the fastest Java version of pidigits uses a native library > named "jpargmp". Is there documentation somewhere that spells out how and > when you are allowed to use native libraries and still claim to be written in > language X? As a practical matter, presumably the same wrapper could be used from Clojure? http://alioth.debian.org/scm/viewvc.php/shootout/bench/Include/java/GmpUtil.h?view=markup&revision=1.3&root=shootout http://alioth.debian.org/scm/viewvc.php/shootout/bench/Include/java/GmpUtil.c?view=markup&revision=1.3&root=shootout -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: only 3 benchmarks game tasks still have no Clojure programs
On Jan 10, 6:27 am, Stuart Halloway wrote: > I notice that the fastest Java version of pidigits uses a native library > named "jpargmp". Is there documentation somewhere that spells out how and > when you are allowed to use native libraries and still claim to be written in > language X? As a practical matter, presumably the same wrapper could be used from Clojure? http://alioth.debian.org/scm/viewvc.php/shootout/bench/Include/java/GmpUtil.h?view=markup&revision=1.3&root=shootout http://alioth.debian.org/scm/viewvc.php/shootout/bench/Include/java/GmpUtil.c?view=markup&revision=1.3&root=shootout -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Multidimensional Float arrays
The question was how to place data in the array, not create it. I've been doing that. How do you populate it?The doc shows: user=> (doc aset-float) - clojure.core/aset-float ([array idx val] [array idx idx2 & idxv]) If I try that I get: user=> (def wa (make-array Float/TYPE 4 4)) #'user/wa user=> wa # user=> (aset-float wa 0 0 & 1.0) java.lang.Exception: Unable to resolve symbol: & in this context (NO_SOURCE_FILE:5) user=> What am I missing? On Jan 10, 10:08 am, Albert Cardona wrote: > 2011/1/10 WoodHacker : > > > Hi, > > > Can anybody explain to me how to create a multidimensional array of > > floats such as: > > > [[1.0 1.0 2.0 2.0] [3.0 2.2 4.0 0.0]] > > > Anything I try gives me errors. > > user=> (doc make-array) > - > clojure.core/make-array > ([type len] [type dim & more-dims]) > Creates and returns an array of instances of the specified class of > the specified dimension(s). Note that a class object is required. > Class objects can be obtained by using their imported or > fully-qualified name. Class objects for the primitive types can be > obtained using, e.g., Integer/TYPE. > nil > user=> (make-array Double/TYPE 2 8) > # > user=> (count (aget *1 0)) > 8 > > --http://albert.rierol.net -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Multidimensional Float arrays
On Mon, Jan 10, 2011 at 4:40 PM, WoodHacker wrote: > The question was how to place data in the array, not create it. I've > been > doing that. How do you populate it? The doc shows: > > user=> (doc aset-float) > - > clojure.core/aset-float > ([array idx val] [array idx idx2 & idxv]) > > If I try that I get: > > user=> (def wa (make-array Float/TYPE 4 4)) > #'user/wa > user=> wa > # > user=> (aset-float wa 0 0 & 1.0) > java.lang.Exception: Unable to resolve symbol: & in this context > (NO_SOURCE_FILE:5) > user=> > > What am I missing? That that's not a literal ampersand expected by aset-float; just that it can take a variable number of indices. Try (aset-float wa 0 0 1.0). -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: only 3 benchmarks game tasks still have no Clojure programs
> As a practical matter, presumably the same wrapper could be used from > Clojure? Yes, I should think so. Thanks for the pointer to the rules, I missed it when reading the first time. Stu > http://alioth.debian.org/scm/viewvc.php/shootout/bench/Include/java/GmpUtil.h?view=markup&revision=1.3&root=shootout > > http://alioth.debian.org/scm/viewvc.php/shootout/bench/Include/java/GmpUtil.c?view=markup&revision=1.3&root=shootout -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Gloss, a byte-format DSL
I don't know if your example codec is as simple as your real problem, but here's a codec that will work for the string you provided: (repeated (string :utf-8 :delimiters ["\n" "\n\0"]) :delimiters ["\n\0"] :strip-delimiters? false) This terminates the whole sequence only on \n\0, but doesn't strip out the terminator so that it can be used by the last string as well. Right now this will not properly encode (the last token will be \n\n \0, so there will be a spurious empty string at the end of the list), but I plan on fixing that soon. Zach On Jan 10, 11:47 am, "pepijn (aka fliebel)" wrote: > Oh, right. My code does have a start and an end. I'm using header for > the start. So the only way Gloss could do this is with a fn that > combines header and repeated into one? > > On Jan 10, 12:29 pm, Ken Wesson wrote: > > > > > > > > > On Mon, Jan 10, 2011 at 4:52 AM, pepijn (aka fliebel) > > > wrote: > > > The later. The string in my example is \n terminated, so it should > > > read past the \0, and then the outer list should terminate on the last > > > \0. > > > > My point is that I need to parse recursive structures, which of course > > > contain the same terminator as the outer one. > > > > What if I wanted to parse null terminated lists of null terminated > > > lists of ... of bytes? Like so: > > > > abc\0def\0\0 > > > def\0ghi\0jkl\0\0 > > > \0 > > > > Your implementation would just make the outer list read to the first > > > \0 and call it a day. What I need is that it only checks for a > > > terminator on the outer list after reading a full inner list, and keep > > > doing that, until it finds a terminator right after the inner list. > > > That's not going to work unless all leaves are at the same depth and > > there are no empty lists at any depth. If the leaves are all at the > > same depth: > > > (defn unflatten > > ([in-seq sentinel] > > (unflatten (seq in-seq) sentinel [[]] 0)) > > ([in-seq sentinel stack height] > > (if in-seq > > (let [[f & r] in-seq] > > (if (= f sentinel) > > (let [h (inc height) > > l1 (get stack h) > > l1 (if l1 l1 []) > > l2 (get stack height) > > s1 (assoc stack h (conj l1 l2)) > > s2 (assoc s1 height [])] > > (recur r sentinel s2 (inc height))) > > (let [l1 (get stack 0) > > s1 (assoc stack 0 (conj l1 f))] > > (recur r sentinel s1 0 > > (peek stack > > > user=> (unflatten [1 2 0 3 4 0 0 5 6 0 7 8 0 0] 0) > > [[[1 2] [3 4]] > > [[5 6] [7 8]]] > > > Otherwise you're going to need to have a start-of-list delimiter as > > well as an end-of-list delimiter: > > > (defn unflatten > > ([in-seq start-del end-del] > > (unflatten (seq in-seq) start-del end-del (list []))) > > ([in-seq s e stack] > > (if in-seq > > (let [[f & r] in-seq] > > (condp = f > > e (let [[x y & z] stack] > > (if y > > (recur r s e (conj z (conj y x))) > > (throw (Error. > > s (recur r s e (conj stack [])) > > (let [[x & y] stack] > > (recur r s e (conj y (conj x f)) > > (if (> (count stack) 1) > > (throw (Error.)) > > (first stack) > > > user=> (unflatten "(((ab)(cd))(ef)(g(hi)))" \( \)) > > \a \b] [\c \d]] > > [\e \f] > > [\g [\h \i -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN: PoolradWheel, a "translation wheel" for 3 classic AD&D games
In the late 80's SSI Published a series of AD&D computer games starting with Pool of Radiance [1]. Some of these came with a decoder Wheel required to enter the game and at some points during game play. This program simlates the decoder wheel as required for entering the game. [1] http://en.wikipedia.org/wiki/Pool_of_Radiance In its present form, it doesn't implement glyph-at-a-time translation which is occasionally required during game play. You can find it here: https://github.com/bpsm/poolradwheel.clj I realize that there are probably about 7 people on the entire Internet that might be interested in what this software does. My primary purpose in writing it was as an example with enough Swing UI to be interesting. It's also a port of an earlier Java (1.4) version, allowing me to compare the the feel and expressiveness of the two languages for this particular task. For those wishing to form their own opinions on these questions, the Java version is here: https://github.com/bpsm/poolradwheel.java The part I'm least happy with is the Model/Controller, though I can't put my finger on why I don't like it. It just feels kind of kludgy. You can jump to the code here: https://github.com/bpsm/poolradwheel.clj/blob/master/src/main/clojure/poolradwheel.clj // Ben -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Notice: c.c.json parser and clojure.lang.Ratio
On Sat, Jan 8, 2011 at 23:38, Stuart Sierra wrote: > Ratios aren't valid JSON. If the recipient is Clojure, you don't need JSON > at all, just pr-str and read-string. Of course! Thanks, mike -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Odd behavior calling a fn "test" or "try"
I know I should not be naming my functions the same thing as ones in core but was surprised when I wrote the following https://github.com/thattommyhall/tth-SICP/blob/master/1-35.clj I have being doing the SICP stuff in clojure and accieently copied "try" as the fn name and it did not work, I noticed a colleague chose "test" and it did work, but test is in core too so I don't get the difference. Playing around on the repl I get user> (defn try [] ()) #'user/try user> (defn test [] ()) WARNING: test already refers to: #'clojure.core/test in namespace: user, being replaced by: #'user/test #'user/test user> (try 1) 1 user> (test 1) Throws "Wrong number of args (1) passed to: user$test" (as you would expect from my defn of test) user> (user/try 1) and user> (user/test 1) both throw the error. Why can test be shadowed and not try? Am I missing something? Tom -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Odd behavior calling a fn "test" or "try"
Hi Tom, "try" is a special form, and "test" is a function. Stu > I know I should not be naming my functions the same thing as ones in > core but was surprised when I wrote the following > https://github.com/thattommyhall/tth-SICP/blob/master/1-35.clj > I have being doing the SICP stuff in clojure and accieently copied > "try" as the fn name and it did not work, I noticed a colleague chose > "test" and it did work, but test is in core too so I don't get the > difference. > > Playing around on the repl I get > user> (defn try [] ()) > #'user/try > user> (defn test [] ()) > WARNING: test already refers to: #'clojure.core/test in namespace: > user, being replaced by: #'user/test > #'user/test > user> (try 1) > 1 > user> (test 1) > Throws "Wrong number of args (1) passed to: user$test" (as you would > expect from my defn of test) > > user> (user/try 1) > and > user> (user/test 1) > both > throw the error. > > > Why can test be shadowed and not try? Am I missing something? > > Tom > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
TriClojure
Hey all! Just wanted to announce that we have formed TriClojure, the Triangle Clojure Users Group. Tomorrow night, Jan 11th, we are co-hosting with TriFunc a talk from Clojure/core member Aaron Bedra title "Building Analytics with Incanter & Compojure." If you are in the area, please drop by the Relevance, Inc offices in Durham at 7pm. If you didn't get enough notice for his meetup, don't worry! Next week, you can drop by the Raleigh.rb to hear Stu Halloway talk about Clojure for Ruby programmers. And don't forget to join our group for future meetup announcements: http://www.meetup.com/TriClojure/ Thanks! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Odd behavior calling a fn "test" or "try"
On Tue, Jan 11, 2011 at 1:51 AM, Stuart Halloway wrote: > Hi Tom, > > "try" is a special form, and "test" is a function. > > Stu Cheers Stu, should have thought of that. Am I correct in thinking only 3 possibilitys for "try" in (try 1) special form, macro, function ? Are the special forms implemented as macros? Tom -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Odd behavior calling a fn "test" or "try"
To expand on this: user=> (defn try [] 5) #'user/try user=> (try) ; `try` alone is resolved to the special form nil user=> (#'try) ; obtaining the `try` var works just fine ; (vars currently delegate function calls to their values) 5 user=> (@#'try) ; explicitly deref'ing the fn from the `try` var and invoking it 5 So, you *can* shadow the binding of try (or any special form) within a given namespace, but you also need to resolve the var in question yourself (since regular symbols naming special forms are always given priority without the #' syntax [or use of the `var` macro]). None of that is required for regular functions, the resolution of which always takes into account the current namespace and its interned/referred vars. - Chas On Jan 10, 2011, at 8:51 PM, Stuart Halloway wrote: > Hi Tom, > > "try" is a special form, and "test" is a function. > > Stu > >> I know I should not be naming my functions the same thing as ones in >> core but was surprised when I wrote the following >> https://github.com/thattommyhall/tth-SICP/blob/master/1-35.clj >> I have being doing the SICP stuff in clojure and accieently copied >> "try" as the fn name and it did not work, I noticed a colleague chose >> "test" and it did work, but test is in core too so I don't get the >> difference. >> >> Playing around on the repl I get >> user> (defn try [] ()) >> #'user/try >> user> (defn test [] ()) >> WARNING: test already refers to: #'clojure.core/test in namespace: >> user, being replaced by: #'user/test >> #'user/test >> user> (try 1) >> 1 >> user> (test 1) >> Throws "Wrong number of args (1) passed to: user$test" (as you would >> expect from my defn of test) >> >> user> (user/try 1) >> and >> user> (user/test 1) >> both >> throw the error. >> >> >> Why can test be shadowed and not try? Am I missing something? >> >> Tom >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with your >> first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: My first clojure web app
On Wed, Jan 5, 2011 at 9:21 PM, Timothy Pratley wrote: > Neat, looks pretty nice. > I love invitations to nit pick! > database.clj > (defn complete-todo [id] > (dosync (ref-set *todo* (vec (remove #(= (get % :id) id) @*todo*) > 1) ref-set is unnecessary you could re-factor this to use alter. The > result is the same, but semantically set only applies when the new > value cannot be calculated from the old. > I thought the update function to alter had to be able to take sequence item so that you could use conj with alter but not cons. and by the same idea, because remove takes the sequence 2nd, it could be used w/ alter. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Question about sorted-sets
All, I'm hoping another, wiser set of eyes can help me to see what I'm doing wrong. I've defined a deftype below that stores a likelihood and a tree structure (nested vectors). The deftype overrides equals, etc, and implements Comparable so I can add SearchResults to a sorted-set and sort by likelihood. Equal SearchResults have the same likelihood and have quasi-isomorphic tree structures. (deftype SearchResult [lik tree] Object (toString [sr] (str lik ":" tree)) (equals [sr other] (and (= lik (.lik other)) (quasi-isomorphic? tree (.tree other (hashCode [sr] (int lik)) Comparable (compareTo [sr sr2] (cond (= sr sr2) 0 (> (.lik sr) (.lik sr2)) -1 :default 1))) I've defined some dummy data, which should illustrate the unusual behavior I'm seeing when I add SearchResults to a sorted-set. user> (def t1 [{:name 0} [{:name 1} [{:name 3}] [{:name 2}]] [{:name 4}]]) user> (def t2 [{:name 0} [{:name 1} [{:name 2}] [{:name 3}]] [{:name 4}]]) user> (def t3 [{:name 0} [{:name 1} [{:name 4}] [{:name 2}]] [{:name 3}]]) user> (def t4 [{:name 0} [{:name 1} [{:name 4}] [{:name 3}]] [{:name 2}]]) user> (quasi-isomorphic? t1 t2) true user> (quasi-isomorphic? t1 t3) false user> (quasi-isomorphic? t1 t4) false user> (def sr1 (SearchResult. 1 t1)) user> (def sr2 (SearchResult. 1 t2)) user> (def sr3 (SearchResult. 1 t3)) user> (def sr4 (SearchResult. 1 t4)) user> (= sr1 sr2) true user> (= sr1 sr3) false user> (= sr1 sr4) false user> (def ss (sorted-set)) true user> (count (conj ss sr1 sr3 sr4 sr2)) 4 user> (count (conj ss sr1 sr2 sr3 sr4)) 3 Of the four SearchResults, only sr1 and sr2 should be equal per the equals and compareTo functions defined in SearchResult. Based on that assumption, I thought that evaluating (conj ss sr1 sr3 sr4 sr2) would only return a set containing sr1, sr3, sr4, but it actually returns a set containing all four SearchResults. However, if I change the order of the SearchResults, as in (conj ss sr1 sr2 sr3 sr4), it works as expected, returning the set containing sr1, sr3, sr4. I've tried debugging the equals function to see what, exactly, is being compared, and it looks like in (conj ss sr1 sr3 sr4 sr2), sr2 is never actually compared to sr1, so sr2 gets added to the set. What am I missing? Any help would be greatly appreciated. -Travis p.s. Yes, the hashCode function isn't the best, but from what I could read, it does fulfill the requirements of the contract outlined in the javadocs. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sorted-sets
On Mon, Jan 10, 2011 at 10:23 PM, Travis Treseder wrote: > All, > I'm hoping another, wiser set of eyes can help me to see what I'm doing > wrong. > I've defined a deftype below that stores a likelihood and a tree structure > (nested vectors). The deftype overrides equals, etc, and implements > Comparable so I can add SearchResults to a sorted-set and sort by > likelihood. Equal SearchResults have the same likelihood and have > quasi-isomorphic tree structures. > (deftype SearchResult [lik tree] > Object > (toString [sr] > (str lik ":" tree)) > (equals [sr other] > (and (= lik (.lik other)) (quasi-isomorphic? tree (.tree other > (hashCode [sr] > (int lik)) > > Comparable > (compareTo [sr sr2] > (cond > (= sr sr2) 0 > (> (.lik sr) (.lik sr2)) -1 > :default 1))) > I've defined some dummy data, which should illustrate the unusual behavior > I'm seeing when I add SearchResults to a sorted-set. > user> (def t1 [{:name 0} [{:name 1} [{:name 3}] [{:name 2}]] [{:name 4}]]) > user> (def t2 [{:name 0} [{:name 1} [{:name 2}] [{:name 3}]] [{:name 4}]]) > user> (def t3 [{:name 0} [{:name 1} [{:name 4}] [{:name 2}]] [{:name 3}]]) > user> (def t4 [{:name 0} [{:name 1} [{:name 4}] [{:name 3}]] [{:name 2}]]) > user> (quasi-isomorphic? t1 t2) > true > user> (quasi-isomorphic? t1 t3) > false > user> (quasi-isomorphic? t1 t4) > false > user> (def sr1 (SearchResult. 1 t1)) > user> (def sr2 (SearchResult. 1 t2)) > user> (def sr3 (SearchResult. 1 t3)) > user> (def sr4 (SearchResult. 1 t4)) > user> (= sr1 sr2) > true > user> (= sr1 sr3) > false > user> (= sr1 sr4) > false > user> (def ss (sorted-set)) > true > user> (count (conj ss sr1 sr3 sr4 sr2)) > 4 > user> (count (conj ss sr1 sr2 sr3 sr4)) > 3 > Of the four SearchResults, only sr1 and sr2 should be equal per the equals > and compareTo functions defined in SearchResult. Based on that assumption, > I thought that evaluating (conj ss sr1 sr3 sr4 sr2) would only return a set > containing sr1, sr3, sr4, but it actually returns a set containing all four > SearchResults. However, if I change the order of the SearchResults, as > in (conj ss sr1 sr2 sr3 sr4), it works as expected, returning the set > containing sr1, sr3, sr4. > I've tried debugging the equals function to see what, exactly, is being > compared, and it looks like in (conj ss sr1 sr3 sr4 sr2), sr2 is never > actually compared to sr1, so sr2 gets added to the set. What am I missing? > Any help would be greatly appreciated. > -Travis > p.s. Yes, the hashCode function isn't the best, but from what I could read, > it does fulfill the requirements of the contract outlined in the javadocs. My guess is that it's your likelihood function that's actually broken. If sr1 and sr2 don't come out with the same likelihood, then in some cases of putting them into the sorted set they'll never end up compared with each other for equality. (Actually, I'd have thought in all cases. Perhaps the compareTo is separately broken and doesn't total-order by likelihood?) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Multidimensional Float arrays
Hi Bill , the following is one way of doing it .. (into-array (map float-array [[1.0 1.0 2.0 2.0] [3.0 2.2 4.0 0.0]])) Sunil. On Mon, Jan 10, 2011 at 8:32 PM, WoodHacker wrote: > Hi, > > Can anybody explain to me how to create a multidimensional array of > floats such as: > > [[1.0 1.0 2.0 2.0] [3.0 2.2 4.0 0.0]] > > Anything I try gives me errors. > > Bill > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Multidimensional Float arrays
since you are looking at multidimensional float arrays .. the following may be of interest to you ... http://clj-me.cgrand.net/2009/10/15/multidim-arrays/ On Tue, Jan 11, 2011 at 10:19 AM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > Hi Bill , > the following is one way of doing it .. > > (into-array (map float-array [[1.0 1.0 2.0 2.0] [3.0 2.2 4.0 0.0]])) > > Sunil. > > > On Mon, Jan 10, 2011 at 8:32 PM, WoodHacker wrote: > >> Hi, >> >> Can anybody explain to me how to create a multidimensional array of >> floats such as: >> >> [[1.0 1.0 2.0 2.0] [3.0 2.2 4.0 0.0]] >> >> Anything I try gives me errors. >> >> Bill >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en > > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: TriClojure
for those of us who cannot attend both .. a video would be awesome!! :) And the lame excuse for that it is just about 16k miles away .. On Tue, Jan 11, 2011 at 7:45 AM, Christopher Redinger wrote: > Hey all! > > Just wanted to announce that we have formed TriClojure, the Triangle > Clojure Users Group. Tomorrow night, Jan 11th, we are co-hosting with > TriFunc a talk from Clojure/core member Aaron Bedra title "Building > Analytics with Incanter & Compojure." If you are in the area, please > drop by the Relevance, Inc offices in Durham at 7pm. > > If you didn't get enough notice for his meetup, don't worry! Next > week, you can drop by the Raleigh.rb to hear Stu Halloway talk about > Clojure for Ruby programmers. > > And don't forget to join our group for future meetup announcements: > http://www.meetup.com/TriClojure/ > > Thanks! > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN: clojurejs -- a Clojure (subset) to Javascript translator
Hi all, I've just released a stable version of `clojurejs' -- an unimaginatively named Clojure library for translating a Clojure subset language to Javascript. clojurejs is something I've been working on for a few weeks as part of a larger web app in Clojure. The code's a bit crufty (reflects my incremental discovery of the inconsistencies in Javascript), but functional and I wanted put something out there for people to check out. I welcome bug reports and feedback. It's been useful for my specific needs, and I'd be happy if it's even marginally useful to others. I realize there are a number of other efforts to compile/translate Clojure (or other Lisp subset) to Javascript, but nothing quite fit my requirements, which prompted me to build clojurejs. Some useful aspects of clojurejs are: * Consistent scoping in let and loop/recur forms * Macros * Implicit return * loop/recur translates to Javascript for loops * Translates Clojure vectors, strings, keywords, symbols and maps to Javascript equivalents * dot form access to methods and properties * Adds a couple of Clojure incompatible special forms for Javascript specific behavior If this seems interesting I've posted a more detailed entry on my blog (http://cynojure.posterous.com/clojurejs-a-clojure-subset-to- javascript-tran). Oh, and the github link: http://github.com/kriyative/clojurejs Look forward to feedback. Cheers, -ram -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: lein-cdt 1.0.0 - a leiningen plugin for the Clojure Debugging Toolkit
Hi, Thanks Travis. This is something I have wanted for a long time .. Have you tried using it with cake? would it work with Cake? Sunil. On Mon, Jan 10, 2011 at 9:34 PM, Travis Vachon wrote: > Hi folks > > I'd like to announce the first stable release of lein-cdt, a leiningen > plugin that makes running George Jahad's excellent Clojure Debugging > Toolkit a little easier. George has been polishing CDT over the past > couple weeks and we both hope that this plugin will help others start > to use and provide feedback on this tool: > > https://github.com/travis/lein-cdt > http://clojars.org/lein-cdt > > This release includes: > > lein cdt - a leiningen task to start a CDT REPL that will > automatically connect to a running debug JVM > lein cdt-emacs - a leiningen task that will download necessary binary > and source dependencies to a central location and print instructions > for setting up emacs integration with CDT > > Nota bene: > * The 1.0.0 status of lein-cdt implies that lein-cdt's API is > relatively stable - easy to do because it's not a lot of code. It does > not imply anything with regards to CDT itself. > * Some important limitations are noted on the GitHub page - please > be sure to read through these before reporting issues. > > Comments, questions and contributions welcome! > > Travis > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: TriClojure
Awesome, thank you! Sadly, this week and next are unavailable for a couple of reasons, but please have another hack night and/or presentation soon! Gary On Jan 10, 2011, at 9:15 PM, Christopher Redinger wrote: > Hey all! > > Just wanted to announce that we have formed TriClojure, the Triangle > Clojure Users Group. Tomorrow night, Jan 11th, we are co-hosting with > TriFunc a talk from Clojure/core member Aaron Bedra title "Building > Analytics with Incanter & Compojure." If you are in the area, please > drop by the Relevance, Inc offices in Durham at 7pm. > > If you didn't get enough notice for his meetup, don't worry! Next > week, you can drop by the Raleigh.rb to hear Stu Halloway talk about > Clojure for Ruby programmers. > > And don't forget to join our group for future meetup announcements: > http://www.meetup.com/TriClojure/ > > Thanks! > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Emacs `align' function customization for Clojure
On 6 January 2011 04:29, Scott Jaderholm wrote: > On Tue, Jan 4, 2011 at 9:10 PM, Eric Schulte > wrote: > > I wonder if anyone else has written any similar Emacs alignment rules > > for Clojure which they would be interested in sharing? > > Alignment rules for let and defroutes are at the top of my most wanted > list. > > align-let.el [1] might be a reasonable starting point for someone wanting to create something for clojure. I have not tried it myself so I have no idea if it even works. [1] http://www.mail-archive.com/gnu-emacs-sources@gnu.org/msg01979/align-let.el -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en