Re: java/Clojure MPI ..

2010-12-31 Thread Sunil S Nandihalli
Here is quick summary of results I obtained by googling.
 There are bunch of libraries out there ... among them are

1. mpiJava a java wrapper for the corresponding c libraries but seems
dated...
2. MPJExpress .. seems to be under more active development.

But yet to find any parallel linear algebra libraries that use either of
these.

Sunil.

On Fri, Dec 31, 2010 at 12:45 PM, Sunil S Nandihalli <
sunil.nandiha...@gmail.com> wrote:

> Hello everybody,
>  I am looking for parallel programming libraries in Clojure. I found
> JavaMPI but its website does not seem to be updated since 2003. I would love
> to hear anything about where Java stands in distributed parallel computing.
> I get the feeling that the Parallel colt libraries are just for shared
> memory parallelism. I am primarily interested in large matrix computations..
> .
>  I currently need something that can do CGLS (conjugate Gradient Least
> squares )  in a distributed way. It is available in parallel colt libraries
> .. but it is only shared-memory parallel.
>   I am sorry this is not directly related to Clojure but would love to hear
> what you all have to say.
> Thanks,
> Sunil.
>

-- 
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: java/Clojure MPI ..

2010-12-31 Thread Tim Daly



On 12/31/2010 3:36 AM, Sunil S Nandihalli wrote:

Here is quick summary of results I obtained by googling.
 There are bunch of libraries out there ... among them are

1. mpiJava a java wrapper for the corresponding c libraries but seems 
dated...

2. MPJExpress .. seems to be under more active development.

But yet to find any parallel linear algebra libraries that use either 
of these.

I do computer algebra as my main open source project (Axiom)
and I am unaware of any parallel linear algebra libraries in Java.

Given that some boffin in Europe just made a 1000 core machine
with local memory per processor I think there needs to be a lot
more effort put into the parallel work. Unfortunately the various
funding agencies don't seem to consider open source work fundable.

I'm looking into constructing parallel programs with Clojure using MPI.
Hopefully it will scale both concurrently and in parallel.


Sunil.

On Fri, Dec 31, 2010 at 12:45 PM, Sunil S Nandihalli 
mailto:sunil.nandiha...@gmail.com>> wrote:


Hello everybody,
 I am looking for parallel programming libraries in Clojure. I
found JavaMPI but its website does not seem to be updated since
2003. I would love to hear anything about where Java stands in
distributed parallel computing. I get the feeling that the
Parallel colt libraries are just for shared memory parallelism. I
am primarily interested in large matrix computations.. .
 I currently need something that can do CGLS (conjugate Gradient
Least squares )  in a distributed way. It is available in parallel
colt libraries .. but it is only shared-memory parallel.
  I am sorry this is not directly related to Clojure but would
love to hear what you all have to say.
Thanks,
Sunil.


--
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 


--
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: java/Clojure MPI ..

2010-12-31 Thread Konrad Hinsen

On 31 Dec 2010, at 09:36, Sunil S Nandihalli wrote:


Here is quick summary of results I obtained by googling.
 There are bunch of libraries out there ... among them are

1. mpiJava a java wrapper for the corresponding c libraries but  
seems dated...

2. MPJExpress .. seems to be under more active development.


That's my impression as well.

But yet to find any parallel linear algebra libraries that use  
either of these.


I haven't found any MPI-based library for Java yet. HPC in Java looks  
pretty dead.


Konrad.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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: java/Clojure MPI ..

2010-12-31 Thread Sunil S Nandihalli
Hi Konrad,
 Have you looked at

http://nativelibs4java.sourceforge.net/

It is created using a java native interface generater called jnaerator .. it
does not seem to have any linear algebra library .. but may be a start .. I
am only introduced to java from clojure ..

Sunil.



On Fri, Dec 31, 2010 at 3:09 PM, Konrad Hinsen
wrote:

> On 31 Dec 2010, at 09:36, Sunil S Nandihalli wrote:
>
>  Here is quick summary of results I obtained by googling.
>>  There are bunch of libraries out there ... among them are
>>
>> 1. mpiJava a java wrapper for the corresponding c libraries but seems
>> dated...
>> 2. MPJExpress .. seems to be under more active development.
>>
>
> That's my impression as well.
>
>
>  But yet to find any parallel linear algebra libraries that use either of
>> these.
>>
>
> I haven't found any MPI-based library for Java yet. HPC in Java looks
> pretty dead.
>
> Konrad.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> 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
>

-- 
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: Do type hints cause auto casting?

2010-12-31 Thread Laurent PETIT
2010/12/31 Jarl Haggerty 

