Re: San Francisco Clojure Users

2011-05-26 Thread Emeka
David,

Yes. I am in Nigeria.

Emeka

On Tue, May 24, 2011 at 9:43 AM, David Jagoe  wrote:

> Are you in Nigeria?
>
> Anyone else on this list in Africa?
>
>
>
> On Sunday, 22 May 2011, Emeka  wrote:
> > Okay.
> > I live in Africa... maybe we should have online meetups for now.
> > Emeka
> >
> > On Thu, May 19, 2011 at 4:29 PM, David Jagoe 
> wrote:
> > On 18 May 2011 18:54, Emeka  wrote:
> >> David,
> >> How is Clojure doing in Africa?
> >
> > There really aren't that many people using it among the people that I
> > have spoken to. I've worked in the UK, Europe and the US and in
> > comparison South Africa is a little bit behind and quite conservative
> > when it comes to technology choices.
> >
> >
> > Cheers,
> > David
> >
> > --
> > 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
> >
> > --
> > Satajanus  Nig. Ltd
> >
> >
> >
> >
> >
> >
> >
> > --
> > 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
>



-- 
*Satajanus  Nig. Ltd


*

-- 
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: San Francisco Clojure Users

2011-05-22 Thread Emeka
Okay.

I live in Africa... maybe we should have online meetups for now.

Emeka

On Thu, May 19, 2011 at 4:29 PM, David Jagoe  wrote:

> On 18 May 2011 18:54, Emeka  wrote:
> > David,
> > How is Clojure doing in Africa?
>
> There really aren't that many people using it among the people that I
> have spoken to. I've worked in the UK, Europe and the US and in
> comparison South Africa is a little bit behind and quite conservative
> when it comes to technology choices.
>
>
> Cheers,
> David
>
> --
> 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
>



-- 
*Satajanus  Nig. Ltd


*

-- 
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: San Francisco Clojure Users

2011-05-18 Thread Emeka
David,

How is Clojure doing in Africa?

Emeka.

On Wed, May 11, 2011 at 12:42 AM, David Jagoe  wrote:

> On 10 May 2011 15:00, Zach Tellman  wrote:
> > Unfortunately, you just missed the monthly Bay Area user group meetup,
>
> Yeah I saw that... gutted!
>
> > which was yesterday.  But with Google I/O going on, maybe there are
> > enough people around that an impromptu meetup would be plausible.
>
> That would be great. There aren't too many Clojure developers in South
> Africa!!
>
> >
> > Zach
> >
> > On May 10, 1:07 pm, David Jagoe  wrote:
> >> G'day everyone,
> >>
> >> Forgive me if this is not the appropriate place for this message, but
> >> I'm in San Francisco for a few days from Johannesburg, South Africa.
> >> Any clojure users keen on meeting up? Any clojure events going on that
> >> I haven't spotted on-line?
> >>
> >> I run a business using Clojure for web development.
> >>
> >> Cheers,
> >> David
> >
> > --
> > 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
>



-- 
*Satajanus  Nig. Ltd


*

-- 
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: into map with vectors versus lists (Re: Creating map from string)

2010-12-24 Thread Emeka
Did you try this

(apply hash-map (partition 2 (split (slurp "data") #",")))



On Sat, Dec 4, 2010 at 11:12 AM, Remco van 't Veer wrote:

> I expected this to work:
>
>  (into {} (partition 2 (split (slurp "data") #",")))
>
> But unfortunately, `into' doesn't seem to allow pushing lists of pairs
> into a map.  But vectors are allowed:
>
>  (into {} (map vec (partition 2 (split (slurp "data") #","
>
> Can somebody explain why vectors are allowed and lists not?
>
>
> On 2010/12/03 15:40, Laurent PETIT wrote:
>
> > Hi,
> >
> > 2010/12/3 Anclj 
> >
> > Hi,
> >
> > I have a string of data and I would like to get a map {:key
> > value, :key value, …}
> >
> > How could I do that?
> >
> > I've got:
> >
> > user> (split (slurp "data") #",")
> > ["0" "2" "1" "5" "2" "8" "3" "15" "4" "9"]
> >
> > And I would like:
> > {:0 2, :1 5, :2 8, :3 15, :4 9}
> >
> > Any idea?
> >
> > (let [s (split (slurp "data") #",")]
> >   (zipmap (take-nth 2 s) (take-nth 2 (rest s
> >
> > 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
>
> --
> 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




-- 
*Satajanus  Nig. Ltd


*

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

2010-12-16 Thread Emeka
Laurent and Robert,

Thank you all.


On Thu, Dec 16, 2010 at 9:44 AM, Laurent PETIT wrote:

> Indeed !
>
> I was stuck in the macro thinking, thanks for getting us out of it !
>
> And then this solution not only works for literal strings:
>
> user=> (foo (str "yo" "man"))
> #'user/yoman
> user=> yoman
> "yoman"
> user=>
>
> 2010/12/16 Robert McIntyre 
>
> no need to use macros at all:
>>
>> (defn foo
>>  "creates a symbol named s with the value s in the current namespace "
>>  [s]
>> (intern *ns* (symbol s) s))
>>
>> that is, assuming I got the use case right.
>>
>> --Robert McIntyre
>>
>>
>> On Wed, Dec 15, 2010 at 8:00 AM, Laurent PETIT 
>> wrote:
>> > 2010/12/15 Emeka 
>> >>
>> >> Helllo All,
>> >> Is there a better way of doing this?
>> >> (defmacro foo [string] (let[b# string f# (symbol b#)] `(def ~f#  ~b#)))
>> >
>> > Hello,
>> >
>> > What is it supposed to be used ?
>> >
>> > What do you expect the macroexpansion to look like ?
>> >
>> > As is stands, your example can go without the ending #'s since they
>> aren't
>> > declared inside the returned quoted expr. They're useless.
>> >
>> > So having
>> >
>> > (defmacro foo [string] (let [b string f (symbol string)] `(def ~f ~b)))
>> >
>> > But now, string is not (as you may think) evaluated within the let in
>> the
>> > macro. string is just an immutable datastructure containing "as is" what
>> has
>> > been passed to foo. So if what you pass to foo is something which
>> > "evaluates" to a string, for example a string concatenation expression
>> as
>> > (str "the-" "value"), then the code will not do what it suggests it's
>> doing
>> > :
>> >
>> > user=> (defmacro foo [string] (let[b# string f# (symbol b#)] `(def ~f#
>> > ~b#)))
>> > #'user/foo
>> > user=> (foo (str "the-" "value"))
>> > java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast
>> to
>> > java.lang.String (NO_SOURCE_FILE:0)
>> > user=> (macroexpand '(foo (str "the-" "value")))
>> > java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast
>> to
>> > java.lang.String (NO_SOURCE_FILE:0)
>> > user=>
>> >
>> >
>> > Now, if you just want the macro to take literal strings as input, then
>> the
>> > code can be further simplified to :
>> >
>> > (defmacro foo [string] `(def ~(symbol string) ~string))
>> >
>> > user=> (defmacro foo [string] `(def ~(symbol string) ~string))
>> > #'user/foo
>> > user=> (foo "the-string")
>> > #'user/the-string
>> > user=> the-string
>> > "the-string"
>> > user=> (macroexpand '(foo "the-string"))
>> > (def the-string "the-string")
>> > user=>
>> >
>> > 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
>>
>> --
>> 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
>



-- 
*Satajanus  Nig. Ltd


*

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

Looking for a better way

2010-12-15 Thread Emeka
*Helllo All,*
*
*
*Is there a better way of doing this?*
*
*
*(defmacro foo [string] (let[b# string f# (symbol b#)] `(def ~f#  ~b#)))*
*
*
*
*
*Regards,*
*Emeka
*

-- 
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: sql utilities

2010-10-18 Thread Emeka
Beautiful .

Emeka

On Fri, Oct 15, 2010 at 1:08 AM, Stuart Campbell  wrote:

> Thanks Kyle. Looks useful!
>
>
> On 15 October 2010 09:25, Saul Hazledine  wrote:
>
>> On Oct 14, 9:16 pm, "Kyle R. Burton"  wrote:
>> > I've written some sql helper functions that will do things like list
>> > the objects in the database and describe a table.  I've found these
>> > handy when doing interactive development as I don't have to jump over
>> > to another app to see what the make up of tables are.  I've also used
>> > it in some scenarios when generating code from the database schema.
>> >
>>
>> Very cool. If you have no joy getting it into contrib you can have
>> write access to clj-sql if you want it:
>>
>> http://github.com/alienscience/clj-sql
>>
>> Otherwise, as Shanatu says, a github project of your own would be
>> welcome and is sure to be used by others.
>>
>> Saul
>>
>> --
>> 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
>



-- 
*Satajanus  Nig. Ltd


*

-- 
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: Displaying source of function typed into the REPL?

2010-09-20 Thread Emeka
Sean,

Try this, http://gist.github.com/193550 . Adjust  it to your taste.


Regards,
Emeka

On Mon, Sep 20, 2010 at 4:00 AM, Sean Corfield wrote:

> That also sounds pretty useful for development. I may try that as an
> exercise...
>
> This weekend has been a journey through The Joy of Clojure. I read
> about 100 pages on Friday evening (easy going), 150 pages on Saturday
> (harder going - more complex topics). Today I read another 50 pages,
> skipped chapters 11 & 12 (brain too full to process - about 80 pages)
> and read chapter 13 (about 20 pages). All the time I had a REPL open
> and kept copy'n'pasting examples in and playing with them to get a
> feel for it. It's been a really fun weekend! Now, unfortunately, I
> must get chores (and work!) done before the week starts.
>
> See some of you at the JavaOne Clojure meetup tomorrow (Monday)?
>
> On Sun, Sep 19, 2010 at 6:11 PM, jlk  wrote:
> > Not sure how practical it is, but a while back I was playing around
> > with a macro redefining defn so that it stored the function source in
> > the meta-data of the function.  I can't find it now but remember it
> > being fairly trivial to implement.
>
> --
> 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
>



-- 
*Satajanus  Nig. Ltd


*

-- 
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: JavaFX and Clojure

2010-08-27 Thread Emeka
Mark,

Can JavaFX do that?

Regards,
Emeka

On Mon, Aug 23, 2010 at 7:12 PM, Mark Engelberg wrote:

> > Rather than
> > creating the JavaFX language they would have done so much more for the
> > community to just focus on this scenegraph library, animation, etc...
>
> I agree.  I'm not interested in the JavaFX language, but am interested
> in doing Flash-like user interfaces and animations from 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: Windows distribution for Leiningen 1.3.0

2010-08-22 Thread Emeka
Wow! I touched it and it reminded  of REBOL interpreter. I downloaded
leningen-1.3.0, and lein batch. I put leningen-1.3.0.jar on by path. Hmmm, I
got electrified. Now, I can make boast by saying this "is the real one".

Thanks for sharing ... and for considering me among the people so favored to
try it.


Regards,
Emeka

On Sat, Aug 21, 2010 at 6:22 PM, Shantanu Kumar wrote:

> The lein.bat script is now updated in the sources if some of you want
> to give it a try. A summary about it is here:
>
> http://bit.ly/c4U2bI
>
> Regards,
> Shantanu
>
> On Aug 21, 12:45 am, Shantanu Kumar  wrote:
> > Discovered a bug in the the bundle I uploaded, which I have fixed in
> > update-1:
> >
> > http://github.com/downloads/kumarshantanu/leiningen/leiningen-1.3.0-u...
> >
> > The earlier lein.bat script uses wildcard in JAR filename in
> > CLASSPATH, which is supported only in JDK 1.6. If you are using JDK
> > 1.5 or certain versions of JDK 1.6, you will likely need the update-1.
> >
> > Regards,
> > Shantanu
> >
> > On Aug 20, 6:46 pm, Phil Hagelberg  wrote:
> >
> >
> >
> > > On Fri, Aug 20, 2010 at 2:35 AM, Shantanu Kumar
> >
> > >  wrote:
> > > > I have created a Windows distribution for Leiningen 1.3.0 (by pruning
> > > > and modifying the lein.bat file a bit) that can be downloaded from
> > > > here:
> >
> > > >
> http://github.com/downloads/kumarshantanu/leiningen/leiningen-1.3.0.zip
> >
> > > > To install,
> > > > 1. Download the bundle and unzip into a folder of your choice
> > > > 2. Include the Leiningen folder in your PATH.
> >
> > > > In my initial tests on Windows XP 32-bit/JDK 1.6, it seems to be
> > > > working okay. Please let me know how it behaves at your end.
> >
> > > Thanks; I'd love to integrate this once it sees some usage and gets
> feedback!
> >
> > > -Phil
>
> --
> 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: ANN: form-dot-clj - HTML form validation and display

2010-08-13 Thread Emeka
Thanks for sharing, I will be trying out your lib. I am doing some web
thing.

Emeka

On Fri, Aug 13, 2010 at 10:11 AM, Saul Hazledine  wrote:

> Form-dot-clj is library for handling the display and validation of
> forms. It Supports HTML5 forms, javascript validation and plain HTML.
> It should work with most methods of generating HTML.
>
> http://github.com/alienscience/form-dot-clj
>
> In the last 10 minutes I have also found a library called "pour" that
> works in a similar way.
>
> http://github.com/Kaali/pour
>
> Form-dot-clj example:
>
> (def-field username
>  [:maxlength 20]
>  [:pattern "[A-Za-z0-9]+" "Only alphanumeric characters please"])
>
> (def-field email-address
>  [:email "Sorry, that style of email address is not supported"])
>
> (def-form example
>  {:size 20 :required "Please fill this in"}
>  :username (textbox username)
>  :email(textbox email-address))
>
> ;; Use the following function to show the form when generating html
> (show-controls example)
>
> ;; Use the following function to validate a post of this form
> (on-post example params success-fn failure-fn)
>
> --
> 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: let binding and recursive function

2010-08-04 Thread Emeka
Hello John,

I would want to add something to what Justin said.

(defn goo [ i k & l] (println l))

=> (goo 2 3 [233])
;;; gives ([233])
(conj '([233]) ...)

(defn goo [i k & [l]](println l))

=>(goo 2 3 [233])
;;; gives [233]
(conj [233] ...)

Hope the difference is clear now.

Emeka


On Mon, Aug 2, 2010 at 10:43 PM, John Sanda  wrote:

> Thanks for the response and suggestions Justin. A co-worker also just
> suggested multiple arg lists which is perfect. He also suggested (or foo
> bar) to further simplify my code. It definitely cleans the code up and
> improves readability.
>
> - John
>
>
> On Mon, Aug 2, 2010 at 5:37 PM, Justin Kramer  wrote:
>
>> I think you want:
>>
>> (defn- do-traversal [tree idx & [tree-traversal]]
>>  ...)
>>
>> Note the extra brackets for destructuring.
>>
>> Another alternative is using multiple arg lists:
>>
>> (defn- do-traversal
>>  ([tree idx]
>>(do-traversal tree idx []))
>>  ([tree idx traversal]
>>...))
>>
>> Lastly, FYI, the form (if foo foo bar) can be simplified to (or foo
>> bar).
>>
>> Hope that helps,
>>
>> Justin
>>
>> On Aug 2, 5:04 pm, John Sanda  wrote:
>> > I've just implemented an inorder traversal function for a vector-based
>> tree.
>> > The functions look like,
>> >
>> > (defn- do-traversal [tree idx traversal]
>> >   (cond
>> >(not (node-exists? tree idx)) traversal
>> >(leaf? tree idx) (conj traversal (tree idx))
>> >:else (apply conj
>> > (do-traversal tree (left-child idx) traversal)
>> > (tree idx)
>> > (do-traversal tree (right-child idx) traversal
>> >
>> > (inorder-traversal [tree]
>> >   (do-traversal tree root-idx []))
>> >
>> > This works as expected but now I am looking to refactor the code some. I
>> > wanted to see if I could do away passing an empty vector to the
>> do-traversal
>> > function. So I updated do-traversal to look like,
>> >
>> > (defn- do-traversal [tree idx & tree-traversal]
>> >   (let [traversal (if tree-traversal tree-traversal [])]
>> >(cond
>> > (not (node-exists? tree idx)) traversal
>> > (leaf? tree idx) (conj traversal (tree idx))
>> > :else (apply conj
>> >  (do-traversal tree (left-child idx) traversal)
>> >  (tree idx)
>> >  (do-traversal tree (right-child idx) traversal)
>> >
>> > When the expected traversal for a tree is [10 20 30] I instead get ([]
>> 30 20
>> > 10 [])) in my unit test. Can someone explain to me why using let as I
>> have
>> > done does not work, and what another solution might be?
>> >
>> > Thanks
>> >
>> > - John
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
>
>
>
> --
>
> - John
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

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

Installing emacs using leiningen on Windows Vista

2010-07-20 Thread Emeka
Hello All,

I need your support here. While troubleshooting I added  "echo CLASSPATH".
C:\Users\rmicro\goog>lein swank
";C:\Users\rmicro\goog\lib\
swank-clojure-1.2.1.jar"
"C:\cygwin\clein\leiningen-1.1.0-standalone.jar";";C:\Users\rmicro\goog\lib\swan
k-clojure-1.2.1.jar";".;C:\Program Files\Java\jre6\lib\ext\QTJava.zip"

The above is the content of my class path. Is there anything wrong?


This is the failure I got.
Exception in thread "main" Could not find clojure.main. Make sure you have
it in
 your classpath (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: Could not find clojure.main. Make sure you have it in your
classpath
at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:17
0)
at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:178)
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
at leiningen.compile$eval_in_project__799.doInvoke(compile.clj:141)
at clojure.lang.RestFn.invoke(RestFn.java:430)
at leiningen.swank$swank__818.doInvoke(swank.clj:11)
at clojure.lang.RestFn.invoke(RestFn.java:447)
at leiningen.swank$swank__818.invoke(swank.clj:13)
at leiningen.swank$swank__818.invoke(swank.clj:14)
at clojure.lang.Var.invoke(Var.java:359)
at clojure.lang.AFn.applyToHelper(AFn.java:173)
at clojure.lang.Var.applyTo(Var.java:476)
at clojure.core$apply__4370.invoke(core.clj:436)
at leiningen.core$_main__46$fn__49.invoke(core.clj:81)
at leiningen.core$_main__46.doInvoke(core.clj:78)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at user$eval__55.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

Leiningen on windows

2010-06-21 Thread Emeka
Hello All,

I need the following;

The clojure version to be used,
The best way to configure Leiningen on Vista,
Examples


I am currently try out  instructions on this site
http://charsequence.blogspot.com/2010/06/setup-leiningen-on-windows.html


Regards,
Emeka

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Using PRXML lib

2010-06-12 Thread Emeka
Thanks, it worked :(

On Sat, Jun 12, 2010 at 8:23 PM, Moritz Ulrich  wrote:

> You can use (with-out-str &body) to capture the output or prxml to a
> string and write that string to a file.
>
> On Sat, Jun 12, 2010 at 8:53 PM, Emeka  wrote:
> > Could someone direct me on how to write the output of prxml form to a
> file?
>
>
>
> --
> Moritz Ulrich
> Programmer, Student, Almost normal Guy
>
> http://www.google.com/profiles/ulrich.moritz
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Using PRXML lib

2010-06-12 Thread Emeka
Hello Moritz,

prxml form prints on the console, my aim is to redirect it to print to a
file. I have not been able to achieve this. I have looked at the prxml lib
code, it prints to *out*, it returns nil. My interest is on capturing the
output of prxml and writing it to a file.

Regards,
Emeka

On Sat, Jun 12, 2010 at 8:23 PM, Moritz Ulrich  wrote:

> You can use (with-out-str &body) to capture the output or prxml to a
> string and write that string to a file.
>
> On Sat, Jun 12, 2010 at 8:53 PM, Emeka  wrote:
> > Could someone direct me on how to write the output of prxml form to a
> file?
>
>
>
> --
> Moritz Ulrich
> Programmer, Student, Almost normal Guy
>
> http://www.google.com/profiles/ulrich.moritz
>
> --
> 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

Using PRXML lib

2010-06-12 Thread Emeka
Hello All,

Could someone direct me on how to write the output of prxml form to a file?

Regards,
Emeka

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Clojure Africa

2010-05-09 Thread Emeka
Hello All,
I have heard of Clojure this , Clojure that, virtually every continent
(every country) is duly represented except Africa. I have not heard of
Clojure Africa, someone here is tell me to call it Clojure South Africa. Now
, I have decided to start off somethingClojure Africa. Come join us.
http://groups.google.com/group/clojure-africa

Regards,
Emeka

-- 
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: Vimclojure Performance on Windows

2010-03-16 Thread Emeka
Meikel,

Is Vimclojure stable enough to have it on my Window's Vista? I tried it out
before without success.

Regards,
Emeka

On Fri, Feb 26, 2010 at 6:22 AM, Meikel Brandmeyer  wrote:

> Hi,
>
> On Feb 25, 4:46 pm, Vitaly Peressada  wrote:
>
> > Installed vimclojure-2.1.2 on Windows XP SP3. Have dual-core machine
> > and 4GB of RAM. In VimRepl
> > (println "Hello World") takes about 10 seconds. Is this expected?
>
> No. Vim shells out to another process. This is the only real portable
> and stable way to talk to other process with Vim. This is slow.
> However on my MacBook (dual-core, 1G RAM) the delay is not noticeable.
> On my crappy Windows Laptop (single-core, 1.7Gh, 2G RAM) at work, the
> delay is noticeable but well below a second.
>
> The only exception is the first command, which (as a side effect) sets
> up the whole clojure machinery in the background. But subsequent
> commands should be much faster.
>
> > Any suggestions how to speed this up?
>
> No clue. You are the first to report such a problem.
>
> Sincerely
> Meikel
>
> PS: there is also the vimclojure google group for such support issues.
>
> --
> 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: find source file for namespace?

2009-12-28 Thread Emeka
Hello nchubrich,

I thinking that you can do this with easy using namespace which would lead
you to resolve the file name and then figure out the path.

Emeka

On Mon, Dec 28, 2009 at 2:43 AM, nchubrich wrote:

> Does anyone know how to dynamically access the pathname for a
> particular piece of code?  I.E., I'd like to be able to write a
> function that can be called in any context and returns the pathname
> for the code it was called in.  (My intended use for this is to
> develop a testing package; I want to figure out an appropriate place
> to save the test files.)
>
> --
> 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

My belated Xmas gift

2009-12-23 Thread Emeka
Hello All,

I wanted something that could help make life a little easier for me, that
was what motivated me to write the below code. However, when I showed it to
a friend, he pointed out that clojure 1.1 has juxt function. So, I quickly
changed its name to apply-juxt. I invite your comments and if you like it
please use it.

Merry Christmas!!

(defn apply-juxt [d & body]
(map #(apply % body) d))

(apply-juxt [* - +] 8 7)


Regards,
Emeka

-- 
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: Funding Clojure 2010

2009-12-14 Thread Emeka
I have not done something like this before but your Clojure changed my life
, so I owe you something. However, coming from a far away continent(with low
income per head) I may not be able to match 100/developer/year price. I hope
you won't mind  my widow's might when it comes.

Emeka

On Mon, Dec 14, 2009 at 6:19 PM, BerlinBrown  wrote:

>
>
> On Dec 14, 9:33 am, Rich Hickey  wrote:
> > Funding Clojure 2010
> >
> > Background
> > --
> >
> > It is important when using open source software that you consider who
> > is paying for it, because someone is. There is no such thing as free
> > software.
> >
> > Sometimes open source software is developed under a license with
> > undesirable properties (e.g. the GPL), such that people are willing to
> > pay for a (proprietary) version of it that is not subject to that
> > license. Both Monty Widenius [1] and Richard Stallman [2] have argued
> > for the necessity of such a mechanism to fund open source software,
> > lest there be insufficient resources for its development. Clojure
> > doesn't use the GPL, thus conveying more freedom to its users, but
> > precluding me from funding it via dual licensing.
> >
> > Some companies develop technology as a component of a proprietary
> > product or service, absorbing it as a necessary expense, only to
> > decide that it is not a core, unique, or advantage-bearing business
> > function. They can reduce their costs in ongoing development by open
> > sourcing it, deriving benefit from community contributions and letting
> > them focus on their core business [3]. It is important to note that
> > the bulk of the costs are often in the original development, and are
> > paid for by the proprietary product or service. That is not the case
> > for Clojure.
> >
> > Some open source is the product of academic research, and is funded by
> > the academic institution and/or research grants [4]. That is not the
> > case for Clojure.
> >
> > Some open source software is (partially) funded by proprietary
> > support. It is important to note that often the support income does
> > not in fact make it to the people who create the software. Such income
> > models work best for support sold to conservative enterprises [5].
> > That is not the case for Clojure.
> >
> > Some companies 'fund' open source software by dedicating some of their
> > employees' time, or making investments, in its development. There must
> > be some business value to the company for doing so (e.g. it helps them
> > sell hardware [6]), and thus is ultimately paid for by their
> > proprietary products/services. That is not the case for Clojure.
> >
> > There *are* companies that make software themselves, whose consumers
> > see a value in it and willingly pay to obtain that value. The money
> > produced by this process pays the salaries of the people who are
> > dedicated to making it, and some profit besides. It's called
> > "proprietary software". People pay for proprietary software because
> > they have to, but otherwise the scenario is very similar to open
> > source - people make software, consumers get value from it. In fact,
> > we often get a lot less with proprietary software - vendor lock-in, no
> > source etc. Most alarmingly, this is the only model that associates
> > value with software itself, and therefore with the people who make it.
> >
> > Why don't people pay for open source software? Primarily, because they
> > don't *have to*. I think also, partially, it is because open source
> > software often doesn't have a price tag. I think it should. I'd like
> > to pay for open source, and know the money is going to those who
> > create it. I'd like companies to *expect* to pay for it. I'd like to
> > see people make a living (and even profit!) directly making open
> > source, not as a side effect of some other proprietary process, to
> > dedicate themselves to it, and not have it be hobby/side work.
> >
> > Unfortunately, there seems to be no way to convey the full benefits of
> > open source software while *forcing* people to pay for it. Only in the
> > proprietary (including dual-license) model is there a direct
> > connection between the consumers of software and the funding of those
> > that produce it. This is having the effect of driving open source
> > software towards having zero apparent cost, becoming a free bounty of
> > someone else's other profitable endeavors, and is severely
> > compromising our profession.
> >
> > 

Re: Transforming a Seq to a Map

2009-11-22 Thread Emeka
(apply has-map (apply concat (map (fn [b] [(apply hash-map (apply concat
(butlast b))) (val (last b))]) (list {9 5 9 9 7 8} {3 4 5 6 7 0}
{{3 4, 5 6} 0, {8 9, 9 5} 8}

I just added some noise!


On Wed, Nov 18, 2009 at 2:05 PM, Sean Devlin wrote:

> user=>(def your-data [{:a 1 :b 2 :c 3} {:a 4 :b 5 :c 6} {:a 7 :b 8 :c
> 9}])
>
> user=>(into {} (map (juxt #(dissoc % :c) :c) your-data))
>
> {{:a 1, :b 2} 3, {:a 4, :b 5} 6, {:a 7, :b 8} 9}
>
> On Nov 18, 8:36 am, Rich Hickey  wrote:
>  > On Wed, Nov 18, 2009 at 8:19 AM, Robert Campbell 
> wrote:
> > > Hey guys,
> >
> > > I'm having some trouble finding a nice way to perform a map
> > > transformation I need. I need to transform this:
> >
> > > [ {:a 1 :b 2 :c 3} {:a 4 :b 5 :c 6} {:a 7 :b 8 :c 9} ]
> >
> > > into this:
> >
> > > { {:a 1 :b 2} 3 {:a 4 :b 5} 6 {:a 7 :b 8} 9 }
> >
> > > I wanted to use map, but each f in map only returns one value, so I
> > > couldn't figure it out. Here is what I have now:
> >
> > > (def result (ref {}))
> > > (for [item coll]
> > >(dosync (alter result assoc (dissoc item :c) (item :c
> > > ; result should now have correct value
> >
> > > I also wrote a recursive version to build the map without using a ref,
> > > but I feel like I'm missing a simpler way..
> >
> > (into {}
> >  (map (fn [m] [(dissoc m :c) (:c m)])
> >   [{:a 1 :b 2 :c 3} {:a 4 :b 5 :c 6} {:a 7 :b 8 :c 9}]))
> >
> > -> {{:a 1, :b 2} 3, {:a 4, :b 5} 6, {:a 7, :b 8} 9}
> >
> > Rich
>
> --
> 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: positions

2009-11-22 Thread Emeka
John,

You should have added that you code came from Programming Clojure.

Regards,
Emeka

On Thu, Nov 19, 2009 at 8:05 PM, John Harrop  wrote:

>  On Thu, Nov 19, 2009 at 1:23 PM, Sean Devlin wrote:
>
>> Try clojure.contrib.seq-utils :)
>>
>> As a learning exercise, I'd recommend re-writing it to be lazy.  Your
>> version is eager because it uses loop.  In order to make it lazy,
>> you'd want to construct a lazy-seq.  See the macro w/ the same name.
>>
>> Another choice is to use built-in functions, like this:
>>
>> (defn positions [pred coll]
>>  (map second
>>(filter (comp pred first)
>>  (map vector coll (iterate inc 0)
>
>
> (defn indexed [coll]
>   (map vector (iterate inc 0) coll))
>
> (defn positions [pred coll]
>   (for [[i e] (indexed coll) :when (pred e)] i))
>
> Seems to work:
>
>  user=> (positions even? [1 1 2 9 3 4 8 7 6])
> (2 5 6 8)
>
> (yes, I know there's already an "indexed" with similar semantics in
> clojure.contrib.)
>
>   --
> 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: positions

2009-11-22 Thread Emeka
Nick,

Remember to re-visit indexed and  index-filter functions of programming
Clojure.

Regard,
Emeka

On Thu, Nov 19, 2009 at 7:13 PM, nchubrich wrote:

> Thanks Sean, I'll do the exercise.  I don't know how I missed it in
> seq-utils.
>   After months of programming Clojure, I realize how much I still
> have to learn.
>   (Knowledge is power; knowledge of lack of knowledge is power to
> power.)
>
> Nick.
>
> --
> 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: equivalent to Haskell's group function

2009-11-09 Thread Emeka
(defn group [x]
(loop [newlist [] currlist x]
 (if (not (empty? x))
   (recur (newlist (cons (first x) newlist))
(newlist (cons (first x) newlist))  You are making a function call here
using an empty vector and your argument is a list. This is not possible,
that's why you have that error ([] (cons 7 [])). When you make a vector a
function its argument should the integer. Try and rework your code.
  (currlist (drop-while #(= (first currlist) %) currlist))
This won't work too. drop-while returns a lazy sequence so you have
(currlist (..))
  

I would advice that you should spend some time with clojure, learning its
data structures, function call and others in order to full appreciate how
things play out .

Regards,
Emeka



On Mon, Nov 9, 2009 at 7:08 PM, Wilson MacGyver  wrote:

>
> Thanks guys for the various solutions. I set out trying to try a recur
> solution
>
> So I came up with this. the idea is to go through the collection being
> passed, and grab one element, then do drop-while until a different
> element is encountered. repeat until there is no more left in the
> collection.
>
> (defn group [x]
> (loop [newlist [] currlist x]
>  (if (not (empty? x))
>(recur (newlist (cons (first x) newlist))
>   (currlist (drop-while #(= (first currlist) %) currlist))
>   
>
>
> It seems logical to me, but when I tried it with
> (group [1 1 2 2 3 3 ])
>
> I get
> CompilerException java.lang.IllegalArgumentException: Key must be integer
>
> what am I missing?
>
> 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: equivalent to Haskell's group function

2009-11-09 Thread Emeka
Meikel,

What is the gain of using lazy-seq here? Why can't we go without laziness?

(defn group
  [s]
  (when-let [s (seq s)]
  (let [f(first s)
[fs & r] (split-with #(= % f) s)]
(cons fs (group r)


Regards,
Emeka
On Mon, Nov 9, 2009 at 4:44 PM, Emeka  wrote:

> Meikel,
>
> Is like you over engineered your version?
> (defn group
>   [s]
>   (lazy-seq
> (when-let [s (seq s)]
>   (let [f(first s)
> [fs & r] (split-with #(= % f) s)]
> (cons fs (group r))
> Should be ..
>
> (defn group
>   [s]
>   (lazy-seq
> (when-let [s (seq s)]
>   (let [f(first s)
> [fs   r] (split-with #(= % f) s)]
> (cons fs (group r))
>
> &
>
> Regards,
> Emeka
>
>>
>>
>

--~--~-~--~~~---~--~~
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: equivalent to Haskell's group function

2009-11-09 Thread Emeka
Meikel,

Is like you over engineered your version?
(defn group
  [s]
  (lazy-seq
(when-let [s (seq s)]
  (let [f(first s)
[fs & r] (split-with #(= % f) s)]
(cons fs (group r))
Should be ..

(defn group
  [s]
  (lazy-seq
(when-let [s (seq s)]
  (let [f(first s)
[fs   r] (split-with #(= % f) s)]
(cons fs (group r))

&

Regards,
Emeka

>
>

--~--~-~--~~~---~--~~
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 I make this faster (and leaner) ?

2009-11-01 Thread Emeka
Hello Sir,

(def *valid-chars* (vec "abcdefghijklmnopqrstuvwxuz0123456789" ))

This looks cleaner.

Regards,
Emeka


On Sat, Oct 31, 2009 at 1:15 PM, John Harrop  wrote:

>  On Fri, Oct 30, 2009 at 7:47 PM, DavidF  wrote:
>
>>
>> Try this:
>>
>> (def *valid-chars* [ \a \b \c \d \e \f \g \h \i \j \k \l \m
>> \n \o \p \q \r \s \t \u \v \w \x \u \z
>> \0 \1 \2 \3 \4 \5 \6 \7 \8 \9 ] )
>>
>> (defn generate-key [keylength]
>>(for [x (range keylength)] (nth *valid-chars* (rand-int (count
>> *valid-
>> chars*)
>
>
> There's a perfectly good reusable function hidden in there:
>
> (defn rand-elt [coll]
>   (nth coll (rand-int (count coll
>
> (defn generate-key [key-length]
>   (for [x (range key-length)] (rand-elt *valid-chars*)))
>
> And you might want to wrap that for loop in (apply str ~the-loop). It also
> might be more idiomatic to call *valid-chars* +valid-chars+ if it's not
> normally going to be rebound or otherwise changed.
>
> (While we're on the topic of valid chars, how come the reader page
> http://clojure.org/reader at clojure.org doesn't list as legal identifier
> characters some characters that occur in identifiers in clojure.core?
> Specifically, =, >, and <.
>
> >
>

--~--~-~--~~~---~--~~
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: Periodic tasks

2009-11-01 Thread Emeka
John,

Is like I am missing something? This thread mentioned making periodic tasks,
there was a java example to it. However, what you posted I am yet to figure
out how to make a periodic tasks possible.

Regards,
Emeka

On Sat, Oct 31, 2009 at 6:27 PM, John Harrop  wrote:

>  On Sat, Oct 31, 2009 at 12:36 PM, Luke VanderHart <
> luke.vanderh...@gmail.com> wrote:
>
>> Why not just run an agent that does something, then calls sleep for N
>> seconds, then calls the next thing?
>>
>> Granted, it will eat up a thread in your agent thread pool, but if
>> you've only got one of these in the app it shouldn't be a problem.
>>
>> Or you could go the Java route, and start a daemon thread manually.
>
>
> Or you could use send-off instead of send; send-off doesn't consume from a
> finite thread pool and is thus suitable for long-running (or blocking, e.g.
> I/O) tasks.
>
> Incidentally, if you ever want to simply reset the state of an agent to a
> particular value, analogously to ref-set and reset!, this can work:
>
> (defn set-agent [a v] (send a (fn [_] v)))
>
>
> >
>

--~--~-~--~~~---~--~~
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: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-27 Thread Emeka
John,

That is why I asked that question because I figured out that the problem has
nothing to do with Vector but with #() read macro. I wanted to correct the
impression that the problem was from Vector.

Regards,
Emeka

--~--~-~--~~~---~--~~
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: reading a range from a large file

2009-10-27 Thread Emeka
>
> (with-open [#^Reader r (reader "FILE")]
>   (with-open [lr (java.io.LineNumberReader. r)]
> (.setLineNumber lr 5)
> ;; Your code here.
> )))
>
> Can't the below work?
(with-open [#^Reader r (reader "FILE")][lr (java.io.LineNumberReader. r)]
(


Regards,
Emeka

--~--~-~--~~~---~--~~
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: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-27 Thread Emeka
John,

On Tue, Oct 27, 2009 at 6:10 PM, John Harrop  wrote:

> On Tue, Oct 27, 2009 at 1:39 PM, Emeka  wrote:
>
>> On Sun, Oct 25, 2009 at 4:57 PM, MarkSwanson 
>> wrote:
>>
>>>
>>> Hello,
>>>
>>> Someone recently posed the question: (why doesn't this work)
>>> (into {} (map #([% (* % %)]) [1 2 3 4]))
>>>
>>>
>> Is this actually a Vector problem or the limitation of the anonymous
>> function?
>>
>
> Neither. It's a limitation of the #() read-macro. (fn [x] [x (* x x)])
> works just fine.
>
Is #() read-macro not an anonymous function?

Regards,
Emeka

--~--~-~--~~~---~--~~
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: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-27 Thread Emeka
On Sun, Oct 25, 2009 at 4:57 PM, MarkSwanson wrote:

>
> Hello,
>
> Someone recently posed the question: (why doesn't this work)
> (into {} (map #([% (* % %)]) [1 2 3 4]))
>
>
Is this actually a Vector problem or the limitation of the anonymous
function?

Regards,
Emeka


> (reference:
> http://groups.google.com/group/clojure/browse_thread/thread/7d3ee57ee8041353
> )
>
> The error message was:
> Caused by: java.lang.IllegalArgumentException: Wrong number of args
> passed to: PersistentVector
>
> How many args were being passed anyway? The code looked fine (to me).
> It would have been helpful to me to know the number of args being
> passed was zero.
>
> With the patch below the error message would look like this:
>
> ... java.lang.IllegalArgumentException: Wrong number of args (0)
> passed to: PersistentVector ...
>
> The patch will handle all cases of wrong arity and report the expected
> number of args. In some cases (RestFN) the exception will now report
> the required arity as well as the given arity.
>
> There is one improvement that could still be made to the patch:
> applyTo(ISeq args) -> should report the count of args:
> -   return throwArity();
> +   return throwArity(-1, reqArity); // TODO/BUG: -1 should be count
> of args
>
> I'm running out the door and don't have time to code this.
>
> Please consider this patch - or something like it.
>
>
>
> diff --git a/src/jvm/clojure/lang/AFn.java b/src/jvm/clojure/lang/
> AFn.java
> index e2646ad..56afa8f
> 100644
> --- a/src/jvm/clojure/lang/
> AFn.java
> +++ b/src/jvm/clojure/lang/
> AFn.java
> @@ -45,110 +45,110 @@ public void run()
> {
>
>
>  public Object invoke() throws Exception
> {
> -   return throwArity
> ();
> +   return throwArity
> (0);
>  }
>
>  public Object invoke(Object arg1) throws Exception
> {
> -   return throwArity
> ();
> +   return throwArity
> (1);
>  }
>
>  public Object invoke(Object arg1, Object arg2) throws Exception
> {
> -   return throwArity
> ();
> +   return throwArity
> (2);
>  }
>
>  public Object invoke(Object arg1, Object arg2, Object arg3) throws
> Exception{
> -   return throwArity
> ();
> +   return throwArity
> (3);
>  }
>
>  public Object invoke(Object arg1, Object arg2, Object arg3, Object
> arg4) throws Exception
> {
> -   return throwArity
> ();
> +   return throwArity
> (4);
>  }
>
>  public Object invoke(Object arg1, Object arg2, Object arg3, Object
> arg4, Object arg5) throws Exception
> {
> -   return throwArity
> ();
> +   return throwArity
> (5);
>  }
>
>  public Object invoke(Object arg1, Object arg2, Object arg3, Object
> arg4, Object arg5, Object arg6) throws Exception
> {
> -   return throwArity
> ();
> +   return throwArity
> (6);
>  }
>
>  public Object invoke(Object arg1, Object arg2, Object arg3, Object
> arg4, Object arg5, Object arg6, Object
> arg7)
>throws Exception
> {
> -   return throwArity
> ();
> +   return throwArity
> (7);
>  }
>
>  public Object invoke(Object arg1, Object arg2, Object arg3, Object
> arg4, Object arg5, Object arg6, Object
> arg7,
>  Object arg8) throws Exception
> {
> -   return throwArity
> ();
> +   return throwArity
> (8);
>  }
>
>  public Object invoke(Object arg1, Object arg2, Object arg3, Object
> arg4, Object arg5, Object arg6, Object
> arg7,
>  Object arg8, Object arg9) throws Exception
> {
> -   return throwArity
> ();
> +   return throwArity
> (9);
>  }
>
>  public Object invoke(Object arg1, Object arg2, Object arg3, Object
> arg4, Object arg5, Object arg6, Object
> arg7,
>  Object arg8, Object arg9, Object arg10) throws
> Exception{
> -   return throwArity
> ();
> +   return throwArity
> (10);
>  }
>
>  public Object invoke(Object arg1, Object arg2, Object arg3, Object
> arg4, Object arg5, Object arg6, Object
> arg7,
>  Object arg8, Object arg9, Object arg10, Object
> arg11) throws Exception
> {
> -   return throwArity
> ();
> +   return throwArity
> (11);
>  }
>
>  public Object invoke(Object arg1, Object arg2, Object arg3, Object
> arg4, Object arg5, Object arg6, Object
> arg7,
>  Object arg8, Object arg9, Object arg10, Object
> arg11, Object arg12) throws Exception
> {
> -   return throwArity
> ();
> +   return throwArity
> (12);
>  }
>
>  public Object invoke(Object arg1, Object arg2, 

Re: server-socket on exit event

2009-10-16 Thread Emeka
Ngo,

I checked out your github , it is great. I have not used netty, it looks
clean. However, what is the meaning of this, (def reshedule nil)?


Regards,
Emeka


On Thu, Oct 15, 2009 at 3:02 AM, ngocdaothanh wrote:

>
> I created this (Netty is used instead of server-socket):
> http://github.com/ngocdaothanh/telchat-clojure
>
> I am going to create a Scala version of the same program to have a
> feeling of Clojure vs Scala, it will be telchat-scala.
>
>
> On Oct 14, 10:12 pm, Emeka  wrote:
> > Ngo,
> >
> > Honestly  speaking I don't know. How far have you gone?
> >
> > Regards,
> > Emeka
> >
> > On Sat, Oct 3, 2009 at 3:21 PM, ngocdaothanh 
> wrote:
> >
> > > Emeka, good catch. It's just my mistake.
> >
> > > Another thing is I think there may be exception raised when on-msg
> > > sends message to a closed socket. How would you solve this?
> >
> > > On Oct 3, 7:35 pm, Emeka  wrote:
> > > > ngo,
> > > > I was about doing this kind of client/server thing some  days ago,
> > > however
> > > > now you are into it I would like to learn then. I am not quite clear
> why
> > > you
> > > > have this:
> > > > (.start (new Thread (fn [] (create-server 8080 chat-loop
> >
> > > > My concern is on  Thread, create-server function has a Thread inside
> > > > create-server-aux function.
> >
> > > > Regards,
> > > > Emeka
> >
> > > > On Fri, Oct 2, 2009 at 3:13 AM, ngocdaothanh  >
> > > wrote:
> >
> > > > > > I'm not sure TCP/IP has a native facility for that.
> >
> > > > > I'm afraid John's statement is correct:
> >
> > > > >
> http://www.velocityreviews.com/forums/t125620-client-socket-disconnec.
> > > ..
> > > > > and trying to read and write until something wrong happens as
> > > > > demonstrated in Roger's code is the only way to check for
> > > > > disconnection.
> >
> > > > > Below is my new code. Sorry it is rather long.
> >
> > > > > (import '[java.io BufferedReader InputStreamReader
> > > > > OutputStreamWriter])
> > > > > (use 'clojure.contrib.server-socket)
> >
> > > > > (def clients (ref []))  ; Each client is an *out*
> >
> > > > > (defn on-msg [from msg]
> > > > >  (println msg)
> > > > >  (doall
> > > > >(map
> > > > >  (fn [client]
> > > > >(if-not (= from client)
> > > > >  (binding [*out* client]
> > > > >(println msg)
> > > > >(flush
> > > > >  @clients)))
> >
> > > > > (defn on-disconnect [client]
> > > > >  (dosync
> > > > >(alter clients
> > > > >  (fn [clients]
> > > > >(remove (fn [c] (= c client)) clients
> > > > >  (on-msg client "A client has disconnected"))
> >
> > > > > (defn on-connect [client]
> > > > >  (dosync (alter clients conj client))
> > > > >  (on-msg client "A client has connected"))
> >
> > > > > (defn chat-loop [is os]
> > > > >  (let [client (OutputStreamWriter. os)]
> > > > >(on-connect client)
> > > > >(binding [*in* (BufferedReader. (InputStreamReader. is))]
> > > > >  (loop []
> > > > >(let [msg (read-line)]  ; msg is nil when the client
> > > > > disconnects
> > > > >  (if (nil? msg)
> > > > >(on-disconnect client)
> > > > >(do
> > > > >  (on-msg client msg)
> > > > >  (recur
> >
> > > > > (.start (new Thread (fn [] (create-server 8080 chat-loop
> >
> > > > > On Oct 2, 5:20 am, John Harrop  wrote:
> > > > > > On Thu, Oct 1, 2009 at 4:02 PM, Roger Gilliar 
> > > wrote:
> > > > > > > Am 01.10.2009 um 21:28 schrieb ngocdaothanh:
> > > > > > > > Roger, your code is not event based.
> > > > > > > What do you mean by not event based ?
> >
> > > > > > He means he wants automatic notification if a connection is
> dropped.
> >
> > > > > > I'm not sure TCP/IP has a native facility for that.
> >
> > > > > > What most chat type programs, multiplayer games, and suchlike do
> is
> > > send
> > > > > a
> > > > > > periodic ping from server to each connected client, which as part
> of
> > > the
> > > > > > chat protocol the client is supposed to acknowledge. If a client
> > > stops
> > > > > > responding for more than a few ping-intervals, it's assumed to
> have
> > > > > > disconnected or otherwise become unreachable.
> >
> > > > > > This method has the advantage of being entirely under the control
> of
> > > the
> > > > > > application layer, and the further advantage of also working with
> UDP
> > > > > (which
> > > > > > is crucial in the "multiplayer games" case at least).
> >
>

--~--~-~--~~~---~--~~
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: server-socket on exit event

2009-10-14 Thread Emeka
Ngo,

Honestly  speaking I don't know. How far have you gone?

Regards,
Emeka

On Sat, Oct 3, 2009 at 3:21 PM, ngocdaothanh  wrote:

>
> Emeka, good catch. It's just my mistake.
>
> Another thing is I think there may be exception raised when on-msg
> sends message to a closed socket. How would you solve this?
>
>
> On Oct 3, 7:35 pm, Emeka  wrote:
> > ngo,
> > I was about doing this kind of client/server thing some  days ago,
> however
> > now you are into it I would like to learn then. I am not quite clear why
> you
> > have this:
> > (.start (new Thread (fn [] (create-server 8080 chat-loop
> >
> > My concern is on  Thread, create-server function has a Thread inside
> > create-server-aux function.
> >
> > Regards,
> > Emeka
> >
> > On Fri, Oct 2, 2009 at 3:13 AM, ngocdaothanh 
> wrote:
> >
> > > > I'm not sure TCP/IP has a native facility for that.
> >
> > > I'm afraid John's statement is correct:
> >
> > >http://www.velocityreviews.com/forums/t125620-client-socket-disconnec.
> ..
> > > and trying to read and write until something wrong happens as
> > > demonstrated in Roger's code is the only way to check for
> > > disconnection.
> >
> > > Below is my new code. Sorry it is rather long.
> >
> > > (import '[java.io BufferedReader InputStreamReader
> > > OutputStreamWriter])
> > > (use 'clojure.contrib.server-socket)
> >
> > > (def clients (ref []))  ; Each client is an *out*
> >
> > > (defn on-msg [from msg]
> > >  (println msg)
> > >  (doall
> > >(map
> > >  (fn [client]
> > >(if-not (= from client)
> > >  (binding [*out* client]
> > >(println msg)
> > >(flush
> > >  @clients)))
> >
> > > (defn on-disconnect [client]
> > >  (dosync
> > >(alter clients
> > >  (fn [clients]
> > >(remove (fn [c] (= c client)) clients
> > >  (on-msg client "A client has disconnected"))
> >
> > > (defn on-connect [client]
> > >  (dosync (alter clients conj client))
> > >  (on-msg client "A client has connected"))
> >
> > > (defn chat-loop [is os]
> > >  (let [client (OutputStreamWriter. os)]
> > >(on-connect client)
> > >(binding [*in* (BufferedReader. (InputStreamReader. is))]
> > >  (loop []
> > >(let [msg (read-line)]  ; msg is nil when the client
> > > disconnects
> > >  (if (nil? msg)
> > >(on-disconnect client)
> > >(do
> > >  (on-msg client msg)
> > >  (recur
> >
> > > (.start (new Thread (fn [] (create-server 8080 chat-loop
> >
> > > On Oct 2, 5:20 am, John Harrop  wrote:
> > > > On Thu, Oct 1, 2009 at 4:02 PM, Roger Gilliar 
> wrote:
> > > > > Am 01.10.2009 um 21:28 schrieb ngocdaothanh:
> > > > > > Roger, your code is not event based.
> > > > > What do you mean by not event based ?
> >
> > > > He means he wants automatic notification if a connection is dropped.
> >
> > > > I'm not sure TCP/IP has a native facility for that.
> >
> > > > What most chat type programs, multiplayer games, and suchlike do is
> send
> > > a
> > > > periodic ping from server to each connected client, which as part of
> the
> > > > chat protocol the client is supposed to acknowledge. If a client
> stops
> > > > responding for more than a few ping-intervals, it's assumed to have
> > > > disconnected or otherwise become unreachable.
> >
> > > > This method has the advantage of being entirely under the control of
> the
> > > > application layer, and the further advantage of also working with UDP
> > > (which
> > > > is crucial in the "multiplayer games" case at least).
> >
>

--~--~-~--~~~---~--~~
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: ANN: scriptjure, a library for generating javascript

2009-10-08 Thread Emeka
Allen,
Great job!

Did you try
(defmulti emit class) ?

Regards,
Emeka

On Thu, Oct 8, 2009 at 7:18 AM, Meikel Brandmeyer  wrote:

>
> Hi,
>
> On Oct 8, 7:50 am, Jarkko Oranen  wrote:
>
> > I took a quick look, and that looks really neat. One thing though:
> > Instead of the "clj" form to escape back to clojure, why not just use
> > "unquote" (and possibly unquote-splicing)? that would allow you to use
> > the ~ reader macro as a shortcut, just like in syntax-quote.
>
> +1
>
> 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: server-socket on exit event

2009-10-03 Thread Emeka
ngo,
I was about doing this kind of client/server thing some  days ago, however
now you are into it I would like to learn then. I am not quite clear why you
have this:
(.start (new Thread (fn [] (create-server 8080 chat-loop

My concern is on  Thread, create-server function has a Thread inside
create-server-aux function.

Regards,
Emeka



On Fri, Oct 2, 2009 at 3:13 AM, ngocdaothanh  wrote:

>
> > I'm not sure TCP/IP has a native facility for that.
>
> I'm afraid John's statement is correct:
>
> http://www.velocityreviews.com/forums/t125620-client-socket-disconnection-event-not-received-on-server-socket-java-nio.html
> and trying to read and write until something wrong happens as
> demonstrated in Roger's code is the only way to check for
> disconnection.
>
> Below is my new code. Sorry it is rather long.
>
> (import '[java.io BufferedReader InputStreamReader
> OutputStreamWriter])
> (use 'clojure.contrib.server-socket)
>
> (def clients (ref []))  ; Each client is an *out*
>
> (defn on-msg [from msg]
>  (println msg)
>  (doall
>(map
>  (fn [client]
>(if-not (= from client)
>  (binding [*out* client]
>(println msg)
>(flush
>  @clients)))
>
> (defn on-disconnect [client]
>  (dosync
>(alter clients
>  (fn [clients]
>(remove (fn [c] (= c client)) clients
>  (on-msg client "A client has disconnected"))
>
> (defn on-connect [client]
>  (dosync (alter clients conj client))
>  (on-msg client "A client has connected"))
>
> (defn chat-loop [is os]
>  (let [client (OutputStreamWriter. os)]
>(on-connect client)
>(binding [*in* (BufferedReader. (InputStreamReader. is))]
>  (loop []
>(let [msg (read-line)]  ; msg is nil when the client
> disconnects
>  (if (nil? msg)
>(on-disconnect client)
>(do
>  (on-msg client msg)
>  (recur
>
> (.start (new Thread (fn [] (create-server 8080 chat-loop
>
>
> On Oct 2, 5:20 am, John Harrop  wrote:
> > On Thu, Oct 1, 2009 at 4:02 PM, Roger Gilliar  wrote:
> > > Am 01.10.2009 um 21:28 schrieb ngocdaothanh:
> > > > Roger, your code is not event based.
> > > What do you mean by not event based ?
> >
> > He means he wants automatic notification if a connection is dropped.
> >
> > I'm not sure TCP/IP has a native facility for that.
> >
> > What most chat type programs, multiplayer games, and suchlike do is send
> a
> > periodic ping from server to each connected client, which as part of the
> > chat protocol the client is supposed to acknowledge. If a client stops
> > responding for more than a few ping-intervals, it's assumed to have
> > disconnected or otherwise become unreachable.
> >
> > This method has the advantage of being entirely under the control of the
> > application layer, and the further advantage of also working with UDP
> (which
> > is crucial in the "multiplayer games" case at least).
> >
>

--~--~-~--~~~---~--~~
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: Re: "Schema" for data structures

2009-10-01 Thread Emeka
Artyom,

> (provide/contract
>[interp  (-> AE? number?)])
>
> ;; interpret an arithmetical expression yielding a number
> (define (interp exp)
>   ;; type-case is very much like a "case ... of" in Haskell/ML
>   (type-case AE exp
> (num (n) n)
> (plus (l r) (+ (interp l) (interp r)))
> (sub (l r) (- (interp l) (interp r)
>

It also looks like clojure condp.

Emeka

>
> Contracts work only between module boundaries though.
>
> Cheers,
> Artyom Shalkhakov.
>
> >
>

--~--~-~--~~~---~--~~
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: Getting REPL transcript

2009-09-26 Thread Emeka
Sorry, here is the link.
http://gist.github.com/193550



On Sat, Sep 26, 2009 at 2:03 PM, Emeka  wrote:

> Thank you all. Chris Grand has figured it out for me. However, I invite you
> to look at it and comment.
>
> Regards,
> Emeka
>
>
> On Sat, Sep 26, 2009 at 12:15 PM, Daniel Werner <
> daniel.d.wer...@googlemail.com> wrote:
>
>>
>> On Sep 23, 6:20 pm, Emeka  wrote:
>> > Hello All,
>> >
>> > I would like to have a transcript of Repl. Could someone help me out
>> here?
>> >
>> > Regards,
>> > Emeka
>>
>> If you use rlwrap, you can give it the --log-file (-l) argument:
>>
>> $ rlwrap -l repl.log java -cp ...
>> >>
>>
>

--~--~-~--~~~---~--~~
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: Getting REPL transcript

2009-09-26 Thread Emeka
Thank you all. Chris Grand has figured it out for me. However, I invite you
to look at it and comment.

Regards,
Emeka

On Sat, Sep 26, 2009 at 12:15 PM, Daniel Werner <
daniel.d.wer...@googlemail.com> wrote:

>
> On Sep 23, 6:20 pm, Emeka  wrote:
> > Hello All,
> >
> > I would like to have a transcript of Repl. Could someone help me out
> here?
> >
> > Regards,
> > Emeka
>
> If you use rlwrap, you can give it the --log-file (-l) argument:
>
> $ rlwrap -l repl.log java -cp ...
> >
>

--~--~-~--~~~---~--~~
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: Getting REPL transcript

2009-09-25 Thread Emeka
Thanks I will look into that. But more information on 'pipe' please?
So we have two Newman{Rich, John}, so I will say thanks to Newmen.

Regards,
Emeka

On Fri, Sep 25, 2009 at 10:43 AM, John Newman  wrote:

> I'm still learning, myself, so I could be wrong, but you might be able to
> use clojure.contrib.server-socket and tweak it's binding for *in*, *out*,
> and *err*, like another PushbackInputStream for *in* and copy the lines to a
> file before sending it into the repl.
>
> Or use a pipe perhaps?
>
> --
> John
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Getting REPL transcript

2009-09-24 Thread Emeka
Rich,

Hmm, it is what I'm looking for.Just the way I planned it to be. The next
issue now is on how to  craft it   into clojure.

Regards,
Emeka

On Thu, Sep 24, 2009 at 7:59 AM, Richard Newman  wrote:

>
> > Actually, that suggests a more general point: that we can have
> > programmatic access to the REPL's backlog if we modify the REPL
> > process's Java code somewhat. A simple example would be to make a
> > repl.class that would provide an interactive stdin/stdout repl but
> > log everything to a ./repl.log file or whatever. This could be used
> > to obtain a text file with the interaction history afterward, to
> > massage, cut and paste from, etc. to one's heart's content in a text
> > editor. Even on MS-DOS, if anyone still uses such a dinosaur. :)
>
> I've mentioned this before:
>
> http://www.franz.com/support/documentation/8.1/ansicl/dictentr/dribble.htm
>
> This problem has been solved for 25 years.
>
> >
>

--~--~-~--~~~---~--~~
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: Getting REPL transcript

2009-09-24 Thread Emeka
Hello John ,

>
> A standalone REPL on Windows is amenable to making the command prompt
> window's backscroll big enough, if needed, and then copying from it using
> the prompt window's mark/copy mode. A standalone REPL on MS-DOS is tougher.
> The only way I know of short of installing Windows is to redirect the REPL's
> output to a file, but then you'd have to interact with it blind, and since
> it has line editing on the prompt line, the file might have escape sequences
> and/or other cruft in it and need some postprocessing. It might be best in
> that case to create a text file with expressions you want to evaluate at the
> REPL, then run the REPL process with input redirected from this file and
> output redirected to another file, to get a clean output and not have to
> type blind. The downside is this isn't as interactive; you can't change your
> mind or decide stuff after seeing some of the results, but only after seeing
> ALL of the results and then altering the input file.
>

I want it to work as standalone REPL on MS-DOS. You said it is tougher,then
am hopeless. I don't intend to interact with log file(for now I don't have
that idea) , I would want to use it later for historical studies and may be
other things.
Could you give me a lead?

Regards,
Emeka

>
> I'd recommend against using a standalone REPL on DOS, or on terminal-mode
> Unix which is only slightly friendlier thanks to the availability of screen.
> Use a terminal emulator from a GUI desktop, if not an IDE.
>
>
> >
>

--~--~-~--~~~---~--~~
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: Getting REPL transcript

2009-09-23 Thread Emeka
Mic,

Or use "script" . I don't think I understood clearly what you are referring
to.

Regards,
Emeka

On Wed, Sep 23, 2009 at 4:40 PM, Michael Wood  wrote:

>
> 2009/9/23 Phil Hagelberg :
> >
> > Emeka  writes:
> >
> >> I would like to have a transcript of Repl. Could someone help me out
> here?
> >
> > Sure; run it in GNU Screen with logging turned on.
> >
> >  $ screen -l
> >  $ rlwrap java -cp clojure.jar clojure.main
> >  => (do some stuff)
> >
> > It will get written to screenlog.0.
>
> Or use "script".
>
> I'm sure there was a thread about this a few months ago.  There might
> be some more useful suggestions if you manage to find it in the
> archives.
>
> --
> 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
-~--~~~~--~~--~--~---



Getting REPL transcript

2009-09-23 Thread Emeka
Hello All,

I would like to have a transcript of Repl. Could someone help me out here?

Regards,
Emeka

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



Managing Clojure project files

2009-09-22 Thread Emeka
Hello All,

Please make out time and check the below link. And if you consider the code
there useful, I  encourage you to use it.
I would appreciate your comments and reviews.

http://emekamicro.blogspot.com/2009/09/managing-clojure-project-files.html

Regards,
Emeka

--~--~-~--~~~---~--~~
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: Is knowing Java a prerequisite for using Clojure?

2009-09-18 Thread Emeka
Hugh,

I receive Factor mails, however, I am still learning Forth/Factor. IMHO, you
should spend much of your time in Java while casually going through Clojure
book. Factor and Clojure are FP languages and I must confess they are close
cousins. I have heard you mention gcode and other stuff in Factor
mailinglist but I have no clue what they are.

Regards,
Emeka

On Fri, Sep 18, 2009 at 2:01 AM, Hugh Aguilar wrote:

>
>
> On Sep 17, 9:33 am, Brian  wrote:
> > As a Java programmer coming to Clojure I would be very interested in the
> > intended application.  How you approach that from a Clojure perspective
> is
> > what I'm interested in.  I've programmed in Lisp in the distant past
> > (Symbolics Lisp machines) and still have very found memories of that
> > environment.  Having programmed in C -> C++ -> Java since then ... well I
> > just miss the edit run test cycle that was so natural with those Lisp
> > machines.
>
> I'll give you guys a brief overview of what I want to do. I'm sure
> that as Clojure enthusiasts you will want to say that Clojure can do
> anything. On the other hand, you might tell me that Clojure is a bad
> fit and that I would be better off with xxx, and I would appreciate
> that advice too.
>
> I want to create a DSL for generating gcode for cnc milling machines
> and lathes, and maybe even more complicated machines such as 5-axis
> laser cutters. I need a language (possibly Clojure) that is simple
> enough to be used by non-programmers whose only background in
> programming is writing gcode.
>
> My first choice was Forth. That is by far my own favorite language. I
> am considering Clojure primarily because it offers a macro facility
> somewhat comparable to Forth compile-time words, which I think is
> necessary for writing a DSL. Also, it is similarly interactive, and I
> can't really ask the users to compile a program and then trace it in a
> debugger --- especially as I consider that to be a clumsy technique
> even for me to do. I know that languages such as Groovy and Ruby have
> been used for writing DSLs (Grails and Rails), and they don't have
> compile-time code, but I don't really understand that kind of
> programming --- I've been writing compile-time code all of my life and
> that is my standard technique for simplifying programs. The reason why
> I am considering Clojure rather than just going with Forth is because
> I am interested in Clojure's focus on sequences and laziness. I see
> this as a trade-off between thinking about programming in terms of
> time (procedural, like Forth) and thinking about programming in terms
> of space (sequences, like Clojure). I think that machinists would be
> more comfortable thinking about space than time because they generally
> work with physical objects that exist in space, and what they
> primarily struggle with is thinking about time, which is what raw
> gcode is all about.
>
> One other thing that I need is security. I had considered using
> Factor, which is a Lisp/Forth hybrid. I don't think this will work
> though because I can't make a language like Factor available to
> machinists. The company owners would worry that these guys would trash
> the data on the computer's hard-drive and/or use the language to write
> computer games and generally goof around on company time. The company
> owners are only going to be comfortable with allowing their employees
> to program if this programming is done in a sandbox. Pretty much any
> language that is written on top of another language will provide this
> security. For example, Lua or FICL could be used so long as it is
> crippled in such a way as to prevent the user from accessing the hard-
> drive or the internet or anything except his own sandbox. Still
> though, I can't just write a gcode library in C++ or Factor --- I
> would need to write a scripting language on top of C++ or Factor that
> provides a safe environment separate from the underlying language.
> Clojure should work well because the JVM is a sandbox. There is also
> more depth there because the entire Java system would be available to
> the user, and still be secure. By comparison, with Lua or FICL the C++
> system is not available except for any libraries that I (laboriously)
> write wrappers for. With Clojure I would get the depth of the Java
> system, while still having the simplicity of Clojure --- I don't want
> to try to tell machinists that they need to learn Java, especially as
> I consider that to be a pretty daunting task even for me to do.
>
> You mentioned having come from a Common Lisp background. Would you
> recommend CL rather than Clojure for what I'm doing?
>
> Do any of you have experience

Re: Windows user

2009-09-03 Thread Emeka
I will wait for the windows installer .

Regards,
Emeka

On Thu, Sep 3, 2009 at 8:07 PM, Meikel Brandmeyer  wrote:

> Hello Emeka,
>
> Am 03.09.2009 um 18:01 schrieb Emeka:
>
>  I am still waiting for the day I could start off using vimclojure on my
>> PC. Is vimclojure ready for my environment? And is it easy to install?
>>
>
> I'm using a Windows setup at work and works without much trouble. Currently
> the setup is a bit hairy on Windows due to some arbitrary limitations
> imposed by the host platform. But Justin Johnson is working on Windows
> installer including some launchers to start the nailgun server.
>
> 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
-~--~~~~--~~--~--~---



Windows user

2009-09-03 Thread Emeka
Hello Meikel,

I am still waiting for the day I could start off using vimclojure on my PC.
Is vimclojure ready for my environment? And is it easy to install?

Regards,
Emeka

--~--~-~--~~~---~--~~
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: Searching the group archives

2009-09-02 Thread Emeka
Another way of searching .

Instead of "Search this group" use "Search Groups" , and inform google of
the group you intend search and your message. Here is an example, re-find
group:clojure .


Regards,
Emeka

On Sun, Aug 30, 2009 at 12:19 PM, Emeka  wrote:

> Thanks, I was about asking for help.
>
> Regards,
> Emeka
>
> On Sat, Aug 29, 2009 at 6:54 PM, Rich Hickey  wrote:
>
>>
>> While the "Search this group" interface seems increasingly anemic, and
>> time-limited in its results, you can get an effective search on the
>> group archives using the advanced search:
>>
>> http://groups.google.com/advanced_search?q=&;
>>
>> Just select google groups and put clojure as the group.
>>
>> Rich
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Java security code in Clojure

2009-08-31 Thread Emeka
Sorry, I was too quick. I misunderstood your code.

Regards,
Emeka

On Mon, Aug 31, 2009 at 6:10 PM, Emeka  wrote:

>
> Hello Sam,
>
> From the Java version you used created array ,byte[] encodedKey = new
> byte[(int) keyFile.length()];, but in clojure version you did (into-array
> Byte/TYPE (byte-seq stream)) , why not  use make-array here.
>
> (byte-seq stream) returns list, is that the right argument for constructor
> call?
>
> Did  you try this;
>
> (make-array Byte/TYPE (int (. (java.io.File. "public.der") length)))
>
> Regards,
> Emeka
>   On Mon, Aug 31, 2009 at 11:19 AM, Sam Hughes 
> wrote:
>
>>
>> Hey,
>>
>> I'm trying to write a Clojure security library. My first step is
>> porting some working Java code into Clojure. The Java and Clojure
>> snippets below are more or less the same, but with the Clojure code,
>> I'm getting: "java.security.InvalidKeyException: IOException: null
>> [Thrown class java.security.spec.InvalidKeySpecException]," which I
>> can't seem to replicate with the Java code.
>>
>> The goal of the code is to read in a DER file, use it to encrypt a
>> "Hello World" message, then output the encrypted message as a new
>> file.
>>
>> Neither of these snippets necessarily follow good coding standards.
>> That said, here's the working Java code snippet:
>>
>> final File keyFile = new File("public.der");
>> byte[] encodedKey = new byte[(int) keyFile.length()];
>>
>> new FileInputStream(keyFile).read(encodedKey);
>> final byte[] newEncoded = encodedKey;
>>
>> final X509EncodedKeySpec keySpec = new X509EncodedKeySpec(newEncoded);
>> KeyFactory kf = KeyFactory.getInstance("RSA");
>> PublicKey pk = kf.generatePublic(keySpec);
>>
>> Cipher rsa = Cipher.getInstance("RSA");
>> rsa.init(Cipher.ENCRYPT_MODE, pk);
>> OutputStream os = new CipherOutputStream(new FileOutputStream
>> ("encrypted.rsa"), rsa);
>>
>> Writer out = new OutputStreamWriter(os);
>> out.write("Hello World");
>> out.close();
>> os.close();
>>
>> And here's the Exception throwing Clojure code:
>>
>> (ns security
>>  (:import
>>   [java.io File FileInputStream IOException]
>>   [java.security.spec X509EncodedKeySpec]
>>   [java.security KeyFactory PublicKey
>>KeyPairGenerator NoSuchAlgorithmException KeyPair]
>>   [javax.crypto KeyGenerator Cipher]))
>>
>> (defn byte-seq [rdr]
>>  (let [result (byte (. rdr read))]
>>(if (= result -1)
>>  (do (. rdr close) nil)
>>  (lazy-seq (cons result (byte-seq rdr))
>>
>> (def stream (new FileInputStream (new File "public.der")))
>> (def byte-arr (into-array Byte/TYPE (byte-seq stream)))
>> (def pk-spec (new X509EncodedKeySpec byte-arr))
>> (def kf (. KeyFactory (getInstance "RSA")))
>> (def pk (. kf (generatePublic pk-spec)))  ; exception thrown
>> here
>>
>> Does anyone have any suggestion for what could be causing the
>> exception? I'm perplexed because, right now, I'm just trying to
>> replicate Java code in Clojure -- nothing too fancy.
>>
>> Thanks a lot,
>> Sam
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Java security code in Clojure

2009-08-31 Thread Emeka
Hello Sam,

>From the Java version you used created array ,byte[] encodedKey = new
byte[(int) keyFile.length()];, but in clojure version you did (into-array
Byte/TYPE (byte-seq stream)) , why not  use make-array here.

(byte-seq stream) returns list, is that the right argument for constructor
call?

Did  you try this;

(make-array Byte/TYPE (int (. (java.io.File. "public.der") length)))

Regards,
Emeka
On Mon, Aug 31, 2009 at 11:19 AM, Sam Hughes wrote:

>
> Hey,
>
> I'm trying to write a Clojure security library. My first step is
> porting some working Java code into Clojure. The Java and Clojure
> snippets below are more or less the same, but with the Clojure code,
> I'm getting: "java.security.InvalidKeyException: IOException: null
> [Thrown class java.security.spec.InvalidKeySpecException]," which I
> can't seem to replicate with the Java code.
>
> The goal of the code is to read in a DER file, use it to encrypt a
> "Hello World" message, then output the encrypted message as a new
> file.
>
> Neither of these snippets necessarily follow good coding standards.
> That said, here's the working Java code snippet:
>
> final File keyFile = new File("public.der");
> byte[] encodedKey = new byte[(int) keyFile.length()];
>
> new FileInputStream(keyFile).read(encodedKey);
> final byte[] newEncoded = encodedKey;
>
> final X509EncodedKeySpec keySpec = new X509EncodedKeySpec(newEncoded);
> KeyFactory kf = KeyFactory.getInstance("RSA");
> PublicKey pk = kf.generatePublic(keySpec);
>
> Cipher rsa = Cipher.getInstance("RSA");
> rsa.init(Cipher.ENCRYPT_MODE, pk);
> OutputStream os = new CipherOutputStream(new FileOutputStream
> ("encrypted.rsa"), rsa);
>
> Writer out = new OutputStreamWriter(os);
> out.write("Hello World");
> out.close();
> os.close();
>
> And here's the Exception throwing Clojure code:
>
> (ns security
>  (:import
>   [java.io File FileInputStream IOException]
>   [java.security.spec X509EncodedKeySpec]
>   [java.security KeyFactory PublicKey
>KeyPairGenerator NoSuchAlgorithmException KeyPair]
>   [javax.crypto KeyGenerator Cipher]))
>
> (defn byte-seq [rdr]
>  (let [result (byte (. rdr read))]
>(if (= result -1)
>  (do (. rdr close) nil)
>  (lazy-seq (cons result (byte-seq rdr))
>
> (def stream (new FileInputStream (new File "public.der")))
> (def byte-arr (into-array Byte/TYPE (byte-seq stream)))
> (def pk-spec (new X509EncodedKeySpec byte-arr))
> (def kf (. KeyFactory (getInstance "RSA")))
> (def pk (. kf (generatePublic pk-spec)))  ; exception thrown
> here
>
> Does anyone have any suggestion for what could be causing the
> exception? I'm perplexed because, right now, I'm just trying to
> replicate Java code in Clojure -- nothing too fancy.
>
> Thanks a lot,
> Sam
>
> >
>

--~--~-~--~~~---~--~~
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: Help

2009-08-30 Thread Emeka
Angel,

 (note the space between & and v) --> no clojure here... it's English... :-)
>
> If you write &v (without space) it's just another identifier &v.


You are pretty right. However, for your case to hold that &v is another
identifier, just try it out.

Regards,
Emeka

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



Help

2009-08-30 Thread Emeka
Hello All,

I was fooling around with clojure and I found something I have not noticed
before. Could someone explain it ?

(defn foo [ &v]
(apply + &v))

Is '&' + the identifier's name another where of making sure that the
parameter must be a collection?
Or is there something I am doing wrong here? To be honest, I am pretty
tired.
Happy Sunday!

Regards,
Emeka

--~--~-~--~~~---~--~~
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: Searching the group archives

2009-08-30 Thread Emeka
Thanks, I was about asking for help.

Regards,
Emeka

On Sat, Aug 29, 2009 at 6:54 PM, Rich Hickey  wrote:

>
> While the "Search this group" interface seems increasingly anemic, and
> time-limited in its results, you can get an effective search on the
> group archives using the advanced search:
>
> http://groups.google.com/advanced_search?q=&;
>
> Just select google groups and put clojure as the group.
>
> Rich
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Java STM

2009-08-28 Thread Emeka
Peter, you will get there some day.



On Fri, Aug 28, 2009 at 8:45 AM, peter veentjer wrote:

>
> > No. I don't want to use transactions for workflow. I don't want
> > blocking transactions. I don't want read tracking.
>
> With multiverse it depends on the engine being used and the settings
> on the transaction. And readonly transactions also don't track reads.
>
> > > And since Clojure is using MVCC, does it also suffer from a broken
> > > serialized isolation level?
> http://pveentjer.wordpress.com/2008/10/04/breaking-oracle-serializable/
> >
> > Clojure doesn't promise any "serialized isolation level". It provides
> > snapshot isolation, which is subject to write skew, as better
> > described here:
> >
> > http://en.wikipedia.org/wiki/Snapshot_isolation
> >
> > In order to prevent write skew, Clojure provides the 'ensure'
> > operation which can be used for reads to non-written refs that form
> > part of the integrity promise of a transaction, without incurring that
> > overhead all the time for reads that do not. I much prefer having this
> > fine-grained choice.
>
> I'll have a look at it.
>
> >
> > > And what kind of performance do you get with clojure?
> >
> > I'll let other people answer that from their experience, but only say
> > that it is probably too general a question to be particularly
> > meaningful.
>
> True.
>
> > Clojure's STM is part of a holistic language design where
> > people will normally be programming with immutable persistent
> > composite data structures. Getting a consistent view of such a data
> > structure doesn't require a transaction at all, so that is much faster
> > than other strategies. When 'changing' a data structure, you read it
> > from the ref once and then structural changes do not involve the STM
> > or refs. Store it back in the ref when done. Thus the granularity of
> > transactions is coarse and the number of ref interactions involved
> > small. These are not things you'll see when timing pounding an integer
> > in a transactional ref in a tight loop, but matter greatly in
> > practice, IMO.
>
> I partly agree. One of my design guidelines is that one should not
> have to pay
> for what is not being used.
>
> One of the things I'm focussing on is making the transaction
> as fast as possible for any length. I'm working on a system that
> advices the
> creation of a transaction with the maximum number of attached objects.
> I have
>  a transaction optimised for a single attachment (5+M transactions/
> second on a single core),
> for a small number of attachments (so using an array to store attached
> items to reduce object creation)
> and one for a large number of attachments (so using an expensive
> hashmap).
> The later one also is going to get a parallel commit (so obtaining
> locks/checking for
> isolation problems.. and doing the write) to make effective use of the
> cores and speed
> up the commit of larger transactions.
>
> So I'm working on all levels to make it as fast as possible and
> pounding
> on an intref is something that helps to find a subset of problem
> areas. And if something
> is fast enough, people don't try to work around it.. so it also helps
> to reduce complexity imho.
>
> But again, I think that clojure is doing a great job. You have a cool
> language,
>  a cool stm, an active community and a lot of exposure. So you are
> where I
> want to be :)
>
> > Rich
> > > PS:
> > > I think that Clojure really did a great job with adding STM to the
> > > language. I have been working on multiverse for almost a year,
> > > and I only have an stm. With Clojure the STM is one of the many
> > > features provided.
> >
> > > > On Mon, Jul 13, 2009 at 2:07 AM, Vagif Verdi
> wrote:
> >
> > > > > Potentially interesting library for clojurians. Java STM
> > > > > implementation:http://www.deucestm.org/
> >
> > > > --
> > > > 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: clojure vs scala

2009-08-28 Thread Emeka
e,

I just picked a new word 'Rogramming'?

Regards,
Emeka

On Fri, Aug 28, 2009 at 1:30 AM, e  wrote:

>
>
>  On Thu, Aug 27, 2009 at 9:57 AM, Emeka  wrote:
>
>> e,
>>
>> What is inspiring in it?
>>
>
> H  from time to time, people use percent literacy as a measure of
> public intellectual health, right?  In that case, it's sort of obvious that
> literacy is a goal.   Well, I'm wondering if we need to add a 4th
> fundamental to the 3 R's (Reading, Riting and 'Rithmetic) ... namely
> 'Rogramming.  That opens up a lot of conversation.  To summarize a paragraph
> that I just erase (was getting a little silly), to me Stuart's point is the
> same as to say that it is not the intent of poems (or even some good movies)
> to be understood completely, all at once, and right away.  There are plenty
> of other worthwhile things in that category, too ... like perhaps clojure.
>
>
>
>>
>> Regards,
>> Emeka
>>
>>   On Thu, Aug 27, 2009 at 1:44 PM, e  wrote:
>>
>>>  On Thu, Aug 27, 2009 at 8:43 AM, Stuart Halloway <
>>> stuart.hallo...@gmail.com> wrote:
>>>
>>>>
>>>> As the author of the book, you can bet I have an opinion on the
>>>> quality of the docs. :-)
>>>>
>>>> (1) I think the documentation for Clojure (website, Mark Volkmann's
>>>> long article [1], blog posts, the book [2]) is *insanely* good, given
>>>> how young the language is. But...
>>>>
>>>> (2) If you are coming from a mainstream business software environment,
>>>> there are a ton of new ideas in Clojure. There's more to learn, so of
>>>> course it is going be harder, and take longer. You won't get there
>>>> just by reading one book, even if you work through all the code
>>>> examples. I *love* that Rich's recommended reading list [3] has not 2,
>>>> or 4, but 36 books!! Clojure stands in opposition to the "in 21 days
>>>> for dummies" [4] school of thought.
>>>>
>>>> (3) Scala's just as hard to learn, because it too is full of ideas
>>>> that are new to many developers. I would love to see the 36-book list
>>>> for learning Scala, and I bet there would be significant overlap.
>>>>
>>>> (4) I think the Clojure docstrings  are ok, but could be improved by
>>>> usage examples. Rich, are you interested in patches that simply add
>>>> examples to docstrings?
>>>>
>>>> In short: if you are the median developer, both Clojure and Scala are
>>>> huge improvements over the language you are using right now. But you
>>>> won't be effective in either one of them tomorrow:  the learning curve
>>>> is not 1, but 5-10 books.
>>>>
>>>> So let's raise the bar. In the world I want to live in, programmers
>>>> above the novice level would understand the ideas in both Clojure and
>>>> Scala. Learn both. :-)
>>>>
>>>> Cheers,
>>>> Stu
>>>>
>>>> [1] http://java.ociweb.com/mark/clojure/article.html
>>>> [2] http://www.pragprog.com/titles/shcloj/programming-clojure
>>>> [3] http://tinyurl.com/clojure-bookshelf
>>>> [4] http://norvig.com/21-days.html
>>>>
>>>
>>> awesome post.  Inspiring.
>>>
>>>>
>>>>
>>>> >
>>>> > I think there are a lot of people who need to choose between Clojure
>>>> > and Scala to study as a "new" language. I must say that both are bad:
>>>> > * Clojure doc is hard to understand.
>>>> > * Scala grammar is complicated.
>>>> >
>>>> > I prefer Clojure. I think Clojure feature at this time is OK, thus the
>>>> > decisive point to draw people to Clojure is doc. I wonder if the doc
>>>> > at this time is obvious for LISP people, but comming from C/C++, Java,
>>>> > Ruby, and Erlang (Erlang doc is bad, but it is paradise compared to
>>>> > that of Clojure :D) and even after reading the Clojure book, I must
>>>> > say that I can't understand 99% of the doc of both clojure and
>>>> > clojure-
>>>> > contrib.
>>>> >
>>>> > For example, what does the following mean?
>>>> > -
>>>> > (-> x form)
>>>> > (-> x form & more)
>>>> > Macro
>>>> > Th

Re: clojure vs scala

2009-08-27 Thread Emeka
e,

What is inspiring in it?

Regards,
Emeka

On Thu, Aug 27, 2009 at 1:44 PM, e  wrote:

>  On Thu, Aug 27, 2009 at 8:43 AM, Stuart Halloway <
> stuart.hallo...@gmail.com> wrote:
>
>>
>> As the author of the book, you can bet I have an opinion on the
>> quality of the docs. :-)
>>
>> (1) I think the documentation for Clojure (website, Mark Volkmann's
>> long article [1], blog posts, the book [2]) is *insanely* good, given
>> how young the language is. But...
>>
>> (2) If you are coming from a mainstream business software environment,
>> there are a ton of new ideas in Clojure. There's more to learn, so of
>> course it is going be harder, and take longer. You won't get there
>> just by reading one book, even if you work through all the code
>> examples. I *love* that Rich's recommended reading list [3] has not 2,
>> or 4, but 36 books!! Clojure stands in opposition to the "in 21 days
>> for dummies" [4] school of thought.
>>
>> (3) Scala's just as hard to learn, because it too is full of ideas
>> that are new to many developers. I would love to see the 36-book list
>> for learning Scala, and I bet there would be significant overlap.
>>
>> (4) I think the Clojure docstrings  are ok, but could be improved by
>> usage examples. Rich, are you interested in patches that simply add
>> examples to docstrings?
>>
>> In short: if you are the median developer, both Clojure and Scala are
>> huge improvements over the language you are using right now. But you
>> won't be effective in either one of them tomorrow:  the learning curve
>> is not 1, but 5-10 books.
>>
>> So let's raise the bar. In the world I want to live in, programmers
>> above the novice level would understand the ideas in both Clojure and
>> Scala. Learn both. :-)
>>
>> Cheers,
>> Stu
>>
>> [1] http://java.ociweb.com/mark/clojure/article.html
>> [2] http://www.pragprog.com/titles/shcloj/programming-clojure
>> [3] http://tinyurl.com/clojure-bookshelf
>> [4] http://norvig.com/21-days.html
>>
>
> awesome post.  Inspiring.
>
>>
>>
>> >
>> > I think there are a lot of people who need to choose between Clojure
>> > and Scala to study as a "new" language. I must say that both are bad:
>> > * Clojure doc is hard to understand.
>> > * Scala grammar is complicated.
>> >
>> > I prefer Clojure. I think Clojure feature at this time is OK, thus the
>> > decisive point to draw people to Clojure is doc. I wonder if the doc
>> > at this time is obvious for LISP people, but comming from C/C++, Java,
>> > Ruby, and Erlang (Erlang doc is bad, but it is paradise compared to
>> > that of Clojure :D) and even after reading the Clojure book, I must
>> > say that I can't understand 99% of the doc of both clojure and
>> > clojure-
>> > contrib.
>> >
>> > For example, what does the following mean?
>> > -
>> > (-> x form)
>> > (-> x form & more)
>> > Macro
>> > Threads the expr through the forms. Inserts x as the second item in
>> > the first form, making a list of it if it is not a list already. If
>> > there are more forms, inserts the first form as the second item in
>> > second form, etc.
>> > -
>> >
>> > My wish: There are easy-to-understand examples in API doc.
>> >
>> > Rails is easy to use largely because there are examples in doc of
>> > every API function.
>> >
>> >
>> > On Aug 26, 12:37 pm, Alan Busby  wrote:
>> >> On Wed, Aug 26, 2009 at 5:43 AM, npowell 
>> >> wrote:
>> >>
>> >>> I mean, I didn't think the article was terribly in depth, but a
>> >>> real,
>> >>> evenhanded comparison would be enlightening.
>> >>
>> >> Reducing it further, I'd be interested just to hear more about the
>> >> contrast
>> >> of static typing versus macros. Which is more beneficial for
>> >> different
>> >> situations and why?
>> > >
>>
>>
>>
>>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A little help needed in understnding anonymous functions

2009-08-26 Thread Emeka
(defn foo2 [n]
(let [r (ref n)]
#(dosync (alter r + %) @r)))

Something went wrong, I am resending the code.

Regards,
Emeka

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A little help needed in understnding anonymous functions

2009-08-26 Thread Emeka
On Wed, Aug 26, 2009 at 6:40 PM, Sourav  wrote:

>
> Hi,
>
> I'm new to clojure and came from a Lisp background. While learning I
> clojure I came accross the two different ways of creating anonymous
> functions ((fn ...) and #(...)). I tried to construct the accumulator
> function in clojure using these forms and this is what I wrote (this
> might seem naive but I'm just a beginner :)
>
> 1.
>
> (defn foo [n]
>  (let [r (ref n)]
>(fn [i]
>   (dosync
> (alter r + i) @r
> And it works fine:
>
> user> (def f (foo 10))
> #'user/f
> user> (f 1)
> 11
> user> (f 1)
> 12
>
> 2.
> (defn foo2 [n]
>  (let [r (ref n)]
>#((dosync
>(alter r + %) @r
>

(defn foo2 [n]
 (let [r (ref n)]
   #(dosync
   (alter r + %) @r
Try the above. The difference between #() and (fn ...) was not the root of
your problem. You had an extra paren before dosync.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



clojure vs scala

2009-08-25 Thread Emeka
Hello All,

This sounds great!

http://codemonkeyism.com/clojure-scala-part-2/


Regards,
Emeka

--~--~-~--~~~---~--~~
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 hadoop example in clojure.

2009-07-27 Thread Emeka
RD,I don't know about the gen-class, to be sincere with you I have not used.
But clojure follows a standard and natural sequence if you look closely.
What you used in your former code were referring to different class path and
the paths were not even defined.

The below is from clojure.org
A stand-alone gen-class <http://clojure.org/API#gen-class> facility is
provided to create named classes for direct use as Java classes, with
facilities for:

   - Naming the generated class

http://clojure.org/compilation

So were do you want clojure to place the generated class. My guess is within
the same folder as your 'ns or need near. Now I hope you have seen why you
need that change.
I invite comments from experts here if I have strayed.

Regards,
Emeka


On Mon, Jul 27, 2009 at 9:47 AM, RD  wrote:

> Hi Stuart,
>  Thanks for the link
>  Relating to the hadoop code I posted above, I got it to compile  by
> putting the code under a namespace and changing
> the class names appropriately , but still I have no clue as to why the code
> didn't work without the namespace.
>
> I'll defenitely check the link though, thks.
>
> regards,
> rdsr
>
>
> Here's the code with the modification
>
> (ns com.rdsr.maxt
>   (:gen-class)
>   (:import [org.apache.hadoop.io IntWritable Text]
>[org.apache.hadoop.fs Path]
>[org.apache.hadoop.mapred
> JobConf JobClient
> FileInputFormat FileOutputFormat
> Mapper Reducer MapReduceBase])
>   (:use [clojure.contrib.str-utils :only (re-split)]))
>
> (gen-class
>  :name com.rdsr.mapper
>  :extends org.apache.hadoop.mapred.MapReduceBase
>  :implements [org.apache.hadoop.mapred.Mapper]
>  :prefix "m-")
>
> (defn m-map [this key value output-collector reporter]
>   (let [line (str value)
> year (subs line 15 19)
> air-temperature (if (= (nth line 87) \+)
>   (Integer/parseInt (subs line 88 92))
>   (Integer/parseInt (subs line 87 92)))
> quality (subs line 92 93)]
> (if (and (not (= air-temperature ))
>  (re-matches #"[01459]" quality))
>   (.collect output-collector (Text. year) (IntWritable.
> air-temperature)
>
> (gen-class
>  :name com.rdsr.reducer
>  :extends org.apache.hadoop.mapred.MapReduceBase
>  :implements [org.apache.hadoop.mapred.Reducer]
>  :prefix "r-")
>
> (defn r-reduce [this key values output-collector reporter]
>   (let [values-seq (iterator-seq values)]
> (.collect output-collector key
>   (apply max (map (fn [n] (.get n)) values-seq)
>
> (defn -main [& args]
>   (let [conf (JobConf. com.rdsr.maxt)]
> (doto conf
>   (.setJobName "Max temperature")
>   (.setMapperClass com.rdsr.mapper)
>   (.setReducerClass com.rdsr.reducer)
>   (.setOutputKeyClass Text)
>   (.setOutputValueClass IntWritable))
> (FileInputFormat/addInputPath conf (Path. (first args)))
> (FileOutputFormat/setOutputPath conf (Path. (second args)))
> (JobClient/runJob conf)))
>
> (compile 'com.rdsr.maxt)
>
>
> On Mon, Jul 27, 2009 at 9:46 PM, Stuart Sierra <
> the.stuart.sie...@gmail.com> wrote:
>
>>
>> Hi rdsr,
>>
>> The problem is that you're trying to use the "maxtemperature" as a
>> class name before it's finished compiling.  To work around that, use
>> (Class/forName "maxtemperature") instead.
>>
>> You can also see my (very task-specific) Hadoop/Clojure integration at
>> <http://tinyurl.com/mqv2os>
>> and <http://tinyurl.com/lznlg2>.
>>
>> -SS
>>
>>
>> On Jul 27, 4:55 am, RD  wrote:
>> > Hi all,
>> >  I'm having trouble converting the basic hadoop example to clojure.
>> > Here's my code.
>> >
>> > (ns maxtemperature
>> >   (:gen-class)
>> >   (:import [org.apache.hadoop.io IntWritable Text]
>> >[org.apache.hadoop.mapred
>> > JobConf JobClient
>> > FileInputFormat FileOutputFormat
>> > Mapper Reducer MapReduceBase])
>> >   (:use [clojure.contrib.str-utils :only (re-split)]))
>> >
>> > (gen-class
>> >  :name mapper
>> >  :extends org.apache.hadoop.mapred.MapReduceBase
>> >  :implements [org.apache.hadoop.mapred.Mapper]
>> >  :prefix "m-")
>> >
>> > (defn m-map [this key value output-collector reporter]
>> >   (let [line (str value)
>> > year (subs line 15 19)
>> > air-temperat

openlg

2009-07-13 Thread Emeka
Hello All, ztellman,

I would like to use  git://github.com/ztellman/penumbra.git , however I
won't mind knowing the owner, too.

Regards,
Emeka

--~--~-~--~~~---~--~~
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: Mysterious ClassFormatError after simple code change.

2009-07-06 Thread Emeka
 (defn- subexpressions-of-sum** [[n p] terms]
 (let-print [sum (cons '+ (map #(factor-term % n p) terms))
   prod (rest (make-product* n p))]
   (cons sum
 (map #(cons '* (cons sum (rest %)))
   (concat prod (subexpressions-of-product prod))

I look at the above, and something stupid just entered into my thought. What
happened when this situation occurs (cons sum ())? I hope that's not
possible with your code.

Regards,
Emeka

On Sun, Jul 5, 2009 at 6:01 AM, John Harrop  wrote:

>
> I had this:
>
> (defn- subexpressions-of-sum** [[n p] terms]
>  (let-print [sum (cons '+ (map #(factor-term % n p) terms))
>prod (rest (make-product* n p))]
>(concat [sum] (subexpressions-of-product (cons sum prod)
>
> in a source file with other definitions. Load-file worked. I then
> changed it to this:
>
> (defn- subexpressions-of-sum** [[n p] terms]
>  (let-print [sum (cons '+ (map #(factor-term % n p) terms))
>prod (rest (make-product* n p))]
>(cons sum
>  (map #(cons '* (cons sum (rest %)))
>(concat prod (subexpressions-of-product prod))
>
> and got:
>
> # 32 in class file com/mycompany/myfile$eval__14598 (NO_SOURCE_FILE:0)>
>
> when I tried to do a load-file.
>
> That function definition was the ONLY thing I changed, but I'm at a
> loss to find any kind of error in it. Delimiters balance, all of the
> referenced functions exist, basically there's nothing wrong.
>
> The full exception trace, which required evaluating (.printStackTrace
> (.getCause *e)) at the repl, is:
>
> java.lang.ClassFormatError: Unknown constant tag 32 in class file
> com/mycompany/myfile$eval__14598
>at java.lang.ClassLoader.defineClass1(Native Method)
>at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
>at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
>at
> clojure.lang.DynamicClassLoader.defineClass(DynamicClassLoader.java:42)
>at clojure.lang.Compiler$FnExpr.getCompiledClass(Compiler.java:3417)
>at clojure.lang.Compiler$FnExpr.eval(Compiler.java:3428)
>at clojure.lang.Compiler.eval(Compiler.java:4531)
>at clojure.core$eval__3990.invoke(core.clj:1728)
>at
> clojure.main$repl__5813$read_eval_print__5825.invoke(main.clj:176)
>at clojure.main$repl__5813.doInvoke(main.clj:193)
>at clojure.lang.RestFn.invoke(RestFn.java:548)
>at
> org.enclojure.repl.main$create_clojure_repl__53$repl_thread_fn__55.invoke(main.clj:96)
>at clojure.lang.AFn.run(AFn.java:37)
>at java.lang.Thread.run(Thread.java:619)
>
> It does not point to any line of my source file.
>
> Perhaps the rewritten version of the function provokes a compiler bug?
> If there is a known bug that would cause this, let me know of the
> known workaround. If there is an error in the second version of my
> function, let me know. (It has intentionally different semantics from
> the first version, so that's not an error in and of itself.)
>
> >
>

--~--~-~--~~~---~--~~
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: *command-line-args*

2009-07-03 Thread Emeka
Steve,

Could this be done such that  % java -cp /sq/ext/clojure/clojure.jar
clojure.main demo.clj foo bar baz  the highlighted part won't the there? But
would be ''attached'' behind the scene .

Regards,
Emeka

On Thu, Jul 2, 2009 at 6:17 PM, Stephen C. Gilardi  wrote:

>
> On Jul 2, 2009, at 2:00 PM, Mark Volkmann wrote:
>
>  I run it with "clj demo.clj foo bar baz" and get this output:
>>
>> clojure.lang.ArraySeq
>> 2
>>
>> I get the same output with "clj demo.clj -- foo bar baz".
>>
>> Why doesn't it output 3?
>>
>
> That depends on your definition of clj.
>
> Here's what I get without using a launcher script:
>
>  % java -cp /sq/ext/clojure/clojure.jar clojure.main demo.clj foo bar baz
>  clojure.lang.ArraySeq
>  3
>  (foo bar baz)
>
> (I added (println *command-line-args*) to my demo.clj. You might get some
> good info by adding it yours as well.)
>
> --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: Article on Dispatch

2009-07-01 Thread Emeka
Thanks, more of it.

Emeka

On Mon, Jun 29, 2009 at 12:31 AM, Daniel Jomphe wrote:

>
> I think the following article I wrote may help properly understanding
> dispatch. I submit here for your pleasure/review.
>
> First paragraph:
>
> "I believe multiple dispatch is known to be hard to understand. When I
> first read about it, for some reason, it took me quite a lot of
> thinking before I really understood it all. Now that I understand it
> very well, I find it odd that it felt so challenging at the time. For
> this reason, I wanted to try putting an end to this nonsense. There’s
> probably other articles out there that explain it very well today. In
> any case, here’s my take. As usual with me, it’s pretty wordy: I like
> to surround that kind of knowledge with lots of useful observations."
>
>
> http://danieljomphe.github.com/2009/06/18/understanding-function-dispatch.html
> >
>

--~--~-~--~~~---~--~~
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: Binary Tree

2009-06-30 Thread Emeka
(defn depth [tree]
  (if (nil? tree) 0
  (+ 1 (max (depth (left tree)) (depth (right tree)
 This looks close to what I need. Let me see if I can't get my head around
it.

Regards,
Emeka


On Tue, Jun 30, 2009 at 8:28 AM, Daniel Lyons wrote:

>
> On Jun 30, 2009, at 1:05 AM, Emeka wrote:
>
> Hello All,
>
> I have a BinaryTree Nodes that I want to resolve it's depth and the
> BinaryTree may be unbalanced. How do I do this? Can't just figure it out on
> my own?
> It is in the form of vector of vectors, and from one cell of any vector I
> can move to the next row  however the column index has to be either
> increased by one or decreased by one(and the new cell is empty).
>
>
> If you had a balanced binary tree, you could just take log_2(N) where N is
> the number of nodes. :) But since you don't you have to do something like
> get the max depth of the left branch and the right branch and add one to it
> (pseudocode):
>
> (defn depth [tree]
>   (if (nil? tree) 0
>   (+ 1 (max (depth (left tree)) (depth (right tree)
>
> If you're storing this binary tree in an array, I vaguely remember doing
> something like storing the left node at 2*i where i is the index of the
> current node, and the right node at 2*i+1. I'm not sure how you'd do that
> with an unbalanced tree unless you did something like have nils in your
> array. If you did that, you just need to take log_2(I) where I is the index
> of the last non-nil value in the array.
>
> I'm not sure exactly what data structure you're working with to make your
> binary tree though. Can you send an example of the tree you have as vectors?
>
> Are you also trying to compute whether or not it's unbalanced or is that
> just a given that it might be?
>
> —
> Daniel Lyons
>
>
> >
>

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



Binary Tree

2009-06-30 Thread Emeka
Hello All,

I have a BinaryTree Nodes that I want to resolve it's depth and the
BinaryTree may be unbalanced. How do I do this? Can't just figure it out on
my own?
It is in the form of vector of vectors, and from one cell of any vector I
can move to the next row  however the column index has to be either
increased by one or decreased by one(and the new cell is empty).

Regards,
Emeka

--~--~-~--~~~---~--~~
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: Trying to use lazy-seq for the first time, failing.

2009-06-29 Thread Emeka
Thanks, however I have that already :)

Regards,
Emeka

On Mon, Jun 29, 2009 at 2:36 PM, _hrrld  wrote:

>
> On Jun 29, 1:15 am, Emeka  wrote:
> > Harold,
> >
> > Do you have any material on Factor? I won't going through it.
>
> Emeka,
>
> Many of these links are relevant:
> http://www.google.com/search?q=factor+language
>
> Regards,
> -Harold
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Trying to use lazy-seq for the first time, failing.

2009-06-29 Thread Emeka
Harold,

Do you have any material on Factor? I won't going through it.

Regards,
Emeka

On Sat, Jun 27, 2009 at 12:23 AM, _hrrld  wrote:

>
> Hi,
>
> I'm trying to use lazy-seq to implement a cool piece of functionality
> I saw in the Factor programming language. Here is the documentation
> for that functionality:
> http://docs.factorcode.org/content/word-produce,sequences.html
>
> I think a lazy version of Factor's "produce" word would be super-
> powerful for some of the things I'm working on.
>
> This is the first time I've tried to create my own lazy sequence, so
> don't laugh.
>
> Here is my attempt:
> http://gist.github.com/136825
>
> For some reason, the lazy sequence that is returned is always empty
> (?) or at least seems that way.
>
> Am I doing something silly? Or perhaps I've misunderstood lazy-seq's
> operation.
>
> Thanks in advance for any advice,
> -Harold
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-26 Thread Emeka
Stuart Sierra,


I want to use StringTemplate, could you give me a lead?


Emeka
On Thu, Jun 25, 2009 at 9:31 PM, Stuart Sierra
wrote:

>
> On Jun 25, 3:59 pm, Berlin Brown  wrote:
> > But does anyone have a problem with Lisp/S-Expressions to HTML/XHtml,
> > especially for the entire document.  What is wrong with using some
> > form of templating system.
>
> Yes, I'm partial to StringTemplate, a Java template framework.  Very
> simple, like a functional language itself.
> http://www.stringtemplate.org/
>
> -SS
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Emeka
CuppoJava,

I was referring to the map data structure {'html "html"..} and not the
other map.

Regards,
Emeka

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Emeka
CuppoJava,

Did you try prxml? May be it can be of help.

Regards,
Emeka

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Emeka
That's cool.

 (doseq [[name tag] [['html "html"]
['head "head"]
['style "style"]
['title "title"]
['body "body"]
['table "table"]
['row "tr"]
['col "td"]
['span "span"]
['h1 "h1"]]]

Why not use map here?

(eval `(defblockfn ~name [block#]
   (html_tag* ~tag nil block#)))
  (eval `(defblockfn ~(symbol (str name "_with")) [attributes# block#]
   (html_tag* ~tag attributes# block#



See if you can simplify the above code.



Regards,
Emeka
On Thu, Jun 25, 2009 at 5:46 PM, CuppoJava wrote:

>
> Hey guys,
> I was a little tired of working on what I am supposed to be working
> on, and decided to take a break and create a website. I decided to use
> Clojure, and to my surprise, it only took a day and less than 3 pages
> of code.
>
> members.shaw.ca/patrickli
>
> It only has a single article right now, under Technical, that talks
> about how I programmed the website. It's still a rough work (I haven't
> written anything substantial for a long time), but it'd be nice to
> hear some thoughts.
>
>  -Patrick
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: defn memory question

2009-06-25 Thread Emeka
>From Steve's post
Symbol objects are subject to garbage collection, but the "namespace" and
"name" strings that identify them are not. Those strings are "interned" via
the "intern" method on java.lang.String. Once a String is interned, there
exists a single canonical String object that represents it throughout the
remaining lifetime the JVM instance. Any two Symbols of the same namespace
and name will reference those canonical namespace and name strings and will
thus have identical namespaces and names.

  Not interning the Symbols themselves turns out to be important in
Clojure because it allows two Symbols with identical namespace and name to
have different metadata.

  Keyword objects are interned by Clojure and are not garbage collected.
When a Keyword is created, it's placed in a ConcurrentHashMap that maps a
Symbol of the same name and namespace to the Keyword object. In a given JVM
instance, there is at most one Keyword object with a given name and
namespace. Whenever the reader reads a Keyword's text representation, it
returns the unique Keyword object associated with it.

  Here's some repl playing to support this:

 user=> (identical? 'a/b 'a/b)
 false
 user=> (identical? (name 'a/b) (name 'a/b))
 true
 user=> (identical? (namespace 'a/b) (namespace 'a/b))
 true
 user=> (= (quote #^{:tagged true} a/b) (quote a/b))
 true
 user=> (= (meta (quote #^{:tagged true} a/b)) (meta (quote
a/b)))
 false
 user=> (identical? :a/b :a/b)
 true




On Thu, Jun 25, 2009 at 10:25 AM, Rich Claxton wrote:

>
> Hello I have just started learning Clojure and functional programming,
> quick question, what happens internally when I do a defn, does this
> create the byte code, or a ref to the function which is stored, as it
> does actually create a function object, I was just wondering about
> memory and GC issues.
>
> Cheers Richard.
>
> >
>

--~--~-~--~~~---~--~~
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: Foreclojure

2009-06-25 Thread Emeka
 accounting software in Clojure?
Which area of accounting will it cover?

Emeka

On Thu, Jun 25, 2009 at 3:41 AM, fft1976  wrote:

>
> I know some of you are searching for names for your projects. I just
> wanted to say that "Foreclojure" is taken! This will be an open-source
> (but not GPL) accounting software in Clojure. Stay tuned.
> >
>

--~--~-~--~~~---~--~~
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: Small question: Best way to create a map with vector vals

2009-06-24 Thread Emeka
Have you tried zipmap?

Emeka

On Tue, Jun 23, 2009 at 10:09 PM, samppi  wrote:

>
> The idiom (into {} coll-of-entries) is often used to create a map from
> a collection of entries or two-sized vectors. But what if I want to do
> something like this:
>
> (mystery-fn [[:a 1] [:b 3] [:b 5] [:c 1]]) ; returns {:a [1], :b [3
> 5], :c [1]})
>
> The only way I can think of doing this is with a complex loop
> construction. But can mystery-fn be built without resorting to that?
> What would be the best way?
>
> >
>

--~--~-~--~~~---~--~~
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: macroexpand question

2009-06-24 Thread Emeka
kedu arasof

I don't know why you should go for macro here, an ordinary function can do
it.

Emeka

On Tue, Jun 23, 2009 at 12:24 AM, arasoft  wrote:

>
> I just wrote my first practice macro, first without and then with
> syntax quoting:
>
> (defmacro take-until1 [function sq]
>  (list 'take-while (list 'fn (vector 'x) (list 'not (list function
> 'x))) sq))
>
> (defmacro take-until2 [function sq]
>  `(take-while (fn [x#] (not (~function x#))) ~sq))
>
> Both seem to work, but macroexpand shows different formats:
>
> (macroexpand '(take-until1 #(> % 10) (iterate inc 1)))
> -> (take-while (fn [x] (not ((fn* [p1__502] (> p1__502 10)) x)))
> (iterate inc 1))
>
> (macroexpand '(take-until2 #(> % 10) (iterate inc 1)))
> (clojure.core/take-while (clojure.core/fn [x__405__auto__]
> (clojure.core/not ((fn* [p1__506] (> p1__506 10)) x__405__auto__)))
> (iterate inc 1))
>
> While I prefer the syntax of macro 2, I like the expand format of
> macro 1.
> Is there any way to get the best of both worlds?
> >
>

--~--~-~--~~~---~--~~
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: Shouldn't c.l.Namespace implement c.l.Named?

2009-06-22 Thread Emeka
kedu pmf
What about this (str *ns*)? I remember reading it from chouser's post.

Regards,
Emeka

--~--~-~--~~~---~--~~
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: javafx

2009-06-20 Thread Emeka
Kedu CuppoJava,

Join this class ♫
javafxprogramm...@googlegroups.com

And learn Fx. I was there for a few days before I drifted.

Regards,
Emeka
On Sat, Jun 20, 2009 at 4:51 PM, CuppoJava wrote:

>
> I'm still not very clear about what JavaFX actually is and what's its
> relation to Java. Do you know of any links that explain it clearly?
>  -Patrick
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Another Clojure Box

2009-06-17 Thread Emeka
Darmac,

I use Scite Just edited it in order to run Clojure Repl(help help from
this group). That's not great, it is ugly. I would like to use yours if it
is as simple as Scite editor and pretty easy to install.

Regards,
Emeka

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure equivalent to Ruby's ERB

2009-06-14 Thread Emeka
markgunnels,

Have you used clojure and StringTemplate to do something? If so, I would
like to tap your knowledge there.

Regards,
Emeka

On Sun, Jun 14, 2009 at 1:36 PM, markgunnels  wrote:

>
> I just wanted to report back that StringTemplate proved to be the
> perfect solution.
>
> I also wanted to recommend Terrence Parr's (the creator and ANTLR and
> StringTemplate) new book Language Design Patterns from The Pragmatic
> Programmers for anyone doing parsing and code generation. It is an
> excellent introduction to the subject.
>
> On May 27, 6:02 pm, Stuart Sierra  wrote:
> > On May 26, 10:47 pm,markgunnels wrote:
> >
> > > Hopefully this doesn't get me booed off the message board but is there
> > > a Clojure equivalent to Ruby's ERB? I'm try to use Clojure to perform
> > > code generation
> >
> > I've had success with StringTemplate.  Very functional design, easy to
> > call from Clojure.  And it's designed for code generation (the ANTLR
> > parser generator).
> >
> > -Stuart Sierra
> >
>

--~--~-~--~~~---~--~~
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: Performance Penalty Converting from Java Code

2009-06-14 Thread Emeka
kedu Travis,

(defn base26 [ n]
 (let [seed-string ""
   s (new StringBuilder seed-string)]
   (loop [ pos (- (count seed-string) 1)
  x n]
 (if (and (> pos 0)(> x 0))
 (do (. s setCharAt pos (char (+ (int \a) (mod x 26
  (recur (- pos 1) (/ x 26)
   (. s toString)))

(doseq [i (range (Math/pow 26 4))]
   (base26 i))

Try the above.

Emeka

--~--~-~--~~~---~--~~
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: breaking early from a "tight loop"

2009-06-13 Thread Emeka
kedu Wrexsoul

user=> (count-more-than? 0 ())
true

(defn count-more-than? [n xs]
  (if (not (seq xs))
   (or (zero? n)
 (recur (dec n) (rest xs)

I'm afraid your code didn't return true for me. Just look at your code, (seq
'()) will always give nil, so your code will return nil and not true. To get
true from your code I guess the (seq xs) should be changed to (not (seq
xs)).

Or am I missing something?

Emeka

On Sat, Jun 13, 2009 at 6:02 PM, Wrexsoul  wrote:

>
> On Jun 12, 9:44 pm, James Reeves  wrote:
> >   (defn count-more-than? [n xs]
> > (or (zero? n)
> > (if (seq xs)
> >   (recur (dec n) (rest xs)
> >
> >   (defn interesting? [pixels c]
> > (count-more-than? c (filter in-interval? pixels)))
>
> Nice, but
>
> user=> (count-more-than? 0 ())
> true
>
> (defn count-more-than? [n xs]
>   (if (seq xs)
>(or (zero? n)
>   (recur (dec n) (rest xs)
>
> seems to work. :)
> >
>

--~--~-~--~~~---~--~~
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: Macro Design - by example

2009-06-10 Thread Emeka
Meikel,

Could I be allowed to join your online class:)

Regards,
Emeka

--~--~-~--~~~---~--~~
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: Help with filechooser

2009-06-09 Thread Emeka
Sorry for the noise, I was too quick.




On Tue, Jun 9, 2009 at 3:46 PM, Emeka  wrote:

> Hello All,
>
> (add-item-action  ost-item (do
>  (.showOpenDialog file-chooser frame)
>  (let [file (.getSelectedFile file-chooser)]
>  (println "file" file
>
>
> When I tried the above on windows box it prints file # C:\clojure\roobot.txt>. But what I want is "file C:\clojure\roobot.txt".
>
> Regards,
> Emeka
>
>
>
>

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



Help with filechooser

2009-06-09 Thread Emeka
Hello All,

(add-item-action  ost-item (do
 (.showOpenDialog file-chooser frame)
 (let [file (.getSelectedFile file-chooser)]
 (println "file" file


When I tried the above on windows box it prints file #. But what I want is "file C:\clojure\roobot.txt".

Regards,
Emeka

--~--~-~--~~~---~--~~
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: filechooser

2009-06-09 Thread Emeka
- line 35 looks wrong. What does Dispatch/put return

Thanks so pointing that out.

I have to out windows guys then.

Regards,
Emeka

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



filechooser

2009-06-08 Thread Emeka
Hello Meikel,

I have not been able to resolve this issue. As I mentioned in another
thread, I want to use filechooser to select the excel file.
My code is in this link http://friendpaste.com/wmX89ywgPhdN5hvVBEAbg

Regards,
Emeka

--~--~-~--~~~---~--~~
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: VimClojure v2.1.1 is released

2009-06-08 Thread Emeka
Thanks. I will wait.
Regards,
Emeka


On Mon, Jun 8, 2009 at 5:05 PM, Meikel Brandmeyer  wrote:

> Hi,
>
> Am 08.06.2009 um 09:15 schrieb Emeka:
>
>  Sure, I sent a private mail because I didn't want to increase noise in is
>> group. I used the mail address you left on vimclojure site to reach you.
>>
>
> Ok. I'm sorry. It must have been stuck in the spam filter.
> I searched my mails, but only found the question about
> Jacob and Excel.
>
>  I just learned about user.home. So I can simplify
>>> also the .vim installation of the plugin.
>>>
>>>
>> Beautiful, when is it coming out?
>>
>
> Obviously soon... -.- I introduced more bugs than
> I fixed with this release. I will iron the bigger ones
> and will do a 2.1.2 soon For that I will throw
> another eye on the build process.
>
> 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: VimClojure v2.1.1 is released

2009-06-08 Thread Emeka
Sure, I sent a private mail because I didn't want to increase noise in is
group. I used the mail address you left on vimclojure site to reach you.

I just learned about user.home. So I can simplify
also the .vim installation of the plugin.

Beautiful, when is it coming out?

Emeka


>

--~--~-~--~~~---~--~~
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: VimClojure v2.1.1 is released

2009-06-07 Thread Emeka
If you
just want to get started with Clojure, use a simple
text editor of your liking and a repl running in the
shell/command prompt window.

Well, that's what I have done. Now I am looking for something else. And
because I have flirted with vi before, and I am somehow thinking that
learning vim would be a great experience :). But I am not yet able to get
vimclojure kicking. That's why I have been appealing for help since. And it
took Meikel three weeks to make out time to talk to me. That shows that vim
learning curve is indeed steep!

Regards,
Emeka

--~--~-~--~~~---~--~~
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: VimClojure v2.1.1 is released

2009-06-06 Thread Emeka
This is probably the global _vimrc installed by Vim I think as much, vim
needs this file to run.
If you installed Vim as an administrator  I  always work as administrator. I
will create that file and now what and what am I going to add to it.

Regards,
Emeka



O

On Sat, Jun 6, 2009 at 4:03 PM, Meikel Brandmeyer  wrote:

> Hi,
>
> Am 06.06.2009 um 17:47 schrieb Emeka:
>
>  Then it is pretty obvious that I have erred again.
>> C:\Program files\Vim\_vimrc That's where I found that file.
>>
>
> This is probably the global _vimrc installed by Vim.
> You should first try a _vimrc in your home directory.
> Just create it if it doesn't exist. If you installed Vim as
> an administrator and now work as a "normal" user
> that might explain, why you are not allowed to edit
> the file.
>
> 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: VimClojure v2.1.1 is released

2009-06-06 Thread Emeka
Then it is pretty obvious that I have erred again.
C:\Program files\Vim\_vimrc That's where I found that file.

Regards,
Emeka

--~--~-~--~~~---~--~~
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: VimClojure v2.1.1 is released

2009-06-06 Thread Emeka
C:\Users\rmicro\.viminfo

That's what I found.

Regards,
Emeka

--~--~-~--~~~---~--~~
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: VimClojure v2.1.1 is released

2009-06-06 Thread Emeka
 Do you edit the correct _vimrc? I found only one file  bearing that name.
Are you referring to other files?

Regards,
Emeka


>
>

--~--~-~--~~~---~--~~
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: VimClojure v2.1.1 is released

2009-06-06 Thread Emeka
Meikel,

I would like to use vimclojure and I have even installed all the needed
applications, however I am still not able to use it. I tried to edit _vimrc
but was told that it is a readonly file(this happened when I used vim to
edit it). When I used other editors, it does not prompt readonly, however
the message(I added) is not saved to the file either. I was able to get the
NGServer up. Please assist me in it figuring out why I can't edit _vimrc.


Regards,
Emeka

--~--~-~--~~~---~--~~
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: What is wrong with my code

2009-06-01 Thread Emeka
Dan and Tim,


This gives you the  link to the whole code.
http://friendpaste.com/C3xbF1r3F3Mehnn8CCBUm. It is still not
cleaned..pretty ugly, I am ashamed to  show  it off at all :)

Regards,
Emeka



On Mon, Jun 1, 2009 at 7:50 AM, Timothy Pratley wrote:

>
> I agree, chang is most likely not being passed a ref, specifically the
> part that does:
>  row-dev (eval (get-next-row inc (first val)))
>  (chang row-dev keyword-dev-right (@alon key))
> Looks to me like row-dev is not a ref, but I can't tell for sure!
>
>
>
>

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



What is wrong with my code

2009-05-31 Thread Emeka
  Hello All


(defn chang[f  key hj]
(dosync (ref-set f (assoc @f key hj



(defn proceed-now-right  [alon key]
(let [val (extract-num alon key)
 row-dev (eval (get-next-row inc (first val)))
 keyword-dev-right (get-key inc  (second val))
 cell-empty-right (check-cell-empty? keyword-dev-right   row-dev)]
 (if cell-empty-right
 (do (chang row-dev keyword-dev-right (@alon key)) (chang alon key
\space))
 (println "can't do this"


I found that each time I try form proceed-now-right I get error when IF is
true. Why is it so? The function chang works on it own...

Regards,
Emeka

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



  1   2   >