Re: Results from 2011 State of Clojure survey

2011-07-13 Thread Albert Cardona
Chas, It seems that relatively few people are taking advantage of some of Clojure’s most sophisticated and unique features: metadata; protocols, records, and types; and multimethods. These facilities are absolutely game-changers, at least IMO. Either most domains have no use for them (I can’t

Re: help--reading keyboard input from Clojure is surprisingly difficult

2011-06-14 Thread Albert Cardona
Hi Meikel, it surprised me that you used an atom to run the event loop. A simple loop/recur also works, at least in clojure 1.2.1: (loop [] (let [input (read-line)] (when (pos? (count input)) (println (pick phrases)) (recur Just for the record. Best, Albert --

Re: Sharing a frustrating bug: using an atom to a hash as a hash

2011-04-21 Thread Albert Cardona
2011/4/21 Tzach tzach.livya...@gmail.com: I made a stupid mistake, and I want to share. This is not the actual code, I simplify it to demonstrate the point. I use a atom to a global hash as follow:  (def *aa* (atom {:x 3 :y 4 :z 17})) Somewhere on the code, I have a function which look at

Re: unchecked-divide etc being replaced in 1.3 - no more support for longs?

2011-03-02 Thread Albert Cardona
Jason, 2011/3/1 Jason Wolfe ja...@w01fe.com: But I don't know what the plan is if you really do want truncating arithmetic on longs. On 1.3 alpha 4: user= (+ Long/MAX_VALUE Long/MAX_VALUE) ArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1581)

Re: unchecked-divide etc being replaced in 1.3 - no more support for longs?

2011-03-02 Thread Albert Cardona
2011/3/2 Meikel Brandmeyer m...@kotka.de: Hi, On 2 Mrz., 10:44, Albert Cardona sapri...@gmail.com wrote: I get: user= (set! *unchecked-math* true) java.lang.IllegalStateException: Can't change/establish root binding of: *unchecked-math* with set ... with latest clojure from git master

Re: ANN: Textmash - another IDE for Clojure

2011-02-08 Thread Albert Cardona
2011/1/23 Olek aleksander.nas...@gmail.com: Pros: 1. Yes, it uses Swing. I have even stared writting it in Clojure, but startup time was too long, not acceptable for lightweight text editor. 2. Yes, it is. I've carefully studied Mac's TextEdit, NetBeans and Eclipse and merged theirs ideas.

Re: Multidimensional Float arrays

2011-01-10 Thread Albert Cardona
2011/1/10 WoodHacker ramsa...@comcast.net: Hi, Can anybody explain to me how to create a multidimensional array of floats such as:   [[1.0 1.0 2.0 2.0] [3.0 2.2 4.0 0.0]] Anything I try gives me errors. user= (doc make-array) - clojure.core/make-array ([type len]

Re: First foray into profiling

2011-01-09 Thread Albert Cardona
2011/1/9 Mark Engelberg mark.engelb...@gmail.com: I'm trying to use JVisualVM to profile some Clojure code. One thing I successfully figured out from using the profiler was that lein swank was not actually starting the jvm in -server mode like I thought it was.  Arggh, now I have to figure

Re: a loop gives boxing warning when it shouldn't

2011-01-03 Thread Albert Cardona
2011/1/3 Allen Johnson akjohnso...@gmail.com: I can't see where the variables are boxed into objects. Both the loop and the let declare them as primitives if they are given primitives. Perhaps they are already objects before they reach the inc and dec function calls in the recur, but if so,

Re: a loop gives boxing warning when it shouldn't

2011-01-02 Thread Albert Cardona
2011/1/2 Allen Johnson akjohnso...@gmail.com: Here is my attempt. I changed the divide to use unchecked-divide-int and explicitly cast recur values to long. http://clojure.pastebin.com/xs79ruw1 Allen Hi Allen, Thanks for the effort. What I don't understand is why one should cast to int

a loop gives boxing warning when it shouldn't

2011-01-01 Thread Albert Cardona
Hi all, I'd apreciate help on figuring out why a loop gets number boxing warnings, when it shouldn't: http://clojure.pastebin.com/9uLZqGhy I'm using clojure from: commit f30995c86056959abca53d0ca35dcb9cfa73e6e6 Author: Stuart Halloway s...@thinkrelevance.com Date: Fri Dec 17 15:17:20 2010

Re: Suspensions

2010-10-20 Thread Albert Cardona
user= (doc future) - clojure.core/future ([ body]) Macro Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet

documentation request: please add examples for use

2010-10-02 Thread Albert Cardona
Hi, I'd like to understand how to properly use use with additional options, such as :only. The current documentation for use says: = (doc use) - clojure.core/use ([ args]) Like 'require, but also refers to each lib's namespace using clojure.core/refer. Use :use in

Re: documentation request: please add examples for use

2010-10-02 Thread Albert Cardona
I just realized the second paste was that of use, not of refer: user= (doc refer) - clojure.core/refer ([ns-sym filters]) refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols

Re: reflection warnings with defprotocol/deftype with type hints

2010-09-01 Thread Albert Cardona
Hi Adrian, Thanks for the explanations. Indeed I was assuming a protocol would work like an interface, so I may just as well use definterface directly. To date, protocols confuse me a bit--I have no reference for it in my head. I see how you use them like multimethods and that's very neat.

reflection warnings with defprotocol/deftype with type hints

2010-08-31 Thread Albert Cardona
Hi all, I am puzzled by the type hint support in deftype. I can add type hints to defprotocol: user= (defprotocol PTest (test-it ^boolean [this ^String msg])) PTest … but adding them to deftype fails: user= (deftype Test [^String name] PTest (test-it [this msg] (str test name : msg

Re: Complex type in clojure

2010-07-20 Thread Albert Cardona
2010/6/7 Mark Engelberg mark.engelb...@gmail.com: Yes, but in (some versions of) Scheme, (sqrt -1) yields i. Representing complex numbers and just doing math between two complex numbers is not the problem.  Retrofitting Clojure math so that all operations work on the entire numeric tower,

Re: need help understanding two issues

2010-06-20 Thread Albert Cardona
Thank you very much Rob and Michal, both issues are clear now. Michael, I agree that the documentation for clojure.set/project could improve. At least now there is your email to be sent around to those like me who don't get it from the very succinct default doc string. Albert --

what replaces clojure.parallel?

2010-06-19 Thread Albert Cardona
Hi all, The http://clojure.org/other_libraries web page states that: Parallel Processing The parallel library (namespace parallel, in parallel.clj) wraps the ForkJoin library. This lib is now deprecated. If the clojure.parallel is deprecated, what replaces it? Is it pcalls and pvalues in

need help understanding two issues

2010-06-19 Thread Albert Cardona
Hi all, I have run into the following two issues over the last few days. I would appreciate insight/help/advice: 1. How come APersistentMap$KeySet doesn't implement IPersistentSet? (clojure.set/intersection (keys {2 two 4 four}) #{2 3}) java.lang.ClassCastException:

-XX:PermSize=512m prevents performance degradation over time

2010-02-04 Thread Albert Cardona
a list of nearly all JVM flags for 1.6.0 with minimal explanations here: http://www.md.pp.ru/~eu/jdk6options.html ] Hope that helps somebody. Albert -- Albert Cardona http://albert.rierol.net -- You received this message because you are subscribed to the Google Groups Clojure group. To post

Re: ANN: dgraph 1.0, a dependency graph library for Clojure

2010-01-17 Thread Albert Cardona
Do you have examples of where you see it interesting to use (and not abuse :-) ) side effects in combination with eager/patient ? I just checked in a Swing usage example which uses side effects to update the UI (http://github.com/gcv/dgraph/blob/master/src/examples/ dgraph/swing.clj). Please

Re: Recommended JVM flags for Clojure

2010-01-07 Thread Albert Cardona
What I use: -Xincgc : enable incremental garbage collector. Works great when there's more than 1 CPU -Xms4000m -Xmx4000m : set both min and max heap size to the same amount (4 Gb in this case). Prevents dynamic heap resizing, which at high loads may result in unexpected out of memory errors and

Re: gui repl

2010-01-03 Thread Albert Cardona
Albert -- Albert Cardona http://albert.rierol.net -- You 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

Re: Image scaling libraries. Request for recommendations

2009-12-14 Thread Albert Cardona
On Mon, Dec 14, 2009 at 10:08 AM, Lauri Pesonen lauri.peso...@iki.fi wrote: IIRC Java AWT-based libraries require a windowing system on the machine. On Windows this is not a big deal since you're always running a windowing system, even on a server, but on linux where the windowing system is an

Re: Image scaling libraries. Request for recommendations

2009-12-14 Thread Albert Cardona
There's a system property (since jdk 1.4) named java.awt.headless (http://java.sun.com/j2se/1.4.2/docs/guide/awt/AWTChanges.html#headless) that allows using AWT classes in server setting. In my experience, the java.awt.headless property doesn't work. I have not tried since a late 1.5; perhaps

Re: Embedding a REPL

2009-12-08 Thread Albert Cardona
On Mon, Dec 7, 2009 at 11:19 AM, Mike cki...@gmail.com wrote: My app has its own JPanel for display results, and a text area for input, so I'll need to start repl with some replacement callback functions (read, print, prompt, need-prompt).  I'd like to code as much as possible in Clojure, but

Re: why a defn- but not a def- ?

2009-11-14 Thread Albert Cardona
On Fri, Nov 13, 2009 at 11:26 PM, Mike Hogye stacktra...@gmail.com wrote: Why is there an easy way to def a private function (defn-), but no similarly easy way to def an arbitrary var as private? The way I see it, def- would encourage gratuitous variable declaration imperative style. By

sorted-set-by fails when given no values

2009-11-12 Thread Albert Cardona
Hi all, When creating a sorted set, the function sorted-set-by cannot be called without at least one element, despite the elements being optional. Chouser on irc.freenode.net #clojure suggested this is a bug, because: 20:26 chouser leafw: sorted-set-by allows for an empty list of initial

Re: Better documentation and error messages are needed for the ns macro

2009-11-11 Thread Albert Cardona
YES please. If I could upvote this message I would. A half-a-dozen of examples on ns/in-ns and require/use/refer and the differences in using them at the prompt or inside a ns would be fantastic. The ns macro is one of the obscure corners of clojure. It relates to the java class path problem,

Re: Periodic tasks

2009-10-30 Thread Albert Cardona
How about: (import '(java.util.concurrent Executors TimeUnit)) (let [s (Executors/newSingleThreadScheduledExecutor)] (.scheduleAtFixedRate s #(try (println I did it again) (catch Exception e (.printStackTrace e))) (long 0) (long 1) TimeUnit/SECONDS))

problems installing vimclojure 2.1.2 over 2.1.0

2009-10-12 Thread Albert Cardona
for an unknown reason Total time: 0 seconds I wonder: there is no uninstall target in the ant xml file. Do I have to manually uninstall the older vimclojure first, file by file, from my ~/.vim directory? Albert -- Albert Cardona http://albert.rierol.net

Re: problems installing vimclojure 2.1.2 over 2.1.0

2009-10-12 Thread Albert Cardona
Meikel Brandmeyer wrote: Hi Albert, On Oct 12, 4:24 pm, Albert Cardona sapri...@gmail.com wrote: /home/albert/vimclojure-2.1.2/build.xml:182: Directory /home/user/.vim/autoload creation was not successful for an unknown reason I wonder: there is no uninstall target in the ant xml file

Re: problems installing vimclojure 2.1.2 over 2.1.0

2009-10-12 Thread Albert Cardona
Meikel Brandmeyer wrote: Hi, On Oct 12, 4:56 pm, Albert Cardona sapri...@gmail.com wrote: /home/albert/Programming/vimclj/vimclojure-2.1.2/build.xml:182: Directory /home/user/.vim/autoload creation was not successful for an unknown reason I think I know the reason: /home/user

clojure cheatsheet typos

2009-10-02 Thread Albert Cardona
1. Missing a '!': set-validator 2. Typo: Rearrangment (under sequences) 3. Macros looping doesn't have loop. So loop is special form and not a macro? Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You received

Re: the point of next vs rest?

2009-08-09 Thread Albert Cardona
this into an abstract immutable sequence with a java interface like: public interface FunctionalListyThing { Object first(); FunctionalListyThing rest(); boolean isEmpty(); } Why does one need the 4th method, next() ? It's all about lazy vs eager sequences. Albert -- Albert

Re: enhancement request: a simple way to read a file

2009-08-08 Thread Albert Cardona
Daniel Lyons wrote: On Aug 7, 2009, at 12:19 PM, Albert Cardona wrote: Currently, one must resort to incantations like: (with-open [stream (java.io.BufferedReader. (java.io.FileReader. /home/albert/test.xml))] (doseq [line (line-seq stream

Re: enhancement request: a simple way to read a file

2009-08-07 Thread Albert Cardona
Vagif Verdi wrote: Try contrib library duck-streams. I know duck-streams rather well. You missed the point, Vagif. Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: Array of primitives

2009-04-03 Thread Albert Cardona
'vec' wrapper to iterate the array: ; Print its values: (doseq [v (vec my-array)] (println v)) Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group

Re: March 20th 2009 Rich Hickey Appreciation Day!

2009-03-23 Thread Albert Cardona
Thank you so much Rich to ease our collective pain !!! Gaudeamus igitur ... Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post

Re: VimClojure 2

2009-03-14 Thread Albert Cardona
any description in a manual. Thanks for VimClojure. I'm loving it despite all the unexpected reactions. Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure

Re: VimClojure 2

2009-03-13 Thread Albert Cardona
files. I cannot see what is wrong. I would appreciate help in understanding what the error means. Thanks. Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure

Re: VimClojure 2

2009-03-13 Thread Albert Cardona
Hi Meikel, Thank you for the prompt response. I will point this out more clearly in the documentation. And future users will be greateful for that! VimClojure is looking great Meikel. Albert -- Albert Cardona http://albert.rierol.net

Re: Java equivalent to Python's Imaging Library (PIL)

2009-03-12 Thread Albert Cardona
. Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You 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

Re: Java equivalent to Python's Imaging Library (PIL)

2009-03-12 Thread Albert Cardona
Hope that helped. Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You 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

Re: Map from generator?

2009-02-06 Thread Albert Cardona
. I had an almost identical (if less elegant) function to genmap as well in my files. Adding it to core would be nice. Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: repeat and replicate

2009-01-28 Thread Albert Cardona
, but interleave and map seem to blur that line. From clojure/core.clj : (defn replicate Returns a lazy seq of n xs. [n x] (take n (repeat x))) -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You received this message because you

Re: function that takes primitives?

2009-01-23 Thread Albert Cardona
. Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You 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

Re: class diagram

2008-12-21 Thread Albert Cardona
Also, is there a Clojure function that outputs all the classes and interfaces in the inheritance hierarchy of a given class or interface? Isn't that ancestors? user= (ancestors String) #{java.lang.Object java.lang.CharSequence java.io.Serializable java.lang.Comparable} -- Albert

Re: learning about AOT

2008-12-15 Thread Albert Cardona
source file? For compiling, you don't need more than the top folder and the folder with the .clj file. But it's just convenient to have the 3 of them, so when running the class' main, the classpath is the same. Albert -- Albert Cardona http://albert.rierol.net

Re: Best Choice of Java Class For *out*

2008-12-15 Thread Albert Cardona
Randall R Schulz wrote: What might be the issues or consequences of making the root binding of *out* a PrintWriter? I've been using a PrintWriter for *out* for months now, and no problems so far. Using always nearly latest svn clojure. Albert -- Albert Cardona http

Re: learning about AOT

2008-12-14 Thread Albert Cardona
/Clojure_Scripting#Generating_java_classes_in_.class_files_from_clojure_code Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Re: Readable names

2008-11-11 Thread Albert Cardona
*) (assoc map key val) (dissoc map key) (get map key) (contains? map key) ... Just a suggestion. Albert -- Albert Cardona http://albert.rierol.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group

Re: executing shell command

2008-08-31 Thread Albert Cardona
) Then: (cmdout (cmd ls -a)) The code above contains an error: (.InputStreamReader. should be: (InputStreamReader. Note one dot less. You are calling a constructor. Otherwise works fine. Thanks for sharing. Albert -- Albert Cardona http://www.mcdb.ucla.edu