Artificial Intelligence in Clojure

2009-06-06 Thread maxsu

Hi, i'd like to write some AI in clojure.

Reading Russel & Norvig's AI: A Modern Approach, which focuses heavily
on autonomous intelligence agents.

Has anyone worked with these or other AI in clojure? Any libraries/git
repos out there?

Can/should we use clojure agents to encapsulate separate interacting
autonomous logical/rational agents?

Finally, in which way should we organize an asynchronous simulation of
a neural network using clojure concurrency? Are agents a good design
idea here as well?

I think I'd like to learn more about clojure's agents, where's a good
place to study up?

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

2009-06-06 Thread Chouser

On Sat, Jun 6, 2009 at 10:42 AM, Stephen C. Gilardi wrote:
> I've checked in changes to clojure.contrib.except to allow the functions it
> provides to produce exceptions that wrap other exceptions: they now support
> "causes".
>
> I believe it's now fully general and will be convenient to use for all of
> our exceptional needs.
>
> The attached text file contains a demo session at the repl showing some of
> its features.

This looks really easy to use, Stephen, thanks.

Since the time I put the rather more top-heavy error-kit in contrib,
it's become increasingly clear to me that hardly anybody (myself
included) need or use the continue-with and bind-continue features it
provides.

That leaves as its only used feature the ability to define and catch
custom error types that can be created without AOT compilation.  But
I'm starting to come around to what I think Rich has been pointing out
all along: that having singly-typed errors is not necessarily a great
idea.  Clojure multi-methods don't require objects to have a single
type after all -- you can dispatch on whatever you'd like.  Why should
exceptions be any different?

So here's an idea:  what if Clojure (or contrib for now) provided
a single new Exception type that besides the normal error string also
carried an object: probably a map with unspecified content (a bit like
metadata is now).  Then a lib like contrib.except could make it easy
to toss bits of detail into the exception that could be read easily
when caught.  This would allow the simplicity that contrib.except
provides now and would allow you to provide as much detail as an
error-kit error without even having to declare an error type.

