Why so?
It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures. -- Alan Perlis Why so? How is it advantageous? -- 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: Thinking in Clojure
On Thu, Sep 2, 2010 at 6:29 PM, HB wrote: > Usually we create some domain entities, map them with Hibernate/ > iBatis. > I don't know how a Clojure application would be build without objects. I wonder if watching this talk by Rich Hickey will help? http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey It focuses on issues with mutability in the context of OO. -- 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
Shootout "fannkuch"
Hello, I've tried writing a a solution to shootout "fannkuch" (http:// shootout.alioth.debian.org/u32/performance.php?test=fannkuchredux), however I seem to have a bug in the checksum. Is it just the order of permutations or am I missing something? Code at http://bitbucket.org/tebeka/shootout-clj/src/tip/fannkuch.clj All the best, -- Miki -- 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: Thinking in Clojure
I'd go over SICP, though it not in Clojure but in Scheme - it will show you how to "think" functional. On Sep 2, 6:29 pm, HB wrote: > Hey, > I finished reading "Programming Clojure" and "Practical Clojure" and > I'm hooked :) > Please count me in the Clojure club. > But I failed how to think in Clojure. > My main career is around Java web applications (Hibernate, Spring, > Lucene) and Web services. > Lets not talk about Java web frameworks neither Clojure ones, I want > to talk in general. > Usually we create some domain entities, map them with Hibernate/ > iBatis. > I don't know how a Clojure application would be build without objects. > I think Scala really shines here, this OOP/FP is really powerful > approach (please note I'm not saying Clojure isn't good, I don't seel > flame war) > How to think in Clojure? how to achieve this shift? -- 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: union using a comparison function
By union do you mean union as in sets, or just smashing the two lists together? --Robert McIntyre On Thu, Sep 2, 2010 at 11:10 AM, mlimotte wrote: > Hi. > > I'd like to do a union of some sequences using my own comparison > function. Similar to supplying a Comparator in Java. The things > being compared are Objects from a Java library that I don't control, > so I can't just override the equals function on the class, for > example. > > Would aprecaite any suggestions. > > thanks, > Marc > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- 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: Thinking in Clojure
I highly recommend "Joy of Clojure". It's a good "2nd book on clojure". It shows you the "why things are the way they are", and how to do things the clojure way as much as possible. On Thu, Sep 2, 2010 at 9:29 PM, HB wrote: > Hey, > I finished reading "Programming Clojure" and "Practical Clojure" and > I'm hooked :) > Please count me in the Clojure club. > But I failed how to think in Clojure. > My main career is around Java web applications (Hibernate, Spring, > Lucene) and Web services. > Lets not talk about Java web frameworks neither Clojure ones, I want > to talk in general. > Usually we create some domain entities, map them with Hibernate/ > iBatis. > I don't know how a Clojure application would be build without objects. > I think Scala really shines here, this OOP/FP is really powerful > approach (please note I'm not saying Clojure isn't good, I don't seel > flame war) > How to think in Clojure? how to achieve this shift? > -- Omnem crede diem tibi diluxisse supremum. -- 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: Thinking in Clojure
So in idiomatic Clojure applications, maps are considered like objects? And to operate on them we pass them to functions? On Sep 3, 4:55 am, David Nolen wrote: > On Thu, Sep 2, 2010 at 9:29 PM, HB wrote: > > Hey, > > I finished reading "Programming Clojure" and "Practical Clojure" and > > I'm hooked :) > > Please count me in the Clojure club. > > But I failed how to think in Clojure. > > My main career is around Java web applications (Hibernate, Spring, > > Lucene) and Web services. > > Lets not talk about Java web frameworks neither Clojure ones, I want > > to talk in general. > > Usually we create some domain entities, map them with Hibernate/ > > iBatis. > > I don't know how a Clojure application would be build without objects. > > I think Scala really shines here, this OOP/FP is really powerful > > approach (please note I'm not saying Clojure isn't good, I don't seel > > flame war) > > How to think in Clojure? how to achieve this shift? > > It does require a significant shift in thinking. I think you'll be surprised > how far maps and functions will take you if you're used to thinking in OOP. > > And contrary to popular belief Clojure is also a hybrid OOP/FP approach: > multimethods, protocols, deftype, defrecord, definterface, etc. will let you > utilize the better aspects of OOP design. However you should be cautious to > reach for these. They are easily misapplied. Stick with the core > datastructures (maps, vectors, sets, lists) and fns and you'll do just fine. > > 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: Thinking in Clojure
On Thu, Sep 2, 2010 at 9:29 PM, HB wrote: > Hey, > I finished reading "Programming Clojure" and "Practical Clojure" and > I'm hooked :) > Please count me in the Clojure club. > But I failed how to think in Clojure. > My main career is around Java web applications (Hibernate, Spring, > Lucene) and Web services. > Lets not talk about Java web frameworks neither Clojure ones, I want > to talk in general. > Usually we create some domain entities, map them with Hibernate/ > iBatis. > I don't know how a Clojure application would be build without objects. > I think Scala really shines here, this OOP/FP is really powerful > approach (please note I'm not saying Clojure isn't good, I don't seel > flame war) > How to think in Clojure? how to achieve this shift? It does require a significant shift in thinking. I think you'll be surprised how far maps and functions will take you if you're used to thinking in OOP. And contrary to popular belief Clojure is also a hybrid OOP/FP approach: multimethods, protocols, deftype, defrecord, definterface, etc. will let you utilize the better aspects of OOP design. However you should be cautious to reach for these. They are easily misapplied. Stick with the core datastructures (maps, vectors, sets, lists) and fns and you'll do just fine. 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: Does 'require' with the :reload option have a tendency to build up memory?
On Thu, Sep 2, 2010 at 7:47 PM, Rayne wrote: > I've got a curious little bit of a memory leak of sorts that I'm > trying to narrow down. > > I have an application (betcha can guess what it is if you know me from > IRC :>) that, in order to reload plugins, requires each of them with > the :reload option whenever you ask them to be reloaded. > > Each of these plugins calls a macro that defines a set of defmethods > for a multimethod in a namespace that never does get reloaded. They > also define a single function that isn't a method. > > Whenever these 'plugins' are reloaded (there are about 20 of them), > the memory my application uses is raised by about 3MB, as monitored > with htop. It's very consistent and always raises 2-3MB each time. The > less plugins being reloaded, the less dramatic the memory jump. > > Now, my question is: can require with :reload a lot of namespaces like > this cause this sort of thing to happen? I mostly just need to know > whether or not I'm going in the wrong direction. I've never had this > sort of problem before. > > If so, are there any steps I can take to keep memory from building up > like this? I'd recommend using a memory profiling tool that lists the object counts by class. I think jvisualvm that comes with Sun's JDK will do it, and I know yourkit will. Check your counts before a :reload and again after -- might give a good clue as to what's going on. --Chouser http://joyofclojure.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
Thinking in Clojure
Hey, I finished reading "Programming Clojure" and "Practical Clojure" and I'm hooked :) Please count me in the Clojure club. But I failed how to think in Clojure. My main career is around Java web applications (Hibernate, Spring, Lucene) and Web services. Lets not talk about Java web frameworks neither Clojure ones, I want to talk in general. Usually we create some domain entities, map them with Hibernate/ iBatis. I don't know how a Clojure application would be build without objects. I think Scala really shines here, this OOP/FP is really powerful approach (please note I'm not saying Clojure isn't good, I don't seel flame war) How to think in Clojure? how to achieve this shift? -- 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: Blogs/Twitter accounts about Clojure
This is amazing, thank you all guys :) On Sep 2, 7:33 pm, Sean Allen wrote: > a few off the top of my head: > > @fogus > @planetclojure > @disclojure > @stuartholloway > @liebke > @richhickey > > blog.fogus.me > dosync.posterous.com > m.3wa.com > nathanmarz.com > > > > On Thu, Sep 2, 2010 at 12:21 PM, HB wrote: > > Hey, > > Would you please recommend some good Blogs/Twitter accounts about > > Clojure? > > Thanks. > > > -- > > You received this message because you are subscribed to the Google > > Groups "Clojure" group. > > To post to this group, send email to clojure@googlegroups.com > > Note that posts from new members are moderated - please be patient with > > your first post. > > To unsubscribe from this group, send email to > > clojure+unsubscr...@googlegroups.com > > For more options, visit this group at > >http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 and the Computer Language Benchmarks Game
On Sep 2, 5:28 pm, Sean Corfield wrote: > On Wed, Sep 1, 2010 at 9:46 PM, John Fingerhut > wrote: > > You can see a brief summary of results comparing > > run time, memory, and code size against "Java 6 -server" here: > >http://shootout.alioth.debian.org/u32/benchmark.php?test=all〈=clo... > > Very interesting. Clojure is faster than several languages > (surprisingly so in some cases - at least for me) but seems to use > more code to express solutions - which really surprised me! Perhaps some of those Clojure programs include code that isn't actually required, for example, code to display a usage message? Perhaps some of those Clojure programs are written to use all the cores on the quad-core machine and the programs you have compared them with are only written to use one core? Memory use was what I noticed. -- 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: Web Development - templating?
On Wed, Sep 1, 2010 at 5:41 AM, Remco van 't Veer wrote: > If you want something old school like CFML you might consider using > plain JSP and taglibs. These are modeled after CFML and available on > every web container by default. FWIW, I've created a small CFML/Clojure bridge so now I can develop web apps with CFML views and a lightweight MVC framework (in CFML) but have my model built entirely in Clojure. Thanx for all the input and suggestions from folks in this thread. -- 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
Re: Clojure 1.2 and the Computer Language Benchmarks Game
On Wed, Sep 1, 2010 at 9:46 PM, John Fingerhut wrote: > You can see a brief summary of results comparing > run time, memory, and code size against "Java 6 -server" here: > http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=clojure&lang2=java Very interesting. Clojure is faster than several languages (surprisingly so in some cases - at least for me) but seems to use more code to express solutions - which really surprised me! -- 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
Re: API for ClojureDocs.org
Awesome! It doesn't have to be much. Searching for examples and docs is the most important thing, obviously. I'd request that if you're going to have any single format, JSON would make me the happiest. Clojure data structures would be cool, but that's kind of limited to Clojure. My vote is on JSON. On Sep 2, 6:11 pm, Lee Hinman wrote: > Hi All, > As Zach announced in the ClojureDocs mailing list [1], I'm going to be > working on the API for ClojureDocs.org in the coming future. I was > hoping to get some feedback regarding what people wanted to see for an > API for ClojureDocs: > > - What kind of features would you like to see in the ClojureDocs API? > - What kind of output would you like to see from the API? (json, > clojure datastructures, xml, plaintext) > > Any other feedback is highly appreciated :) > > - Lee Hinman > > [1]:http://groups.google.com/group/clojuredocsorg/browse_thread/thread/eb... -- 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 and the Computer Language Benchmarks Game
On Sep 1, 9:46 pm, John Fingerhut wrote: > Thanks to many people on this list in Aug 2009 who helped improve my code, > to Johannes Friestad for writing a nice fast Clojure program using deftype > for the n-body problem, to Isaac Gouy for setting up the shootout web site > to accept Clojure submissions, and to my having more time than good sense to > work on this, there are now Clojure programs for 5 of the 10 shootout web > site benchmark problems. iirc Clojure won't show up on the summary pages until there are 7 programs implemented. Nontheless I've put Clojure on the home page. > You can see a brief summary of results comparing > run time, memory, and code size against "Java 6 -server" here: > > http://shootout.alioth.debian.org/u32/benchmark.php?test=all〈=clo... > > Note: All Clojure programs are AOT compiled before any time measurements are > made when running the program. The programs are short enough that I believe > the longest one was around 1.5 or 2 seconds on my MacBook Pro, but that time > isn't included on the web site results. > > Are there improvements that could be made to the Clojure programs to make > them faster? Most likely so. I doubt very much these are the fastest ones > possible. I have not written any Java code for these solutions. I am sure > that when push comes to shove in improving the run time of parts of a > real-world program that were performance-critical, most programmers would > optimize using Java or even C/C++. The goal here was to see what could be > done without using those techniques. > > If people want to beat each other up using the shootout web site's results, > I would probably recognize in them some of the "my language is best for > every purpose" attitude I once had as a teenager. Now I just see it as one > of several ways to evaluate a programming language, and often not the most > important one. > > Thanks, > Andy > > On Thu, Aug 26, 2010 at 11:59 AM, Isaac Gouy wrote: > > > On Aug 26, 8:37 am, John Fingerhut wrote: > > > I have now submitted small modifications that permit AOT compilation. > > The > > > compile time was small -- on the order of 1 to 2 sec of the total CPU > > time, > > > which is often a small percentage of the long runs that are reported on > > the > > > shootout web site. > > > > But of course it is better if it is not included in the reported times, > > > which it soon will not be. > > > AOT compiled > > >http://shootout.alioth.debian.org/u32q/program.php?test=mandelbrot&la... > > >http://shootout.alioth.debian.org/u32q/program.php?test=regexdna&lang... > > >http://shootout.alioth.debian.org/u32q/program.php?test=knucleotide&l... > > > > Andy > > > > On Thu, Aug 26, 2010 at 12:26 AM, Meikel Brandmeyer > > wrote: > > > > Hi, > > > > > On 26 Aug., 07:58, Isaac Gouy wrote: > > > > > > Have you actually measured the time difference? > > > > > Compare the mandelbrot numbers for Haskell, Java and Scala. The ranges > > > > are (0.07s 0.86s 13s), (0.19s 0.86s 12s), (0.22s 0.97s 15s). So Java > > > > and Scala are not slower than Haskell, but the low iteration numbers > > > > say something different. So you don't measure what you claim you > > > > measure. And the fact that things vanish asymptotically doesn't fix a > > > > broken methodology. > > > > > 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 > > > -- > > 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
Does 'require' with the :reload option have a tendency to build up memory?
I've got a curious little bit of a memory leak of sorts that I'm trying to narrow down. I have an application (betcha can guess what it is if you know me from IRC :>) that, in order to reload plugins, requires each of them with the :reload option whenever you ask them to be reloaded. Each of these plugins calls a macro that defines a set of defmethods for a multimethod in a namespace that never does get reloaded. They also define a single function that isn't a method. Whenever these 'plugins' are reloaded (there are about 20 of them), the memory my application uses is raised by about 3MB, as monitored with htop. It's very consistent and always raises 2-3MB each time. The less plugins being reloaded, the less dramatic the memory jump. Now, my question is: can require with :reload a lot of namespaces like this cause this sort of thing to happen? I mostly just need to know whether or not I'm going in the wrong direction. I've never had this sort of problem before. If so, are there any steps I can take to keep memory from building up like this? -- 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
API for ClojureDocs.org
Hi All, As Zach announced in the ClojureDocs mailing list [1], I'm going to be working on the API for ClojureDocs.org in the coming future. I was hoping to get some feedback regarding what people wanted to see for an API for ClojureDocs: - What kind of features would you like to see in the ClojureDocs API? - What kind of output would you like to see from the API? (json, clojure datastructures, xml, plaintext) Any other feedback is highly appreciated :) - Lee Hinman [1]: http://groups.google.com/group/clojuredocsorg/browse_thread/thread/eb2457a778647bc5 -- 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: building new contrib against a specific clojure jar
On Sep 2, 5:24 pm, Stuart Sierra wrote: > You'll need to adjust the version numbers for the Clojure > dependencies. These are configured in clojure-contrib/modules/parent/ > pom.xml at the line: > > > 1.2.0 > > Change that to 1.3.0-SNAPSHOT for the latest snapshot (including the > ones you build locally) or set it to a specific snapshot version > number > fromhttp://build.clojure.org/snapshots/org/clojure/clojure/1.3.0-master-S... Can it be done on the command line, with -Dclojure.version=... ? -- Alexy -- 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: building new contrib against a specific clojure jar
You'll need to adjust the version numbers for the Clojure dependencies. These are configured in clojure-contrib/modules/parent/ pom.xml at the line: 1.2.0 Change that to 1.3.0-SNAPSHOT for the latest snapshot (including the ones you build locally) or set it to a specific snapshot version number from http://build.clojure.org/snapshots/org/clojure/clojure/1.3.0-master-SNAPSHOT/ -S On Sep 2, 4:36 pm, braver wrote: > I usually git pull clojure, ant, mvn install, then git pull and build > clojure-contrib against it. There used to be a -Dclojure.jar=... > option mentioned in README.txt for the contrib. The new modular > version, however, doesn't mention it, just saying, use these contrib > versions for those clojure ones, such as master for master. Just > doing mvn compile seems to pull clojure-1.2.0. How do we build the > new contrib explicitly against a given clojure jar? > > -- Alexy -- 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
building new contrib against a specific clojure jar
I usually git pull clojure, ant, mvn install, then git pull and build clojure-contrib against it. There used to be a -Dclojure.jar=... option mentioned in README.txt for the contrib. The new modular version, however, doesn't mention it, just saying, use these contrib versions for those clojure ones, such as master for master. Just doing mvn compile seems to pull clojure-1.2.0. How do we build the new contrib explicitly against a given clojure jar? -- Alexy -- 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: Blogs/Twitter accounts about Clojure
Shameless self-promotion: http://clojurls.com (like hackurls.com, but only clojure content only) On 2 Sep., 18:21, HB wrote: > Hey, > Would you please recommend some good Blogs/Twitter accounts about > Clojure? > 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: Blogs/Twitter accounts about Clojure
Hi, On Thu, Sep 2, 2010 at 17:21, HB wrote: > Hey, > Would you please recommend some good Blogs/Twitter accounts about > Clojure? I irregularly maintain a list here: https://twitter.com/#/list/otfrom/clojure -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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
Google has agreed to continue to host the NYC Clojure users group meetings! We need speakers.
Special thanks to Andrey Fedorov for making this happen for us! If you are in the tri-state area and would like to present at the Clojure NYC @google, please contact me with the topic and we'll get it setup. Thanks, Eric -- 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: Blogs/Twitter accounts about Clojure
http://planet.clojure.in/ is all i really need :) On 2 Sep., 18:21, HB wrote: > Hey, > Would you please recommend some good Blogs/Twitter accounts about > Clojure? > 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: Extending Clojure's STM with external transactions
On Wed, 1 Sep 2010 15:14:45 -0700 (PDT) Alyssa Kwan wrote: > I'll go one step further and say that we shouldn't have to call > "persist namespace". It should be automatic such that a change to the > state of an identity is transactionally written. > > Let's start with refs. We can tackle the other identities later. > > The API is simple. Call (refp) instead of (ref) when creating a > persisted ref. Passed into the call are a persistence address (file > path, DB connection string, etc.) and a name that has to be unique to > that persistence address. Not all refs end up being referred to by a > top-level symbol in a package, and multi-process systems are hard... > Ensuring uniqueness of name is up to the programmer. Upon creation, > Clojure checks to see if the refp exists in the store; if so it > instantiates in memory with that state, else it uses the default in > the call. First, I like the idea. But I think it's a bit clunky. Putting the address information directly in the refp means you'll probably need it in multiple places, as the most common usage is probably to store more than one data item in each storage. This strikes me as a bad idea, violating DRY. How about introducing a second part to the api? (store) creates a wrapper for the persistent address, and refp then takes one of those wrappers and the name? http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.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: multiple parameters passed to fns
good suggestions guys!! thx so much On Sep 2, 10:44 am, Justin Kramer wrote: > A couple other things: > 1) (apply identity ...) is the same as (first ...) > 2) Consider using the ->> macro to clean up the let > > Here's a quick rewrite: > > (defn make-target > ([file channel sweepidx] > (make-target file channel sweepidx 0)) > ([file channel sweepidx startidx] > (make-target file channel sweepidx startidx nil)) > ([file channel sweepidx startidx size] > (let [target (->> (graph-part file channel sweepidx (inc > sweepidx)) > first > (drop startidx))] > (if size > (take size target) > target > > Lastly, if graph-part happened to return something like a vector or > string, there are faster ways of taking a slice than take & drop -- > that is, subvec or subs. > > HTH, > > Justin > > On Sep 2, 10:20 am, Miki wrote: > > > > > Hello Glen, > > > I'd use the first two forms to set startidx and size and then call the > > "full" form: > > > (def inf java.lang.Double/POSITIVE_INFINITY) > > > (defn make-target > > "Parses text file for single sweep specified by sweepidx. If size > > is > > not specified will parse till end of sweep. If startidx and size > > are > > not spefified will parse from beginning to end" > > ([file channel sweepidx] > > (make-target file channel sweepidx 0 inf)) > > ([file channel sweepidx startidx] > > (make-target file channel sweepidx startidx inf)) > > ([file channel sweepidx startidx size] > > ([file channel sweepidx startidx size] > > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > > > sweepidx)) > > collated-target2 (apply identity collated-target1) > > ;apply starting point and size parameters > > collated-target3 (take size (drop startidx collated- > > target2))] > > collated-target3))) > > > On Sep 2, 5:54 am, Glen Rubin wrote: > > > > I defined a fn whose execution depends on the number of parameters > > > passed to it. It works fine! I am just concerned that I am doing > > > this in a way that is not as concise as it could or should be. Here > > > is my fn: > > > > (defn make-target > > > > "Parses text file for single sweep specified by sweepidx. If size is > > > not specified will parse till end of sweep. If startidx and size are > > > not spefified will parse from beginning to end" > > > > ([file channel sweepidx] > > > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > > > sweepidx)) > > > ;break open double parens > > > collated-target2 (apply identity collated-target1)] > > > collated-target2)) > > > > ([file channel sweepidx startidx] > > > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > > > sweepidx)) > > > collated-target2 (apply identity collated-target1) > > > ;;apply starting point > > > collated-target3 (drop startidx collated-target2)] > > > collated-target3)) > > > > ([file channel sweepidx startidx size] > > > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > > > sweepidx)) > > > collated-target2 (apply identity collated-target1) > > > ;apply starting point and size parameters > > > collated-target3 (take size (drop startidx collated-target2))] > > > collated-target3))) -- 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: Blogs/Twitter accounts about Clojure
a few off the top of my head: @fogus @planetclojure @disclojure @stuartholloway @liebke @richhickey blog.fogus.me dosync.posterous.com m.3wa.com nathanmarz.com On Thu, Sep 2, 2010 at 12:21 PM, HB wrote: > Hey, > Would you please recommend some good Blogs/Twitter accounts about > Clojure? > Thanks. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
json parsing issues with apache cxf integration
I am trying to build a rest webservice using compojure/ring and json marshalling. the consumers of the web service are written in java and we are thinking of using apache cxf. when i am trying to send an object using jsonprovider , it is getting correctly parsed at the client end but on using ring.middleware.json- params and passing a multi-level map, the map kinds of gets unreadable . My method is the reference cabinet http://mmcgrana.github.com/2010/08/clojure-rest-api.html for name when I use curl -X PUT -H "Content-Type: application/json" \ -d '{"name": "hacker"}' \ http://localhost:8080/ ,it works fine but suppose I use '{"name": {"part1" : "part2"}}, we have a problem. {"part1":"part2"} becomes {part1 part2} instead of {"part1" "part2"} or {:part1 "part2"} so that I can use (:part1 name) in the put method or ("part1" name). I tried over riding the json- params file by using read-json of clojure contrib but it parsed the input as {:part1 part2}. this will wrk fine for clojure part of it but I am building a content generation service which will pass some maps to ftl. hence {:part1 part2} wont wrk there. Interestingly, (.get name "part1") while ("part1" name) does not work. Furthur testing the webservice using ff-plugin wrk as {"part1" "part2"}. However on using cxf JaxrsClientFactory and curl, it does not work any ideas ??? I am just a week old to clojure so, I might be asking very trivial questions. -- 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: multiple parameters passed to fns
On Thu, 2 Sep 2010 05:54:26 -0700 (PDT) Glen Rubin wrote: > I defined a fn whose execution depends on the number of parameters > passed to it. It works fine! I am just concerned that I am doing > this in a way that is not as concise as it could or should be. Here > is my fn: > > (defn make-target > > "Parses text file for single sweep specified by sweepidx. If size is > not specified will parse till end of sweep. If startidx and size are > not spefified will parse from beginning to end" > > ([file channel sweepidx] > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > sweepidx)) > ;break open double parens > collated-target2 (apply identity collated-target1)] > collated-target2)) > > ([file channel sweepidx startidx] > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > sweepidx)) > collated-target2 (apply identity collated-target1) > ;;apply starting point > collated-target3 (drop startidx collated-target2)] > collated-target3)) > > ([file channel sweepidx startidx size] > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > sweepidx)) > collated-target2 (apply identity collated-target1) > ;apply starting point and size parameters > collated-target3 (take size (drop startidx collated-target2))] > collated-target3))) > The variants already posted - using the shorter argument list variants to provide default arguments to the longer ones - is the idiomatic approach. I missed those and saw this alternative, and figured it was worth posting for comparison, if nothing else: (defn make-target "Parses text file for single sweep specified by sweepidx. If size is not specified will parse till end of sweep. If startidx and size are not spefified will parse from beginning to end" ([file channel sweepidx] (let [collated-target1 (graph-part file channel sweepidx (+ 1 sweepidx)) ;break open double parens collated-target2 (apply identity collated-target1)] collated-target2)) ([file channel sweepidx startidx] (drop startidx (make-target file channel sweepidx))) ([file channel sweepidx startidx size] (take size (make-target file channel sweepidx startidx -- Mike Meyer http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.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
Blogs/Twitter accounts about Clojure
Hey, Would you please recommend some good Blogs/Twitter accounts about Clojure? 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: RT vs recasting
Ah...so I looked into the RT code a bit more and you're right. If we passed in a Java array or a Java String then it would need to be converted to a Seqable class first then we could have a seq() method to call. Thanks, Timothy On Thu, Sep 2, 2010 at 9:43 AM, Armando Blancas wrote: > Probably so the list can be compared to anything and thus o may not > implement Seqable, like: > user=> (.equals '() nil) > false > > On Sep 1, 4:14 pm, Timothy Baldridge wrote: >> While examining the Clojure source I came across this line in the >> EmptyList class: >> >> public boolean equals(Object o) { >> return (o instanceof Sequential || o instanceof List) && >> RT.seq(o) == null; >> } >> >> What's up with the RT.seq(o) == null? Why don't we do this instead: >> >> public boolean equals(Object o) { >> return (o instanceof Sequential || o instanceof List) && o >> instanceof Seqable && ((Seqable)o).seq(o) == null; >> } >> >> I've seen RT used in other places as well, I guess I don't understand >> why it's used here, or what it is at all >> >> Timothy >> >> -- >> “One of the main causes of the fall of the Roman Empire was >> that–lacking zero–they had no way to indicate successful termination >> of their C programs.” >> (Robert Firth) > > -- > 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 -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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
union using a comparison function
Hi. I'd like to do a union of some sequences using my own comparison function. Similar to supplying a Comparator in Java. The things being compared are Objects from a Java library that I don't control, so I can't just override the equals function on the class, for example. Would aprecaite any suggestions. thanks, Marc -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: multiple parameters passed to fns
A couple other things: 1) (apply identity ...) is the same as (first ...) 2) Consider using the ->> macro to clean up the let Here's a quick rewrite: (defn make-target ([file channel sweepidx] (make-target file channel sweepidx 0)) ([file channel sweepidx startidx] (make-target file channel sweepidx startidx nil)) ([file channel sweepidx startidx size] (let [target (->> (graph-part file channel sweepidx (inc sweepidx)) first (drop startidx))] (if size (take size target) target Lastly, if graph-part happened to return something like a vector or string, there are faster ways of taking a slice than take & drop -- that is, subvec or subs. HTH, Justin On Sep 2, 10:20 am, Miki wrote: > Hello Glen, > > I'd use the first two forms to set startidx and size and then call the > "full" form: > > (def inf java.lang.Double/POSITIVE_INFINITY) > > (defn make-target > "Parses text file for single sweep specified by sweepidx. If size > is > not specified will parse till end of sweep. If startidx and size > are > not spefified will parse from beginning to end" > ([file channel sweepidx] > (make-target file channel sweepidx 0 inf)) > ([file channel sweepidx startidx] > (make-target file channel sweepidx startidx inf)) > ([file channel sweepidx startidx size] > ([file channel sweepidx startidx size] > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > > sweepidx)) > collated-target2 (apply identity collated-target1) > ;apply starting point and size parameters > collated-target3 (take size (drop startidx collated- > target2))] > collated-target3))) > > On Sep 2, 5:54 am, Glen Rubin wrote: > > > > > I defined a fn whose execution depends on the number of parameters > > passed to it. It works fine! I am just concerned that I am doing > > this in a way that is not as concise as it could or should be. Here > > is my fn: > > > (defn make-target > > > "Parses text file for single sweep specified by sweepidx. If size is > > not specified will parse till end of sweep. If startidx and size are > > not spefified will parse from beginning to end" > > > ([file channel sweepidx] > > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > > sweepidx)) > > ;break open double parens > > collated-target2 (apply identity collated-target1)] > > collated-target2)) > > > ([file channel sweepidx startidx] > > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > > sweepidx)) > > collated-target2 (apply identity collated-target1) > > ;;apply starting point > > collated-target3 (drop startidx collated-target2)] > > collated-target3)) > > > ([file channel sweepidx startidx size] > > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > > sweepidx)) > > collated-target2 (apply identity collated-target1) > > ;apply starting point and size parameters > > collated-target3 (take size (drop startidx collated-target2))] > > collated-target3))) -- 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: RT vs recasting
Probably so the list can be compared to anything and thus o may not implement Seqable, like: user=> (.equals '() nil) false On Sep 1, 4:14 pm, Timothy Baldridge wrote: > While examining the Clojure source I came across this line in the > EmptyList class: > > public boolean equals(Object o) { > return (o instanceof Sequential || o instanceof List) && > RT.seq(o) == null; > } > > What's up with the RT.seq(o) == null? Why don't we do this instead: > > public boolean equals(Object o) { > return (o instanceof Sequential || o instanceof List) && o > instanceof Seqable && ((Seqable)o).seq(o) == null; > } > > I've seen RT used in other places as well, I guess I don't understand > why it's used here, or what it is at all > > Timothy > > -- > “One of the main causes of the fall of the Roman Empire was > that–lacking zero–they had no way to indicate successful termination > of their C programs.” > (Robert Firth) -- 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: Tutorial: clojure.zip
Meant to thank you for this. It was very timely for me, and very understandable. On Thu, Sep 2, 2010 at 10:34 AM, Brian Marick wrote: > I've written a short tutorial for clojure.zip: > > > http://www.exampler.com/blog/2010/09/01/editing-trees-in-clojure-with-clojurezip/ > > - > Brian Marick, independent consultant > Mostly on agile methods with a testing slant > Author of /Programming Cocoa with Ruby/ > www.exampler.com, www.exampler.com/blog, www.twitter.com/marick > > -- > 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
Tutorial: clojure.zip
I've written a short tutorial for clojure.zip: http://www.exampler.com/blog/2010/09/01/editing-trees-in-clojure-with-clojurezip/ - Brian Marick, independent consultant Mostly on agile methods with a testing slant Author of /Programming Cocoa with Ruby/ www.exampler.com, www.exampler.com/blog, www.twitter.com/marick -- 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: Extending Clojure's STM with external transactions
>It checks the value against memory. If it's >the same, commit data store changes. If not, retry after refreshing >memory with the current contents of the store. May I suggest we take a page from the CouchDB book here? In addition to having a "id" each ref also has a revision id. Let's say the id for my ref is "foo". Then the first time I modify that ref the revid becomes "1-foo". From there the 1- is incremented by one on each writing transaction. This allows for a single string load & compare for each change, instead of reading the entire contents of the ref. That combined with CouchDB's copy-on-write means that you can kill a couchDB process mid-execution, and then restart it without any data corruption at all. If we find a way to do external persistence...that would be awesome, I can think of several use cases for it right now. Timothy -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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: multiple parameters passed to fns
Hello Glen, I'd use the first two forms to set startidx and size and then call the "full" form: (def inf java.lang.Double/POSITIVE_INFINITY) (defn make-target "Parses text file for single sweep specified by sweepidx. If size is not specified will parse till end of sweep. If startidx and size are not spefified will parse from beginning to end" ([file channel sweepidx] (make-target file channel sweepidx 0 inf)) ([file channel sweepidx startidx] (make-target file channel sweepidx startidx inf)) ([file channel sweepidx startidx size] ([file channel sweepidx startidx size] (let [collated-target1 (graph-part file channel sweepidx (+ 1 sweepidx)) collated-target2 (apply identity collated-target1) ;apply starting point and size parameters collated-target3 (take size (drop startidx collated- target2))] collated-target3))) On Sep 2, 5:54 am, Glen Rubin wrote: > I defined a fn whose execution depends on the number of parameters > passed to it. It works fine! I am just concerned that I am doing > this in a way that is not as concise as it could or should be. Here > is my fn: > > (defn make-target > > "Parses text file for single sweep specified by sweepidx. If size is > not specified will parse till end of sweep. If startidx and size are > not spefified will parse from beginning to end" > > ([file channel sweepidx] > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > sweepidx)) > ;break open double parens > collated-target2 (apply identity collated-target1)] > collated-target2)) > > ([file channel sweepidx startidx] > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > sweepidx)) > collated-target2 (apply identity collated-target1) > ;;apply starting point > collated-target3 (drop startidx collated-target2)] > collated-target3)) > > ([file channel sweepidx startidx size] > (let [collated-target1 (graph-part file channel sweepidx (+ 1 > sweepidx)) > collated-target2 (apply identity collated-target1) > ;apply starting point and size parameters > collated-target3 (take size (drop startidx collated-target2))] > collated-target3))) -- 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
multiple parameters passed to fns
I defined a fn whose execution depends on the number of parameters passed to it. It works fine! I am just concerned that I am doing this in a way that is not as concise as it could or should be. Here is my fn: (defn make-target "Parses text file for single sweep specified by sweepidx. If size is not specified will parse till end of sweep. If startidx and size are not spefified will parse from beginning to end" ([file channel sweepidx] (let [collated-target1 (graph-part file channel sweepidx (+ 1 sweepidx)) ;break open double parens collated-target2 (apply identity collated-target1)] collated-target2)) ([file channel sweepidx startidx] (let [collated-target1 (graph-part file channel sweepidx (+ 1 sweepidx)) collated-target2 (apply identity collated-target1) ;;apply starting point collated-target3 (drop startidx collated-target2)] collated-target3)) ([file channel sweepidx startidx size] (let [collated-target1 (graph-part file channel sweepidx (+ 1 sweepidx)) collated-target2 (apply identity collated-target1) ;apply starting point and size parameters collated-target3 (take size (drop startidx collated-target2))] collated-target3))) -- 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: Extending Clojure's STM with external transactions
Persistant variable handling is one of the things which I have spent much time on as a beginner and former SQL-illiterate (Among getting the swank to finally work (it's a dream!)). I have however got into databases quite a bit among the way - but it was not my main goal and it has taken some time from "the real task". I have looked into clj-record, which seems to be highly usable as well, but the persistant refs-idea IMHO may feel a bit more elegant. An easy way of persistence would be highly valuable when developing web applications with compojure in :reload-mode, since it seems to lose normal persistant refs after each reload in the browser. It would be valuable in production environments as well, of course. /Linus 2010/9/2 Alyssa Kwan > I'll go one step further and say that we shouldn't have to call > "persist namespace". It should be automatic such that a change to the > state of an identity is transactionally written. > > Let's start with refs. We can tackle the other identities later. > > The API is simple. Call (refp) instead of (ref) when creating a > persisted ref. Passed into the call are a persistence address (file > path, DB connection string, etc.) and a name that has to be unique to > that persistence address. Not all refs end up being referred to by a > top-level symbol in a package, and multi-process systems are hard... > Ensuring uniqueness of name is up to the programmer. Upon creation, > Clojure checks to see if the refp exists in the store; if so it > instantiates in memory with that state, else it uses the default in > the call. > > In a dosync block, the function runs as normal until commit time. > Then Clojure acquires a transactional write lock on each refp that is > alter-ed or ensure-d. It checks the value against memory. If it's > the same, commit data store changes. If not, retry after refreshing > memory with the current contents of the store. If the data store > commit fails, retry a number of times. If the data store commit still > can't proceed, roll back the whole thing. commute and refset are > slightly different, but for an initial implementation, just treat > commute as an alter, and ignore refset. > > Does this make sense? > > My intention is to cover the 80% case. The implementation would > necessarily be chatty, since the API is chatty. That's OK for most > systems. > > This API has the benefit of being able to be shared across Clojure > instances. It's a nice bonus. > > A dosync block may contain symbols pointing to refp's spanning > different data stores, which isn't too hard to handle. It simply > requires that if this is the case, each data store must support two- > phase commit or some other distributed transaction supporting > protocol. For an initial implementation, I would just throw an > exception. > > I've begun working on an implementation using BDB. > > What do people think? > > On Aug 30, 5:02 pm, nchubrich wrote: > > I'm not aware of any, but +1 for seeing persistence handled as part of > > the language. A big project and a long-term one, to be sure, but > > could it not be considered a goal? > > > > In my student days, I was talking to a well-known Lisper (name > > suppressed for fear of Google indexing) about some data structures in > > MIT Scheme. When I asked about saving them to disk, he said in > > effect, "You're on your ownthat's something that \should be > > handled, but never is". > > > > I think people are so used to this state of affairs they forget how > > ugly it really is. Programming languages are like Moses without > > Joshua: they lead your data in the wilderness, but when it comes to > > finding it a permanent home, you have to talk to someone else. And > > these "someone elses" (who seem to be as numberless as the sons of > > Abraham) each have their own habits and ways of talking. > > > > Persistence libraries always end up warping the entire codebase; I've > > never succeeded in keeping them at bay. Using data with Incanter is > > different from ClojureQL, which is different from just using > > contrib.sql, and all of it is different from dealing with just > > Clojure. (I've never even tried Clojure + Hibernate.) You might as > > well rewrite the program from scratch depending on what you use. > > Maybe other people have had better luck; but whatever luck they have, > > I'm sure it is a fight to keep programs abstracted from persistence. > > > > I'd like to be able to work with mere Clojure until my program is > > complete, and then work in a completely separate manner on how to read > > and write data. Or maybe there would be off-the-shelf solutions I > > could plug in for different needs: low latency, high read, high write, > > large stores, etc. > > > > On the Clojure side, you would simply call something like "persist > > namespace", which would save the state of your current or given > > namespace (unless you pass it the names of variables as well, in which > > case it only saves those). And
Re: How to use Java array of primitive types as key of Clojure map?
Thanks! That worked for me. Understood on the precautions about these things not being immutable, and thus potentially unsafe as hash keys (and anything else that expects immutability, whether that is obvious or not). This raises the question in my mind -- will there be something in Clojure, perhaps for Clojure-in-Clojure, that allows any old Clojure programmer to create their own immutable types? Perhaps with deftype or some future extension of it? Sorry if this is widely known and I'm just behind the news, but I had read recently that a motivation for deftype is to get closer to the point where more of Clojure can be implemented in itself. I don't expect there to be *guarantees* provided by the compiler or run-time that the interface provided above a given API layer implements a persistent data structure, because that sounds impossible to guarantee in general. But the only guarantee that we have that Clojure vectors, maps, sequences, etc. are immutable and persistent is that the Java implementations correctly implement those features, with no automated checking of those properties. Thanks, Andy On Wed, Sep 1, 2010 at 7:11 AM, Stuart Halloway wrote: > Be super-careful doing this. Java's array equality and hashCode are > correct: since arrays are mutable, they are not values. So equals and > hashCode are correctly identity-based. > > Also, 1.2's vector-of lets you have vectors of primitives, which may give > you the perf you need. > > But, if you can ensure that the arrays will be used as values: > > (ns key > (:require [clojure.string :as str])) > > (deftype Key [key] > Object > (equals [this other] > (if (= (class this) (class other)) > (java.util.Arrays/equals ^ints key ^ints (.key ^Key other)) > false)) > (hashCode [this] > (java.util.Arrays/hashCode ^ints key)) > (toString [this] > (str/join \, (seq key > > (defn int-key [coll] > (Key. (int-array (count coll) coll))) > > Stu > > Stuart Halloway > Clojure/core > http://clojure.com > > If you don't do anything special, and create several Java array of bytes > (for example) and use them as keys in a Clojure map, the default hashCode > and equals implementation will cause two arrays with identical contents to > be treated as different keys in the map, unless they are also == in Java. > > I'd like to use Java byte arrays as keys in Clojure maps, but haven't been > able to figure out how yet. I know that java.util.Arrays/hashCode and > java.util.Arrays/equals have the behavior I want, so one way would be to get > Clojure to somehow use those methods when given the byte arrays as keys. > That led me to think of trying deftype to make my own type Key with the > desired implementation of hashCode and equals. I'm using Clojure 1.2, and I > don't see how to give the appropriate type hints to declare that something > is a Java byte array. Here is one attempt for Java int arrays instead of > Java byte arrays: > > (definterface IKey > (^ints key []) > (equals [other-key] "Compare two Keys for value equality, i.e. same > length and same bytes in array value") > (hashCode [] "Return a hash code that is the same for equal keys, and > usually different for different keys")) > > > (deftype Key [^ints key] > IKey > (key [this] key) > (equals [this other-key] > (let [^Key other other-key] > (java.util.Arrays/equals key (.key other > (hashCode [this] > (java.util.Arrays/hashCode key)) > > Object > (toString [this] > (apply str (map char key > > When I try to evaluate the deftype statement, I get an error like this: > > java.lang.NoClassDefFoundError: java/lang/ints > > Same error if I replace ^ints with #^ints. If I leave out the type hints > for the field key completely, I get the following error when trying to > evaluate the deftype: > > java.lang.VerifyError: (class: user/Key, method: hashCode signature: > ()Ljava/lang/Object;) Expecting to find object/array on stack > > I'm not wedded to deftype as being part of the solution. My real goal is > as high performance way of using Java byte/int/some-native-type arrays as > map keys, i.e. with no reflection warnings. > > Thanks, > Andy > > > -- > 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...@googleg
Re: Clojure 1.2 and the Computer Language Benchmarks Game
Thanks to many people on this list in Aug 2009 who helped improve my code, to Johannes Friestad for writing a nice fast Clojure program using deftype for the n-body problem, to Isaac Gouy for setting up the shootout web site to accept Clojure submissions, and to my having more time than good sense to work on this, there are now Clojure programs for 5 of the 10 shootout web site benchmark problems. You can see a brief summary of results comparing run time, memory, and code size against "Java 6 -server" here: http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=clojure&lang2=java Note: All Clojure programs are AOT compiled before any time measurements are made when running the program. The programs are short enough that I believe the longest one was around 1.5 or 2 seconds on my MacBook Pro, but that time isn't included on the web site results. Are there improvements that could be made to the Clojure programs to make them faster? Most likely so. I doubt very much these are the fastest ones possible. I have not written any Java code for these solutions. I am sure that when push comes to shove in improving the run time of parts of a real-world program that were performance-critical, most programmers would optimize using Java or even C/C++. The goal here was to see what could be done without using those techniques. If people want to beat each other up using the shootout web site's results, I would probably recognize in them some of the "my language is best for every purpose" attitude I once had as a teenager. Now I just see it as one of several ways to evaluate a programming language, and often not the most important one. Thanks, Andy On Thu, Aug 26, 2010 at 11:59 AM, Isaac Gouy wrote: > > > On Aug 26, 8:37 am, John Fingerhut wrote: > > I have now submitted small modifications that permit AOT compilation. > The > > compile time was small -- on the order of 1 to 2 sec of the total CPU > time, > > which is often a small percentage of the long runs that are reported on > the > > shootout web site. > > > > But of course it is better if it is not included in the reported times, > > which it soon will not be. > > > AOT compiled > > > http://shootout.alioth.debian.org/u32q/program.php?test=mandelbrot&lang=clojure&id=2 > > > http://shootout.alioth.debian.org/u32q/program.php?test=regexdna&lang=clojure&id=2 > > > http://shootout.alioth.debian.org/u32q/program.php?test=knucleotide&lang=clojure&id=1 > > > > > > > > > Andy > > > > On Thu, Aug 26, 2010 at 12:26 AM, Meikel Brandmeyer > wrote: > > > Hi, > > > > > On 26 Aug., 07:58, Isaac Gouy wrote: > > > > > > Have you actually measured the time difference? > > > > > Compare the mandelbrot numbers for Haskell, Java and Scala. The ranges > > > are (0.07s 0.86s 13s), (0.19s 0.86s 12s), (0.22s 0.97s 15s). So Java > > > and Scala are not slower than Haskell, but the low iteration numbers > > > say something different. So you don't measure what you claim you > > > measure. And the fact that things vanish asymptotically doesn't fix a > > > broken methodology. > > > > > 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 > > -- > 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
RT vs recasting
While examining the Clojure source I came across this line in the EmptyList class: public boolean equals(Object o) { return (o instanceof Sequential || o instanceof List) && RT.seq(o) == null; } What's up with the RT.seq(o) == null? Why don't we do this instead: public boolean equals(Object o) { return (o instanceof Sequential || o instanceof List) && o instanceof Seqable && ((Seqable)o).seq(o) == null; } I've seen RT used in other places as well, I guess I don't understand why it's used here, or what it is at all Timothy -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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: Extending Clojure's STM with external transactions
I'll go one step further and say that we shouldn't have to call "persist namespace". It should be automatic such that a change to the state of an identity is transactionally written. Let's start with refs. We can tackle the other identities later. The API is simple. Call (refp) instead of (ref) when creating a persisted ref. Passed into the call are a persistence address (file path, DB connection string, etc.) and a name that has to be unique to that persistence address. Not all refs end up being referred to by a top-level symbol in a package, and multi-process systems are hard... Ensuring uniqueness of name is up to the programmer. Upon creation, Clojure checks to see if the refp exists in the store; if so it instantiates in memory with that state, else it uses the default in the call. In a dosync block, the function runs as normal until commit time. Then Clojure acquires a transactional write lock on each refp that is alter-ed or ensure-d. It checks the value against memory. If it's the same, commit data store changes. If not, retry after refreshing memory with the current contents of the store. If the data store commit fails, retry a number of times. If the data store commit still can't proceed, roll back the whole thing. commute and refset are slightly different, but for an initial implementation, just treat commute as an alter, and ignore refset. Does this make sense? My intention is to cover the 80% case. The implementation would necessarily be chatty, since the API is chatty. That's OK for most systems. This API has the benefit of being able to be shared across Clojure instances. It's a nice bonus. A dosync block may contain symbols pointing to refp's spanning different data stores, which isn't too hard to handle. It simply requires that if this is the case, each data store must support two- phase commit or some other distributed transaction supporting protocol. For an initial implementation, I would just throw an exception. I've begun working on an implementation using BDB. What do people think? On Aug 30, 5:02 pm, nchubrich wrote: > I'm not aware of any, but +1 for seeing persistence handled as part of > the language. A big project and a long-term one, to be sure, but > could it not be considered a goal? > > In my student days, I was talking to a well-known Lisper (name > suppressed for fear of Google indexing) about some data structures in > MIT Scheme. When I asked about saving them to disk, he said in > effect, "You're on your ownthat's something that \should be > handled, but never is". > > I think people are so used to this state of affairs they forget how > ugly it really is. Programming languages are like Moses without > Joshua: they lead your data in the wilderness, but when it comes to > finding it a permanent home, you have to talk to someone else. And > these "someone elses" (who seem to be as numberless as the sons of > Abraham) each have their own habits and ways of talking. > > Persistence libraries always end up warping the entire codebase; I've > never succeeded in keeping them at bay. Using data with Incanter is > different from ClojureQL, which is different from just using > contrib.sql, and all of it is different from dealing with just > Clojure. (I've never even tried Clojure + Hibernate.) You might as > well rewrite the program from scratch depending on what you use. > Maybe other people have had better luck; but whatever luck they have, > I'm sure it is a fight to keep programs abstracted from persistence. > > I'd like to be able to work with mere Clojure until my program is > complete, and then work in a completely separate manner on how to read > and write data. Or maybe there would be off-the-shelf solutions I > could plug in for different needs: low latency, high read, high write, > large stores, etc. > > On the Clojure side, you would simply call something like "persist > namespace", which would save the state of your current or given > namespace (unless you pass it the names of variables as well, in which > case it only saves those). And to read data, you would simply require > or use it into your namespace: you could choose what granularity to > give first-class status: just tables, or columns as well, etc. And > you could do this equally well for XML, JSON, relational data, or a > graph store; your choice. And the only difference between these and > ordinary variables would beheaven forbid!a disk access might > happen when you deal with them! > > To have such a system work well, you would need to enrich the way you > query Clojure datastructures. I have some ideas on that, but I'd like > to make sure I'm not shouting in the dark first. > > I'd like to see a day when programmers need to worry about persistence > about as much as they worry about garbage collection now. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegrou