Re: chinese character in hiccup

2010-08-10 Thread Nebojsa Stricevic
Hi,

This looks similar like problem that I had with Clojure + Compojure +
Enlive and Serbian characters. I'm not sure if this is true, but maybe
solution to my problem can be helpful. Read this mailing list thread:
http://tiny.cc/3cmrx

Greets,

--
Nebojša Stričević

-- 
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: lazy-seq realization/retention within futures

2010-08-10 Thread timcharper


On Aug 7, 6:42 pm, Ben Mabey  wrote:
> Hi all,
> I've run into an issue with a lazy-seq either being prematurely realized
> or having the head unwittingly retained.  Reading chapter 5 in The Joy
> of Clojure I realize that I am breaking one of the rules (page 150 in my
> MEAP version): avoid binding your lazy sequences locally. That said, I
> am using Clojure 1.2RC2, and the book states that as of 1.2 the compiler
> is smarter about avoiding premature realization issues.  I think I may
> have stumbled upon a case where it is not handling (or is not able to).  
> Basically, the entire lazy-seq is being retained in memory when it is
> bound locally and then realized in a different thread via a future.
>
> Here is an example of the problem I am facing:
>
> (deftype Foo [])
> ; The entire lazy-seq is held in memory resulting in an OutOfMemoryError.
> (let [foos (take 1000 (repeatedly #(Foo.)))]
>   @(future (doseq [foo foos] foo)))
>
> I tried to reproduce this problem in different ways, but as far as I
> could tell the above combination of local binding and realization in a
> future is the only way the problem crops up.  Here is a gist of some of
> the other variants that did not cause the 
> problem:http://gist.github.com/513376
>
> My co-worker, Tim Harper, also did some work with weak references
> showing that the objects in the lazy-seq are not being 
> GCed:http://gist.github.com/510601
>
> Could someone shed some light onto why I am seeing the entire lazy-seq
> retained?  FWIW, I ran across this issue when using fill-queue like so:
>
> (defn map-queue
>   "Like map, but populated eagerly via fill-queue
>    (map-queue odd? (range 1 10) :queue-size 5) ;; will always calculate
> 5 ahead of the last used item from the lazy sequence"
>   [f coll & options]
>   (apply fill-queue (bound-fn [fill] (doseq [value coll] (fill (f
> value options))
>
> So in my case coll is a lazy-seq that can't be retained in memory.  Any
> explanation of what I'm doing wrong and how to better go about my
> problem would be greatly appreciated.
>
> Thanks!
>
> -Ben

As a follow up for anyone following this thread / discovering it, it
was discussed in #clojure on Tuesday:

http://clojure-log.n01se.net/date/2010-08-10.html

(search for timcharper for the start of the discussion)

I've distilled the issue down to a series of two tests: in one case,
the head is properly released, and in the other, the head is retained
even though it seems it shouldn't be.

http://gist.github.com/510601

Tim

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


RFC: updated c.c.logging with some breaking changes

2010-08-10 Thread ataggart
I've pushed the changes to my fork of contrib[1] and would like to get
feedback before pushing to contrib master.

Changes to logging.clj[2]:

New features:
- Log and LogFactory protocols allow adding new implementations
- log macros for using println-style args
- log macros for using format-style args

Improvements:
- Fixed reflection in log-stream
- log-capture! now optionally takes args specifying out and err
logging levels
- with-logs now optionally takes args specifying out and err logging
levels
- Fixed synchronization issue around calling System.setOut/setErr
- spy uses pprint to format output

Breaking changes from 1.0:
- *allow-direct-logging*: Replaced with improved functionality via
*force*
- *impl-name*: Replaced with impl-info fn on LogFactory protocol
- trace/debug/etc: Now take args like println, throwable position
changed
- log: order of args changed to keep consistency with new println and
format
   style args' placement of throwable

[1] http://github.com/ataggart/clojure-contrib
[2] 
http://github.com/ataggart/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/logging.clj

-- 
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: Cannot sen msg to #clojure channel

2010-08-10 Thread Sandeep Puri
first change your nick to whatever you want to register
/nick 

then you can register using
/msg NickServ register  

freenode requires you to confirm your registration i think (via a code
sent via email)

On Aug 10, 7:44 am, Laurent PETIT  wrote:
> You need to register with NickServ, e.g.
> /msg NickServ identify 
>
> It's a protection so that nobody else uses limux1972 when you're not online.
>
> (you also need to register limux1972, but I don't remember how)
>
> 2010/8/10 limux 
>
>
>
> > Why? My nickname in #clojure is limux1972.
>
> > --
> > 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: How to construct Set

2010-08-10 Thread Mark Engelberg
BTW, when you're done, it would be great if you could post a report
about your experience using JGraphT from Clojure.  I've been thinking
a lot lately about what an ideal graph library would look like in pure
Clojure, and it would be interesting to hear how easy/hard it already
is to use an existing Java graph library like JGraphT.

-- 
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: Can't get my nesting right

2010-08-10 Thread Meikel Brandmeyer
Hi,

Am 10.08.2010 um 20:56 schrieb Alan:

> which is exactly what I want. But I have failed countless times to
> define a make-hand function - I'd like to be able to call (make-
> hand :west {:spade [9 5], :club [10]}) and get back
> 
> {:spade
> ({:suit :spade, :owner :west, :rank 9}
>  {:suit :spade, :owner :west, :rank 5}),
> :club
> ({:suit :club, :owner :west, :rank 10})}
> 
> Can someone put me on the right track? I'm sure the solution for this
> is trivially simple but I can't quite find it.

So from your description the function signature should look like this:

(defn make-hand
  [owner suit-map]
  ...)

Now we have to fill the dots. Let's have a look at the map. It already has the 
right structure: it maps suits to things. In the input it's the vector of 
ranks, in the output it should be the sequence of card maps. We have to do it 
for all contained suits. And then pack everything back into a map.

(defn make-hand
  [owner suit-map]
  (->> suit-map
(map (fn [[suit ranks]]
   [suit (map (partial struct-map card
   :suit  suit
   :owner owner
   :rank)
  ranks)]))
(into (empty suit-map

Another possibility is to gradually transform the input map, which is not a 
problem due to Clojure's persistent data structures.

(defn make-hand
  [owner suit-map]
  (reduce (fn [suit-map suit]
(update-in suit-map [suit]
   (fn [ranks]
 (map (partial struct-map card
   :suit  suit
   :owner owner
   :rank)
  ranks
  suit-map
  (keys suit-map)))

Hope that helps.

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: Can't get my nesting right

2010-08-10 Thread Rasmus Svensson
2010/8/10 Alan :
> I have the following function as part of a card-game system I'm
> developing:
>
> (defn make-suit
>  [suit owner ranks]
>    {suit (map (partial struct-map card
>                        :suit suit
>                        :owner owner
>                        :rank)
>                ranks)})
>
> (make-suit :spade :west [9 5]) yields
>
> {:spade
>  ({:suit :spade, :owner :west, :rank 9}
>   {:suit :spade, :owner :west, :rank 5})}
>
> which is exactly what I want. But I have failed countless times to
> define a make-hand function - I'd like to be able to call (make-
> hand :west {:spade [9 5], :club [10]}) and get back
>
> {:spade
>  ({:suit :spade, :owner :west, :rank 9}
>  {:suit :spade, :owner :west, :rank 5}),
>  :club
>  ({:suit :club, :owner :west, :rank 10})}
>
> Can someone put me on the right track? I'm sure the solution for this
> is trivially simple but I can't quite find 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
>

My attempt:

  (defn make-hand [owner cards]
(into {} (for [[suit ranks] cards]
   [suit (for [rank ranks]
   {:suit suit
:owner owner
:rank rank})])))

Notice that a sequence of a map is a sequence of its [key value]
pairs. The keys are in this case the suits and the values which ranks
of that suits that should be included. To generate a map, it is often
useful to make [key value] pars and conj them into an empty map using
'into'. The generated map has the suits as its key, and for each suit
the ranks are looped over. A card map, including suit, rank and owner
is generated for each rank. The "current" suit and owner is accessed
through the for body's closure.

// raek

-- 
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: chinese character in hiccup

2010-08-10 Thread Joop Kiefte
What do you get if you use the meta-line with GBK encoding? if that
gives the right output, it is an input problem (i.e. the input is not
UTF-8).

2010/8/10 Rasmus Svensson :
> 2010/8/10 limux :
>> There is some chinese chararters in the tables. I want to display them
>> by hiccup, but browser display those chinese character as ???.
>
> I spoke to him on #clojure and from what I could tell from some
> experiments I asked him to run:
>
> (map int "刘孟江") -> (21016 23391 27743)
>=> no source file encoding issues
>
> (.name (java.nio.charset.Charset/defaultCharset)) -> "GBK"
>=> his OS default encoding is GBK ("GBK is an extension of the
> GB2312 character set for simplified Chinese characters, used in the
> People's Republic of China.")
> some libs might erroneously rely on that the OS default
> encoding is UTF-8 or something else
>
> (defroutes app (GET "/" [] (java.io.ByteArrayInputStream. (.getBytes
> "刘孟江" "UTF-8" -> showed
> up correctly
>=> works, since we do the encoding ourselves
>
> (defroutes app (GET "/" [] " http-equiv='Content-Type' content='text/html;
> charset=UTF-8'>刘孟江")) -> showed up
> correctly
>=> ring uses UTF-8 as the default encoding no matter what the OS
> default is. a very reasonable behavior, since then the result is
> always deterministic.
>
> This leaves me to the conclusion that the error is caused by hiccup
> somehow (which he also used), since everything seems to work fine
> without it. I might look into this later this evening to see if I can
> reproduce the error that occurred for him.
>
> // raek, your encoding wizard
>
> --
> 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



-- 
Communication is essential. So we need decent tools when communication
is lacking, when language capability is hard to acquire...

- http://esperanto.net  - http://esperanto-jongeren.nl

Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004

-- 
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: How to construct Set

2010-08-10 Thread Nikita Beloglazov
>
> If the JGraphT constructor takes say 2 args arg1 and arg2, you'll just
> write
> (let [graph (JGraphT. arg1 arg2)] ) and every side will be happy:
> clojure, and java.
>

And when you need to add vertex or edge you create it and add.
If you need to get edge (e.g. getEdge(...) method) you just call it with
appropriate vertexes and it will return edge. And you assume that it will
return object of the same type, you've added.



On Wed, Aug 11, 2010 at 12:25 AM, Laurent PETIT wrote:

> 2010/8/10 Tim Daly 
>
> This code uses the JGraphT graphing package which
>> wants to create a graph where the types of the
>> vertices and edges are generics, as in:
>>
>> JGraphT graph = 
>>
>> and I'm at a loss for how to instantiate a graph in clojure.
>
>
> Tim, Generics in java are there only for making the java compiler happy
> (err sorry, in order for the compiler to help you write more robust code ;-)
> ). They are lost (erased) at runtime, even in "pure java".
>
> So you just don't need to care for generics when instanciating objects from
> clojure, even with java interoperability in mind.
>
> If the JGraphT constructor takes say 2 args arg1 and arg2, you'll just
> write
> (let [graph (JGraphT. arg1 arg2)] ) and every side will be happy:
> clojure, and java.
>
>
>>
>>
>> Armando Blancas wrote:
>>
>>> If you must use Java's HashSet, you can use it untyped:
>>>
>>> user=> (deftype MyType [])
>>> user.MyType
>>> user=> (def my-set (HashSet.))
>>> #'user/my-set
>>> user=> (.add my-set (MyType.))
>>> true
>>> user=> (.add my-set (java.util.Date.))
>>> true
>>>
>>> If you need to enforce the use of a type, use a checked set:
>>>
>>> user=> (def checked (java.util.Collections/checkedSet my-set MyType))
>>> #'user/checked
>>> user=> (.add checked (MyType.))
>>> true
>>> user=> (.add checked (java.util.Date.))
>>> java.lang.ClassCastException: Attempt to insert class java.util.Date
>>> element
>>> into collection with element type class user.MyType (NO_SOURCE_FILE:0)
>>>
>>> On Aug 10, 1:40 pm, Tim Daly  wrote:
>>>
>>>
 I have java code that reads:

 Set s = new HashSet();

 I don't know how to write the parameter  in clojure
 where MyType is a Java class.



 Laurent PETIT wrote:


> 2010/8/10 Tim Daly  >
>  How do I construct
> Set s = new HashSet();
>in clojure?
>  Can you be more precise about the context of what you're trying to
> achieve ?
>  'cause the naive answer to your question is
>  (def s #{})
> or
> (let [s #{}] ...)
>  but I think you have a usecase in mind I'm not clearling seeing
> yet
> from your question ...
>  --
> 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- Hide quoted text -
>
>
 - Show quoted text -


>>>
>>>
>>>
>>
>> --
>> 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: How to construct Set

2010-08-10 Thread Meikel Brandmeyer
Hi,

Am 10.08.2010 um 23:22 schrieb Tim Daly:

> This code uses the JGraphT graphing package which
> wants to create a graph where the types of the
> vertices and edges are generics, as in:
> 
> JGraphT graph = 
> 
> and I'm at a loss for how to instantiate a graph in clojure.

Just leave away the generics. (let [graph (JGraphT.)] ...)

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: How to construct Set

2010-08-10 Thread Laurent PETIT
2010/8/10 Tim Daly 

> This code uses the JGraphT graphing package which
> wants to create a graph where the types of the
> vertices and edges are generics, as in:
>
> JGraphT graph = 
>
> and I'm at a loss for how to instantiate a graph in clojure.


Tim, Generics in java are there only for making the java compiler happy (err
sorry, in order for the compiler to help you write more robust code ;-) ).
They are lost (erased) at runtime, even in "pure java".

So you just don't need to care for generics when instanciating objects from
clojure, even with java interoperability in mind.

If the JGraphT constructor takes say 2 args arg1 and arg2, you'll just write

(let [graph (JGraphT. arg1 arg2)] ) and every side will be happy:
clojure, and java.


>
>
> Armando Blancas wrote:
>
>> If you must use Java's HashSet, you can use it untyped:
>>
>> user=> (deftype MyType [])
>> user.MyType
>> user=> (def my-set (HashSet.))
>> #'user/my-set
>> user=> (.add my-set (MyType.))
>> true
>> user=> (.add my-set (java.util.Date.))
>> true
>>
>> If you need to enforce the use of a type, use a checked set:
>>
>> user=> (def checked (java.util.Collections/checkedSet my-set MyType))
>> #'user/checked
>> user=> (.add checked (MyType.))
>> true
>> user=> (.add checked (java.util.Date.))
>> java.lang.ClassCastException: Attempt to insert class java.util.Date
>> element
>> into collection with element type class user.MyType (NO_SOURCE_FILE:0)
>>
>> On Aug 10, 1:40 pm, Tim Daly  wrote:
>>
>>
>>> I have java code that reads:
>>>
>>> Set s = new HashSet();
>>>
>>> I don't know how to write the parameter  in clojure
>>> where MyType is a Java class.
>>>
>>>
>>>
>>> Laurent PETIT wrote:
>>>
>>>
 2010/8/10 Tim Daly >>> >
  How do I construct
 Set s = new HashSet();
in clojure?
  Can you be more precise about the context of what you're trying to
 achieve ?
  'cause the naive answer to your question is
  (def s #{})
 or
 (let [s #{}] ...)
  but I think you have a usecase in mind I'm not clearling seeing yet
 from your question ...
  --
 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- Hide quoted text -


>>> - Show quoted text -
>>>
>>>
>>
>>
>>
>
> --
> 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: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Alan
Similar experience here. For what it's worth, I found that emacs/swank
made my wildest dreams come true - if you're willing to put in the
effort to learn emacs, you'll love emacs for clojure as much as you
love eclipse for java.

On Aug 10, 11:38 am, gammelgedden  wrote:
> Now we are at  eclipse / clojure, I ahave had some issues.
>
> I love eclipse, have used it a lot with java, but i could not get it
> working satisfactorily with cloure and ccw. Hopefully unjustified.
>
> I am using windows (XP). My issues were that as soon as I had had some
> compilation error (in ccw) i got spurious errors and the workspace
> would never get back to functioning after this. i had to close down
> eclipse and start over to get it in a sound state.
>
> the errors were related to the class files in the bin directory. ccw
> could not overwrite class files with new versions after recompilation.
> I think eclipse/ccw was prevented from overwritring class files (by
> windows file locking) because they were still kept open by repl or
> comilation - I assume it is caused by the Windows file locking (in
> contrast to unix/linux where these errors could probably not occur) .
> Unfortunately i dont have the precise error mesages because I gave up
> on using ccw.
>
> is that an issue you are aware of, or have heard of before?
>
> This was an issue that was also very much present in early versions of
> clojure itself. If you had a load error on a file from the repl you
> could not go in with your editor and save a corrected version, because
> clojre repl still kept the file open.
>
> thanks,
> regards GG

-- 
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: How to construct Set

2010-08-10 Thread Alan
Depends on what you mean by that. If you mean, create a hashset for
use in clojure that will only accept MyType objects, I'll defer to
someone here who knows more clojure than I do, though it looks like
metadata preconditions are the way to go.

If you mean, create a hashset you can pass to Java objects and it will
(a) accept only MyType objects, and (b) not require casting when
getting elements out of it: it's not possible. Java's generics are a
source-level convenience, and a HashSet won't contain any reference
to the E with which it was constructed.

On Aug 10, 1:06 pm, Tim Daly  wrote:
> How do I construct
>   Set s = new HashSet();
> in clojure?

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


Can't get my nesting right

2010-08-10 Thread Alan
I have the following function as part of a card-game system I'm
developing:

(defn make-suit
  [suit owner ranks]
{suit (map (partial struct-map card
:suit suit
:owner owner
:rank)
ranks)})

(make-suit :spade :west [9 5]) yields

{:spade
  ({:suit :spade, :owner :west, :rank 9}
   {:suit :spade, :owner :west, :rank 5})}

which is exactly what I want. But I have failed countless times to
define a make-hand function - I'd like to be able to call (make-
hand :west {:spade [9 5], :club [10]}) and get back

{:spade
 ({:suit :spade, :owner :west, :rank 9}
  {:suit :spade, :owner :west, :rank 5}),
 :club
 ({:suit :club, :owner :west, :rank 10})}

Can someone put me on the right track? I'm sure the solution for this
is trivially simple but I can't quite find 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


Re: How to construct Set

2010-08-10 Thread Tim Daly

This code uses the JGraphT graphing package which
wants to create a graph where the types of the
vertices and edges are generics, as in:

JGraphT graph = 

and I'm at a loss for how to instantiate a graph in clojure.

Armando Blancas wrote:

If you must use Java's HashSet, you can use it untyped:

user=> (deftype MyType [])
user.MyType
user=> (def my-set (HashSet.))
#'user/my-set
user=> (.add my-set (MyType.))
true
user=> (.add my-set (java.util.Date.))
true

If you need to enforce the use of a type, use a checked set:

user=> (def checked (java.util.Collections/checkedSet my-set MyType))
#'user/checked
user=> (.add checked (MyType.))
true
user=> (.add checked (java.util.Date.))
java.lang.ClassCastException: Attempt to insert class java.util.Date
element
into collection with element type class user.MyType (NO_SOURCE_FILE:0)

On Aug 10, 1:40 pm, Tim Daly  wrote:
  

I have java code that reads:

Set s = new HashSet();

I don't know how to write the parameter  in clojure
where MyType is a Java class.



Laurent PETIT wrote:


2010/8/10 Tim Daly mailto:d...@axiom-developer.org>>
  
How do I construct

 Set s = new HashSet();
in clojure?
  
Can you be more precise about the context of what you're trying to

achieve ?
  
'cause the naive answer to your question is
  
(def s #{})

or
(let [s #{}] ...)
  
but I think you have a usecase in mind I'm not clearling seeing yet

from your question ...
  
--

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- Hide quoted text -
  

- Show quoted text -



  


--
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: How to construct Set

2010-08-10 Thread Tim Daly

All of the code I'm trying to convert uses generics everywhere.
I don't know how to construct a generic in clojure.
Is there a syntax for it?

For instance, I have a graph of nodes of type Chart.
They are stored in the graph where the nodes are kept as:

Set nodes =

Can I construct a type hint ^Set ?

Nikita Beloglazov wrote:

Hi, Tim
Can you describe you task?
Sets (and other collections) in clojure don't use generics, as I know. 
You can add element to set and check if set contains element. Why do 
you need MyType? To allow add only MyType elements in set?


On Tue, Aug 10, 2010 at 11:40 PM, Tim Daly > wrote:


I have java code that reads:


Set s = new HashSet();

I don't know how to write the parameter  in clojure
where MyType is a Java class.

Laurent PETIT wrote:

2010/8/10 Tim Daly mailto:d...@axiom-developer.org>
>>


   How do I construct
Set s = new HashSet();
   in clojure?


Can you be more precise about the context of what you're
trying to achieve ?


'cause the naive answer to your question is

(def s #{})
or
(let [s #{}] ...)

but I think you have a usecase in mind I'm not clearling
seeing yet from your question ...

-- 
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: How to construct Set

2010-08-10 Thread Armando Blancas
If you must use Java's HashSet, you can use it untyped:

user=> (deftype MyType [])
user.MyType
user=> (def my-set (HashSet.))
#'user/my-set
user=> (.add my-set (MyType.))
true
user=> (.add my-set (java.util.Date.))
true

If you need to enforce the use of a type, use a checked set:

user=> (def checked (java.util.Collections/checkedSet my-set MyType))
#'user/checked
user=> (.add checked (MyType.))
true
user=> (.add checked (java.util.Date.))
java.lang.ClassCastException: Attempt to insert class java.util.Date
element
into collection with element type class user.MyType (NO_SOURCE_FILE:0)

On Aug 10, 1:40 pm, Tim Daly  wrote:
> I have java code that reads:
>
> Set s = new HashSet();
>
> I don't know how to write the parameter  in clojure
> where MyType is a Java class.
>
>
>
> Laurent PETIT wrote:
> > 2010/8/10 Tim Daly  > >
>
> >     How do I construct
> >      Set s = new HashSet();
> >     in clojure?
>
> > Can you be more precise about the context of what you're trying to
> > achieve ?
>
> > 'cause the naive answer to your question is
>
> > (def s #{})
> > or
> > (let [s #{}] ...)
>
> > but I think you have a usecase in mind I'm not clearling seeing yet
> > from your question ...
>
> > --
> > 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- Hide quoted text -
>
> - Show quoted text -

-- 
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: How to construct Set

2010-08-10 Thread Nikita Beloglazov
Hi, Tim
Can you describe you task?
Sets (and other collections) in clojure don't use generics, as I know. You
can add element to set and check if set contains element. Why do you need
MyType? To allow add only MyType elements in set?

On Tue, Aug 10, 2010 at 11:40 PM, Tim Daly  wrote:

> I have java code that reads:
>
>
> Set s = new HashSet();
>
> I don't know how to write the parameter  in clojure
> where MyType is a Java class.
>
> Laurent PETIT wrote:
>
>> 2010/8/10 Tim Daly > d...@axiom-developer.org>>
>>
>>
>>How do I construct
>> Set s = new HashSet();
>>in clojure?
>>
>>
>> Can you be more precise about the context of what you're trying to achieve
>> ?
>>
>>
>> 'cause the naive answer to your question is
>>
>> (def s #{})
>> or
>> (let [s #{}] ...)
>>
>> but I think you have a usecase in mind I'm not clearling seeing yet from
>> your question ...
>>
>> --
>> 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: How to construct Set

2010-08-10 Thread Tim Daly

I have java code that reads:

Set s = new HashSet();

I don't know how to write the parameter  in clojure
where MyType is a Java class.

Laurent PETIT wrote:
2010/8/10 Tim Daly >


How do I construct
 Set s = new HashSet();
in clojure?


Can you be more precise about the context of what you're trying to 
achieve ?



'cause the naive answer to your question is

(def s #{})
or
(let [s #{}] ...)

but I think you have a usecase in mind I'm not clearling seeing yet 
from your question ...


--
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: chinese character in hiccup

2010-08-10 Thread Rasmus Svensson
I looked into the source of hiccup and tried entering the string "刘孟江"
at various places, but I couldn't reproduce the error or find any code
that did any form of encoding.

When playing around with the repl, I was reminded that JLine (used by
lein repl) does not support multibyte encodings (including UTF-8 and
GBK). Could this be the problem, Limux?

// raek

-- 
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: How to construct Set

2010-08-10 Thread Laurent PETIT
2010/8/10 Tim Daly 

> How do I construct
>  Set s = new HashSet();
> in clojure?
>

Can you be more precise about the context of what you're trying to achieve ?


'cause the naive answer to your question is

(def s #{})
or
(let [s #{}] ...)

but I think you have a usecase in mind I'm not clearling seeing yet from
your question ...

-- 
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: Bug in try/finally?

2010-08-10 Thread Chouser
On Tue, Aug 10, 2010 at 2:51 PM, Chouser  wrote:
>
> That patch seems to essentially reverse this one:
>
> http://github.com/clojure/clojure/commit/5e9f2b293b307aa7953cd390360d24549e542b92
>
> ...which suggests to me there must be a better solution, though I
> don't see yet what it would be.

Ok, it looks to me like the above commit was an insufficient
solution for the problem it was trying to solve.  Since the
content of the finally block is emitted after the main try
block as well as after each catch block, a single finally handler
for all them together (which is what the above commit does)
cannot avoid potentially re-running some parts of the finally
clause.

To see what javac emits in similar circumstances, I wrote
a foo.java and disassmbled it here: http://gist.github.com/517865

It looks like javac protects the try block and each catch block
individually with separate entries in the exception table, all of
them pointing to the final finally block.

The patch at the top of that gist attempts to do the same thing,
and also fully reverses the earlier "endTryCatch" commit.  This
passes all tests, including new ones Joe Gallo wrote based on
reports in this thread: http://gist.github.com/517871

--Chouser
http://joyofclojure.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


How to construct Set

2010-08-10 Thread Tim Daly

How do I construct
 Set s = new HashSet();
in clojure?

--
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: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Laurent PETIT
010/8/10 gammelgedden 

>
> Thanks! I will definitely give it another try :-)
>


feedback welcome (especially for things you don't like - and how you would
like them to be - )

-- 
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: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread gammelgedden

Thanks! I will definitely give it another try :-)

-- 
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: M-x clojure-mode in Slime REPL disables REPL

2010-08-10 Thread Steve Purcell
On 10 Aug 2010, at 19:19, Mike Meyer wrote:

> On Tue, 10 Aug 2010 09:57:02 -0700 (PDT)
> Alexis Rondeau  wrote:
>> What I would like to do is to enable clojure-mode when I get my REPL
>> (connected either via swank-clojure-project or lein swank/M-x slime-
>> connect) but whenever I do M-x clojure-mode, the REPL stops (I think)
>> evaluating. While the syntax highlighting does take effect, writing an
>> expression and pressing Enter yields nothing. The message I get is
>> 'Buffer is read-only".
> 
> I think you're wanting something that's not possible. Not very
> desirable, for that matter.
> 
> The repl buffer is a nice tool for communicating with a running
> clojure, so it binds Enter to slime-repl-return, which evaluates the
> current input string. clojure-mode is meant for editing clojure code,
> so it binds Enter to newline-and-indent-relative, to make it easy to
> type the next line in your clojure program. Turning on clojure-mode in
> the repl rebinds Enter (and probably other things), thus breaking them
> in the repl.
> 
> While you could write a mode that did what you want, I don't think
> anyone has done it yet. The issue is that code you edit in the repl
> isn't saved anywhere if the repl exits. Normally, you create a file
> for your clojure code, and edit that in clojure mode. That gives you
> commands to send functions (and etc.)  to the repl so you can test
> them.


You can, however, make the slime REPL better aware of Clojure syntax (and 
font-locking). See the function slime-clojure-repl-setup in my emacs config 
here: http://github.com/purcell/emacs.d/blob/master/init-clojure.el

-Steve

-- 
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: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Laurent PETIT
Hi,

sad you gave up on ccw :-(.

Let's address your point, though ...

2010/8/10 gammelgedden 

> Now we are at  eclipse / clojure, I ahave had some issues.
>
> I love eclipse, have used it a lot with java, but i could not get it
> working satisfactorily with cloure and ccw. Hopefully unjustified.
>
> I am using windows (XP). My issues were that as soon as I had had some
> compilation error (in ccw) i got spurious errors and the workspace
> would never get back to functioning after this. i had to close down
> eclipse and start over to get it in a sound state.
>
> the errors were related to the class files in the bin directory. ccw
> could not overwrite class files with new versions after recompilation.
> I think eclipse/ccw was prevented from overwritring class files (by
> windows file locking) because they were still kept open by repl or
> comilation - I assume it is caused by the Windows file locking (in
> contrast to unix/linux where these errors could probably not occur) .
> Unfortunately i dont have the precise error mesages because I gave up
> on using ccw.
>
> is that an issue you are aware of, or have heard of before?
>

Yes, we were aware of it. I've also hopefully managed to get rid of it a few
releases ago (in June? in July? I don't remember exactly).
I myself am not a regular Windows user anymore, but the tests I did with
Windows at that time seemed to prove the problem was gone. And from the
release, I didn't have any new report of such a problem.

Maybe it's time for you to give ccw another try ! :-)


>
> This was an issue that was also very much present in early versions of
> clojure itself. If you had a load error on a file from the repl you
> could not go in with your editor and save a corrected version, because
> clojre repl still kept the file open.
>


If such errors still occur for corner cases, I think the problem may still
happen from time to time. A future version of ccw will hopefully lessen the
problem, by narrowing the list of AOT compiled files vs just reloaded files.

HTH,

-- 
Laurent

-- 
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: Bug in try/finally?

2010-08-10 Thread Chouser
On Tue, Aug 10, 2010 at 1:09 PM, joegg  wrote:
> diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/
> Compiler.java
> index f5684f1..af55660 100644
> --- a/src/jvm/clojure/lang/Compiler.java
> +++ b/src/jvm/clojure/lang/Compiler.java
> @@ -1775,7 +1775,7 @@ public static class TryExpr implements Expr{
>                        gen.visitTryCatchBlock(startTry, endTry,
> clause.label, clause.c.getName().replace('.', '/'));
>                        }
>                if(finallyExpr != null)
> -                       gen.visitTryCatchBlock(startTry, endTryCatch,
> finallyLabel, null);
> +                       gen.visitTryCatchBlock(startTry, endTry,
> finallyLabel, null);
>                for(int i = 0; i < catchExprs.count(); i++)
>                        {
>                        CatchClause clause = (CatchClause)
> catchExprs.nth(i);
>
>
> This fixes the behavior we're seeing, but, ummm... might break other
> things, I suppose.  The tests I've written don't cover all the
> expected behavior of try/catch/finally.

That patch seems to essentially reverse this one:

http://github.com/clojure/clojure/commit/5e9f2b293b307aa7953cd390360d24549e542b92

...which suggests to me there must be a better solution, though I
don't see yet what it would be.
--Chouser

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread gammelgedden
Now we are at  eclipse / clojure, I ahave had some issues.

I love eclipse, have used it a lot with java, but i could not get it
working satisfactorily with cloure and ccw. Hopefully unjustified.

I am using windows (XP). My issues were that as soon as I had had some
compilation error (in ccw) i got spurious errors and the workspace
would never get back to functioning after this. i had to close down
eclipse and start over to get it in a sound state.

the errors were related to the class files in the bin directory. ccw
could not overwrite class files with new versions after recompilation.
I think eclipse/ccw was prevented from overwritring class files (by
windows file locking) because they were still kept open by repl or
comilation - I assume it is caused by the Windows file locking (in
contrast to unix/linux where these errors could probably not occur) .
Unfortunately i dont have the precise error mesages because I gave up
on using ccw.

is that an issue you are aware of, or have heard of before?

This was an issue that was also very much present in early versions of
clojure itself. If you had a load error on a file from the repl you
could not go in with your editor and save a corrected version, because
clojre repl still kept the file open.

thanks,
regards GG

-- 
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: M-x clojure-mode in Slime REPL disables REPL

2010-08-10 Thread Mike Meyer
On Tue, 10 Aug 2010 09:57:02 -0700 (PDT)
Alexis Rondeau  wrote:
> What I would like to do is to enable clojure-mode when I get my REPL
> (connected either via swank-clojure-project or lein swank/M-x slime-
> connect) but whenever I do M-x clojure-mode, the REPL stops (I think)
> evaluating. While the syntax highlighting does take effect, writing an
> expression and pressing Enter yields nothing. The message I get is
> 'Buffer is read-only".

I think you're wanting something that's not possible. Not very
desirable, for that matter.

The repl buffer is a nice tool for communicating with a running
clojure, so it binds Enter to slime-repl-return, which evaluates the
current input string. clojure-mode is meant for editing clojure code,
so it binds Enter to newline-and-indent-relative, to make it easy to
type the next line in your clojure program. Turning on clojure-mode in
the repl rebinds Enter (and probably other things), thus breaking them
in the repl.

While you could write a mode that did what you want, I don't think
anyone has done it yet. The issue is that code you edit in the repl
isn't saved anywhere if the repl exits. Normally, you create a file
for your clojure code, and edit that in clojure mode. That gives you
commands to send functions (and etc.)  to the repl so you can test
them.

 http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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: How to convert a sequence to a byte[]?

2010-08-10 Thread Meikel Brandmeyer
Hi,

there is also byte-array: 
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/byte-array

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: noob q: infinite loop recur

2010-08-10 Thread chepprey

To all - THANKS (especially David Sletten) for the excellent
responses!  Very helpful.

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


M-x clojure-mode in Slime REPL disables REPL

2010-08-10 Thread Alexis Rondeau
Hi there, I'm very new to both Clojure and Emacs, but I've come across
the following unexpected situation when wanting to activate clojure-
mode in my slime REPL:

Running Emacs 23 on OS X, installed clojure-mode, slime, slime-repl
and swank-clojure via ELPA (the same situation arises when getting
everything 'by hand', too, especially swank-clojure).

What I would like to do is to enable clojure-mode when I get my REPL
(connected either via swank-clojure-project or lein swank/M-x slime-
connect) but whenever I do M-x clojure-mode, the REPL stops (I think)
evaluating. While the syntax highlighting does take effect, writing an
expression and pressing Enter yields nothing. The message I get is
'Buffer is read-only".

I'm not sure where to turn for this, slime, clojure-mode, swank-
clojure?

Any advise is highly appreciated. Thank you for pointers!


With best wishes,


Alexis

-- 
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: How to convert a sequence to a byte[]?

2010-08-10 Thread Piotr 'Qertoip' Włodarek
On Aug 10, 7:19 pm, Janico Greifenberg  wrote:
> By into-array default, into-array returns an array of the capital-B
> Bytes (that's what the cryptic  [Ljava.lang.Byte; in the error message
> means). To get an array of primitive bytes (the class being printed as
> [B), you can pass the type as additional parameter
> (into-array Byte/TYPE mybytes)

This works perfectly fine, 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: How to convert a sequence to a byte[]?

2010-08-10 Thread Janico Greifenberg
By into-array default, into-array returns an array of the capital-B
Bytes (that's what the cryptic  [Ljava.lang.Byte; in the error message
means). To get an array of primitive bytes (the class being printed as
[B), you can pass the type as additional parameter
(into-array Byte/TYPE mybytes)

On Tue, Aug 10, 2010 at 6:05 PM, Piotr 'Qertoip' Włodarek
 wrote:
> I need to write raw bytes to the file. I do it with:
>
>    (.write (FileOutputStream "/path") bytes)
>
> ...where bytes must be of type byte[]. Please note it cannot be
> Byte[].
>
> I tried to convert my sequence with both (bytes) and/or (into-array)
> functions and got frustrated, one example:
>
>    user=> (bytes (into-array (filter #(not (= % 13)) (to-byte-array
> (File. "e:/vpn.bat")
>    java.lang.ClassCastException: [Ljava.lang.Byte; cannot be cast to
> [B (NO_SOURCE_FILE:0)
>
> --
> 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
>



-- 
http://jgre.org

-- 
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: Bug in try/finally?

2010-08-10 Thread joegg
diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/
Compiler.java
index f5684f1..af55660 100644
--- a/src/jvm/clojure/lang/Compiler.java
+++ b/src/jvm/clojure/lang/Compiler.java
@@ -1775,7 +1775,7 @@ public static class TryExpr implements Expr{
gen.visitTryCatchBlock(startTry, endTry,
clause.label, clause.c.getName().replace('.', '/'));
}
if(finallyExpr != null)
-   gen.visitTryCatchBlock(startTry, endTryCatch,
finallyLabel, null);
+   gen.visitTryCatchBlock(startTry, endTry,
finallyLabel, null);
for(int i = 0; i < catchExprs.count(); i++)
{
CatchClause clause = (CatchClause)
catchExprs.nth(i);


This fixes the behavior we're seeing, but, ummm... might break other
things, I suppose.  The tests I've written don't cover all the
expected behavior of try/catch/finally.

Joe


On Aug 10, 12:23 pm, joegg  wrote:
> Laurent,
>
> Looking through the output of javap -v, it looks to me like this is
> roughly what's been emitted (please forgive the mix of clojure and
> java):
>
> try {
>   (prn :test)
>   (swap! a inc)
>   (.foo nil)} finally {
>
>   (swap! a inc)
>   (.foo nil)
>
> }
>
> Which explains why @a is 3 -- I'm not sure this is intended, though.
>
> Joe
>
> On Aug 10, 9:52 am, Laurent PETIT  wrote:
>
>
>
>
>
>
>
> > Weird indeed:
>
> > user=> (def a (atom 1))
> > #'user/a
> > user=> (try (prn :test) (finally (swap! a inc) (.foo nil)))
> > :test
> > java.lang.NullPointerException (NO_SOURCE_FILE:0)
> > user=> @a
> > 3
>
> > I would have expected 2 as a result, in any case ?

-- 
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: chinese character in hiccup

2010-08-10 Thread Rasmus Svensson
2010/8/10 limux :
> There is some chinese chararters in the tables. I want to display them
> by hiccup, but browser display those chinese character as ???.

I spoke to him on #clojure and from what I could tell from some
experiments I asked him to run:

(map int "刘孟江") -> (21016 23391 27743)
=> no source file encoding issues

(.name (java.nio.charset.Charset/defaultCharset)) -> "GBK"
=> his OS default encoding is GBK ("GBK is an extension of the
GB2312 character set for simplified Chinese characters, used in the
People's Republic of China.")
 some libs might erroneously rely on that the OS default
encoding is UTF-8 or something else

(defroutes app (GET "/" [] (java.io.ByteArrayInputStream. (.getBytes
"刘孟江" "UTF-8" -> showed
up correctly
=> works, since we do the encoding ourselves

(defroutes app (GET "/" [] "刘孟江")) -> showed up
correctly
=> ring uses UTF-8 as the default encoding no matter what the OS
default is. a very reasonable behavior, since then the result is
always deterministic.

This leaves me to the conclusion that the error is caused by hiccup
somehow (which he also used), since everything seems to work fine
without it. I might look into this later this evening to see if I can
reproduce the error that occurred for him.

// raek, your encoding wizard

-- 
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: Bug in try/finally?

2010-08-10 Thread joegg
Laurent,

Looking through the output of javap -v, it looks to me like this is
roughly what's been emitted (please forgive the mix of clojure and
java):

try {
  (prn :test)
  (swap! a inc)
  (.foo nil)
} finally {
  (swap! a inc)
  (.foo nil)
}

Which explains why @a is 3 -- I'm not sure this is intended, though.

Joe

On Aug 10, 9:52 am, Laurent PETIT  wrote:
> Weird indeed:
>
> user=> (def a (atom 1))
> #'user/a
> user=> (try (prn :test) (finally (swap! a inc) (.foo nil)))
> :test
> java.lang.NullPointerException (NO_SOURCE_FILE:0)
> user=> @a
> 3
>
> I would have expected 2 as a result, in any case ?
>

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


How to convert a sequence to a byte[]?

2010-08-10 Thread Piotr 'Qertoip' Włodarek
I need to write raw bytes to the file. I do it with:

(.write (FileOutputStream "/path") bytes)

...where bytes must be of type byte[]. Please note it cannot be
Byte[].

I tried to convert my sequence with both (bytes) and/or (into-array)
functions and got frustrated, one example:

user=> (bytes (into-array (filter #(not (= % 13)) (to-byte-array
(File. "e:/vpn.bat")
java.lang.ClassCastException: [Ljava.lang.Byte; cannot be cast to
[B (NO_SOURCE_FILE:0)

-- 
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: jna Java Native Acess and clojure ....

2010-08-10 Thread Frederick Polgardy
Access to C/C++ is only available via JNI, which requires a bit of technical 
understanding about the Java-C bridge. Are you just trying to make use of a C++ 
library you already have, for which there is no pure Java equivalent?

-Fred

--
Science answers questions; philosophy questions answers.

On Aug 10, 2010, at 6:29 AM, Sunil S Nandihalli wrote:

> Thanks Mac for your clarification .. I am using clojure 1.2 .. so should be 
> fine. And I was wondering if I can acess c++ stuff via clj-native .. What are 
> your suggestions?
> Sunil
> 
> On Tue, Aug 10, 2010 at 12:45 PM, mac  wrote:
> I'm the author of clj-native.
> Currently it only works with Clojure 1.2. In retrospect I should have
> made a separate branch when dropping 1.1 support.
> If you need 1.1 support, just tell me and I could make a branch for it
> since the changes required should be small.
> 
> /Markus
> 
> On Aug 9, 5:31 pm, Chouser  wrote:
> > On Mon, Aug 9, 2010 at 10:55 AM, Sunil Nandihalli
> >
> >  wrote:
> > > Hello everybody,
> > >  I have been trying to use the native libraries in clojure. I have
> > > found clj-native and clojure-jna which may serve the purposes. I would
> > > like to get a feed back from the community .. Which of these is good
> > > to use .. Or do you have any other suggestions..
> >
> > I wrote clojure-jna, but although I haven't had a chance to use
> > clj-native yet I understand it's significantly more advanced and
> > efficient than clojure-jna.  So I'd recommend at least starting with
> > clj-native to see if it will meet your needs.
> >
> > --Chouserhttp://joyofclojure.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
> 
> 
> -- 
> 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: chinese character in hiccup

2010-08-10 Thread Joop Kiefte
Try using [:meta {:http-equiv "Content-Type" :content "text/html;
charset=utf-8"}] inside your [:head]

(can this be done with Jetty?)

2010/8/10 limux :
> hi!
>
> I am doing a real-file demo with ring, compojure, hiccup, and database
> access as well.
> There is some chinese chararters in the tables. I want to display them
> by hiccup, but browser display those chinese character as ???. But the
> prn to console is ok. I am confused since I was a newbie in Clojure
> and not very familiar with Java yet.
> Also, There is extractly not very much people who are using or
> familiar with Clojure in china(known as myself). even some of famous
> IT web or blog does not have many articles about Clojure to put on. So
> there is no any where or any one I can get help.
>
> I uses Windows 7 as the dev platform. Heartly thanks of advices!
>
> Limux,
> Regards.
>
> --
> 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



-- 
Communication is essential. So we need decent tools when communication
is lacking, when language capability is hard to acquire...

- http://esperanto.net  - http://esperanto-jongeren.nl

Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004

-- 
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: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Laurent PETIT
2010/8/10 garf 

> thanks for the answer.  I suspect that the REPL dieing is justified,
> as I tend to use the file as workspace with somethings uncompleted,
> and with my newness to Clojure in general, I am often doing things in
> ways that are not correct
>


This may explain that.

FYI, there's a rework of the REPL stuff currently, so in Q3 or Q4 of 2010,
expect to have an even better user experience !

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Nicolas Oury
On Tue, Aug 10, 2010 at 11:23 AM, Will M. Farr  wrot>
> Sorry for the digression; I hope people find it interesting.
I found it interesting.

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Will M. Farr
Maybe this point about Racket is too off-topic for the list, but:

On Aug 10, 2010, at 4:55 AM, Mark Engelberg wrote:

> Generally speaking, I find I do not have to worry about "blowing the
> stack" in Scheme, and as a result, non-tail-call structural recursion
> (such as the algorithm that kicked off this thread) is perfectly
> idiomatic in the implementations of Scheme I have used (mostly
> Racket).  In Clojure, I find stack limitations are a real issue unless
> I transform the algorithms into a tail-recursive accumulator style.
> For lists, it's usually not hard.  For trees, it can be a bit of a
> pain.

You don't worry about blowing the stack in Racket with recursion because they 
implement stack copying particularly elegantly: when you are about to blow the 
stack, the stack is copied to the heap and then blown away.  A "handler" 
procedure is called (i.e. placed on the top of the stack), and then your 
computation proceeds.  When you return your way back to the handler, it recalls 
the previous stack from the heap, jumps to the bottom of it, and your 
computation proceeds.  In effect, the stack is treated as a limited-size window 
into the heap, so you will never run out of stack until you run out of heap.  
It's a neat trick, and could (in principle) be done on the JVM, but probably 
involves a significant speed trade-off even for code that doesn't take 
advantage of it.  (The only way I can think of doing it is to follow the 
process outlined in "Continuations from Generalized Stack Inspection" by the 
PLT Folks, which requires installing an exception handler around each procedure 
to catch stack-overflow exceptions and "re-build" the current continuation on 
the heap.)

I suspect that Chicken, with its "the Stack is the first generation of a 
copying generational garbage collector" would also have this "unlimited stack" 
property, but I don't know about the other Schemes---it's certainly standards 
complying to blow up when you run out of stack.

Sorry for the digression; I hope people find it interesting.

Will

-- 
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: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread garf
thanks for the answer.  I suspect that the REPL dieing is justified,
as I tend to use the file as workspace with somethings uncompleted,
and with my newness to Clojure in general, I am often doing things in
ways that are not correct

On Aug 10, 8:21 am, Laurent PETIT  wrote:
> 2010/8/10 garf 
>
> > On occasion the REPL in Eclipse will stop taking input, or will fail
> > to recognize a function I have just defined.  Is there a simple way to
> > get the REPL to restart, or break out of its current state?
>
> Hi, I don't know why your REPL is not responding anymore, and maybe we
> should try to find whether it's justified or not.
> Anyway, to answer your question: Hit the red button in the REPL's view: this
> will kill the process (and thus the REPL). And then start a new REPL. You
> can also get rid of the old REPL's log histories by hitting the grey cross.
>
>
>
> > One other question as well, to get the REPL running when I first bring
> > up Eclipse I have a file that runs a few tests.  Then I switch over to
> > the file that I am working on.  I notice the namespace that is shown
> > in the REPL remains in the original test namespace.  Does that mean
> > that all the definitions I am getting with selecting code tidbits &
> > then using cntrl-alt-x are in the test namespace?
>
> Currently, yes.
> (BTW, what you see colored in green in the REPL is what ccw "typed" for you
> automatically, no more no less.)

-- 
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: Cannot sen msg to #clojure channel

2010-08-10 Thread Laurent PETIT
You need to register with NickServ, e.g.
/msg NickServ identify 

It's a protection so that nobody else uses limux1972 when you're not online.

(you also need to register limux1972, but I don't remember how)

2010/8/10 limux 

> Why? My nickname in #clojure is limux1972.
>
> --
> 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

Cannot sen msg to #clojure channel

2010-08-10 Thread limux
Why? My nickname in #clojure is limux1972.

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


chinese character in hiccup

2010-08-10 Thread limux
hi!

I am doing a real-file demo with ring, compojure, hiccup, and database
access as well.
There is some chinese chararters in the tables. I want to display them
by hiccup, but browser display those chinese character as ???. But the
prn to console is ok. I am confused since I was a newbie in Clojure
and not very familiar with Java yet.
Also, There is extractly not very much people who are using or
familiar with Clojure in china(known as myself). even some of famous
IT web or blog does not have many articles about Clojure to put on. So
there is no any where or any one I can get help.

I uses Windows 7 as the dev platform. Heartly thanks of advices!

Limux,
Regards.

-- 
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: noob q: infinite loop recur

2010-08-10 Thread Meikel Brandmeyer
Hi,

On Aug 10, 3:48 pm, David Sletten  wrote:

> Notice how Clojure returns two different values here. Other Lisps (such as 
> Common Lisp) define FIRST/REST of the empty list to both be NIL (i.e., the 
> empty list itself). So it is common in other Lisps to test for the end of a 
> list using the equivalent of 'nil?', namely the function NULL. But in Clojure 
> if we are traversing a list and looking for the end, the correct function is 
> 'empty?'.
> (nil? '()) => false
> (empty? '()) => true

The idiomatic way to test for emptiness is actually to use seq. empty?
is actually defined as (empty? x) := (not (seq x)).

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: Eclipse and Compojure

2010-08-10 Thread Rasmus Svensson
> I assume the problem is that there are no .class files in the jar. I
> tried to rebuild the compojure jar using "lein jar" but still didn't
> get .class files, even though:

Clojure looks for both .class files and .clj files, so you don't need
to compile anything manually.

> I'm seeing the following error:
> java.io.FileNotFoundException: Could not locate compojure/
> core__init.class or compojure/core.clj on classpath:core.clj/web-
> app-adder/src/adder line 1  Clojure Compilation Problem

As you can see, it actually said that it looked for:

1) compojure/core__init.class
2) compojure/core.clj

and didn't find any of them. This means that the compojure jar file is
not on the CLASSPATH somehow. I'm not a clojure + eclipse user, so I
can't give you any advice on how to setup eclipse so that it uses the
correct CLASSPATH . But one thing that might be useful to know is
that, for the JVM, jar files counts as directories. Thus you might
have to add the paths to all the jar file, not the directory that
contains them.

I hope that this could be helpful, or perhaps narrow down your
debugging a little...

// raek

-- 
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: Eclipse and Compojure

2010-08-10 Thread Laurent PETIT
2010/8/10 Rasmus Svensson 

> > I assume the problem is that there are no .class files in the jar. I
> > tried to rebuild the compojure jar using "lein jar" but still didn't
> > get .class files, even though:
>
> Clojure looks for both .class files and .clj files, so you don't need
> to compile anything manually.
>
> > I'm seeing the following error:
> > java.io.FileNotFoundException: Could not locate compojure/
> > core__init.class or compojure/core.clj on classpath:core.clj
>  /web-
> > app-adder/src/adder line 1  Clojure Compilation Problem
>
> As you can see, it actually said that it looked for:
>
> 1) compojure/core__init.class
> 2) compojure/core.clj
>
> and didn't find any of them. This means that the compojure jar file is
> not on the CLASSPATH somehow. I'm not a clojure + eclipse user, so I
> can't give you any advice on how to setup eclipse so that it uses the
> correct CLASSPATH . But one thing that might be useful to know is
> that, for the JVM, jar files counts as directories. Thus you might
> have to add the paths to all the jar file, not the directory that
> contains them.
>
> I hope that this could be helpful, or perhaps narrow down your
> debugging a little...
>
>
> Yes, probably, a REPL/environment was already running, and thus adding the
jars to the project's classpath didn't reflect automatically in the launched
environment. And then stopping the env and running a fresh one did the job.
So not specifically a problem with ccw, AFAICT

-- 
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: Bug in try/finally?

2010-08-10 Thread Laurent PETIT
Weird indeed:

user=> (def a (atom 1))
#'user/a
user=> (try (prn :test) (finally (swap! a inc) (.foo nil)))
:test
java.lang.NullPointerException (NO_SOURCE_FILE:0)
user=> @a
3

I would have expected 2 as a result, in any case ?

2010/8/10 Meikel Brandmeyer 

> Hi,
>
> On Aug 10, 8:36 am, Brian Stiles  wrote:
>
> > The following succeeds:
> >
> > (try
> >   (prn 1)
> >   (finally
> >(prn 2)
> >(doto (System/out) (.print "-") (.println "-"
> >
> > prints:
> >
> > 1
> > 2
> > --
> >
> > The following fails (note the odd duplication of "2" in the output):
> >
> > (try
> >   (prn 1)
> >   (finally
> >(prn 2)
> >(.. (System/out) (print "-") (println "-"
> >
> > prints:
> >
> > 1
> > 2
> > -2
> > -Exception in thread "main" java.lang.NullPointerException
>
> Of course it fails, because print is a void method and hence "returns"
> nil. So you are calling print on nil leading to the NPE.
>
> Why the 2 is printed twice... good question:
>
> user=> (try (prn 1) (finally (prn 2) (.foo nil)))
> 1
> 2
> 2
> java.lang.NullPointerException (NO_SOURCE_FILE:0)
> user=> (let [] (try (prn 1) (finally (prn 2) (.foo nil
> 1
> 2
> 2
> java.lang.NullPointerException (NO_SOURCE_FILE:0)
> user=> (let [a (atom 2)] (try (prn 1) (finally (prn @a) (.foo nil
> 1
> 2
> java.lang.NullPointerException (NO_SOURCE_FILE:0)
> user=> (def a (atom 2))
> #'user/a
> user=> (try (prn 1) (finally (prn @a) (.foo nil)))
> 1
> 2
> 2
> java.lang.NullPointerException (NO_SOURCE_FILE:0)
>
> 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
>

-- 
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: noob q: infinite loop recur

2010-08-10 Thread David Sletten

On Aug 9, 2010, at 11:52 PM, chepprey wrote:
> 
> (defn show [words]
>   (let [word (first words)]
>   (do
>   (println word)
>   (if (nil? word)
>   (println "DONE")
>   (recur (rest words))
> 
> (show '("some" "sample" "words"))
> 
> ... this shows the 3 words, then DONE, and terminates.

Your program works but maybe not the way you think it does. The first issue is 
related to an idiosyncrasy of other Lisps compared to Clojure. It's easy to 
understand the basic behavior of 'first' and 'rest':
(first '(a b c)) => a
(rest '(a b c)) => (b c)

However, what happens when we look at the empty list?
(first '()) => nil
(rest '()) => ()

Notice how Clojure returns two different values here. Other Lisps (such as 
Common Lisp) define FIRST/REST of the empty list to both be NIL (i.e., the 
empty list itself). So it is common in other Lisps to test for the end of a 
list using the equivalent of 'nil?', namely the function NULL. But in Clojure 
if we are traversing a list and looking for the end, the correct function is 
'empty?'. 
(nil? '()) => false
(empty? '()) => true

Furthermore, in your example you are testing whether the current first element 
is nil rather than checking that the list itself is empty. Your test should be 
(if (empty? words) ...). Your program eventually terminated because once your 
list was empty the first element was evaluated to be nil as above.

> 
> But originally, I was trying to use loop/recur.  If I replace the
> "let" with "loop" in the above code, it goes into an infinite loop.  I
> assume there's something different in the scoping/binding rules with
> loop, but I can't find a good explanation of what.  I read in
> "Programming Clojure", regarding loop, that it "...works like let,
> establishing bindings and then evaluating exprs..."
> 

This is a separate issue. It is true that 'loop' establishes bindings, however, 
it is your responsibility to update those bindings on each iteration through 
the loop by means of the 'recur' form. Your 'recur' confuses the distinction 
between the variables 'words' and 'word'. On the initial loop iteration, the 
variable 'word' is assigned the value of the first element of 'words'. But on 
the next iteration (and all others) your recur passes the rest of 'words' as 
the new value of 'word'. So in your example we wind up with this:
1. word <- "some"
2. word <- ("sample" "words")

Obviously this 2-element list is never 'nil?', and the recur form keeps 
reassigning the same value forever.

Instead, you need to rebind the variable 'words' to subsequent tails of the 
original list:
(defn show [words]
  (loop [l words]
(println (first l))
(if (empty? l)
  (println "DONE")
  (recur (rest l)

And you probably want to test for the end of list before you print anything:
(defn show [words]
  (loop [l words]
(if (empty? l)
  (println "DONE")
  (do
(println (first l))
(recur (rest l ))



Have all good days,
David Sletten




-- 
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: noob q: infinite loop recur

2010-08-10 Thread Meikel Brandmeyer
Hi,

On Aug 10, 3:13 pm, Laurent PETIT  wrote:

> next is more eager than rest, but in a loop scenario, I generally use next
> since we'll test for nil in order to know whether to continue to iterate or
> not.

I generally use next when I know that I need to realise anyway soon.
As Laurent said: this happens a lot in loop. Would we use rest, we
would have to check with seq whether the sequence is exhausted. If we
do this anyway, we can just as well use next and save the seq call.

Another such scenario is when you need a look-ahead in a lazy
sequence. Eg. partition-by needs at least one item look-ahead in order
to decide whether to split groups or not. Then you can also use next
since you realise the next step of the input sequence anyway.

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: Bug in try/finally?

2010-08-10 Thread Adrian Cuthbertson
Hi Brian,

System/out
#
(System/out)
#

both return the "out" PrintStream object, so
(.. System/out (print "-"))
-nil
(.. (System/out) (print "-"))
-nil
(.. System/out (print "-"))
-nil

all invoke the print method on the java PrintStream object and
correctly return nil
as does...

(.print System/out "-")
-nil

which is the alternative way of invoking a method on a java object.
Your

(doto (System/out) (.print "-") (.println "-"))
--

works correctly as you're calling the two print methods on the
System/out object,

but your

(.. (System/out) (print "-") (println "-"))

is trying to pass the result of the 2nd (println "-") as a extra arg
to the call,
hence the bomb. So actually it's nothing to do with try/finally.

-Hth, Adrian.






On Tue, Aug 10, 2010 at 8:36 AM, Brian Stiles  wrote:
> The following succeeds:
>
> (try
>  (prn 1)
>  (finally
>   (prn 2)
>   (doto (System/out) (.print "-") (.println "-"
>
> prints:
>
> 1
> 2
> --
>
> The following fails (note the odd duplication of "2" in the output):
>
> (try
>  (prn 1)
>  (finally
>   (prn 2)
>   (.. (System/out) (print "-") (println "-"
>
> prints:
>
>
> 1
> 2
> -2
> -Exception in thread "main" java.lang.NullPointerException
> (NO_SOURCE_FILE:0)
>        at clojure.lang.Compiler.eval(Compiler.java:4658)
>        at clojure.core$eval__5236.invoke(core.clj:2017)
>        at clojure.main$eval_opt__7411.invoke(main.clj:227)
>        at clojure.main$initialize__7418.invoke(main.clj:246)
>        at clojure.main$null_opt__7446.invoke(main.clj:271)
>        at clojure.main$main__7466.doInvoke(main.clj:346)
>        at clojure.lang.RestFn.invoke(RestFn.java:426)
>        at clojure.lang.Var.invoke(Var.java:363)
>        at clojure.lang.AFn.applyToHelper(AFn.java:175)
>        at clojure.lang.Var.applyTo(Var.java:476)
>        at clojure.main.main(main.java:37)
> Caused by: java.lang.NullPointerException
>        at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:26)
>        at user$eval__1.invoke(NO_SOURCE_FILE:1)
>        at clojure.lang.Compiler.eval(Compiler.java:4642)
>        ... 10 more
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> 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: Bug in try/finally?

2010-08-10 Thread Christian Vest Hansen
The bug has nothing to do with try-finally.

Take a look at the macro expansion:

user=> (macroexpand '(.. (System/out) (print "-") (println "-")))
(. (. (System/out) (print "-")) (println "-"))

You are trying to call 'println on what ever 'print returns. But
'print is a void method.

On Tue, Aug 10, 2010 at 08:36, Brian Stiles  wrote:
> The following succeeds:
>
> (try
>  (prn 1)
>  (finally
>   (prn 2)
>   (doto (System/out) (.print "-") (.println "-"
>
> prints:
>
> 1
> 2
> --
>
> The following fails (note the odd duplication of "2" in the output):
>
> (try
>  (prn 1)
>  (finally
>   (prn 2)
>   (.. (System/out) (print "-") (println "-"
>
> prints:
>
>
> 1
> 2
> -2
> -Exception in thread "main" java.lang.NullPointerException
> (NO_SOURCE_FILE:0)
>        at clojure.lang.Compiler.eval(Compiler.java:4658)
>        at clojure.core$eval__5236.invoke(core.clj:2017)
>        at clojure.main$eval_opt__7411.invoke(main.clj:227)
>        at clojure.main$initialize__7418.invoke(main.clj:246)
>        at clojure.main$null_opt__7446.invoke(main.clj:271)
>        at clojure.main$main__7466.doInvoke(main.clj:346)
>        at clojure.lang.RestFn.invoke(RestFn.java:426)
>        at clojure.lang.Var.invoke(Var.java:363)
>        at clojure.lang.AFn.applyToHelper(AFn.java:175)
>        at clojure.lang.Var.applyTo(Var.java:476)
>        at clojure.main.main(main.java:37)
> Caused by: java.lang.NullPointerException
>        at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:26)
>        at user$eval__1.invoke(NO_SOURCE_FILE:1)
>        at clojure.lang.Compiler.eval(Compiler.java:4642)
>        ... 10 more
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> 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



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

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

2010-08-10 Thread Meikel Brandmeyer
Hi,

On Aug 10, 8:36 am, Brian Stiles  wrote:

> The following succeeds:
>
> (try
>   (prn 1)
>   (finally
>    (prn 2)
>    (doto (System/out) (.print "-") (.println "-"
>
> prints:
>
> 1
> 2
> --
>
> The following fails (note the odd duplication of "2" in the output):
>
> (try
>   (prn 1)
>   (finally
>    (prn 2)
>    (.. (System/out) (print "-") (println "-"
>
> prints:
>
> 1
> 2
> -2
> -Exception in thread "main" java.lang.NullPointerException

Of course it fails, because print is a void method and hence "returns"
nil. So you are calling print on nil leading to the NPE.

Why the 2 is printed twice... good question:

user=> (try (prn 1) (finally (prn 2) (.foo nil)))
1
2
2
java.lang.NullPointerException (NO_SOURCE_FILE:0)
user=> (let [] (try (prn 1) (finally (prn 2) (.foo nil
1
2
2
java.lang.NullPointerException (NO_SOURCE_FILE:0)
user=> (let [a (atom 2)] (try (prn 1) (finally (prn @a) (.foo nil
1
2
java.lang.NullPointerException (NO_SOURCE_FILE:0)
user=> (def a (atom 2))
#'user/a
user=> (try (prn 1) (finally (prn @a) (.foo nil)))
1
2
2
java.lang.NullPointerException (NO_SOURCE_FILE:0)

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: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Laurent PETIT
2010/8/10 garf 

> On occasion the REPL in Eclipse will stop taking input, or will fail
> to recognize a function I have just defined.  Is there a simple way to
> get the REPL to restart, or break out of its current state?
>

Hi, I don't know why your REPL is not responding anymore, and maybe we
should try to find whether it's justified or not.
Anyway, to answer your question: Hit the red button in the REPL's view: this
will kill the process (and thus the REPL). And then start a new REPL. You
can also get rid of the old REPL's log histories by hitting the grey cross.


>
> One other question as well, to get the REPL running when I first bring
> up Eclipse I have a file that runs a few tests.  Then I switch over to
> the file that I am working on.  I notice the namespace that is shown
> in the REPL remains in the original test namespace.  Does that mean
> that all the definitions I am getting with selecting code tidbits &
> then using cntrl-alt-x are in the test namespace?
>

Currently, yes.
(BTW, what you see colored in green in the REPL is what ccw "typed" for you
automatically, no more no less.)

-- 
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: noob q: infinite loop recur

2010-08-10 Thread Laurent PETIT
Hi,

if you recur with "rest", you should use (empty?), if you recur with next,
you can use (nil?)

next is more eager than rest, but in a loop scenario, I generally use next
since we'll test for nil in order to know whether to continue to iterate or
not.

2010/8/10 chepprey 

> Dipping my toes for the first time in Clojure.  Having some beginner
> troubles.
>
> THIS code works (on the repl, if that matters... also, Clojure 1.2):
>
> (defn show [words]
>(let [word (first words)]
>(do
>(println word)
>(if (nil? word)
>(println "DONE")
>(recur (rest words))
>
> (show '("some" "sample" "words"))
>
> ... this shows the 3 words, then DONE, and terminates.
>
> But originally, I was trying to use loop/recur.  If I replace the
> "let" with "loop" in the above code, it goes into an infinite loop.  I
> assume there's something different in the scoping/binding rules with
> loop, but I can't find a good explanation of what.  I read in
> "Programming Clojure", regarding loop, that it "...works like let,
> establishing bindings and then evaluating exprs..."
>
> Noob Q#2: should I (and when) use "next" instead of "rest" on a seq?
> a lazy seq?
>
> 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

-- 
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: jna Java Native Acess and clojure ....

2010-08-10 Thread Sunil S Nandihalli
Thanks Mac for your clarification .. I am using clojure 1.2 .. so should be
fine. And I was wondering if I can acess c++ stuff via clj-native .. What
are your suggestions?
Sunil

On Tue, Aug 10, 2010 at 12:45 PM, mac  wrote:

> I'm the author of clj-native.
> Currently it only works with Clojure 1.2. In retrospect I should have
> made a separate branch when dropping 1.1 support.
> If you need 1.1 support, just tell me and I could make a branch for it
> since the changes required should be small.
>
> /Markus
>
> On Aug 9, 5:31 pm, Chouser  wrote:
> > On Mon, Aug 9, 2010 at 10:55 AM, Sunil Nandihalli
> >
> >  wrote:
> > > Hello everybody,
> > >  I have been trying to use the native libraries in clojure. I have
> > > found clj-native and clojure-jna which may serve the purposes. I would
> > > like to get a feed back from the community .. Which of these is good
> > > to use .. Or do you have any other suggestions..
> >
> > I wrote clojure-jna, but although I haven't had a chance to use
> > clj-native yet I understand it's significantly more advanced and
> > efficient than clojure-jna.  So I'd recommend at least starting with
> > clj-native to see if it will meet your needs.
> >
> > --Chouserhttp://joyofclojure.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
>

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

Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread garf
On occasion the REPL in Eclipse will stop taking input, or will fail
to recognize a function I have just defined.  Is there a simple way to
get the REPL to restart, or break out of its current state?

One other question as well, to get the REPL running when I first bring
up Eclipse I have a file that runs a few tests.  Then I switch over to
the file that I am working on.  I notice the namespace that is shown
in the REPL remains in the original test namespace.  Does that mean
that all the definitions I am getting with selecting code tidbits &
then using cntrl-alt-x are in the test namespace?

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


Bug in try/finally?

2010-08-10 Thread Brian Stiles
The following succeeds:

(try
  (prn 1)
  (finally
   (prn 2)
   (doto (System/out) (.print "-") (.println "-"

prints:

1
2
--

The following fails (note the odd duplication of "2" in the output):

(try
  (prn 1)
  (finally
   (prn 2)
   (.. (System/out) (print "-") (println "-"

prints:


1
2
-2
-Exception in thread "main" java.lang.NullPointerException
(NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:4658)
at clojure.core$eval__5236.invoke(core.clj:2017)
at clojure.main$eval_opt__7411.invoke(main.clj:227)
at clojure.main$initialize__7418.invoke(main.clj:246)
at clojure.main$null_opt__7446.invoke(main.clj:271)
at clojure.main$main__7466.doInvoke(main.clj:346)
at clojure.lang.RestFn.invoke(RestFn.java:426)
at clojure.lang.Var.invoke(Var.java:363)
at clojure.lang.AFn.applyToHelper(AFn.java:175)
at clojure.lang.Var.applyTo(Var.java:476)
at clojure.main.main(main.java:37)
Caused by: java.lang.NullPointerException
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:26)
at user$eval__1.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:4642)
... 10 more

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

2010-08-10 Thread Sunil S Nandihalli
Thanks Chouser for your reply .. I was wondering if it is possible to acess
c++ code via clj-native .. I only seem to find c-native calls .. do you have
a comment on this..
Sunil.

On Mon, Aug 9, 2010 at 9:01 PM, Chouser  wrote:

> On Mon, Aug 9, 2010 at 10:55 AM, Sunil Nandihalli
>  wrote:
> > Hello everybody,
> >  I have been trying to use the native libraries in clojure. I have
> > found clj-native and clojure-jna which may serve the purposes. I would
> > like to get a feed back from the community .. Which of these is good
> > to use .. Or do you have any other suggestions..
>
> I wrote clojure-jna, but although I haven't had a chance to use
> clj-native yet I understand it's significantly more advanced and
> efficient than clojure-jna.  So I'd recommend at least starting with
> clj-native to see if it will meet your needs.
>
> --Chouser
> http://joyofclojure.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

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

noob q: infinite loop recur

2010-08-10 Thread chepprey
Dipping my toes for the first time in Clojure.  Having some beginner
troubles.

THIS code works (on the repl, if that matters... also, Clojure 1.2):

(defn show [words]
(let [word (first words)]
(do
(println word)
(if (nil? word)
(println "DONE")
(recur (rest words))

(show '("some" "sample" "words"))

... this shows the 3 words, then DONE, and terminates.

But originally, I was trying to use loop/recur.  If I replace the
"let" with "loop" in the above code, it goes into an infinite loop.  I
assume there's something different in the scoping/binding rules with
loop, but I can't find a good explanation of what.  I read in
"Programming Clojure", regarding loop, that it "...works like let,
establishing bindings and then evaluating exprs..."

Noob Q#2: should I (and when) use "next" instead of "rest" on a seq?
a lazy seq?

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: Please help! Really simple function not working.

2010-08-10 Thread Nicolas Oury
The table show 20!.
I am far from being sure of my point, but in a first approximation:
Loading a part of memory that is not cached (which will be the case
for big lists) is around 300 cycles.
An addition in a register is a few cycles, a jump is a few cycles too,
at most, (the prediction will be good here).

Of course, it is only guess. And, if you really count the time to get
through a line of cache adding one, it might
not be negligeable in regard of the time to load cache, but I think it
will have an impact.

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Meikel Brandmeyer
Hi,

On Aug 10, 11:34 am, Mark Engelberg  wrote:

> The table shows that the performance of the accumulator-style version
> of factorial is always worse than that of the original factorial
> function."

I'm a little bit surprised, that people still prefer programs, which
are only sometimes not broken, over programs which work always
correctly.

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: Please help! Really simple function not working.

2010-08-10 Thread Mark Engelberg
On Tue, Aug 10, 2010 at 2:21 AM, Nicolas Oury  wrote:
> It would probably be up to twice as slow, I would say.
> For a list that is continuous in memory and continuations that are
> allocated perfectly in memory,
> you would need to go through twice the same amount of memory.
> (I assume that the main cost here is going through the memory)

I don't think this is true.

See comment at bottom of http://www.htdp.org/2001-09-22/Book/node163.htm:

"People who encounter accumulator-style programming for the first time
often get the impression that they are always faster or easier to
understand (design) than their recursive counterparts. Both parts are
plain wrong. While it is impossible to deal with the full scope of the
mistake, let us take a look at a small counterexample.

Consider the following table:

[Go to link to see table]

...

The table shows that the performance of the accumulator-style version
of factorial is always worse than that of the original factorial
function."

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Laurent PETIT 

>
>
> 2010/8/10 Nicolas Oury 
>
> On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT 
>> wrote:
>> > Naive question from someone who has not really used Scheme in practice :
>> > beyond the memory footprint problem (which may or may not be a problem
>> > depending on the memory size of an element in the initial list, and also
>> > depending on whether you're recurring over a datastructure, or a
>> presumably
>> > very long lazy seq), isn't there an impact on CPU usage too ?
>>
>> It would probably be up to twice as slow, I would say.
>> For a list that is continuous in memory and continuations that are
>> allocated perfectly in memory,
>> you would need to go through twice the same amount of memory.
>> (I assume that the main cost here is going through the memory)
>>
>
>
> Isn't this improbable (your assumption about the main cost) ? Even for the
> smallest accumulating computation such as doing an addition or consing
> things (which requires memory allocation, etc.), I'm not certain that there
> wouldn't be near-to-an-order-of-magnitude between the "going through the
> memory" and the "accumulator computation" ?
>

The more I think about it, the more I tend to consider that it's just the
memory footprint of ( size of an intermediate result x number of elements of
the coll ) which counts. With the caveat that sometimes saying "if the coll
can stay in memory and the size of an intermediate result is negligeable
compared to the size of an element of the coll, everything's ok" may not
work if we're not really holding the coll in memory, but rather computing a
very long lazy seq / lazy tree.

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Nicolas Oury 

> On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT 
> wrote:
> > Naive question from someone who has not really used Scheme in practice :
> > beyond the memory footprint problem (which may or may not be a problem
> > depending on the memory size of an element in the initial list, and also
> > depending on whether you're recurring over a datastructure, or a
> presumably
> > very long lazy seq), isn't there an impact on CPU usage too ?
>
> It would probably be up to twice as slow, I would say.
> For a list that is continuous in memory and continuations that are
> allocated perfectly in memory,
> you would need to go through twice the same amount of memory.
> (I assume that the main cost here is going through the memory)
>


Isn't this improbable (your assumption about the main cost) ? Even for the
smallest accumulating computation such as doing an addition or consing
things (which requires memory allocation, etc.), I'm not certain that there
wouldn't be near-to-an-order-of-magnitude between the "going through the
memory" and the "accumulator computation" ?

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Nicolas Oury
On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT  wrote:
> Naive question from someone who has not really used Scheme in practice :
> beyond the memory footprint problem (which may or may not be a problem
> depending on the memory size of an element in the initial list, and also
> depending on whether you're recurring over a datastructure, or a presumably
> very long lazy seq), isn't there an impact on CPU usage too ?

It would probably be up to twice as slow, I would say.
For a list that is continuous in memory and continuations that are
allocated perfectly in memory,
you would need to go through twice the same amount of memory.
(I assume that the main cost here is going through the memory)

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Nicolas Oury
On Tue, Aug 10, 2010 at 9:55 AM, Mark Engelberg
 wrote:
>  In Clojure, I find stack limitations are a real issue unless
> I transform the algorithms into a tail-recursive accumulator style.
> For lists, it's usually not hard.  For trees, it can be a bit of a
> pain.

Try CPS+trampoline
It is more or less what scheme does internally...

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
Hello Mark,

2010/8/10 Mark Engelberg 

> On Tue, Aug 10, 2010 at 1:15 AM, Nicolas Oury 
> wrote:
> >  So, in this particular case, Scheme does not warranty no exhaustion
> > of resources.
>
> Yes, but your recursion depth is limited to the length of the list you
> are processing.  So if you have enough resources to comfortably hold
> and manipulate the list in memory, odds are good you have enough
> resources to handle the non-tail recursive processing of the list.
>
> Generally speaking, I find I do not have to worry about "blowing the
> stack" in Scheme, and as a result, non-tail-call structural recursion
> (such as the algorithm that kicked off this thread) is perfectly
> idiomatic in the implementations of Scheme I have used (mostly
> Racket).


Naive question from someone who has not really used Scheme in practice :
beyond the memory footprint problem (which may or may not be a problem
depending on the memory size of an element in the initial list, and also
depending on whether you're recurring over a datastructure, or a presumably
very long lazy seq), isn't there an impact on CPU usage too ?


> In Clojure, I find stack limitations are a real issue unless
> I transform the algorithms into a tail-recursive accumulator style.
> For lists, it's usually not hard.  For trees, it can be a bit of a
> pain.
>

oh yes :-)


>
> Since Clojure has a lot of similarities with Scheme, this is a key
> difference that needs to be emphasized to people coming from Scheme or
> using a Scheme-based textbook to try to learn Clojure.
>
> --
> 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: Please help! Really simple function not working.

2010-08-10 Thread Mark Engelberg
On Tue, Aug 10, 2010 at 1:15 AM, Nicolas Oury  wrote:
>  So, in this particular case, Scheme does not warranty no exhaustion
> of resources.

Yes, but your recursion depth is limited to the length of the list you
are processing.  So if you have enough resources to comfortably hold
and manipulate the list in memory, odds are good you have enough
resources to handle the non-tail recursive processing of the list.

Generally speaking, I find I do not have to worry about "blowing the
stack" in Scheme, and as a result, non-tail-call structural recursion
(such as the algorithm that kicked off this thread) is perfectly
idiomatic in the implementations of Scheme I have used (mostly
Racket).  In Clojure, I find stack limitations are a real issue unless
I transform the algorithms into a tail-recursive accumulator style.
For lists, it's usually not hard.  For trees, it can be a bit of a
pain.

Since Clojure has a lot of similarities with Scheme, this is a key
difference that needs to be emphasized to people coming from Scheme or
using a Scheme-based textbook to try to learn Clojure.

-- 
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: drop-while for noobs

2010-08-10 Thread Michael Wood
On 9 August 2010 22:16, Alan  wrote:
> Weird. I wonder if I was using an outdated version of Clojure or (more
> likely) assumed from (doc drop-while) that it wouldn't handle false
> the way I wanted. When doc says "not nil" should I assume it means
> "neither nil nor false", or should the doc for drop-while be updated?
>
> user=> (doc drop-while)
> -
> clojure.core/drop-while
> ([pred coll])
>  Returns a lazy sequence of the items in coll starting from the first
>  item for which (pred item) returns nil.

I think the docs should be fixed to refer to "logical false" like
other parts of the documentation, instead of "nil".

e.g.:

(find-doc "logical false")
[...]
clojure.core/when-not
([test & body])
Macro
  Evaluates test. If logical false, evaluates body in an implicit do.
nil

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


Re: Basic Lisp Compiler: How to tell which functions to compile?

2010-08-10 Thread Nicolas Oury
On Tue, Aug 10, 2010 at 12:43 AM, Jules  wrote:
> It is impossible (undecidable) to tell precisely which functions a
> function will call. Therefore you will need to consider not exactly
> set of functions that a function will call, but some superset of that.
> Why not take as your superset all functions? That is, always compile
> all functions.
>

There is a smaller decidable superset: all functions occurring in the
static call graph for a function.
But, I agree, most compilers would just compile everything and it's
probably a better idea.

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Nicolas Oury
On Tue, Aug 10, 2010 at 2:40 AM, Mark Engelberg
 wrote:
> arbitrary-sized lists is a primary goal.  The posted code (minus the
> call to recur), is an elegant recursive formulation that is idiomatic
> in Scheme because Scheme is (typically) implemented in a way that
> makes stack limitations (mostly) a non-issue.
>
> In Clojure, you have to work around stack limitations imposed by Java,
> and recursive functions must be "translated" to work on largish lists
> in Clojure.  There is no one recipe to make that translation, but
> there are several common patterns.  If the recursive call is in tail

I want to add a little bit of information. (I am not a specialist of
Scheme but believe what follow to be true)
The original function minus recur + a recursive call on the  second
cond is not tail-recursive.
 So, in this particular case, Scheme does not warranty no exhaustion
of resources.
(A lot of Scheme implementation, and SML/NJ I believe, are
CPS-compiled and will exhaust heap and not stack
but those that are based on Lazy Stack copying would probably exhaust stack).
Anyway, this implementation - in any language - would still eat
memory, constructing a long stack-allocated (or heap-allocated in most
Scheme and SML/NJ) list of continuations to remember "what to do when
I have finished". In more fancy term, whether on the stack and on the
heap,
you need to keep a list of "continuations" to the computation.
"When I am at the end of the list, I will add one, and then add one,
and then add one "

A tail-call has the particularity to have a trivial continuation: "I
take the result and return it", so you don't have to actually keep any
information.
Most functional languages optimise this, but those on the JVM have a
hard time doing it, because the way the JVM works.
Scheme warranties it. You are not a Scheme implementation if you do
not do tail-call optimisation.

Clojure  does it, for self recursion, when you explicitly ask for it,
emitting a compile-time error if it can't.
I think it is a good idea, because sometimes you write the function
lightly badly and do not realise tail-call optimisation do not happen
until a bug in production.

There are ways to transform a call in tail-call. Adding an
accumulator, using a list passed as argument as a stack, or doing a
Continuation passing Style transformation.
(http://en.wikipedia.org/wiki/Continuation-passing_style , in a word:
to put the future in a closure we pass to the recursive call.)
It is harder to transform a program to only self tail-call, but I
think CPS+trampoline always do the trick.
(Without the restriction to only do self calls, CPS does always the trick)

Best regards,

Nicolas.

-- 
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: why the def of run-jetty looks like "defn #^Server run-jetty"

2010-08-10 Thread ngocdaothanh
> The main usage (at least for me) is avoiding reflection in the context
> of direct call to a Java method.
>
> if you write:
> (defn foo [x]
>   (.clone x))

Thank you for the insightful explanation.

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Laurent PETIT 

> 2010/8/10 Meikel Brandmeyer 
>
>> Hi,
>>
>>
>> On Aug 10, 9:36 am, Laurent PETIT  wrote:
>>
>> > Interesting ! Though it seems like a repetition in this case ...
>>
>> Indeed. However, eg. with multimethods this a nice-to-know to supply
>> some meaningful argument info.
>>
>
> Indeed !
>

And with macro generating macros too !

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Meikel Brandmeyer 

> Hi,
>
> On Aug 10, 9:36 am, Laurent PETIT  wrote:
>
> > Interesting ! Though it seems like a repetition in this case ...
>
> Indeed. However, eg. with multimethods this a nice-to-know to supply
> some meaningful argument info.
>

Indeed !

-- 
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: looking for a simpler implementation of a function I'm using

2010-08-10 Thread ngocdaothanh
> What I'm looking for is a natural, conceptually clean approach.

Erlang programmers do version 2 all the time and it can be call
"Erlang-style". You should be confident with version 2.

Version 2 is cleaner if you write the inner loop as a separate
function.

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Meikel Brandmeyer
Hi,

On Aug 10, 9:36 am, Laurent PETIT  wrote:

> Interesting ! Though it seems like a repetition in this case ...

Indeed. However, eg. with multimethods this a nice-to-know to supply
some meaningful argument info.

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: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Meikel Brandmeyer 

> Hi,
>
> On Aug 10, 8:22 am, Laurent PETIT  wrote:
>
> > Though here, the version with different arities "exposes as API for the
> > user" the 2-arity version, but it may not make sense for the user of your
> > function to know about this 2-arity version. I personally prefer the
> first
> > approach (with a private helper function via defn-) or the last approach
> > (with an embedded loop).
>
> One can also remove the multiple arities from the contract.
>
> (defn count-zeros
>  {:arglists '([coll])}
>  ([coll] (count-zeros coll 0))
>  ([coll result]
>   ...))
>
>
Interesting ! Though it seems like a repetition in this case ...

-- 
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: Please help! Really simple function not working.

2010-08-10 Thread Meikel Brandmeyer
Hi,

On Aug 10, 8:22 am, Laurent PETIT  wrote:

> Though here, the version with different arities "exposes as API for the
> user" the 2-arity version, but it may not make sense for the user of your
> function to know about this 2-arity version. I personally prefer the first
> approach (with a private helper function via defn-) or the last approach
> (with an embedded loop).

One can also remove the multiple arities from the contract.

(defn count-zeros
  {:arglists '([coll])}
  ([coll] (count-zeros coll 0))
  ([coll result]
   ...))

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: jna Java Native Acess and clojure ....

2010-08-10 Thread mac
I'm the author of clj-native.
Currently it only works with Clojure 1.2. In retrospect I should have
made a separate branch when dropping 1.1 support.
If you need 1.1 support, just tell me and I could make a branch for it
since the changes required should be small.

/Markus

On Aug 9, 5:31 pm, Chouser  wrote:
> On Mon, Aug 9, 2010 at 10:55 AM, Sunil Nandihalli
>
>  wrote:
> > Hello everybody,
> >  I have been trying to use the native libraries in clojure. I have
> > found clj-native and clojure-jna which may serve the purposes. I would
> > like to get a feed back from the community .. Which of these is good
> > to use .. Or do you have any other suggestions..
>
> I wrote clojure-jna, but although I haven't had a chance to use
> clj-native yet I understand it's significantly more advanced and
> efficient than clojure-jna.  So I'd recommend at least starting with
> clj-native to see if it will meet your needs.
>
> --Chouserhttp://joyofclojure.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