Re: Improving the documentation

2009-08-18 Thread Seth

I'm also very interested in a more public wiki for Clojure and would
help maintain it.

Seth

On Aug 17, 11:39 am, Ollie Saunders  wrote:
> OK, so given all the support this idea got and the amount of material
> we already have. Who should I talk to about getting access to the
> clojure.org wiki so more centralised contribution can start there?
>
> 2009/8/17 Mark Volkmann :
>
>
>
>
>
> > On Sun, Aug 16, 2009 at 8:27 PM, Chas Emerick wrote:
>
> >>> On Aug 16, 2009, at 8:52 PM, Mark Volkmann wrote:
>
>  I took a shot at it at
> http://ociweb.com/mark/clojure/ClojureCategorized.html. Suggestions
>  for changes to this are welcomed. Also check out
> http://ociweb.com/mark/clojure/article.html.
>
> >> Indeed, Mark, there's a ton of great material there -- I know I
> >> benefitted from it a number of times.  I hope you'll consider
> >> contributing all or parts of it to whatever central resource develops.
>
> > Consider it contributed! Everything I've written about Clojure is
> > freely available for inclusion in some central repository of Clojure
> > documentation.
>
> > --
> > 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
Note that posts from new members are moderated - please be patient with your 
first post.
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
-~--~~~~--~~--~--~---



clojure article in french magazine

2009-08-18 Thread rb

Hey,

I was looking computer magazines and I had the good surprise to see
clojure mentioned on the cover of Programmez, a french magazine.
The article is titled 'Cloure, a Lisp for the JVM", and seems positive
(eg, it says "Clojure (...) est génial" meaning "Clojure is great"):
http://www.programmez.com/magazine_articles.php?titre=Clojure, un Lisp
pour la JVM&id_article=1251&magazine=121

Cheers

Raph

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Improving the documentation

2009-08-18 Thread John Newman
I believe http://en.wikibooks.org/wiki/Clojure_Programming is the intended
central location for contributing documentation.  I've heard complaints
about it's openness though.

Is it a pain to try to contribute there?

On Tue, Aug 18, 2009 at 4:52 AM, Seth  wrote:

>
> I'm also very interested in a more public wiki for Clojure and would
> help maintain it.
>
> Seth
>
> On Aug 17, 11:39 am, Ollie Saunders  wrote:
> > OK, so given all the support this idea got and the amount of material
> > we already have. Who should I talk to about getting access to the
> > clojure.org wiki so more centralised contribution can start there?
> >
> > 2009/8/17 Mark Volkmann :
> >
> >
> >
> >
> >
> > > On Sun, Aug 16, 2009 at 8:27 PM, Chas Emerick
> wrote:
> >
> > >>> On Aug 16, 2009, at 8:52 PM, Mark Volkmann wrote:
> >
> >  I took a shot at it at
> > http://ociweb.com/mark/clojure/ClojureCategorized.html. Suggestions
> >  for changes to this are welcomed. Also check out
> > http://ociweb.com/mark/clojure/article.html.
> >
> > >> Indeed, Mark, there's a ton of great material there -- I know I
> > >> benefitted from it a number of times.  I hope you'll consider
> > >> contributing all or parts of it to whatever central resource develops.
> >
> > > Consider it contributed! Everything I've written about Clojure is
> > > freely available for inclusion in some central repository of Clojure
> > > documentation.
> >
> > > --
> > > R. Mark Volkmann
> > > Object Computing, Inc.
> >
>


-- 
John

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Improving the documentation

2009-08-18 Thread Harold Ancell

At 09:18 AM 8/18/2009, John Newman wrote:
>I believe 
>http://en.wikibooks.org/wiki/Clojure_Programming
> is the intended central location for contributing documentation.

One issue with that site is its limited scope, "Wikibooks
is a Wikimedia community for creating a free library of
educational textbooks"  

>I've heard complaints about it's openness though.
>
>Is it a pain to try to contribute there?

It's part of the Wikimedia Foundation, which includes
Wikipedia, and it's as easy to work with as that but I assume
with different politics than Wikipedia.

When I stumbled on the clojure-1.0.0.jar problem I updated
the appropriate page there in a few minutes including
registering an account, which isn't required:

http://en.wikibooks.org/w/index.php?title=Clojure_Programming/Getting_Started&diff=prev&oldid=1582045

or http://tinyurl.com/p9r7zd

- Harold




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Improving the documentation

2009-08-18 Thread Meikel Brandmeyer

Hi,

On Aug 18, 4:50 pm, Harold Ancell  wrote:

> When I stumbled on the clojure-1.0.0.jar problem I updated
> the appropriate page there in a few minutes including
> registering an account, which isn't required:

The problem with the wikibook site is, that they
came up with some moronic "quality management".
Only special "editors" can release changes to a page.
However back when this was introduced, no one from
the Clojure community was an "editor". Seeing the
updates was at least hard and it was not obvious
(only a small note at the top) that one was looking
at old content. So they basically locked out the
community. (Here the "moronic" part comes in: a
non-member of the community has to judge the
quality of the content... How is he supposed to know?
And when does he review the changes? Once every
three months?)

But maybe we now have editors or the quality things
changed, in that case it would be worth to have a look
again.

Sincerely
Meikel

