Mp3-player written in Clojure using Derby, Swing, Clojure-contrib etc!
This is my first major Clojure program and my first major lisp-program at all. It unfortuneately has a few bugs. 1 minor where I don't handle an exception when there is no file chosen when you open a playlist. The big and annoying one however is that sometimes the player starts playing 2 songs. I suspect this has something to do with the threading/ polling where I check if the song is complete or not. I think the code in general is not very pretty. Maybe it is all the Java interop that makes it look a bit cludgy. The logic is decently separated but I don't feel all that satisfied with it. It uses Derby as a database(just for storing basic playing-info(the only thing it is used for is loading 10most played songs but if you look in database.clj you can read the database and get the info out to do something with that). Clojure-contrib's sql lib makes the database interop very easy. For the GUI I use Swing and Miglayout and miglayout from Clojure- contrib which I find very neat. Start repl with: C:\clojure>java -cp clojure.jar;C:/clojure/;C:/clojure/classes;C:/ javalibs/miglayout-3.6.2-swing.jar;C:/javalibs/mp3/jl1.0.jar;C:/ Progra~1/Sun/JavaDB/lib/derby.jar;C:/clojure/clojure-contrib.jar; clojure.lang.Repl user=> (load-file "C:/clojure/progs/mp3player/mp3player.clj") #'progs.mp3player.mp3player/compile-player user=> (progs.mp3player.mp3player/compile-player) progs.mp3player.mp3player user=> here's a python script to run the player once it is compiled: #!/usr/bin/env python import subprocess command = "javaw -cp C:/javalibs/jl1.0.1.jar;C:/javalibs/ miglayout-3.6.2-" + \ "swing.jar;C:/clojure/clojure-contrib.jar;C:/clojure/ clojure.jar;" + \ "C:/Progra~1/Sun/JavaDB/lib/derby.jar; progs.mp3player.mp3player" subprocess.Popen(command) Finally, here is the code: main: http://paste.lisp.org/display/79566 guilogic: http://paste.lisp.org/display/79567 utils: http://paste.lisp.org/display/79568 database: http://paste.lisp.org/display/79569 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Feedback on new persistentmatrix datatype
Hello everyone, I just uploaded some of my work on a new datatype for clojure to a git repository. http://github.com/aperotte/persistentmatrix A bit of the rationale and motivation for the datatype is described on the github page. I basically wanted to create a datastructure for manipulating large amounts of data efficiently and in a human friendly way in clojure. Its main features are: 1. Immutability 2. Primitive Support 3. N-Dimensional – Arbitrary number and size of dimensions (ie. ability to create a 4×3×5x6 datastructure) 4. N-Dimensional units (ie. ability to create a 10×10 matrix with 2×1 units to represent complex numbers) 5. Fast submatrix views via structural sharing (ie. constant time slicing, transposing, and other data manipulations) 6. Maintenance of both deep and superficial dimensionality (ie. slicing a 4×3×5x6 along the 3rd dimension will yield a datastructure with a superficial dimensionality of 3 and a deep dimensionality of 4) 7. Axis and element labeling and label indexing (ie. ability to label axes and elements of an axis with strings or any arbitrary object) 8. Implementing many of the clojure interfaces and thereby automatically inheriting much of the functionality of the standard library for data structures. I would welcome any feedback. Also, if anyone is interested in working together to accelerate its development, that would be welcome too! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Ant tasks for Clojure
I'm beginning to do more work in Clojure (just a side project for now, but an interesting one). A couple of things I'm missing from Clojure in terms of building & deploying an application is built-in Ant tasks for common actions: - Pre-compiling Clojure - Starting up a REPL (and perhaps passing a form to evaluate) - Generating XML/HTML documentation Two of these things are possible using clumsy Ant operation. Creating a proper Ant task for them is not much work and would make it easier and more consistent for Clojure library builders. I've seen that the documentation for clojure-contrib if generated automatically; perhaps some of that logic could move into clojure-lang? Of course, this could all be done as part of clojure-contrib, and virtually any real project will use some of clojure-contrib but it still feels more "complete" to have it build into clojure-lang. Flip side: a fourth task for running tests should be in clojure-contrib (or test-is should move to clojure-lang). So do others feel the same need for these things as I do? And do they belong in clojure-lang or clojiure-contrib? -- Howard M. Lewis Ship Creator of Apache Tapestry Director of Open Source Technology at Formos --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: leveraging Clojure STM in other JVM languages?
On May 1, 1:40 pm, Raoul Duke wrote: > hi, > > has anybody experimented with using Clojure code from e.g. Scala, to > get Clojure STM goodness in other languages? > The Clojure STM is just a Java library. You could use clojure.lang.Ref and LockingTransaction directly from Java/Scala/etc. runInTransaction takes a Callable, and the values placed in Refs can be anything immutable. Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
clojure.xml and *preserve-whitespace*
Hello, Currently clojure.xml discards text nodes when they contain only whitespace characters. Can this behavior be made optional? Attached is a patch which adds a *preserve-whitespace* var (by defaul to false). Thanks, Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~--- diff --git a/src/clj/clojure/xml.clj b/src/clj/clojure/xml.clj index 251f16c..15f3ade 100644 --- a/src/clj/clojure/xml.clj +++ b/src/clj/clojure/xml.clj @@ -14,6 +14,8 @@ (def *current*) (def *state*) ; :element :chars :between (def *sb*) +(def #^{:doc "When set to true, clojure.xml/parse preserves significant whitespace."} + *preserve-whitespace* false) (defstruct element :tag :attrs :content) @@ -25,8 +27,9 @@ (let [push-content (fn [e c] (assoc e :content (conj (or (:content e) []) c))) push-chars (fn [] - (when (and (= *state* :chars) -(some (complement #(. Character (isWhitespace %))) (str *sb*))) + (when (and (= *state* :chars) +(or *preserve-whitespace* + (some (complement #(. Character (isWhitespace %))) (str *sb* (set! *current* (push-content *current* (str *sb*)] (new clojure.lang.XMLHandler (proxy [ContentHandler] []
Re: Getting slime-edit-definition to work with Clojure
Phil, >> (setq swank-clojure-binary "clojure") >> >> (add-to-list 'slime-lisp-implementations >> '(clojure ("/home/ghoseb/bin/clojure") :init >> swank-clojure-init)) > > It looks like you're using a wrapper script rather than letting > swank-clojure construct a "java" command-line invocation. I'm not sure > why you're doing this; working with the defaults might fix it. Many thanks. Just using the conf generated by clojure-install did the trick. Right now M-. for all clojure.contrib functions work fine. But it still doesn't work for Clojure's internal functions in, say, core.clj Any idea how to get that to work? Regards, BG -- Baishampayan Ghose oCricket.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Why does this not work?
On Sat, May 2, 2009 at 12:10 AM, Stephen C. Gilardi wrote: > > On May 1, 2009, at 5:24 PM, Michael Wood wrote: > >> I don't think it's so hard and fast. I think of it more like somefunc >> is the usual thing, and somefunc* is similar, but not as commonly >> used. Maybe someone else has a better explanation/definition. > > The special forms are documented at http://clojure.org/special_forms. It's > that definitive description of the behavior of each special form that > Clojure programmers should program to. Exactly how a special form is > implemented is not a promise of the Clojure language. Instead, it's an > internal detail of a specific implementation of Clojure. Yes, I was not talking about special forms. Only the naming convention of having similarly named functions/macros where the names differ only in that one of them has an asterisk appended, and whether all things with trailing asterisks were "private". -- Michael Wood --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: The Path to 1.0
2009/5/1 Rich Hickey > > > > On Apr 26, 6:54 pm, Laurent PETIT wrote: > > I've created issue 110 with the patch attached in clojure's google code > project. > > > > > > Note: I strongly suggest that the clojure.version.interim property > > remains true in svn, so that it's not possible to inadvertently > > release a version "too early". > > > > Just to clarify - are you suggesting I should just change > version.properties by hand, build and release the result, but never > check in with clojure.version.interim=false? > Yes. I think this is correct to check-in with other version attributes correctly set for the upcoming release, but keep the interim attribute to false in the svn repository, so that nobody can create an official release inadvertently. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---