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
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
--
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
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)
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
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.
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]
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
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,
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
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
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
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
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
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.
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
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,
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
--
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
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:
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
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
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
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
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
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
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
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
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
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,
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))
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
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
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
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
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
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
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
'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
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
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
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
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
.
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
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
.
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
, 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
.
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
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
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
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
/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
*)
(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
)
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
54 matches
Mail list logo