Re: Clojure speed
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 reinforces the insignificance of microbenchmarks without some context of what you are actually trying to achieve. On Mon, Feb 2, 2009 at 2:12 PM, Christian Vest Hansen karmazi...@gmail.comwrote: It is safe to assume that Python uses the GMP library for its infinite precision math, no? This could be a big part of the explanation as, if the language shootouts are to be believed, BigInteger and BigDecimal have inferior performance when compared to what can be achieved with GMP. Well, Python uses home-grown arbitrary precision numbers: http://svn.python.org/view/python/trunk/Objects/intobject.c?rev=68381view=markup http://svn.python.org/view/python/trunk/Objects/longobject.c?rev=68975view=markup Anyway, I am not trying to prove that Clojure is slow or anything like that. Out of curiosity: are there any public Clojure benchmarks available? Anything like Great Computer Languages Shootout benchmarks? It will be very interesting to play with them a bit, comparing them to Java ones, for example. --~--~-~--~~~---~--~~ 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: Clojure speed
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 t=timeit.Timer('sum(fac(n) for n in range(1000))', 'from functools import reduce; from operator import mul; fac = lambda n: reduce(mul, range(1, n+1), 1)') t.timeit(10)/10 0.35052159800038679 This is XP SP2 on Core2 Duo, with 3Gb of RAM. As you can see, Python is almost 3 times faster on this microbenchmark! Can anybody explain this to me? (No flame wars, please, I am really interested in why the things are as they are, is it considered ok or not, and what can be done to make Clojure faster on similar tests). Hi, welcome in the group. Can you please write that program in Java and see how well it performs for you? --~--~-~--~~~---~--~~ 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: Questions about a Clojure Datalog
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 we'd want. I've sent an email to their support folks to find out if this is possible. I gave it a crack. It is definitely possible (perhaps even easy if you are familiar with the nomenclature). Setting up the primitive support is trivial, but combining the parts sent me into a spin - enter a DSL which seems the logical aim (is this indeed the intention?)... http://github.com/timothypratley/strive/blob/80a3e41af4c8d882c0330ff1... Here is where I got to so far... does the cheats method (parse) to demonstrate simple facts/rules/query, then exposes the underlying primitives that could be used to build the same expression without parsing. Then I got somewhat lost and figured I'd call it a night :) Did the same thing some time ago. Iris has good (at least good enough) API docs in pdf and javadoc form. Inspired by the Allegro CL Prolog syntax i set up a little DSL for writing datalog programs and providing relations from clojure-sets and sql-queries. Unfortunately the whole package is currently broken while I'm completing the surrounding relational algebra library. But maybe someone wants to look at the code: http://github.com/hoeck/ra/blob/a018f2347fb409e7adc438f9c8b74fe8fecc57e9/hoeck/rel/iris.clj the simpsons example would then look like: (clear-universe) (- (man '#{homer})) (- (woman '#{marge})) (- (hasSon '#{[homer bart]})) (- (isMale ?x) (man ?x)) (- (isFemale ?x) (woman ?x)) (- (isMale ?y) (hasSon ?x ?y)) (?- (isMale ?x)) I hope to get it running again soon. I couldn't find much info (any?) at all on the web about Datalog or how to use IRIS in general... it certainly seems interesting as a solver, but in practical terms how can I take advantage of it? Ok I can think of some classic solver type problems (which are indeed practical), but I get the impression Datalog is slated for greater things, ie: general data modeling? Iris is hosted at the Semantic Technology Institute (STI) Innsbruck, reading through their research projects page leads to a new iris page, describing its goal as: It is the mission of the IRIS research unit to define languages for describing data and Web services, and to build software components to reason about these data and service descriptions in order to make the vision of the Semantic Web a reality. (http://iris.sti-innsbruck.at) So you're probably right about it being for greater things. erik --~--~-~--~~~---~--~~ 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: London Clojurians
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 weavejes...@googlemail.com On Feb 2, 9:37 am, Tom Ayerst tom.aye...@gmail.com wrote: Is there anyone getting together in London to discuss Clojure? If so, can anyone play? If not, would anyone be interested? I'm in London, and I might be interested. I tend to have a pretty tight schedule, though :( - James --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Queues
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 remove from the other, so one of the two operations is necessarily expensive. But is there a difference between the two? Konrad. --~--~-~--~~~---~--~~ 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: London Clojurians
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 quiet, suggestions welcome. The people at Scheme UK have (very) occasional meetings in Shoreditch. We could join up with them and get a few more people, perhaps. http://upcoming.yahoo.com/group/4654/ Perhaps someone could do an introductory talk 'Clojure for Schemers' and then move on to Compojure. --~--~-~--~~~---~--~~ 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: A short guide on how to use NetBeans to create GUI and then use this GUI from clojure available
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 it isn't much use. I thought of using it as the start function to make the GUI visible (instead of .setVisible). Cheers for showing me how to call the function. http://groups.google.com/group/clojure/web/app.clj Options are good :-). Any objections on including your variant in the guide? I found the guide very well written and easy to follow. :-) Vlad --~--~-~--~~~---~--~~ 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: Queues
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 need to add at one end and remove from the other, so one of the two operations is necessarily expensive. But is there a difference between the two? Konrad. If you haven't tried it yet, there's clojure.lang.PersistentQueue: user= (def empty-queue clojure.lang.PersistentQueue/EMPTY) #'user/empty-queue user= (conj empty-queue 1) (1) user= (conj *1 2 3 4) (1 2 3 4) user= (pop *1) (2 3 4) user= (peek *2) 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 -~--~~~~--~~--~--~---
Re: Queues
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 end. For queues you need to add at one end and remove from the other, so one of the two operations is necessarily expensive. But is there a difference between the two? 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. I don't have time to write this in clojure at the moment but in haskell it would be something like this: -- A queue consists of two lists of a's data Queue a = Queue [a] [a] -- i.e. when enqueueing we add the new item to the front of the second list enqueue (Queue as bs) i = Queue as (i:bs) -- when dequeueing we need to handle two cases: when A is emply and when A is not empty. In -- the first case we replace A with the reverse of B and replace B with the empty list, i.e. we -- move the enqueued elements from B to A and then run dequeue again with the new queue -- structure dequeue (Queue [] bs) = dequeue (Queue (reverse b) []) -- In the second case we simply return the head of A as the dequeued item and update the -- queue structure dequeue (Queue as bs) = (head as, Queue (tail as) bs) The point is that enqueueing and dequeueing are O(1) most cases and the reversing operation which is O(n) is amortised over the lifetime of the qeueue. Konrad. -- ! Lauri --~--~-~--~~~---~--~~ 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: Queues
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. Java already have concurrent, albeit mutable, queue implementations in the java.util.concurrent package. Since most operations you'd want to execute on a queue are writes, I can't help but think that a mutable datastructure is better suited, and that an attempt with immutable structures would most likely end up simulating mutability with some form of copy-on-write + CAS scheme anyway. Then again, safe snapshots might really be important, and that's where I'd use PersistentQueue as Christophe Grand mentioned. On Tue, Feb 3, 2009 at 2:35 PM, Konrad Hinsen konrad.hin...@laposte.net wrote: 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 remove from the other, so one of the two operations is necessarily expensive. But is there a difference between the two? Konrad. -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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: Queues
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 a vector like clojure.lang.PersistentQueue does thus you won't need to reverse the vector but the queue will retain references on dequeued items for some time (until the current seq is empty). Christophe --~--~-~--~~~---~--~~ 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: rules for writing macros
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, what are some? I can't think of anything that would be forbidden in a macro but allowed in a plain function. There are many things that don't make sense in a macro, of course: launching agents, opening windows, ... Konrad. --~--~-~--~~~---~--~~ 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: Queues
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! Konrad. --~--~-~--~~~---~--~~ 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: Queues
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 http://www.cs.bu.edu/teaching/c/queue/array/types.html But also look here for other approaches: http://www.google.com/search?q=queue+persistent Cheers P. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Example of functional relational programming in clojure
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 http://stuartsierra.com/2008/08/08/clojure-for-the-semantic-web Can anybody provide an little example of *functional relational programming* in clojure? Thank you. Jack Norimi --~--~-~--~~~---~--~~ 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: SVN branches
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 discussion from earlier today, mainly about the lazy branch: http://clojure-log.n01se.net/date/2009-02-02.html#09:47 I've started documenting the lazy branch work here: http://clojure.org/lazier Feedback welcome, 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 -~--~~~~--~~--~--~---
Re: Example of functional relational programming in clojure
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 functional and relational techniques to manage state. fromhttp://stuartsierra.com/2008/08/08/clojure-for-the-semantic-web Can anybody provide an little example of *functional relational programming* in clojure? Clojure is currently missing the 'relational' part of FRP, but I have hopes for an embedded Datalog fulfilling that role. Note also that Clojure has extensive support for managed state, and doesn't espouse a pure approach to FRP. A primary value of that paper, which I highly recommend, is the focus on complexity, and the role of state in complexity. 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 -~--~~~~--~~--~--~---
Re: Example of functional relational programming in clojure
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 SBCL but after I switched to Clojure, I've found the need for something like it greatly reduced because Rich has put such an emphasis on making concurrent programming easy. Jim Jack Norimi wrote: 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 http://stuartsierra.com/2008/08/08/clojure-for-the-semantic-web Can anybody provide an little example of *functional relational programming* in clojure? Thank you. Jack Norimi --~--~-~--~~~---~--~~ 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: Santiago Clojurians?
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 London clojurians thread, thought I'd add some noise :) -- None are more hopelessly enslaved than those who falsely believe they are free — Goethe --~--~-~--~~~---~--~~ 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: SVN branches
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 input stream and then used lazy-cons to call it when needed. Look forward to using these lazy sequences. Jim Rich Hickey wrote: 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 discussion from earlier today, mainly about the lazy branch: http://clojure-log.n01se.net/date/2009-02-02.html#09:47 I've started documenting the lazy branch work here: http://clojure.org/lazier Feedback welcome, 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 -~--~~~~--~~--~--~---
Re: special forms vs. functions and macros
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 MathContext (http://java.sun.com/j2se/1.5.0/docs/api/java/math/MathContext.html) to control how operations on BigDecimals are performed (rounding and precision). 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 -~--~~~~--~~--~--~---
Re: removing duplicates from combinatorics/selections
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 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: special forms vs. functions and macros
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 Clojure or not? Asked another way, are there any functions or macros that are included with Clojure that are implemented entirely in Java code? 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 (meta %))) (vals (ns-publics 'clojure.core))) These are the functions: load-file in-ns identical? Note that even though 'in-ns' and 'ns' are not special forms, they are handled specially in the resolver so you never need to give the namespace using them. The other documented vars are: *agent* *command-line-args* *compile-files* *compile-path* *err* *file* *flush-on-newline* *in* *ns* *out* *print-dup* *print-meta* *print-readably* *warn-on-reflection* 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* All (or nearly?) of these forms are defined starting around here: http://code.google.com/p/clojure/source/browse/trunk/src/jvm/clojure/lang/RT.java#171 --Chouser --~--~-~--~~~---~--~~ 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: SVN branches
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 stream generators do) is progress. I'll check out the lazy branch immediately! Konrad. --~--~-~--~~~---~--~~ 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: Amsterdam.clj
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 3, 12:13 am, Jeff Rose ros...@gmail.com wrote: Oh, cool! I'll be at the library next Monday then. Thanks for letting me know. -Jeff Remco van 't Veer wrote: Great idea! Maybe you would like to join ACK: http://groups.google.com/group/amsterdam-rb/browse_thread/thread/2a38... A small get together initiated by Rubyist in Amsterdam. Next meeting is next monday. At least two of us, myself included, are happily hacking clojure. On Mon, Feb 2, 2009 at 1:11 PM, Jeff Rose ros...@gmail.com wrote: Anyone else hacking Clojure in Amsterdam? How about going for a beer and talking some shop? -Jeff --~--~-~--~~~---~--~~ 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: Questions about a Clojure Datalog
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, 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 we'd want. I've sent an email to their support folks to find out if this is possible. I gave it a crack. It is definitely possible (perhaps even easy if you are familiar with the nomenclature). Setting up the primitive support is trivial, but combining the parts sent me into a spin - enter a DSL which seems the logical aim (is this indeed the intention?)... http://github.com/timothypratley/strive/blob/80a3e41af4c8d882c0330ff1... Here is where I got to so far... does the cheats method (parse) to demonstrate simple facts/rules/query, then exposes the underlying primitives that could be used to build the same expression without parsing. Then I got somewhat lost and figured I'd call it a night :) Did the same thing some time ago. Iris has good (at least good enough) API docs in pdf and javadoc form. Inspired by the Allegro CL Prolog syntax i set up a little DSL for writing datalog programs and providing relations from clojure-sets and sql-queries. Unfortunately the whole package is currently broken while I'm completing the surrounding relational algebra library. But maybe someone wants to look at the code: http://github.com/hoeck/ra/blob/a018f2347fb409e7adc438f9c8b74fe8fecc5... the simpsons example would then look like: (clear-universe) (- (man '#{homer})) (- (woman '#{marge})) (- (hasSon '#{[homer bart]})) (- (isMale ?x) (man ?x)) (- (isFemale ?x) (woman ?x)) (- (isMale ?y) (hasSon ?x ?y)) (?- (isMale ?x)) I hope to get it running again soon. I couldn't find much info (any?) at all on the web about Datalog or how to use IRIS in general... it certainly seems interesting as a solver, but in practical terms how can I take advantage of it? Ok I can think of some classic solver type problems (which are indeed practical), but I get the impression Datalog is slated for greater things, ie: general data modeling? Iris is hosted at the Semantic Technology Institute (STI) Innsbruck, reading through their research projects page leads to a new iris page, describing its goal as: It is the mission of the IRIS research unit to define languages for describing data and Web services, and to build software components to reason about these data and service descriptions in order to make the vision of the Semantic Web a reality. (http://iris.sti-innsbruck.at) So you're probably right about it being for greater things. erik --~--~-~--~~~---~--~~ 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: rules for writing macros
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 don't know, but I'll bravely guess that this is false, simply because I don't see any reason for it to be true. After all, many things we take for granted are in fact macros (e.g. for). I bet you can use for during the execution of a macro. Macros cannot use syntactic sugar such as '(items) to create a list and instead must use non-sugared forms like (list items). This is false. Macros use ', `, ~ and ~@ all the time. This leads me to a question I've always had. Is there a variant of ~@ that can be used outside of macros? e.g. (+ @(1 2 3)) ; - 6 (I realise you can use apply here, but that's not always the case.) Gavin --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
rules for writing macros
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 instead must use non-sugared forms like (list items). -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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: rules for writing macros
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 macro, and perhaps vice-versa. Are those clearly documented anywhere? If not, what are some? I can't think of anything that would be forbidden in a macro but allowed in a plain function. There are many things that don't make sense in a macro, of course: launching agents, opening windows, ... 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 write a macro that expands to any of the syntactic sugar forms ... For example, you cannot write a macro that expands to (Math/PI). when you are writing macros, make sure they expand to ordinary forms, not any of the sugared short forms. -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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: rules for writing macros
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 write a macro that expands to any of the syntactic sugar forms ... For example, you cannot write a macro that expands to (Math/PI). Hm... (defmacro pi [] 'Math/PI) == #'user/pi (macroexpand '(pi)) == Math/PI (pi) == 3.141592653589793 (defmacro strlen [s] `(.length ~s)) == #'user/strlen (strlen hello) == 5 (defmacro mydoc [s] `(:doc ^#'~s)) == #'user/mydoc (macroexpand '(mydoc doc)) == (:doc (clojure.core/meta (var doc))) (mydoc doc) == Prints documentation for a var or special form given its name That's a whole lot of sugar that all seems to work ok. Is there some other syntactic sugar form that does not work? Perhaps he's referring to actually producing reader macro usages, like this: (defmacro mydoc2 [s] `(:doc ~(symbol (str ^#' s == #'user/mydoc2 (macroexpand '(mydoc2 doc)) == (:doc ^#'doc) (mydoc2 doc) == java.lang.Exception: Unable to resolve symbol: ^#'doc --Chouser --~--~-~--~~~---~--~~ 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: removing duplicates from combinatorics/selections
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))) --~--~-~--~~~---~--~~ 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: rules for writing macros
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 *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? I can't think of anything that would be forbidden in a macro but allowed in a plain function. There are many things that don't make sense in a macro, of course: launching agents, opening windows, ... 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 write a macro that expands to any of the syntactic sugar forms ... For example, you cannot write a macro that expands to (Math/PI). when you are writing macros, make sure they expand to ordinary forms, not any of the sugared short forms. It's certainly ugly and inconvenient to do it this way, but it seems to work fine: user= (defmacro static-field [c f] (symbol (str (name c) \/ (name f #'user/field user= (macroexpand-1 '(static-field Math PI)) Math/PI user= (static-field Math PI) 3.141592653589793 user= (defmacro call-method [o m] `(~(symbol (str \. m)) ~o)) #'user/call user= (macroexpand-1 '(call-method foo toString)) (.toString foo) user= (call-method foo toString) foo Kind regards, achim -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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: Clojure speed
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 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 with performance, hm? --~--~-~--~~~---~--~~ 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: need some help getting jacob com library to work
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 Excel.Application)) #'user/xl user= (Dispatch/put xl Visible true) nil user= (Dispatch/call xl Quit) #Variant null user= (ComThread/Release) nil user= --~--~-~--~~~---~--~~ 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: Clojure speed
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 great answers. At that point you might start to understand what the performance characteristic of the language actually are. Perhaps some idioms in Python are faster, perhaps you need to learn new idioms to express them more efficiently in Clojure. Perhaps you'll find out some things are ungodly faster in Clojure and, of course, some things, like BigInteger math, aren't. 2009/2/3 Gregory Petrosyan gregory.petros...@gmail.com 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 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 with performance, hm? --~--~-~--~~~---~--~~ 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: special forms vs. functions and macros
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 .clj file, although that implementation may simply be a wrapper for a method in clojure.lang.RT. Also check out the source macro in clojure.contrib.repl_utils. It's quite nifty: user (source into) (defn into Returns a new coll consisting of to-coll with all of the items of from-coll conjoined. [to from] (let [ret to items (seq from)] (if items (recur (conj ret (first items)) (rest items)) ret))) nil Or, if you're just interested in where a fn or macro is defined, user (meta (var into)) {:ns #Namespace clojure.core, :name into, :file core.clj, :line 1771, :arglists ([to from]), :doc Returns a new coll consisting of to- coll with all of the items of\n from-coll conjoined.} user ^#'into ; same thing, just more terse Cheers, Jason --~--~-~--~~~---~--~~ 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: rules for writing macros
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 be interested in the development of this thread: http://groups.google.com/group/clojure/browse_thread/thread/fa976abf80c91361/0019b33732f34e62 --~--~-~--~~~---~--~~ 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: rules for writing macros
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 expand to code that uses macros. As for the first part of your statement, it depends on what you mean by calling a macro. A macro is just a function marked (with a tag in the metadata) as a macro. More precisely, the var whose value is the macro is tagged as a macro. This tag causes the compiler to call the macro function at compile time, rather than compile a call at runtime. The arguments are therefore unevaluated forms. The definition of a macro is an ordinary function definition, which can use macros just like any other function. These macros will be expanded when the macro is compiled, not when it is executed. If you want it to call another function tagged as a macro, but call it as if it weren't tagged as a macro, you can retrieve its function definition from the var and call it by another name. For example, (def and-fn @(var and)) will assign the function that implements and to and-fn, which is an ordinary function. Macros cannot use syntactic sugar such as '(items) to create a list and instead must use non-sugared forms like (list items). The standard quote is not very useful in macro definitions, but syntax-quote (`) is: (defmacro l [x y] `(~x ~y)) (macroexpand-1 '(l 1 2)) -- (1 2) Konrad. --~--~-~--~~~---~--~~ 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: A short guide on how to use NetBeans to create GUI and then use this GUI from clojure available
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). Cheers for showing me how to call the function. 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 resulting object). In any case it does not matter much (but I am still curious). Vlad --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Stupid Java questions
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 /Library/Java/Extensions/ clojure.jar jline-0.9.94.jar jsr166y.jar libsvnjavahl-1.jnilib libsvnjavahl.jnilib and I include it when I start up clojure: sihpc03:clojure anand$ java -server -cp jline-0.9.94.jar:jsr166y.jar:clojure.jar jline.ConsoleRunner clojure.lang.Repl However, when I try to load parallel.clj from the clojure source directory, a problem happens: user= (load-file parallel.clj) java.lang.ClassNotFoundException: jsr166y.forkjoin.ParallelArray (parallel.clj:0) How can I fix that? Another question: in the example on the clojure webpage, the load-file command is (load-file src/parallel.clj). To make that work do I have to have clojure's source directory on my classpath, or my regular path, or are the sources available from inside the jar file somehow? I'm sure the answers are available from Java documentation somewhere, but the fact that I'm working from closure adds a thick enough layer of confusion that I considered this worth posting... hope I'm not taking advantage. Thanks, Anand --~--~-~--~~~---~--~~ 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: Memory Consumption of Large Sequences
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 :-) mfh --~--~-~--~~~---~--~~ 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: Stupid Java questions
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 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 -~--~~~~--~~--~--~---
Simple math functions should support sequences
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 should be able to use (+ (map #(. Math pow 2 %) (range 10))) ... which could consume a lazy sequence without generating it. Also, this would let you check if a sequence was sorted by using ( (range 10)) .. which would be pretty elegant =) Thanks, Stu --~--~-~--~~~---~--~~ 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: Santiago Clojurians?
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 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: Simple math functions should support sequences
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 generate the sequence first. This is a common misconception: passing a seq to apply doesn't force its evaluation. You can test this fact by passing an infinite seq to a function: (defn second-arg [ args] (second args)) user= (apply second-arg (iterate inc 0)) 1 and (apply + some-seq) is really equivalent to (reduce + some-seq), see the def of + in core.clj: (defn + ... ([x y more] (reduce + (+ x y) more))) 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 -~--~~~~--~~--~--~---
Re: Questions about a Clojure Datalog
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 i_am_wea...@kittymail.com wrote: 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) mentioned above. One thing i added is the possiblity to add clojure-sets as named relations to a iris datalog program. All the evaluation is done by iris. The wrapper is part of a larger library dealing with lazy relational operators and sets. erik --~--~-~--~~~---~--~~ 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: special forms vs. functions and macros
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 (meta %))) (vals (ns-publics 'clojure.core))) These are the functions: load-file in-ns identical? Note that even though 'in-ns' and 'ns' are not special forms, they are handled specially in the resolver so you never need to give the namespace using them. The other documented vars are: *agent* *command-line-args* *compile-files* *compile-path* *err* *file* *flush-on-newline* *in* *ns* *out* *print-dup* *print-meta* *print-readably* *warn-on-reflection* 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* All (or nearly?) of these forms are defined starting around here: http://code.google.com/p/clojure/source/browse/trunk/src/jvm/clojure/lang/RT.java#171 --Chouser Very interesting, thanks Chouser! -Jason --~--~-~--~~~---~--~~ 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: Simple math functions should support sequences
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 very easy to allow (+) to take a sequence. I still think the ( (range 10)) ... use case is really worthwhile though, and I don't see a way to accomplish it with reduce. Thanks, Stu On Tue, Feb 3, 2009 at 1:36 PM, Christophe Grand christo...@cgrand.netwrote: 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 generate the sequence first. This is a common misconception: passing a seq to apply doesn't force its evaluation. You can test this fact by passing an infinite seq to a function: (defn second-arg [ args] (second args)) user= (apply second-arg (iterate inc 0)) 1 and (apply + some-seq) is really equivalent to (reduce + some-seq), see the def of + in core.clj: (defn + ... ([x y more] (reduce + (+ x y) more))) 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 -~--~~~~--~~--~--~---
Re: Simple math functions should support sequences
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: (apply (range 10)) and it stops as soon as it can: user=(apply (map #(doto % println) (concat (range 10 20) (range 10 10 11 12 13 14 15 16 17 18 19 0 false 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 -~--~~~~--~~--~--~---
Re: Got a Clojure library?
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, taking stylesheets, XPaths, XQuery expressions returning Clojure functions which apply them to compiled XML documents. For XQuery XPath, functions return lazy sequences of query results with atomic types (i.e. non-node results) converted to native Clojure (Java) datatypes. Perry --~--~-~--~~~---~--~~ 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: Stupid Java questions
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. Cheers, Anand --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
read-line problems
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 clojure.core$read_line__3987.invoke(core.clj:1976) at testbuttsecks.main$prompt_read__412.invoke(main.clj:14) at testbuttsecks.main$_main__425.invoke(main.clj:37) at clojure.lang.AFn.applyToHelper(AFn.java:172) at clojure.lang.AFn.applyTo(AFn.java:165) at testbuttsecks.main.main(Unknown Source) Here is the code I'm using. http://paste.pocoo.org/show/102647/ However, the 'read' function works perfectly, but I don't need it for what I'm doing. Thanks in advance! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Possible bug in preduce
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 reduce, but of course with this fn it shouldn't make any difference: user= (defn q [new sofar] (do (print new sofar\n) (+ (+ 1 new) sofar))) #'user/q user= (preduce q 0 [1 2 3]) 2 3 1 6 8 Looks like it's using 3 where it should compute (q 3). This is a bug, correct? Thanks, Anand --~--~-~--~~~---~--~~ 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: Possible bug in preduce
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]) 3 2 6 1 8 It looks like preduce takes its arguments in the opposite order from reduce, but of course with this fn it shouldn't make any difference: user= (defn q [new sofar] (do (print new sofar\n) (+ (+ 1 new) sofar))) #'user/q user= (preduce q 0 [1 2 3]) 2 3 1 6 8 Looks like it's using 3 where it should compute (q 3). This is a bug, correct? No, it's not. as the docs for preduce say: http://clojure.org/api#preduce Also note that (f base an-element) might be performed many times in fact, an arbitrary number of times depending on how many parallel tasks are fired up. So, the function with base value should produce an identity, e.g. (+ 0 x) and (* 1 x), and your q with 0 does not. 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 -~--~~~~--~~--~--~---
Re: A short guide on how to use NetBeans to create GUI and then use this GUI from clojure available
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 resulting object). In any case it does not matter much (but I am still curious). Yes that's right, the main is generated as a static method. static methods are invoked by their class, not object. So calling MainFrame.main() runs the static method, but you cannot do m = new MainFrame(); m.main(); The generated main creates a new instance of MainFrame and makes it visible. There is no way for you to provide the object to main or get the object from main without modifying the java code. Regards, Tim. --~--~-~--~~~---~--~~ 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: Clojure speed
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 Consultancy Ltd. http://www.ffconsultancy.com/?e --~--~-~--~~~---~--~~ 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: sorted-set-by?
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 wrap up some of this behavior into some functions that would clean it up. Is this the best approach, or should I be approaching this from another direction? --~--~-~--~~~---~--~~ 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: CLJOS - Spinoza, 3X faster than struct-map ;)
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 many structs. Spinoza's make-instance macro automatically orders your key/values and uses struct not struct-map. (defclass shape [object] (:position [0 0])) (defclass rect [shape] (:position [5 5]) :width :height) (time (dotimes [x 100] (make-instance rect :height 100 :width 150))) ~280ms (defstruct rect-struct :tag :position :width :height) (time (dotimes [x 100] (struct-map rect-struct :tag ::rect :position [50 50] :width 100 :height 190))) ~800ms Also, it is now available under an MIT license, feel free to fork, send patches at will etc. Does Spinoza do anything to optimize the size of the object? I'm tinkering with a project that will have several million objects in it. Currently I'm using struct-maps with around 7 keys, and the overhead appears to be around 200 bytes per map - I'd like it to be around 32 bytes ideally. I'm planning on eventually using Java objects to shrink the size, but it would be nice if there were a Clojure library I could use. Cheers, Brad --~--~-~--~~~---~--~~ 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: Clojure speed
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 with performance, hm? BigInteger have problems, but so does that benchmark: No warm-up. Includes startup time. Using client VM. And probably a number of less obvious things that commonly haunt Java micro-benchmarks. On the other hand, we have reason to hope that the big-math story will improve significantly in JDK 7: http://markmail.org/message/7conncsespvrlazn -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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: Stupid Java questions
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 namespace: parallel (NO_SOURCE_FILE:0) user= preduce java.lang.Exception: Unable to resolve symbol: preduce in this context (NO_SOURCE_FILE:0) Also, the word 'jsr166y.jar' on clojure.org/other_libraries should probably point to the working jar. Thanks, Anand On Feb 3, 6:22 pm, Zak Wilson zak.wil...@gmail.com wrote: 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 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 -~--~~~~--~~--~--~---
Macro error
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 executing it. I don't understand. --~--~-~--~~~---~--~~ 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: Questions about a Clojure Datalog
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) mentioned above. One thing i added is the possiblity to add clojure-sets as named relations to a iris datalog program. All the evaluation is done by iris. The wrapper is part of a larger library dealing with lazy relational operators and sets. erik --~--~-~--~~~---~--~~ 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: Macro error
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 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 executing it. I don't understand. --~--~-~--~~~---~--~~ 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: Simple math functions should support sequences
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)) ... 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: (apply (range 10)) and it stops as soon as it can: user=(apply (map #(doto % println) (concat (range 10 20) (range 10 10 11 12 13 14 15 16 17 18 19 0 false 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 -~--~~~~--~~--~--~---
Re: sorted-set-by?
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 http://groups.google.com/group/clojure/web/sorted-map-map.clj Regards, Tim. --~--~-~--~~~---~--~~ 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: read-line problems
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 this error Exception in thread main java.lang.ClassCastException: clojure.lang.LineNumberingPushbackReader cannot be cast to java.io.BufferedReader at clojure.core$read_line__3987.invoke(core.clj:1976) at testbuttsecks.main$prompt_read__412.invoke(main.clj:14) at testbuttsecks.main$_main__425.invoke(main.clj:37) at clojure.lang.AFn.applyToHelper(AFn.java:172) at clojure.lang.AFn.applyTo(AFn.java:165) at testbuttsecks.main.main(Unknown Source) Here is the code I'm using. http://paste.pocoo.org/show/102647/ However, the 'read' function works perfectly, but I don't need it for what I'm doing. Thanks in advance! --~--~-~--~~~---~--~~ 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: Macro error
{} 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. 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 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 executing it. I don't understand. --~--~-~--~~~---~--~~ 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: Macro error
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 straszheimjeff...@gmail.com 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. 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 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 executing it. I don't understand. --~--~-~--~~~---~--~~ 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: Macro error
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 reader level to specify a hash-map, not create one (excuse my inaccurate terminology). just can't put a ~@ form inside of a { } set builder. {} is a hash-map, if you wanted a set #{} (def wrap-var) (defmacro datalog-term Builds a term [relation formals] (let [wrapped-formals (map wrap-var formals)] `(struct rule ~relation (set ~...@wrapped-formals Which I think is more what you want. Regards, Tim. --~--~-~--~~~---~--~~ 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: Macro error
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 can work around this by calling hash-map instead of using a map literal. #{ } reads a literal set. That works. Some examples: user= (defmacro j [ formals] `...@formals}) #'user/j user= (j 1 2 3 4) #{1 2 3 4} user= (defmacro j [ formals] `...@formals}) java.lang.ArrayIndexOutOfBoundsException: 1 java.lang.Exception: Unmatched delimiter: ) user= (defmacro j [ formals] `(hash-map ~...@formals)) #'user/j user= (j 1 2 3 4) {1 2, 3 4} My impression is that the preferred way to write this would be the one calling hash-map. I'm not exactly sure why the one using #{} works. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Macro error
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 ~@ 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 can work around this by calling hash-map instead of using a map literal. #{ } reads a literal set. That works. Some examples: user= (defmacro j [ formals] `...@formals}) #'user/j user= (j 1 2 3 4) #{1 2 3 4} user= (defmacro j [ formals] `...@formals}) java.lang.ArrayIndexOutOfBoundsException: 1 java.lang.Exception: Unmatched delimiter: ) user= (defmacro j [ formals] `(hash-map ~...@formals)) #'user/j user= (j 1 2 3 4) {1 2, 3 4} My impression is that the preferred way to write this would be the one calling hash-map. I'm not exactly sure why the one using #{} works. --Steve smime.p7s 3KViewDownload --~--~-~--~~~---~--~~ 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: sorted-set-by?
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 with the interleave in sorted-map-map. I expect I'll make use of it as soon as I'm working with sorting structmaps of more than two keys. Thanks, Rick --~--~-~--~~~---~--~~ 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: Possible bug in preduce
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 me wonder whether Clojure might be better off just writing the various parallel functions using the same techniques as pmap, rather than relying on ForkJoin. Was it just me? Has anyone here had success with the parallel library? --~--~-~--~~~---~--~~ 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: SVN branches
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? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
java.lang.NoClassDefFoundError: clojure/main
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 c:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/slime. 21424 :encoding iso-latin-1-unix) java.lang.NoClassDefFoundError: clojure/main Caused by: java.lang.ClassNotFoundException: clojure.main at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Could not find the main class: clojure.main. Program will exit. Exception in thread main Process inferior-lisp exited abnormally with code 1 ;;; .emacs ;;; clojure-mode ;;; http://github.com/nablaone/slime/tree/master (add-to-list 'load-path ~/emacs-contrib/slime) ;;; http://github.com/jochu/swank-clojure/tree/master (add-to-list 'load-path ~/emacs-contrib/swank-clojure) ;;; http://github.com/jochu/clojure-mode/tree/master (add-to-list 'load-path ~/emacs-contrib/clojure-mode) (require 'slime) (autoload 'slime slime t) ;(swank-clojure-config (setq swank-clojure-jar-path ~/src/clojure/ clojure.jar)) (setq swank-clojure-jar-path ~/src/clojure/clojure.jar) ;(setq swank-clojure-extra-classpaths '(~/src/clojure-contrib/clojure- contrib.jar)) ;; (setq swank-clojure-binary clojure) ;(require 'clojure-auto) (require 'swank-clojure-autoload) (autoload 'clojure-mode clojure-mode A major mode for Clojure t) (add-to-list 'auto-mode-alist '(\\.clj$ . clojure-mode)) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Parsec style library
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 implementation of Monads in Clojure.Contrib which can be used to build this library. Having such powerful and easy way to build a parser could attract many more users to Clojure. BTW, I have seen a parser combinator file by jim in the files section, which could be used as a stepping stone. If anybody is working on similar library, please drop me a line. I have some bandwidth to spend towards such work/fun. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
possible bug with doto and function literals
(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 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: SVN branches
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 like this is the way to go. Are there any drawbacks? The performance is not as good. I'm looking into that, but it is unlikely to compete with streams on performance due to fundamental factors like allocation and indirection. Other than that, there is just the general loss of nil-punning. This was the theoretical problem that kept me from making this tradeoff earlier. I'm very much interesting in hearing from those for whom the lazy branch represents a real problem due to loss of nil punning. 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 -~--~~~~--~~--~--~---
Re: possible bug with doto and function literals
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 The inner doto form evaluates to an ArrayList containing one element: 1. Mapping the function literal across that collection ends up requesting evaluation of: (doto 1 (.add 2)) Integer has no method add, so that fails. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Bug or desired behavior: contains? doesn't seem to work on java.util.Sets.
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 IPersistentSet with Set on lines 648 and 649 of RT.java. I can make a patch if desired. If the current behavior is as-desired, I would like to understand why. Is it that some java.util.Sets have linear lookup time or something like that? Thanks, Jason --~--~-~--~~~---~--~~ 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: Bug or desired behavior: contains? doesn't seem to work on java.util.Sets.
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, would it be a good idea for the object returned by clojure.core/keys to implement java.util.Set and/or clojure.lang.IPersistentSet? --Steve smime.p7s Description: S/MIME cryptographic signature
What is defn-
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 --~--~-~--~~~---~--~~ 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: Parsec style library
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 sbkoga...@gmail.com wrote: 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 implementation of Monads in Clojure.Contrib which can be used to build this library. Having such powerful and easy way to build a parser could attract many more users to Clojure. BTW, I have seen a parser combinator file by jim in the files section, which could be used as a stepping stone. If anybody is working on similar library, please drop me a line. I have some bandwidth to spend towards such work/fun. --~--~-~--~~~---~--~~ 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: What is defn-
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 differ from defn? Source:http://www.codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_... --~--~-~--~~~---~--~~ 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: What is defn-
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: 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 -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? --~--~-~--~~~---~--~~ 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: Bug or desired behavior: contains? doesn't seem to work on java.util.Sets.
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 RT.java. I can make a patch if desired. Along those lines, would it be a good idea for the object returned by clojure.core/keys to implement java.util.Set and/or clojure.lang.IPersistentSet? --Steve Yeah, that would be great. (Or, at least, a separate keyset function). I would ask for IPersistentSet, since java.util.Sets don't play as well with Clojure (e.g., you can't call into on them, and they aren't set?s). Thanks, Jason --~--~-~--~~~---~--~~ 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: SVN branches
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 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 -~--~~~~--~~--~--~---