> I think I asked the wrong question, not only that but I guess I
> answered the question I asked, what I want to know is what exactly is
> a type hint.  I think I've failed to understand exactly what a type
> hint is, I assumed to give a hint was to statically type something but
> that doesn't seem to be what happens here.
>
>
They are there for helping the compiler generate efficient bytecode for java
interop calls (e.g. `(.someMethod anObject ...) calls). Efficient bytecode
is bytecode which does not involve the use of reflection at runtime ( e.g.
calling getClass().getMethods(), choosing the right method by signature,
etc.).

Clojure compiler uses inference to minimize the number of required "type
hints".

In Clojure 1.3 (not yet stable/released beyond alpha versions), type hints
will also be used for generating efficient functions signatures with up to 4
long or double primitive arguments.

HTH,

-- 
Laurent


> On Dec 30, 9:18 pm, Sunil S Nandihalli 
> wrote:
> > I don't think type hints lead to auto casting .. May be somebody else can
> > throw more light on it. And it is this way by design.
> > Sunil.
> >
> > On Fri, Dec 31, 2010 at 9:35 AM, Jarl Haggerty  >wrote:
> >
> > > I have this function
> >
> > > (defn floor
> > >  ^int [^float x] x)
> >
> > > and (floor 1.5) returns 1.5 which confuses me as to how type hints
> > > work, I was expecting the result to be truncated or for the program to
> > > spit out some exception about expecting an int and getting a float.
> >
> > > --
> > > 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
> >
> >
>
> --
> 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
>

-- 
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: java/Clojure MPI ..

2010-12-31 Thread Konrad Hinsen

On 31 Dec 2010, at 10:56, Sunil S Nandihalli wrote:


 Have you looked at

http://nativelibs4java.sourceforge.net/


I have seen it, but not looked any closer.

It is created using a java native interface generater called  
jnaerator .. it does not seem to have any linear algebra library ..  
but may be a start .. I am only introduced to java from clojure ..


Me too, and I don't really want to do anything in Java itself. If JNA  
can be used to create efficient native interfaces (I haven't found the  
time yet to check it out), then I'd happily use clj-native to create  
Clojure-only JVM interfaces and forget about Java!


Konrad.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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: Time/size bounded cache?

2010-12-31 Thread Peter Schuller
> The problem is that "seen" will grow without bounds.
> Is there a built in way to have some sort of LRU cache or should I use
> external libraries (like plru)?

I wrote a persistent LRU cache:

   https://github.com/scode/plru

It's not going to be as memory efficient as a LInkedArrayList, but if
it matters to you do have it be persistent/immutable...

-- 
/ Peter Schuller

-- 
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 aset in clojure-1.3-alpha4

2010-12-31 Thread Sunil S Nandihalli
Hello Everybody,
why does this give an error in clojure-1.3-alpha4
  (aset (make-array Integer/TYPE 3 4 5) 1 2 3 -1)
can anybody tell me as to how to do this right?
Thanks,
Sunil.

-- 
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

A Web Server in Clojure

2010-12-31 Thread limux
I have read  Fast Track Clojure's serials tutorial. lession 5 is about
a web server.

Below is part of demo code:

(use 'clojure.contrib.server-socket)
(create-server
  8080
  (fn [in out]
(binding
  [*out* (java.io.PrintWriter. out)]
  (println "HTTP/1.0 200 OK")
  (println "Content-Type: text/html")
  (println "")
  (println "Wooo hooo hooo, my first web server!")
  (flush

I found these codes could do well without any issue, while the browser
have displayed nothing for error of 101 (net::ERR_CONNECTION_RESET).
But another codes below all is okey. Was there someting wrong?

(use 'clojure.contrib.server-socket)
(import  '(java.io BufferedReader InputStreamReader PrintWriter))

(create-server
  8080
  (fn [in out]
(binding
  [ *in* (BufferedReader. (InputStreamReader. in))
*out* (PrintWriter. out)]
  (println "HTTP/1.0 200 OK")
  (println "Content-Type: text/html")
  (println "")
  (loop [line (read-line)]
(println (str line ""))
(if-not (empty? line)
  (recur (read-line
  (flush

-- 
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


A Web Server in Clojure

2010-12-31 Thread limux
I have read  Fast Track Clojure's serials tutorial. lession 5 is about
a web server.

Below is part of demo code:

(use 'clojure.contrib.server-socket)
(create-server
  8080
  (fn [in out]
(binding
  [*out* (java.io.PrintWriter. out)]
  (println "HTTP/1.0 200 OK")
  (println "Content-Type: text/html")
  (println "")
  (println "Wooo hooo hooo, my first web server!")
  (flush

I found these codes could do well without any issue, while the browser
have displayed nothing for error of 101 (net::ERR_CONNECTION_RESET).
But another codes below all is okey. Was there someting wrong?

(use 'clojure.contrib.server-socket)
(import  '(java.io BufferedReader InputStreamReader PrintWriter))

(create-server
  8080
  (fn [in out]
(binding
  [ *in* (BufferedReader. (InputStreamReader. in))
*out* (PrintWriter. out)]
  (println "HTTP/1.0 200 OK")
  (println "Content-Type: text/html")
  (println "")
  (loop [line (read-line)]
(println (str line ""))
(if-not (empty? line)
  (recur (read-line
  (flush

-- 
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: Do type hints cause auto casting?

2010-12-31 Thread nickik
The hints are not use for static type analysis they are there for
speed. There is no type checker. In your example the compiler tries
using it as an int if that is not working the compiler uses reflaction
to find out the type.

no auto casts are by design.

On 31 Dez., 05:57, Jarl Haggerty  wrote:
> I think I asked the wrong question, not only that but I guess I
> answered the question I asked, what I want to know is what exactly is
> a type hint.  I think I've failed to understand exactly what a type
> hint is, I assumed to give a hint was to statically type something but
> that doesn't seem to be what happens here.
>
> On Dec 30, 9:18 pm, Sunil S Nandihalli 
> wrote:
>
> > I don't think type hints lead to auto casting .. May be somebody else can
> > throw more light on it. And it is this way by design.
> > Sunil.
>
> > On Fri, Dec 31, 2010 at 9:35 AM, Jarl Haggerty 
> > wrote:
>
> > > I have this function
>
> > > (defn floor
> > >  ^int [^float x] x)
>
> > > and (floor 1.5) returns 1.5 which confuses me as to how type hints
> > > work, I was expecting the result to be truncated or for the program to
> > > spit out some exception about expecting an int and getting a float.
>
> > > --
> > > 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

-- 
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


A Web Server in Clojure

2010-12-31 Thread limux
I have read  Fast Track Clojure's serials tutorial. lession 5 is about
a web server.

Below is part of demo code:

(use 'clojure.contrib.server-socket)
(create-server
  8080
  (fn [in out]
(binding
  [*out* (java.io.PrintWriter. out)]
  (println "HTTP/1.0 200 OK")
  (println "Content-Type: text/html")
  (println "")
  (println "Wooo hooo hooo, my first web server!")
  (flush

I found these codes could do well without any issue, while the browser
have displayed nothing for error of 101 (net::ERR_CONNECTION_RESET).
But another codes below all is okey. Was there someting wrong?

(use 'clojure.contrib.server-socket)
(import  '(java.io BufferedReader InputStreamReader PrintWriter))

(create-server
  8080
  (fn [in out]
(binding
  [ *in* (BufferedReader. (InputStreamReader. in))
*out* (PrintWriter. out)]
  (println "HTTP/1.0 200 OK")
  (println "Content-Type: text/html")
  (println "")
  (loop [line (read-line)]
(println (str line ""))
(if-not (empty? line)
  (recur (read-line
  (flush

-- 
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: A Web Server in Clojure

2010-12-31 Thread limux
Sorry for my net speed is too slow  result in duplicate post.

-- 
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 aset in clojure-1.3-alpha4

2010-12-31 Thread Allen Johnson
This worked for me on 1.3.0:

(aset-int (make-array Integer/TYPE 3 4 5) 1 2 3 -1)

Might have something to do with the enhanced primitive support which
causes array handling to be stricter than it was in 1.2? Just a guess.

Allen

On Fri, Dec 31, 2010 at 8:53 AM, Sunil S Nandihalli
 wrote:
> Hello Everybody,
> why does this give an error in clojure-1.3-alpha4
>   (aset (make-array Integer/TYPE 3 4 5) 1 2 3 -1)
> can anybody tell me as to how to do this right?
> Thanks,
> Sunil.
>
> --
> 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

-- 
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: Clojure in Small Pieces -- Literate Clojure

2010-12-31 Thread Robert McIntyre
This looks very cool, and the opportunities for fully exploiting the
power of a cross-referenced book format are very appealing

Might I suggest two possible improvements:
1) Colored syntax highlighting for all clojure code.
2) Cross references for every clojure symbol used in the code --- I'd
love to be able to click on + anywhere in the document and have it
bring me to the proper section in the book discussing the arithmetic
operators.

Page 971 looks like it still overflows a bit :)
I agree that some of the java parts of clojure were definitely
developed on very large screens.

Thanks for starting on this; best of luck,
Sincerely,

--Robert McIntyre


On Fri, Dec 31, 2010 at 2:07 AM, Mark Engelberg
 wrote:
> I find this exciting!  Thanks for starting this.
>
> --
> 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

-- 
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: Chunking is making my life more difficult.

2010-12-31 Thread ehanneken
On Dec 31, 12:48 am, Ken Wesson  wrote:
> Is mapcat also semi-eager, then?

I guess so.  The Clojure 1.1 release notes also say, "Some of the
sequence processing functions (like map and
filter) are now chunk-aware and leverage this efficiency."  I should
have mentioned that.

-- 
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: an object of class created using defrecord does not implement IFn .. while it behaves very similar to map otherwise ..

2010-12-31 Thread Alyssa Kwan
Generating readable code for IDEs is not a good reason. You should
think carefully about variable capture and decide which you want.
Usually, in a macro-generated defn, I do want to capture the
parameters, so I would use ~'this.

On Dec 30, 11:54 pm, André Thieme  wrote:
> Am 31.12.2010 03:29, schrieb Alex Baranosky:
>
>
>
>
>
> > I've been playing with making a macro to encapsulate Stuart's post, like
> > this:
>
> > (defmacro defrecord-ifn [name & args]
> >    `(defrecord ~name ~...@args
> >      clojure.lang.IFn
> >      (invoke [this key] (get this key
>
> > (defrecord-ifn Foo [a b c])
>
> > (def foo (Foo. "A" "B" "C"))
>
> > (prn (map foo [:a :c])) => ("A", "C")
>
> > I get the error:
>
> > "No such var: user/this".  I guess this is because it is expanding
> > 'this' to 'user/this'.  What is the proper way to get a macro like this
> > to expand properly?
>
> Others have already pointed to this# .
> I just would like to add that you can as well use ~'this in some
> cases, where your macros generate defns. The advantage is that some
> editors (like emacs) will show you the parameter vector and that would
> show a useful name and not this_auto_foobarbaz123456 .

-- 
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: Time/size bounded cache?

2010-12-31 Thread Miki


I wrote a persistent LRU cache:
>
>https://github.com/scode/plru
>
> Yup, I've looked at it (mentioned in the original post). I might end up 
using it, thanks.
 

-- 
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: A Web Server in Clojure

2010-12-31 Thread Miki
Both of these examples work for me (clojure 1.2).
Is there an error on the console when you access the site?

Also, if this is not a learning exercise, I recommend having a look at 
Compojure for web development.

HTH,
--
Miki 

-- 
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: an object of class created using defrecord does not implement IFn .. while it behaves very similar to map otherwise ..

2010-12-31 Thread Robert McIntyre
Be sure to also implement the version of get which takes a not-found
argument so that your objects will work with map code which uses this
functionality.

(defrecord map-like-object [field-1 field-2 etc]
  clojure.lang.IFn
  (invoke [this k] (get this k))
  (invoke [this k not-found] (get this k not-found)))

sincerely,
--Robert McIntryre

On Fri, Dec 31, 2010 at 11:04 AM, Alyssa Kwan  wrote:
> Generating readable code for IDEs is not a good reason. You should
> think carefully about variable capture and decide which you want.
> Usually, in a macro-generated defn, I do want to capture the
> parameters, so I would use ~'this.
>
> On Dec 30, 11:54 pm, André Thieme  wrote:
>> Am 31.12.2010 03:29, schrieb Alex Baranosky:
>>
>>
>>
>>
>>
>> > I've been playing with making a macro to encapsulate Stuart's post, like
>> > this:
>>
>> > (defmacro defrecord-ifn [name & args]
>> >    `(defrecord ~name ~...@args
>> >      clojure.lang.IFn
>> >      (invoke [this key] (get this key
>>
>> > (defrecord-ifn Foo [a b c])
>>
>> > (def foo (Foo. "A" "B" "C"))
>>
>> > (prn (map foo [:a :c])) => ("A", "C")
>>
>> > I get the error:
>>
>> > "No such var: user/this".  I guess this is because it is expanding
>> > 'this' to 'user/this'.  What is the proper way to get a macro like this
>> > to expand properly?
>>
>> Others have already pointed to this# .
>> I just would like to add that you can as well use ~'this in some
>> cases, where your macros generate defns. The advantage is that some
>> editors (like emacs) will show you the parameter vector and that would
>> show a useful name and not this_auto_foobarbaz123456 .
>
> --
> 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

-- 
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 aset in clojure-1.3-alpha4

2010-12-31 Thread Sunil S Nandihalli
Hi Allen ..
 is 1.3.0 out? and I did not know that aset had so many variants.. glad I
asked .. now I know .. :) thanks Allen.
Sunil.

On Fri, Dec 31, 2010 at 8:19 PM, Allen Johnson wrote:

> This worked for me on 1.3.0:
>
> (aset-int (make-array Integer/TYPE 3 4 5) 1 2 3 -1)
>
> Might have something to do with the enhanced primitive support which
> causes array handling to be stricter than it was in 1.2? Just a guess.
>
> Allen
>
> On Fri, Dec 31, 2010 at 8:53 AM, Sunil S Nandihalli
>  wrote:
> > Hello Everybody,
> > why does this give an error in clojure-1.3-alpha4
> >   (aset (make-array Integer/TYPE 3 4 5) 1 2 3 -1)
> > can anybody tell me as to how to do this right?
> > Thanks,
> > Sunil.
> >
> > --
> > 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
>
> --
> 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

-- 
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: clojure can't see a method in my protocol

2010-12-31 Thread Stuart Halloway
Ken,

Classloader visibility (http://dev.clojure.org/jira/browse/CLJ-371) is one 
possible point of confusion. If you have an AOT-compiled class, you can't 
replace it from the REPL which works from a child classloader.

This is "correct" from a Java perspective, and easy enough to deal with one you 
know what is going on. But the ticket is there so somebody can propose 
something better.

Stu

> On Thu, Dec 30, 2010 at 7:41 PM, André Thieme
>  wrote:
>> Do you observe this in a fresh Clojure?
>> I ran into something similar, but with definterface.
>> I had a definterface form and later added new functions to it, which I
>> could not implement before restarting the JVM, as the interface has
>> already been created the way I specified it in the first place.
> 
> Tangent: this incident is the one I was referring to earlier in
> another thread regarding some of the defprotocol-related features
> combining poorly with in-REPL development, which I had trouble
> locating when I wanted to use it as an example. (And now that other
> thread where the topic came up is, of course, the one I can't seem to
> locate!)
> 
> -- 
> 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

-- 
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 aset in clojure-1.3-alpha4

2010-12-31 Thread Allen Johnson
Sorry I should have written 1.3.0-master-SNAPSHOT or whatever the
convention is that represents the latest master build :)


On Fri, Dec 31, 2010 at 11:21 AM, Sunil S Nandihalli
 wrote:
> Hi Allen ..
>  is 1.3.0 out? and I did not know that aset had so many variants.. glad I
> asked .. now I know .. :) thanks Allen.
> Sunil.
>
> On Fri, Dec 31, 2010 at 8:19 PM, Allen Johnson 
> wrote:
>>
>> This worked for me on 1.3.0:
>>
>> (aset-int (make-array Integer/TYPE 3 4 5) 1 2 3 -1)
>>
>> Might have something to do with the enhanced primitive support which
>> causes array handling to be stricter than it was in 1.2? Just a guess.
>>
>> Allen
>>
>> On Fri, Dec 31, 2010 at 8:53 AM, Sunil S Nandihalli
>>  wrote:
>> > Hello Everybody,
>> > why does this give an error in clojure-1.3-alpha4
>> >   (aset (make-array Integer/TYPE 3 4 5) 1 2 3 -1)
>> > can anybody tell me as to how to do this right?
>> > Thanks,
>> > Sunil.
>> >
>> > --
>> > 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
>>
>> --
>> 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
>
> --
> 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

-- 
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 aset in clojure-1.3-alpha4

2010-12-31 Thread Miki


>   (aset (make-array Integer/TYPE 3 4 5) 1 2 3 -1)
> can anybody tell me as to how to do this right?
>
> (aset (make-array Long/TYPE 3 4 5) 1 2 3 -1)

I *think* that number by default are long, and the array is of ints.

HTH,
--
Miki
http://clojurewise.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: Chunking is making my life more difficult.

2010-12-31 Thread Steven E. Harris
ehanneken  writes:

> I spent a long time debugging some Clojure code yesterday.  The
> essence of it looked similar to this:
>
> (defn items []
>   (mapcat expensive-function (range 0 4000 100)))
>
> . . . (take 5 (items)) . . .

I tried to distill the problem down by defining a non-chunking range
function (a simple variant), then working outward from there to see what
else is evaluating a surprising number of times.

,
| (defn non-chunked-range
|   [start end]
|   (prn (format "In non-chunked-range with %d and %d." start end))
|   (lazy-seq
|(when-not (= start end)
|  (cons start (non-chunked-range (inc start) end)
`

Note that `mapcat` is defined in terms of `map` and `concat`. First
let's confirm that `map` is not eager:

,
| ;; Draws one, and evaluates lazy sequence function twice:
| (take 1
|   (map #(list %)
|(non-chunked-range 0 10)))
`

Experimenting with the argument to `take` shows that the lazy sequence
function is evaluated as expected: a number of times equal to the
argument plus one for the terminal case (n + 1).

Now add `concat` into the mix to make sure it's not eager:

,
| ;; Draws two, and evaluates lazy sequence function three times:
| (concat (take 2 (non-chunked-range 0 10)))
`

That works as expected. Now add `apply` to `concat` as `mapcat` does to
flatten the input lists:

,
| ;; Draws one, and evaluates lazy sequence five times:
| (take 1
|   (apply concat
|  (map #(list %)
|   (non-chunked-range 0 10
`

Whoah! Where did the extra three evaluations of the lazy sequence
function come from? Note that this one calls on the function /five/
times.

Here is the mapping of the argument to `take` and the number of times
the function is called:

 take   calls
    =
 0  5  
 1  5
 2  5
 3  5
 4  6 
 5  7
 ...
 n  n + 2

I read the source for `concat`, but I don't see what it's doing to force
the extra evaluations both below four arguments and the extra one
(yielding n + 2) with four or more arguments. What's responsible for
this difference in behavior?

-- 
Steven E. Harris

-- 
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: Do type hints cause auto casting?

2010-12-31 Thread Stuart Sierra
In Clojure 1.2, type hints only help the compiler avoid reflection and thus 
generate faster Java interop code.

Starting in 1.3, function arguments and return values can have ^long or 
^double type hints (int and float are not supported).  These are enforced at 
compile time, but they are not type-casts.

For example:

Clojure 1.3.0-master-SNAPSHOT
user=> (defn floor ^long [^double x] x)
CompilerException java.lang.RuntimeException: 
java.lang.IllegalArgumentException: Mismatched primitive return, expected: 
long, had: double

The `long` and `double` functions can be used to coerce primitives to their 
respective types.

user=> (defn floor ^long [^double x] (long x))
#'user/floor
user=> (floor 1.5)
1


-Stuart Sierra
clojure.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: using aset in clojure-1.3-alpha4

2010-12-31 Thread Stuart Sierra
Yes, integer literals are longs by default in 1.3.  As noted, this works:

(aset-int (make-array Integer/TYPE 3 4 5) 1 2 3 -1)

My intuition says this should work as well, but it doesn't:

(aset ^ints (make-array Integer/TYPE 3 4 5) 1 2 3 (int -1))
IllegalArgumentException argument type mismatch 
 java.lang.reflect.Array.set

The reason why becomes apparent on examining the source of aset:

(defn aset
  {:inline (fn [a i v] `(. clojure.lang.RT (aset ~a (int ~i) ~v)))
   :inline-arities #{3}
   :added "1.0"}
  ([array idx val]
   (. Array (set array idx val))
   val)
  ([array idx idx2 & idxv]
   (apply aset (aget array idx) idx2 idxv)))

When given more than three arguments, `aset` uses `apply`, which does not 
accept primitive arguments.  Thus, for multidimensional arrays, `aset` 
cannot be called with primitive arguments.

With single-dimensional arrays, `aset` works on primitives as expected:

(aset (int-array 3) 1 -1)

-Stuart Sierra
clojure.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: Chunking is making my life more difficult.

2010-12-31 Thread ehanneken
Chas,

Thanks for your help.  However, modifying the code to use mapcat
instead of (map println) seems to cause some chunking:

(defn tenify [n]
  (do
(println \" n \")
[n n n n n n n n n n]))

=> (->> (range 50)
 (mapcat list)
 (mapcat tenify)
 first)
" 0 "
" 1 "
" 2 "
" 3 "
0

And indeed, when I modify my code I see four HTTP GETs being issued.
Four is better than 32, but still.

-- 
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: Clojure in Small Pieces -- Literate Clojure

2010-12-31 Thread Tim Daly



On 12/31/2010 10:36 AM, Robert McIntyre wrote:

This looks very cool, and the opportunities for fully exploiting the
power of a cross-referenced book format are very appealing

Might I suggest two possible improvements:
1) Colored syntax highlighting for all clojure code.
2) Cross references for every clojure symbol used in the code --- I'd
love to be able to click on + anywhere in the document and have it
bring me to the proper section in the book discussing the arithmetic
operators.

I can't help much with the colored syntax. I am partially
color blind so I don't find colors all that useful.

Cross references occur naturally as part of the markup process.
The current chunks are much too large but that will change.

One useful side-effect of markup is that you can find where a
symbol is defined and every use of that symbol. Of course, since
everything is in one file you only need a text editor to find
anything.


Page 971 looks like it still overflows a bit :)
I agree that some of the java parts of clojure were definitely
developed on very large screens.

Yeah, what I posted is only a snapshot to see if anyone else
found the idea interesting. I don't think that most programmers
have ever seen literate documentation so this may be their first
exposure to the idea.

Thanks for starting on this; best of luck,
Sincerely,

Thanks. I think that this is really useful in some contexts,
especially where you're trying to bring new developers up to
speed on a language. One problem I've found with open source
is that once the original developer team leaves the project
just dies. Another problem is that new developers will add
"new" features that are already in the language elsewhere.

Working with the actual source surrounded by an explanation of
"why" the code exists and the ideas behind the code seems to
me to solve both problems.

The other problem is that clever code is hard to maintain
even for the original authors. I got my own "dirt simple" code
back after 15 years and, while I understood what the code did,
I had no idea why it was there. Sometimes whole subsystems die
because they are no longer used but nobody is able to remove
the dead code because they don't understand it.

--
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


chunked-seq? is lying?

2010-12-31 Thread Mike K
In 1.2, I don't understand why one of the sequences below is chunked,
but the other is not.  Also, chunked-seq? seems to be lying about the
second one.

user> (take 1 (map #(do (print ".") [% %2]) (range 100) (range 100)))
(.[0 0])
user> (take 1 (map #(do (print ".") [%]) (range 100)))
([0])
user> (chunked-seq? (map #(do (print ".") [%]) (range 100)))
false

   Mike




-- 
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


"Vars" problem

2010-12-31 Thread xlarsx
Good day
Before anything I'd like to thank you for your time

I've the following problem:
user=> (def x 1)
#'user/x
user=> (def y 1)
#'user/y
user=> (+ x y)
2
user=> (binding [x 2 y 3] (+ x y))
IllegalStateException Can't dynamically bind non-dynamic var: user/x
clojure.lang.Var.pushThreadBindings (Var.java:339)

The origin of this code is: http://clojure.org/vars

Thank you

Luis Alejandro Rangel Sánchez

-- 
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: chunked-seq? is lying?

2010-12-31 Thread Meikel Brandmeyer
Hi,

Am 31.12.2010 um 19:57 schrieb Mike K:

> In 1.2, I don't understand why one of the sequences below is chunked,
> but the other is not.  Also, chunked-seq? seems to be lying about the
> second one.
> 
> user> (take 1 (map #(do (print ".") [% %2]) (range 100) (range 100)))
> (.[0 0])
> user> (take 1 (map #(do (print ".") [%]) (range 100)))
> ([0])
> user> (chunked-seq? (map #(do (print ".") [%]) (range 100)))
> false

For map with multiple input sequences all sequences would probably be have to 
be chunked with the same chunk size. So instead of checking this, map produces 
for multiple input sequences a non-chunked seq.

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


Re: "Vars" problem

2010-12-31 Thread Meikel Brandmeyer
Hi,

Am 31.12.2010 um 20:12 schrieb xlarsx:

> Good day
> Before anything I'd like to thank you for your time
> 
> I've the following problem:
> user=> (def x 1)
> #'user/x
> user=> (def y 1)
> #'user/y
> user=> (+ x y)
> 2
> user=> (binding [x 2 y 3] (+ x y))
> IllegalStateException Can't dynamically bind non-dynamic var: user/x
> clojure.lang.Var.pushThreadBindings (Var.java:339)
> 
> The origin of this code is: http://clojure.org/vars

This a change in the upcoming 1.3 release. Vars have to be declared explicitly 
dynamic to be able to rebind them via binding. But I don't know the exact 
syntax how to do this.

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


Re: "Vars" problem

2010-12-31 Thread Sean Corfield
On Fri, Dec 31, 2010 at 11:12 AM, xlarsx  wrote:
> user=> (binding [x 2 y 3] (+ x y))
> IllegalStateException Can't dynamically bind non-dynamic var: user/x
> clojure.lang.Var.pushThreadBindings (Var.java:339)
>
> The origin of this code is: http://clojure.org/vars

The docs refer to Clojure 1.2 but the error you're seeing indicates
you're running Clojure 1.3 (alpha/snapshot), yes?

In Clojure 1.3, variables must be declared dynamic in order to change
their bound value:

(def ^:dynamic x 1)
(def ^:dynamic y 1)
(binding [x 2 y 3] (+ x y))
-- 
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

-- 
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


Loading JNI

2010-12-31 Thread ax2groin
I'm having trouble formulating a method to load JNI libraries into
System. I'm just getting started, so this is a newbie question.

I want something like this:

(defn get-jni-path
  "Derive the path to DLLs from environmental variables"
  []
  (let [path (System/getenv "APP_CONFIG_DIR")]
(str (.substring path 0 (- (.length path) (.length "Config")))
"bin/")))

(defn load-jni
  "Load the required libraries into the System so that the JNI works."
  []
  (let [paths (map #(str (get-jni-path) %) ["coms.dll", "sqlite.dll",
"utils.dll", "zlib.dll"])]
(doto System
  (load paths


But obviously I cannot handle the "paths" like this. I'm sure it's a
simple answer, but I'm missing it.

Thanx,
msd

-- 
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: chunked-seq? is lying?

2010-12-31 Thread Mike K
OK, I understand the difference in behavior between the two maps.  But
why is chunked-seq? incorrect?

user> (take 1 (map #(do (print ".") [%]) (range 100)))
([0])
user> (chunked-seq? (range 100))
false
user> (chunked-seq? (map #(do (print ".") [%]) (range 100)))
false
user> (chunked-seq? (take 1 (map #(do (print ".") [%]) (range 100
false

The implementation of chunked-seq? checks to see if the sequence is an
instance of clojure.lang.IChunkedSeq.  That doesn't appear to be
sufficient in the case of map taking one collection.

Also, Chas Emerick stated in another discussion that ranges always
produce chunked seqs, but the value of (chunked-seq? (range 100))
seems to belie that.


  Mike

-- 
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: Loading JNI

2010-12-31 Thread dysinger
Msd,

something like this

java -Djava.library.path=/usr/local/lib -cp clojure-1.2.0.jar:src
clojure.main

or in lein add

 :native-path "/usr/local/lib:/usr/lib"

to your project def

then you should be able to make the JNI/JNA calls

On Dec 31, 12:39 pm, ax2groin  wrote:
> I'm having trouble formulating a method to load JNI libraries into
> System. I'm just getting started, so this is a newbie question.
>
> I want something like this:
>
> (defn get-jni-path
>   "Derive the path to DLLs from environmental variables"
>   []
>   (let [path (System/getenv "APP_CONFIG_DIR")]
>     (str (.substring path 0 (- (.length path) (.length "Config")))
> "bin/")))
>
> (defn load-jni
>   "Load the required libraries into the System so that the JNI works."
>   []
>   (let [paths (map #(str (get-jni-path) %) ["coms.dll", "sqlite.dll",
> "utils.dll", "zlib.dll"])]
>     (doto System
>       (load paths
>
> But obviously I cannot handle the "paths" like this. I'm sure it's a
> simple answer, but I'm missing it.
>
> Thanx,
> msd

-- 
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: A Web Server in Clojure

2010-12-31 Thread limux
There is no  any error when I access http://127.0.0.1:8080 by browser.
While with wget, there will be some messages as below:

--2011-01-01 09:22:49--  (try:20)  http://127.0.0.1:8080/
Connecting to 127.0.0.1:8080... connected.
HTTP request sent, awaiting response... 200 No headers, assuming HTTP/
0.9
Length: unspecified
index.html has sprung into existence.
Giving up.


On 1月1日, 上午12时10分, Miki  wrote:
> Both of these examples work for me (clojure 1.2).
> Is there an error on the console when you access the site?
>
> Also, if this is not a learning exercise, I recommend having a look at
> Compojure for web development.
>
> HTH,
> --
> Miki

-- 
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: chunked-seq? is lying?

2010-12-31 Thread Chas Emerick

On Dec 31, 2010, at 5:53 PM, Mike K wrote:

> OK, I understand the difference in behavior between the two maps.  But
> why is chunked-seq? incorrect?
> 
> Also, Chas Emerick stated in another discussion that ranges always
> produce chunked seqs, but the value of (chunked-seq? (range 100))
> seems to belie that.

I was being a little loose in my description.  Ranges always produce chunked 
seqs via seq:

=> (chunked-seq? (range 10))
false
=> (chunked-seq? (seq (range 10)))
true

`range` returns a lazy seq, which "guards" the chunked seq.  Lazy seqs are 
never chunked themselves (otherwise, "proper" laziness would never be possible) 
but the seqs they provide are always aligned with the chunkiness of whatever 
lies beneath the lazy seq:

=> (chunked-seq? (seq (lazy-seq '(1 2 3
false
=> (chunked-seq? (seq (lazy-seq [1 2 3])))
true

- Chas

-- 
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


The non-Enclojure Clojure plugin homepages are all rather hard to find.

2010-12-31 Thread Ken Wesson
I use Enclojure/NetBeans myself, but it occurred to me to check out
the current state of its Eclipse counterpart.

But I can't find it anywhere. Google returns tons of results, of
course, but they're all third-party results except the first, which is
a code.google.com repository. *None* of the top ten results are the
home page of the plugin; if you're just looking to download the binary
and use it, or read about it in plain English, you're going to ignore
the Google Code link, and if you want to get your information from the
horse's mouth, you'll ignore all of the other hits and then give up.

This is a problem for Counterclockwise, which really should have its
own web site in the top ten (and preferably at the very top) of a
Google search for "counterclockwise clojure" (no quotation marks in
the actual search).

Contrast with the results of searching for "enclojure": the first hit
is the enclojure.org home page and the next two are other pages at
enclojure.org. Then the discussion group, hosted by Google. Fifth is
the source code repository. Third-party content, such as people
blogging about it, starts around the seventh returned hit, versus the
second with Counterclockwise with only the repository ranking higher.

In particular, if there is a counterclockwise.org or a
counterclockwise.com or anything similar it does not show up in the
top ten.

The situations with swank-clojure and La Clojure are similar to that
with Counterclockwise, though emacs users are probably just going to
download the source from the repository and run it anyway and
apparently IDEA has a plugin repository it can automatically download
and install plugins from, like NB (and, perhaps, Eclipse). The lack of
an obvious Google-findable starting point for reading about any of
these first before installing them or doing something with their
source code is troubling, regardless.

-- 
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