Re: Clojure speed

2009-02-03 Thread Gregory Petrosyan
On Feb 2, 10:29 pm, David Nolen 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 insignific

Re: Clojure speed

2009-02-03 Thread André Thieme
On 2 Feb., 16:35, Gregory Petrosyan 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

Re: Questions about a Clojure Datalog

2009-02-03 Thread hoeck
Hi, On Feb 2, 3:42 pm, Timothy Pratley wrote: > Hi Jeffrey, > > On Feb 1, 4:50 am, Jeffrey Straszheim > 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 thei

Re: London Clojurians

2009-02-03 Thread Tom Ayerst
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 > > On

Queues

2009-02-03 Thread Konrad Hinsen
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

Re: London Clojurians

2009-02-03 Thread AndrewC.
On Feb 3, 12:54 pm, Tom Ayerst 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, suggestion

Re: rules for writing macros

2009-02-03 Thread Mark Volkmann
On Tue, Feb 3, 2009 at 7:32 AM, Konrad Hinsen wrote: > > 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

Re: A short guide on how to use NetBeans to create GUI and then use this GUI from clojure available

2009-02-03 Thread prhlava
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,

Re: Queues

2009-02-03 Thread Christophe Grand
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 y

Re: Queues

2009-02-03 Thread Lauri Pesonen
2009/2/3 Konrad Hinsen : > > 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

Re: Queues

2009-02-03 Thread Christian Vest Hansen
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.

Re: Queues

2009-02-03 Thread Christophe Grand
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

Re: rules for writing macros

2009-02-03 Thread Konrad Hinsen
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

Re: Queues

2009-02-03 Thread Konrad Hinsen
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! Ko

Re: Queues

2009-02-03 Thread Pierpaolo Bernardi
On Tue, Feb 3, 2009 at 2:35 PM, Konrad Hinsen wrote: > 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/

Example of functional relational programming in clojure

2009-02-03 Thread Jack Norimi
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:/

Re: SVN branches

2009-02-03 Thread Rich Hickey
On Feb 2, 2:27 pm, Chouser wrote: > On Mon, Feb 2, 2009 at 2:05 PM, MikeM 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, mai

Re: Example of functional relational programming in clojure

2009-02-03 Thread Rich Hickey
On Feb 3, 9:19 am, Jack Norimi 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 relati

Re: Example of functional relational programming in clojure

2009-02-03 Thread jim
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 SBC

Re: Santiago Clojurians?

2009-02-03 Thread blackdog
On Tue, 3 Feb 2009 05:47:36 -0800 (PST) peg 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 clojurian

Re: SVN branches

2009-02-03 Thread jim
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

Re: special forms vs. functions and macros

2009-02-03 Thread Christophe Grand
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 o

Re: removing duplicates from combinatorics/selections

2009-02-03 Thread kyle smith
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@googlegrou

Re: special forms vs. functions and macros

2009-02-03 Thread Chouser
On Mon, Feb 2, 2009 at 9:28 PM, Mark Volkmann 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 anoth

Re: SVN branches

2009-02-03 Thread Konrad Hinsen
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 st

Re: Amsterdam.clj

2009-02-03 Thread bOR_
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

Re: Questions about a Clojure Datalog

2009-02-03 Thread Jeffrey Straszheim
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 wrote: > Hi, > > On Feb 2, 3:42 pm, Timothy Pratley wrote: > > > > > Hi Jeffrey, > > > On Feb 1, 4:50 am, Jeffrey Straszheim > > wrote: > > > > Ho

Re: rules for writing macros

2009-02-03 Thread GS
On Feb 4, 12:01 am, Mark Volkmann 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 br

rules for writing macros

2009-02-03 Thread Mark Volkmann
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 instea

Re: rules for writing macros

2009-02-03 Thread Mark Volkmann
On Tue, Feb 3, 2009 at 8:24 AM, Konrad Hinsen 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 perha

Re: rules for writing macros

2009-02-03 Thread Chouser
On Tue, Feb 3, 2009 at 11:26 AM, Mark Volkmann 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 tha

Re: removing duplicates from combinatorics/selections

2009-02-03 Thread kyle smith
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))) --~--

Re: rules for writing macros

2009-02-03 Thread Achim Passen
Hi! Am 03.02.2009 um 17:26 schrieb Mark Volkmann: > On Tue, Feb 3, 2009 at 8:24 AM, Konrad Hinsen > 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 y

Re: Clojure speed

2009-02-03 Thread Gregory Petrosyan
On Feb 3, 12:50 pm, André Thieme 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 mor

Re: need some help getting jacob com library to work

2009-02-03 Thread greg
Thanks. It worked. I had to add the library path as well. C:\myprograms\clojure>java -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

Re: Clojure speed

2009-02-03 Thread David Nolen
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

Re: special forms vs. functions and macros

2009-02-03 Thread Telman Yusupov
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 wrote: > I believe that any non-special-form has a clojure implementation in > some .clj file, althou

Re: rules for writing macros

2009-02-03 Thread Daniel Jomphe
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 migh

Re: rules for writing macros

2009-02-03 Thread Konrad Hinsen
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

Re: A short guide on how to use NetBeans to create GUI and then use this GUI from clojure available

2009-02-03 Thread prhlava
> > 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 .setVisi

Stupid Java questions

2009-02-03 Thread Anand Patil
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/

Re: Memory Consumption of Large Sequences

2009-02-03 Thread Keith Bennett
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 to

Re: Stupid Java questions

2009-02-03 Thread Zak Wilson
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 clo

Simple math functions should support sequences

