Re: Question about sorted-sets
Yes that compareTo doesn't define a total order on your class. I think you are missing a clause in cond: (cond (= sr sr2) 0 (= (.lik sr) (.lik s2)) return something based on quasi-isomorphic (> (.lik sr) (.lik sr2)) -1 :default 1) I think you should implement quasi-isomorphic as a compare function (Comparator), then: equals: (and (= lik (.lik other)) (= 0 (compare-quasi-isomorphism tree (.tree other compareTo: (let [l (- (.lik sr) (.lik sr2)) q (compare-quasi-isomorphism (.tree sr) (.tree sr2))] (cond (and (= l 0) (= q 0)) 0 (not= l 0) l (not= q 0) q :default 1)) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
Hi, of course this doesn't help you directly, because you don't like vi, but it may be of interest for other vi users. On 12 Jan., 04:40, Mark Engelberg wrote: > Looking back over the above comments, it looks like my major checklist > points for an IDE are: > 1. Reasonable set of editing features (indenting, formatting, paren matching) Check. YMMV. > 2. An easy way to load all the relevant code and dependencies into a REPL. Check. Vim itself does not provide that. But it is easy to use lein, cake or gradle to fire up the backend server. For lein there exists a third-party plugin. For gradle there will be a plugin with the next release of VimClojure, but at the moment it is possible by using a simple custom task. > 3. An easy way to make the REPL obey the -server flag, and use the > proper version of Clojure for a given project. Check. Depends on 2., but with gradle it's trivial. > 4. A way to come back to where I left off with a given project. Check. Vim supports sessions, although I can't tell how well it works. I never used them. Repl state will be lost however. > 5. A way to compile projects for standalone use. Check. Again: Depends on 2. Trivial with gradle. (You mean something like "uberjar", I presume.) > 6. A way to debug and profile code. Half-check. Adding debug stuff is on the list of open issues for VimClojure. However something like debug-repl is likely not possible due to limitations in Vim. This is highly non-trivial. For profiling I used jvisualvm in the past with great success. Got it up and running and results within minutes without having used it before. Very cool. > Anyone have anything working on Windows that fits this list? I use an identical setup of VimClojure and gradle on Mac, Windows and Linux. And it works everywhere without problems. Although I don't really guarantee Windows support in VimClojure. Of course, I'm biased. 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: running just one test
@Bill, If you have a REPL open you can just run the test as a zero arg function. (ns 'abc) (detest xyz ...) user=> (abc/xyz) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
Here's one way to use eclipse + ccw + lein 1. Download latest eclipse helios. Go to market place and search for counter clockwise plugin. Install the latest stable. 2. Create a new Clojure project. Delete the 4 jars it provides :) (yes that's right delete them). 3. Install lein (https://github.com/technomancy/leiningen). 4. Create a new project.clj (top level of your project) with clojure 1.2 & clojure-contrib 1.2 dep (or even 1.3-alpha4). 5. Open up a cmd and cd to your project and do >lein deps. (It will add jars to the lib directory in your project folder). 6. Right click on your project in eclipse, go to properties > java build path. Remove the 4 jar entries already present. Then 'Add jars' by selecting your lib folder. This will amend a a file '.classpath' in your project, you can directly amend that and refresh your project too (its the same). The entries present in .classpath are used as the -cp argument (along with some more dirs) to launch the clojure REPL (there's no magic). 7. Done! Right click on project and Run As Clojure REPL. For adding any new deps, just add the entry in project.clj and repeat steps 5., 6. above. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
easiest way to do this is, Go to Run-> Edit Configuration. under clojure script, you'll see options for VM parameters, and a checkbox on "run script in REPL". the plugin is actively being developed. in fact, it has been rewritten in clojure. Most recent release was on Dec 29th http://plugins.intellij.net/plugin/?id=4050 On Tue, Jan 11, 2011 at 10:40 PM, Mark Engelberg wrote: > IntelliJ/La Clojure: I tried this briefly when it first came out. I > liked the look and feel of IntelliJ and found it to be the most > intuitive of the IDEs I tried. I couldn't figure out how to run the > REPL with customized java flags (such as -server), and I encountered > several formatting errors and bugs that were frustrating. I reported > the problems and checked back several months later, and as far as I > could tell, nothing had changed. So I gave up, assuming the plug-in > wasn't being actively developed. I never got far enough with it to > determine how it fares on other criteria, such as ease of creating a > customized project REPL with the right combination of dependencies, > the ease of compiling some sort of standalone app, ease of > debugging/profiling, etc. -- 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: Clojure Quizzes?
hurrr. teh codes are at https://gist.github.com/775623 sorry for leaving that out. I'm rather new at this; all criticisms are welcome. ---Robert McIntyre On Tue, Jan 11, 2011 at 10:07 PM, Robert McIntyre wrote: > Coderloop is a lot of fun. I'm wondering how people are submitting their > code? > > You can use the latest version of clojure if you include it as a > dependency in your submission, so even though they say they only > support clojure1.0 they really support all of them. > > I wrote a short clojure program that automatically packages a clojure > namespace and it's particular minimal set of dependencies into a > tar.bz2 file with the executable that they want. > > If anyone's interested, I'd love to hear his/her thoughts on this code. > > A few thoughts: > Should it automatically AOT compile everything and package it all in > an executable jar? > Can I use a pure java implementation of bzip and tar without calling > out to the system's tar command? > > (I'm bortreb on coderloop btw) > > sincerely, > --Robert McIntyre > > On Tue, Jan 11, 2011 at 9:17 PM, Sean Corfield wrote: >> Ah, that does look like more fun - thanx for the link, hadn't heard of >> it before! >> >> On Wed, Jan 5, 2011 at 10:11 PM, benjamin.s.r >> wrote: >>> http://coderloop.com/ like Project Euler but more modern >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with your >> first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
A related question: What IDE are people on Windows using? I've struggled for a long time to find an acceptable environment on Windows and would love to have more detailed pointers. My experience: Clojure Box - Easiest way to get started. Runs without much hassle. Dependency management is difficult, in part because it doesn't integrate with the community-standard tools such as lein and clojars. It is possible to set up a classpath and install libs for the whole environment, but I've never figured out how to do it on a per project basis, launching a "project-oriented REPL" that has exactly the dependencies needed for a given project. Only runs the latest stable version, so there's no way to play around with alphas or go back and forth between projects that use 1.1 and 1.2. I've also never figured out how to do any debugging/profiling in Clojure Box. Also, don't know how to build any kind of standalone jar in Clojure Box. Some libraries don't seem to work with Clojure Box (e.g., Clojuratica), and messages printed in multi-threaded apps don't always show up. lein/emacs - Getting lein to run under Windows has been an ongoing struggle. It sort of works, but there are a lot of little problems. I've made lots of edits to my batch file to try to address the problems, but then it becomes difficult to update to new versions of lein. Some of the problems I've encountered: REPL doesn't use version of Clojure specified in the project file; doesn't use specified jvm flags; tests don't work. Whereas Clojure Box starts you right up in a REPL, with lein/emacs it is a multi-step process in which you first have to start a swank server from the command line, and then slime-connect to it from emacs (usually generating a bunch of warnings about mismatched versions). The good part is that the REPL is then customized specifically for your project with all the right dependencies. Also, compiling uberjars is easy. The bad part is that killing threads and restarting the session from within emacs doesn't seem to work, so it's quite a hassle to stop and restart everything when you get caught in an infinite loop. As with Clojure Box, I've never figured out how to debug or profile code in lein/emacs. My favorite part about emacs: Emacs is incredibly stable, and I run it for days without closing it, and have no trouble. General complaints about emacs: My #1 issue with emacs is that I don't know how save my "workspace" so that I can return to emacs and automatically open the last set of files I was working on, and my places within them. It's always a big hassle when I sit down to work to open up all the files manually and find my places. I don't like the way so many of the keystrokes conflict with the normal keystrokes used in other programs, so when I get in the habit of typing, say Ctrl-X Ctrl-S to save a file, and then do it in another file, I discover I've accidentally "cut" a huge block of text and then saved it. It's so out-of-step with other apps, it's very frustrating to use. I've learned how to adjust some of the keystrokes in the config file, but inevitably, these modifications end up clashing with other packages. I've experimented with paredit and org-mode, and if you use things like CUA or other customizations, they just don't work that well. Lots of little things don't work quite right in emacs (at least on Windows), for example, dragging a file onto emacs to edit it, and copying and pasting between apps. Netbeans/Enclojure: Lots of nice stuff here. The REPL works very well, and is easy to restart. I found Netbeans' source control integration to be easy to use. You can build a standalone app which places the dependencies in a folder, but I don't know of a way to build an uberjar using Netbeans/Enclojure. If you know what jars you want, it's easy enough to add them to the project and get a custom REPL that sees those jars. Unfortunately, many Clojure libraries assume you are using lein to automatically download chains of dependencies; it can be hard to find all the relevant jars and add them manually to the project. For me, the #1 showstopper is that Enclojure becomes unreliable after about an hour of use, and any customized settings are repeatedly lost. I tried to update to the latest versions of Netbeans/Enclojure to see if things had gotten better, but just experienced a whole lot of breakage. IntelliJ/La Clojure: I tried this briefly when it first came out. I liked the look and feel of IntelliJ and found it to be the most intuitive of the IDEs I tried. I couldn't figure out how to run the REPL with customized java flags (such as -server), and I encountered several formatting errors and bugs that were frustrating. I reported the problems and checked back several months later, and as far as I could tell, nothing had changed. So I gave up, assuming the plug-in wasn't being actively developed. I never got far enough with it to determine how it fares on other criteria, such as ease of
Re: Clojure Quizzes?
Coderloop is a lot of fun. I'm wondering how people are submitting their code? You can use the latest version of clojure if you include it as a dependency in your submission, so even though they say they only support clojure1.0 they really support all of them. I wrote a short clojure program that automatically packages a clojure namespace and it's particular minimal set of dependencies into a tar.bz2 file with the executable that they want. If anyone's interested, I'd love to hear his/her thoughts on this code. A few thoughts: Should it automatically AOT compile everything and package it all in an executable jar? Can I use a pure java implementation of bzip and tar without calling out to the system's tar command? (I'm bortreb on coderloop btw) sincerely, --Robert McIntyre On Tue, Jan 11, 2011 at 9:17 PM, Sean Corfield wrote: > Ah, that does look like more fun - thanx for the link, hadn't heard of > it before! > > On Wed, Jan 5, 2011 at 10:11 PM, benjamin.s.r > wrote: >> http://coderloop.com/ like Project Euler but more modern > > -- > You 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 Quizzes?
Ah, that does look like more fun - thanx for the link, hadn't heard of it before! On Wed, Jan 5, 2011 at 10:11 PM, benjamin.s.r wrote: > http://coderloop.com/ like Project Euler but more modern -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
On Tue, Jan 11, 2011 at 4:11 PM, Ken Wesson wrote: >> anything else. If you're working extensively with Java (as well), >> you'll want to either stick to IntelliJ or look at Eclipse + CCW. > Or Netbeans+Enclojure. Ah, yes, another option for Java folk. Sorry, I tend to forget that one since I've only used IntelliJ and Eclipse... > So much for the "it's like riding a bicycle" theory of emacs mastery, then. :) :) It used to be muscle memory back in the day but that day was the best part of 30 years ago and my memory ain't what it used to be... -- 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: Entity component system
Thanks for sharing! Entity component systems are something I'm very interested in and something I have tinkered with in the past. I hope to (eventually) find some time to play around with them in Clojure too. I would be very interested in hearing more about your solution and would be delighted if you were to choose to open source your project. As an aside, do you mind if I copy your sample code and possibly parts of your email to the clojure-games.org wiki? Thanks, Dan. On 10 January 2011 00:43, justinhj wrote: > Thanks for sharing. I've also spent some time building a Common Lisp > game engine that uses a component architecture for the game objects. > > For example in pong the player's paddle is made up of a visual, > physical and logical components. > > (defun make-pong-player(side human sprite-def control-type name) > (let ((phys (make-instance '2d-physics > :collide-type 'paddle :y *paddle-start-y* :width > *paddle- > width* :height *paddle-height*)) > ; (anim (make-instance 'animated-sprite :sprite-def sprite-def > ; :current-frame 'frame-1 :speed 5.0)) > (visual (make-instance 'rectangle > :w *paddle-width* :h *paddle-height*)) > (pong (make-instance 'player-paddle-logic > :control-type control-type :side side)) > (obj (make-instance 'composite-object :name name))) > (add-component obj phys) > (add-component obj visual) > ; (add-component obj anim) > (add-component obj pong) > obj)) > > The objects implement message handlers in order to operate. For > example the game engine sends update and draw messages. Users can > write their own message types with custom argument lists. > > I've put the project on google code http://code.google.com/p/lisp-game-engine/ > > Although the pong game works I wouldn't consider this a finished > project by any means; it's more an experiment in game programming > using CL and the REPL. > > It would require significant refactoring to make it work with Clojure > since I use mutable state a lot, but would certainly be possible. > > Justin > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
On Tue, Jan 11, 2011 at 6:50 PM, Sean Corfield wrote: > On Sun, Jan 9, 2011 at 11:01 AM, Alex Baranosky > wrote: >> I've been considering switching to Emacs because it seems to be the de facto >> standard for the community. > > I'd disagree with that. Yes, there are a lot of Emacs users in the > Clojure community but I think that's the Lisp bias rather than > anything else. If you're working extensively with Java (as well), > you'll want to either stick to IntelliJ or look at Eclipse + CCW. Or Netbeans+Enclojure. > Emacs is a very different beast that takes a lot of getting used to. I > used it day in, day out a long, long time ago (for C programming, > mostly) but when I came back to it recently as a trial because of the > seeming bias toward it in the Clojure community, I had a really hard > time - it was just too alien after working with Eclipse for years - > and I gave up after about a week of frustration. So much for the "it's like riding a bicycle" theory of emacs mastery, then. :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
On Sun, Jan 9, 2011 at 11:01 AM, Alex Baranosky wrote: > I've been considering switching to Emacs because it seems to be the de facto > standard for the community. I'd disagree with that. Yes, there are a lot of Emacs users in the Clojure community but I think that's the Lisp bias rather than anything else. If you're working extensively with Java (as well), you'll want to either stick to IntelliJ or look at Eclipse + CCW. Emacs is a very different beast that takes a lot of getting used to. I used it day in, day out a long, long time ago (for C programming, mostly) but when I came back to it recently as a trial because of the seeming bias toward it in the Clojure community, I had a really hard time - it was just too alien after working with Eclipse for years - and I gave up after about a week of frustration. -- 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: distributeted computing newby, clojure ...
> I have a simple library that mimics newLISP's net-eval command, which > will allow you to evaluate expressions in parallel on remote network > nodes, > > http://nakkaya.com/net-eval.html > > Regards... Very Nice. I looked at it and its what I need. I tested it sucessfully and I am using it with in my project atm. Will you keep developing this? I will probebly work on it, do you accept patches? (Maybe we can keep talking about this on direct email.) -- You 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: java 7
So far, Clojure has targeted JVMs that are widely used in enterprise Java environments. That's why it still targets JDK 1.5 instead of 1.6. So if/when Java 7 arrives, Clojure probably wouldn't switch until it is widely deployed. -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
Re: Compiling dynamically created namespaces, without on-disk source code?
You would have to capture the source form of each definition before it's compiled. Not too hard if you hack the REPL a bit; someone has probably already worked on it. -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
Re: running just one test
Unfortunately, clojure.test can't support that. Best you can do is comment out the other tests while you work. -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
running just one test
I have a namespace that uses clojure.test to define multiple tests. The namespace also has a test fixture. Let's say I just ran all the tests and one of them failed. The entire suite takes a while to run, so while I debug the problem, I want to run just that one test. What's the idiomatic way to run just one test? I don't see a run-test function or a way to pass individual test names to run-tests. I also tried defining a test-ns-hook. That works, but your test-ns-hook needs to take care of calling your fixtures, which surprised me. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
I should also add that emacs users would probably be disappointed with the current state of affairs of (auto)(re)indentation in ccw, which is very "minimalistic" (but very predictable ;) : literal lists are indented 2 chars, other literal datastructures are indented 1 char. Of course, if you indent deeper one line inside a datastructure, other lines at the same level in the datastructure will align. 2011/1/11 Laurent PETIT > 2011/1/11 Mark Engelberg > > The counterclockwise site indicates that it doesn't format your code. >> Is that still the case? >> > > no and yes. > > It does auto-indent your code when you hit enter, as well as reindent the > current line when you explicitly ask to (hitting the Tab key, or the > Eclipse-provided wayy more hard to find Ctrl+I "shortcut"). > It does not (yet) reformat the whole document in one pass. > > >> >> -- >> >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
2011/1/11 Mark Engelberg > The counterclockwise site indicates that it doesn't format your code. > Is that still the case? > no and yes. It does auto-indent your code when you hit enter, as well as reindent the current line when you explicitly ask to (hitting the Tab key, or the Eclipse-provided wayy more hard to find Ctrl+I "shortcut"). It does not (yet) reformat the whole document in one pass. > > -- > You 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: Question about sorted-sets
> You should also try using a TreeSet and see if you get the same results as > with sorted-set. I get the same results with TreeSet. After looking at the javadocs more carefully, I realized the Comparator isn't implemented properly, namely, it's not doing this: The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. I'll fix that and cross my fingers. Thanks, -Travis -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
How do I find implemented protocols in Clojure object?
Is there a documented way to find which protocols are implemented by a Clojure object? The other way around (show for which classes a given protocol is extended) is easy: (extenders protocol). Maurits -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
The counterclockwise site indicates that it doesn't format your code. Is that still the case? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sorted-sets
Stuart, > In order for this to work, the "quasi-isomorphic?" function has be reflexive. > Is it? (The .equals implementation is also missing a type test, but that > probably isn't > the problem here.) Yes, it is reflexive, and symmetric: user> (quasi-isomorphic? t2 t1) true user> (quasi-isomorphic? t1 t2) true user> (quasi-isomorphic? t1 t1) true user> (quasi-isomorphic? t2 t2) true What I really don't understand, is that when I set a breakpoint in the equals function to see what search records are being compared, the comparison between sr1 and sr2 never occurs, even though sr1 is in the set when sr2 is added. From Rich's videos I think I remember these persistent data structures being ideal hash tries, so I tried to look at the PersistentMap code to see why this was occurring. No luck, yet. I also thought that the deftype might need to implement a different interface for this to work. > You should also try using a TreeSet and see if you get the same results as > with sorted-set. I will. Thank you for the suggestions. -Travis -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how do I improve indentation of reify methods in clojure-mode
On Tue, Jan 11, 2011 at 08:12, Eric Schulte wrote: > As an example of a user-accessible function for customizing indentation, > the following can be used with the latest clojure-mode either > interactively or from a user's config. > > (defun clojure-new-indent (&optional func level) > "Set the indentation level of FUNC to LEVEL." > (interactive) > (let ((func (or func > (read-from-minibuffer "function name: " > (condition-case nil > (which-function) (error nil) > (level (or level (read-from-minibuffer "indent (number): " "1") > (put (if (stringp func) (intern func) func) > 'clojure-indent-function > (if (stringp level) (string-to-number level) level))) > > e.g. (clojure-new-indent 'while-let 1) will result in > > (while-let [something stuff] > (body)) > > rather than > > (while-let [something stuff] > (body)) > > Cheers -- Eric I'll give that a try. Thanks! // ben -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how do I improve indentation of reify methods in clojure-mode
As an example of a user-accessible function for customizing indentation, the following can be used with the latest clojure-mode either interactively or from a user's config. (defun clojure-new-indent (&optional func level) "Set the indentation level of FUNC to LEVEL." (interactive) (let ((func (or func (read-from-minibuffer "function name: " (condition-case nil (which-function) (error nil) (level (or level (read-from-minibuffer "indent (number): " "1") (put (if (stringp func) (intern func) func) 'clojure-indent-function (if (stringp level) (string-to-number level) level))) e.g. (clojure-new-indent 'while-let 1) will result in (while-let [something stuff] (body)) rather than (while-let [something stuff] (body)) Cheers -- 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: ANN: clojurejs -- a Clojure (subset) to Javascript translator
On Jan 11, 3:55 am, Daniel Werner wrote: > Hi Ram, > > your take on Clojure to JS translation seems very interesting to say > the least. Thanks for sharing your work. You're very welcome, and thanks for the quick feedback. > A few points I tripped over while reading the example: > * Why are functions being defined as "join = function (...)" instead > of "function join (...)"? Does this make a semantic difference? This stems from my misunderstanding of Clojure's `defn' form. I had started implementing Scheme like scoping for functions where, (defn test1 [] (defn test2 [] (+ 1 1)) (= (test2) 2)) would generate: var test1 = function () { var test2 = function () { return 1 + 1; }; return test2() == 2; }; This effectively would hide `test2' from the toplevel, but this isn't the behavior of `defn' as I discovered. So, by dropping the leading `var' in the generated Javascript, I could make all the inner functions exposed at the top level as well. I believe there's no scoping semantics difference between the `x = function () {...}' and `function x () {...}' forms, unless `x' is declared somewhere in the scope as a local var. Of course, the scoping semantics completely change with the explicit introduction of `var x = function () {...}'. > * "if { ... } else { ...} break;" is probably missing a semicolon > before "break". Don't trust JS' implicit semicolon-adding ;-) You're absolutely right. I'll add a test case and fix that today. > * The whole function body is being wrapped in a "return function() > { ...}()". Is this done in order to support implicit return? My guess > is that deeply nesting such constructs could become quite performance- > heavy due to the many additional function calls. You're probably right. As I worked on the let/loop forms I suspected they were probably going to have performance issues in the long run, but I really really wanted to have consistent scoping rules. I traded off the performance issue in the expectation that with the race to build the fastest Javascript JIT compiler, Google, Mozilla, or Apple will eventually solve these crazy performance gotchas in Javascript. > * Mozilla's JS 1.7 supports a let statement[1] with lexical scoping, > though implementation support outside of Firefox is scarce. Depending > on your target audience and performance requirements it could be > worthwhile to implement this as an optimization instead of using the > "function(){...}()" trick, but only if allowed by some flag, > like :features #{:let} or similar. That's an interesting idea, although I'm not too keen on specializing for any one browser. The other problem is I don't see any reasonable way of providing the alternates from a web server without some form of user-agent sniffing. > > I'm going to take a deeper look into this once I have the time. > > [1]https://developer.mozilla.org/en/New_in_JavaScript_1.7#Block_scope_wi... > > Daniel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sorted-sets
> All, > > I'm hoping another, wiser set of eyes can help me to see what I'm doing wrong. > > I've defined a deftype below that stores a likelihood and a tree structure > (nested vectors). The deftype overrides equals, etc, and implements > Comparable so I can add SearchResults to a sorted-set and sort by likelihood. > Equal SearchResults have the same likelihood and have quasi-isomorphic tree > structures. > > (deftype SearchResult [lik tree] > Object > (toString [sr] >(str lik ":" tree)) > (equals [sr other] >(and (= lik (.lik other)) (quasi-isomorphic? tree (.tree other > (hashCode [sr] >(int lik)) > > Comparable > (compareTo [sr sr2] >(cond > (= sr sr2) 0 > (> (.lik sr) (.lik sr2)) -1 > :default 1))) > > I've defined some dummy data, which should illustrate the unusual behavior > I'm seeing when I add SearchResults to a sorted-set. > > user> (def t1 [{:name 0} [{:name 1} [{:name 3}] [{:name 2}]] [{:name 4}]]) > user> (def t2 [{:name 0} [{:name 1} [{:name 2}] [{:name 3}]] [{:name 4}]]) > user> (def t3 [{:name 0} [{:name 1} [{:name 4}] [{:name 2}]] [{:name 3}]]) > user> (def t4 [{:name 0} [{:name 1} [{:name 4}] [{:name 3}]] [{:name 2}]]) > user> (quasi-isomorphic? t1 t2) > true > user> (quasi-isomorphic? t1 t3) > false > user> (quasi-isomorphic? t1 t4) > false > user> (def sr1 (SearchResult. 1 t1)) > user> (def sr2 (SearchResult. 1 t2)) > user> (def sr3 (SearchResult. 1 t3)) > user> (def sr4 (SearchResult. 1 t4)) > user> (= sr1 sr2) > true > user> (= sr1 sr3) > false > user> (= sr1 sr4) > false > user> (def ss (sorted-set)) > true > user> (count (conj ss sr1 sr3 sr4 sr2)) > 4 > user> (count (conj ss sr1 sr2 sr3 sr4)) > 3 > > Of the four SearchResults, only sr1 and sr2 should be equal per the equals > and compareTo functions defined in SearchResult. Based on that assumption, I > thought that evaluating (conj ss sr1 sr3 sr4 sr2) would only return a set > containing sr1, sr3, sr4, but it actually returns a set containing all four > SearchResults. However, if I change the order of the SearchResults, as in > (conj ss sr1 sr2 sr3 sr4), it works as expected, returning the set > containing sr1, sr3, sr4. > > I've tried debugging the equals function to see what, exactly, is being > compared, and it looks like in (conj ss sr1 sr3 sr4 sr2), sr2 is never > actually compared to sr1, so sr2 gets added to the set. What am I missing? > > Any help would be greatly appreciated. > > -Travis > > p.s. Yes, the hashCode function isn't the best, but from what I could read, > it does fulfill the requirements of the contract outlined in the javadocs. Hi Travis, In order for this to work, the "quasi-isomorphic?" function has be reflexive. Is it? (The .equals implementation is also missing a type test, but that probably isn't the problem here.) You should also try using a TreeSet and see if you get the same results as with sorted-set. Cheers, 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
Re: Multidimensional Float arrays
When all else fails, read the directions. Thanks for the help. On Jan 10, 4:44 pm, Ken Wesson wrote: > On Mon, Jan 10, 2011 at 4:40 PM, WoodHacker wrote: > > The question was how to place data in the array, not create it. I've > > been > > doing that. How do you populate it? The doc shows: > > > user=> (doc aset-float) > > - > > clojure.core/aset-float > > ([array idx val] [array idx idx2 & idxv]) > > > If I try that I get: > > > user=> (def wa (make-array Float/TYPE 4 4)) > > #'user/wa > > user=> wa > > # > > user=> (aset-float wa 0 0 & 1.0) > > java.lang.Exception: Unable to resolve symbol: & in this context > > (NO_SOURCE_FILE:5) > > user=> > > > What am I missing? > > That that's not a literal ampersand expected by aset-float; just that > it can take a variable number of indices. Try (aset-float wa 0 0 1.0). -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: which IDEs are you all using?
I use IntelliJ + LaClojure at work. We do a lot of java + clojure integration and IntelliJ seems to be the best solution for that. (tho, I've never bothered to look at eclipse) I use emacs at home where most of my work is clojure exclusively. You could argue: the right tool for the job. But, I truthfully don't mind working with either. Sent from my iPhone On Jan 9, 2011, at 2:45 PM, Vagif Verdi wrote: > Jumping to the definition of function: Alt-. > Returning back Alt-, > > All other (and much more) features are implemented in slime (emacs > package). > > On Jan 9, 11:01 am, Alex Baranosky > wrote: >> Hi, >> >> I'm most used to using Intellij, since it is what I use everyday at work >> programming in Java. So my first forays into Clojure have been using >> LaClojure. Some things I like about using Intellij for Clojure development >> are: >> >>- I can click on a piece of code and have Intellij take me to the file >>where that code is defined, even if I didn't write it; this means I can >>click right through into clojure.core and read the source. >>- It also has a nice rainbow parens feature which I find helps with >>visually parsing the Clojure code. >>- And of course Intellij has a LOT of keyboard shortcuts to help with >>manipulating the text. >>- I also like to change the color scheme, I assume emacs allows you to >>use a self-created color scheme? >> >> I've been considering switching to Emacs because it seems to be the de facto >> standard for the community. Does emacs have the equivalent of these four >> features? If not, does it have their equivalents? >> >> On another note, I'd also love to hear what features Emacs would give me >> that LaClojure doesn't enable. >> >> All the Best, >> Alex > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sorted-sets
> My guess is that it's your likelihood function that's actually broken. > If sr1 and sr2 don't come out with the same likelihood, then in some > cases of putting them into the sorted set they'll never end up > compared with each other for equality. (Actually, I'd have thought in > all cases. Perhaps the compareTo is separately broken and doesn't > total-order by likelihood?) I thought this too, originally, but in my example above, all of the sr likelihoods are set to 1. I was under the assumption that when you tried to add to a set, it would check all of the members of that set before allowing its insertion. In the example above, sr2 is never even checked against sr1, the one SearchResult that is indeed equal to s2. Maybe I'm implementing (overriding, as the case may be) the wrong interfaces to get this working correctly. -Travis -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: clojurejs -- a Clojure (subset) to Javascript translator
Hi Ram, your take on Clojure to JS translation seems very interesting to say the least. Thanks for sharing your work. A few points I tripped over while reading the example: * Why are functions being defined as "join = function (...)" instead of "function join (...)"? Does this make a semantic difference? * "if { ... } else { ...} break;" is probably missing a semicolon before "break". Don't trust JS' implicit semicolon-adding ;-) * The whole function body is being wrapped in a "return function() { ...}()". Is this done in order to support implicit return? My guess is that deeply nesting such constructs could become quite performance- heavy due to the many additional function calls. * Mozilla's JS 1.7 supports a let statement[1] with lexical scoping, though implementation support outside of Firefox is scarce. Depending on your target audience and performance requirements it could be worthwhile to implement this as an optimization instead of using the "function(){...}()" trick, but only if allowed by some flag, like :features #{:let} or similar. I'm going to take a deeper look into this once I have the time. [1] https://developer.mozilla.org/en/New_in_JavaScript_1.7#Block_scope_with_let Daniel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Odd behavior calling a fn "test" or "try"
On Jan 11, 2:28 am, Tom Hall wrote: > I know I should not be naming my functions the same thing as ones in core You can and should, as long as it makes your life easier and doesn't get too confusing for readers. Just make sure you're able to access the original core bindings if you need them: (ns foo.bar (:refer-clojure :exclude [and]) (:require [clojure.core :as c])) (defn and [x & types] "Tests whether x is an instance of all given types." (every? #(instance? x %) types)) (defn quagga? [x] (c/and (pos? x) (and x Double Number))) Alright, this a rather negative example because it does get confusing, but I hope you get the general idea. Daniel -- You 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