Re: subtractng sequence?

2009-06-03 Thread kyle smith
How about (map - seq1 seq2) ? An example or two of the desired output would be helpful. --~--~-~--~~~---~--~~ 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 No

Re: subtractng sequence?

2009-06-03 Thread Wilson MacGyver
Christophe's solution seems to work. basically I just wanted to remove (4 6 8 10) from (2 3 4 5 6 7 8 9 10) so I end up with (2 3 5 7 9) On Wed, Jun 3, 2009 at 3:27 AM, kyle smith wrote: > > How about (map - seq1 seq2) ? > > An example or two of the desired output would be helpful. > > > -

Re: subtractng sequence?

2009-06-03 Thread Laurent PETIT
If what you really want to do is treat those sequences as sets, then you can use clojure.seq/difference: 1:1 user=> (def seq1 (list 2 3 4 5 6 7 8 9 10)) #'user/seq1 1:2 user=> (def seq2 (list 4 6 8 10)) #'user/seq2 1:3 user=> (require 'clojure.set) nil 1:4 user=> (clojure.set/difference (set seq1

Re: subtractng sequence?

2009-06-03 Thread Wilson MacGyver
ah, that works too! thanks! On Wed, Jun 3, 2009 at 3:48 AM, Laurent PETIT wrote: > > If what you really want to do is treat those sequences as sets, then > you can use clojure.seq/difference: > > 1:1 user=> (def seq1 (list 2 3 4 5 6 7 8 9 10)) > #'user/seq1 > 1:2 user=> (def seq2 (list 4 6 8 10)

Re: Macros applied to entire programs

2009-06-03 Thread Christophe Grand
Rich Hickey a écrit : > > On May 13, 9:57 am, Christophe Grand wrote: > >> Mark Reid a écrit : >> >> >>> In particular, it seems converting `(+ 1 2 3)` to `(+ 1 (+ >>> 2 3))` can speed things up. >>> >> Rich, would you accept a patch to make all arities inlinable for basic >> math o

Re: Macros applied to entire programs

2009-06-03 Thread Christophe Grand
I'm sure there's something wrong with my patch (the "eval" smell) and the fact that I'm assoc-ing a closure in the metadat map. I'll rework it if you agree with the idea of this patch Christophe Grand a écrit : > Rich Hickey a écrit : > >> On May 13, 9:57 am, Christophe Grand wrote: >> >>

Re: You know you've been writing too much Clojure when...

2009-06-03 Thread Fogus
Question: You know you've been writing too much Clojure when... (dorun Question) -m --~--~-~--~~~---~--~~ 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 Not

Re: unit testing private methods?

2009-06-03 Thread stephaner
Hi everyone, I agree with Stuart, this would be very helpfull. Thank you, Stephan On Jun 3, 12:36 am, Stuart Halloway wrote: > Hi Allen, > > You could write a function that uses the clojure.contrib.with-ns/with- > ns macro to dip into the namespace being tested and return the private   > func

Re: unit testing private methods?

2009-06-03 Thread Andrew Wagner
Well, of course this is a classic situation in OO, if you think about it. Googling around may shed some interesting light on the subject. Essentially, the question is: are you sure that's what you want to do? Why not concentrate your unit tests on the public interface in such a way that the private

Re: unit testing private methods?

2009-06-03 Thread Stuart Sierra
Hi Allen, Stu, I guess my first inclination would be one of: > 1) put the unit tests in the same file using the with-test macro, or > 2) put the unit tests in a separate file, in the same namespace Stu's suggestion of with-ns would also work. But you don't even need with-ns. You can refer a pr

Fwd: Clojure at LispNYC, June 9th

2009-06-03 Thread Stuart Sierra
This is the talk that was supposed to happen on May 12. And we're going to shoot video -- email me if you can volunteer to bring a camera. -Stuart -- Forwarded message -- Join us Tuesday, may 12th from 7:00-9:00 for Stuart Sierra's presentation:     Implementing AltLaw.org in Cl

Re: unit testing private methods?

2009-06-03 Thread Christophe Grand
Stuart Sierra a écrit : > Stu's suggestion of with-ns would also work. But you don't even need > with-ns. You can refer a private function into the local namespace > like this: > > (def private-function (ns-resolve 'other-namespace 'private-function)) > And don't forget the good old @#'other

Clojure Talk @ Philly Java Users Gropu Tonight

