On Feb 2, 10:29 pm, David Nolen dnolen.li...@gmail.com wrote:
Heh, this is a more reasoned reply than my own as it points out an actual
implementation difference between Python and Clojure. And of course you
might need arbitrary precision arithmetic in your program, but again this
just
On 2 Feb., 16:35, Gregory Petrosyan gregory.petros...@gmail.com
wrote:
Clojure rev. 1173:
user= (defn fac [#^Integer n] (reduce * (range 1 (+ 1 n
#'user/fac
user= (time (reduce + (map fac (range 1000
Elapsed time: 944.798019 msecs
Python 3.0: import timeit
Hi,
On Feb 2, 3:42 pm, Timothy Pratley timothyprat...@gmail.com wrote:
Hi Jeffrey,
On Feb 1, 4:50 am, Jeffrey Straszheim straszheimjeff...@gmail.com
wrote:
However, I'm not sure if you can built your own predicates in Java
code (and therefore in Clojure code). That seems like a feature
I suggest we work to James' schedule and talk about Compojure in our first
meet; how does that sound?
I don't have access to a private venue. If anyone else does that would be
cool, otherwise I'll try and find somewhere reasonably quiet, suggestions
welcome.
Tom
2009/2/2 James Reeves
Is there any reason to prefer lists over vectors or vice versa for
implementing queues? It seems that for both lists and vectors, adding
and removing at one end (front for lists, end for vectors) is cheap,
whereas it is expensive at the other end. For queues you need to add
at one end and
On Feb 3, 12:54 pm, Tom Ayerst tom.aye...@gmail.com wrote:
I suggest we work to James' schedule and talk about Compojure in our first
meet; how does that sound?
I don't have access to a private venue. If anyone else does that would be
cool, otherwise I'll try and find somewhere reasonably
Hello Tim,
Thanks for pointing the mistakes in code and the quote thing. Will be
fixed in the next version of the guide...
You can call main very easily: (MainFrame/main nil) however seeing the
default implementation does not return the created object, you can't
add the action listeners, so
Konrad Hinsen a écrit :
Is there any reason to prefer lists over vectors or vice versa for
implementing queues? It seems that for both lists and vectors, adding
and removing at one end (front for lists, end for vectors) is cheap,
whereas it is expensive at the other end. For queues you
2009/2/3 Konrad Hinsen konrad.hin...@laposte.net:
Is there any reason to prefer lists over vectors or vice versa for
implementing queues? It seems that for both lists and vectors, adding
and removing at one end (front for lists, end for vectors) is cheap,
whereas it is expensive at the other
I don't know which of these two options are best in general, but I
wonder; are persistance and immutability valuable properties of
queues? Safe and cheap snap-shotting might be a nice feature of a
queue but I (generally) wouldn't want it at the cost of more expensive
put and take operations.
Lauri Pesonen a écrit :
You can use a pair of lists to implement a queue where the first list
is used to dequeue items from and the second list is used to enqueue
items to. When the first queue is empty, you replace it with a
reversed version of the second queue.
Or you can use a seq and
On Feb 3, 2009, at 14:49, Mark Volkmann wrote:
I see from the feedback so far that my statements are wrong. However,
I think it's true that there are *some* things you can do in a
function that you cannot do in a macro, and perhaps vice-versa. Are
those clearly documented anywhere? If not,
On Feb 3, 2009, at 14:57, Christophe Grand wrote:
If you haven't tried it yet, there's clojure.lang.PersistentQueue:
I didn't, since it's well hidden - you can even search for
PersistentQueue on the Clojure web site without finding anything. But
it looks like just what I want - thanks!
On Tue, Feb 3, 2009 at 2:35 PM, Konrad Hinsen konrad.hin...@laposte.netwrote:
For queues you need to add
at one end and remove from the other, so one of the two operations is
necessarily expensive.
No.
Look here for hints: http://www.cs.bu.edu/teaching/c/queue/array/types.html
I found this document
http://www.scribd.com/doc/3566845/FRP-Presentation-Web
and this document
http://web.mac.com/ben_moseley/frp/paper-v1_01.pdf
and this phrase
Rich recommended a paper, Out of the Tar Pit, for a discussion of functional
and relational techniques to manage state.
from
On Feb 2, 2:27 pm, Chouser chou...@gmail.com wrote:
On Mon, Feb 2, 2009 at 2:05 PM, MikeM michael.messini...@invista.com wrote:
There is a lazy branch in SVN. The streams branch has been
discussed, but I haven't seen any discussion of the lazy branch -
perhaps I missed it.
Here's a
On Feb 3, 9:19 am, Jack Norimi clojuregr...@ululi.it wrote:
I found this documenthttp://www.scribd.com/doc/3566845/FRP-Presentation-Web
and this documenthttp://web.mac.com/ben_moseley/frp/paper-v1_01.pdf
and this phrase Rich recommended a paper, Out of the Tar Pit, for a
discussion of
I read that paper a couple of years ago and its what started me on the
path toward functional programming which brought me to Clojure. As
Rich said, it has some very important insights about complexity and
presents an interesting idea of how to manage it.
I took a crack at implementing it in
On Tue, 3 Feb 2009 05:47:36 -0800 (PST)
peg philippe.gi...@gmail.com wrote:
hi,
if I can help ( but for what? ;-) , I know relatively well Santiago,
know people there
and speak and write spanish (I'm french living in France).
Phil
Nothing specific, I was following on from the
Rich,
I like the way that's headed. I'm working on an network app where I'm
parsing a stream from a TCP socket. Being able to get the chars from
the socket in a lazy way, without reading one too many, would be
great. I fudged that by defining a function to read a single char
from the socket's
Chouser a écrit :
What the remaining vars do is a mystery for all but those willing to
plumb the depths of Clojure's Java sources:
*macro-meta*
*math-context*
*use-context-classloader*
I can shed some light on one third of this mystery:
*math-context* can be bound to an instance of
Ok, I'm an idiot. All I needed was (remove #( (last %1) (first %1))
(selections [1 2 3 4] 3))
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this group, send email to
On Mon, Feb 2, 2009 at 9:28 PM, Mark Volkmann r.mark.volkm...@gmail.com wrote:
I understand that special forms are all recognized by the Clojure
compiler clojure.lang.Compiler. Is it the case that all function and
macro definitions can be found in some .clj file, whether supplied
with
On Feb 3, 2009, at 15:31, Rich Hickey wrote:
I've started documenting the lazy branch work here:
http://clojure.org/lazier
Interesting stuff...
I agree that streams are ugly. Anything that will have most of the
advantages of streams while not enforcing explicit state management
(as
Using Clojure at the RIVM in bilthoven, and at University of Utrecht.
Previous projects of my phd were in ruby, last one is in clojure.
Postdoc is in Clojure.
Amsterdam is closeby. I've about no free time till end of march
(finishing thesis!), but might find it fun to join in April.
On Feb
Erik,
Did you use a bottom up evaluation strategy? What top level
optimizations did you use (e.g. magic sets and so on)?
On Feb 3, 6:34 am, hoeck i_am_wea...@kittymail.com wrote:
Hi,
On Feb 2, 3:42 pm, Timothy Pratley timothyprat...@gmail.com wrote:
Hi Jeffrey,
On Feb 1, 4:50 am,
On Feb 4, 12:01 am, Mark Volkmann r.mark.volkm...@gmail.com wrote:
Are the following statements true? They aren't discussed
athttp://clojure.org/macros, but I think they are true.
Macros cannot call other macros during their evaluation, but they can
expand to code that calls macros.
I
Are the following statements true? They aren't discussed at
http://clojure.org/macros, but I think they are true.
Macros cannot call other macros during their evaluation, but they can
expand to code that calls macros.
Macros cannot use syntactic sugar such as '(items) to create a list
and
On Tue, Feb 3, 2009 at 8:24 AM, Konrad Hinsen konrad.hin...@laposte.net wrote:
On Feb 3, 2009, at 14:49, Mark Volkmann wrote:
I see from the feedback so far that my statements are wrong. However,
I think it's true that there are *some* things you can do in a
function that you cannot do in a
On Tue, Feb 3, 2009 at 11:26 AM, Mark Volkmann
r.mark.volkm...@gmail.com wrote:
Now I remember what I was thinking about. This isn't so much a
difference between macros and functions as it is a rule about
something you cannot do in a macro. Quoting from Programming Clojure
...
You cannot
In general, this function will work for non-integer collections. I
make no performance/laziness guarantees.
(defn selections-dups [coll n]
(let [r (range (count coll))
f #( (last %1) (first %1))
s (remove f (selections r n))]
(map #(map (fn [x] (nth coll x)) %1) s)))
Hi!
Am 03.02.2009 um 17:26 schrieb Mark Volkmann:
On Tue, Feb 3, 2009 at 8:24 AM, Konrad Hinsen konrad.hin...@laposte.net
wrote:
On Feb 3, 2009, at 14:49, Mark Volkmann wrote:
I see from the feedback so far that my statements are wrong.
However,
I think it's true that there are
On Feb 3, 12:50 pm, André Thieme splendidl...@googlemail.com wrote:
Hi, welcome in the group.
Can you please write that program in Java and see how well it
performs for you?
Will try to compare Java and Clojure later.
Here http://leonardo-m.livejournal.com/75825.html you can find similar
Thanks. It worked. I had to add the library path as well.
C:\myprograms\clojurejava -Djava.library.path=c:\myprograms
\jacob-1.14.3 -cp C:
\myprograms\jacob-1.14.3\jacob.jar;clojure.jar clojure.lang.Repl
Clojure
user= (import '(com.jacob.com Dispatch ComThread))
nil
user= (def xl (new Dispatch
Even more constructive is to take a real Python program that you've written
where you actually care about it's performance. Rewrite it Clojure. Do
some investigation about which parts seem slow to you. Spend some time on
this. Come back with some code and questions and you'll probably get some
Jason, thanks a lot for the tip on source macro in
clojure.contrib.repl-utils, it is indeed very nifty!
Resolution for the day: get to know the contrib library!
On Feb 2, 9:48 pm, Jason Wolfe jawo...@berkeley.edu wrote:
I believe that any non-special-form has a clojure implementation in
some
Mark Volkmann wrote:
I see from the feedback so far that my statements are wrong. However,
I think it's true that there are *some* things you can do in a
function that you cannot do in a macro, and perhaps vice-versa. Are
those clearly documented anywhere? If not, what are some?
You might
On Feb 3, 2009, at 14:01, Mark Volkmann wrote:
Are the following statements true? They aren't discussed at
http://clojure.org/macros, but I think they are true.
Macros cannot call other macros during their evaluation, but they can
expand to code that calls macros.
Macros can certainly
You can call main very easily: (MainFrame/main nil) however seeing the
default implementation does not return the created object, you can't
add the action listeners, so it isn't much use.
I thought of using it as the start function to make the GUI visible
(instead of .setVisible).
Hi all,
I'm using the system java on Mac OS Leopard, and confused about how to
get the parallel library working. I've got the necessary jar file on
my classpath:
sihpc03:clojure anand$ echo $CLASSPATH
/usr/local/clojure:/Library/Java/Extensions
sihpc03:clojure anand$ ls
Mark -
Not a problem. I didn't take it that way at all.
- Keith
Hope I didn't offend with my rather sharp reply -- I meant to be clear
but I realized later that it could be taken as sounding annoyed! The
other folks did a great job of explaining the situation with a more
friendly tone
I had similar results when I compiled jsr166y myself. There's a jar in
the group's files that is known to work.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this group, send email to
Functions like (+), (*), (-), (and probably more) should support
sequences as parameters.
The current way to accomplish this (without implementing your own sum
using reduce) seems to be:
(apply + (map #(. Math pow 2 %) (range 10)))
... which has to generate the sequence first.
Instead, you
hi,
if I can help ( but for what? ;-) , I know relatively well Santiago,
know people there
and speak and write spanish (I'm french living in France).
Phil
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure
Hello,
stuhood a écrit :
Functions like (+), (*), (-), (and probably more) should support
sequences as parameters.
The current way to accomplish this (without implementing your own sum
using reduce) seems to be:
(apply + (map #(. Math pow 2 %) (range 10)))
... which has to
I see. Iris does look pretty good, but I think I'm going to give
writing this in Clojure a try -- the worst outcome is I waste some
time and learn a lot about logic programming. I think Clojure's
superior handling of state and concurrency will pay off here.
On Feb 3, 1:35 pm, hoeck
There are a very few functions and a few more vars defined only in
Java code, but that participate in namespaces the normal way and
therefore don't count as special forms.
One way to find these is to get a list of all the clojure.core vars
that have no :file metadata:
(filter #(nil? (:file
This is a common misconception: passing a seq to apply doesn't force its
evaluation.
Ahh, is this because the [ more] portion is itself a lazy sequence? That's
very cool =)
Hmm, the (reduce + ...) approach works just fine, but if it is already
implemented as reduce, it seems like it would be
Stu Hood a écrit :
I still think the
( (range 10))
... use case is really worthwhile though, and I don't see a way to
accomplish it with reduce.
reduce is not a good fit since you would want to short circuit the
computation at the first false.
but apply works very well for this use case:
Name: saxon
Author: Perry Trolard
URL: http://github.com/pjt/saxon/tree/master
Category: XML, XPath, XQuery
License: MIT
Depends: Michael Kay's Saxon XSLT and XQuery Processor (http://
saxonica.com); included in distribution
saxon is a simple functional wrapper around Saxon's high-level APIs,
OK, I get it:
- parallel.clj writes into the namespace 'clojure.parallel, not
plain 'parallel as written on clojure.org/other_libraries
- parallel.clj needs to be on my path, not my classpath.
That wasn't so bad, but It'll be easier if the examples on the website
were brought up to date.
Whenever I try to use read-line, the program compiles but when it's
run and it gets to where it uses the function it gives me this error
Exception in thread main java.lang.ClassCastException:
clojure.lang.LineNumberingPushbackReader cannot be cast to
java.io.BufferedReader
at
Hi all,
Messing around with preduce at the REPL I saw this:
user= (defn q [sofar new] (do (print new sofar\n) (+ (+ 1 new)
sofar)))
#'user/q
user= (reduce q 0 [1 2
3])
1 0
2 2
3 5
9
user= (preduce q 0 [1 2
3])
3 2
6 1
8
It looks like preduce takes its arguments in the opposite order from
On Feb 3, 4:43 pm, Anand Patil anand.prabhakar.pa...@gmail.com
wrote:
Hi all,
Messing around with preduce at the REPL I saw this:
user= (defn q [sofar new] (do (print new sofar\n) (+ (+ 1 new)
sofar)))
#'user/q
user= (reduce q 0 [1 2
3])
1 0
2 2
3 5
9
user= (preduce q 0 [1 2
3])
Hi Vlad,
Options are good :-). Any objections on including your variant in the
guide?
Feel free to use it as you wish.
It looks that the main is class method? It can be called as above but
I do not know if/how to call that after the MainFrame has being
created (i.e calling it on
On Monday 02 February 2009 19:12:48 David Nolen wrote:
Please do the list a favor and read the very long threads about
performance.
I would be interested to see a Clojure port of my ray tracer benchmark:
http://www.ffconsultancy.com/languages/ray_tracer/
--
Dr Jon Harrop, Flying Frog
On further reflection, perhaps the best approach would use sorted-map:
(defstruct example :msg :order)
(def a (struct there 2))
(def b (struct hi 1))
(def c (struct everyone 3))
We want our map to be sorted on the :order key. So:
(sorted-map (:order a) a (:order b) b (:order c) c)
I could
On Feb 1, 5:22 pm, David Nolen dnolen.li...@gmail.com wrote:
I've changed the name of my project since that was a joke
anyway.http://github.com/swannodette/spinoza/tree/master
Spinoza isn't just for people who want object oriented behaviors. It's also
for anyone who plans on instantiating
2009/2/3 Gregory Petrosyan gregory.petros...@gmail.com:
Here http://leonardo-m.livejournal.com/75825.html you can find similar
microbenchmark. Java is more than 3х slower than Python's built-in
integers, and more than 10x slower than GMPY ones. Seems like Java's
BigIntegers have some problems
Thanks Zak,
With the other jar I could load parallel.clj without errors, but I
wasn't able to refer to the parallel namespace as on clojure.org/
other_libraries, nor was preduce present in the user namespace:
user= (load-file parallel.clj)
nil
user= (refer 'parallel)
java.lang.Exception: No
I'm trying to define a macro:
http://paste.pocoo.org/show/102695/
But whenever I try to compile it I get:
java.lang.ArrayIndexOutOfBoundsException: 1
java.lang.Exception: Unmatched delimiter: )
java.lang.Exception: Unmatched delimiter: )
Note, this is when compiling the macro itself, not
hi jeffrey,
On Feb 3, 2:50 pm, Jeffrey Straszheim straszheimjeff...@gmail.com
wrote:
Erik,
Did you use a bottom up evaluation strategy? What top level
optimizations did you use (e.g. magic sets and so on)?
I only wrote a clojure-wrapper for the iris-reasoner (www.iris-
reasoner.org)
Btw, I fixed the ~ needed on relation. It didn't help. It seems I
just can't put a ~@ form inside of a { } set builder.
On Feb 3, 7:43 pm, Jeffrey Straszheim straszheimjeff...@gmail.com
wrote:
I'm trying to define a macro:
http://paste.pocoo.org/show/102695/
But whenever I try to compile
but apply works very well for this use case: (apply (range 10))
and it stops as soon as it can:
Alright, I fold... thanks for clearing things up Christophe!
On Tue, Feb 3, 2009 at 3:13 PM, Christophe Grand christo...@cgrand.netwrote:
Stu Hood a écrit :
I still think the
( (range 10))
On further reflection, perhaps the best approach would use sorted-map:
Just curious, does the key need to be in the struct? (seeing you'll
get key-value pairs anyhow if you use first/last etc - the info will
still be there)
If you do need the key in both places, perhaps something like this
The version of Clojure that I was using's read-line function was
broken obviously, the release version works.
On Feb 3, 3:37 pm, Rayne disciplera...@gmail.com wrote:
Whenever I try to use read-line, the program compiles but when it's
run and it gets to where it uses the function it gives me
{} is a reader macro for hash-map I believe, try something like this:
(defmacro foobar [ rest]
`(hash-map ~...@rest))
(foobar :first 1 :second 2)
On Tue, Feb 3, 2009 at 7:45 PM, Jeffrey Straszheim
straszheimjeff...@gmail.com wrote:
Btw, I fixed the ~ needed on relation. It didn't help.
Thanks.
On Feb 3, 7:55 pm, David Nolen dnolen.li...@gmail.com wrote:
{} is a reader macro for hash-map I believe, try something like this:
(defmacro foobar [ rest]
`(hash-map ~...@rest))
(foobar :first 1 :second 2)
On Tue, Feb 3, 2009 at 7:45 PM, Jeffrey Straszheim
This works for me:
(def wrap-var)
(defmacro datalog-term
Builds a term
[relation formals]
(let [wrapped-formals (map wrap-var formals)]
`(struct rule ~relation (hash-map ~...@wrapped-formals
ie: using (has-map ...) instead of {}
I believe this is because {} is handled at the
On Feb 3, 2009, at 7:45 PM, Jeffrey Straszheim wrote:
Btw, I fixed the ~ needed on relation. It didn't help. It seems I
just can't put a ~@ form inside of a { } set builder.
{ } reads a literal map. It appears to expect an even number arguments
between the curly braces at read time. You
Yes, it was working as a reader macro and messing me up. Using
hashmap worked. Thanks.
On Feb 3, 8:03 pm, Stephen C. Gilardi squee...@mac.com wrote:
On Feb 3, 2009, at 7:45 PM, Jeffrey Straszheim wrote:
Btw, I fixed the ~ needed on relation. It didn't help. It seems I
just can't put a
Just curious, does the key need to be in the struct? (seeing you'll
get key-value pairs anyhow if you use first/last etc - the info will
still be there)
Excellent point! Given that I'll be using a sorted-map now, I don't
even need the structmap!
Thanks for the code...I like what you did
A month or so ago, I installed the ForkJoin library, and played around
with the clojure.parallel wrapper library, and I wasn't able to get a
single test to show a speed improvement on my dual core machine. In
contrast, pmap, which doesn't rely on the ForkJoin library, works just
fine. It makes
Code written with the fully-lazy branch certainly looks cleaner than
the streams branch equivalent, and having full laziness seems like a
plus. The local-clearing mechanism seems like it will be
straightforward to use.
Seems like this is the way to go. Are there any drawbacks?
Hello, I cannot get slime and clojure-mode up and running:
;;; inferior lisp output
(add-classpath file:///c:/Documents and Settings/Administrator/
Application Data/emacs-contrib/swank-clojure/)
(require 'swank.swank)
(swank.swank/ignore-protocol-version 2009-01-30)
(swank.swank/start-server
Parsec is a very powerful parsing library for Haskell. I was mainly
attracted to Haskell because of this library (ala Pugs project which
used Parsec to create a Perl6 parser).
I am wondering if there is an ongoing effort to write similar library
for Clojure. I have seen a very nice
(map #(doto %1 (.add 2)) (doto (new java.util.ArrayList) (.add 1)))
This seems like it should work, but does not. Can anyone confirm?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this
On Feb 3, 9:57 pm, MikeM michael.messini...@invista.com wrote:
Code written with the fully-lazy branch certainly looks cleaner than
the streams branch equivalent, and having full laziness seems like a
plus. The local-clearing mechanism seems like it will be
straightforward to use.
Seems
On Feb 3, 2009, at 10:32 PM, kyle smith wrote:
(map #(doto %1 (.add 2)) (doto (new java.util.ArrayList) (.add 1)))
user= (map #(doto %1 (.add 2)) (doto (new java.util.ArrayList) (.add
1)))
java.lang.IllegalArgumentException: No matching method found: add for
class java.lang.Integer
This just bit me a second time, since one of my revised set functions
uses contains? and thus doesn't work on java.util.Sets (or even
the .keySets of Clojure maps).
user (contains? (.keySet {:a :b}) :a)
false
It seems that all that's required to make contains? work on general
Sets is to replace
On Feb 3, 2009, at 10:44 PM, Jason Wolfe wrote:
user (contains? (.keySet {:a :b}) :a)
false
It seems that all that's required to make contains? work on general
Sets is to replace IPersistentSet with Set on lines 648 and 649 of
RT.java. I can make a patch if desired.
Along those lines,
What is the significance of the dash after defn? How does it differ
from defn?
Source:
http://www.codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages:Clojure:Chapter_1#.3B_1.1.4_The_Elements_of_Programming_-_Compound_Procedures
Meikel Brandmeyer has been doing some work on one. Check it out at:
http://kotka.de/projects/clojure/parser.html.
I haven't looked at it too closely myself. Maybe Meikel will stop in
and give you a feeling for how close/far it is from full Parsec.
Tom
On Feb 3, 6:42 pm, sbkogs
It means the same thing as defn except that the resulting definition
is not visible outside the defining namespace. This is equivalent to
(defn #^{:private true} ...).
On Feb 3, 8:19 pm, Terrence Brannon metap...@gmail.com wrote:
What is the significance of the dash after defn? How does it
as a namespace is to a java package, defn- is to private, and defn is to public
On Tue, Feb 3, 2009 at 8:19 PM, Terrence Brannon metap...@gmail.com wrote:
What is the significance of the dash after defn? How does it differ
from defn?
Source:
On Feb 3, 2009, at 8:16 PM, Stephen C. Gilardi wrote:
On Feb 3, 2009, at 10:44 PM, Jason Wolfe wrote:
user (contains? (.keySet {:a :b}) :a)
false
It seems that all that's required to make contains? work on general
Sets is to replace IPersistentSet with Set on lines 648 and 649
of
One thing I couldn't tell from the lazier doc is whether rest is
only being kept around for backward compatibility or whether there
still might be reasons to actively prefer rest to more.
--~--~-~--~~~---~--~~
You received this message because you are subscribed
87 matches
Mail list logo