Perhaps using it would look something like:

  (defn foo [x y]
(if (neg? x)
  (throwf :source ::Args, :arg 'x, :value x,
  "The value x may not be negative")
  (+ x y)))

  (try
(foo -5 10)
(catch ClojureError e
  (if-not (isa? ::Args (:source e))
(throw e)
(printf "Argument was incorrect:" e

I suppose the catch clause could be augmented:

  (tryf
(foo -5 10)
(catchf [e] (isa? ::Args (:source e))
  (printf "Argument was incorrect:" e)))

...or something.

Any thoughts?
--Chouser

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



Re: What books have helped you wrap your brain around FP and Clojure?

2009-06-06 Thread Matt Revelle

It may help to review the code and structure of open source Clojure
projects, part of the mind-bend feeling could be coming from
struggling to know where to begin when writing code and less from
unfamiliarity with the theory of FP.

I'd also recommend playing with Haskell and reviewing "Real World
Haskell" (http://book.realworldhaskell.org/).  Even though Clojure has
a focus on FP, other Lisps don't exhibit this; there are bits of FP
that can be found in any programming language but with Haskell you'll
be immersed in it.

On Jun 6, 4:10 pm, Daniel Lyons  wrote:
> I recommend "Purely Functional Data Structures" by Chris Okasaki. If  
> you can get your hands on "OCaml for Scientists" it's pretty good too.  
> And of course The Little Lisper/Schemer. I haven't made it through my  
> copy of SICP or PAIP.
>
> --
> Daniel
>
> On Jun 6, 2009, at 10:26 AM, kyle smith  wrote:
>
>
>
>
>
> > I read Norvig's PAIP.  The concept of first defining a dsl and then
> > writing an interpreter/compiler for it is amazing.  Even something as
> > simple as his sentence grammar shows the idea.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: What books have helped you wrap your brain around FP and Clojure?

2009-06-06 Thread prhlava

> Going beyond the language-specific Programming Clojure book, what
> other books have best helped you make the (sometimes mind-bending)

I have not yet read anything more mind-bending than this:

http://www.gp-field-guide.org.uk/

(A field guide to genetic programming)

It is free download - the book is under Creative Commons license...

A clojure example of the above is at:

http://npcontemplation.blogspot.com/2009/01/clojure-genetic-mona-lisa-problem-in.html

(but the code did not work in the latest clojure for me)

Kind regards,

Vlad

PS: Apart from being a fascinating subject - the book made the "code
is data" idea obvious...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: improoved version of parallel factorial uploaded - is it possible to push the performance further?

2009-06-06 Thread prhlava


Oops - the link above is broken, but the code is in the files section,
called:

parallel-factorial-example-2.clj

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



improoved version of parallel factorial uploaded - is it possible to push the performance further?

2009-06-06 Thread prhlava


Hello,

Just uploaded better version of parallel factorial...

Is is possible to push the performance further (short of implementing
parallel multiplication algorithm)?

Comments welcome.

http://groups.google.com/group/clojure/files/parallel-factorial-example-2.clj

Kind regards,

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

2009-06-06 Thread Rob Wolfe



Meikel Brandmeyer napisał(a):
> Hi,
>
> Am 06.06.2009 um 21:40 schrieb Rob Wolfe:
>
> > I'm trying to understand why this program throws an exception:
>
> It doesn't work because
>
> > (-> (new StringReader "abc")
> >   (new clojure.lang.LineNumberingPushbackReader))
>
> expands to
>
> (new (new StringReader "abc") LineNumberingPushbackReader)
>
> while
>
> (-> (StringReader. "abc")
>(LineNumberingPushbackReader.))
>
> expands to
>
> (LineNumberingPushbackReader. (StringReader. "abc"))
>
> which is equivalent to
>
> (new LineNumberingPushbackReader (new StringReader "abc")).
>
> Note the difference.

Oh yes, of course, now I can see it.
I will be careful with "->" macro next time. ;)
Thanks for help.

Br,
Rob

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

2009-06-06 Thread Meikel Brandmeyer

Hi,

Am 06.06.2009 um 21:40 schrieb Rob Wolfe:


I'm trying to understand why this program throws an exception:


It doesn't work because


(-> (new StringReader "abc")
  (new clojure.lang.LineNumberingPushbackReader))


expands to

(new (new StringReader "abc") LineNumberingPushbackReader)

while

(-> (StringReader. "abc")
  (LineNumberingPushbackReader.))

expands to

(LineNumberingPushbackReader. (StringReader. "abc"))

which is equivalent to

(new LineNumberingPushbackReader (new StringReader "abc")).

Note the difference.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: What books have helped you wrap your brain around FP and Clojure?

2009-06-06 Thread Daniel Lyons

I recommend "Purely Functional Data Structures" by Chris Okasaki. If  
you can get your hands on "OCaml for Scientists" it's pretty good too.  
And of course The Little Lisper/Schemer. I haven't made it through my  
copy of SICP or PAIP.

-- 
Daniel

On Jun 6, 2009, at 10:26 AM, kyle smith  wrote:

>
> I read Norvig's PAIP.  The concept of first defining a dsl and then
> writing an interpreter/compiler for it is amazing.  Even something as
> simple as his sentence grammar shows the idea.
> >

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



with-open and java interoperability

2009-06-06 Thread Rob Wolfe

Hi,

I'm trying to understand why this program throws an exception:

$ clojure -e "(clojure-version)"
"1.0.0-"
$ cat test1.clj
(ns rw.test (:import (java.io StringReader)))

(def x
 (with-open [s (-> (new StringReader "abc")
   (new
clojure.lang.LineNumberingPushbackReader))]
   (binding [*in* s]
 (read
(println x)
$ clojure test1.clj
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at jline.ConsoleRunner.main(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Unable to resolve
classname: (new StringReader "abc") (test1.clj:4)


whereas this one works without problems:

$ clojure -e "(clojure-version)"
"1.0.0-"
$ cat test2.clj
(ns rw.test (:import (java.io StringReader)))

(def x
 (with-open [s (-> (StringReader. "abc")
   (clojure.lang.LineNumberingPushbackReader.))]
   (binding [*in* s]
 (read
(println x)
$ clojure test2.clj
abc

I thougth that "StringReader." and "new StringReader" are equivalent,
right?
So why these programs work differently?

Br,
Rob

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

2009-06-06 Thread Stephen C. Gilardi


On Jun 6, 2009, at 12:34 PM, Meikel Brandmeyer wrote:


as threatened before here a first stab at a small action and menu
builder suite. It is inspired by what Waterfront does. You basically
create a map describing the action or menu and let the builder  
functions

create them for you.


Added:

http://code.google.com/p/clojure-contrib/source/detail?r=918

Thanks!

--Steve



smime.p7s
Description: S/MIME cryptographic signature


c.c.swing-utils: action and menu builders

2009-06-06 Thread Meikel Brandmeyer

Hello Stephen and fellow Clojurians,

as threatened before here a first stab at a small action and menu
builder suite. It is inspired by what Waterfront does. You basically
create a map describing the action or menu and let the builder functions
create them for you. Example:

(let [frame(JFrame. "Example")
  save-action  (make-action
 {:name   "Save"
  :mnemonic   KeyEvent/VK_S
  :long-desc  "Save the file to disk. No-op if  
file not modified"

  :short-desc "Save file"
  :handlersave-file-handler})
  menubar-spec [{:name "File"
 :mnemonic KeyEvent/VK_F
 :items[{:action save-action}
{} ; <- adds a separator
{:name "Close Window"
 :mnemonic KeyEvent/VK_W
 :handler  (fn [_] (.close frame))}]}
{:name "Help"
 :mnemonic KeyEvent/VK_H
 :items[{:name "About"
 :mnemonic KeyEvent/VK_A
 :handler  (fn [_] (show-about))}]}]
  menubar  (make-menubar menubar-spec)]
  (doto frame
(.setJMenbuBar menubar)
(.pack)
(.setVisible true)))

So the whole description is code. It can be put in IRefs and be
modified at runtime with the usual means.

Here's the code:

(defvar action-translation-table
  (atom {:nameAction/NAME
 :accelerator Action/ACCELERATOR_KEY
 :command-key Action/ACTION_COMMAND_KEY
 :long-desc   Action/LONG_DESCRIPTION
 :short-desc  Action/SHORT_DESCRIPTION
 :mnemonicAction/MNEMONIC_KEY
 :iconAction/SMALL_ICON})
  "Translation table for the make-action constructor.")

(defn make-action
  "Create an Action proxy from the given action spec. The standard keys
  recognised are: :name, :accelerator, :command-key, :long- 
desc, :short-desc,
  :mnemonic and :icon – corresponding to the similar named Action  
properties.
  The :handler value is used in the actionPerformed method of the  
proxy to

  pass on the event."
  [spec]
  (let [t-table @action-translation-table
handler (:handler spec)
spec(dissoc spec :handler)
spec(map (fn [[k v]] [(t-table k) v]) spec)
action  (proxy [AbstractAction] []
  (actionPerformed [evt] (handler evt)))]
(doseq [[k v] spec]
  (.putValue action k v))
action))

(defvar menu-constructor-dispatch
  (atom #{:action :handler :items})
  "An atom containing the dispatch set for the add-menu-item method.")

(defmulti add-menu-item
  "Adds a menu item to the parent according to the item description.
  The item description is a map of the following structure.

  Either:
- one single :action specifying a javax.swing.Action to be  
associated

  with the item.
- a specification suitable for make-action
- a set of :name, :mnemonic and :items keys, specifying a submenu  
with

  the given sequence of item entries.
- an empty map specifying a separator."
  {:arglists '([parent item])}
  (fn add-menu-item-dispatch [_ item]
(some @menu-constructor-dispatch (keys item

(defmethod add-menu-item :action
  add-menu-item-action
  [parent {:keys [action]}]
  (let [item (JMenuItem. action)]
(.add parent item)))

(defmethod add-menu-item :handler
  add-menu-item-handler
  [parent spec]
  (add-menu-item parent {:action (make-action spec)}))

(defmethod add-menu-item :items
  add-menu-item-submenu
  [parent {:keys [items mnemonic name]}]
  (let [menu (JMenu. name)]
(when mnemonic
  (.setMnemonic menu mnemonic))
(doseq [item items]
  (add-menu-item menu item))
(.add parent menu)))

(defmethod add-menu-item nil ; nil meaning separator
  add-menu-item-separator
  [parent _]
  (.addSeparator parent))

(defn make-menubar
  "Create a menubar containing the given sequence of menu items. The  
menu items
  are described by a map as is detailed in the docstring of the add- 
menu-item

  function."
  [menubar-items]
  (let [menubar (JMenuBar.)]
(doseq [item menubar-items]
  (add-menu-item menubar item))
menubar))

Sincerely
Meikel




smime.p7s
Description: S/MIME cryptographic signature


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: What books have helped you wrap your brain around FP and Clojure?

2009-06-06 Thread kyle smith

I read Norvig's PAIP.  The concept of first defining a dsl and then
writing an interpreter/compiler for it is amazing.  Even something as
simple as his sentence grammar shows the idea.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: What books have helped you wrap your brain around FP and Clojure?

2009-06-06 Thread Nathan Hawkins

Higher Order Perl. While I don't want to use Perl anymore, I do know it 
very well, and it provided a good introduction to FP in a more familiar 
language. YMMV.

Robert Campbell wrote:
> Going beyond the language-specific Programming Clojure book, what
> other books have best helped you make the (sometimes mind-bending)
> transition from OOP thinking to FP thinking? My bookshelf is piled
> high with OOP books like Design Patterns, Domain Driven Design,
> Analysis Patterns, etc. I've recently ordered:
>
> - Concepts, Techniques, and Models of Computer Programming (mentioned
> on this/compojure's list)
> - Structure and Interpretation of Computer Programs (highly
> recommended on Stackoverflow, lectures posted online)
>
> Any others?
>
> >
>   


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

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



smime.p7s
Description: S/MIME cryptographic signature


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

Hi,

Am 06.06.2009 um 17:27 schrieb Emeka:


C:\Users\rmicro\.viminfo

That's what I found.


Then it should be C:\Users\rmicro\_vimrc, I guess.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: Interest in creating a NYC Clojure user group?

2009-06-06 Thread John D. Hume

On Thu, Jun 4, 2009 at 12:09 PM, Eric Thorsen wrote:
> what kind of interest there might be in creating a Clojure user group
> in the NY metro area to meet up in Manhattan once a month to discuss
> all things Clojure.

I'd make an effort to attend monthly Clojure meetings in NYC.

-- 
http://elhumidor.blogspot.com/

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



Re: 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 Meikel Brandmeyer

Hi,

Am 06.06.2009 um 17:05 schrieb Emeka:

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


Well there should be your personal _vimrc.
It should probably be:
C:\Documents and Settings\\_vimrc.
Although this might be different for your
Windows version.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: What books have helped you wrap your brain around FP and Clojure?

2009-06-06 Thread CuppoJava

As messy of a language it is, learning Ruby was the final step needed
to show me the philosophy and merits of FP.
  -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: What books have helped you wrap your brain around FP and Clojure?

2009-06-06 Thread Vincent Foley

I recommend "The Little Schemer" and if you want to go further, "The
Seasoned Schemer".

On Jun 6, 7:12 am, Robert Campbell  wrote:
> Going beyond the language-specific Programming Clojure book, what
> other books have best helped you make the (sometimes mind-bending)
> transition from OOP thinking to FP thinking? My bookshelf is piled
> high with OOP books like Design Patterns, Domain Driven Design,
> Analysis Patterns, etc. I've recently ordered:
>
> - Concepts, Techniques, and Models of Computer Programming (mentioned
> on this/compojure's list)
> - Structure and Interpretation of Computer Programs (highly
> recommended on Stackoverflow, lectures posted online)
>
> Any others?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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
-~--~~~~--~~--~--~---



clojure.contrib.except enhanced

2009-06-06 Thread Stephen C. Gilardi
I've checked in changes to clojure.contrib.except to allow the  
functions it provides to produce exceptions that wrap other  
exceptions: they now support "causes".


I believe it's now fully general and will be convenient to use for all  
of our exceptional needs.


The attached text file contains a demo session at the repl showing  
some of its features.


--Steve

Clojure 1.1.0-alpha-SNAPSHOT
user=> (use 'clojure.contrib.except)
nil
user=> (doc throwf)
-
clojure.contrib.except/throwf
([& args])
  Throws an Exception or Error with an optional message formatted using
  clojure.core/format. All arguments are optional:

  class? cause? format? format-args*

  - class defaults to Exception, if present it must name a kind of
Throwable
  - cause defaults to nil, if present it must be a Throwable
  - format is a format string for clojure.core/format
  - format-args are objects that correspond to format specifiers in
format.
nil

user=> (throwf) ; no args
java.lang.Exception (NO_SOURCE_FILE:0)

user=> (throwf "hi there") ; a simple message
java.lang.Exception: hi there (NO_SOURCE_FILE:0)

user=> (throwf "hi there %s %s" 3 :look) ; a formatted message
java.lang.Exception: hi there 3 :look (NO_SOURCE_FILE:0)

user=> (throwf IllegalAccessException "hi there %s %s" 4 :oh) ; specified class
java.lang.IllegalAccessException: hi there 4 :oh (NO_SOURCE_FILE:0)

user=> (try (throwf "there") (catch Exception e (throwf e "hi"))) ; wrapped 
cause
java.lang.Exception: hi (NO_SOURCE_FILE:0)

user=> (.printStackTrace *e)
java.lang.Exception: hi (NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:4617)
at clojure.core$eval__4610.invoke(core.clj:1730)
at clojure.main$repl__6453$read_eval_print__6465.invoke(main.clj:178)
at clojure.main$repl__6453.doInvoke(main.clj:195)
at clojure.lang.RestFn.invoke(RestFn.java:426)
at clojure.main$repl_opt__6493.invoke(main.clj:249)
at clojure.main$main__6528.doInvoke(main.clj:336)
at clojure.lang.RestFn.invoke(RestFn.java:402)
at clojure.lang.Var.invoke(Var.java:342)
at clojure.lang.AFn.applyToHelper(AFn.java:171)
at clojure.lang.Var.applyTo(Var.java:463)
at clojure.main.main(main.java:37)
Caused by: java.lang.Exception: hi
at user$eval__141.invoke(NO_SOURCE_FILE:9)
at clojure.lang.Compiler.eval(Compiler.java:4601)
... 11 more
Caused by: java.lang.Exception: there
... 13 more
nil

user=> (doc throw-arg)
-
clojure.contrib.except/throw-arg
([& args])
  Throws an IllegalArgumentException. All arguments are optional:

cause? format? format-args*

  - cause defaults to nil, if present it must be a Throwable
  - format is a format string for clojure.core/format
  - format-args are objects that correspond to format specifiers in
format.
nil

user=> (throw-arg "that was a bad argument")
java.lang.IllegalArgumentException: that was a bad argument (NO_SOURCE_FILE:0)
user=> 






smime.p7s
Description: S/MIME cryptographic signature


Re: performance concerns (again)

2009-06-06 Thread Jonah Benton

RSS is "resident set size"- as I recall from the days when I compiled
my own kernels, it's based on a lazily-maintained
not-guaranteed-to-be-accurate count of physical memory pages "in use"
by the process. On linux, this number may overstate memory use by 50%
or more for non-JVM processes. For JVM processes the "overcount" may
be much greater.

On Sat, Jun 6, 2009 at 8:46 AM, Jarkko Oranen wrote:
>
>>
>> The problem was that it was not as fast as I expected it should be
>> given that it was using no less than 100% of the CPU on my system.
>> (two 3GHz Xeon CPUs [1 core]; 3GB RAM; a beefy workstation).  That
>> this was visible in the GUI shows how slow it appeared to me.  Also,
>> it was using 700MB RAM (VIRT in top).  Sure - it was "swapped" (I'm
>> familiar w/ some of the interpretations of these memory issues) except
>> that my system has ZERO swap space.  PMAP showed that 400MB of it was
>> heap, too, not libraries or binaries or anything else that we can
>> safely ignore.  This was (apparently) real, allocated heap, private to
>> the process's address space.
>
> I doubt the VIRT size matters at all. From what I know, it represents
> the address space that is available to the process; there's no
> guarantee that it's actually allocated or in use. Hence, it's not even
> "swapped". On my system, I have several processes with hundreds of
> megabytes in their "VSIZE" column shown in top. About 12GB in total;
> yet, I have barely any swap space... only a single 64MB file is
> allocated. (OS X allocates swapspace dynamically)
> According to top, I have 0 pageouts since last boot, so the swap isn't
> even being used. I have 3GB of RAM.
>
>> Additionally, as the simulation ran, the initial RSS of 60MB rose to
>> 130MB then stopped.  The VIRT remained constant.  I had expected that
>> - however I remained concerned.
>
> I'm not sure what kind of memory "RSS" is, but if it's shared, then
> it's java's own overhead, and not the application itself.
> the "private" memory areas are what you're interested in. Though of
> course the overhead is meaningful if it's the only java app running,
> but it's very difficult to tell what amount of the shared memory is
> actually used only by your application.
>
> You can try tuning the java VM and decrease its heap size and other
> things; see if it makes a difference.
>
> --
> Jarkko
>
> >
>

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

2009-06-06 Thread Robert Campbell

Talk about bad timing - reading the "Silly question from Programming
Clojure" it looks like a book thread already got started there. Here
were some additional mentions:

Laurent PETIT: OOSC: Object Oriented Software Construction, but this
is OOP so I'm disinclined to include it for this specific list
Paul Stadig: Concepts of Programming Languages by Sebesta, suggested
as more general than SICP


On Sat, Jun 6, 2009 at 1:12 PM, Robert Campbell wrote:
> Going beyond the language-specific Programming Clojure book, what
> other books have best helped you make the (sometimes mind-bending)
> transition from OOP thinking to FP thinking? My bookshelf is piled
> high with OOP books like Design Patterns, Domain Driven Design,
> Analysis Patterns, etc. I've recently ordered:
>
> - Concepts, Techniques, and Models of Computer Programming (mentioned
> on this/compojure's list)
> - Structure and Interpretation of Computer Programs (highly
> recommended on Stackoverflow, lectures posted online)
>
> Any others?
>

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

2009-06-06 Thread Jarkko Oranen

>
> The problem was that it was not as fast as I expected it should be
> given that it was using no less than 100% of the CPU on my system.
> (two 3GHz Xeon CPUs [1 core]; 3GB RAM; a beefy workstation).  That
> this was visible in the GUI shows how slow it appeared to me.  Also,
> it was using 700MB RAM (VIRT in top).  Sure - it was "swapped" (I'm
> familiar w/ some of the interpretations of these memory issues) except
> that my system has ZERO swap space.  PMAP showed that 400MB of it was
> heap, too, not libraries or binaries or anything else that we can
> safely ignore.  This was (apparently) real, allocated heap, private to
> the process's address space.

I doubt the VIRT size matters at all. From what I know, it represents
the address space that is available to the process; there's no
guarantee that it's actually allocated or in use. Hence, it's not even
"swapped". On my system, I have several processes with hundreds of
megabytes in their "VSIZE" column shown in top. About 12GB in total;
yet, I have barely any swap space... only a single 64MB file is
allocated. (OS X allocates swapspace dynamically)
According to top, I have 0 pageouts since last boot, so the swap isn't
even being used. I have 3GB of RAM.

> Additionally, as the simulation ran, the initial RSS of 60MB rose to
> 130MB then stopped.  The VIRT remained constant.  I had expected that
> - however I remained concerned.

I'm not sure what kind of memory "RSS" is, but if it's shared, then
it's java's own overhead, and not the application itself.
the "private" memory areas are what you're interested in. Though of
course the overhead is meaningful if it's the only java app running,
but it's very difficult to tell what amount of the shared memory is
actually used only by your application.

You can try tuning the java VM and decrease its heap size and other
things; see if it makes a difference.

--
Jarkko

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

Hi,

Am 06.06.2009 um 13:24 schrieb Emeka:

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.


I'm sorry. This seems more like a general Vim
question. _vimrc probably means, that you use
Windows. Things there are sometimes a bit
awkward. However I never had problems
editing my _vimrc with vim itself...  Do you edit
the correct _vimrc?

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


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



What books have helped you wrap your brain around FP and Clojure?

2009-06-06 Thread Robert Campbell

Going beyond the language-specific Programming Clojure book, what
other books have best helped you make the (sometimes mind-bending)
transition from OOP thinking to FP thinking? My bookshelf is piled
high with OOP books like Design Patterns, Domain Driven Design,
Analysis Patterns, etc. I've recently ordered:

- Concepts, Techniques, and Models of Computer Programming (mentioned
on this/compojure's list)
- Structure and Interpretation of Computer Programs (highly
recommended on Stackoverflow, lectures posted online)

Any others?

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

2009-06-06 Thread Parth



On Jun 6, 11:44 am, Sean Devlin  wrote:
> This problem came up on the mailing list recently:
>
> http://groups.google.com/group/clojure/browse_thread/thread/5e0c078d0...
>
> You might want to compare your code to what was done here, but at a
> glance the implementations are similar.
>
> You provide relative speed comparisons (Such and such is %
> better...).  Would you be able to share absolute times as well?  I'm
> just curious at this point.
>
> Sean

For some reason the google spreadsheet link provided in
my original mail requires users to login for viewing.
The same numbers are available in this published
google spreadsheet (hopefully without login).

http://tinyurl.com/ofhync

Regards,
Parth


>
> On Jun 6, 12:41 am, Parth Malwankar  wrote:
>
> > Hello,
>
> > In order to understand the agent model of Clojure
> > better I wrote the alioth shootout threadring benchmark [1].
> > I ran some tests to compare it with the Java and Scala
> > implementation [2, 3] which I picked from the published
> > benchmarks.
>
> > The clojure code can be found here:http://gist.github.com/124688
>
> > The benchmark from my two core 1.7GHz pentium system
> > (ubuntu 9.04) w/ 1GB RAM can be found 
> > here:http://spreadsheets.google.com/ccc?key=rQLD6jgTTV5OqXwHdXtrTyg
>
> > In summary, scala implementation is 6.34x times slower than
> > java, clojure is 7.8x. Avg CPU consumption is 93.3% for java and
> > 179.2% and 131.34% for scala and clojure respectively.
>
> > I thought of sharing this in case others are interested.
> > As this is my first program using clojure agents I would appreciate
> > any
> > comments on improving the Clojure implementation (or in case
> > there are any bugs).
>
> > Thanks.
> > Parth
> > PS: For the Java implementation I happen to pick the "interesting
> > alternate programs" (Java 6 -server #5) but it was already quite
> > late in the cycle when I realized that. So the Java numbers are
> > probably better than the other java implementations.
>
> > [1]http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadring&;...
> > [2]http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadring&;...
> > [3]http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadring&;...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



VimClojure v2.1.1 is released

2009-06-06 Thread Meikel Brandmeyer

Dear Vimming Clojurians,

VimClojure v2.1.1 is out. This is only a bugfix release.
No new features added. It mostly fixes bugs in the
syntax highlighting.

http://www.vim.org/scripts/script.php?script_id=2501

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: defnk addition to c.c.def

2009-06-06 Thread Meikel Brandmeyer

Hi,

Am 05.06.2009 um 00:22 schrieb Meikel Brandmeyer:

   sym-vals(apply hash-map (interleave syms  
values))


Ah! I always forget about zipmap...

Clojure is just fun! :)

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: Question for Clojure-Mode users.

2009-06-06 Thread Daniel Lyons


On Jun 5, 2009, at 3:27 PM, Phil Hagelberg wrote:

>
> "Stephen C. Gilardi"  writes:
>
>> (my-cool-database-operation the-database
>>  (arg-exp-1 with operands)
>>  literal-arg
>>  angstroms)
>>
>> There doesn't seem to be an easy way to distinguish these two types  
>> of
>> initial operands (or the N-2 other types I've missed). "with-*" would
>> probably seldom be wrong as an indicator of the second type.
>
> The only way I can think of is to connect to a running slime instance
> and check to see if the var refers to a macro that takes a & body
> argument. But this is a lot of moving parts for a slim benefit. It's
> easier just to name these kinds of macros with-foo. =)

I think Slime does this with CL. At least I seem to remember having  
code with macros that indented differently when the connection was  
established.

—
Daniel Lyons
http://www.storytotell.org -- Tell It!


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