Re: cool compiler-project?
There is a size limit on methods on the jVM. partial-evaluator would be a cool project, I think. On Thu, Aug 19, 2010 at 6:38 AM, Tim Daly d...@axiom-developer.org wrote: Could the compiler insert phantom method bodies around classes? Or does the JVM insist that you can't lie about the code structure? Am I being too lispish for the JVM? Clearly the JVM needs to look up some factoid out of the method body in order to recur so I'm suggesting that the whole set of classes get wrapped in a phantom method. The code that comes out of the compiler does not need to mirror the code that went into the compiler. That's the whole point of doing compiler optimizations. Perhaps a literature pointer could make the restriction clear. Tim Daly Kevin Downey wrote: only in the cases already handled by recur. jvm's goto instruction only works within method bodies On Wed, Aug 18, 2010 at 6:24 PM, Tim Daly d...@axiom-developer.org wrote: Write a compiler routine to detect tail recursion. It is my (limited) understanding that Java can perform tail recursion elimination but only under limited conditions. Is there a way to detect tail recursion in Clojure and dynamically rewrite the code to do real recursion rather than using recur? Is your solution general enough? Mark Derricutt wrote: Or a native dalvik compiler! -- Pull me down under... On Thu, Aug 19, 2010 at 10:37 AM, Jules julesjac...@gmail.com mailto:julesjac...@gmail.com wrote: Or a Clojure to Javascript compiler. So many interesting projects! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: What is the reason Lisp code is not written with closing parenthesis on new lines?
In any Lisp, I think parens are for the compiler and indentation is for humans. Regards, Shantanu On Aug 19, 10:20 am, Rayne disciplera...@gmail.com wrote: It isn't helpful at all to me. My eyes bleed when I see code written like that. It may be helpful to some people, but I don't see the point when I have an editor that can match parens for me without any real work on my part. The parens aren't something I feel I need to maintain, because between paredit and paren matching, I never have problems with them. On Aug 18, 4:09 am, michele michelemen...@gmail.com wrote: Wouldn't that make it easier to keep track of them. Example: (defn myfn-a [a b] (if (zero? b) a (recur (afn (bfn (...)) a) (dec b (defn myfn-b [a b] (if (zero? b) a (recur (afn (bfn (...)) a) (dec b) ) ) ) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Impedance mismatch
I'm not trying to start a language war, especially since Clojure is trying to be both a Java and a Lisp. This is more of a user experience report. I'd be more interested in hearing about your experiences and where you find an impedance mismatch than having a Lisp vs Java discussion. Where do you struggle, not which is better. I am trying to understand why lisp is more productive (for me) than java. I am also trying to understand whether Clojure is closer to lisp (e.g. faster for me) or java (e.g. slower for me). Maybe you don't feel the mismatch or you are equally productive in both. Your OODA-loop times [1] may vary. Televisions vs Monitors. I'm trying to port some Java code to Clojure and I'm running into an interesting snag. In Clojure it is possible to add type hints and I thought this might be a good idea. I no longer believe it is. I've also gotten some insight about why I find my OODA loop in lisp is so much faster than it is in Java. It comes down to types. In Java, types are associated with the boxes, so you have a box and you give it a label, say Television. Only a television can go in that box. In Lisp, types are associated with the thing itself, so a television is always a Television. You can put it in any box. Now I find that I want to change a television (old school) and make it into a monitor screen (new school). In Lisp, I just change the object and everything just works. My OODA loop is measured in seconds. In Java I find that I have to make systemic changes to multiple files because I pass around the Television-boxes and I can't put monitors in Television boxes (they are not IS-A so inheritance fails, the exceptions they throw are different, the method signatures are different, etc). If Television is a widely used thing then I end up changing lots of little files. My OODA loop is around 10 minutes or more for a change like this. I would have thought that the work necessary to make a change from a television to a monitor would be the same in either case but it is not. Most of the things I do to a television (plug it in, turn it on, move it, etc) are not specific to Television and the lisp routines are agnositc. The Java routines are tightly signatured. In theory, IF the Java code were structured properly then it would be just as easy to change a Television into a Monitor but who knew that anyone would replace their Television with some strange device? I will be interested to see if Clojure comes down on the side of Lisp in this, or if Java types bleed over in non-lispish ways. NULL, EMPTY LIST, BOOLEANS, oh my! Another hint of this impedance mismatch is the whole discussion of boxed vs unboxed booleans. One thing that lisp got absolutely right is the unification of the symbol nil, the empty list (), and the boolean false. Clojure seems to have waffled on this point and I think it will cause grief in subtle places. In Java I find it makes me insane to try to use an iterator over a declared collection and have it fail due to null. For instance, SetGraphNode nodes = null; (insert lots of code/classes/files) for (GraphNode n : nodes) { } fails! So I have to protect the for with if (nodes != null) { for (GraphNode n : nodes) {...} } In other words, the 'for' iterator construct does not know that 'null' is a valid value for 'nodes' even though 'null' is a valid value for anything. The Java solution to this, proposed by a coworker, is to create a GraphNodeFactory which properly initializes all substructures. That's a great idea but deeply changes the existing design. The substructures are dynamically discovered so GraphNodeFactory would not know them. I understand why Clojure did not do the classic lisp unification but tries to keep the Java false boolean idea around but I find that it makes coding somewhat more tedious. In Clojure, nil does not map to false in some cases and it always comes as a surprise to me. I know that Scheme broke the unification, which always surprises me and why I don't code in Scheme. I'm trying to give Clojure the benefit of the doubt. Tim Daly [1] http://en.wikipedia.org/wiki/OODA_loop -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: cool compiler-project?
+1Dalvik compiler On 19 août, 02:52, Mark Derricutt m...@talios.com wrote: Or a native dalvik compiler! -- Pull me down under... On Thu, Aug 19, 2010 at 10:37 AM, Jules julesjac...@gmail.com wrote: Or a Clojure to Javascript compiler. So many interesting projects! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Impedance mismatch
In which situation nil is not treated as false in Clojure? If I understand well, Clojure separates nil/false from (). In particular, if you use next and not rest, your iteration example will work if translated into Clojure. empty? works in all case and is not ugly either. For the java typing story, I think this problem is one of the cause of the big activity of Clojure, JRuby, Groovy and the like. I find that I write very little type annotations in Clojure, mainly on interfaces, and never far away from a method call on that interface. (To prevent a call to go through reflection). In practice, it only prevents me from using the same method call for a method of the same name in another interface. It is not something that I often (I have no memory of any case) want to do, even if I understand that for people coming from a Ruby/Python background, it can be annoying. These calls to an interface are in a first layer above the JVM and tend to be rare in Clojure programs. (Library interface, mostly) Best, Nicolas. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Impedance mismatch
On Thu, Aug 19, 2010 at 12:36 AM, Tim Daly d...@axiom-developer.org wrote: I am trying to understand why lisp is more productive (for me) than java. Let me go off at a bit of a tangent and then I'll answer some of your questions. First off, I currently do mostly web application development and I do it in CFML. I use Railo as my primary CFML engine. It's a free open source (LGPL) JBoss community project that dynamically compiles CFML to JVM bytecode and it's very fast. For those not familiar with CFML - or who only know it from olden days - it's a tag-based templating language for web pages and (now) a fully script-based (C-like) dynamic language for objects on the back end. I am very productive in CFML, much more so than Java. I believe it's for the same reasons you state (the OODA-loop, primarily). CFML can be written in a more Java style with full typing (although it's all runtime checked) or no typing (closer to Clojure style). It's easy to change Television to Monitor if you've used the Clojure style of programming (which I do - types are for the birds :) So, productivity comes from a number of things that speak to the abstraction level of the language (and the code). My experience - with lots and lots of languages now, after OMG 30 years of doing this :( - is that untyped languages (or loosely typed languages) are more abstract and more productive. In addition, languages that behave like interpreted / scripted languages (i.e., where the explicit edit-compile-test cycle is hidden) are more productive. Hopefully that supports your Lisp more productive than Java hypothesis. I also find Scala more productive than Java because, although it has the edit-compile-test cycle and strong typing, it has inferred types and a lot more language-level abstractions than Java (and much less ceremony). I also find Groovy more productive than Java because it's a dynamically typed language and has less of the ceremony of Java. The only thing preventing me being more productive in Clojure is a lack of familiarity that I'm sure will come over the next year as I use it more... -- Sean A Corfield -- (904) 302-SEAN Railo Technologies, Inc. -- http://getrailo.com/ An Architect's View -- http://corfield.org/ If you're not annoying somebody, you're not really alive. -- Margaret Atwood -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Compile works with 1.1, fails with 1.2.0-RC3
I'm trying to compile a program, with source files as follows. com/minibar/PmsSimulator.clj -- containing these lines: (ns com.minibar.PmsSimulator (:require [com.minibar :as mb] ...etc) (:load pmssim/util ...etc) (:gen-class)) ...etc where the file com/minibar/pmssim/util.clj contains these lines: (ns com.minibar.PmsSimulator (:require [com.minibar :as mb])) ... (mb/getProgArg :foobar) ...etc The com.minibar namespace is a separately compiled library (getProgArg gets program args by keyword). This library compiles fine with 1.2.0- RC3. I am using Ant to do this, with a task like this: java classname=clojure.lang.Compile classpath pathelement location=libs/clojure-1.2.0-RC3.jar / pathelement location=libs/clojure-contrib-1.2.0-RC3.jar / ...etc /classpath sysproperty key=clojure.compile.path value=${classes.dir}/ arg value=com.minibar.PmsSimulator/ /java The above compiles fine with Clojure 1.1, but fails to compile with 1.2.0-RC3, with this exception: [java] Compiling com.minibar.PmsSimulator to classes [java] java.lang.Exception: No such var: mb/getProgArg (util.clj: 85) I happen to be doing all this with Eclipse CCW, but that's irrelevant I think. Has anyone else seen anything like this? 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Compile works with 1.1, fails with 1.2.0-RC3
Hi, On 19 Aug., 13:05, timc timgcl...@gmail.com wrote: com/minibar/PmsSimulator.clj -- containing these lines: (ns com.minibar.PmsSimulator (:require [com.minibar :as mb] ...etc) (:load pmssim/util ...etc) (:gen-class)) ...etc where the file com/minibar/pmssim/util.clj contains these lines: (ns com.minibar.PmsSimulator (:require [com.minibar :as mb])) ... (mb/getProgArg :foobar) ...etc This should just be (in-ns 'com.minibar.PmsSimulator). Any require or use should be moved to the master ns in com/minibar/ PmsSimulator.clj. ns and in-ns are not equivalent. There should be just one ns. Use in-ns to switch namespaces (eg. at the top of a :load'ed file). I can't say for sure that this is the root cause, but compiling a namespace which redefines itself when loading somehow asks for trouble. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Today's clojure trick question
Armando~ Libraries that target JRE 1.2 compatibility, will not call `Boolean.valueOf(var)` internally. Instead they will call `new Boolean(var)`. If they return those results to modern java code, it will unbox correctly into either true or false and thus work as expected in constructs of the form: if (old_library_call()) { // handle true } else { // handle false } If clojure's `if` form does not correctly unbox Booleans in the same manner, then that really should be viewed as a bug in Clojure. As these libraries are not likely to change to using the newer `Boolean.valueOf()` since that break compatibility. Yes, they could create their own static factory for Booleans and call that instead, but I don't think consumers of the library are going to want to figure out (the hard way) that they need to hack their library to use it from Clojure. Matt On Wed, Aug 18, 2010 at 4:07 PM, Armando Blancas armando_blan...@yahoo.comwrote: I don't see what the concern may be. Can you elaborate? On Aug 18, 10:04 am, Matt Fowles matt.fow...@gmail.com wrote: All~ Boolean.valueOf() was added in 1.4. While that seems ancient, some older libraries use 'new Boolean()' because they maintain 1.2 compatibility. It seems like Clojure should take more care when it unboxes Booleans... Matt On Wed, Aug 18, 2010 at 12:57 PM, Nicolas Oury nicolas.o...@gmail.com wrote: I am not an expert. Is it possible on some JDK to put a breakpoint on Boolean constructor and look at the stack? Or you can't put a breakpoint on standard library? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com clojure%2bunsubscr...@googlegroups.comclojure%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Bug: contains? doesn't work on transient maps or sets
Just came across this problem on RC3. Here is a fix: diff --git a/src/jvm/clojure/lang/RT.java b/src/jvm/clojure/lang/RT.java index 9aea629..5e67449 100644 --- a/src/jvm/clojure/lang/RT.java +++ b/src/jvm/clojure/lang/RT.java @@ -678,7 +678,11 @@ static public Object contains(Object coll, Object key){ else if(key instanceof Number (coll instanceof String || coll.getClass().isArray())) { int n = ((Number) key).intValue(); return n = 0 n count(coll); - } + } else if(coll instanceof ITransientSet) + return ((ITransientSet) coll).contains(key) ? T : F; + else if(coll instanceof ILookup) + return ((ILookup) coll).valAt(key) != null ? T : F; + return F; } On Aug 9, 2010, at 3:45 PM, Nicolas Oury wrote: Does someone know if there is a ticket open for this already? Best, Nicolas. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: What is the reason Lisp code is not written with closing parenthesis on new lines?
Thanks everyone for the your answers (and the internal debates). I will not put closing parenthesis on new lines. Even though the editor helps me with the parenthesis, there have been situations - while editing inside functions - that I had to count them. Here is an idea (by Harold A.), I will try: The trick I did back when I was actively programming LISP in the '80s was to depend on EMACS to get the indentation right and then each closing paren matches a level of indentation. You'll note in your example above that there are 4 closing parens and four levels of indentation including 0 for the first paren. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Emacs auto-complete plugin for slime users
Great plugin- thanks steve i applied your patch but still throws on clojure.main and on some (import '(java.util.concurrent MHOOO's code above seems to resolve my errors. thanks -doug On Aug 18, 1:44 pm, MHOOO thomas.karol...@googlemail.com wrote: I can get rid of those errors by evaling this in the repl. Does this work for you as well?: (do (require 'clojure.contrib.with-ns) (clojure.contrib.with-ns/with-ns 'swank.commands.basic (defn- describe-to-string [var] {:pre [(var? var)]} (with-out-str (print-doc var))) (defn- describe-symbol* [symbol-name] (with-emacs-package (let [v (try (ns-resolve (maybe-ns *current-package*) (symbol symbol-name)) (catch ClassNotFoundException e nil))] (if (and v (var? v)) (describe-to-string v) (str Unknown symbol symbol-name))) On Aug 17, 10:38 am, Stefan Kamphausen ska2...@googlemail.com wrote: Hi, just yesterday I took a first look at auto-complete together with your slime auto completion sources. I'm encountering some Exceptions, though, If I'm in a .clj-buffer and start typing (clojure. and then wait for the auto completion to popup I see a list of possible completions like, e.g., clojure.set, clojure.xml and more, and then an Exception pops up: clojure.set [Thrown class java.lang.ClassNotFoundException] Restarts: 0: [QUIT] Quit to the SLIME top level 1: [ABORT] ABORT to SLIME level 0 Backtrace: 0: java.net.URLClassLoader$1.run(URLClassLoader.java:202) 1: java.security.AccessController.doPrivileged(Native Method) 2: java.net.URLClassLoader.findClass(URLClassLoader.java:190) 3: clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java: 58) 4: java.lang.ClassLoader.loadClass(ClassLoader.java:307) 5: java.lang.ClassLoader.loadClass(ClassLoader.java:248) 6: java.lang.Class.forName0(Native Method) 7: java.lang.Class.forName(Class.java:247) 8: clojure.lang.RT.classForName(RT.java:1566) 9: clojure.lang.Compiler.maybeResolveIn(Compiler.java:5700) 10: clojure.core$ns_resolve.invoke(core.clj:3380) 11: swank.commands.basic$describe_symbol_STAR_.invoke(basic.clj:184) 12: swank.commands.basic $eval880$documentation_symbol__881.invoke(basic.clj:201) 13: clojure.lang.Var.invoke(Var.java:365) 14: user$eval1927.invoke(NO_SOURCE_FILE) 15: clojure.lang.Compiler.eval(Compiler.java:5424) 16: clojure.lang.Compiler.eval(Compiler.java:5391) 17: clojure.core$eval.invoke(core.clj:2382) 18: swank.core$eval_in_emacs_package.invoke(core.clj:94) 19: swank.core$eval_for_emacs.invoke(core.clj:241) 20: clojure.lang.Var.invoke(Var.java:373) 21: clojure.lang.AFn.applyToHelper(AFn.java:169) 22: clojure.lang.Var.applyTo(Var.java:482) 23: clojure.core$apply.invoke(core.clj:540) 24: swank.core$eval_from_control.invoke(core.clj:101) 25: swank.core$sldb_loop$fn__401.invoke(core.clj:203) 26: swank.core$sldb_loop.invoke(core.clj:200) 27: swank.core$invoke_debugger.invoke(core.clj:216) 28: swank.core$sldb_debug.invoke(core.clj:220) 29: swank.core$eval_for_emacs.invoke(core.clj:279) 30: clojure.lang.Var.invoke(Var.java:373) 31: clojure.lang.AFn.applyToHelper(AFn.java:169) 32: clojure.lang.Var.applyTo(Var.java:482) 33: clojure.core$apply.invoke(core.clj:540) 34: swank.core$eval_from_control.invoke(core.clj:101) 35: swank.core$spawn_worker_thread$fn__455$fn__456.invoke(core.clj: 300) 36: clojure.lang.AFn.applyToHelper(AFn.java:159) 37: clojure.lang.AFn.applyTo(AFn.java:151) 38: clojure.core$apply.invoke(core.clj:540) 39: swank.core$spawn_worker_thread$fn__455.doInvoke(core.clj:296) 40: clojure.lang.RestFn.invoke(RestFn.java:398) 41: clojure.lang.AFn.run(AFn.java:24) 42: java.lang.Thread.run(Thread.java:619) Another one shows up if I hit TAB (bound to indent-for-tab-command) before the completion shows up I get a No message. [Thrown class java.lang.NullPointerException] Restarts: 0: [QUIT] Quit to the SLIME top level Backtrace: 0: clojure.lang.Compiler$FnMethod.parse(Compiler.java:4290) 1: clojure.lang.Compiler$FnExpr.parse(Compiler.java:3173) 2: clojure.lang.Compiler.analyzeSeq(Compiler.java:5367) 3: clojure.lang.Compiler.analyze(Compiler.java:5190) 4: clojure.lang.Compiler.analyze(Compiler.java:5151) 5: clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3057) 6: clojure.lang.Compiler.analyzeSeq(Compiler.java:5371) 7: clojure.lang.Compiler.analyze(Compiler.java:5190) 8: clojure.lang.Compiler.analyze(Compiler.java:5151) 9: clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:4670) 10: clojure.lang.Compiler$FnMethod.parse(Compiler.java:4328) 11: clojure.lang.Compiler$FnExpr.parse(Compiler.java:3173) 12: clojure.lang.Compiler.analyzeSeq(Compiler.java:5367) 13:
Re: Program design
You should look at Clojure 1.2 protocols and records which provides an easy way to do polymorphism on types. See http://clojure.org/protocols. On 18 August 2010 08:25, Mark Engelberg mark.engelb...@gmail.com wrote: I think the easiest way to port OO code would be to use Clojure's multimethods, dispatching on the type of the first argument. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Feedback on idiomatic clojure
A few remarks: ## begin (defn f-to-seq[file] (with-open [rdr (java.io.BufferedReader. (java.io.FileReader. file))] (doall (line-seq rdr Do you need the doall? (defn str-sort[str] (if (nil? str) str (String. (into-array (. Character TYPE) (sort str) (and str (String. (into-array (. Character TYPE) (sort str (if str is nil this will return nil) (defn anagram-add[anagrams akey word] (if (empty? (get anagrams akey)) (assoc anagrams akey (hash-map :count 1, :words (list word))) (update-in (update-in anagrams [akey :count] inc) [akey :words] conj word))) You could use a literal {:count 1 :words (list words)} instead of hash-map I believe that (get anagrams akey) will give nil in case there is known. If it is the case (or (get anagrams key) ...) will be more readable. (update-in ...) = (- anagrams (update-in [akey :count] inc) (update-in [akey :words] conj word)) I will have a look to the rest of the program later. Best, Nicolas. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Impedance mismatch
On Thu, Aug 19, 2010 at 3:36 AM, Tim Daly d...@axiom-developer.org wrote: Televisions vs Monitors. This is the whole point of deftype/defrecord and protocols. To get the absolute best performance of the platform without having the pollute your code with type information. For example prior to 1.2 I had to use javax.vecmath.Vector2D and litter my functions with type-hints. Now I can just use a library like cantor (http://github.com/ztellman/cantor), get the exact same perf, and not have to think about putting type information anywhere. One thing that lisp got absolutely right is the unification of the symbol nil, the empty list (), and the boolean false. Clojure seems to have waffled on this point and I think it will cause grief in subtle places. nil, the empty list, and boolean false are not equal, because they simply aren't. I haven't seen many cases where this is a problem in practice. (doall (map inc nil)) (doall (map inc [])) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Feedback on idiomatic clojure
Hi, here my turn. Comments inline. Hope this helps. Sincerely Meikel (defn f-to-seq [file] (with-open [rdr (java.io.BufferedReader. (java.io.FileReader. file))] (doall (line-seq rdr ; Yes. doall is required here. Alternatively you can wrap the whole thing ; in the with-open. Then you can process also larger files without keeping ; all data in memory. YMMV. (defn str-sort [string] (when string (apply str (sort string ; One can also skip the when here. Then nil input returns an empty string. ; Whether that is better depends on the usage of the return value. YMMV. ; (if (nil? x) x ...) is usually written as (when x ...). (defn str-to-lower [string] (when string (.toLowerCase string))) (defn anagram-add [anagrams akey word] (if (contains? anagrams akey) (- anagrams (update-in [akey :count] inc) (update-in [akey :words] conj word)) (assoc anagrams akey {:count 1 :words [word]}))) ; I would prefer vectors over lists to store stuff. You get nice ; things for free, like O(1) appending, O(1) reverse, O(1) random ; access, ... (defn word [s] (first s)) ; or: (def word first) ; not needed for my solution (def normalise (comp str-to-lower str-sort)) (defn build-anagrams [words] (reduce #(anagram-add %1 (normalise %2) %2) {} words)) ; Looping with an accumulator, just returning the latter when the ; input is exhausted cries for reduce. (defn print-anagram [v] (println (str (:count (second v)) (first v) : (:words (second v) ; one could use destructuring to access things. (defn print-anagram [anagram] (let [[normal-form {:keys [count words]}] anagram] (println (str count normal-form : words (defn print-anagrams [ana] (doseq [v ana] (print-anagram v))) ; more descriptive names would be good, I guess (defn anagram-key [elem] (- (:count (second elem ; the minus should take care of the reverse? (def *words* (f-to-seq /usr/share/dict/web2)) (def *anagrams* (sort-by anagram-key (build-anagrams *words*))) (print-anagrams (take 10 *anagrams*)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Impedance mismatch
David Nolen wrote: On Thu, Aug 19, 2010 at 3:36 AM, Tim Daly d...@axiom-developer.org mailto:d...@axiom-developer.org wrote: Televisions vs Monitors. This is the whole point of deftype/defrecord and protocols. To get the absolute best performance of the platform without having the pollute your code with type information. For example prior to 1.2 I had to use javax.vecmath.Vector2D and litter my functions with type-hints. Now I can just use a library like cantor (http://github.com/ztellman/cantor), get the exact same perf, and not have to think about putting type information anywhere. I admit my lack of understanding of protocols (mentioned in another thread). I'll study them in more detail. One thing that lisp got absolutely right is the unification of the symbol nil, the empty list (), and the boolean false. Clojure seems to have waffled on this point and I think it will cause grief in subtle places. nil, the empty list, and boolean false are not equal, because they simply aren't. I haven't seen many cases where this is a problem in practice. (doall (map inc nil)) (doall (map inc [])) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: cool compiler-project?
+1 on Dalvik compiler :) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Feedback on idiomatic clojure
Meikel's suggestions are all good and I would follow them. There are a number of built-in functions you can take advantage of if you're using 1.2 (they're also available in contrib for 1.1): clojure.string/lower-case clojure.java.io/reader -- obviates java.io.BufferedReader and friends: (reader /usr/share/dict/words) As a point of comparison, I did a similar code kata recently. I've posted it here, with a few lines added to show the top 10: http://gist.github.com/537945 It runs in a couple seconds on my machine. For maximum speed, transients might help. Justin On Aug 18, 6:46 pm, Damon Snyder drsny...@gmail.com wrote: Hi Everyone, I'm looking for some feedback on a small get-your-feet wet program I wrote in clojure (my first). In particular, I hope to get feedback on how to better make use of clojure's data structures and functional programming in general. Below is the toy program and the sample output. It reads in words from the OS X dictionary file, catalogs the anagrams, and then prints out the top ten by frequency. Although performance is not my primary concern here, it is a bit slow. It takes about 15s on my mac book pro. As an example, is this the proper way to update multiple fields at once in a nested hash-map: (update-in (update-in anagrams [akey :count] inc) [akey :words] conj word))) I understand this as returning an copy of an updated copy of an updated copy. Any feedback would be appreciated. Thanks, Damon ## begin (defn f-to-seq[file] (with-open [rdr (java.io.BufferedReader. (java.io.FileReader. file))] (doall (line-seq rdr (defn str-sort[str] (if (nil? str) str (String. (into-array (. Character TYPE) (sort str) (defn str-to-lower[str] (if (nil? str) str (.toLowerCase str))) (defn anagram-add[anagrams akey word] (if (empty? (get anagrams akey)) (assoc anagrams akey (hash-map :count 1, :words (list word))) (update-in (update-in anagrams [akey :count] inc) [akey :words] conj word))) (defn word[seq] (first seq)) (defn build-anagrams[seq] (loop [seq seq akey (str-sort (str-to-lower (word seq))) anagrams {}] (if (empty? seq) anagrams (recur (rest seq) (str-sort (str-to-lower (word (rest seq (anagram-add anagrams akey (word seq)) (defn print-anagram[v] (println (str (:count (first (rest v))) (first v) : (:words (first (rest v)) (defn print-anagrams[ana] (doseq [v ana] (print-anagram v))) (defn anagram-key[elem] (:count (first (rest elem (def *words* (f-to-seq /usr/share/dict/web2)) (def *anagrams* (sort-by anagram-key (build-anagrams *words*))) (print-anagrams (take 10 (reverse *anagrams*))) ## output 11 agnor: (Ronga rogan organ orang Orang nagor groan grano goran argon angor) 10 aelps: (speal spale slape sepal saple salep Pales Lepas lapse Elaps) 9 eerst: (tsere terse stree stere steer reset reest estre ester) 9 aeerst: (teaser staree seater saeter reseat Eastre easter Easter asteer) 9 aacinr: (narica crania Crania carina Carian canari Canari arnica acinar) 9 acert: (trace recta react creta creat crate cater carte caret) 8 ailr: (rial rail lira liar lari Lari lair aril) 8 aelpt: (tepal pleat plate petal pelta patel palet leapt) 8 airst: (Trias tisar tarsi stria stair sitar astir arist) 8 aemrt: (Trema trame terma tamer ramet metra mater armet) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Emacs auto-complete plugin for slime users
On Thu, Aug 19, 2010 at 6:21 AM, Steve Purcell st...@sanityinc.com wrote: I guess Phil's very busy, but if he can apply this patch, then the regular swank-clojure 1.3.0-SNAPSHOT on clojars should end up containing the fix. Just applied this patch and pushed to github and clojars. Thanks! -Phil -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: cool compiler-project?
On Thu, Aug 19, 2010 at 6:44 AM, Allen Johnson akjohnso...@gmail.com wrote: +1 on Dalvik compiler :) This might be kind of boring--I suspect you'd just have to port the asm library that Clojure depends on to Dalvik. I wonder if there's not already an effort started to do this, since Clojure's not the only user of asm. Of course there'd probably be work to optimize Clojure to work better with Dalvik's JIT etc. -Phil -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: What is the reason Lisp code is not written with closing parenthesis on new lines?
On Aug 18, 3:26 pm, Nicolas Oury nicolas.o...@gmail.com wrote: There is no law. Do what is best for you. But there OUGHT to be a law. Adam -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN: Clojure User Group Meeting Today (Thurs)
The National Capital Area Clojure User Group (CAP CLUG) is meeting tonight (Thurs) at: FGM 12021 Sunset Hills Road Suite 400 Reston, VA Pizza and other refreshments will be served at 6:15 PM, and the presentations will begin at about 6:30 PM. We would love to have any and all who can make it, but please do sign up at the CAP CLUG meetup site: (http://www.meetup.com/Cap-Clug) So that we know how much pizza to order! We've got two things lined up this week: First Michael Fogus will be talking about the new features in Clojure 1.2. Second, we are going to do a group get Clojure setup on your computer therapy session. Bring your laptop and leave with Clojure. Hope to see you there! Russ -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: FSM
On Aug 16, 3:55 am, ngocdaothanh ngocdaoth...@gmail.com wrote: I have used Erlang's gen_fsm and like it very much:http://erlang.org/doc/design_principles/fsm.html I want to write a game in Clojure and I need a FSM library (best if it supports timeout event). I would like to ask if there is any Java (or Clojure?) FSM library that works well with Clojure. Thanks. I've not used it state machines in Clojure but I just found this thread while searching for something else: http://groups.google.com/group/clojure/browse_thread/thread/ec529d99e1c37de1/19e750580d203158 Saul -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Clojure Conj Questions
Well, courtesy of HN the cat's out of the bag: http://first.clojure-conj.org/ What is the ballpark price? I think this would help a lot of people determine if they can go. Also, will there be cake? If this is Clojure's birthday party, there had better be cake. Just sayin' -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Clojure 1.2 Release
I'm pleased to announce today the release of Clojure 1.2. http://clojure.org/downloads For maven/leiningen users, your settings to get the beta from build.clojure.org/releases are: :dependencies [[org.clojure/clojure 1.2.0] [org.clojure/clojure-contrib 1.2.0] This release includes many significant new features, such as protocols and datatypes; enhancements to existing features like the sequence library, destructuring and agents; support for annotations, etc. In addition, it incorporates many enhancements first developed and nurtured in clojure-contrib like I/O, string and pretty printing facilities. This release reflects the work of many people in addition to myself, and I'd like to thank all of the contributors who've submitted fix and enhancement patches, and everyone in the community who has participated in terrific dialog that surrounds the development and use of Clojure. Congrats and thanks to the contrib authors whose work has made it into the release: Chas Emerick Tom Faulhaber Stephen Gilardi Christophe Grand Stuart Halloway Chris Houser David Liebke Michel Salim Stuart Sierra I'd especially like to thank Stuart Halloway and the rest of the Clojure/core team for their tireless effort in authoring, screening and applying patches, setting up build machines, monitoring the mailing list, cutting releases etc. Their help greatly facilitates my ability to concentrate on the core design issues, and builds the foundation for increasing community involvement. A lot of work goes into Clojure. The team's effort is enabled and funded by the Clojure/ core practice (http://clojure.com). The full list of enhancements and changes is here: http://github.com/clojure/clojure/blob/1.2.x/changes.txt and the fixed tickets are here: http://www.assembla.com/spaces/clojure/tickets?milestone_id=149827tickets_report_id=5 What's next? Plenty! There are a few fixes and enhancements too impactful to squeeze into this release that we hope to get out there ASAP. I've done a ton of work already on enhanced primitive support and call linkage that will be moving into master. Design work is proceeding on many fronts. I'm looking forward to the increasing capability and maturity of Clojure, and the growth of the community. Thanks to all involved! 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
Congratulations! Thanks to everybody who worked on this masterpiece. Best. Language. Ever. On Aug 19, 10:25 am, Rich Hickey richhic...@gmail.com wrote: I'm pleased to announce today the release of Clojure 1.2. http://clojure.org/downloads For maven/leiningen users, your settings to get the beta from build.clojure.org/releases are: :dependencies [[org.clojure/clojure 1.2.0] [org.clojure/clojure-contrib 1.2.0] This release includes many significant new features, such as protocols and datatypes; enhancements to existing features like the sequence library, destructuring and agents; support for annotations, etc. In addition, it incorporates many enhancements first developed and nurtured in clojure-contrib like I/O, string and pretty printing facilities. This release reflects the work of many people in addition to myself, and I'd like to thank all of the contributors who've submitted fix and enhancement patches, and everyone in the community who has participated in terrific dialog that surrounds the development and use of Clojure. Congrats and thanks to the contrib authors whose work has made it into the release: Chas Emerick Tom Faulhaber Stephen Gilardi Christophe Grand Stuart Halloway Chris Houser David Liebke Michel Salim Stuart Sierra I'd especially like to thank Stuart Halloway and the rest of the Clojure/core team for their tireless effort in authoring, screening and applying patches, setting up build machines, monitoring the mailing list, cutting releases etc. Their help greatly facilitates my ability to concentrate on the core design issues, and builds the foundation for increasing community involvement. A lot of work goes into Clojure. The team's effort is enabled and funded by the Clojure/ core practice (http://clojure.com). The full list of enhancements and changes is here: http://github.com/clojure/clojure/blob/1.2.x/changes.txt and the fixed tickets are here: http://www.assembla.com/spaces/clojure/tickets?milestone_id=149827ti... What's next? Plenty! There are a few fixes and enhancements too impactful to squeeze into this release that we hope to get out there ASAP. I've done a ton of work already on enhanced primitive support and call linkage that will be moving into master. Design work is proceeding on many fronts. I'm looking forward to the increasing capability and maturity of Clojure, and the growth of the community. Thanks to all involved! 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure Conj Questions
Well, courtesy of HN the cat's out of the bag: http://first.clojure-conj.org/ What is the ballpark price? I think this would help a lot of people determine if they can go. Attendee pricing will be designed to cover attendee costs for running the event, plus a little margin for error. So this should be very much on the affordable side as conferences go. We'll get this info out as as soon as we have it. Also, will there be cake? If this is Clojure's birthday party, there had better be cake. Yes. And tea. Not necessarily served at the same time. :-) Stu Stuart Halloway Clojure/core http://clojure.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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
REPL
How to exit from REPL? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
I'm pleased to announce today the release of Clojure 1.2. Woohoo! Time to party and then port all the 13k lines of Clojure code that we have written so far to 1.2. Awesome work, Rich co. Clojure rocks! Regards, BG -- Baishampayan Ghose b.ghose at 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
built in forms
How to know which are built in forms available ie functions available and its syntax? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
Hi, On 19 Aug., 17:25, Rich Hickey richhic...@gmail.com wrote: I'm pleased to announce today the release of Clojure 1.2. this is a great achievement. Congratulations to all involved and thank you! For us it the release is just on time. We will finish our book / tomorrow/ and I had been hoping for weeks now, that 1.2 would come out before we have to finalize things. So, we don't have to use an RC for our examples. Funny how life organizes itself sometime. :-) Kind regards, Stefan -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
Congrats! :-D BTW, the link to clojure-contrib-1.2 seems to be broken (currently returning 404): http://github.com/downloads/clojure/clojure/clojure-contrib-1.2.0.zip Was RC3 the final build? I couldn't find the answer in the release notes. Cheers, Greg On Aug 19, 2010, at 8:25 AM, Rich Hickey wrote: I'm pleased to announce today the release of Clojure 1.2. http://clojure.org/downloads For maven/leiningen users, your settings to get the beta from build.clojure.org/releases are: :dependencies [[org.clojure/clojure 1.2.0] [org.clojure/clojure-contrib 1.2.0] This release includes many significant new features, such as protocols and datatypes; enhancements to existing features like the sequence library, destructuring and agents; support for annotations, etc. In addition, it incorporates many enhancements first developed and nurtured in clojure-contrib like I/O, string and pretty printing facilities. This release reflects the work of many people in addition to myself, and I'd like to thank all of the contributors who've submitted fix and enhancement patches, and everyone in the community who has participated in terrific dialog that surrounds the development and use of Clojure. Congrats and thanks to the contrib authors whose work has made it into the release: Chas Emerick Tom Faulhaber Stephen Gilardi Christophe Grand Stuart Halloway Chris Houser David Liebke Michel Salim Stuart Sierra I'd especially like to thank Stuart Halloway and the rest of the Clojure/core team for their tireless effort in authoring, screening and applying patches, setting up build machines, monitoring the mailing list, cutting releases etc. Their help greatly facilitates my ability to concentrate on the core design issues, and builds the foundation for increasing community involvement. A lot of work goes into Clojure. The team's effort is enabled and funded by the Clojure/ core practice (http://clojure.com). The full list of enhancements and changes is here: http://github.com/clojure/clojure/blob/1.2.x/changes.txt and the fixed tickets are here: http://www.assembla.com/spaces/clojure/tickets?milestone_id=149827tickets_report_id=5 What's next? Plenty! There are a few fixes and enhancements too impactful to squeeze into this release that we hope to get out there ASAP. I've done a ton of work already on enhanced primitive support and call linkage that will be moving into master. Design work is proceeding on many fronts. I'm looking forward to the increasing capability and maturity of Clojure, and the growth of the community. Thanks to all involved! 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: built in forms
http://clojure.github.com/clojure http://clojure.github.com/clojure-contrib On 19 Aug., 17:29, Abraham Varghese abev...@gmail.com wrote: How to know which are built in forms available ie functions available and its syntax? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
Congrats and Cheers, :-) 2010/8/19 Greg g...@kinostudios.com: Congrats! :-D BTW, the link to clojure-contrib-1.2 seems to be broken (currently returning 404): http://github.com/downloads/clojure/clojure/clojure-contrib-1.2.0.zip Was RC3 the final build? I couldn't find the answer in the release notes. Cheers, Greg On Aug 19, 2010, at 8:25 AM, Rich Hickey wrote: I'm pleased to announce today the release of Clojure 1.2. http://clojure.org/downloads For maven/leiningen users, your settings to get the beta from build.clojure.org/releases are: :dependencies [[org.clojure/clojure 1.2.0] [org.clojure/clojure-contrib 1.2.0] This release includes many significant new features, such as protocols and datatypes; enhancements to existing features like the sequence library, destructuring and agents; support for annotations, etc. In addition, it incorporates many enhancements first developed and nurtured in clojure-contrib like I/O, string and pretty printing facilities. This release reflects the work of many people in addition to myself, and I'd like to thank all of the contributors who've submitted fix and enhancement patches, and everyone in the community who has participated in terrific dialog that surrounds the development and use of Clojure. Congrats and thanks to the contrib authors whose work has made it into the release: Chas Emerick Tom Faulhaber Stephen Gilardi Christophe Grand Stuart Halloway Chris Houser David Liebke Michel Salim Stuart Sierra I'd especially like to thank Stuart Halloway and the rest of the Clojure/core team for their tireless effort in authoring, screening and applying patches, setting up build machines, monitoring the mailing list, cutting releases etc. Their help greatly facilitates my ability to concentrate on the core design issues, and builds the foundation for increasing community involvement. A lot of work goes into Clojure. The team's effort is enabled and funded by the Clojure/ core practice (http://clojure.com). The full list of enhancements and changes is here: http://github.com/clojure/clojure/blob/1.2.x/changes.txt and the fixed tickets are here: http://www.assembla.com/spaces/clojure/tickets?milestone_id=149827tickets_report_id=5 What's next? Plenty! There are a few fixes and enhancements too impactful to squeeze into this release that we hope to get out there ASAP. I've done a ton of work already on enhanced primitive support and call linkage that will be moving into master. Design work is proceeding on many fronts. I'm looking forward to the increasing capability and maturity of Clojure, and the growth of the community. Thanks to all involved! 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 云中漫步 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
Hi, On 19 Aug., 17:56, Greg g...@kinostudios.com wrote: http://github.com/downloads/clojure/clojure/clojure-contrib-1.2.0.zip I would expect this to be: http://github.com/downloads/clojure/clojure-contrib/clojure-contrib-1.2.0.zip Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
Congratulations!! I am very happy with 1.2, as everybody I think. Great improvements to my favorite language. Your announcement got me curious: what are the future call linkage improvements? Thanks to all of you, it's great. Best, Nicolas. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: REPL
I use Ctrl+D. But I am on Linux. On Thu, Aug 19, 2010 at 4:28 PM, Abraham Varghese abev...@gmail.com wrote: How to exit from REPL? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
Congratulations! Just as a heads-up, the download link for Clojure Contrib on http://clojure.org/downloads is currently broken. It's pointing to: http://github.com/downloads/clojure/clojure/clojure-contrib-1.2.0.zip .. when I'm guessing it should be: http://github.com/downloads/clojure/clojure-contrib/clojure-contrib-1.2.0.zip On Aug 19, 9:45 am, Stefan Kamphausen ska2...@googlemail.com wrote: Hi, On 19 Aug., 17:25, Rich Hickey richhic...@gmail.com wrote: I'm pleased to announce today the release of Clojure 1.2. this is a great achievement. Congratulations to all involved and thank you! For us it the release is just on time. We will finish our book / tomorrow/ and I had been hoping for weeks now, that 1.2 would come out before we have to finalize things. So, we don't have to use an RC for our examples. Funny how life organizes itself sometime. :-) Kind regards, Stefan -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
Link fixed, thanks. Clojure 1.2 is RC3, but for the metadata change to remove the RC3 part. The changes.txt notes this, but for some reason my git branch tracking 1.2.x isn't pushing. I just pushed it explicitly. Stu Congrats! :-D BTW, the link to clojure-contrib-1.2 seems to be broken (currently returning 404): http://github.com/downloads/clojure/clojure/clojure-contrib-1.2.0.zip Was RC3 the final build? I couldn't find the answer in the release notes. Cheers, Greg On Aug 19, 2010, at 8:25 AM, Rich Hickey wrote: I'm pleased to announce today the release of Clojure 1.2. http://clojure.org/downloads For maven/leiningen users, your settings to get the beta from build.clojure.org/releases are: :dependencies [[org.clojure/clojure 1.2.0] [org.clojure/clojure-contrib 1.2.0] This release includes many significant new features, such as protocols and datatypes; enhancements to existing features like the sequence library, destructuring and agents; support for annotations, etc. In addition, it incorporates many enhancements first developed and nurtured in clojure-contrib like I/O, string and pretty printing facilities. This release reflects the work of many people in addition to myself, and I'd like to thank all of the contributors who've submitted fix and enhancement patches, and everyone in the community who has participated in terrific dialog that surrounds the development and use of Clojure. Congrats and thanks to the contrib authors whose work has made it into the release: Chas Emerick Tom Faulhaber Stephen Gilardi Christophe Grand Stuart Halloway Chris Houser David Liebke Michel Salim Stuart Sierra I'd especially like to thank Stuart Halloway and the rest of the Clojure/core team for their tireless effort in authoring, screening and applying patches, setting up build machines, monitoring the mailing list, cutting releases etc. Their help greatly facilitates my ability to concentrate on the core design issues, and builds the foundation for increasing community involvement. A lot of work goes into Clojure. The team's effort is enabled and funded by the Clojure/ core practice (http://clojure.com). The full list of enhancements and changes is here: http://github.com/clojure/clojure/blob/1.2.x/changes.txt and the fixed tickets are here: http://www.assembla.com/spaces/clojure/tickets?milestone_id=149827tickets_report_id=5 What's next? Plenty! There are a few fixes and enhancements too impactful to squeeze into this release that we hope to get out there ASAP. I've done a ton of work already on enhanced primitive support and call linkage that will be moving into master. Design work is proceeding on many fronts. I'm looking forward to the increasing capability and maturity of Clojure, and the growth of the community. Thanks to all involved! 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Today's clojure trick question
I copy that. Thanks for the explanation. On Aug 18, 1:22 pm, Matt Fowles matt.fow...@gmail.com wrote: Armando~ Libraries that target JRE 1.2 compatibility, will not call `Boolean.valueOf(var)` internally. Instead they will call `new Boolean(var)`. If they return those results to modern java code, it will unbox correctly into either true or false and thus work as expected in constructs of the form: if (old_library_call()) { // handle true } else { // handle false } If clojure's `if` form does not correctly unbox Booleans in the same manner, then that really should be viewed as a bug in Clojure. As these libraries are not likely to change to using the newer `Boolean.valueOf()` since that break compatibility. Yes, they could create their own static factory for Booleans and call that instead, but I don't think consumers of the library are going to want to figure out (the hard way) that they need to hack their library to use it from Clojure. Matt On Wed, Aug 18, 2010 at 4:07 PM, Armando Blancas armando_blan...@yahoo.comwrote: I don't see what the concern may be. Can you elaborate? On Aug 18, 10:04 am, Matt Fowles matt.fow...@gmail.com wrote: All~ Boolean.valueOf() was added in 1.4. While that seems ancient, some older libraries use 'new Boolean()' because they maintain 1.2 compatibility. It seems like Clojure should take more care when it unboxes Booleans... Matt On Wed, Aug 18, 2010 at 12:57 PM, Nicolas Oury nicolas.o...@gmail.com wrote: I am not an expert. Is it possible on some JDK to put a breakpoint on Boolean constructor and look at the stack? Or you can't put a breakpoint on standard library? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com clojure%2bunsubscr...@googlegroups.comclojure%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en-Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
On Aug 19, 2010, at 11:25 AM, Rich Hickey wrote: I'm pleased to announce today the release of Clojure 1.2. A huge milestone. Thanks, Rich, and to everyone else that has helped, fretted, argued, and worked to make Clojure and its community what it is today. I can't wait to see what tomorrow brings. - Chas -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
Woohoo, congrats! Can't wait to see all the new goodies that are in store for the next version. Justin On Aug 19, 11:25 am, Rich Hickey richhic...@gmail.com wrote: I'm pleased to announce today the release of Clojure 1.2. http://clojure.org/downloads For maven/leiningen users, your settings to get the beta from build.clojure.org/releases are: :dependencies [[org.clojure/clojure 1.2.0] [org.clojure/clojure-contrib 1.2.0] This release includes many significant new features, such as protocols and datatypes; enhancements to existing features like the sequence library, destructuring and agents; support for annotations, etc. In addition, it incorporates many enhancements first developed and nurtured in clojure-contrib like I/O, string and pretty printing facilities. This release reflects the work of many people in addition to myself, and I'd like to thank all of the contributors who've submitted fix and enhancement patches, and everyone in the community who has participated in terrific dialog that surrounds the development and use of Clojure. Congrats and thanks to the contrib authors whose work has made it into the release: Chas Emerick Tom Faulhaber Stephen Gilardi Christophe Grand Stuart Halloway Chris Houser David Liebke Michel Salim Stuart Sierra I'd especially like to thank Stuart Halloway and the rest of the Clojure/core team for their tireless effort in authoring, screening and applying patches, setting up build machines, monitoring the mailing list, cutting releases etc. Their help greatly facilitates my ability to concentrate on the core design issues, and builds the foundation for increasing community involvement. A lot of work goes into Clojure. The team's effort is enabled and funded by the Clojure/ core practice (http://clojure.com). The full list of enhancements and changes is here: http://github.com/clojure/clojure/blob/1.2.x/changes.txt and the fixed tickets are here: http://www.assembla.com/spaces/clojure/tickets?milestone_id=149827ti... What's next? Plenty! There are a few fixes and enhancements too impactful to squeeze into this release that we hope to get out there ASAP. I've done a ton of work already on enhanced primitive support and call linkage that will be moving into master. Design work is proceeding on many fronts. I'm looking forward to the increasing capability and maturity of Clojure, and the growth of the community. Thanks to all involved! 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: What is the reason Lisp code is not written with closing parenthesis on new lines?
Again, that's quite a straw man--the attached code uses tabs for indentation, (ick!) and you're viewing it with a different tab-stop setting Whoops, you're right, it was an honest mistake on my part. I use tabs of size 4 and the tab-stop used there was 8 I believe. This issue is making me look into SmartTabs: http://www.emacswiki.org/emacs/SmartTabs Although SmartTabs won't magically make other people's code look right (even in Emacs) if they use a tab-stop of 8 (unless there's some feature I'm missing), they will however ensure that *my* code looks the way it should in anyone else's editor. I'm currently using this to activate it: (smart-tabs-advice lisp-indent-line lisp-indent-offset) And that *seems* to be working so far... If I'm doing it wrong though feel free to let me know! Thanks, Greg On Aug 18, 2010, at 2:05 PM, Phil Hagelberg wrote: On Wed, Aug 18, 2010 at 1:36 PM, Greg g...@kinostudios.com wrote: Attached is a screenshot of some code from the wonderful Incanter library. I think it's a great illustration of how confusing stacking parenthesis can be (there are many functions in there that are like this). Again, that's quite a straw man--the attached code uses tabs for indentation, (ick!) and you're viewing it with a different tab-stop setting. It's also several times longer than reasonable. -Phil -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: What is the reason Lisp code is not written with closing parenthesis on new lines?
Brian Goslinga quickbasicg...@gmail.com writes: Here is another trick that works for me in Emacs: delete most of the stack of closing parens, and then spam the ) key until the Emacs matches it to the desired opening paren. I can't remember a time that I had to manually count the parens when using that technique. Note that if you are using SLIME, C-c C-] will close all parentheses still open at point -- though as with the above method, it's good to take a look and make sure that's really what you want. Historically, several lisps have provided ']' to mean `close all currently open parens' as well, as in (defun foo (x) (progn (foo) (bar] but as more lisps (R6RS, clojure, several older schemes) provide [ ] as a separate syntactic form or as an equivalent to ( ), this is not really an option any more. -- Jim Wise jw...@draga.com pgpoDAuynSAaM.pgp Description: PGP signature
Re: Clojure 1.2 Release
What a day for Clojure! If anyone wants more information than what's available in Rich's links, then you can view the slides for a talk I'm giving tonight: http://fogus.me/static/preso/clj1.2+/ -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
Excellent news. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: What is the reason Lisp code is not written with closing parenthesis on new lines?
Yet another one for Emacs users that don't use paredit: I have Paren Match Highlighting enabled and set to highlight the entire expression within matching parens (the highlighting kicks in when the cursor is before the opening paren or after the closing paren): (show-paren-mode 1) (setq show-paren-style 'expression) In addition to helping me match up parens, it also helps me see the scope of extended expressions like let or for at a glance. On Aug 19, 10:08 am, Brian Goslinga quickbasicg...@gmail.com wrote: On Aug 19, 1:55 am, michele michelemen...@gmail.com wrote: Thanks everyone for the your answers (and the internal debates). I will not put closing parenthesis on new lines. Even though the editor helps me with the parenthesis, there have been situations - while editing inside functions - that I had to count them. Here is another trick that works for me in Emacs: delete most of the stack of closing parens, and then spam the ) key until the Emacs matches it to the desired opening paren. I can't remember a time that I had to manually count the parens when using that technique. Using paredit would be another solution, though (like most things) you have to invest some time in learning it to put it to good use. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
On Thu, Aug 19, 2010 at 10:25 AM, Rich Hickey richhic...@gmail.com wrote: I'm pleased to announce today the release of Clojure 1.2. http://clojure.org/downloads For maven/leiningen users, your settings to get the beta from build.clojure.org/releases are: :dependencies [[org.clojure/clojure 1.2.0] [org.clojure/clojure-contrib 1.2.0] When should 1.2.0 be available at http://repo2.maven.org/maven2/org/clojure/clojure/ ? Jeff -- Jeff Brown SpringSource http://www.springsource.com/ Autism Strikes 1 in 166 Find The Cause ~ Find The Cure http://www.autismspeaks.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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Program design
On Wed, Aug 18, 2010 at 5:20 PM, Patrick Moriarty pmoria...@annadaletech.com wrote: You should look at Clojure 1.2 protocols and records which provides an easy way to do polymorphism on types. See http://clojure.org/protocols. Protocols don't offer inheritance. The original poster specifically mentioned porting code involving inheritance. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Program design
A big part of inheritance can be done by using defrecord, keywords and functions instead of method, and getting read of the abstract class. (defrecord Orange [:mass :energy :juice]) (defrecord Apple [:mass :energy :juice : family]) (defn get-juice [fruit] (:juice fruit)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
On Aug 19, 1:12 pm, Jeff Brown j...@jeffandbetsy.net wrote: When should 1.2.0 be available athttp://repo2.maven.org/maven2/org/clojure/clojure/? We don't have a direct sync to Maven central. They don't seem to be giving those out anymore. So someone with the authority will have to upload it manually. :( Until then, add http://build.clojure.org/releases to your list of repositories. -S -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
First Clojure Conj October 22-23
In case you haven't heard, here's the official story: http://first.clojure-conj.org/ Clojure Conj 2010 will be held in Durham, North Carolina on October 22 and 23. We are currently collecting emails of people interested in attending. If you plan on attending, please submit your email at the link above to help us with capacity planning. Still to be determined: - venue (depends on number of attendees) - cost (there will be a registration fee, but it will be modest) - final list of speakers Watch this space and @clojure_conj on Twitter for more updates, coming as soon as we have them. -S -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Fwd: Feedback on idiomatic clojure
Damon reply to me and not the list, so I forward. On Thu, Aug 19, 2010 at 9:09 PM, Damon Snyder drsny...@gmail.com wrote: Hi Nicolas, Thanks for the suggestions. Regarding the first one: ah, I see. That is a nice compact way to test to see if the str is nil. I added that I reckon that Meikel's suggestion of using when is surely better in this situation (for a and). But the (or something? default) or (or known? recompute?) can be useful. in because I was getting null pointer exceptions when the string was null. What is the difference between {:count 1 :words (list words)} and a hash-map? I was under the impression that {} created a hash. I just find it easier to read because it looks like a value and not a function call. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
I think I can do that - or at least push that along. Will check into it when I get to the office in about 30 minutes. PS: Direct sync to central is easy via oss.sonatype.org repositories. -- Pull me down under... On Fri, Aug 20, 2010 at 6:42 AM, Stuart Sierra the.stuart.sie...@gmail.comwrote: We don't have a direct sync to Maven central. They don't seem to be giving those out anymore. So someone with the authority will have to upload it manually. :( -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Feedback on idiomatic clojure
Hi. Am 19.08.2010 um 22:14 schrieb Nicolas Oury: in because I was getting null pointer exceptions when the string was null. What is the difference between {:count 1 :words (list words)} and a hash-map? I was under the impression that {} created a hash. I just find it easier to read because it looks like a value and not a function call. Another difference is that in this case it creates not a hash map but an array map. Rule of thumb: up to 8 keys = array map, more than 8 = hash map. The array map is simply a short alist, not a full blown hash map. For such small maps this is faster than pulling at the hash cannon. So the difference is not limited to syntax alone. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Docstrings in Clojure?
Hi, Does clojure have docstrings: http://en.wikipedia.org/wiki/Docstring and, if so, do you have a link to the feature in the Clojure documentation? Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Docstrings in Clojure?
(defn function-name Your docstring goes here [your argument list more] (call some functions)) 2010/8/19 Paddy3118 paddy3...@googlemail.com: Hi, Does clojure have docstrings: http://en.wikipedia.org/wiki/Docstring and, if so, do you have a link to the feature in the Clojure documentation? Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 Demandoj en aŭ pri Esperanto? Questions about Esperanto? Vragen over Esperanto? Perguntas sobre o Esperanto? - http://demandoj.tk -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: REPL
I use Ctrl-D on linux, but Ctrl-C works too, and is what I would try first on Windows. (System/exit 0) won't work if you're using leiningen to get your repl, because it passes I/O through JLine and System.exit terminates the clojure process without notifying the JLine process: $ lein repl user= (System/exit 0) ��� type some random crap ���Exception in thread main java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 43) at java.lang.reflect.Method.invoke(Method.java:616) at jline.ConsoleRunner.main(ConsoleRunner.java:69) Caused by: java.net.SocketException: Broken pipe (NO_SOURCE_FILE:0) at clojure.lang.Compiler.eval(Compiler.java:5435) at clojure.lang.Compiler.eval(Compiler.java:5386) at clojure.core$eval.invoke(core.clj:2382) at clojure.main$eval_opt.invoke(main.clj:235) at clojure.main$initialize.invoke(main.clj:254) at clojure.main$script_opt.invoke(main.clj:270) at clojure.main$main.doInvoke(main.clj:354) at clojure.lang.RestFn.invoke(RestFn.java:458) at clojure.lang.Var.invoke(Var.java:377) at clojure.lang.AFn.applyToHelper(AFn.java:174) at clojure.lang.Var.applyTo(Var.java:482) at clojure.main.main(main.java:37) ... 5 more Caused by: java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java: 109) at java.net.SocketOutputStream.write(SocketOutputStream.java:153) at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:220) at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:290) at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:294) at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:140) at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 43) at java.lang.reflect.Method.invoke(Method.java:616) at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:90) at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java: 265) at leiningen.repl$repl_client.invoke(repl.clj:42) at leiningen.repl$connect_to_server.invoke(repl.clj:47) at leiningen.repl$poll_for_socket$fn__1035.invoke(repl.clj:51) at leiningen.repl$poll_for_socket.invoke(repl.clj:51) at leiningen.repl$repl.invoke(repl.clj:63) at clojure.lang.Var.invoke(Var.java:365) at clojure.lang.AFn.applyToHelper(AFn.java:163) at clojure.lang.Var.applyTo(Var.java:482) at clojure.core$apply.invoke(core.clj:540) at leiningen.core$_main.doInvoke(core.clj:111) at clojure.lang.RestFn.applyTo(RestFn.java:138) at clojure.core$apply.invoke(core.clj:540) at leiningen.core$_main.invoke(core.clj:114) at user$eval46.invoke(NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:5419) ... 16 more On Aug 19, 9:01 am, Meikel Brandmeyer m...@kotka.de wrote: Control-D on Unix, Control-Z Enter on Windows, (System/exit 0) On 19 Aug., 17:28, Abraham Varghese abev...@gmail.com wrote: How to exit from REPL? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
multiplying lists
I want to multiply a list of n items by h lists of n items, so that for example if i have list 'a' and 'b' (def a (list 1 2 3)) (def b (list '(4 5 6) '(7 8 9))) when multiplied I will get: ((4 10 18) (7 16 27)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: multiplying lists
On Thu, Aug 19, 2010 at 7:56 PM, Glen Rubin rubing...@gmail.com wrote: I want to multiply a list of n items by h lists of n items, so that for example if i have list 'a' and 'b' (def a (list 1 2 3)) (def b (list '(4 5 6) '(7 8 9))) when multiplied I will get: ((4 10 18) (7 16 27)) Clojure makes this easy! (map #(map * % [1 2 3]) [[4 5 6] [7 8 9]]) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: multiplying lists
user= (def a [1 2 3]) #'user/a user= (def b [[4 5 6] [7 8 9]]) #'user/b user= (map #(map * a %) b) ((4 10 18) (7 16 27)) - Will Morgan On Aug 19, 7:56 pm, Glen Rubin rubing...@gmail.com wrote: I want to multiply a list of n items by h lists of n items, so that for example if i have list 'a' and 'b' (def a (list 1 2 3)) (def b (list '(4 5 6) '(7 8 9))) when multiplied I will get: ((4 10 18) (7 16 27)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: multiplying lists
Or if you want to avoid the #(...%...) syntax: user= (def a (list 1 2 3)) #'user/a user= (def b (list '(4 5 6) '(7 8 9))) #'user/b user= (map (partial map * a) b) ((4 10 18) (7 16 27)) On Aug 19, 4:56 pm, Glen Rubin rubing...@gmail.com wrote: I want to multiply a list of n items by h lists of n items, so that for example if i have list 'a' and 'b' (def a (list 1 2 3)) (def b (list '(4 5 6) '(7 8 9))) when multiplied I will get: ((4 10 18) (7 16 27)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Docstrings in Clojure?
On Aug 19, 4:37 pm, Joop Kiefte iko...@gmail.com wrote: (defn function-name Your docstring goes here [your argument list more] (call some functions)) And then you can access it with (doc function-name). (find-doc #regexp) or (find-doc string) searches all doc strings. There is also (clojure.repl/source function-name), which tries to print out the source and doc-string. It doesn't work all the time, though. 2010/8/19 Paddy3118 paddy3...@googlemail.com: Hi, Does clojure have docstrings:http://en.wikipedia.org/wiki/Docstring and, if so, do you have a link to the feature in the Clojure documentation? Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 Demandoj en aŭ pri Esperanto? Questions about Esperanto? Vragen over Esperanto? Perguntas sobre o Esperanto? -http://demandoj.tk -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Lazy reading from subprocess stdout?
Hello! -- Here's a how-to question for subprocess and threading experts. What's the right way to obtain an output stream for stdout from a subprocess, and read it lazily? At the moment, there's the sh function, but this collects all the output from the stdout and stderr streams into arrays, and returns them wholesale when these end. This doesn't work well for processes which generate very long streams of data. One approach might be to modify sh to return the stdout stream, but I think that won't tend to work, because the stderr stream must still be collected (for most programs), and the process would also probably have to be stopped at the end somehow. Another approach might be to make a function which creates the Process object -- say, open-subprocess, which returns a map {:out stdout :in stdin :err stderr}. But something still must service both the output and error streams. (sh handles this by interleaving character reads from the stdout and stderr streams.) A companion function close-subprocess would shut things down, and return the result code. (Could a close method be made for this, which would work with with-open?) At this point I'm thinking of an open-subprocess which spawns some kind of thread which could read either or both streams into an array. Is there another possibility for doing this? What's the usual way to handle this situation, if any? Of course, I could use sh to pipe the stdout to a temporary file, but that seems a cop-out. Thanks in advance for any and all answers! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Unexpected FileNotFoundException
Hello everyone. Clojure noob here. I apologize in advance for what may turn out to be a dumb question. When trying to (use '[clojure.contrib.seq]) I get the following error: java.io.FileNotFoundException: Could not locate clojure/contrib/ seq__init.class or clojure/contrib/seq.clj on classpath: (NO_SOURCE_FILE:1) which is strange because others succeed, like (use '[clojure.contrib.str-utils]). I'm using Clojure 1.1.0 and Clojure- contrib 1.1.0, and clojure-contrib.jar is on the classpath. Any help is appreciated. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Docstrings in Clojure?
So it is before arguments. What is the motivation behind that opposition to other lisps and python ? On 19 août, 22:37, Joop Kiefte iko...@gmail.com wrote: (defn function-name Your docstring goes here [your argument list more] (call some functions)) 2010/8/19 Paddy3118 paddy3...@googlemail.com: Hi, Does clojure have docstrings:http://en.wikipedia.org/wiki/Docstring and, if so, do you have a link to the feature in the Clojure documentation? Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 Demandoj en aŭ pri Esperanto? Questions about Esperanto? Vragen over Esperanto? Perguntas sobre o Esperanto? -http://demandoj.tk -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: First Clojure Conj October 22-23
Are you guys interested in me presenting/speaking about my clojure refactoring tool at this conference? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: multiplying lists
This should work: (defn mult-list-by-lists [a b] (let [mult-lists (fn [x y] (map * x y))] (map #(mult-lists a %) b))) On Aug 19, 5:56 pm, Glen Rubin rubing...@gmail.com wrote: I want to multiply a list of n items by h lists of n items, so that for example if i have list 'a' and 'b' (def a (list 1 2 3)) (def b (list '(4 5 6) '(7 8 9))) when multiplied I will get: ((4 10 18) (7 16 27)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Docstrings in Clojure?
On Thu, Aug 19, 2010 at 10:09 PM, Ameen amy...@gmail.com wrote: So it is before arguments. What is the motivation behind that opposition to other lisps and python ? Functions support mutiple arity. (defn foo ... ([a] ...) ([a b] ...)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Unexpected FileNotFoundException
On 20 August 2010 11:52, Tim McIver tmci...@verizon.net wrote: Hello everyone. Clojure noob here. I apologize in advance for what may turn out to be a dumb question. When trying to (use '[clojure.contrib.seq]) I get the following error: java.io.FileNotFoundException: Could not locate clojure/contrib/ seq__init.class or clojure/contrib/seq.clj on classpath: (NO_SOURCE_FILE:1) which is strange because others succeed, like (use '[clojure.contrib.str-utils]). I'm using Clojure 1.1.0 and Clojure- contrib 1.1.0, and clojure-contrib.jar is on the classpath. Any help is appreciated. According to the c.c 1.1 docshttp://richhickey.github.com/clojure-contrib/branch-1.1.x/index.html, there is no clojure.contrib.seq - perhaps you meant clojure.contrib.seq-utils? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Adding seajure to Clojure.org
Hello. I noticed we have a list of user groups at http://clojure.org/community Could we add Seajure (Seattle Clojure Group) at http://seajure.technomancy.us? Thanks, Phil -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
[ANN] Leiningen 1.2.0 released
I just pushed out a new release of Leiningen, a Clojure build tool, with lots of help from many contributors. This adds a couple new tasks (test! and interactive) and the ability to chain tasks. It also allows for user-level init scripts and user-level plugins, so you don't have to declare things like swank as a dependency for every project you use; just install it once and be done with it. The repl task now acts as a socket server, so multiple concurrent connections may be used. Another neat feature is the ability to bundle shell script launchers with your jar files. Leiningen will place these in the ~/.lein/bin directory so you can have an easy way to launch projects from the command-line. One last new feature is the Leiningen stickers: http://twitpic.com/2e33r1 If you've contributed to Leiningen, you can send for one yourself; details at: http://groups.google.com/group/leiningen/browse_thread/thread/fb4db02386cb9fe9 Users of 1.1.0 and 1.2.0 can upgrade with lein upgrade. Otherwise download the script from http://github.com/technomancy/leiningen/raw/stable/bin/lein, place it on your $PATH and make it executable, and then run lein self-install to get going. New users should check out the Tutorial: http://github.com/technomancy/leiningen/blob/master/TUTORIAL.md A complete list of the new features and bug fixes can be found at http://bit.ly/lein-news Enjoy! -Phil -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: [ANN] Leiningen 1.3.0 released
I just pushed out a new release of Leiningen, a Clojure build tool, with lots of help from many contributors. In the subject, I am sure you meant [ANN] Leiningen 1.3.0 released :) Nevertheless, great work! Regards, BG -- Baishampayan Ghose b.ghose at 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: cool compiler-project?
You might consider some kind of whole-program optimizations along the lines of the Stalin compiler for Scheme. Stalin compiles Scheme to C and makes a lot of representation decisions, unboxing, as well as a lot of call-stack-aware memory allocations/deallocations. Not all of these would be applicable to the same degree running on the JVM or CLR, but many would. On Aug 18, 5:35 am, Sreeraj a writeto...@gmail.com wrote: Hi, I am a post-grad student looking for a cool compiler - project to do. I am getting comfortable with clojure and would really like to help Ideas anyone? or, Is there a to-do list where can i start? Cheers Sreeraj -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: [ANN] Leiningen 1.2.0 released
On Fri, Aug 20, 2010 at 12:39 AM, Phil Hagelberg p...@hagelb.org wrote: I just pushed out a new release of Leiningen, a Clojure build tool, with lots of help from many contributors. Looks great. A couple early observations/issues, 1) It's no longer possible to start a REPL w/o a project.clj :( 2) starting a REPL puts you in clojure.core instead of user David -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Docstrings in Clojure?
(defn foo ... ([a] ...) ([a b] ...)) Is there any way to add docstring for each case? (One for summary, one for [a], and one for [a b].) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Today's clojure trick question
Sean Corfield seancorfi...@gmail.com writes: On Wed, Aug 18, 2010 at 10:28 AM, Shantanu Kumar kumar.shant...@gmail.com wrote: Would suggest to consider this: (let [ x (true? (new java.lang.Boolean false)) ] (if x trouble ok)) Ah, but that wouldn't work for a new Boolean set to true: (let [ x (true? (new java.lang.Boolean true)) ] (if x ok trouble)) Expect ok? Nope, you'll get trouble. How about something along these lines? (defmacro careful-if [test then else] `(let [result# ~test] (cond (nil? result#) ~else (identical? Boolean/FALSE result#) ~else (identical? Boolean/TRUE result#) ~then (instance? Boolean result#) (if (Boolean/valueOf result#) ~then ~else) :else ~then))) In the case of a proper boolean value I think you just get one more reference check than with normal if; you only hit reflection if both those reference checks fail. It satisfies the original author's challenge, anyway: (map #(careful-if %1 :truthy :falsey) [true false (new Boolean true) (new Boolean false)]) ;;; = (:truthy :falsey :truthy :falsey) I'll leave it to someone more skilled in Clojure than me to tell us what would be the impact of either using this as a replacement if or somehow embedding similar logic into the Java interop functions... -- Mark Shroyer http://markshroyer.com/contact/ -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Feedback on idiomatic clojure
Hi Meikel, Nicolas, and Justin, Thank you for the great feedback! I learned a lot. I was puzzled about (update-in (update-in)) and after doing that the - operator makes a lot of sense. The reduce is clever and fits nicely as well. I dropped the function that read in the lines of the file and used read-lines instead. Below is what I put together after the feedback. Thanks, Damon PS- I was mistaken before. The first version was taking over a minute. This version takes about 15s. (ns clojure.example.anagrams (:require clojure.contrib.duck-streams) (:gen-class)) (defn str-sort[string] (when string (apply str (sort string (defn str-to-lower[string] (when string (.toLowerCase string))) (defn anagram-add[anagrams akey word] (if (contains? anagrams akey) (- anagrams (update-in [akey :count] inc) (update-in [akey :words] conj word)) (assoc anagrams akey {:count 1 :words [word]}))) (def normalise (comp str-to-lower str-sort)) (defn build-anagrams[words] (reduce #(anagram-add %1 (normalise %2) %2) {} words)) (defn print-anagram[v] (println (str (:count (second v)) (first v) : (:words (second v) (defn print-anagrams[ana] (doseq [v ana] (print-anagram v))) (defn anagram-key[elem] (- (:count (second elem ;(def *words* (f-to-seq /usr/share/dict/web2)) ;(def *anagrams* (sort-by anagram-key (build-anagrams *words*))) ;(print-anagrams (take 10 *anagrams*)) (defn -main[file] (time (print-anagrams (take 10 (sort-by anagram-key (build-anagrams (clojure.contrib.duck-streams/read-lines file))) On Aug 19, 5:41 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, here my turn. Comments inline. Hope this helps. Sincerely Meikel (defn f-to-seq [file] (with-open [rdr (java.io.BufferedReader. (java.io.FileReader. file))] (doall (line-seq rdr ; Yes. doall is required here. Alternatively you can wrap the whole thing ; in the with-open. Then you can process also larger files without keeping ; all data in memory. YMMV. (defn str-sort [string] (when string (apply str (sort string ; One can also skip the when here. Then nil input returns an empty string. ; Whether that is better depends on the usage of the return value. YMMV. ; (if (nil? x) x ...) is usually written as (when x ...). (defn str-to-lower [string] (when string (.toLowerCase string))) (defn anagram-add [anagrams akey word] (if (contains? anagrams akey) (- anagrams (update-in [akey :count] inc) (update-in [akey :words] conj word)) (assoc anagrams akey {:count 1 :words [word]}))) ; I would prefer vectors over lists to store stuff. You get nice ; things for free, like O(1) appending, O(1) reverse, O(1) random ; access, ... (defn word [s] (first s)) ; or: (def word first) ; not needed for my solution (def normalise (comp str-to-lower str-sort)) (defn build-anagrams [words] (reduce #(anagram-add %1 (normalise %2) %2) {} words)) ; Looping with an accumulator, just returning the latter when the ; input is exhausted cries for reduce. (defn print-anagram [v] (println (str (:count (second v)) (first v) : (:words (second v) ; one could use destructuring to access things. (defn print-anagram [anagram] (let [[normal-form {:keys [count words]}] anagram] (println (str count normal-form : words (defn print-anagrams [ana] (doseq [v ana] (print-anagram v))) ; more descriptive names would be good, I guess (defn anagram-key [elem] (- (:count (second elem ; the minus should take care of the reverse? (def *words* (f-to-seq /usr/share/dict/web2)) (def *anagrams* (sort-by anagram-key (build-anagrams *words*))) (print-anagrams (take 10 *anagrams*)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Docstrings in Clojure?
Hi, On 20 Aug., 07:18, ngocdaothanh ngocdaoth...@gmail.com wrote: (defn foo ... ([a] ...) ([a b] ...)) Is there any way to add docstring for each case? (One for summary, one for [a], and one for [a b].) No. (And honestly: I don't see any use for this. Why is one docstring not enough to describe the behaviour of the function?) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: multiplying lists
Hi, On 20 Aug., 01:56, Glen Rubin rubing...@gmail.com wrote: I want to multiply a list of n items by h lists of n items, so that for example if i have list 'a' and 'b' (def a (list 1 2 3)) (def b (list '(4 5 6) '(7 8 9))) when multiplied I will get: ((4 10 18) (7 16 27)) And just to train myself to use for more often: (for [b [[456] [789]]] (map * b [1 2 3])) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: REPL
Hi, On 19 Aug., 23:43, Alan a...@malloys.org wrote: Ctrl-C works too, and is what I would try first on Windows. Ctrl-C is a rather hard way to shutdown things. Compare to turning off the computer without flushing the disk caches. With JLine Ctrl-D also works on Windows. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en