Re: state monad transformer
On 16.02.2009, at 23:38, jim wrote: Here's a shot at implementing a monad transformer for the state monad. Any chance of getting it added to clojure.contrib.monads? If you are on the list of contributors (those who have signed a contributor agreement), yes, of course! Konrad. --~--~-~--~~~---~--~~ 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 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: How do I do this in clojure?
Hello, I wanted to try it too, so I grabbed Timothy's version, and did some improvements (I hope they are, feedback welcome ! :-) over it. Something I corrected is the removal of null or blank items, as in the first python version. I also got rid of the assoc by using update-in. And I felt that there was too much use of apply, but this may be subjective. Question: In order to use update-in (or assoc in the previous version), one has to transform the seqs returned by partition into a vector of vectors, thus the use of 'into. It still seems a little bit ugly to me. Is there a more concise (if not idiomatic) way to do that ? Here is the new version: (ns html.table) (defn make-table [column-count selected-row selected-column words] (let [remove-blank (partial remove #(or (nil? %) (- % .trim .isEmpty))) table (into [] (map (partial into []) (partition column-count (remove-blank words table-with-selected (update-in table [selected-row selected-column] (partial list :bold))] (cons :table (map (fn [r] (cons :tr (map (fn [i] (list :item i)) r))) table-with-selected (defn test-mt [] (make-table 3 1 0 [cat dog rabbit cat dog rabbit frog elephant gorilla])) Regards, -- Laurent 2009/2/17 Timothy Pratley timothyprat...@gmail.com I found this question interesting for two reasons: (1) A selected item has been specified which needs to be handled differently - at first glance suggests an iterative solution. (2) There is good support for html in clojure via libraries, so you should avoid string concatenation of tags. So here is my solution: http://groups.google.com/group/clojure/web/layout.clj Notably it bolds the selected item without any iteration, and returns a list representation of the html instead of a string. I'm not familiar with the html libraries to render this representation so forgive any inconsistencies there, but the output is: (:table (:tr (:item (:bold cat)) (:item dog) (:item )) (:tr (:item rabbit) (:item frog) (:item elephant))) Which will be validated by the rendering library, giving an additional security that it is correct. In order to deal with the 'selected item' I had to jump through some hoops to treat collections as vectors and use assoc on that. Is there perhaps a more elegant way? Overall though I hope it is a good example of how and why it is a good idea to avoid string catting and instead think of the problem in terms of creating a structure. Really you are building a tree based upon some inputs. I'd be interested in other ways the tree could be constructed. Regards, Tim. --~--~-~--~~~---~--~~ 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 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: terminology question re: binding
On Feb 17, 2009, at 0:17, Stuart Sierra wrote: As I understand it, every Var has a name, which is a symbol, but the name is an inherent property of the Var and cannot be changed. You Unless you create a var using with-local-vars, right? Konrad. --~--~-~--~~~---~--~~ 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 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: Clojure on CLR/DLR
I can see a minor problem with ClojureCLR, that is, j in clojure stands for JVM, right? So it's a bit messy. --~--~-~--~~~---~--~~ 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 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: Clojure on CLR/DLR
Clonure (n for dot *n*et), as in : Clonure, a dot net clone of Clojure (ok, sorry ;-) 2009/2/17 Lucio Fulci luciofulc...@gmail.com I can see a minor problem with ClojureCLR, that is, j in clojure stands for JVM, right? So it's a bit messy. --~--~-~--~~~---~--~~ 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 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: How do I do this in clojure?
On Tue, Feb 17, 2009 at 11:05 AM, Laurent PETIT laurent.pe...@gmail.com wrote: Hello, I wanted to try it too, so I grabbed Timothy's version, and did some improvements (I hope they are, feedback welcome ! :-) over it. Something I corrected is the removal of null or blank items, as in the first python version. I also got rid of the assoc by using update-in. And I felt that there was too much use of apply, but this may be subjective. Question: In order to use update-in (or assoc in the previous version), one has to transform the seqs returned by partition into a vector of vectors, thus the use of 'into. It still seems a little bit ugly to me. Is there a more concise (if not idiomatic) way to do that ? Here is the new version: (ns html.table) (defn make-table [column-count selected-row selected-column words] (let [remove-blank (partial remove #(or (nil? %) (- % .trim .isEmpty))) I got an exception here: java.lang.IllegalArgumentException: No matching field found: isEmpty for class java.lang.String (NO_SOURCE_FILE:0) I assume you're using Java 1.6? Changing it to the following fixes it for me: [...] (let [remove-blank (partial remove #(or (nil? %) (empty? (.trim % [...] table (into [] (map (partial into []) (partition column-count (remove-blank words table-with-selected (update-in table [selected-row selected-column] (partial list :bold))] (cons :table (map (fn [r] (cons :tr (map (fn [i] (list :item i)) r))) table-with-selected (defn test-mt [] (make-table 3 1 0 [cat dog rabbit cat dog rabbit frog elephant gorilla])) -- Michael Wood esiot...@gmail.com --~--~-~--~~~---~--~~ 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 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: How do I do this in clojure?
Thanks Michael 2009/2/17 Michael Wood esiot...@gmail.com On Tue, Feb 17, 2009 at 11:05 AM, Laurent PETIT laurent.pe...@gmail.com wrote: Hello, I wanted to try it too, so I grabbed Timothy's version, and did some improvements (I hope they are, feedback welcome ! :-) over it. Something I corrected is the removal of null or blank items, as in the first python version. I also got rid of the assoc by using update-in. And I felt that there was too much use of apply, but this may be subjective. Question: In order to use update-in (or assoc in the previous version), one has to transform the seqs returned by partition into a vector of vectors, thus the use of 'into. It still seems a little bit ugly to me. Is there a more concise (if not idiomatic) way to do that ? Here is the new version: (ns html.table) (defn make-table [column-count selected-row selected-column words] (let [remove-blank (partial remove #(or (nil? %) (- % .trim .isEmpty))) I got an exception here: java.lang.IllegalArgumentException: No matching field found: isEmpty for class java.lang.String (NO_SOURCE_FILE:0) I assume you're using Java 1.6? Changing it to the following fixes it for me: [...] (let [remove-blank (partial remove #(or (nil? %) (empty? (.trim % [...] table (into [] (map (partial into []) (partition column-count (remove-blank words table-with-selected (update-in table [selected-row selected-column] (partial list :bold))] (cons :table (map (fn [r] (cons :tr (map (fn [i] (list :item i)) r))) table-with-selected (defn test-mt [] (make-table 3 1 0 [cat dog rabbit cat dog rabbit frog elephant gorilla])) -- Michael Wood esiot...@gmail.com --~--~-~--~~~---~--~~ 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 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: Fully lazy sequences are coming - feedback wanted!
On Feb 16, 2009, at 20:23, Rich Hickey wrote: It seems the Sequence/ISeq dichotomy was a sticking point for many. After some tweaking, I've been able to get rid of Sequence entirely, SVN 1284+ in lazy branch. This is source compatible with 1282 (first/ rest/next), except that sequence? no longer exists - go back to seq?. New docs here: http://clojure.org/lazy Let me know if that is simpler. I'd say yes. The remaining weird feature is the seq function and its use. The name suggests that it converts to a seq, which is in fact what it used to do. Now it converts to a seq unless the resulting seq would be empty. For an empty seq, it actually converts a seq to a non-seq! Would it be possible to make an empty seq test as false? One could then do away with the conversion to seq in tests completely, and seq could always return a seq, including an empty one. Of course, this would imply that a logical test on a seq evaluates its first element, but that doesn't look unreasonable to me. Konrad. --~--~-~--~~~---~--~~ 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 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: Clojure on CLR/DLR
Haha. I just noticed my typo in the previous post. Disregard that. :| On Feb 17, 3:22 am, Laurent PETIT laurent.pe...@gmail.com wrote: Clonure (n for dot *n*et), as in : Clonure, a dot net clone of Clojure (ok, sorry ;-) 2009/2/17 Lucio Fulci luciofulc...@gmail.com I can see a minor problem with ClojureCLR, that is, j in clojure stands for JVM, right? So it's a bit messy. --~--~-~--~~~---~--~~ 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 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: Clojure on CLR/DLR
Fantastic news, David. This should help the spread of Clojure. Although I like Bonjure as a name, and even though two syllable names are generally considered best by marketers, I think ClojureCLR is best for branding purposes. It helps spread the Clojure meme and it linguistically supports the claim that the language is cross-VM. The world needs a good Lisp that runs on popular VMs. Looks like we're getting there. Thanks for your hard work. On Feb 16, 2:43 pm, dmiller dmiller2...@gmail.com wrote: [I thought I'd slip this in while Rich has everyone distracted lazy sequences.] What do you do when you love Lisp, are intrigued by Clojure, but have absolutely no projects at hand to test it out? Oh, and you have an interest in how dynamic languages are being implemented in modern virtual machine environments. You might implement Clojure on the CLR, I guess. So I did. At least, I have started. The project has reached the point where I need input from the community and especially Rich. Rich asked that I go public. So I will. (Though most certainly I would prefer to wait until the code is ... better.) The code will go up on clojure-contrib ASAP. I need input from the clojure-contrib project members on how they operate, where they want to put it, etc. This is definitely alpha-level, developer-only. Hard hats, goggles, and heavy gloves recommended. Goals: (a) Implement a feature-complete Clojure on top of CLR and the DLR (Dynamic Language Runtime). (b) Stay as close as possible to the JVM implementation so that the versions can stay in synch. That includes: (c) To the extent possible, use exactly the same boostrap *.clj files to define the environment. (d) Try to use some of the more advanced features of the DLR, where it makes sense to do so. (e) Spawn a cottage industry of people making Visual Studio extensions for Clojures. :) (e) Have fun. Status: Let's call it alpha. Not for the casual user, but developers might want to take a look. Stop here unless you really want status details. The basic runtime data structures--the persistent collections, namespaces/symbols/keywords, vars, refs, atoms, agents, etc.--are 95% complete. The remaining pieces are trivial. The LispReader is feature-complete except for #=. Call this 96% complete. There are currently 500+ unit tests on the basic data structures and the reader. Call this 34% complete. There are no unit tests on compiler. That would be 0%. This is not an interpreter. A compiler translates Clojure forms into DLR expression trees. DLR does its magic, i.e. compiles to MSIL, and computation happens. At the moment, there is not a single call to Reflection.Emit in the compiler code. (Though that will have to change soon.) It handles all special forms, can load most of core.clj, deals with macros, inlines, tags, CLR-interop, There is a basic REPL. core.clj loads with minor edits (java.util.Collection = System.Collections.ICollection, for example). Of roughly 425 def forms in core.clj, only 43 are commented out. 19 of those are for specialized array access, 6 for regular expressions -- nothing significant in terms of work. Of the 360 defs that load, most have been tested at a rudimentary level. However, the roughly 20 defs related to libs/loading/compiling definitely do not work. Call this 85% complete. core-print.clj also loads and seems to work. ants.clj runs. (The sim code is unchanged. The GUI was rewritten to Windows Forms.) 100%. The code is consistent with revision 1279 of the JVM code (Feb 13). It is running on release 10606 of the DLR (Feb 11). It is slow. Roughly 4X slower than Clojure/JVM on one or two very easy tests. (No need to comment on microbenchmarks.) This will be the focus of the next round of work. What's not there: Libs and loading -- lots of design problems because of the differences between JVM and CLR relating to classpaths, assemblies, etc. (Basic file loads can be done.) AOT/Compilation/gen-class Proxies Bootstrap *.clj files other than core.clj and core-print.clj -- Just haven't had time yet. Speed. So there you have it. I'll post again when the code becomes available on clojure-contrib. -- David Miller --~--~-~--~~~---~--~~ 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 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: terminology question re: binding
On Feb 16, 2009, at 10:34 AM, Stuart Halloway wrote: David Sletten sent me this erratum: At the beginning of section 2.4 we have The symbol user/foo refers to a var which is bound to the value 10. Under the next subsection Bindings we have Vars are bound to names, but there are other kinds of bindings as well. The Common Lisp standard defines a binding as an association between a name and that which the name denotes. This is the second sense used in the book. The first sense of a binding between a var and its value is inconsistent. Should I be using two different terms, or is the notion of binding overloaded? Stuart, I'm sorry but my comments appear to have raised more of a fuss than I intended. I think I need to clarify two issues: 1. I was probably not sufficiently clear in my intent. I did not mean so much to point out that you were wrong as to simply highlight the inconsistent use of the words binding and bound. Your term overloaded is more neutral, and therefore a better choice than mine. In a language such as Common Lisp where every variable is (effectively) a reference variable, we have three concepts: names, variables (references), and values (referents). These three things have two connections. In an orthodox (perhaps pedantic) sense a name is bound to a variable, and the variable has a value. Names can be bound to different variables and variables can be assigned new values: (defvar *x* 8) ; Bind *x* to special variable and assign value. (setf *x* 9) ; Assign new value to variable. Binding hasn't changed. (let ((x 12)) ; Bind x to variable, assign value. (let ((x pung)) ; Bind x to different variable - different binding. (setf x foo) ; Same (2nd) variable, new value. ...) ; 1st binding visible again outside of inner LET ...) ; No more binding for x out here On a side note, when we talk of scope we shouldn't talk about an identifier's scope or a variable's scope. Scope is an issue involving both names and variables: bindings have scope. The definitions in the CLHS glossary all reflect this interpretation. However, as I was looking through my notes it became clear that your overloaded use is hardly idiosyncratic. For example, the CLHS entry for LET states: let and let* create new variable bindings and execute a series of forms that use these bindings. Yet it explicitly states later that: ...Then all of the variables varj are bound to the corresponding values. This seems to me inconsistent with the glossary definitions, but such usage occurs throughout the Standard. I think that the strict usage is consistent with Clojure's binding macro, which binds a name to a new variable. The let special form does a similar thing, but the situation is a little different than in CL since you can't assign a new value to a variable established by a Clojure let binding. Consequently, it seems that we can more safely blur the distinctions among name/variable/value here. A name is associated with a given value for the lifetime of the binding. As another example, the language Oz has the notion of identifiers, which may be either bound or free, and variables, which may either be bound or unbound. Oz variables are like Clojure lexicals--once assigned their values cannot change. So an unbound variable is simply a variable that has not been assigned a value yet. Assignment binds a value to a variable. Likewise, a free identifier is a name that doesn't refer to anything yet. Once bound, an identifier names a variable. So to wrap this all up, if you are satisfied with your discussion in the book--and you seem justified in that--then I'll just shut up about binding. 2. My erratum report and comments above should not be viewed as though I advocate Clojure being evaluated through the lens of Common Lisp. I have a few years experience studying CL, so naturally that affects my perception of Clojure. However, in fairness the language should be judged on its own merits, and I am far too new to Clojure to make any such judgment yet. Aloha, David Sletten --~--~-~--~~~---~--~~ 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 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: Creating executable Jars?
Kev, I didn't make it, however, I guess the issue was on namespace and not on the instruction given. I will try again and again until I get my head around namespace, or could you help me to jump start? Emeka --~--~-~--~~~---~--~~ 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 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: Fully lazy sequences are coming - feedback wanted!
On Feb 17, 2009, at 4:40 AM, Konrad Hinsen wrote: On Feb 16, 2009, at 20:23, Rich Hickey wrote: It seems the Sequence/ISeq dichotomy was a sticking point for many. After some tweaking, I've been able to get rid of Sequence entirely, SVN 1284+ in lazy branch. This is source compatible with 1282 (first/ rest/next), except that sequence? no longer exists - go back to seq?. New docs here: http://clojure.org/lazy Let me know if that is simpler. I'd say yes. The remaining weird feature is the seq function and its use. The name suggests that it converts to a seq, which is in fact what it used to do. Now it converts to a seq unless the resulting seq would be empty. For an empty seq, it actually converts a seq to a non-seq! There will always be a tension between treating the first node in a list as a node vs as the entire list. The seq function is firmly in the former camp, essentially returning the node containing the first item. seq also has an important role regarding lazy seqs - when given one it forces it and returns the inner seq. This is the big reason why empty? is not a replacement for seq. One way to look at (seq x) is as a version of (not (empty? x)), where the truth value is more useful than 'true'. I will be adding a sequence function that will act as a constructor/ coercion, so: (seq []) - nil (sequence []) - () In addition, sequence, when given a seq, will not force it, if it is lazy. It will work like this: (defn sequence [x] (if (seq? x) x (or (seq x) ( People that don't like nil punning need never use seq/next. Would it be possible to make an empty seq test as false? No - then you could no longer distinguish between an empty collection and nothing. Additionally, that would be a big performance hit for 'if'. Rich --~--~-~--~~~---~--~~ 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 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: How do I do this in clojure?
Hi Laurent, Thanks for those improvements. I agree that it would be nice in this case to be able to 'update-in' an arbitrary tree. I played around using zippers to achieve this with some success, however it was very verbose. Next I tried implementing update-in-list which seemed a bit more obvious, though is still quite verbose. However it make the core program itself quite nice (excluding the helpers): (uploaded new version http://clojure.googlegroups.com/web/layout.clj, you may need to F5 reload it to see the new version) Regards, Tim. --~--~-~--~~~---~--~~ 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 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: How do I do this in clojure?
Jesse, Could I see your own version. Emeka --~--~-~--~~~---~--~~ 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 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: How do I do this in clojure?
Jesse, Could I see your own version. Haha, I was afraid someone would say this. Here is my embarrassingly bad (but working) version: (defn build-table [] (def num-cols 3) (def selected-row 0) (def selected-col 0) (def all-strings [apple cat dog frog elephant gorilla]) (defn new_cell [string row col] (defn bg-color [] (if (and (= col selected-col) (= row selected-row)) d0e0ff cfcfdf)) (str td bgcolor=# (bg-color) font color=#cc (first string) /font (.substring string 1 (.length string)) /td)) (loop [row 0 col 0 table_contents table cellpadding=30 bgcolor=#aa\ntr \n strings all-strings] (if strings (if (not= (first strings) ) (if (= col num-cols) (recur (inc row) 0 (str table_contents /tr\ntr) strings) (recur row (inc col) (str table_contents (new_cell (first strings) row col)) (rest strings))) (recur row col table_contents (rest strings))) (str table_contents /tr\n/table I actually got it working before reading any of the replies here. So I'll probably take some of these suggestions and use them to improve the code. --~--~-~--~~~---~--~~ 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 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: Clojure on CLR/DLR
I've been working on Xronos which is also a c# version of clojure (I need to be careful to not use the work port, since it doesn't share any code with clojure). It compiles to the DLR as well. It is located here: http://www.bitbucket.org/stefanrusek/xronos/wiki/Home One big difference is that Xronos is released under the BSD license instead of the Eclipse Public License. --Stefan Rusek --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Libraries? model and generic-functions
Two of the subsystems in my app project might usefully be packaged and distributed as libraries, if people want them. I thought I'd describe them, so as to discover whether I should be planning for that. Why not post this to Rich's Got a Clojure Library? thread? Because that thread is presently a nice catalog of available libraries, and I don't want to clutter it with descriptions of things that might or might not be of interest. Anyhow, below are the descriptions; I'll let the level of interest guide me in whether I package them for more general distribution. 1. model - model is a subsystem for creating maps based on other maps.They are similar in purpose to structs, but provide some additional facilities for defining constraints on values allowed in fields, for combining models to yield composite models, and for testing whether a given map is an instance of one or more models. For example, my application code contains these definitions: (def node (model :port {:class java.lang.Integer} :input-stream {:class java.io.Reader} :output-stream {:class java.io.Writer} :error-output-stream {:class java.io.Writer, :default *out*})) (def client-node (combine-models node (model :client-socket nil) :strictly)) (def server-node (combine-models node (model :server-socket nil :server-function {:criterion ifn?}) :strictly)) The ... notation is just a naming convention: models that get reused a lot are stored on Vars whose names are bracketed with and . The function model returns a model. A model is just a map that is intended to be used for creating other maps, similar to s struct, but with some additional features: - the values stored on a model are descriptions of the values that are allowed in an instance of the model; you can see some of the possible value constraints above. You can declare that a field allows any value, or that it restricts values by class, by model, or by some functional criterion. - make-instance creates a map that is an instance of a model, ensuring that any initial values conform to the declared value constraints - combine-models creates a new model that contains the keys and associated value constraints of the input models. When the input models have a key in common, there are two ways the ambiguity can be resolved: permissively means the key from the leftmost model is used strictly means that the two constraints must be non- contradictory, and are combined in the output model The default moethod is permissively; a :strictly keyword elects the strict rules - (model? x m strict?) returns true if x is a map, m is a model, and the keys of m are all present in x. If strict? is true, then model? also checks whether the values for those keys all satisfy the corresponding value constraints in m. 2. generic functions - Generic functions are functions that dispatch to methods based on certain tests against their arguments. They are conceptually similar to Clojure MultiFns, but use a different dispatching mechanism: given a set of arguments, a generic function compares them to the methods defined on the generic function. It collects all defined methods that can be applied to the given arguments (that is, all methods whose declared parameters are compatible with the actual parameters supplied); it orders the found methods by specificity, and it then applies the most specific method to the actual arguments, in an environment where the remaining applicable methods are accessible through a function called next-method. In other words, you can create a generic function: (def frob (make-generic-function)) Then you can add some methods to it: (add-gf-method frob [java.lang.Number java.lang.Number] (fn [x y] (+ x y))) (add-gf-method frob [java.lang.String java.lang.String] (fn [x y] (str x y))) (add-gf-method frob [java.lang.String java.lang.Integer] (fn [s i] (apply str (take i (cycle [s]) (add-gf-method frob [{:test (fn [x] (= x swordfish))}] (fn [s] (str You said the secret word, you win a hundred dollars!))) user (frob hello world) hello world user (frob 2 3) 5 user (frob foo 5) foofoofoofoofoo user (frob swordfish) You said the secret word, you win a hundred dollars! Generic functions dispatch on class, model, equality to a specific value, and satisfaction of a user-supplied predicate. That list is from least- to most-specific (so, for example. a match that satisfies a user predicate will always override one that matches a class). I'm using the model code fairly extensively now; the generic functions satisfy some tests and are in modest use, but would require additional work to be more generally useful. --~--~-~--~~~---~--~~ You received this message because you are subscribed to
Re: Clojure on CLR/DLR
I'm up for suggestions on the name. The obvious ones: - Clojure.net - ClojureCLR - IronClojure (paralleling IronPython/IronRuby, unless MS has Iron trademarked.) - CLjR (too cute) Perhaps Rich will have a preference. He'll have to live with it longer than anyone and has branding/confusion issues to keep in mind. So, as a long-time .NET guy, IronClojure seems like the best name, in terms of making it obvious what it does: it's like IronRuby/Python, but it's Clojure. Failing that, it seems like NClojure fits the pattern of other JVM-ported efforts. I realize that there's already an Enclojure. Just to throw more chaff into the air: * CoCLR: Clojure on the CLR. (Maybe pronounced cochlear?) * Coc: Same as above. * CoNET: Clojure on .NET. * Icon: An Implementation of Clojure on .NET. * Ichor: I can't think of an acronym here, but I want to. :) --~--~-~--~~~---~--~~ 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 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: How do I do this in clojure?
Haha, I was afraid someone would say this. Here is my embarrassingly bad (but working) version: I won't say that, you ported Python to Clojure while maintaining Python spirit. That's great! Emeka --~--~-~--~~~---~--~~ 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 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: Clojure on CLR/DLR
On Feb 17, 9:03 am, Craig Andera craig.and...@gmail.com wrote: I'm up for suggestions on the name. The obvious ones: - Clojure.net - ClojureCLR - IronClojure (paralleling IronPython/IronRuby, unless MS has Iron trademarked.) - CLjR (too cute) Perhaps Rich will have a preference. He'll have to live with it longer than anyone and has branding/confusion issues to keep in mind. So, as a long-time .NET guy, IronClojure seems like the best name, in terms of making it obvious what it does: it's like IronRuby/Python, but it's Clojure. Failing that, it seems like NClojure fits the pattern of other JVM-ported efforts. I realize that there's already an Enclojure. Just to throw more chaff into the air: * CoCLR: Clojure on the CLR. (Maybe pronounced cochlear?) * Coc: Same as above. * CoNET: Clojure on .NET. * Icon: An Implementation of Clojure on .NET. There is an existing programming language named Icon, developed by Ralph Griswold (the same guy who developed SNOBOL). Icon has been around for decades, and is an interesting language in its own right. * Ichor: I can't think of an acronym here, but I want to. :) --~--~-~--~~~---~--~~ 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 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: How do I do this in clojure?
2009/2/17 Emeka emekami...@gmail.com Haha, I was afraid someone would say this. Here is my embarrassingly bad (but working) version: I won't say that, you ported Python to Clojure while maintaining Python spirit. That's great! Are you serious, or is this a joke somewhat bashing the python language ? Emeka --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
clojure and embedded derby
Has anyone had experience creating clojure applications that use the embedded derby database driver? I am having an issue where I am unable to get the derby embedded database to shut down properly from within clojure. More specifically, whenever a java app accesses a derby embedded database, it creates a lock file to prevent other apps from accessing the db and corrupting it. This file should be removed in a proper shutdown of a derby database, but so far, even though I appear to have gotten the derby database engine to shutdown from within clojure with (java.sql.DriverManager/getConnection jdbc:derby:;shutdown=true), the lock file still remains, and no app can access the derby database until the db.lck file is deleted manually. I assumed this file would be deleted automagically during database shutdown, but is this actually something my app should do manually after shutting down its derby database? Thanks in advance for any assistance, I appreciate that this is only marginally a clojure issue. Brian --~--~-~--~~~---~--~~ 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 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: How do I do this in clojure?
Yeah, I think you're right. That's Python spirit in place of original code spirit that surprised me. 2009/2/17 Dan redalas...@gmail.com I won't say that, you ported Python to Clojure while maintaining Python spirit. That's great! Are you serious, or is this a joke somewhat bashing the python language ? I guess he meant maintaining the spirit of the original python code. The original code was overtly long and non-idiomatic and the clojure translation is faithful to what the code was actually doing. --~--~-~--~~~---~--~~ 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 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: Clojure on CLR/DLR
So, as a long-time .NET guy, IronClojure seems like the best name, in terms of making it obvious what it does: it's like IronRuby/Python, but it's Clojure. Failing that, it seems like NClojure fits the pattern of other JVM-ported efforts. I realize that there's already an Enclojure. Just to throw more chaff into the air: * CoCLR: Clojure on the CLR. (Maybe pronounced cochlear?) * Coc: Same as above. * CoNET: Clojure on .NET. * Icon: An Implementation of Clojure on .NET. There is an existing programming language named Icon, developed by Ralph Griswold (the same guy who developed SNOBOL). Icon has been around for decades, and is an interesting language in its own right. * Ichor: I can't think of an acronym here, but I want to. :) As far as I understood, the rules are that it should be derived from Clojure and sports either an N or a CLR. So I suggest Conjure It looks like clojure, sounds pleasing, and sounds lispish (conj). And Lisp to me sounds like magic (in the Arthur C. Clarke meaning that it is a technology sufficiently advanced that it is indistinguishable from it). --~--~-~--~~~---~--~~ 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 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: How do I do this in clojure?
Hi On Tue, Feb 17, 2009 at 4:03 PM, Jesse Aldridge jessealdri...@gmail.com wrote: Jesse, Could I see your own version. Haha, I was afraid someone would say this. Here is my embarrassingly bad (but working) version: (defn build-table [] (def num-cols 3) (def selected-row 0) (def selected-col 0) (def all-strings [apple cat dog frog elephant gorilla]) let would be better than def here. def creates basically a global variable (although I'm sure someone will complain about me calling them that :) (defn new_cell [string row col] (defn bg-color [] There's no point using nested defns, since defn is defined in terms of def. i.e. these are also global. (if (and (= col selected-col) (= row selected-row)) d0e0ff cfcfdf)) (str td bgcolor=# (bg-color) font color=#cc (first string) /font (.substring string 1 (.length string)) /td)) (loop [row 0 col 0 table_contents table cellpadding=30 bgcolor=#aa\ntr \n strings all-strings] (if strings (if (not= (first strings) ) (if (= col num-cols) (recur (inc row) 0 (str table_contents /tr\ntr) strings) (recur row (inc col) (str table_contents (new_cell (first strings) row col)) (rest strings))) (recur row col table_contents (rest strings))) (str table_contents /tr\n/table I actually got it working before reading any of the replies here. So I'll probably take some of these suggestions and use them to improve the code. -- Michael Wood esiot...@gmail.com --~--~-~--~~~---~--~~ 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 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: terminology question re: binding
I'm still not *entirely* clear about the mappings from symbols and namespaces to Vars. I think I sort of understand how it works in practical terms, but this is a confusing area and getting the terminology nailed down would be a big help. On Tue, Feb 17, 2009 at 10:10 AM, Chouser chou...@gmail.com wrote: On Tue, Feb 17, 2009 at 7:01 AM, David Sletten da...@bosatsu.net wrote: In a language such as Common Lisp where every variable is (effectively) a reference variable, we have three concepts: names, variables (references), and values (referents). These three things have two connections. In an orthodox (perhaps pedantic) sense a name is bound to a variable, and the variable has a value. Clojure similarly has three concepts with two connection for global Vars. As you point out later, locals (as created by 'fn' and 'let') are a bit different. I think that the strict usage is consistent with Clojure's binding macro, which binds a name to a new variable. Are you sure? It seems to me the most natural mapping from the CL concepts to Clojure is: CL name - Clojure symbol, name, or perhaps namespace entry CL variable - Clojure Var (or perhaps ref, atom, etc.) CL value or referent - Clojure value. Clojure's 'binding' macro does not change the connection from name to Var, but the one from Var to (effective, thread-local) value. I think this is worth dicussing not so much so because I care about being consistent with the classic meaning of these words in various other languages, but I'm all for careful use of English to reduce confusion as much as possible. --Chouser --~--~-~--~~~---~--~~ 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 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: Fully lazy sequences are coming - feedback wanted!
On Mon, Feb 16, 2009 at 12:05 PM, Perry Trolard trol...@gmail.com wrote: I agree with the majority of posters that the breaking changes in the service of optimal names is the right way to go. I found the explanation recipe for porting at clojure.org/lazier clear easy to follow. I didn't do full ports of any projects, but I did some selective porting found it to be straightforward. That said, the only problem I see is with the names. Like Mibu, I think next isn't ideal -- it connotes an item in an iteration to me. If you think next *seq* when you see next (how Rich explains it at /lazier), it helps, but it's still not exactly right; or it requires a different mental model from the non-lazy-branch rest: the cursor moving to the next item rather than the abstracted rest of the coll (where you think about a cursor). I think the issue is that rest is the right name for both rest next. The only difference between them, from the perspective of users, is how empty rests are represented ('() or nil), that's a hard distinction to make manifest in a short name. If it's the case that rest will almost exclusively appear in the context of constructing lazy-seqs (lazy-seq (cons [something] (rest [something])) next will appear all over, it makes sense to me to sacrifice brevity in the case of rest, give next the right name: rest (that's tortuous, I know). rest* isn't quite right, but you get the idea: make the fully-lazy rest the special-kind-of-rest, the consumer-code rest the transparent one. This way, people's concepts about recursing through seqs of colls testing for the end won't have to change; they'll only have to change their understanding of how to make lazy sequences. I know in my code I do a lot more of the former. Anyone who's on board with this line of thought have ideas for the right name of fully-lazy rest? I am fully on board with this idea. 'next' seems unfit to me exactly as a few people have pointed out, it connotes an item rather than the rest of a seq. That said, I really have no grounds to be confident either way that rest will almost exclusively appear in the context of constructing lazy-seqs. Can any other more experienced folks can offer some thoughts on this conjecture? Someone suggested 'next-seq' earlier. I would also suggest rest-seq, which is almost a literal translation of the invariant: (rest-seq x) === (seq (rest x)) I like this, but as you point out Perry, there is a typing penalty to be paid here; however, I think it is a small one and completely justified. Jim asked above why seq-on-the-next-item-if-any-else-nil is needed at all, and clearly as Rich stated, there is a large number of uses of rest right now proving its usefulness. For me, this highlights the fact that in the new fully lazy seq model, the function 'seq-on-the-next-item-if-any-else-nil is not core to the abstraction. As a result, having a second class' hyphenated name such as rest-seq (or next-seq), almost confers the exists for convenience nature of this function that we are trying to name. /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 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: Clojure Off-topic IRC channel
I have now acquired 4 regulars who agree with me! We need more! Join people join! :p --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
do-form swallows exception?
Hi, How come the following code does not throw an exception? (defn foo [] (do (map (fn [_] (throw (RuntimeException. fail))) [1 2]) no exception)) this however does throw exception: (defn foo [] (map (fn [_] (throw (RuntimeException. fail))) [1 2])) Is this a bug or am I missing something? --~--~-~--~~~---~--~~ 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 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: do-form swallows exception?
First, map returns a lazy seq. Second, do only returns the result of the last expression. So, the mapping you do in your do form is never executed because you never ask for the result. Try wrapping the mapping in dorun to explicitly realize the lazy seq from your mapping: (defn foo [] (do (dorun (map (fn [_] (throw (RuntimeException. fail))) [1 2])) no exception)) On Tue, Feb 17, 2009 at 5:11 PM, linh nguyenlinh.m...@gmail.com wrote: Hi, How come the following code does not throw an exception? (defn foo [] (do (map (fn [_] (throw (RuntimeException. fail))) [1 2]) no exception)) this however does throw exception: (defn foo [] (map (fn [_] (throw (RuntimeException. fail))) [1 2])) Is this a bug or am I missing something? -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 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: Clojure Off-topic IRC channel
+1 I actually think that #clojure is very active. Of the channels I frequent/lurk in, only #git regularly surpasses #clojure in number of messages per (my) day. Maybe that says more about my irc interests, so take that as you will. #clojure-offtopic doesn't have much poetry to it, but I'll keep out of naming stuffs. - Chas On Feb 17, 2009, at 8:23 AM, Rayne wrote: A week or 2 ago, Lau_Of_DK asked me very nicely to stop talking so off- topic in #Clojure. I mentioned that we should have an Off-topic channel for people who would just like to talk, because just about every other language's channel on freenode has an off topic channel (#haskell-blah for instance). He said it has been discussed and because of the low volume of #clojure (which isn't so low if you think about it), it would not be a good idea. I just went along with that. But today I thought about it, and I haven't seen it discussed and if it has been discussed here before I'm sorry, but I'd like other peoples input on this. I feel that making an off topic channel for Clojurists would not effect the volume of #Clojure in any way. In fact I feel that it would remove any current, or future extensive off topic chatter in #Clojure and help to keep things on tract. If people want to talk off topic they can come to the off topic channel, and if they don't want to talk about #Clojure, they probably wouldn't be there in the first place. How would it effect #Clojure's volume? I personally think having an off topic channel is a great idea, but it's not my language and #Clojure isn't my channel. I have made a channel on freenode called #Clojure-Offtopic for now it is explicitly marked as unofficial and waiting for Rich Hickey's approval. If for some reason, you guys /really/ don't want an off topic channel, I have respect enough to remove the channel for you guys. I will not announce this channel in #Clojure until I have the communities approval. It seems I've attracted durka to the channel somehow though :p. I'm sorry if this topic isn't right for this group, but I'm not sure where else I should discuss it. -Rayne --~--~-~--~~~---~--~~ 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 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: Clojure Off-topic IRC channel
Names really weren't my priority here. I'll be happy to link -offtopic to another channel with a different name if someone thinks of a better name somewhere down the road ^_^. On Feb 17, 10:15 am, Chas Emerick cemer...@snowtide.com wrote: +1 I actually think that #clojure is very active. Of the channels I frequent/lurk in, only #git regularly surpasses #clojure in number of messages per (my) day. Maybe that says more about my irc interests, so take that as you will. #clojure-offtopic doesn't have much poetry to it, but I'll keep out of naming stuffs. - Chas On Feb 17, 2009, at 8:23 AM, Rayne wrote: A week or 2 ago, Lau_Of_DK asked me very nicely to stop talking so off- topic in #Clojure. I mentioned that we should have an Off-topic channel for people who would just like to talk, because just about every other language's channel on freenode has an off topic channel (#haskell-blah for instance). He said it has been discussed and because of the low volume of #clojure (which isn't so low if you think about it), it would not be a good idea. I just went along with that. But today I thought about it, and I haven't seen it discussed and if it has been discussed here before I'm sorry, but I'd like other peoples input on this. I feel that making an off topic channel for Clojurists would not effect the volume of #Clojure in any way. In fact I feel that it would remove any current, or future extensive off topic chatter in #Clojure and help to keep things on tract. If people want to talk off topic they can come to the off topic channel, and if they don't want to talk about #Clojure, they probably wouldn't be there in the first place. How would it effect #Clojure's volume? I personally think having an off topic channel is a great idea, but it's not my language and #Clojure isn't my channel. I have made a channel on freenode called #Clojure-Offtopic for now it is explicitly marked as unofficial and waiting for Rich Hickey's approval. If for some reason, you guys /really/ don't want an off topic channel, I have respect enough to remove the channel for you guys. I will not announce this channel in #Clojure until I have the communities approval. It seems I've attracted durka to the channel somehow though :p. I'm sorry if this topic isn't right for this group, but I'm not sure where else I should discuss it. -Rayne --~--~-~--~~~---~--~~ 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 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: do-form swallows exception?
Map is lazy. You are presumably executing (foo) at the REPL. In the first foo, since the value calculated by map is unused, no elements of the seq are calculated and your anonymous function never runs. In the second foo, since the function actually returns the value and the REPL wants to print it, the values are calculated, and your anonymous function runs. (defn foo2 [] (doseq [a [1 2]] (throw (RuntimeException. fail))) end) This function always throws, because doseq always goes through the whole seq. --~--~-~--~~~---~--~~ 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 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: do-form swallows exception?
Thank you for the quick answers. I'm new to clojure and functional programming so this lazy-stuff is new to me, but it makes sense and is really cool. --~--~-~--~~~---~--~~ 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 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: Libraries? model and generic-functions
On Feb 17, 9:20 am, Raffael Cavallaro raffaelcavall...@gmail.com wrote: On Feb 17, 9:56 am, mikel mev...@mac.com wrote: I'll let the level of interest guide me in whether I package them for more general distribution. I am very interested in both of these subsystems and would love to see you package them as clojure.contrib libraries. Hopefully others feel the same and we'll see an announcement for them here soon. Best of luck with model and generic functions, and with clojure in general. Good to know; thanks. I think model just needs the packaging done, but I should probably allow a little more time in use to shake out any unanticipated problems. Generic functions work, but probably want a reimplementation to improve their efficiency and to add some amenities. Probably they want a little syntactic sugar, and likely they want to be built on a Java Class like MultiFn rather than on closures. Also, their dispatch mechanism knows about models, and I think I want to change that for two reasons: first, dispatching on models can be costly, so it should probably be optional, which entails an extension to the current generic functions that would allow users to specify the dispatch protocol; second, the use of models in the dispatch is the only dependency between the two subsystems, and I just think it would be nice to completely separate them. If I can devise a suitably straightforward way to parameterize the dispatch algorithm for generic functions that would then become easy to accomplish. I will say that I am quite enjoying having generic functions and a composable object model that are completely orthogonal to one another. --~--~-~--~~~---~--~~ 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 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: clojure and embedded derby
Is your Clojure app running in a REPL? I've run into situations where it seems like the Derby lock file doesn't go away until the Clojure process terminates. -Stuart Sierra On Feb 17, 10:28 am, BrianS bstephen...@enclojure.org wrote: Has anyone had experience creating clojure applications that use the embedded derby database driver? I am having an issue where I am unable to get the derby embedded database to shut down properly from within clojure. More specifically, whenever a java app accesses a derby embedded database, it creates a lock file to prevent other apps from accessing the db and corrupting it. This file should be removed in a proper shutdown of a derby database, but so far, even though I appear to have gotten the derby database engine to shutdown from within clojure with (java.sql.DriverManager/getConnection jdbc:derby:;shutdown=true), the lock file still remains, and no app can access the derby database until the db.lck file is deleted manually. I assumed this file would be deleted automagically during database shutdown, but is this actually something my app should do manually after shutting down its derby database? Thanks in advance for any assistance, I appreciate that this is only marginally a clojure issue. Brian --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
map literals, computed keys and side-effects
While kicking the tires, I encountered this behavior: user= (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9}) {3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9, 1 2} user= (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8}) {1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8} Granted, it's not casual Clojure code but it's surprising. Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (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 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: map literals, computed keys and side-effects
That's odd. Might you have uncovered a bug regarding: user= (class {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9}) clojure.lang.PersistentHashMap user= (class {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}) clojure.lang.PersistentArrayMap While with the atom code we have: user= (class (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9})) clojure.lang.PersistentArrayMap user= (class (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8})) clojure.lang.PersistentArrayMap On Tue, Feb 17, 2009 at 8:03 PM, Christophe Grand christo...@cgrand.net wrote: While kicking the tires, I encountered this behavior: user= (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9}) {3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9, 1 2} user= (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8}) {1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8} Granted, it's not casual Clojure code but it's surprising. Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Web Services On Clojure
Hello everybody! How do I create a web service on Clojure? Thank you. Fahed --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Fully lazy sequences are here!
I've merged the lazy branch into trunk, SVN rev 1287 Please do not rush to this version unless you are a library/tool developer. Let them do their ports and chime in on their progress. Move only when the libs/tools you depend upon have been ported. Thanks to all for your feedback and input! Rich --~--~-~--~~~---~--~~ 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 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: map literals, computed keys and side-effects
I think I got it :) The two (swap! a inc) forms are added to the map at read-time - which is before they are evaluated. However, since we are associating the (swap! a inc) key with a value twice, only the last one counts. So the atom is inc'ed to 1 once (because keys can only be in the map once), and assoc'ed with the value 2 (because that's the second assoc we're doing to the (swap! a inc) form). The PersistantArrayMap, on the other hand, is more gullible and trusting towards the parsed array of forms that the reader presents it, and therefor accepts the (swap! a inc) key twice, which in turn causes it to evaluate twice; into two different keys with two different associations. On Tue, Feb 17, 2009 at 8:28 PM, Christian Vest Hansen karmazi...@gmail.com wrote: That's odd. Might you have uncovered a bug regarding: user= (class {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9}) clojure.lang.PersistentHashMap user= (class {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}) clojure.lang.PersistentArrayMap While with the atom code we have: user= (class (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9})) clojure.lang.PersistentArrayMap user= (class (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8})) clojure.lang.PersistentArrayMap On Tue, Feb 17, 2009 at 8:03 PM, Christophe Grand christo...@cgrand.net wrote: While kicking the tires, I encountered this behavior: user= (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9}) {3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9, 1 2} user= (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8}) {1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8} Granted, it's not casual Clojure code but it's surprising. Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) -- Venlig hilsen / Kind regards, Christian Vest Hansen. -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 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: clojure and embedded derby
I've seen the same thing with embedded Derby while using SLIME. From within the REPL I was always able to reconnect to the same database, so it didn't really impact me. Outside the REPL I didn't notice a problem. If it holds you up, here's one observation you might investigate. Calling (.close conn) doesn't remove the lock file, however causing a new connection to fail does. It seems the embedded Derby driver may have some locking clean-up logic in its connect call. Perhaps browsing the Derby source might show how to invoke the real release lock method. - Jeff On Tuesday 17 February 2009 12:57, Stuart Sierra wrote: Is your Clojure app running in a REPL? I've run into situations where it seems like the Derby lock file doesn't go away until the Clojure process terminates. -Stuart Sierra On Feb 17, 10:28 am, BrianS bstephen...@enclojure.org wrote: Has anyone had experience creating clojure applications that use the embedded derby database driver? I am having an issue where I am unable to get the derby embedded database to shut down properly from within clojure. More specifically, whenever a java app accesses a derby embedded database, it creates a lock file to prevent other apps from accessing the db and corrupting it. This file should be removed in a proper shutdown of a derby database, but so far, even though I appear to have gotten the derby database engine to shutdown from within clojure with (java.sql.DriverManager/getConnection jdbc:derby:;shutdown=true), the lock file still remains, and no app can access the derby database until the db.lck file is deleted manually. I assumed this file would be deleted automagically during database shutdown, but is this actually something my app should do manually after shutting down its derby database? Thanks in advance for any assistance, I appreciate that this is only marginally a clojure issue. Brian --~--~-~--~~~---~--~~ 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 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: map literals, computed keys and side-effects
Just to clarify; I think PersistentArrayMap is too naïve: user= {1 1 1 1 1 1 2 2} {1 1, 1 1, 1 1, 2 2} Also, this is rev 1286 (just prior to lazy-branch merge thingy). On Tue, Feb 17, 2009 at 8:50 PM, Christian Vest Hansen karmazi...@gmail.com wrote: I think I got it :) The two (swap! a inc) forms are added to the map at read-time - which is before they are evaluated. However, since we are associating the (swap! a inc) key with a value twice, only the last one counts. So the atom is inc'ed to 1 once (because keys can only be in the map once), and assoc'ed with the value 2 (because that's the second assoc we're doing to the (swap! a inc) form). The PersistantArrayMap, on the other hand, is more gullible and trusting towards the parsed array of forms that the reader presents it, and therefor accepts the (swap! a inc) key twice, which in turn causes it to evaluate twice; into two different keys with two different associations. On Tue, Feb 17, 2009 at 8:28 PM, Christian Vest Hansen karmazi...@gmail.com wrote: That's odd. Might you have uncovered a bug regarding: user= (class {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9}) clojure.lang.PersistentHashMap user= (class {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}) clojure.lang.PersistentArrayMap While with the atom code we have: user= (class (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9})) clojure.lang.PersistentArrayMap user= (class (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8})) clojure.lang.PersistentArrayMap On Tue, Feb 17, 2009 at 8:03 PM, Christophe Grand christo...@cgrand.net wrote: While kicking the tires, I encountered this behavior: user= (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9}) {3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9, 1 2} user= (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 3 3 4 4 5 5 6 6 7 7 8 8}) {1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8} Granted, it's not casual Clojure code but it's surprising. Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) -- Venlig hilsen / Kind regards, Christian Vest Hansen. -- Venlig hilsen / Kind regards, Christian Vest Hansen. -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 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: map literals, computed keys and side-effects
Christian Vest Hansen a écrit : Just to clarify; I think PersistentArrayMap is too naïve: user= {1 1 1 1 1 1 2 2} {1 1, 1 1, 1 1, 2 2} Also, this is rev 1286 (just prior to lazy-branch merge thingy). Fixing array-map would make the two tests consistent but I'm not sure that (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 }) should evaluate to {1 2}. Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (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 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: Clojure on CLR/DLR
As far as I understood, the rules are that it should be derived from Clojure and sports either an N or a CLR. So I suggest Conjure It looks like clojure, sounds pleasing, and sounds lispish (conj). And Lisp to me sounds like magic (in the Arthur C. Clarke meaning that it is a technology sufficiently advanced that it is indistinguishable from it). Ooh - that's much better than mine. :) +1! --~--~-~--~~~---~--~~ 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 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: How do I do this in clojure?
(ns html-table (:use clojure.contrib.prxml) (:use clojure.contrib.seq-utils)) (defn print-table [grid selected] (prxml [:table {:cellpadding 30, :bgcolor #aa} (for [[x row] (indexed grid)] [:tr (for [[y cell] (indexed row)] [:td {:bgcolor (if (= selected [x y]) #d0e0ff #cfcfdf)} [:font {:color #cc} (subs cell 0 1)] (subs cell 1)])])])) (defn make-grid [col-size data] (partition col-size (filter #(not= % ) data))) (print-table (make-grid 3 [cat dog rabbit frog elephant gorilla]) [0 0]) (println) On Feb 17, 2:18 am, Jesse Aldridge jessealdri...@gmail.com wrote: I'm trying to port some Python code to Clojure. I'm new to functional programming and I hit a function that is causing my brain to melt. The python function looks something like this: def build_table(): num_cols = 3 selected_row = 0 selected_col = 0 strings = [cat, dog, , rabbit, frog, elephant, gorilla] row, col = 0, 0 table_contents = table cellpadding=30 bgcolor=#aa\ntr\n for string in strings: if string == : continue if col = num_cols: row += 1 col = 0 table_contents += /tr\ntr def new_cell(): bg_color = cfcfdf if(col == selected_col and row == selected_row): bg_color = d0e0ff return td bgcolor=# + bg_color + + \ font color=#cc + string[0] + \ /font + string[1:] + /td\n table_contents += new_cell() col += 1 table_contents += /tr\n/table return table_contents If someone could please demonstrate how to do this in Clojure, I think it would greatly help my understanding of the language and functional programming in general. --~--~-~--~~~---~--~~ 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 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: map literals, computed keys and side-effects
On Tue, Feb 17, 2009 at 9:08 PM, Christophe Grand christo...@cgrand.net wrote: Fixing array-map would make the two tests consistent but I'm not sure that (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 }) should evaluate to {1 2}. That would make it two distinct issues, as I see it. One for array-map, and one for whether association happens before or after the keys have been evaluated. It would seem really strange to me if the following behavior is correct: user= (def m (array-map 1 1 1 2 1 3)) #'user/m user= (m 1) 1 user= (m 2) nil user= m {1 1, 1 2, 1 3} So I went ahead and opened an issue for that: http://code.google.com/p/clojure/issues/detail?id=83 I agree it would be nice if the keys were evaluated before the map was created - python certainly does it that way, though it isn't a lisp. Clojure is the only lisp I'm familiar with, so I can't say what's normal here. Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 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: Web Services On Clojure
Fahed Alrafidi wrote: How do I create a web service on Clojure? Thank you. Depends what sort of web service. A simple RESTFUL web service is pretty easy to develop in Compojure: (ns web-service (:use compojure)) (defservlet math-servlet (POST /add (let [x (Integer/parseInt (params :x)) y (Integer/parseInt (params :y))] (str (+ x y) \n (run-server {:port 8080} /math/* math-servlet) - James --~--~-~--~~~---~--~~ 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 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: Fully lazy sequences are here!
On Tue, Feb 17, 2009 at 2:43 PM, Rich Hickey richhic...@gmail.com wrote: I've merged the lazy branch into trunk, SVN rev 1287 Please do not rush to this version unless you are a library/tool developer. Let them do their ports and chime in on their progress. Move only when the libs/tools you depend upon have been ported. I've just merged contrib's lazy branch into trunk, since I couldn't think of any reason not to -- contrib svn 478 So nobody should upgrade contrib now either, unless you're working on fixing it for Clojure svn rev 1287. Contrib authors: the lazy branch is still there, but it's probably best to ignore it now and make all further lazy changes to trunk. If it seems to be working, we can delete the lazy branch later. Thanks Stuart for setting that up and getting a bunch of key changes in. --Chouser --~--~-~--~~~---~--~~ 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 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: map literals, computed keys and side-effects
On Feb 17, 3:30 pm, Christian Vest Hansen karmazi...@gmail.com wrote: On Tue, Feb 17, 2009 at 9:08 PM, Christophe Grand christo...@cgrand.net wrote: Fixing array-map would make the two tests consistent but I'm not sure that (let [a (atom 0)] {(swap! a inc) 1 (swap! a inc) 2 }) should evaluate to {1 2}. That would make it two distinct issues, as I see it. One for array-map, and one for whether association happens before or after the keys have been evaluated. It would seem really strange to me if the following behavior is correct: user= (def m (array-map 1 1 1 2 1 3)) #'user/m user= (m 1) 1 user= (m 2) nil user= m {1 1, 1 2, 1 3} So I went ahead and opened an issue for that:http://code.google.com/p/clojure/issues/detail?id=83 Please don't create issues without getting a nod from me here first. These are bugs in user code. Map literals are in fact read as maps, so a literal map with duplicate keys isn't going to produce an evaluated map with distinct keys. If you create an array map with duplicate keys, bad things will happen. I'm not sure I want to slow down array-map in order to add the check. Rich --~--~-~--~~~---~--~~ 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 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: Fully lazy sequences are here!
That was fast! ;-) Rich, I am porting test_clojure and old 'cycle' worked as: (cycle []) = nil Currently: (cycle []) = java.lang.StackOverflowError Frantisek On Feb 17, 8:43 pm, Rich Hickey richhic...@gmail.com wrote: I've merged the lazy branch into trunk, SVN rev 1287 Please do not rush to this version unless you are a library/tool developer. Let them do their ports and chime in on their progress. Move only when the libs/tools you depend upon have been ported. Thanks to all for your feedback and input! Rich --~--~-~--~~~---~--~~ 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 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: Clojure Off-topic IRC channel
Since -social might imply the normal channel is .. err .. not (which would be most inaccurate!), how about #clojure-cafe? - Haskell has a Cafe forum / mailing list - Additional cute point: the first 16-bit of a Java class file is 0xCAFE Best regards, -- Michel S. On Feb 17, 11:27 am, Rayne disciplera...@gmail.com wrote: Names really weren't my priority here. I'll be happy to link -offtopic to another channel with a different name if someone thinks of a better name somewhere down the road ^_^. On Feb 17, 10:15 am, Chas Emerick cemer...@snowtide.com wrote: +1 I actually think that #clojure is very active. Of the channels I frequent/lurk in, only #git regularly surpasses #clojure in number of messages per (my) day. Maybe that says more about my irc interests, so take that as you will. #clojure-offtopic doesn't have much poetry to it, but I'll keep out of naming stuffs. - Chas On Feb 17, 2009, at 8:23 AM, Rayne wrote: A week or 2 ago, Lau_Of_DK asked me very nicely to stop talking so off- topic in #Clojure. I mentioned that we should have an Off-topic channel for people who would just like to talk, because just about every other language's channel on freenode has an off topic channel (#haskell-blah for instance). He said it has been discussed and because of the low volume of #clojure (which isn't so low if you think about it), it would not be a good idea. I just went along with that. But today I thought about it, and I haven't seen it discussed and if it has been discussed here before I'm sorry, but I'd like other peoples input on this. I feel that making an off topic channel for Clojurists would not effect the volume of #Clojure in any way. In fact I feel that it would remove any current, or future extensive off topic chatter in #Clojure and help to keep things on tract. If people want to talk off topic they can come to the off topic channel, and if they don't want to talk about #Clojure, they probably wouldn't be there in the first place. How would it effect #Clojure's volume? I personally think having an off topic channel is a great idea, but it's not my language and #Clojure isn't my channel. I have made a channel on freenode called #Clojure-Offtopic for now it is explicitly marked as unofficial and waiting for Rich Hickey's approval. If for some reason, you guys /really/ don't want an off topic channel, I have respect enough to remove the channel for you guys. I will not announce this channel in #Clojure until I have the communities approval. It seems I've attracted durka to the channel somehow though :p. I'm sorry if this topic isn't right for this group, but I'm not sure where else I should discuss it. -Rayne --~--~-~--~~~---~--~~ 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 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: map literals, computed keys and side-effects
On Tue, Feb 17, 2009 at 10:07 PM, Rich Hickey richhic...@gmail.com wrote: On Feb 17, 3:30 pm, Christian Vest Hansen karmazi...@gmail.com Please don't create issues without getting a nod from me here first. Ok. I won't. I must have overlooked the Similarly, please confirm a bug before making an entry. part. These are bugs in user code. Map literals are in fact read as maps, so a literal map with duplicate keys isn't going to produce an evaluated map with distinct keys. If you create an array map with duplicate keys, bad things will happen. I'm not sure I want to slow down array-map in order to add the check. My opinion is unchanged, even though I always end up being in the wrong when we argue. Rich -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
clojure.contrib.repl-ln vs. new lazy
Using clojure 1287, compiling clojure.contrib.repl-ln gives an error: user= (compile 'clojure.contrib.repl-ln) java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String; (repl_ln.clj:15) user= (st) [...] Caused by: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String; at clojure.core$generate_class__5435.invoke(genclass.clj:219) at clojure.core$gen_class__5516.doInvoke(genclass.clj:550) at clojure.lang.RestFn.invoke(RestFn.java:498) at clojure.lang.Var.invoke(Var.java:360) at clojure.lang.AFn.applyToHelper(AFn.java:197) at clojure.lang.Var.applyTo(Var.java:457) at clojure.lang.Compiler.macroexpand1(Compiler.java:4100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4167) ... 32 more nil user= The ns form that's failing is: (ns clojure.contrib.repl-ln (:gen-class) (:import (clojure.lang Compiler LineNumberingPushbackReader RT Var) (java.io InputStreamReader OutputStreamWriter PrintWriter) java.util.Date) (:require clojure.main) (:use [clojure.contrib.def :only (defmacro- defonce- defstruct- defvar-)])) Removing the (:gen-class) clause allows it to compile. This line looks important: at clojure.core$generate_class__5435.invoke(genclass.clj:219) --Steve smime.p7s Description: S/MIME cryptographic signature
Re: clojure.contrib.repl-ln vs. new lazy
On Feb 17, 2009, at 5:12 PM, Stephen C. Gilardi wrote: This line looks important: at clojure.core$generate_class__5435.invoke(genclass.clj:219) Turning on nil punning debugging with: cd clojure ant -Dclojure.assert-if-lazy-seq=true and testing with: user= (compile 'clojure.contrib.repl-ln) suggests that genclass.clj could use some lazy love. --Steve smime.p7s Description: S/MIME cryptographic signature
'nil 'false 'true - symbols or Clojure keywords?
Usual symbol: 'abc = abc (symbol? 'abc) = true (symbol abc) = abc (symbol? (symbol abc)) = true Special symbol: 'nil = nil (symbol? 'nil) = false (symbol nil) = nil (symbol? (symbol nil)) = true (= 'nil (symbol nil)) = false (= 'nil nil) = true We can see that (symbol nil) truly evaluates to symbol nil. On the other side, reader evalutes 'nil to nil (nothing). (The same holds true for 'false and 'true.) Is this consistent and correct behavior? If it is correct, page http://clojure.org/Reader could tell more about 'nil, 'false and 'true. Thank you, Frantisek --~--~-~--~~~---~--~~ 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 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: 'nil 'false 'true - symbols or Clojure keywords?
On Feb 17, 2009, at 5:48 PM, Frantisek Sodomka wrote: Is this consistent and correct behavior? If it is correct, page http://clojure.org/Reader could tell more about 'nil, 'false and 'true. It is correct. nil, true, and false are literals--they evaluate to themselves. They are a bit special in that if they were not literals, they would be symbols. All other literals are adorned somehow which makes it easy to see what they are: * Strings - Enclosed in double quotes. * Numbers - Always begin with a character in: + - 0 1 2 3 4 5 6 7 8 9 (and follow some rules after that) * Characters - preceded by a backslash * Keywords - preceded by a colon The remaining literals: * nil, true, and false These are already listed in the literals section at clojure.org/ Reader. I agree that a note emphasizing that these 3 literals are unusual because they're unadorned may be helpful. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: map literals, computed keys and side-effects
I don't understand your example: user= (class {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9}) clojure.lang.PersistentHashMap user= (class {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}) clojure.lang.PersistentArrayMap What governs which class {} will return? The number of arguments? --~--~-~--~~~---~--~~ 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 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: map literals, computed keys and side-effects
On Feb 17, 2009, at 6:24 PM, Timothy Pratley wrote: What governs which class {} will return? The number of arguments? Yes. The current implementation of Clojure's literal map reader returns a PersistentArrayMap if there are 8 entries or fewer and a PersistentHashMap otherwise. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Clojure Off-topic IRC channel
On Feb 17, 8:23 am, Rayne disciplera...@gmail.com wrote: A week or 2 ago, Lau_Of_DK asked me very nicely to stop talking so off- topic in #Clojure. I mentioned that we should have an Off-topic channel for people who would just like to talk, because just about every other language's channel on freenode has an off topic channel (#haskell-blah for instance). He said it has been discussed and because of the low volume of #clojure (which isn't so low if you think about it), it would not be a good idea. I just went along with that. But today I thought about it, and I haven't seen it discussed and if it has been discussed here before I'm sorry, but I'd like other peoples input on this. I feel that making an off topic channel for Clojurists would not effect the volume of #Clojure in any way. In fact I feel that it would remove any current, or future extensive off topic chatter in #Clojure and help to keep things on tract. If people want to talk off topic they can come to the off topic channel, and if they don't want to talk about #Clojure, they probably wouldn't be there in the first place. How would it effect #Clojure's volume? I personally think having an off topic channel is a great idea, but it's not my language and #Clojure isn't my channel. I have made a channel on freenode called #Clojure-Offtopic for now it is explicitly marked as unofficial and waiting for Rich Hickey's approval. If for some reason, you guys /really/ don't want an off topic channel, I have respect enough to remove the channel for you guys. I will not announce this channel in #Clojure until I have the communities approval. It seems I've attracted durka to the channel somehow though :p. I'm sorry if this topic isn't right for this group, but I'm not sure where else I should discuss it. -Rayne The IRC nazis are just that. IRC is on the internet. IRC is not some CIA/FBI stream of information. I think off-topic should be allowed in most IRC channels and in most it is. It is a virtual community. Community implies communal discussions. That sometimes veer from the core topic. I started out on freenode on #java and they were liberal about off-topic and it was a great way to interact with cool people. The more stand-offish channels are easily forgettable. There are really only two ways to run IRC, no off-topic or off-topic. The no off-topic channels suck. With that, I think it is silly to create a clojure-offtopic, offtopic should be OK sometimes in #clojure. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Bug: LazySeq.equiv()
Empty lazy seqs do not always compare as equal: user= (= (map inc nil) ()) false The problem is in IPersistentCollection equiv: user= (.equiv (map inc nil) ()) false --Chouser --~--~-~--~~~---~--~~ 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 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: Bug: LazySeq.equiv()
On Tue, Feb 17, 2009 at 8:37 PM, Chouser chou...@gmail.com wrote: Empty lazy seqs do not always compare as equal: user= (= (map inc nil) ()) false The problem appears to be when the first seq being compared is empty but not identical to the second collection. The attached patch fixes this and is I think correct. --Chouser --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~--- commit 9dd308c0151f74c262d498ac8086178e742d9eee Author: Chouser chou...@n01se.net Date: Tue Feb 17 20:44:52 2009 -0500 Fix LazySeq.equiv() for empty seqs. diff --git a/trunk/src/jvm/clojure/lang/LazySeq.java b/trunk/src/jvm/clojure/lang/LazySeq.java index 1769d43..fbc25cb 100644 --- a/trunk/src/jvm/clojure/lang/LazySeq.java +++ b/trunk/src/jvm/clojure/lang/LazySeq.java @@ -72,7 +72,12 @@ public class LazySeq extends AFn implements ISeq, List { public boolean equiv(Object o) { ISeq s = seq(); -return s == o || (s != null s.equiv(o)); +if( s == o ) +return true; +if( s != null ) +return s.equiv(o); +else +return ((IPersistentCollection)o).seq() == null; } public int hashCode() {
Re: clojure.contrib.repl-ln vs. new lazy
On Tue, Feb 17, 2009 at 5:33 PM, Stephen C. Gilardi squee...@mac.com wrote: Turning on nil punning debugging with: cd clojure ant -Dclojure.assert-if-lazy-seq=true and testing with: user= (compile 'clojure.contrib.repl-ln) suggests that genclass.clj could use some lazy love. I think this I have just the lazy love it needs... --Chouser --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~--- commit 68173e96e709707810c989669a0326a97259f8fe Author: Chouser chou...@n01se.net Date: Tue Feb 17 20:50:08 2009 -0500 lazy valentine for genclass diff --git a/trunk/src/clj/clojure/genclass.clj b/trunk/src/clj/clojure/genclass.clj index b7bb74f..43c076c 100644 --- a/trunk/src/clj/clojure/genclass.clj +++ b/trunk/src/clj/clojure/genclass.clj @@ -24,9 +24,9 @@ (let [[mm considered] (loop [mm mm considered considered - meths (concat - (seq (. c (getDeclaredMethods))) - (seq (. c (getMethods] + meths (seq (concat +(seq (. c (getDeclaredMethods))) +(seq (. c (getMethods)] (if meths (let [#^java.lang.reflect.Method meth (first meths) mods (. meth (getModifiers)) @@ -215,8 +215,8 @@ ;start class definition (. cv (visit (. Opcodes V1_5) (+ (. Opcodes ACC_PUBLIC) (. Opcodes ACC_SUPER)) cname nil (iname super) - (when interfaces - (into-array (map iname interfaces) + (when-let [ifc (seq interfaces)] + (into-array (map iname ifc) ;static fields for vars (doseq [v var-fields]
what is the new version of clj about?
Hi, I read a few messages on the new version. Could someone summarize the changes and the motivation behind? Thanks, sun --~--~-~--~~~---~--~~ 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 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: what is the new version of clj about?
http://clojure.org/lazy On Tue, Feb 17, 2009 at 8:54 PM, wubbie sunj...@gmail.com wrote: Hi, I read a few messages on the new version. Could someone summarize the changes and the motivation behind? Thanks, sun --~--~-~--~~~---~--~~ 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 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: what is the new version of clj about?
On Tue, Feb 17, 2009 at 8:56 PM, Jeffrey Straszheim straszheimjeff...@gmail.com wrote: http://clojure.org/lazy Also: http://blog.n01se.net/?p=39 I know, I'm shameless. --Chouser --~--~-~--~~~---~--~~ 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 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: what is the new version of clj about?
Not shameless ... you took the time to write it. It is on-topic. It should be shared. :) On Tue, Feb 17, 2009 at 9:04 PM, Chouser chou...@gmail.com wrote: On Tue, Feb 17, 2009 at 8:56 PM, Jeffrey Straszheim straszheimjeff...@gmail.com wrote: http://clojure.org/lazy Also: http://blog.n01se.net/?p=39 I know, I'm shameless. --Chouser --~--~-~--~~~---~--~~ 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 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: Clojure on CLR/DLR
On Tue, Feb 17, 2009 at 10:03 AM, Craig Andera craig.and...@gmail.com wrote: I'm up for suggestions on the name. The obvious ones: - Clojure.net - ClojureCLR - IronClojure (paralleling IronPython/IronRuby, unless MS has Iron trademarked.) - CLjR (too cute) Perhaps Rich will have a preference. He'll have to live with it longer than anyone and has branding/confusion issues to keep in mind. So, as a long-time .NET guy, IronClojure seems like the best name, in terms of making it obvious what it does: it's like IronRuby/Python, but it's Clojure. Failing that, it seems like NClojure fits the pattern of other JVM-ported efforts. I realize that there's already an Enclojure. Just to throw more chaff into the air: * CoCLR: Clojure on the CLR. (Maybe pronounced cochlear?) * Coc: Same as above. * CoNET: Clojure on .NET. * Icon: An Implementation of Clojure on .NET. * Ichor: I can't think of an acronym here, but I want to. :) Coc sounds similar to Coq, a theorem-prover system for Ocaml. I'm actually fond of CLjR, but oh well :) -- miʃel salim • http://hircus.jaiku.com/ IUCS • msa...@cs.indiana.edu Fedora • sali...@fedoraproject.org MacPorts • hir...@macports.org --~--~-~--~~~---~--~~ 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 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: clojure.contrib.repl-ln vs. new lazy
On Feb 17, 8:52 pm, Chouser chou...@gmail.com wrote: On Tue, Feb 17, 2009 at 5:33 PM, Stephen C. Gilardi squee...@mac.com wrote: Turning on nil punning debugging with: cd clojure ant -Dclojure.assert-if-lazy-seq=true and testing with: user= (compile 'clojure.contrib.repl-ln) suggests that genclass.clj could use some lazy love. I think this I have just the lazy love it needs... Patch applied - svn 1289 - thanks! Rich --~--~-~--~~~---~--~~ 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 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: Fully lazy sequences are here!
On Feb 17, 4:16 pm, Frantisek Sodomka fsodo...@gmail.com wrote: That was fast! ;-) Rich, I am porting test_clojure and old 'cycle' worked as: (cycle []) = nil Currently: (cycle []) = java.lang.StackOverflowError Fixed in svn 1290 - thanks for the report. Rich --~--~-~--~~~---~--~~ 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 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: Fully lazy sequences are here!
On Tue, Feb 17, 2009 at 3:47 PM, Chouser chou...@gmail.com wrote: On Tue, Feb 17, 2009 at 2:43 PM, Rich Hickey richhic...@gmail.com wrote: Please do not rush to this version unless you are a library/tool developer. Let them do their ports and chime in on their progress. Move only when the libs/tools you depend upon have been ported. Clojure-contrib svn rev 482 can now be compiled and built into a .jar with Clojure svn rev 1291. This includes patches to several contrib libs from several authors, but I assume not all of the contrib libs have been throughly tested yet. --Chouser --~--~-~--~~~---~--~~ 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 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: Clojure on CLR/DLR
My thanks to Rich for the suggestion to go public and for agreeing to include this as part of the Clojure community. Thanks to all for the encouragement. -- David On Feb 17, 2:55 pm, Rich Hickey richhic...@gmail.com wrote: The whole point of including David's work in contrib is to give people confidence that it is, in fact, Clojure, derived from the original sources, as is ClojureScript. Rebranding it is counterproductive. This will be a supported effort, part of the Clojure project, and a product of Clojure's community. CLR is a qualifier, Clojure is the brand. Rich --~--~-~--~~~---~--~~ 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 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: terminology question re: binding
On Feb 17, 2009, at 5:10 AM, Chouser wrote: I think that the strict usage is consistent with Clojure's binding macro, which binds a name to a new variable. Are you sure? It seems to me the most natural mapping from the CL concepts to Clojure is: CL name - Clojure symbol, name, or perhaps namespace entry CL variable - Clojure Var (or perhaps ref, atom, etc.) CL value or referent - Clojure value. Clojure's 'binding' macro does not change the connection from name to Var, but the one from Var to (effective, thread-local) value. I see that you are correct. Observe the following behavior: ; Common Lisp. We have no way to get ahold of the variable (reference) to which a ; name is bound. Dereferencing is automatic. However, with a dynamic ; variable we can access the symbol data structure associated with the name *PUNG*. (defvar *pung* 8) (defvar *foo* *pung*) ; Referent of *PUNG* assigned (defvar *bar* '*pung*) ; Note the quote here--assigning symbol *PUNG* ; Establish a new binding for *PUNG*. *BAR* changed as well. (let ((*pung* 9)) (list *pung* *foo* (symbol-value *bar*))) = (9 8 9) ; Clojure. We can access the reference itself via var. (def pung 8) (def foo pung) ; i.e., (deref (var pung)) or @#'pung (def bar (var pung)) ; binding changes value of pung--apparently not the variable itself, thus ; bar also reflects changed value. (binding [pung 9] (list pung foo @bar)) = (9 8 9) ; By contrast let binds pung to a new variable, which shadows the global. ; bar still refers to global pung (let [pung 9] (list pung foo @bar)) = (9 8 8) Do I have it right now? Aloha, David Sletten --~--~-~--~~~---~--~~ 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 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: terminology question re: binding
On Tue, Feb 17, 2009 at 11:48 PM, David Sletten da...@bosatsu.net wrote: ; Clojure. We can access the reference itself via var. (def pung 8) (def foo pung) ; i.e., (deref (var pung)) or @#'pung (def bar (var pung)) ; binding changes value of pung--apparently not the variable itself, thus ; bar also reflects changed value. (binding [pung 9] (list pung foo @bar)) = (9 8 9) ; By contrast let binds pung to a new variable, which shadows the global. ; bar still refers to global pung (let [pung 9] (list pung foo @bar)) = (9 8 8) Do I have it right now? The code and comments look right to me, but I'm not sure where that leaves us on the original question of terminology. I could say that the var named pung (user/pung, to be specific) has the root value 8, but was there anything bound there? And I can't deny that pung becomes bound to 9 since a macro named 'binding' was used. Does that imply that the var was bound to 8 earlier? Was the name 'pung' bound to the Var? Everything seems to have stopped making sense. Perhaps I shouldn't try to post this late at night. --Chouser --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Idiomatic Way to Write the Following:
Hi, I'm wondering if there's a terser more idiomatic way to write the following. I want to get a new vector with the specified indexes removed. I found myself doing this often enough to warrant writing my own function for this but I would be much happier if there's some terse way of expressing this using the standard clojure functions. (defn remove_at [coll indexes] (map second (remove #(some #{(first %)} indexes) (map vector (iterate inc 0) coll Thanks a lot -Patrick --~--~-~--~~~---~--~~ 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 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: Idiomatic Way to Write the Following:
Is using subvec for something like this a bad idea? On Wed, Feb 18, 2009 at 12:38 AM, CuppoJava patrickli_2...@hotmail.comwrote: Hi, I'm wondering if there's a terser more idiomatic way to write the following. I want to get a new vector with the specified indexes removed. I found myself doing this often enough to warrant writing my own function for this but I would be much happier if there's some terse way of expressing this using the standard clojure functions. (defn remove_at [coll indexes] (map second (remove #(some #{(first %)} indexes) (map vector (iterate inc 0) coll Thanks a lot -Patrick --~--~-~--~~~---~--~~ 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 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: Idiomatic Way to Write the Following:
Mmm, subvec doesn't quite seem to do the same thing. I want a function that removes certain indexes of a vector: eg. (remove_at [1 2 3 4 5 6] 0 3) = [2 3 5 6] --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Performance of (fn [] ...)?
Hi, I've noticed that I'm creating a lot of maps of functions, and I'm wondering if there's a performance penalty for this. ie. (defn create_fn [] (fn [] (println hi))) ((create_fn)) --- Does this create a new function every-time it's called? Or is the function code cached somewhere? How much of a performance penalty does this incur? Thanks for the help -Patrick --~--~-~--~~~---~--~~ 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 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: Performance of (fn [] ...)?
new MBP 2.53ghz (defn create-fn [] (fn [] (println hi))) (time (dotimes [x 4000] (create-fn))) Elapsed time: 1034.409 msecs Hopefully you don't need 40,000,000 functions in less than a second ;) On Wed, Feb 18, 2009 at 1:16 AM, CuppoJava patrickli_2...@hotmail.comwrote: (defn create_fn [] (fn [] (println hi))) --~--~-~--~~~---~--~~ 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 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: Idiomatic Way to Write the Following:
My point was that you could use subvec to do vector splicing and build your remove function off of that. I'm sure the more experienced Clojurians can chime in on what is the most idiomatic form. On Wed, Feb 18, 2009 at 1:10 AM, CuppoJava patrickli_2...@hotmail.comwrote: Mmm, subvec doesn't quite seem to do the same thing. I want a function that removes certain indexes of a vector: eg. (remove_at [1 2 3 4 5 6] 0 3) = [2 3 5 6] --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---