2009-06-03 Thread Kyle R. Burton
I realize this is late notice (didn't think of it till now), there is a Clojure talk tonight at the Philadelphia Java Users Group - to attend you'll need to RSVP (see: http://phillyjug.jsync.com/ to sign up). The announcement is below. Regards, Kyle Agenda: 6:30 – 7:00 Grab a good seat, some

Re: You know you've been writing too much Clojure when...

2009-06-03 Thread Adrian Cuthbertson
> ... You know you've been writing too much Clojure when... You see a cartoon swearword @^#!>! and you think it's clojure meta-data! -Adrian. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Scoopler whispers that clojure is making a nice impression

2009-06-03 Thread bOR_
Having fun watching scoopler these days, and seeing people twitter and whatnot about clojure at javaone. http://www.scoopler.com/search/#clojure --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Re: Macros applied to entire programs

2009-06-03 Thread Christophe Grand
I attached a better patch: no eval and a more standard "inline". Christophe Grand a écrit : > I'm sure there's something wrong with my patch (the "eval" smell) and > the fact that I'm assoc-ing a closure in the metadat map. > I'll rework it if you agree with the idea of this patch > > Christophe

Re: You know you've been writing too much Clojure when...

2009-06-03 Thread Laurent PETIT
2009/6/3 Adrian Cuthbertson : > >> ... You know you've been writing too much Clojure when... > > You see a cartoon swearword @^#!>! and you think it's clojure meta-data! LOL ! :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Go

Re: subtractng sequence?

2009-06-03 Thread Daniel Lyons
On Jun 2, 2009, at 11:22 PM, Wilson MacGyver wrote: > > More newbie questions. :) > > If I have two sequences as follow: > > (2 3 4 5 6 7 8 9 10) > (4 6 8 10) > > what's the best way to subtract the 2nd sequence from the first one? > > The best I can come up with was to do (first) on 2nd sequenc

What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread CuppoJava
Hi, Is there a function that will return true iff calling seq on it's argument will not throw an error? I thought it was seq?, but (seq? [1 2 3]) returns false. -Patrick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Grou

Re: What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread J. McConnell
On Wed, Jun 3, 2009 at 12:53 PM, CuppoJava wrote: > > Is there a function that will return true iff calling seq on it's > argument will not throw an error? I thought it was seq?, but (seq? [1 > 2 3]) returns false. I was looking for this the other day as well and didn't see it. However, this mig

Re: What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread Sean Devlin
I don't know either, but you can use the following work around (defn my-seq[object] (instance? clojure.lang.Seqable object)) (my-seq []) =>true (my-seq {}) =>true (my-seq #{}) =>true (my-seq '()) =>true (my-seq :a) => false (my-seq 'a-symbol) => false Still, it would be nice to know the righ

Re: Macro Writing Helper?

2009-06-03 Thread CuppoJava
In case anybody else found defblockfn useful, here's the final version. The original didn't work when you used destructuring in the argument list of the function. (defn remove_destructuring [params] (map (fn [arg] (if (or (vector? arg) (map? arg)) (gensym) arg))

Re: Macro Writing Helper?

2009-06-03 Thread Sean Devlin
Could you throw together some live examples and unit tests? On Jun 3, 1:10 pm, CuppoJava wrote: > In case anybody else found defblockfn useful, here's the final > version. The original didn't work when you used destructuring in the > argument list of the function. > > (defn remove_destructuring

Re: Macro Writing Helper?

2009-06-03 Thread CuppoJava
Sure. Here's two plausible examples. I apologize for not providing any unit tests. I'm not quite sure what they are. I've never written one before. ;---EXAMPLE 1- (defblockfn surround_with_text [text block] (println text) (block) (println text)) (surround_with_text "surroun

Re: What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread craig mcmillan
user=> (seq? (seq [1])) true On 3 Jun 2009, at 17:53, CuppoJava wrote: > > Hi, > Is there a function that will return true iff calling seq on it's > argument will not throw an error? I thought it was seq?, but (seq? [1 > 2 3]) returns false. > > -Patrick > > --~--~-~--~~--

Re: What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread craig mcmillan
oops, sorry, that's not what u meant On 3 Jun 2009, at 17:56, craig mcmillan wrote: > user=> (seq? (seq [1])) > true > > On 3 Jun 2009, at 17:53, CuppoJava wrote: > >> >> Hi, >> Is there a function that will return true iff calling seq on it's >> argument will not throw an error? I thought it wa

Using Clojure script as Spring beans

2009-06-03 Thread Dmitriy Kopylenko
Hello Clojure gang. I am just wondering is there a way to 'magically' create Spring bean (eligible for injection) from Clojure scripts source, provided that Clojure code implements the existing Java interface? The approach similar to Spring dynamic language support: http://static.springframework.

Spring and Clojure

2009-06-03 Thread Dmitriy Kopylenko
Hello. I'm just wondering is there a way to create Clojure beans and inject them into other Spring beans (given that Clojure code implements Java interface) inside Spring ApplicationContext, similar to other dynamic langs support: http://static.springframework.org/spring/docs/2.5.x/reference/dyn

Re: What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread CuppoJava
It seems the consensus is that this function doesn't yet exist. I'll use the instance? Seqable workaround for now. Thanks for the help guys. -Patrick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. T

Re: What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread Meikel Brandmeyer
Hi, Am 03.06.2009 um 18:53 schrieb CuppoJava: Is there a function that will return true iff calling seq on it's argument will not throw an error? I thought it was seq?, but (seq? [1 2 3]) returns false. (or (coll? x) (seq? x)) should give a reasonable approximation. Sincerely Meikel smime

Re: What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread MikeM
BDFL says: http://groups.google.com/group/clojure/browse_frm/thread/3826ba3a52ec8cf7/ea899cfd965744a8?lnk=gst&q=hickey+seqable#ea899cfd965744a8 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Re: What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread Stephen C. Gilardi
On Jun 3, 2009, at 12:53 PM, CuppoJava wrote: Is there a function that will return true iff calling seq on it's argument will not throw an error? I thought it was seq?, but (seq? [1 2 3]) returns false. Such a function might be called "seqable?". As far as I know it doesn't exist currently.

Re: Spring and Clojure

2009-06-03 Thread Laurent PETIT
Hi, Provided that the beans you would like to see implemented via clojure must conform to a preexisting interface, I guess there would be no need at all to leverage to dynamic-language part of spring. Here is a recipe (out of my head, not tested) for how this would work: 1. identify the interf

Re: What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread CuppoJava
Thanks Steve. That's very useful for me. Personally I'm not too bothered by the clojure.lang.Seqable confusion. I've never had to deal directly with the Java interfaces for Clojure, and this is probably true for a lot of other users as well. The only use-case where I can see users being confused

Re: unit testing private methods?

2009-06-03 Thread Stuart Halloway
>> 2) put the unit tests in a separate file, in the same namespace This works for me, but since it won't work with the normal use/require idiom, I would like to see a standard convention evolve to make it easy to read other people's code. Stu --~--~-~--~~~---~--~

Re: Spring and Clojure

2009-06-03 Thread Dmitriy Kopylenko
Thanks Laurent. So it is indeed possible. I need to dive into Clojure to understand it better (I only started looking into Clojure few days ago). Are there any Maven plugins or Ant tasks for doing AOT compilation? Perhaps a small example of this set up (with Spring bean) would be terrific

Re: Spring and Clojure

2009-06-03 Thread Alen Ribic
This link might help. Came across this weblog titled "Practical Clojure with SWT, JUnit and Spring": http://berlinbrowndev.blogspot.com/2009/04/practical-clojure-with-swt-junit-and.html -Al On Wed, Jun 3, 2009 at 6:02 PM, Dmitriy Kopylenko wrote: > > Hello. > > I'm just wondering is there a wa

Re: "run" macro for "executable namespaces"

2009-06-03 Thread Stephen C. Gilardi
On Jun 2, 2009, at 9:38 AM, Meikel Brandmeyer wrote: Did you further think about your previous suggestion to provide the functionality of "calling" a qualified function from the command line of clojure.main? I'd like to see a (:main...) clause supported by ns to name the "main" entry point

Re: subtractng sequence?

2009-06-03 Thread Wilson MacGyver
Thank you for such a detail email on the algorithm. I'll certainly keep that in mind. This is so far been the most impressive thing I've found about clojure. the community is very friendly and helpful. You've made a newbie feel much more comfortable. On Wed, Jun 3, 2009 at 12:33 PM, Daniel Lyons

Re: Spring and Clojure

2009-06-03 Thread Luc Prefontaine
We did the reverse (using Spring directly from Clojure) without any difficulty. Never thought about creating Clojure beans however. We had already some code to bootstrap Spring from Java. Just called it from Clojure. We wanted to drop Java as much as possible but did not want to loose some of the

Where does the language end and the libraries begin?

2009-06-03 Thread ataggart
Tonight Rich made a comment (related to distributed computing) about not wanting to include things in the language that should belong in libraries. This led me to wonder (only after leaving the meeting), where does that boundary live? Is clojure.core "language" or "library"? Is it the java impl

Help with Math Question

2009-06-03 Thread CuppoJava
Hey guys, I'm really stuck on this math question, and I'm wondering if you guys know of any links that may help me. Given: f(x,y), a0, a list of numbers v. Find: g(x,y) and b0 such that: (reduce f a0 v) = (reduce g b0 (reverse v)) Thanks for your help -Patrick --~--~-~--~~-

Re: Where does the language end and the libraries begin?

2009-06-03 Thread CuppoJava
I've always considered the core part of the language to be the portion that cannot be written in the language itself. I don't think you can write an Clojure if form in Clojure. When we talk about implementing Clojure entirely in Clojure, we don't actually mean implementing the language in itself

Re: Help with Math Question

2009-06-03 Thread Mark Reid
Hi, Maybe I'm missing something but doesn't + fit the bill (or any symmetric function)? (== (reduce + 3 [1 2 3]) (reduce + 3 [3 2 1])) ;; => true In this case f = g = + and a0 = b0 for any choice of a0 and v. Regards, Mark. On Jun 4, 3:23 pm, CuppoJava wrote: > Hey guys, > I'm really stuck