2009-02-03 Thread stuhood
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 sho

Re: Santiago Clojurians?

2009-02-03 Thread peg
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" g

Re: Simple math functions should support sequences

2009-02-03 Thread Christophe Grand
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 ha

Re: Questions about a Clojure Datalog

2009-02-03 Thread Jeffrey Straszheim
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 wrote: > hi

Re: special forms vs. functions and macros

2009-02-03 Thread Jason Wolfe
> 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?

Re: Simple math functions should support sequences

2009-02-03 Thread Stu Hood
> 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

Re: Simple math functions should support sequences

2009-02-03 Thread Christophe Grand
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 cas

Re: Got a Clojure library?

2009-02-03 Thread Perry Trolard
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, tak

Re: Stupid Java questions

2009-02-03 Thread Anand Patil
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. Che

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-03 Thread David Nolen
Haha, nope that's probably beyond the scope of what I'm trying to achieve. Spinoza just adds some object orientedness to struct-maps that's all. As far as I can tell there not much explicit control over memory consumption in Clojure. On Tue, Feb 3, 2009 at 2:56 PM, Bradbev wrote: > > On Feb 1,

read-line problems

2009-02-03 Thread Rayne
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.co

Possible bug in preduce

2009-02-03 Thread Anand Patil
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 r

Re: Possible bug in preduce

2009-02-03 Thread Rich Hickey
On Feb 3, 4:43 pm, Anand Patil 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

Re: A short guide on how to use NetBeans to create GUI and then use this GUI from clojure available

2009-02-03 Thread Timothy Pratley
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 res

Re: Clojure speed

2009-02-03 Thread Jon Harrop
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 Con

sorted-set-by?

2009-02-03 Thread R. P. Dillon
I want to create a sorted-set of structmaps that are sorted on a particular key of the structmap. The set was going to act as a queue, and initially I implemented this using a PriorityQueue with a Comparator I made using proxy. In general, I'd prefer to use pure Clojure, and sorted-set seemed lik

Re: sorted-set-by?

2009-02-03 Thread R. P. Dillon
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 cou

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-03 Thread Bradbev
On Feb 1, 5:22 pm, David Nolen 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.  Spi

Re: Clojure speed

2009-02-03 Thread Christian Vest Hansen
2009/2/3 Gregory Petrosyan : > 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?

Re: Stupid Java questions

2009-02-03 Thread Anand Patil
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

Macro error

2009-02-03 Thread Jeffrey Straszheim
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 exec

Re: Questions about a Clojure Datalog

2009-02-03 Thread hoeck
hi jeffrey, On Feb 3, 2:50 pm, Jeffrey Straszheim 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 a

Re: Macro error

2009-02-03 Thread Jeffrey Straszheim
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 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

Re: Simple math functions should support sequences

2009-02-03 Thread Stu Hood
> 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 wrote: > > Stu Hood a écrit : > > I still think the > > (< (range 10)) > > ... use c

Re: sorted-set-by?

2009-02-03 Thread Timothy Pratley
> 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

Re: read-line problems

2009-02-03 Thread Rayne
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 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

Re: Macro error

2009-02-03 Thread David Nolen
{} 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 hel

Re: Macro error

2009-02-03 Thread Jeffrey Straszheim
Thanks. On Feb 3, 7:55 pm, David Nolen 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>

Re: Macro error

2009-02-03 Thread Timothy Pratley
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 re

Re: Macro error

2009-02-03 Thread Stephen C. Gilardi
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 c

Re: Macro error

2009-02-03 Thread Jeffrey Straszheim
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" 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 i

Re: sorted-set-by?

2009-02-03 Thread R. P. Dillon
> 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 w

Re: Possible bug in preduce

2009-02-03 Thread Mark Engelberg
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 m

Re: SVN branches

2009-02-03 Thread MikeM
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? --~--~-~

java.lang.NoClassDefFoundError: clojure/main

2009-02-03 Thread Terrence Brannon
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-ser

Parsec style library

2009-02-03 Thread sbkogs
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 implementati

possible bug with doto and function literals

2009-02-03 Thread kyle smith
(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

Re: SVN branches

2009-02-03 Thread Rich Hickey
On Feb 3, 9:57 pm, MikeM 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

Re: possible bug with doto and function literals

2009-02-03 Thread Stephen C. Gilardi
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 T

Re: Bug or desired behavior: "contains?" doesn't seem to work on java.util.Sets.

2009-02-03 Thread Jason Wolfe
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 rep

Re: Bug or desired behavior: "contains?" doesn't seem to work on java.util.Sets.

2009-02-03 Thread Stephen C. Gilardi
On Feb 3, 2009, at 10:44 PM, Jason Wolfe wrote: user> (contains? (.keySet {:a :b}) :a) false It seems that all that's required to make "contains?" work on general Sets is to replace "IPersistentSet" with "Set" on lines 648 and 649 of RT.java. I can make a patch if desired. Along those lines

What is "defn-"

2009-02-03 Thread Terrence Brannon
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 --~--~-~--~~~---~--~

Re: Parsec style library

2009-02-03 Thread Tom Faulhaber
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 wrote: > Parsec

Re: What is "defn-"

2009-02-03 Thread Tom Faulhaber
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 wrote: > What is the significance of the dash after defn? How does it differ > from defn?

Re: What is "defn-"

2009-02-03 Thread Kevin Downey
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 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_i

Re: Bug or desired behavior: "contains?" doesn't seem to work on java.util.Sets.

2009-02-03 Thread Jason Wolfe
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

Re: SVN branches

2009-02-03 Thread Mark Engelberg
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