PS: After looking at the front-page: Top right of the
page there is "Sighted page (view draft)". Comparing
the draft with the page shows changes. Bleh.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Pure-functional N-body benchmark implementation

2009-08-18 Thread Brad Beveridge





On 2009-08-17, at 8:58 PM, FFT  wrote:

> On Mon, Aug 17, 2009 at 9:25 AM, Bradbev  
> wrote:
>>
>> On Aug 17, 1:32 am, Nicolas Oury  wrote:
>>> I was referring to the rules of the benchmark game. When you  
>>> benchmark
>>> language, using another language is not fair.
>>>
>>> If you were to do your own program, of course you could use Java.
>>> However, in the particular circumstance, it is a bit annoying to use
>>> Java just to create a data structure type.
>>>
>> Ah, that makes more sense re the "cheating" then.  Your insight for
>> array range check elimination got me thinking - why can't the  
>> accessor
>> macros (posx, etc) that use aset/aget have their ranges eliminated by
>> the JVM?  After all, it should be a simple constant fold.  I found
>> another 2-3x speed up by coercing the indexes with (int x), ie
>> (defmacro mass [p] `(double (aget ~p (int 0
>
> I'm not seeing this. Maybe you are running this on "-client"?
I'm running Java 1.5 32bit on OS X 10.5 with -server.
>
>> I don't have the Java version running on my machine, but I saw
>> runtimes go from 833ms to 295ms for 10 iterations, a 2.8x speed
>> up, which should put the "no cheating" version on the same standing  
>> as
>> the Java implementation.
>
> You can't get a consistent timing for anything less than 1-10M  
> iterations here.
Why do you think that?  Everything I've read says that hotspot kicks  
in at 10,000, and I always do a warmup run.
I see consistent enough timings, within 50ms each run. When coerced  
ints gives an immediate 3x speedup something is happening. What JVM  
are you running & what settings?  I'll compile the java version soon  
so I can do a direct compare on a single machine. I take it that your  
setup is showing clojure 3x slower than the java version?

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
Note that posts from new members are moderated - please be patient with your 
first post.
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: Idiom for array slicing

2009-08-18 Thread John Harrop
On Mon, Aug 17, 2009 at 11:35 PM, Mark Triggs wrote:

>
> Thanks all.  So combining a few suggested ideas:
>
>  (defn slice
>  "Return the items in coll at index positions keys.
>
>   (slice [0 4 6] \"abcdefg\") => (\\a \\e \\g)"
>[keys coll]
>(let [max-idx (apply max keys)
>  keyset (set keys)]
>  (map second
>   (filter (fn [[idx _]] (keyset idx))
>   (take-while (fn [[idx _]] (<= idx max-idx))
>   (indexed coll))
>
> This version has the advantage of working on infinite sequences and not
> hanging onto the head.  This works as expected:
>
>  (slice [200 201] (repeatedly #(int-array 102400)))
>
> without blowing up the stack or throwing OutOfMemory (on my JVM).


So does the very simple

(defn slice [indices coll]
  (map #(nth coll %) indices))

though that doesn't use keys rather than position with maps.

(defn slice [indices coll]
  (map #(get coll %) indices))

does, but works for maps and vectors but not lists. It does work for
strings.

(defn slice [indices coll]
  (map #(get (indexed coll) %) indices))

should if (indexed coll) has the semantics it seems it should from what
you've posted, but the indexed function is apparently bleeding-edge because
my copy of clojure 1.0 doesn't have anything by that name in it.

(defn slice [coll & indices]
  (map #(nth coll %) indices))

has the same argument syntax as suggested originally by Mark.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Idiom for array slicing

2009-08-18 Thread CuppoJava

The most straight-forward answer I would have given is also:
(defn slice [indices coll]
  (map #(nth coll %) indices))

Is there some disadvantage with this approach that I'm not seeing?
  -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Improving the documentation

2009-08-18 Thread Harold Ancell

At 10:20 AM 8/18/2009, Meikel Brandmeyer wrote:

>Hi,

Greetings and salutations.

>On Aug 18, 4:50 pm, Harold Ancell  wrote:
>
>> When I stumbled on the clojure-1.0.0.jar problem I updated
>> the appropriate page there in a few minutes including
>> registering an account, which isn't required:
>
>The problem with the wikibook site is, that they
>came up with some moronic "quality management"

Well, this seems to make sense for a wiki that's dedicated to
creating textbooks, e.g. see this page which covers the
reviewing process:

http://en.wikibooks.org/wiki/Help:Revision_review

  Wikibooks uses the FlaggedRevs extension (also known as
  flagged revisions or stable revisions) so that editors and
  reviewers can review page revisions for quality. Reviewed
  pages are said to be stable.

  This feature allows readers who are not logged in, or have
  set their stability preferences accordingly, to be served
  with stable versions for pages where they exist. This
  makes low activity books more resistant to vandalism.

  Regular contributors are automatically given editor status
  by the software. Editors automatically review pages at the
  lowest setting (called sighting a page) when they save, so
  active books will usually have contributions by
  non-editors added shortly after they are committed.

This underlines the point that Wikibooks is not ideal for a general
purpose Clojure wiki.

- Harold


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Idiom for array slicing

2009-08-18 Thread Andrew Baine


If coll has O(n) access and we impose the restriction that indices is
increasing (or sort it up front), we can do better than this by only
doing one pass through coll.

On Aug 18, 10:46 am, CuppoJava  wrote:
> The most straight-forward answer I would have given is also:
> (defn slice [indices coll]
>   (map #(nth coll %) indices))
>
> Is there some disadvantage with this approach that I'm not seeing?
>   -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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 leak in vec (and maybe persistent!)?

2009-08-18 Thread Andy Fingerhut

On Aug 17, 3:51 am, Christophe Grand  wrote:
> On Sat, Aug 15, 2009 at 4:23 PM, Andy Fingerhut <
>
> andy_finger...@alum.wustl.edu> wrote:
> > Not to say this ought to be done, but would it be possible to have no
> > 'edit' field *at all* for persistent data structures (not even a null
> > reference), and only an edit field at the "root" data structure of a
> > transient (none of the children would have one, only the root), and
> > preserve O(1) transient/persistent! calls?
>
> The problem is when you have several calls to transient/persistent! You have
> to be able to tell transient nodes owned by the current transient processing
> from older transient nodes left in place by previous calls to persistent!.
> (and these transient nodes can be shared!)
> One could have a set of nodes owned by the current transient but it would
> incur some bookkeeping to not retain a reference to a reclaimable node.
> I don't know if there's another way to do that.

But if there is only a single non-null edit reference in the "root
node", then the non-root nodes don't really need a reference to the
thread that is currently mutating the data structure, right?

And after a call to peristent!, a different thread could later call
transient on it, and want to make its own modified version.  So any
non-null edit references anywhere in the persistent data structure are
useless, aren't they?

>
> But even if edit remains in all of them, I'm wondering whether it
>
> > could be maintained that only the root node has a non-null edit field,
> > while that data structure is transient.
>
> Why do you focus on these AtomicReferences? If you contrast pre-transient
> vectors and actual vectors you'll see that the overhead due to instance of
> PersistentVector$Node is far more important.
>
> Christophe

I only focus my questions on AtomicReferences because I noticed them.
I haven't yet taken the time to read through all the source code
related to the implementation of transient data structures.

It just seems to me that a persistent data structure doesn't _need_ a
reference to the thread that created it.  It is now immutable, and it
and all of its "sub-parts" always will be, until and unless they are
deallocated by garbage collection.

Thanks,
Andy
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Pure-functional N-body benchmark implementation

2009-08-18 Thread FFT

On Mon, Aug 17, 2009 at 9:25 AM, Bradbev wrote:
>
> On Aug 17, 1:32 am, Nicolas Oury  wrote:
>> I was referring to the rules of the benchmark game. When you benchmark
>> language, using another language is not fair.
>>
>> If you were to do your own program, of course you could use Java.
>> However, in the particular circumstance, it is a bit annoying to use
>> Java just to create a data structure type.
>>
> Ah, that makes more sense re the "cheating" then.  Your insight for
> array range check elimination got me thinking - why can't the accessor
> macros (posx, etc) that use aset/aget have their ranges eliminated by
> the JVM?  After all, it should be a simple constant fold.  I found
> another 2-3x speed up by coercing the indexes with (int x), ie
> (defmacro mass [p] `(double (aget ~p (int 0

I'm not seeing this. Maybe you are running this on "-client"?

> I don't have the Java version running on my machine, but I saw
> runtimes go from 833ms to 295ms for 10 iterations, a 2.8x speed
> up, which should put the "no cheating" version on the same standing as
> the Java implementation.

You can't get a consistent timing for anything less than 1-10M iterations here.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: JDBC-ODBC Bridge

2009-08-18 Thread Sean Devlin

I believe your result set is closed by the time you execute your
statement. If you use (class (sel)) you will notice it is a resultset.

Start by executed your desired s-exp inside the macro at the REPL.
Then I would
use a let/map combination to turn it into a fn.

Hope this helps,
Sean

On Aug 18, 2:28 pm, shane  wrote:
> I am trying to use the JDBC-ODBC with the following code:
>
> (use '[clojure.contrib.sql])
>
> (def db {:classname "sun.jdbc.odbc.JdbcOdbcDriver"
>          :subprotocol "odbc"
>          :subname "jdbc:odbc:D2D1"
>          :username "ERASUSR"
>          :password "REPORTS"})
>
> (defn sel []
>   (with-connection db
>     (with-query-results rs ["SELECT * FROM
> DB2PROD.ED0CDT_CYCLE_DATES"]
>       (map :CYCLE_IND rs
>
> When I execute (first (sel)) I receive the following error:
>
> java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source
> name not found and no default driver specified (NO_SOURCE_FILE:0)
>   [Thrown class clojure.lang.Compiler$CompilerException]
>
> I use this dsn (D2P1) in a number of other programs/languages with no
> problem. Can anyone spot something wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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
-~--~~~~--~~--~--~---



JDBC-ODBC Bridge

2009-08-18 Thread shane

I am trying to use the JDBC-ODBC with the following code:

(use '[clojure.contrib.sql])

(def db {:classname "sun.jdbc.odbc.JdbcOdbcDriver"
 :subprotocol "odbc"
 :subname "jdbc:odbc:D2D1"
 :username "ERASUSR"
 :password "REPORTS"})

(defn sel []
  (with-connection db
(with-query-results rs ["SELECT * FROM
DB2PROD.ED0CDT_CYCLE_DATES"]
  (map :CYCLE_IND rs

When I execute (first (sel)) I receive the following error:

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source
name not found and no default driver specified (NO_SOURCE_FILE:0)
  [Thrown class clojure.lang.Compiler$CompilerException]

I use this dsn (D2P1) in a number of other programs/languages with no
problem. Can anyone spot something wrong?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: JDBC-ODBC Bridge

2009-08-18 Thread shane

entering "(with-connection db)" on the repl yields the same error,
making me think it's still something wrong with how I am going about
connection to the dsn.

On Aug 18, 3:07 pm, Sean Devlin  wrote:
> I believe your result set is closed by the time you execute your
> statement. If you use (class (sel)) you will notice it is a resultset.
>
> Start by executed your desired s-exp inside the macro at the REPL.
> Then I would
> use a let/map combination to turn it into a fn.
>
> Hope this helps,
> Sean
>
> On Aug 18, 2:28 pm, shane  wrote:
>
>
>
> > I am trying to use the JDBC-ODBC with the following code:
>
> > (use '[clojure.contrib.sql])
>
> > (def db {:classname "sun.jdbc.odbc.JdbcOdbcDriver"
> >          :subprotocol "odbc"
> >          :subname "jdbc:odbc:D2D1"
> >          :username "ERASUSR"
> >          :password "REPORTS"})
>
> > (defn sel []
> >   (with-connection db
> >     (with-query-results rs ["SELECT * FROM
> > DB2PROD.ED0CDT_CYCLE_DATES"]
> >       (map :CYCLE_IND rs
>
> > When I execute (first (sel)) I receive the following error:
>
> > java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source
> > name not found and no default driver specified (NO_SOURCE_FILE:0)
> >   [Thrown class clojure.lang.Compiler$CompilerException]
>
> > I use this dsn (D2P1) in a number of other programs/languages with no
> > problem. Can anyone spot something wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Pure-functional N-body benchmark implementation

2009-08-18 Thread Aaron Cohen

On Tue, Aug 18, 2009 at 11:28 AM, Brad
Beveridge wrote:
>
> On 2009-08-17, at 8:58 PM, FFT  wrote:
>
>> On Mon, Aug 17, 2009 at 9:25 AM, Bradbev
>> wrote:
>>>
>>> Ah, that makes more sense re the "cheating" then.  Your insight for
>>> array range check elimination got me thinking - why can't the
>>> accessor
>>> macros (posx, etc) that use aset/aget have their ranges eliminated by
>>> the JVM?  After all, it should be a simple constant fold.  I found
>>> another 2-3x speed up by coercing the indexes with (int x), ie
>>> (defmacro mass [p] `(double (aget ~p (int 0
>>
>> I'm not seeing this. Maybe you are running this on "-client"?
> I'm running Java 1.5 32bit on OS X 10.5 with -server.
>>
>>> I don't have the Java version running on my machine, but I saw
>>> runtimes go from 833ms to 295ms for 10 iterations, a 2.8x speed
>>> up, which should put the "no cheating" version on the same standing
>>> as
>>> the Java implementation.
>>
>> You can't get a consistent timing for anything less than 1-10M
>> iterations here.
> Why do you think that?  Everything I've read says that hotspot kicks
> in at 10,000, and I always do a warmup run.
> I see consistent enough timings, within 50ms each run. When coerced
> ints gives an immediate 3x speedup something is happening. What JVM
> are you running & what settings?  I'll compile the java version soon
> so I can do a direct compare on a single machine. I take it that your
> setup is showing clojure 3x slower than the java version?
>
> Brad
>

I don't see much of any difference here from those coercions either.
What clojure version are you using?
-- Aaron

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: JDBC-ODBC Bridge

2009-08-18 Thread Michael Wood

2009/8/18 shane :
>
> I am trying to use the JDBC-ODBC with the following code:
>
> (use '[clojure.contrib.sql])
>
> (def db {:classname "sun.jdbc.odbc.JdbcOdbcDriver"
>         :subprotocol "odbc"
>         :subname "jdbc:odbc:D2D1"
[...]
> I use this dsn (D2P1) in a number of other programs/languages with no
> problem. Can anyone spot something wrong?

I hesitate to mention this, since it might just be a typo in your
message, but you have "D2D1" in the connection string and not "D2P1"
as you say you are using successfully elsewhere.

-- 
Michael Wood 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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
-~--~~~~--~~--~--~---



Inheriting Clojure special variables in child threads

2009-08-18 Thread Constantine Vetoshev

Clojure's binding form only establishes vars with dynamic extent
limited to the current thread. This makes a lot of sense. However, I
have a use case where I'd like it to establish the dynamic extent in a
way which affects the current thread and all threads started within
the current thread.

Suppose, for example, that I want to launch a couple of different
instances of the embedded Jetty server. I have no control over what
threads Jetty starts and stops, but I want to make sure that my code
running inside that entire instance has a specific "global" variable
binding:

(declare *x*)

(binding* [*x* 3]
  (start-jetty :port 8001 :my-servlet servlet-implemented-in-clojure))

(binding* [*x* 5]
  (start-jetty :port 8002 :my-servlet servlet-implemented-in-clojure))

That way, code I wrote to run inside of Jetty can blindly refer to
*x*, and the first instance would then use the value 3, and the second
instance would use the value 5. Basically, I'd like a binding* macro
to establish a dynamic binding visible only in thread hierarchies
started in its scope.

Aside from the utility in my use case, I think a binding* macro like
this would improve the current concurrency situation, where any thread
can alter a def'ed global variable for any other thread. If the thread
starts in a binding*, it would, at worst, affect itself and its
children. Seems useful.

Any comments? Is this possible? How difficult would this be to
implement?

Best regards,
Constantine Vetoshev

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Pure-functional N-body benchmark implementation

2009-08-18 Thread Aaron Cohen

On Tue, Aug 18, 2009 at 3:32 PM, Aaron Cohen wrote:
> On Tue, Aug 18, 2009 at 11:28 AM, Brad
> Beveridge wrote:
>>
>> On 2009-08-17, at 8:58 PM, FFT  wrote:
>>
>>> On Mon, Aug 17, 2009 at 9:25 AM, Bradbev
>>> wrote:

 Ah, that makes more sense re the "cheating" then.  Your insight for
 array range check elimination got me thinking - why can't the
 accessor
 macros (posx, etc) that use aset/aget have their ranges eliminated by
 the JVM?  After all, it should be a simple constant fold.  I found
 another 2-3x speed up by coercing the indexes with (int x), ie
 (defmacro mass [p] `(double (aget ~p (int 0
>>>
>>> I'm not seeing this. Maybe you are running this on "-client"?
>> I'm running Java 1.5 32bit on OS X 10.5 with -server.
>>>
 I don't have the Java version running on my machine, but I saw
 runtimes go from 833ms to 295ms for 10 iterations, a 2.8x speed
 up, which should put the "no cheating" version on the same standing
 as
 the Java implementation.
>>>
>>> You can't get a consistent timing for anything less than 1-10M
>>> iterations here.
>> Why do you think that?  Everything I've read says that hotspot kicks
>> in at 10,000, and I always do a warmup run.
>> I see consistent enough timings, within 50ms each run. When coerced
>> ints gives an immediate 3x speedup something is happening. What JVM
>> are you running & what settings?  I'll compile the java version soon
>> so I can do a direct compare on a single machine. I take it that your
>> setup is showing clojure 3x slower than the java version?
>>
>> Brad
>>
>
> I don't see much of any difference here from those coercions either.
> What clojure version are you using?
> -- Aaron
>

I reworked advance! a little bit and while it didn't have much
performance impact, I find this version a little clearer:

(defmacro doarray
  "Executes an expression for each element of array a (presumably for
its side-effects), using an index named idx,
   beginning with element 'start'"
  [a idx start expr]
  `(let [a# ~a end# (int (alength a#))]
 (loop  [~idx (int ~start)]
   (if (< ~idx end#)
 (do
 ~expr
 (recur (unchecked-inc ~idx)))

(defn advance! [#^"[Ljava.lang.Object;" bodies delta-t]
  (let [delta-t (double delta-t)]
(doarray bodies i1 0
(doarray bodies i2 (unchecked-inc i1)
(let [#^doubles b1 (aget bodies i1)
#^doubles b2 (aget bodies i2)
delta-posx (- (posx b1) (posx b2))
delta-posy (- (posy b1) (posy b2))
delta-posz (- (posz b1) (posz b2))
dist-squared (+ (+ (* delta-posx delta-posx)
   (* delta-posy delta-posy))
(* delta-posz delta-posz))
dist (Math/sqrt dist-squared)
mag (/ delta-t (* dist-squared dist))
b1-scale (* (- mag) (mass b2))
dv1x (* delta-posx b1-scale)
dv1y (* delta-posy b1-scale)
dv1z (* delta-posz b1-scale)
b2-scale (* mag (mass b1))
dv2x (* delta-posx b2-scale)
dv2y (* delta-posy b2-scale)
dv2z (* delta-posz b2-scale)]
(add-to-vel! b1 dv1x dv1y dv1z)
(add-to-vel! b2 dv2x dv2y dv2z
(doarray bodies i 0
(let [#^doubles b (aget bodies i)]
  (set-posx! b (+ (posx b) (* (velx b) delta-t)))
  (set-posy! b (+ (posy b) (* (vely b) delta-t)))
  (set-posz! b (+ (posz b) (* (velz b) delta-t)))

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Idiom for array slicing

2009-08-18 Thread Mark Triggs

Yep, this was my thinking too.  Maybe it doesn't matter, but I'm always
a little reluctant to make those sort of compromises when writing
general-purpose utility functions.

Mark


Andrew Baine  writes:

> If coll has O(n) access and we impose the restriction that indices is
> increasing (or sort it up front), we can do better than this by only
> doing one pass through coll.
>
> On Aug 18, 10:46 am, CuppoJava  wrote:
>> The most straight-forward answer I would have given is also:
>> (defn slice [indices coll]
>>   (map #(nth coll %) indices))
>>
>> Is there some disadvantage with this approach that I'm not seeing?

-- 
Mark Triggs


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: JDBC-ODBC Bridge

2009-08-18 Thread Meikel Brandmeyer

Hi,

Am 18.08.2009 um 20:28 schrieb shane:


(defn sel []
 (with-connection db
   (with-query-results rs ["SELECT * FROM
DB2PROD.ED0CDT_CYCLE_DATES"]
 (map :CYCLE_IND rs


Michael's suggestion about the typo is plausible.
Should that fix the connection problem, you will
almost surely want to wrap the map into a doall.
Otherwise the lazy seq gets passed outside the
with-connection and the connection will be closed,
when realising the seq. Sean is also on the right
track here.

Sincerely
Meikel
 

smime.p7s
Description: S/MIME cryptographic signature


Dan Weinreb Google Tech Talk

2009-08-18 Thread Tom Emerson

http://www.youtube.com/watch?v=xquJvmHF3S8

Dan Weinreb gave a great talk at Google entitled "Lisp for
High-Performance Transaction Processing" on Monday, where he talks
about the use of Common Lisp at ITA Software. The last 10 - 15 minutes
of the talk he discusses the future of Lisp: Common Lisp, Scheme, and
Clojure. Definitely worth watching.

-tree

-- 
Tom Emerson
tremer...@gmail.com
http://treerex.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Inheriting Clojure special variables in child threads

2009-08-18 Thread Meikel Brandmeyer

Hi,

Am 18.08.2009 um 21:40 schrieb Constantine Vetoshev:


(binding* [*x* 3]
 (start-jetty :port 8001 :my-servlet servlet-implemented-in-clojure))


There are two Assembla tickets, which go into that direction:
http://www.assembla.com/spaces/clojure/tickets/169-thread-local-bindings-interface
http://www.assembla.com/spaces/clojure/tickets/170-bound-fn-macro

I'm not familiar with jetty, so take with a grain of salt.

I could imagine that servlet-implemented-in-clojure is some function.  
Then (using the above patches) it could be made binding aware using  
the boundfn* function:


(binding [*x* 3]
  (start-jetty :port 8001 :my-servlet (boundfn* servlet- 
implemented-in-clojure)))


However, when ever you spawn a thread or when something running  
possibly delayed, you have to take similar actions. I'm not sure how  
easy it is do this automatically.


This issues are not yet included in Clojure officially. But the  
tickets suggests, that the issue is being addressed soon.


As for the re-def'ing: This is a non issue. Code which gets problems  
because of this, probably deserves it. The only legitimate use of a re- 
defing is during experimentation in the Repl. Production code should  
never ever have a def not at the toplevel. (The only exceptions are  
closing over a let-local for information hiding (which is no redefing)  
and macros expanding into a def (eg. defn, etc.))


Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Daniel Weinreb on Clojure

2009-08-18 Thread Rock

Daniel Weinreb (of Common Lisp fame) talks about Clojure in the second
part of this Google Tech Talk:

http://www.youtube.com/watch?v=xquJvmHF3S8


Rock

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Idiom for array slicing

2009-08-18 Thread CuppoJava

Ah... and the function that I called "split" should really be called
"slice".
And "lazy_reduce" should really be called "lazy-reduce" i keep on
forgetting to use hypens instead of underscores.
  -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Infinite Sequence of Coin Flips

2009-08-18 Thread CuppoJava

"repeatedly" is the function that you're looking for in the first
question.

And = should work I think:
 (= [1 2 3] [1 2 3]) returns true.

Hope that helps
  -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Idiom for array slicing

2009-08-18 Thread CuppoJava

I see. Thanks for explaining.

If speed is an issue, and if you can assume that indices are properly
sorted in ascending order, I believe this looks like a lazy-reduce
problem. Clojure has no lazy-reduce (or does it?) so I've written my
own:

(defn lazy_reduce [f val coll]
  (lazy-seq
(if (seq coll)
  (let [val (f val (first coll))]
(cons val (lazy_reduce f val (rest coll)))

(defn split [indices coll]
  (map first
   (lazy_reduce nthnext coll
 (map - indices (cons 0 indices)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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
-~--~~~~--~~--~--~---



Infinite Sequence of Coin Flips

2009-08-18 Thread tmountain

Hi, I was wondering if there's a more idiomatic way to do the
following:

(defn flip-coin []
  (int (rand 2)))

(let [coin-flips (for [x (repeat true)] (flip-coin))]
  

Basically I want to generate an infinite lazy sequence based on the
output of a given function with zero or more arguments. Also, this is
a side question, but does anybody know if there's a faster (or better)
way to compare two lazy sequences than the following?

(defn seq-identical? [seq1 seq2]
  (zero? (compare (vec seq1) (vec seq2

Thanks,
Travis
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Infinite Sequence of Coin Flips

2009-08-18 Thread Tayssir John Gabbour

On Aug 19, 1:08 am, tmountain  wrote:
> Hi, I was wondering if there's a more idiomatic way to do the
> following:
>
> (defn flip-coin []
>   (int (rand 2)))

To add to CuppoJava's advice, (rand-int 2) is a synonym of (int (rand
2)).


All the best,
Tayssir

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Improving the documentation

2009-08-18 Thread Ollie Saunders

Status: I've applied for membership on the dev list, citing this
thread so this can be discussed with the major contributors.

2009/8/18 Harold Ancell :
>
> At 10:20 AM 8/18/2009, Meikel Brandmeyer wrote:
>
>>Hi,
>
> Greetings and salutations.
>
>>On Aug 18, 4:50 pm, Harold Ancell  wrote:
>>
>>> When I stumbled on the clojure-1.0.0.jar problem I updated
>>> the appropriate page there in a few minutes including
>>> registering an account, which isn't required:
>>
>>The problem with the wikibook site is, that they
>>came up with some moronic "quality management"
>
> Well, this seems to make sense for a wiki that's dedicated to
> creating textbooks, e.g. see this page which covers the
> reviewing process:
>
> http://en.wikibooks.org/wiki/Help:Revision_review
>
>  Wikibooks uses the FlaggedRevs extension (also known as
>  flagged revisions or stable revisions) so that editors and
>  reviewers can review page revisions for quality. Reviewed
>  pages are said to be stable.
>
>  This feature allows readers who are not logged in, or have
>  set their stability preferences accordingly, to be served
>  with stable versions for pages where they exist. This
>  makes low activity books more resistant to vandalism.
>
>  Regular contributors are automatically given editor status
>  by the software. Editors automatically review pages at the
>  lowest setting (called sighting a page) when they save, so
>  active books will usually have contributions by
>  non-editors added shortly after they are committed.
>
> This underlines the point that Wikibooks is not ideal for a general
> purpose Clojure wiki.
>
>                                        - Harold
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Idiom for array slicing

2009-08-18 Thread Mark Triggs

That works nicely, even for infinite sequences, but appears to hang on
to the head:

  user=> (split [2000 2001] (repeatedly #(int-array 102400)))
  java.lang.OutOfMemoryError: Java heap space

The map/nth variant has this same problem, unfortunately.  My original
version works around these issues at the expense of being longer and
uglier ;o)

Mark


CuppoJava  writes:

> I see. Thanks for explaining.
>
> If speed is an issue, and if you can assume that indices are properly
> sorted in ascending order, I believe this looks like a lazy-reduce
> problem. Clojure has no lazy-reduce (or does it?) so I've written my
> own:
>
> (defn lazy_reduce [f val coll]
>   (lazy-seq
> (if (seq coll)
>   (let [val (f val (first coll))]
> (cons val (lazy_reduce f val (rest coll)))
>
> (defn split [indices coll]
>   (map first
>(lazy_reduce nthnext coll
>  (map - indices (cons 0 indices)

-- 
Mark Triggs


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Infinite Sequence of Coin Flips

2009-08-18 Thread tmountain

> And = should work I think:
>  (= [1 2 3] [1 2 3]) returns true.

Oh man... now I feel stupid. Thanks for the help!

Travis

On Aug 18, 7:17 pm, CuppoJava  wrote:
> "repeatedly" is the function that you're looking for in the first
> question.
>
> And = should work I think:
>  (= [1 2 3] [1 2 3]) returns true.
>
> Hope that helps
>   -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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
-~--~~~~--~~--~--~---



Quirk with filter

2009-08-18 Thread Sean Devlin

Hello Clojurians,
I commonly use a set in my filtering operations, like the example
below.

user=> (filter #{\a \e \i \o \u} "The quick brown fox jumped over the
lazy dog")
(\e \u \i \o \o \u \e \o \e \e \a \o)

Today I found myself using the following code

user=> (filter #{false} [true false false true])
()

Obviously, this is not what I intended.  The best I could do was the
following

user=> (filter (comp not nil? #{false}) [true false false true])
(false false)

Does anyone else have any other ideas?

Sean
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Idiom for array slicing

2009-08-18 Thread Rock

What if someone wanted to slice a multi-dimensional vector (vector of
vectors of vectors ...) or even just an ordinary matrix (vector of
vectors).

Is there a way to extend this beyond an ordinary one-dimensional
vector?

Rock


On Aug 18, 3:17 am, Mark Triggs  wrote:
> Hi all,
>
> Is there an idiom for what I'm doing below, or does a function already
> exist?
>
> (let [vowels (slice "abcdefghijklmnopqrstuvwxyz"
>                      0 4 8 14 20)]
>   vowels)
>   => (\a \e \i \o \u)
>
> A possible implementation:
>
>   (defn slice
>     "Return the items in coll at index positions keys.
>
>     (slice \"abcdefg\" 0 4 6) => (\\a \\e \\g)"
>     [coll & keys]
>     (let [keyset (set keys)]
>       (for [[idx elt] (indexed coll)
>             :when (keyset idx)]
>         elt)))
>
> I often want something like this when picking apart lines from log files
> (calling .split on a string, then grabbing certain segments)
>
> Thanks,
>
> Mark
>
> --
> Mark Triggs
> 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Quirk with filter

2009-08-18 Thread J. McConnell
On Tue, Aug 18, 2009 at 7:37 PM, Sean Devlin wrote:

>
> user=> (filter #{false} [true false false true])
> ()
>
> Obviously, this is not what I intended.  The best I could do was the
> following
>
> user=> (filter (comp not nil? #{false}) [true false false true])
> (false false)
>
> Does anyone else have any other ideas?
>

user=> (filter false? [true false false true])
(false false)

Or is the set in question being passed in as a parameter?

Regards,

- J.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Quirk with filter

2009-08-18 Thread Sean Devlin

The set is being passed in as a parameter, so that will be a problem.
Still, I'll be able to re-write my routine with false.  Thanks!

On Aug 18, 8:18 pm, "J. McConnell"  wrote:
> On Tue, Aug 18, 2009 at 7:37 PM, Sean Devlin wrote:
>
>
>
> > user=> (filter #{false} [true false false true])
> > ()
>
> > Obviously, this is not what I intended.  The best I could do was the
> > following
>
> > user=> (filter (comp not nil? #{false}) [true false false true])
> > (false false)
>
> > Does anyone else have any other ideas?
>
> user=> (filter false? [true false false true])
> (false false)
>
> Or is the set in question being passed in as a parameter?
>
> Regards,
>
> - J.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Idiom for array slicing

2009-08-18 Thread CuppoJava

Hmm... I suppose so. That would depend on the semantics that you want.
How exactly would a multi-dimensional slice work?

Right now, if you use slice on a multi-dimensional vector, it will
return a list of vectors for you, which you can further slice to your
heart's content. Perhaps that's good enough?

Interesting question though.
-Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Idiom for array slicing

2009-08-18 Thread CuppoJava

Sigh... I never did understand that "head hanging" part. I need to go
back and read Rich's post in more detail.

Does anyone know if there's a compounded collection of all of Rich's
"webpages" which aren't officially online yet? eg. clojure.org/lazy,
clojure.org/streams, etc...

  -Patrick

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Quirk with filter

2009-08-18 Thread Mark Reid

Hi,

The problem here is that filter is expecting a predicate and you are
passing a set.

When used as a function like so

   user=> (#{1 2 3} 2)
   2

   user=> (#{1 2 3} 5)
   nil

the set returns the argument if it is in the set and nil otherwise.

The problem you are observing is because the item being returned is
false. That is,

   user=> (#{true false} false)
   false

and the conditional test in the definition of filter is, naturally,
failing for this value.

I actually think the behaviour in the first case is wrong since the
documentation for filter is

   Returns a lazy sequence of the items in coll for which
  (pred item) returns true. pred must be free of side-effects.

Note it says "returns true" not "not nil nor false".

The  problem here is that the "if" special form used to define filter
does the following:

   user=> (if 1 "yes" "no")
   "yes"

As it currently stands, either "filter" needs to be redefined using
(if (true? (p (first s) ...) or the documentation needs to be changed.

Regards,

Mark.

On Aug 19, 9:37 am, Sean Devlin  wrote:
> Hello Clojurians,
> I commonly use a set in my filtering operations, like the example
> below.
>
> user=> (filter #{\a \e \i \o \u} "The quick brown fox jumped over the
> lazy dog")
> (\e \u \i \o \o \u \e \o \e \e \a \o)
>
> Today I found myself using the following code
>
> user=> (filter #{false} [true false false true])
> ()
>
> Obviously, this is not what I intended.  The best I could do was the
> following
>
> user=> (filter (comp not nil? #{false}) [true false false true])
> (false false)
>
> Does anyone else have any other ideas?
>
> Sean
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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
-~--~~~~--~~--~--~---



Using the var special-form

2009-08-18 Thread samppi

Why doesn't this work?

Clojure 1.0.0-
user=> (declare aaa)
#'user/aaa
user=> (var (symbol "aaa"))
java.lang.ClassCastException: clojure.lang.PersistentList cannot be
cast to clojure.lang.Symbol (NO_SOURCE_FILE:2)
user=> (var 'aaa)
java.lang.ClassCastException: clojure.lang.Cons cannot be cast to
clojure.lang.Symbol (NO_SOURCE_FILE: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
Note that posts from new members are moderated - please be patient with your 
first post.
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: Quirk with filter

2009-08-18 Thread CuppoJava

Hi Sean,
I think your solution with (comp not nil? ... ) is very clean already.
But in case you don't like that, here's another way of writing it:

(filter #(contains? #{false} %) [false true false true])
returns (false false)

It probably gets compiled to almost the same thing under the hood. But
it looks a little less cryptic. Hope this helps.
  -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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: Using the var special-form

2009-08-18 Thread Timothy Pratley

user=> (resolve (symbol "aaa"))
#'user/aaa
might be what you want?



On Aug 19, 1:11 pm, samppi  wrote:
> Why doesn't this work?
>
> Clojure 1.0.0-
> user=> (declare aaa)
> #'user/aaa
> user=> (var (symbol "aaa"))
> java.lang.ClassCastException: clojure.lang.PersistentList cannot be
> cast to clojure.lang.Symbol (NO_SOURCE_FILE:2)
> user=> (var 'aaa)
> java.lang.ClassCastException: clojure.lang.Cons cannot be cast to
> clojure.lang.Symbol (NO_SOURCE_FILE: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
Note that posts from new members are moderated - please be patient with your 
first post.
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: Using the var special-form

2009-08-18 Thread Meikel Brandmeyer

Hi,

On Aug 19, 5:11 am, samppi  wrote:

> Why doesn't this work?

`var` is a special form. You have to give the symbol directly.

user=> (var aaa)
#'user/aaa

Other than that see Timothy's answer.

Sincerely
Meikel

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
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
-~--~~~~--~~--~--~---