Re: Waterfront - The Clojure-based editor for Clojure

2009-03-03 Thread Michael Wood

On Tue, Mar 3, 2009 at 9:14 PM, aperotte  wrote:
>
> Hi,
>
> I'm using linux (Ubuntu) and none of the above scripts worked for me.
> I added the ${DP}/bin directory to the classpath list to get it to
> work.
>
> #!/bin/sh
> DP="${0%/*}"
> java -cp ~/src/clojure/clojure.jar:${DP}/clj:${DP}/java -
> Dnet.sourceforge.waterfront.plugins=${DP}/clj/net/sourceforge/
> waterfront/ide/plugins clojure.main ${DP}/clj/net/sourceforge/
> waterfront/ide/main.clj $*

There are some bugs in your script.  See my post in this thread from a
few days ago for details:
http://groups.google.com/group/clojure/browse_thread/thread/d5ce5ddb679cb8f9/79919526bf401a08?lnk=gst#79919526bf401a08

> P.S. - The text editor you are using for the shell script is encoding
> DOS style newlines and doesn't work on linux.  I copied the text to a
> new file to get around it.

-- 
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
To unsubscribe from 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: contrib build errors after javadoc => repl-utils

2009-03-03 Thread Christophe Grand

Stephen C. Gilardi a écrit :
>> Hi Christophe Grand or other contrib committers,
>>
>> clojure.contrib.javadoc should be removed from the list of libs to
>> compile in the build.xml file; as it stands, building with ant throws
>> the Exception that fires when c.c.javadoc is compiled.
>>
>> Best,
>> Perry
>
> Fixed. Thanks for the report!
>
> --Steve
>
Thanks Perry for the report and thanks Steve for fixing it (and sorry 
for forgetting about the build part).

Christophe


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

2009-03-03 Thread Stephen C. Gilardi


On Mar 3, 2009, at 11:01 PM, Timothy Pratley wrote:


Just because there is always another way :P

(defn determine-new-state [x y]
 (let [alive (count (for [dx [-1 0 1] dy [-1 0 1]
  :when (cells [(+ x dx) (+ y dy)])]
  :alive))]
   (if (cells [x y])
 (< 2 alive 5)
 (= alive 3


Nice!

And for more golfing fun:

(defn calc-state []
  (dosync
   (ref-set cells
 (reduce conj {}
   (for [x (range 32) y (range 48)]
 [[x y] (determine-new-state x y)])

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Question on names of errors in error-kit

2009-03-03 Thread David Nolen
capitals seems pretty weird for a Lisp. Now that I think about it, perhaps
foo-error isn't so bad.
David

On Tue, Mar 3, 2009 at 10:54 PM, Chouser  wrote:

>
> On Tue, Mar 3, 2009 at 10:36 PM, David Nolen 
> wrote:
> > I appreciate that they stand out.  Again, this is similar to the
> constants
> > conversation earlier, visually marking the intended use is a good habit,
> > IMHO.  Of course this doesn't mean that error-kit should define the base
> > error this way, but I intend to keep on wrapping my errors in earmuffs :)
>
> Since earmuffs already mean something different, perhaps there's
> something else that would work?  Maybe capitals, because they're a
> kind of type name?  Error, Odd-Number-Error?
>
> --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
To unsubscribe from 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: Game of Life

2009-03-03 Thread Larry Sherrill

> Am I "over interpreting" the meaning of the copyright clause at the top of 
> the published code ?

Yes. I hesitated to put it there but went ahead out of habit. :> I'll
either remove it or stick some minimal open source license on it.
Thanks for pointing that out.

On Mar 3, 4:53 pm, Laurent PETIT  wrote:
> Hello Larry,
>
> is there a reason why the code of this port of Game of Life does not seem to
> be under an open source license (e.g. EPL, etc.) ?
>
> I was interested in playing with your code, but I'm a bit reluctant when I
> see an "all rights reserved" in the top of the file ...
> It seems to me like your code is open to suggestions from others, but not
> for sharing with others ?
>
> Am I "over interpreting" the meaning of the copyright clause at the top of
> the published code ?
>
> Regards,
>
> --
> Laurent
>
> 2009/3/4 Larry Sherrill 
>
>
>
>
>
> > Thanks everyone for the suggestions. Very helpful.
> > - Afficher le texte des messages précédents -
>
> > On Mar 3, 2:03 pm, "Stephen C. Gilardi"  wrote:
> > > On Mar 3, 2009, at 3:03 PM, lps540 wrote:
>
> > > > I've written a small example of Conway's Game of Life using Clojure
> > > > and Swing. Comments/critiques are welcome.
>
> > > Very nice example!
>
> > > Here's a more compact determine-new-state:
>
> > > (defn determine-new-state [x y]
> > >    (let [count (reduce + (for [dx [-1 0 1] dy [-1 0 1]]
> > >                            (if (cells [(+ x dx) (+ y dy)]) 1 0)))]
> > >      (or (and (cells [x y]) (> count 2) (< count 5))
> > >          (= count 3
>
> > > I'm guessing someone can make the reduce even tighter.
>
> > > I considered using :when (not (and (zero? dx) (zero? dy))) in the for
> > > expression, but it seemed simpler to account for the extra count when
> > > (cells [x y]) is true in the new state expression down below.
>
> > > --Steve
>
> > >  smime.p7s
> > > 3KViewDownload
> > - Afficher le texte des messages précédents -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Game of Life

2009-03-03 Thread Timothy Pratley

Just because there is always another way :P

(defn determine-new-state [x y]
  (let [alive (count (for [dx [-1 0 1] dy [-1 0 1]
   :when (cells [(+ x dx) (+ y dy)])]
   :alive))]
(if (cells [x y])
  (< 2 alive 5)
  (= alive 3
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Question on names of errors in error-kit

2009-03-03 Thread Chouser

On Tue, Mar 3, 2009 at 10:36 PM, David Nolen  wrote:
> I appreciate that they stand out.  Again, this is similar to the constants
> conversation earlier, visually marking the intended use is a good habit,
> IMHO.  Of course this doesn't mean that error-kit should define the base
> error this way, but I intend to keep on wrapping my errors in earmuffs :)

Since earmuffs already mean something different, perhaps there's
something else that would work?  Maybe capitals, because they're a
kind of type name?  Error, Odd-Number-Error?

--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
To unsubscribe from 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: Question on names of errors in error-kit

2009-03-03 Thread David Nolen
I appreciate that they stand out.  Again, this is similar to the constants
conversation earlier, visually marking the intended use is a good habit,
IMHO.  Of course this doesn't mean that error-kit should define the base
error this way, but I intend to keep on wrapping my errors in earmuffs :)
David

On Tue, Mar 3, 2009 at 10:27 PM, Chouser  wrote:

>
> On Tue, Mar 3, 2009 at 2:10 PM, samppi  wrote:
> >
> > Small questions on error-kit—which I love and think that all clojure-
> > contrib libraries should use—why do defined errors such as *error*,
> > *number-error*, etc. have names surrounded by asterisks?
>
> Thanks for the endorsement!  Have you used continue or bind-continue
> yet?  These are the features I'm less certain about.
>
> Your question is a very good one.  Early versions actually rebound the
> error Vars, so I named them appropriately.  Of course that's not
> exactly how it works anymore, but I grew accustomed to how they look
> with earmuffs, and didn't change them.
>
> I'm hesitant to remove them because I like how they stand out in the
> code.  Perhaps it's not really necessary, or perhaps there's a better
> naming convention we could use?  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
To unsubscribe from 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: Question on names of errors in error-kit

2009-03-03 Thread Chouser

On Tue, Mar 3, 2009 at 2:10 PM, samppi  wrote:
>
> Small questions on error-kit—which I love and think that all clojure-
> contrib libraries should use—why do defined errors such as *error*,
> *number-error*, etc. have names surrounded by asterisks?

Thanks for the endorsement!  Have you used continue or bind-continue
yet?  These are the features I'm less certain about.

Your question is a very good one.  Early versions actually rebound the
error Vars, so I named them appropriately.  Of course that's not
exactly how it works anymore, but I grew accustomed to how they look
with earmuffs, and didn't change them.

I'm hesitant to remove them because I like how they stand out in the
code.  Perhaps it's not really necessary, or perhaps there's a better
naming convention we could use?  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
To unsubscribe from 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: doall, dorun, doseq, for

2009-03-03 Thread Chouser

On Tue, Mar 3, 2009 at 2:54 PM, Mark Volkmann  wrote:
>
> I agree that using doseq instead of dorun results in code that is
> easier to read. I don't understand though why it is more efficient.
> They both walk the entire sequence, neither holds onto the head and
> both return nil. Why is doseq more efficient than dorun?

A simple doseq does run about as fast as dorun on the same seq.  Bus
something like this would be more likely (let's pretend inc has useful
side-effects):

  (defn f [] (dorun (map #(inc %) (range 1000

  (defn f2 [] (doseq [i (range 1000)] (inc i)))

The results would be the same, but dorun requires 'map', which creates
another seq.  'doseq' is able to accomplish the same work with less
allocation.

  user=> (time (f))
  "Elapsed time: 1685.796066 msecs"

  user=> (time (f2))
  "Elapsed time: 531.730209 msecs"

--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
To unsubscribe from 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: Game of Life

2009-03-03 Thread Stephen C. Gilardi


On Mar 3, 2009, at 4:03 PM, Stephen C. Gilardi wrote:


(defn determine-new-state [x y]
 (let [count (reduce + (for [dx [-1 0 1] dy [-1 0 1]]
 (if (cells [(+ x dx) (+ y dy)]) 1 0)))]
   (or (and (cells [x y]) (> count 2) (< count 5))
   (= count 3




I'm guessing someone can make the reduce even tighter.


Here's another shot at it:

(defn determine-new-state [x y]
  (let [nearby [-1 0 1]
neighborhood (for [dx nearby dy nearby]
   (cells [(+ x dx) (+ y dy)]))
alive (count (filter identity neighborhood))]
(if (cells [x y])
  (< 2 alive 5)
  (= alive 3

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Game of Life

2009-03-03 Thread Laurent PETIT
Hello Larry,

is there a reason why the code of this port of Game of Life does not seem to
be under an open source license (e.g. EPL, etc.) ?

I was interested in playing with your code, but I'm a bit reluctant when I
see an "all rights reserved" in the top of the file ...
It seems to me like your code is open to suggestions from others, but not
for sharing with others ?

Am I "over interpreting" the meaning of the copyright clause at the top of
the published code ?

Regards,

-- 
Laurent

2009/3/4 Larry Sherrill 

>
> Thanks everyone for the suggestions. Very helpful.
> - Afficher le texte des messages précédents -
>
> On Mar 3, 2:03 pm, "Stephen C. Gilardi"  wrote:
> > On Mar 3, 2009, at 3:03 PM, lps540 wrote:
> >
> > > I've written a small example of Conway's Game of Life using Clojure
> > > and Swing. Comments/critiques are welcome.
> >
> > Very nice example!
> >
> > Here's a more compact determine-new-state:
> >
> > (defn determine-new-state [x y]
> >(let [count (reduce + (for [dx [-1 0 1] dy [-1 0 1]]
> >(if (cells [(+ x dx) (+ y dy)]) 1 0)))]
> >  (or (and (cells [x y]) (> count 2) (< count 5))
> >  (= count 3
> >
> > I'm guessing someone can make the reduce even tighter.
> >
> > I considered using :when (not (and (zero? dx) (zero? dy))) in the for
> > expression, but it seemed simpler to account for the extra count when
> > (cells [x y]) is true in the new state expression down below.
> >
> > --Steve
> >
> >  smime.p7s
> > 3KViewDownload
> - Afficher le texte des messages précédents -
> >
>

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

2009-03-03 Thread Larry Sherrill

Thanks everyone for the suggestions. Very helpful.

On Mar 3, 2:03 pm, "Stephen C. Gilardi"  wrote:
> On Mar 3, 2009, at 3:03 PM, lps540 wrote:
>
> > I've written a small example of Conway's Game of Life using Clojure
> > and Swing. Comments/critiques are welcome.
>
> Very nice example!
>
> Here's a more compact determine-new-state:
>
> (defn determine-new-state [x y]
>    (let [count (reduce + (for [dx [-1 0 1] dy [-1 0 1]]
>                            (if (cells [(+ x dx) (+ y dy)]) 1 0)))]
>      (or (and (cells [x y]) (> count 2) (< count 5))
>          (= count 3
>
> I'm guessing someone can make the reduce even tighter.
>
> I considered using :when (not (and (zero? dx) (zero? dy))) in the for  
> expression, but it seemed simpler to account for the extra count when  
> (cells [x y]) is true in the new state expression down below.
>
> --Steve
>
>  smime.p7s
> 3KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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 + Terracotta: the Next Steps

2009-03-03 Thread Paul Stadig

I've done some more work on Clojure + Terracotta. I moved my code into
a Terracotta Integration Module (TIM), which allows the bundling and
reuse of the Terracotta configuration, but also provides for class
replacement so that clustered versions of some classes can be written
without necessarily having to support Terracotta in the Clojure
codebase.

I have shared the TIM here:

http://github.com/pjstadig/tim-clojure-1.0-snapshot/tree/master

and an update here:

http://paul.stadig.name/2009/03/clojure-terracotta-next-steps.html

The summary is that I've now got a REPL running with Terracotta, but I
cannot connect multiple JVMs because of two issues. 1) *in*, *out*,
and *err* need to be different per JVM, but the way Vars work the root
binding is shared amongst all JVMs. My temporary workaround is to
leave the root binding nil, and manually bind those vars (as per
suggestion from Rich). 2) When pulling compiled functions out of the
Terracotta cache, I get a ClassNotFoundException, because the classes
of compiled functions are not being shared via Terracotta. We need to
either find a way to get those classes into the object graph, or come
up with some other solution.

Once getting past these issues, there is still more work to be done. I
know for a fact that Agents will not work (because they use
AtomicReference), neither will Atoms. I'm sure we will come across
other issues, but we're making some good progress here.


Paul

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: emacs / swank / slime startup problem - ClassNotFoundException: swank.swank

2009-03-03 Thread Korny Sietsma

Thanks - that seemed to fix it!

- Korny

On Wed, Mar 4, 2009 at 1:34 AM, Bradbev  wrote:
>
> On Mar 3, 4:46 am, Korny Sietsma  wrote:
>> Hi folks;
>>
>> I have an intermittent problem that's driving me nuts.
>> I'm running the emacs-starter-kit setup for editing clojure, recently
>> updated from git, and when I first run "M-x slime", I often get the
>> following messages:
>> user=> user=> java.lang.IllegalArgumentException: URI has an authority
>> component (NO_SOURCE_FILE:0)
>> user=> user=> java.lang.ClassNotFoundException: swank.swank 
>> (NO_SOURCE_FILE:9)
>> user=> user=> java.lang.ClassNotFoundException: swank.swank 
>> (NO_SOURCE_FILE:11)
>>
>> I then get a continual message of the form:
>> Polling "/var/folders/9h/9h261S2vGcakoICm25U72k+++TI/-Tmp-/slime.21452"..
>> (Abort with `M-x slime-abort-connection'.)
>>
>> ... and I have to abort.
>> However, sometimes, generally when I've started trying to fiddle
>> around with inserting println statements in the swank code, I run
>> 'slime' again - and everything is good!
>> Well, I still seem to get the
>>    java.lang.IllegalArgumentException: URI has an authority component
>> (NO_SOURCE_FILE:0)
>> message, but slime/swank/clojure all seem to work.
>>
>> Any thoughts? Any ideas where to look?
>> Note this is with MacPorts emacs Version 23.0.0 (NS 9.0-rc3)
>>
>> - Korny
>> --
>> Kornelis Sietsma  korny at my surname dot com
>> kornys on gmail, twitter, facebook, etc.
>> "Every jumbled pile of person has a thinking part
>> that wonders what the part that isn't thinking
>> isn't thinking of"
> I got this when upgrading to the lazy branch.  I never figured out
> what the actual problem is, but setting swank-clojure-compile-p (in
> swank-clojure.el) to nil fixed it.
> I use Aquamacs.
>
> Cheers,
> Brad
> >
>



-- 
Kornelis Sietsma  korny at my surname dot com
kornys on gmail, twitter, facebook, etc.
"Every jumbled pile of person has a thinking part
that wonders what the part that isn't thinking
isn't thinking of"

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: test-clojure: trouble with the latest Clojure SVN version

2009-03-03 Thread Rich Hickey



On Mar 3, 3:58 pm, "Stephen C. Gilardi"  wrote:
> On Mar 3, 2009, at 3:39 PM, Frantisek Sodomka wrote:
>
> > There is a problem with the latest Clojure SVN version. Try running in
> > clojure-contrib: ant test_clojure
>
> I confirmed that r1321 passes the tests and r1322 fails.
>
> To run the tests, I use:
>
> cd /the/path/to/my/clojure-contrib
> ant -Dclojure.jar=/the/path/to/my/clojure.jar test
>

Runs clean now on svn 1323 - thanks for the report.

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
To unsubscribe from 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: Roman Numerals

2009-03-03 Thread Michel S.

Hello,

Chouser has commented extensively, so I'll just put in my two cents.

On Mar 3, 6:40 am, David Sletten  wrote:
>
> Incidentally, the "cond" form in roman-to-arabic-aux seems to me  
> harder to read in Clojure than it would be in CL with its additional  
> set of grouping parentheses. When you can't fit both the predicate  
> and the consequent expression on the same line it gets confusing.
>
I find that rather confusing too, formatting wise.

> I'd appreciate any feedback regarding my Clojure style. Any more  
> natural ways to do things?
>
> Aloha,
> David Sletten
>
> (def roman-values-map {\I 1 \V 5 \X 10 \L 50 \C 100 \D 500 \M 1000})
>
> (defn value [roman]
>    (get roman-values-map (Character/toUpperCase roman)))
>
One really neat thing in Clojure is that a collection can be treated
as a function that map from an index (or a key) to a value. So in this
case, this works:

(roman-values-map (Character/toUpperCase roman))

Regards,

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

2009-03-03 Thread Achim Passen

Hi!

Are you using the release version from clojure.org? I remember this  
one having a strange *compile-path* default when started as  
clojure.main (something like "/Users/rich/..."), but defaulting to  
"classes" when started as clojure.lang.Repl ...

Kind regards,
achim


Am 03.03.2009 um 22:22 schrieb zodoz:

>
> I found the solution (though I'm still in the process of understanding
> why it works):
>
> java -cp clojure.jar;.\src;.\classes clojure.lang.Repl
> user=> (compile 'test.test)
>
> On Mar 3, 10:56 am, zodoz  wrote:
>> Same thing.  I even tried putting (compile 'test.test) in the src/ 
>> test/
>> test.clj file and loading it with "java -
>> classpath .;src;classes;clojure.jar clojure.main src/test/test.clj".
>> If it helps, the full error I am getting now is:
>>
>> java.io.IOException: The system cannot find the path specified
>> (test.clj:1)
>> at clojure.lang.Compiler.analyzeSeq(Compiler.java:4113)
>> at clojure.lang.Compiler.analyze(Compiler.java:3935)
>> at clojure.lang.Compiler.analyze(Compiler.java:3908)
>> at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:
>> 3613)
>> at clojure.lang.Compiler.analyzeSeq(Compiler.java:4106)
>> at clojure.lang.Compiler.analyze(Compiler.java:3935)
>> at clojure.lang.Compiler.analyzeSeq(Compiler.java:4094)
>> at clojure.lang.Compiler.analyze(Compiler.java:3935)
>> at clojure.lang.Compiler.analyze(Compiler.java:3908)
>> at clojure.lang.Compiler.compile(Compiler.java:4559)
>> at clojure.lang.RT.compile(RT.java:362)
>> at clojure.lang.RT.load(RT.java:404)
>> at clojure.lang.RT.load(RT.java:376)
>> at clojure.core$load__4557$fn__4559.invoke(core.clj:3427)
>> at clojure.core$load__4557.doInvoke(core.clj:3426)
>> at clojure.lang.RestFn.invoke(RestFn.java:413)
>> at clojure.core$load_one__4520.invoke(core.clj:3271)
>> at clojure.core$compile__4563$fn__4565.invoke(core.clj:3437)
>> at clojure.core$compile__4563.invoke(core.clj:3436)
>> at test.test$eval__7.invoke(test.clj:8)
>> at clojure.lang.Compiler.eval(Compiler.java:4142)
>> at clojure.lang.Compiler.load(Compiler.java:4470)
>> at clojure.lang.Compiler.loadFile(Compiler.java:4437)
>> at clojure.main$load_script__5177.invoke(main.clj:117)
>> at clojure.main$script_opt__5209.invoke(main.clj:163)
>> at clojure.main$_main__5222.doInvoke(main.clj:227)
>> at clojure.lang.RestFn.applyTo(RestFn.java:142)
>> at clojure.main.main(Unknown Source)
>> Caused by: java.io.IOException: The system cannot find the path
>> specified
>> at java.io.WinNTFileSystem.createFileExclusively(Native
>> Method)
>> at java.io.File.createNewFile(File.java:883)
>> at clojure.lang.Compiler.writeClassFile(Compiler.java:4498)
>> at clojure.core$gen_class__5126.doInvoke(genclass.clj:547)
>> at clojure.lang.RestFn.invoke(RestFn.java:498)
>> at clojure.lang.Var.invoke(Var.java:347)
>> at clojure.lang.AFn.applyToHelper(AFn.java:198)
>> at clojure.lang.Var.applyTo(Var.java:444)
>> at clojure.lang.Compiler.macroexpand1(Compiler.java:4025)
>> at clojure.lang.Compiler.analyzeSeq(Compiler.java:4092)
>> ... 27 more
>>
>> On Mar 3, 9:49 am, Laurent PETIT  wrote:
>>
>>> You cannot have both a classpath full of jars and directories (via  
>>> the -cp
>>> option) and run directly from a jar.
>>
>>> Try java -classpath .;src;classes;clojure.jar clojure.main" instead
>>
>>> (http://clojure.org/repl_and_main)
>>
>>> 2009/3/3 zodoz 
>>
 *sigh*...  Still no joy.  I've looked around for how to use the
 command and I finally got it to stop giving me directory permission
 errors, but Java still does not seem to be liking it.  I am now
 running it with "java -classpath .;src;classes -jar clojure.jar",  
 but
 when I run (compile 'test) or (compile 'test.test) I still get
 "java.io.IOException: The system cannot find the path specified
 (test.clj:1)"...  Am I running the command java command wrong?
>>
 P.S.  I tried the java command with "src" only and "." only as  
 well.
>>
 On Mar 3, 6:41 am, Mark Volkmann  wrote:
> On Tue, Mar 3, 2009 at 12:58 AM, zodoz  wrote:
>>
>> I'm just larning Clojure and have been able to figure out  
>> everything
>> so far via trial-and-error.  However, I cannot for the LIFE of me
>> figure out how to compile anything.  I have tried every  
>> possible setup
>> I can think of and I all I have is a sneaking suspicion that  
>> its a
>> Vista issue.
>>
>> Below I have listed my setup to make this as complete a  
>> question as I
>> can, however the error I am getting is "java.io.IOException: The
>> system cannot find the path specified (test.clj:1)" so I don't  
>> expect
>> the problem to be with how my filesystem is s

Re: Compiling problem.

2009-03-03 Thread zodoz

I found the solution (though I'm still in the process of understanding
why it works):

java -cp clojure.jar;.\src;.\classes clojure.lang.Repl
user=> (compile 'test.test)

On Mar 3, 10:56 am, zodoz  wrote:
> Same thing.  I even tried putting (compile 'test.test) in the src/test/
> test.clj file and loading it with "java -
> classpath .;src;classes;clojure.jar clojure.main src/test/test.clj".
> If it helps, the full error I am getting now is:
>
> java.io.IOException: The system cannot find the path specified
> (test.clj:1)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:4113)
>         at clojure.lang.Compiler.analyze(Compiler.java:3935)
>         at clojure.lang.Compiler.analyze(Compiler.java:3908)
>         at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:
> 3613)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:4106)
>         at clojure.lang.Compiler.analyze(Compiler.java:3935)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:4094)
>         at clojure.lang.Compiler.analyze(Compiler.java:3935)
>         at clojure.lang.Compiler.analyze(Compiler.java:3908)
>         at clojure.lang.Compiler.compile(Compiler.java:4559)
>         at clojure.lang.RT.compile(RT.java:362)
>         at clojure.lang.RT.load(RT.java:404)
>         at clojure.lang.RT.load(RT.java:376)
>         at clojure.core$load__4557$fn__4559.invoke(core.clj:3427)
>         at clojure.core$load__4557.doInvoke(core.clj:3426)
>         at clojure.lang.RestFn.invoke(RestFn.java:413)
>         at clojure.core$load_one__4520.invoke(core.clj:3271)
>         at clojure.core$compile__4563$fn__4565.invoke(core.clj:3437)
>         at clojure.core$compile__4563.invoke(core.clj:3436)
>         at test.test$eval__7.invoke(test.clj:8)
>         at clojure.lang.Compiler.eval(Compiler.java:4142)
>         at clojure.lang.Compiler.load(Compiler.java:4470)
>         at clojure.lang.Compiler.loadFile(Compiler.java:4437)
>         at clojure.main$load_script__5177.invoke(main.clj:117)
>         at clojure.main$script_opt__5209.invoke(main.clj:163)
>         at clojure.main$_main__5222.doInvoke(main.clj:227)
>         at clojure.lang.RestFn.applyTo(RestFn.java:142)
>         at clojure.main.main(Unknown Source)
> Caused by: java.io.IOException: The system cannot find the path
> specified
>         at java.io.WinNTFileSystem.createFileExclusively(Native
> Method)
>         at java.io.File.createNewFile(File.java:883)
>         at clojure.lang.Compiler.writeClassFile(Compiler.java:4498)
>         at clojure.core$gen_class__5126.doInvoke(genclass.clj:547)
>         at clojure.lang.RestFn.invoke(RestFn.java:498)
>         at clojure.lang.Var.invoke(Var.java:347)
>         at clojure.lang.AFn.applyToHelper(AFn.java:198)
>         at clojure.lang.Var.applyTo(Var.java:444)
>         at clojure.lang.Compiler.macroexpand1(Compiler.java:4025)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:4092)
>         ... 27 more
>
> On Mar 3, 9:49 am, Laurent PETIT  wrote:
>
> > You cannot have both a classpath full of jars and directories (via the -cp
> > option) and run directly from a jar.
>
> > Try java -classpath .;src;classes;clojure.jar clojure.main" instead
>
> > (http://clojure.org/repl_and_main)
>
> > 2009/3/3 zodoz 
>
> > > *sigh*...  Still no joy.  I've looked around for how to use the
> > > command and I finally got it to stop giving me directory permission
> > > errors, but Java still does not seem to be liking it.  I am now
> > > running it with "java -classpath .;src;classes -jar clojure.jar", but
> > > when I run (compile 'test) or (compile 'test.test) I still get
> > > "java.io.IOException: The system cannot find the path specified
> > > (test.clj:1)"...  Am I running the command java command wrong?
>
> > > P.S.  I tried the java command with "src" only and "." only as well.
>
> > > On Mar 3, 6:41 am, Mark Volkmann  wrote:
> > > > On Tue, Mar 3, 2009 at 12:58 AM, zodoz  wrote:
>
> > > > > I'm just larning Clojure and have been able to figure out everything
> > > > > so far via trial-and-error.  However, I cannot for the LIFE of me
> > > > > figure out how to compile anything.  I have tried every possible setup
> > > > > I can think of and I all I have is a sneaking suspicion that its a
> > > > > Vista issue.
>
> > > > > Below I have listed my setup to make this as complete a question as I
> > > > > can, however the error I am getting is "java.io.IOException: The
> > > > > system cannot find the path specified (test.clj:1)" so I don't expect
> > > > > the problem to be with how my filesystem is setup but rather with
> > > > > classpaths.  Any suggestions and thanks in advance?
>
> > > > > I have a simple extraction of the latest files, inside the "clojure"
> > > > > folder I have renamed the orrigonal "src" folder to "srcb" so that I
> > > > > can single out only my code.  I have a test.clj file whose contents
> > > > > are (basically the example given on the main site):
> > > > > (ns test
> > > > >        (:ge

Re: Game of Life

2009-03-03 Thread Stephen C. Gilardi


On Mar 3, 2009, at 3:03 PM, lps540 wrote:


I've written a small example of Conway's Game of Life using Clojure
and Swing. Comments/critiques are welcome.


Very nice example!

Here's a more compact determine-new-state:

(defn determine-new-state [x y]
  (let [count (reduce + (for [dx [-1 0 1] dy [-1 0 1]]
  (if (cells [(+ x dx) (+ y dy)]) 1 0)))]
(or (and (cells [x y]) (> count 2) (< count 5))
(= count 3

I'm guessing someone can make the reduce even tighter.

I considered using :when (not (and (zero? dx) (zero? dy))) in the for  
expression, but it seemed simpler to account for the extra count when  
(cells [x y]) is true in the new state expression down below.


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Game of Life

2009-03-03 Thread Mark Volkmann

On Tue, Mar 3, 2009 at 2:03 PM, lps540  wrote:
>
> I've written a small example of Conway's Game of Life using Clojure
> and Swing. Comments/critiques are welcome.

Instead of all the uses of (- x 1), (- y 1), (+ x 1) and (+ y 1), I
think it's more idiomatic to use (dec x), (dec y), (inc x) and (inc
y).

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: test-clojure: trouble with the latest Clojure SVN version

2009-03-03 Thread Stephen C. Gilardi

On Mar 3, 2009, at 3:39 PM, Frantisek Sodomka wrote:


There is a problem with the latest Clojure SVN version. Try running in
clojure-contrib: ant test_clojure


I confirmed that r1321 passes the tests and r1322 fails.

To run the tests, I use:

cd /the/path/to/my/clojure-contrib
ant -Dclojure.jar=/the/path/to/my/clojure.jar test

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Game of Life

2009-03-03 Thread Mark Volkmann

On Tue, Mar 3, 2009 at 2:03 PM, lps540  wrote:
>
> I've written a small example of Conway's Game of Life using Clojure
> and Swing. Comments/critiques are welcome.
>
> http://lpsherrill.blogspot.com/2009/02/conways-game-of-life.html

The paint-cells function can be shorted by using doseq and destructuring.

(defn paint-cells [graphics]
  (doseq [[[x, y] state] @cells]
(doto graphics
  (.setColor (if state Color/RED Color/WHITE))
  (.fillRect (* 10 x) (* 10 y) 10 10

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Waterfront 148 (was: Waterfront - The Clojure-based editor for Clojure)

2009-03-03 Thread Itay Maman

Adler, Konard:

Thank you guys for the patches.
-Itay


On Mar 3, 9:14 pm, aperotte  wrote:
> Hi,
>
> I'm using linux (Ubuntu) and none of the above scripts worked for me.
> I added the ${DP}/bin directory to the classpath list to get it to
> work.
>
> #!/bin/sh
> DP="${0%/*}"
> java -cp ~/src/clojure/clojure.jar:${DP}/clj:${DP}/java -
> Dnet.sourceforge.waterfront.plugins=${DP}/clj/net/sourceforge/
> waterfront/ide/plugins clojure.main ${DP}/clj/net/sourceforge/
> waterfront/ide/main.clj $*
>
> P.S. - The text editor you are using for the shell script is encoding
> DOS style newlines and doesn't work on linux.  I copied the text to a
> new file to get around it.
>
> -Adler
>
> On Feb 25, 4:32 am, Itay Maman  wrote:
>
> > On Feb 25, 11:08 am, bOR_  wrote:
>
> > > I'm trying to rewrite the wf.bat to a linux version, but I was a bit
> > > puzzled what all the ;%~dp0 's mean.
>
> > In .bat files %~dp0 specifies the directory where the .bat file is
> > located.
> > In sh scripts, it should be `dirname $0`.
>
> > >Apparently the bash version of it
> > > is ${0%/*}
>
> > > java -cp ~/src/clojure/clojure.jar;${0%/*}clj;${0%/*}java -
> > > Dnet.sourceforge.waterfront.plugins=${0%/*}clj/net/sourceforge/
> > > waterfront/ide/plugins clojure.main ${0%/*}clj/net/sourceforge/
> > > waterfront/ide/main.clj %*
>
> > > It seems like you're also assuming 'clj' to exist?
>
> > clj and java are the subdirectories in the Waterfront installation
> > directory. So if the zip was unzipped
> > successfully, it is safe to assume they exist.
>
> > I don't have a Linux machine. Could you send me this script (one it is
> > up and running)
> > so that I will put it inside the .zip file?
>
> > Thanks,
> > -Itay
>
> > > On Feb 25, 2:57 am, Kevin Albrecht  wrote:
>
> > > > Itay,
>
> > > > I took a look at Waterfront and it seems to have a lot of potential.
> > > > Keep me and the group updated on your future work.
>
> > > > I have also been working on a GUI application in Clojure and I share
> > > > your perspective on the challenges of designing a functional GUI.  I
> > > > am definitely intrigued by the application context pattern and I am
> > > > going to take a look at it for incorporation in my design.
>
> > > > Thanks,
> > > > Kevin Albrecht
>
> > > > On Feb 24, 6:04 am, Itay Maman  wrote:
>
> > > > > I've been silently following Clojure (and this group) for several
> > > > > months now.Somewhere around December I started working on a Clojure
> > > > > editor/REPL written in Clojure. This effort evolved into the
> > > > > Waterfront project which is now available on sourceforge (http://
> > > > > sourceforge.net/project/showfiles.php?group_id=249246).
>
> > > > > Waterfront's Highlights:
>
> > > > > * CTRL+E: Eval current selection, or the whole file if the selection
> > > > > is empty
> > > > > * Edit -> Eval as you type: When turned on (default) periodically
> > > > > evaluates your code. Boosts productivity as many errors are detected
> > > > > on the spot.
> > > > > * Eval-ed code can inspect/mutate Waterfront by accessing the *app*
> > > > > variable. For instance, if you eval this expression,
> > > > > ((*app* :change) :font-name "Arial"), you will choose "Arial" as the
> > > > > UI font.
> > > > > * Eval-ed code can inspect the currently edited Clojure program. For
> > > > > instance, if you eval this expression, ((*app* :visit) #(when (= (str
> > > > > (first %1)) "cons") (println %1))), the output window will show all
> > > > > calls, made by your code, to the cons function.
> > > > > * Syntax and Evaluation errors are displayed on: (1) The Problems
> > > > > window; (2) The line-number panel, as red markers.
> > > > > * Source -> Generate -> Proxy: Generates a proxy for the given list of
> > > > > super-types, with stub implementations for all abstract methods.
> > > > > * F1: Shows the doc (as per Clojure's (doc x) function) of the
> > > > > identifier under the caret.
> > > > > * Source -> Reflect: Shows the synopsis of a Java class when the caret
> > > > > stands on a class symbol (e.g.: java.awt.Color).
> > > > > * CTRL+Space: Token-based auto completion.
> > > > > * Full parenthesis matching.
> > > > > * An extensible plugin architecture.
> > > > > * Other goodies such as undo/redo, toggle comment, recently opened
> > > > > files, indent/unindent, Tab is *always* two spaces, ...
>
> > > > > In order to get started, you need to
> > > > >   (1) Download the waterfront zip file 
> > > > > from:http://sourceforge.net/project/showfiles.php?group_id=249246.
> > > > >   (2) Unpack it into a local directory.
> > > > >   (3) Edit wf.bat: fix the path to clojure.jar according to its
> > > > > location on your machine.
>
> > > > > Personally, this effort was quite interesting. Writing GUI
> > > > > applications in a functional language is sometimes a challenging task
> > > > > (at least if you want your Clojure code not to be a transliteration of
> > > > > Java code…).  I used a pattern the "application context" pattern: an
> 

Re: Game of Life

2009-03-03 Thread Larry Sherrill

Hi Phil,

Thanks for the tips. Yes, alter and doseq do look better.

As far as the "running" variable, there is one thread painting the
squares and another thread responding to the mouse click on start/
stop. This was the only way I could think of that the user could stop
the paint thread, using a Java idiom. I'll read up on binding.

Thank again!
Larry

On Mar 3, 1:30 pm, Phil Hagelberg  wrote:
> lps540  writes:
> > I've written a small example of Conway's Game of Life using Clojure
> > and Swing. Comments/critiques are welcome.
>
> Interesting program!
>
>     (for [x (range 32) y (range 48)]
>                 (ref-set cells
>                   (assoc (deref cells) [x y] (= 0 (rand-int 5)
>
> While you can use ref-set this way, it's much more concise to use alter:
>
>     (for [x (range 32) y (range 48)]
>       (alter cells assoc [x y] (= 0 (rand-int 5
>
> You should use this in calc-state as well.
>
> Also, the paint-cells function is called only for side-effects. Instead
> of using dorun+map, you should use doseq:
>
>   (defn paint-cells [graphics]
>     (doseq [cell @cells]
>       (let [x (first (first cell))
>             y (second (first cell))
>             state (second cell)]
>         (doto graphics
>           (. setColor (if state Color/RED Color/WHITE))
>           (. fillRect (* 10 x) (* 10 y) 10 10)
>
> I'm not sure if making "running" a ref makes sense here. Do you need to
> coordinate change in it across threads, or will the change only happen
> in one thread? If it's the former, using a thread-local var with
> "binding" is probably a better choice.
>
> Also, instead of calling (deref cells), you can use @cells for short.
>
> -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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



test-clojure: trouble with the latest Clojure SVN version

2009-03-03 Thread Frantisek Sodomka

There is a problem with the latest Clojure SVN version. Try running in
clojure-contrib: ant test_clojure

It generates failures and errors. There is some confusion between
"nil" and "()" by the reader/compiler it seems.

Also:
user=> (pop '(1 2 3))
java.lang.ClassCastException: clojure.lang.Cons cannot be cast to
clojure.lang.IPersistentStack

user=> (peek '(1 2 3))
java.lang.ClassCastException: clojure.lang.Cons cannot be cast to
clojure.lang.IPersistentStack

Many tests pass in REPL, but fail when loaded from file it seems.

Thanks for your attention, Frantisek

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

2009-03-03 Thread Phil Hagelberg

lps540  writes:

> I've written a small example of Conway's Game of Life using Clojure
> and Swing. Comments/critiques are welcome.

Interesting program!

(for [x (range 32) y (range 48)]
(ref-set cells 
  (assoc (deref cells) [x y] (= 0 (rand-int 5)

While you can use ref-set this way, it's much more concise to use alter:

(for [x (range 32) y (range 48)]
  (alter cells assoc [x y] (= 0 (rand-int 5

You should use this in calc-state as well.

Also, the paint-cells function is called only for side-effects. Instead
of using dorun+map, you should use doseq:

  (defn paint-cells [graphics]
(doseq [cell @cells]
  (let [x (first (first cell))
y (second (first cell))
state (second cell)]
(doto graphics
  (. setColor (if state Color/RED Color/WHITE))
  (. fillRect (* 10 x) (* 10 y) 10 10)

I'm not sure if making "running" a ref makes sense here. Do you need to
coordinate change in it across threads, or will the change only happen
in one thread? If it's the former, using a thread-local var with
"binding" is probably a better choice.

Also, instead of calling (deref cells), you can use @cells for short.

-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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Game of Life

2009-03-03 Thread lps540

I've written a small example of Conway's Game of Life using Clojure
and Swing. Comments/critiques are welcome.

http://lpsherrill.blogspot.com/2009/02/conways-game-of-life.html

Thanks,
Larry

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: contrib build errors after javadoc => repl-utils

2009-03-03 Thread Stephen C. Gilardi

Hi Christophe Grand or other contrib committers,

clojure.contrib.javadoc should be removed from the list of libs to
compile in the build.xml file; as it stands, building with ant throws
the Exception that fires when c.c.javadoc is compiled.

Best,
Perry


Fixed. Thanks for the report!

--Steve



smime.p7s
Description: S/MIME cryptographic signature


contrib build errors after javadoc => repl-utils

2009-03-03 Thread Perry Trolard

Hi Christophe Grand or other contrib committers,

clojure.contrib.javadoc should be removed from the list of libs to
compile in the build.xml file; as it stands, building with ant throws
the Exception that fires when c.c.javadoc is compiled.

Best,
Perry
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Waterfront - The Clojure-based editor for Clojure

2009-03-03 Thread aperotte

Hi,

I'm using linux (Ubuntu) and none of the above scripts worked for me.
I added the ${DP}/bin directory to the classpath list to get it to
work.

#!/bin/sh
DP="${0%/*}"
java -cp ~/src/clojure/clojure.jar:${DP}/clj:${DP}/java -
Dnet.sourceforge.waterfront.plugins=${DP}/clj/net/sourceforge/
waterfront/ide/plugins clojure.main ${DP}/clj/net/sourceforge/
waterfront/ide/main.clj $*

P.S. - The text editor you are using for the shell script is encoding
DOS style newlines and doesn't work on linux.  I copied the text to a
new file to get around it.

-Adler

On Feb 25, 4:32 am, Itay Maman  wrote:
> On Feb 25, 11:08 am, bOR_  wrote:
>
> > I'm trying to rewrite the wf.bat to a linux version, but I was a bit
> > puzzled what all the ;%~dp0 's mean.
>
> In .bat files %~dp0 specifies the directory where the .bat file is
> located.
> In sh scripts, it should be `dirname $0`.
>
> >Apparently the bash version of it
> > is ${0%/*}
>
> > java -cp ~/src/clojure/clojure.jar;${0%/*}clj;${0%/*}java -
> > Dnet.sourceforge.waterfront.plugins=${0%/*}clj/net/sourceforge/
> > waterfront/ide/plugins clojure.main ${0%/*}clj/net/sourceforge/
> > waterfront/ide/main.clj %*
>
> > It seems like you're also assuming 'clj' to exist?
>
> clj and java are the subdirectories in the Waterfront installation
> directory. So if the zip was unzipped
> successfully, it is safe to assume they exist.
>
> I don't have a Linux machine. Could you send me this script (one it is
> up and running)
> so that I will put it inside the .zip file?
>
> Thanks,
> -Itay
>
> > On Feb 25, 2:57 am, Kevin Albrecht  wrote:
>
> > > Itay,
>
> > > I took a look at Waterfront and it seems to have a lot of potential.
> > > Keep me and the group updated on your future work.
>
> > > I have also been working on a GUI application in Clojure and I share
> > > your perspective on the challenges of designing a functional GUI.  I
> > > am definitely intrigued by the application context pattern and I am
> > > going to take a look at it for incorporation in my design.
>
> > > Thanks,
> > > Kevin Albrecht
>
> > > On Feb 24, 6:04 am, Itay Maman  wrote:
>
> > > > I've been silently following Clojure (and this group) for several
> > > > months now.Somewhere around December I started working on a Clojure
> > > > editor/REPL written in Clojure. This effort evolved into the
> > > > Waterfront project which is now available on sourceforge (http://
> > > > sourceforge.net/project/showfiles.php?group_id=249246).
>
> > > > Waterfront's Highlights:
>
> > > > * CTRL+E: Eval current selection, or the whole file if the selection
> > > > is empty
> > > > * Edit -> Eval as you type: When turned on (default) periodically
> > > > evaluates your code. Boosts productivity as many errors are detected
> > > > on the spot.
> > > > * Eval-ed code can inspect/mutate Waterfront by accessing the *app*
> > > > variable. For instance, if you eval this expression,
> > > > ((*app* :change) :font-name "Arial"), you will choose "Arial" as the
> > > > UI font.
> > > > * Eval-ed code can inspect the currently edited Clojure program. For
> > > > instance, if you eval this expression, ((*app* :visit) #(when (= (str
> > > > (first %1)) "cons") (println %1))), the output window will show all
> > > > calls, made by your code, to the cons function.
> > > > * Syntax and Evaluation errors are displayed on: (1) The Problems
> > > > window; (2) The line-number panel, as red markers.
> > > > * Source -> Generate -> Proxy: Generates a proxy for the given list of
> > > > super-types, with stub implementations for all abstract methods.
> > > > * F1: Shows the doc (as per Clojure's (doc x) function) of the
> > > > identifier under the caret.
> > > > * Source -> Reflect: Shows the synopsis of a Java class when the caret
> > > > stands on a class symbol (e.g.: java.awt.Color).
> > > > * CTRL+Space: Token-based auto completion.
> > > > * Full parenthesis matching.
> > > > * An extensible plugin architecture.
> > > > * Other goodies such as undo/redo, toggle comment, recently opened
> > > > files, indent/unindent, Tab is *always* two spaces, ...
>
> > > > In order to get started, you need to
> > > >   (1) Download the waterfront zip file 
> > > > from:http://sourceforge.net/project/showfiles.php?group_id=249246.
> > > >   (2) Unpack it into a local directory.
> > > >   (3) Edit wf.bat: fix the path to clojure.jar according to its
> > > > location on your machine.
>
> > > > Personally, this effort was quite interesting. Writing GUI
> > > > applications in a functional language is sometimes a challenging task
> > > > (at least if you want your Clojure code not to be a transliteration of
> > > > Java code…).  I used a pattern the "application context" pattern: an
> > > > immutable map describing the application's current state that is
> > > > passed around. This made it possible for most of Waterfront's code to
> > > > be purely functional. Consequently, plugins can accomplish a lot with
> > > > just a handful of lines. Many plugins span

Re: doall, dorun, doseq, for

2009-03-03 Thread Mark Volkmann

On Tue, Mar 3, 2009 at 9:42 AM, Chouser  wrote:
>
> If you have a lazy sequence with side-effects, you almost certainly
> don't want to let it out of your sight.  You're likely to get very
> strange behavior unless you're exceedingly careful.  Most likely, if
> you've got a lazy seq with side effects you should force it with dorun
> or doall immediately.  Use doall if you care about the values in the
> produced seq, otherwise use dorun.
>
> This means that dorun should almost always show up right next to the
> form producing the lazy seq, which means doseq is very likely a better
> choice, as it is more efficient and usually more succinct than dorun
> combined with a lazy-seq producer.

I agree that using doseq instead of dorun results in code that is
easier to read. I don't understand though why it is more efficient.
They both walk the entire sequence, neither holds onto the head and
both return nil. Why is doseq more efficient than dorun?

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Question on names of errors in error-kit

2009-03-03 Thread samppi

Small questions on error-kit—which I love and think that all clojure-
contrib libraries should use—why do defined errors such as *error*,
*number-error*, etc. have names surrounded by asterisks? According to
this thread—http://groups.google.com/group/clojure/browse_thread/
thread/65d98eda2d1154b2—the convention is that variables surrounded by
asterisks are meant to be used with the binding function. I don't
really think that applies as much to error types, though—but does it?
And should I use asterisks when I define my own errors?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Waterfront 148 (was: Waterfront - The Clojure-based editor for Clojure)

2009-03-03 Thread Konrad Hinsen

Itay,

> Alternatively hoping that this is the only Java6-only dependency in
> the code, you can also apply this patch to clj/net/sourceforge/
> waterfront/ide/plugins/file.clj (I didn't test is though - I am away
> from my machine, so no warranty...)

Thanks for the quick fix, it works!

I can now start Waterfront and work with it, but there are still some  
error messages at startup concerning certain plugins:

Can't load plugin undo.clj. Reason: java.lang.Exception: LazySeq used  
in 'if' (lexer.clj:0)
Can't load plugin comments.clj. Reason: java.lang.Exception: Unable  
to resolve symbol: create-undo-transaction in this context  
(comments.clj:48)
Can't load plugin find.clj. Reason: java.lang.Exception: Unable to  
resolve symbol: create-undo-transaction in this context (find.clj:117)
Can't load plugin check-syntax.clj. Reason: java.lang.Exception:  
LazySeq used in 'if' (lexer.clj:0)
Can't load plugin indent.clj. Reason: java.lang.Exception: Unable to  
resolve symbol: create-undo-transaction in this context (indent.clj:125)
Can't load plugin paren-matching.clj. Reason: java.lang.Exception:  
LazySeq used in 'if' (lexer.clj:0)
Can't load plugin eval-as-you-type.clj. Reason: java.lang.Exception:  
LazySeq used in 'if' (lexer.clj:0)


I applied two fixes in lexer.clj that get rid of all these messages:

1) Replace first-is by

(defn first-is
   { :test (fn []
 (assert-eq false (first-is \a (seq "")))
 (assert-eq true (first-is :nothing (seq "")))
 (assert-eq true (first-is \a (seq "a")))
 (assert-eq false (first-is :nothing (seq "a")))
 (assert-eq true (first-is \a (seq "ab")))
 (assert-eq false (first-is :nothing (seq "ab")))
 (assert-eq false (first-is \a (seq "ba")))
 (assert-eq false (first-is :nothing (seq "ba"))) )}
   [e es]
   (if (seq es)
 (= e (first es))
 (= e :nothing) ))


2) Replace get-mate-from-pairs by

(defn get-mate-from-pairs
   { :test (fn []
 (assert-eq [:match 4] (get-mate-from-pairs (compute- 
paren-matching-pairs  "01[3]5") 2)) )}
   [pairs offset]
   (let [pair (filter (fn [x] (= offset (second x))) pairs)]
 (if (seq pair)
   [(nth (first pair) 0) (nth (first pair) 2)]
   nil )))


Konrad.


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

2009-03-03 Thread Daniel Spiewak

Warning: if you're using a clone of my Git repository, you will
probably need to reclone from scratch, otherwise things will no longer
work.  Because of some changes in the upstream Buildr SVN repository,
everybody on the project has been doing a ton of rebasing lately.
This means that the latest stuff on GitHub is *unrelated* (at the Git
level) to what came before.  The repository and commit history is
internally consistent, but it has no shared root with the old.  This
means that if you try to do a git pull, you'll run into merge
conflicts out the wazoo.  The good news is that this is probably the
last time we will need to do this sort of rebasing, meaning that you
should be able to trust the remote refs from this point forward.

As mentioned previously, the preferred way to install my fork is to
use the following commands:

  gem sources -a http://gems.github.com
  gem install djspiewak-buildr

This will keep you up to date with the latest stuff in my fork without
the need to clone it yourself or go through the conniptions of
installing all of the build dependencies (which include some other
weird installs like assaf-docter).

Daniel

On Feb 27, 4:21 pm, Daniel Spiewak  wrote:
> As an aside, "gem install djspiewak-buildr" probably works again.
> I've merged Assaf's fixes, and GitHub *claims* to be building things
> correctly.  So, I haven't tried it, but I can't think of a reason why
> it wouldn't work.
>
> Daniel
>
> On Feb 27, 2:39 pm, Christian Vest Hansen 
> wrote:
>
> > On Fri, Feb 27, 2009 at 6:47 PM, Daniel Spiewak  wrote:
>
> > > Correction:
>
> > >  git clone git://github.com:djspiewak/buildr.git
>
> > git clone git://github.com/djspiewak/buildr.git
>
> > Excellent. Got it installed.
>
> > > Daniel
>
> > > On Feb 27, 11:44 am, Daniel Spiewak  wrote:
> > >> I was able to repeat the problem.  I suspect that the issue is the way
> > >> in which GitHub is building its gems.  I think Assaf (the lead dev for
> > >> Buildr) has implemented a workaround in some of the more recent
> > >> commits, but I haven't been able to merge with his master so I really
> > >> couldn't say.
>
> > >> For the moment, the solution is to just clone the git repository and
> > >> build using rake.  If you were able to get djspiewak-buildr to install
> > >> (as you did), then you should be able to just run the following:
>
> > >>   sudo gem uninstall djspiewak-buildr
> > >>   git clone g...@github.com:djspiewak/buildr.git
> > >>   cd buildr
> > >>   rake install
>
> > >> Note that there is no need to run rake under sudo, the install task
> > >> will handle that for you.
>
> > >> Daniel
>
> > >> On Feb 26, 7:59 pm, Daniel Spiewak  wrote:
>
> > >> > Crud.  I suspect this is something weird with the way that the GitHib
> > >> > gem server works.  I'll try to repeat the problem on Ubuntu as soon as
> > >> > I get back to my computer.  In the meantime, you could try these
> > >> > commands:
>
> > >> >   sudo gem uninstall djspiewak-buildr
> > >> >   sudo gem install djspiewak-buildr
>
> > >> > Daniel
>
> > >> > On Feb 26, 3:59 pm, Christian Vest Hansen 
> > >> > wrote:
>
> > >> > > rowe:~$ buildr --version
> > >> > > /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in
> > >> > > `gem_original_require': no such file to load -- buildr (LoadError)
> > >> > >         from 
> > >> > > /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in
> > >> > > `require'
> > >> > >         from 
> > >> > > /opt/local/lib/ruby/gems/1.8/gems/djspiewak-buildr-1.3.4/bin/buildr:18
> > >> > >         from /opt/local/bin/buildr:19:in `load'
> > >> > >         from /opt/local/bin/buildr:19
> > >> > > rowe:~$ gem --version
> > >> > > 1.3.1
> > >> > > rowe:~$
>
> > >> > > On Thu, Feb 26, 2009 at 10:30 PM, Daniel Spiewak 
> > >> > >  wrote:
>
> > >> > > > I'm not sure what the File not found thing is all about, but you
> > >> > > > should still be ok (crazy gems).  Try the following:
>
> > >> > > >  buildr --version
>
> > >> > > > Daniel
>
> > >> > > > On Feb 26, 3:16 pm, Christian Vest Hansen 
> > >> > > > wrote:
> > >> > > >> On Thu, Feb 26, 2009 at 6:17 PM, Daniel Spiewak 
> > >> > > >>  wrote:
>
> > >> > > >> > Odd.  Must be a problem with RubyForge.  If you try again, does 
> > >> > > >> > it
> > >> > > >> > work?
>
> > >> > > >> I tried again at home and got quite a bit further. Maybe it was 
> > >> > > >> just a
> > >> > > >> hiccup at rubyforge.
>
> > >> > > >> However, I still see some questionable things in the output, and I
> > >> > > >> have yet to actually try it out (this is the first time I'm 
> > >> > > >> trying out
> > >> > > >> buildr). Here in verbatim:
>
> > >> > > >> rowe:~$ sudo gem install djspiewak-buildr
> > >> > > >> Building native extensions.  This could take a while...
> > >> > > >> Successfully installed builder-2.1.2
> > >> > > >> Successfully installed net-ssh-2.0.4
> > >> > > >> Successfully installed net-sftp-2.0.1
> > >> > > >> Successfully installed rubyzip-0.9.1
> > >> > > >> Successfull

Re: Compiling problem.

2009-03-03 Thread zodoz

Same thing.  I even tried putting (compile 'test.test) in the src/test/
test.clj file and loading it with "java -
classpath .;src;classes;clojure.jar clojure.main src/test/test.clj".
If it helps, the full error I am getting now is:

java.io.IOException: The system cannot find the path specified
(test.clj:1)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4113)
at clojure.lang.Compiler.analyze(Compiler.java:3935)
at clojure.lang.Compiler.analyze(Compiler.java:3908)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:
3613)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4106)
at clojure.lang.Compiler.analyze(Compiler.java:3935)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4094)
at clojure.lang.Compiler.analyze(Compiler.java:3935)
at clojure.lang.Compiler.analyze(Compiler.java:3908)
at clojure.lang.Compiler.compile(Compiler.java:4559)
at clojure.lang.RT.compile(RT.java:362)
at clojure.lang.RT.load(RT.java:404)
at clojure.lang.RT.load(RT.java:376)
at clojure.core$load__4557$fn__4559.invoke(core.clj:3427)
at clojure.core$load__4557.doInvoke(core.clj:3426)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at clojure.core$load_one__4520.invoke(core.clj:3271)
at clojure.core$compile__4563$fn__4565.invoke(core.clj:3437)
at clojure.core$compile__4563.invoke(core.clj:3436)
at test.test$eval__7.invoke(test.clj:8)
at clojure.lang.Compiler.eval(Compiler.java:4142)
at clojure.lang.Compiler.load(Compiler.java:4470)
at clojure.lang.Compiler.loadFile(Compiler.java:4437)
at clojure.main$load_script__5177.invoke(main.clj:117)
at clojure.main$script_opt__5209.invoke(main.clj:163)
at clojure.main$_main__5222.doInvoke(main.clj:227)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.main.main(Unknown Source)
Caused by: java.io.IOException: The system cannot find the path
specified
at java.io.WinNTFileSystem.createFileExclusively(Native
Method)
at java.io.File.createNewFile(File.java:883)
at clojure.lang.Compiler.writeClassFile(Compiler.java:4498)
at clojure.core$gen_class__5126.doInvoke(genclass.clj:547)
at clojure.lang.RestFn.invoke(RestFn.java:498)
at clojure.lang.Var.invoke(Var.java:347)
at clojure.lang.AFn.applyToHelper(AFn.java:198)
at clojure.lang.Var.applyTo(Var.java:444)
at clojure.lang.Compiler.macroexpand1(Compiler.java:4025)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4092)
... 27 more

On Mar 3, 9:49 am, Laurent PETIT  wrote:
> You cannot have both a classpath full of jars and directories (via the -cp
> option) and run directly from a jar.
>
> Try java -classpath .;src;classes;clojure.jar clojure.main" instead
>
> (http://clojure.org/repl_and_main)
>
> 2009/3/3 zodoz 
>
>
>
> > *sigh*...  Still no joy.  I've looked around for how to use the
> > command and I finally got it to stop giving me directory permission
> > errors, but Java still does not seem to be liking it.  I am now
> > running it with "java -classpath .;src;classes -jar clojure.jar", but
> > when I run (compile 'test) or (compile 'test.test) I still get
> > "java.io.IOException: The system cannot find the path specified
> > (test.clj:1)"...  Am I running the command java command wrong?
>
> > P.S.  I tried the java command with "src" only and "." only as well.
>
> > On Mar 3, 6:41 am, Mark Volkmann  wrote:
> > > On Tue, Mar 3, 2009 at 12:58 AM, zodoz  wrote:
>
> > > > I'm just larning Clojure and have been able to figure out everything
> > > > so far via trial-and-error.  However, I cannot for the LIFE of me
> > > > figure out how to compile anything.  I have tried every possible setup
> > > > I can think of and I all I have is a sneaking suspicion that its a
> > > > Vista issue.
>
> > > > Below I have listed my setup to make this as complete a question as I
> > > > can, however the error I am getting is "java.io.IOException: The
> > > > system cannot find the path specified (test.clj:1)" so I don't expect
> > > > the problem to be with how my filesystem is setup but rather with
> > > > classpaths.  Any suggestions and thanks in advance?
>
> > > > I have a simple extraction of the latest files, inside the "clojure"
> > > > folder I have renamed the orrigonal "src" folder to "srcb" so that I
> > > > can single out only my code.  I have a test.clj file whose contents
> > > > are (basically the example given on the main site):
> > > > (ns test
> > > >        (:gen-class))
>
> > > > (defn -main
> > > >        [gre]
> > > >        (println (str "Hello " gre))
>
> > > > I have the following folder/file setup:
> > > > clojure/
> > > > ->clojure/classes
> > > > ->clojure/src
> > > > -->clojure/src/test
> > > > --->clojure/src/test/test.clj
> > > > -->clojure/src/test.clj
> > > > ->clojure/test.clj
>
> > > > Each of these test.c

Re: So what do we want for a Cells-alike ?

2009-03-03 Thread Stuart Sierra

On Mar 2, 10:41 pm, Jeffrey Straszheim 
wrote:
> There are a lot of "toy" cells implementations for Clojure, but as far as I
> can tell none of them are really full-production ready libraries like K.
> Tilton's.  I'm planning on starting a GUI based project and something cell's
> like would be very helpful.  I may end up building it myself, and am
> wondering what the community thinks is the best direction.

I think Clojure's existing concurrency tools get you most of the way
there.  The biggest missing piece is dependency management.  One good
goal, in my mind, is to build something that works alongside atoms/
agents/refs/vars, *not* something that adds a whole separate "cells
API".

-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
To unsubscribe from 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: Waterfront 148 (was: Waterfront - The Clojure-based editor for Clojure)

2009-03-03 Thread Itay Maman

Konrad,

Your installation is probably fine. The problem lies in the
FileNameExtensionFilter  class. It was only introduced in Java6.
Therefore, despite the fact
that you now have binaries that are compatible with your JVM, the
program does not run. I'll try to fix this soon. I'll post a message
when a new revision is up.

Alternatively hoping that this is the only Java6-only dependency in
the code, you can also apply this patch to clj/net/sourceforge/
waterfront/ide/plugins/file.clj (I didn't test is though - I am away
from my machine, so no warranty...)

Replace lines 169..173 with this:

(defn add-chooser [app]
  (let [chooser (javax.swing.JFileChooser. (. System getProperty
"user.dir"))]
(assoc app :file-chooser chooser) ))


Hope that helps.
-Itay


On Mar 3, 5:21 pm, Konrad Hinsen  wrote:
> On Mar 3, 2009, at 11:46, Tom Ayerst wrote:
>
> > If you pull trunk out of subversion you can build it locally with  
> > Ant.  Would that do it?
>
> Definitely, thanks!  I pulled the latest revision and built it by  
> typing "ant". No compilation errors, but I can't run it either:
>
> Can't load plugin custom-editor.clj. Reason:  
> java.lang.ClassNotFoundException:  
> javax.swing.filechooser.FileNameExtensionFilter (file.clj:171)
> Can't load plugin context-menu.clj. Reason: nil
> Can't load plugin file.clj. Reason: java.lang.ClassNotFoundException:  
> javax.swing.filechooser.FileNameExtensionFilter (file.clj:171)
> Can't load plugin problem-window.clj. Reason: nil
> Can't load plugin undo.clj. Reason: java.lang.Exception: LazySeq used  
> in 'if' (lexer.clj:0)
> Can't load plugin comments.clj. Reason: java.lang.Exception: Unable  
> to resolve symbol: create-undo-transaction in this context  
> (comments.clj:48)
> Can't load plugin line-column.clj. Reason: nil
> Can't load plugin find.clj. Reason: java.lang.Exception: Unable to  
> resolve symbol: create-undo-transaction in this context (find.clj:117)
> Can't load plugin indicator.clj. Reason: nil
> Can't load plugin output-window.clj. Reason: nil
> Can't load plugin check-syntax.clj. Reason: java.lang.Exception:  
> LazySeq used in 'if' (lexer.clj:0)
> Can't load plugin indent.clj. Reason: java.lang.Exception: Unable to  
> resolve symbol: create-undo-transaction in this context (indent.clj:125)
> Can't load plugin paren-matching.clj. Reason: java.lang.Exception:  
> LazySeq used in 'if' (lexer.clj:0)
> Can't load plugin eval-as-you-type.clj. Reason: java.lang.Exception:  
> LazySeq used in 'if' (lexer.clj:0)
> java.lang.NullPointerException
>         at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:26)
>         at net.sourceforge.waterfront.ide.plugins$set_font__1700.invoke(font-
> observer.clj:20)
>         at net.sourceforge.waterfront.ide.plugins$set_fonts__1703.invoke
> (font-observer.clj:26)
>         at net.sourceforge.waterfront.ide$dispatcher__550$fn__554.invoke
> (ui.clj:85)
> ...
>
> It looks as if my installation lacks parts of Swing, but there also  
> seem to be some lazy-seq-related bugs in Waterfront itself (my  
> Clojure is compiled with clojure.assert-if-lazy-seq=true).
>
> Is anyone running Waterfront successfully on a Mac with Java 1.5?
>
> Konrad.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: So what do we want for a Cells-alike ?

2009-03-03 Thread Jeffrey Straszheim
I don't think I gain anything here, however, over just updating the graph in
a dosync block, except I add a bunch of asynchronicity that I then have to
block to avoid.  With agents it also becomes more difficult to do static
analysis on the graph.

On Tue, Mar 3, 2009 at 11:12 AM, Anand Patil <
anand.prabhakar.pa...@gmail.com> wrote:

>
> On Mar 3, 3:38 pm, Jeffrey Straszheim 
> wrote:
> > I'm pretty sure I don't want an agent based model.  I want clear
> > transactional semantics.  However, there is no reason both should not
> > exist.
>
> I think you can get solid transactions with lazy agents, since an
> update corresponds to a single step/data pulse/whatever. Pseudocode:
>
> (dosync
>Attach a watcher to all the cells, that when requested blocks
> until they've computed a new value
>Change the values of the base cells
>Send an update message to all the cells, which will cause them all
> to update exactly once
>Wait on the watcher)
>
> Since agents are integrated with the STM, my understanding is that the
> new data update will get written in all at once. Is that good enough
> for your purpose?
>
> As Raffael pointed out, the laziness doesn't get you recording of
> previous values... but that wouldn't be inordinately challenging to
> add in.
>
> Anand
> >
>

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

2009-03-03 Thread Laurent PETIT
Correct. It seems that we are agreeing that we agree :-)

2009/3/3 Meikel Brandmeyer 

> Hi Laurent,
>
> Am 03.03.2009 um 17:03 schrieb Laurent PETIT:
>
>  Why should there ever be the need to call dorun?
>>>
>>
>>
>> If you still want to force a veeerry long seq for side effect, without
>> fearing to face an OutOfMemory error ?
>>
>
>  (let [some-lng-seq ]
>(dorun some-lng-seq)
>...)
>
> How does dorun help here? In such a scenario
> dorun only helps, if you don't hold onto the head.
> But that means you loose the seq immediately
> without using the return value at all. So you made
> the seq purely for side-effects. And at that point
> I boldly claim you should have used doseq in the
> first place
>
> 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
To unsubscribe from 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: doall, dorun, doseq, for

2009-03-03 Thread Chouser

On Tue, Mar 3, 2009 at 10:56 AM, Meikel Brandmeyer  wrote:
>>
>> This means that dorun should almost always show up right next to the
>> form producing the lazy seq, which means doseq is very likely a better
>> choice, as it is more efficient and usually more succinct than dorun
>> combined with a lazy-seq producer.
>
> What is the use case for dorun? It returns nil, so it can itself only
> be called as a side-effect.

This was kind of my point.  In every case I can think of at the
moment, I would prefer doseq over dorun.

>  (let [the-seq (map #(* % 2) (range 100))]
>    (doseq [x the-seq]
>      (println "Just produced:" x)))

So here's an example of where you could use dorun.

  (dorun (map #(println "Just produced: " (* % 2))
  (range 100)))

But I think what you had was at least as clear.  Though there's no
need for 'map' if you're going to use doseq:

  (doseq [x (range 100)]
(println "Just produced:" (* x 2)))

And no need for doseq if you're using a simple range:

  (dotimes [x 100]
(println "Just produced:" (* x 2)))

>> 'for' is in rather a different category, since unlike the others it
>> produces a lazy seq rather than forcing anything.  Use 'for' when it's
>> a more convenient way to express the lazy seq you want than the
>> equivalent combination of map, filter, take-while, etc.
>
> I must confess, I almost never used for... Maybe I should
> try to use it more often.

I like 'for' when I need nested behavior:

  (for [x '(a b c), y '(d e f)]
[x y])

vs.

  (mapcat (fn [x] (map #(vector x %)
   '(d e f)))
  '(a b c))

Of course it also does handy things with :when, :while, and :let, as
does doseq.

--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
To unsubscribe from 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: doall, dorun, doseq, for

2009-03-03 Thread Meikel Brandmeyer

Hi Laurent,

Am 03.03.2009 um 17:03 schrieb Laurent PETIT:


Why should there ever be the need to call dorun?



If you still want to force a veeerry long seq for side effect,  
without fearing to face an OutOfMemory error ?


  (let [some-lng-seq ]
(dorun some-lng-seq)
...)

How does dorun help here? In such a scenario
dorun only helps, if you don't hold onto the head.
But that means you loose the seq immediately
without using the return value at all. So you made
the seq purely for side-effects. And at that point
I boldly claim you should have used doseq in the
first place

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: So what do we want for a Cells-alike ?

2009-03-03 Thread Anand Patil

On Mar 3, 3:38 pm, Jeffrey Straszheim 
wrote:
> I'm pretty sure I don't want an agent based model.  I want clear
> transactional semantics.  However, there is no reason both should not
> exist.

I think you can get solid transactions with lazy agents, since an
update corresponds to a single step/data pulse/whatever. Pseudocode:

(dosync
Attach a watcher to all the cells, that when requested blocks
until they've computed a new value
Change the values of the base cells
Send an update message to all the cells, which will cause them all
to update exactly once
Wait on the watcher)

Since agents are integrated with the STM, my understanding is that the
new data update will get written in all at once. Is that good enough
for your purpose?

As Raffael pointed out, the laziness doesn't get you recording of
previous values... but that wouldn't be inordinately challenging to
add in.

Anand
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: doall, dorun, doseq, for

2009-03-03 Thread Laurent PETIT
2009/3/3 Meikel Brandmeyer 

> Hi,
>
> Am 03.03.2009 um 16:42 schrieb Chouser:
>
>  If you have a lazy sequence with side-effects, you almost certainly
>> don't want to let it out of your sight.  You're likely to get very
>> strange behavior unless you're exceedingly careful.  Most likely, if
>> you've got a lazy seq with side effects you should force it with dorun
>> or doall immediately.  Use doall if you care about the values in the
>> produced seq, otherwise use dorun.
>>
>> This means that dorun should almost always show up right next to the
>> form producing the lazy seq, which means doseq is very likely a better
>> choice, as it is more efficient and usually more succinct than dorun
>> combined with a lazy-seq producer.
>>
>
> What is the use case for dorun? It returns nil, so it can itself only
> be called as a side-effect. From doall and dorun, only doall makes
> sense to me. It is either called immediately
>
>  (doall (map ...))
>
> Or when giving the seq out of the hands:
>
>  (with-some resource
>...
>(doall the-seq))
>
> Why should there ever be the need to call dorun?


If you still want to force a veeerry long seq for side effect, without
fearing to face an OutOfMemory error ?


>
> And by the way: the output of the following code doesn't lie.
>
>  (let [the-seq (map #(* % 2) (range 100))]
>(doseq [x the-seq]
>  (println "Just produced:" x)))
>
>  'for' is in rather a different category, since unlike the others it
>> produces a lazy seq rather than forcing anything.  Use 'for' when it's
>> a more convenient way to express the lazy seq you want than the
>> equivalent combination of map, filter, take-while, etc.
>>
>
> I must confess, I almost never used for... Maybe I should
> try to use it more often.
>
> 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
To unsubscribe from 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: So what do we want for a Cells-alike ?

2009-03-03 Thread Raffael Cavallaro



On Mar 3, 10:45 am, Anand Patil 
wrote:

> Cells don't update until all of their parents have reported in, ie
> reached the current step.

This bit is important (i.e., no update until all parents are current)
and
constitutes an implicit notion of current step.

It still doesn't get you time lags though. For that you need to
memoize previous parent vals and a way to explicitly refer to them.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: doall, dorun, doseq, for

2009-03-03 Thread Meikel Brandmeyer

Hi,

Am 03.03.2009 um 16:42 schrieb Chouser:


If you have a lazy sequence with side-effects, you almost certainly
don't want to let it out of your sight.  You're likely to get very
strange behavior unless you're exceedingly careful.  Most likely, if
you've got a lazy seq with side effects you should force it with dorun
or doall immediately.  Use doall if you care about the values in the
produced seq, otherwise use dorun.

This means that dorun should almost always show up right next to the
form producing the lazy seq, which means doseq is very likely a better
choice, as it is more efficient and usually more succinct than dorun
combined with a lazy-seq producer.


What is the use case for dorun? It returns nil, so it can itself only
be called as a side-effect. From doall and dorun, only doall makes
sense to me. It is either called immediately

  (doall (map ...))

Or when giving the seq out of the hands:

  (with-some resource
...
(doall the-seq))

Why should there ever be the need to call dorun?

And by the way: the output of the following code doesn't lie.

  (let [the-seq (map #(* % 2) (range 100))]
(doseq [x the-seq]
  (println "Just produced:" x)))


'for' is in rather a different category, since unlike the others it
produces a lazy seq rather than forcing anything.  Use 'for' when it's
a more convenient way to express the lazy seq you want than the
equivalent combination of map, filter, take-while, etc.


I must confess, I almost never used for... Maybe I should
try to use it more often.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: Compiling problem.

2009-03-03 Thread Laurent PETIT
You cannot have both a classpath full of jars and directories (via the -cp
option) and run directly from a jar.

Try java -classpath .;src;classes;clojure.jar clojure.main" instead

(http://clojure.org/repl_and_main)

2009/3/3 zodoz 

>
> *sigh*...  Still no joy.  I've looked around for how to use the
> command and I finally got it to stop giving me directory permission
> errors, but Java still does not seem to be liking it.  I am now
> running it with "java -classpath .;src;classes -jar clojure.jar", but
> when I run (compile 'test) or (compile 'test.test) I still get
> "java.io.IOException: The system cannot find the path specified
> (test.clj:1)"...  Am I running the command java command wrong?
>
> P.S.  I tried the java command with "src" only and "." only as well.
>
> On Mar 3, 6:41 am, Mark Volkmann  wrote:
> > On Tue, Mar 3, 2009 at 12:58 AM, zodoz  wrote:
> >
> > > I'm just larning Clojure and have been able to figure out everything
> > > so far via trial-and-error.  However, I cannot for the LIFE of me
> > > figure out how to compile anything.  I have tried every possible setup
> > > I can think of and I all I have is a sneaking suspicion that its a
> > > Vista issue.
> >
> > > Below I have listed my setup to make this as complete a question as I
> > > can, however the error I am getting is "java.io.IOException: The
> > > system cannot find the path specified (test.clj:1)" so I don't expect
> > > the problem to be with how my filesystem is setup but rather with
> > > classpaths.  Any suggestions and thanks in advance?
> >
> > > I have a simple extraction of the latest files, inside the "clojure"
> > > folder I have renamed the orrigonal "src" folder to "srcb" so that I
> > > can single out only my code.  I have a test.clj file whose contents
> > > are (basically the example given on the main site):
> > > (ns test
> > >(:gen-class))
> >
> > > (defn -main
> > >[gre]
> > >(println (str "Hello " gre))
> >
> > > I have the following folder/file setup:
> > > clojure/
> > > ->clojure/classes
> > > ->clojure/src
> > > -->clojure/src/test
> > > --->clojure/src/test/test.clj
> > > -->clojure/src/test.clj
> > > ->clojure/test.clj
> >
> > > Each of these test.clj files have their own ns as either "test" or
> > > "test.test" depending on where they are in the filesystem.  The
> > > exception is the one in the clojure folder, this one I have tested it
> > > with both.
> >
> > The step-by-step instructions athttp://
> www.ociweb.com/mark/clojure/article.html#Compilingmight help,
> > especially step #8 related to setting the classpath.
> >
> > --
> > R. Mark Volkmann
> > Object Computing, Inc.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: So what do we want for a Cells-alike ?

2009-03-03 Thread Anand Patil



On Mar 3, 3:22 pm, Raffael Cavallaro 
wrote:
> On Mar 3, 8:04 am, Rich Hickey  wrote:
>
> >  If B and C depend on A in such
> > a way that their values must be coordinated in order to be valid and
> > consistent, then maybe they shouldn't independently depend on A,
> > instead a transaction should fire on changes to A, which in turn
> > updates B and C. Then any downstream consumers of B and C could never
> > see inconsistent values, all without a notion of 'current step'.
>
> Certainly you can and should hide the notion of current step for
> *most* purposes. Using transactions is certainly a good way to do it;
> but you must expose it in some way or you won't be able to express the
> full range of dataflow models.
>
> Typically:
>
> ;; pseudocode
>
> (defmodel my-model
>    (a :independent)
>    (b (fn [a] (+ (* a 12) 3)))
>    (c (fn [a] (+ a 7)))
>    (d (fn [c b] (* c d 3.2
>
> Here the step is implicit, as each reference to another cell in the
> functions above really means "the value of that cell at the *same*
> step/time/data pulse."  However:
>
> 1.  failing to deal with this issue in the *implementation* of a
> dataflow
> library leads to the wrong semantics; the absence of this notion or
> any other means of dealing with it, (such as a transaction as you
> suggest)
> commonly leads to bugs in cells-alikes, including at least one clojure
> implementation.
>
> 2. there are certain types of models where one needs to be able to
> refer to previous pulses/steps. These include reflexive update
> functions, (where the value of a cell depends on its own value at some
> previous step/time/pulse), and time lags. With these types of
> dependencies, there must be some way to explicitly refer to step or
> pulse:
>
> ;pseudocode with time lag
>
> ((defmodel my-model
>    (a :independent)
>    (b (fn [a] (previous a 3))) ;; i.e., how many steps back
>    (c (fn [a] (+ a 7)))
>    (d (fn [c d] (* c d 3.2
>
> You can certainly hide the most common case (i.e., everything is at
> the same
> step/pulse), but it has to be there internally or the semantics will
> be
> wrong, and it has to be exposed in some way or you won't be able to
> express many interesting types of models in a simple, direct way.

Laziness can work like a step counter, too. When you update a group of
the lazy cells in my previous post, you cause a single data pulse.
Cells don't update until all of their parents have reported in, ie
reached the current step.

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

2009-03-03 Thread zodoz

*sigh*...  Still no joy.  I've looked around for how to use the
command and I finally got it to stop giving me directory permission
errors, but Java still does not seem to be liking it.  I am now
running it with "java -classpath .;src;classes -jar clojure.jar", but
when I run (compile 'test) or (compile 'test.test) I still get
"java.io.IOException: The system cannot find the path specified
(test.clj:1)"...  Am I running the command java command wrong?

P.S.  I tried the java command with "src" only and "." only as well.

On Mar 3, 6:41 am, Mark Volkmann  wrote:
> On Tue, Mar 3, 2009 at 12:58 AM, zodoz  wrote:
>
> > I'm just larning Clojure and have been able to figure out everything
> > so far via trial-and-error.  However, I cannot for the LIFE of me
> > figure out how to compile anything.  I have tried every possible setup
> > I can think of and I all I have is a sneaking suspicion that its a
> > Vista issue.
>
> > Below I have listed my setup to make this as complete a question as I
> > can, however the error I am getting is "java.io.IOException: The
> > system cannot find the path specified (test.clj:1)" so I don't expect
> > the problem to be with how my filesystem is setup but rather with
> > classpaths.  Any suggestions and thanks in advance?
>
> > I have a simple extraction of the latest files, inside the "clojure"
> > folder I have renamed the orrigonal "src" folder to "srcb" so that I
> > can single out only my code.  I have a test.clj file whose contents
> > are (basically the example given on the main site):
> > (ns test
> >        (:gen-class))
>
> > (defn -main
> >        [gre]
> >        (println (str "Hello " gre))
>
> > I have the following folder/file setup:
> > clojure/
> > ->clojure/classes
> > ->clojure/src
> > -->clojure/src/test
> > --->clojure/src/test/test.clj
> > -->clojure/src/test.clj
> > ->clojure/test.clj
>
> > Each of these test.clj files have their own ns as either "test" or
> > "test.test" depending on where they are in the filesystem.  The
> > exception is the one in the clojure folder, this one I have tested it
> > with both.
>
> The step-by-step instructions 
> athttp://www.ociweb.com/mark/clojure/article.html#Compilingmight help,
> especially step #8 related to setting the classpath.
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: doall, dorun, doseq, for

2009-03-03 Thread Chouser

On Tue, Mar 3, 2009 at 10:03 AM, Mark Volkmann
 wrote:
>
> Does this seem like a good way to choose between doall, dorun, doseq
> and for to evaluate all the items in sequences?
>
> Ask these questions:
>
> Do you already have the lazy sequence in a variable or do you still
> need to build it?
> If you already have it, use dorun or doall. Otherwise use doseq or for.

If you have a lazy sequence with side-effects, you almost certainly
don't want to let it out of your sight.  You're likely to get very
strange behavior unless you're exceedingly careful.  Most likely, if
you've got a lazy seq with side effects you should force it with dorun
or doall immediately.  Use doall if you care about the values in the
produced seq, otherwise use dorun.

This means that dorun should almost always show up right next to the
form producing the lazy seq, which means doseq is very likely a better
choice, as it is more efficient and usually more succinct than dorun
combined with a lazy-seq producer.

'for' is in rather a different category, since unlike the others it
produces a lazy seq rather than forcing anything.  Use 'for' when it's
a more convenient way to express the lazy seq you want than the
equivalent combination of map, filter, take-while, etc.

--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
To unsubscribe from 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: doall, dorun, doseq, for - Debugging as a side effect?

2009-03-03 Thread Peter Wolf

RE: Side Effects

What about logging?   Without a debugger I use lots of print's to debug 
my code... and that often produces confusing results as things may not 
get evaluated in the order I expect.

For that matter, now that we have integrated Java debuggers, what does 
setting a breakpoint really mean?  And what does it imply about the 
state of all the variables outside the current scope?

How do others think about debugging lazy code?

P

Laurent PETIT wrote:
> 2009/3/3 Mark Volkmann  >
>
>
> On Tue, Mar 3, 2009 at 9:12 AM, Laurent PETIT
> mailto:laurent.pe...@gmail.com>> wrote:
> > Hello Mark,
> >
> > Just one point :
> >
> > 2009/3/3 Mark Volkmann  >
> >>
> >> Does this seem like a good way to choose between doall, dorun,
> doseq
> >> and for to evaluate all the items in sequences?
> >>
> >> Ask these questions:
> >>
> >> Do you already have the lazy sequence in a variable or do you still
> >> need to build it?
> >> If you already have it, use dorun or doall. Otherwise use doseq
> or for.
> >> While code inside a dorun or doall could build the sequence, using
> >> doseq and for are considered more idiomatic/readable.
> >> Also, they provide list comprehension features such as
> processing more
> >> than one sequence and filtering with :when/:while.
> >>
> >> For example, instead of using the following to get a new sequence
> >> where all the items are multiplied by two:
> >> (doall (map #(* % 2) my-coll))
> >> use this:
> >> (for [item my-coll] (* item 2))
> >
> > I don't think it is a good example, since it conveys the idea
> that it could
> > be interesting to use doall or for for mapping a coll to
> multiply its items.
> > This example, in which there is no side effect at all in the
> inner loop, is
> > really typical of the use of map ! And forcing the sequence
> there gives you
> > nothing (?)
> >
> > Maybe a more interesting example could be something that touches
> global
> > vars, or does IO, ... ?
>
> Very good point! With what I'm doing, simply multiplying items by two,
> you'd want the result to be an unevaluated, lazy sequence which is why
> map would be preferred.
>
> But supposing I was doing something like you suggested where I really
> do want to force the evaluation of all the items in the sequence, do
> my rules of thumb make sense?
>
>
> I haven't thought really hard about it, what it written seems correct 
> to me.
>
> But I think the first point is a little bit dangerous without a side 
> note : "if you already have the seq, then call 'doall or 'dorun on it".
> Indeed, if you're dealing with a seq that is passed around, you may 
> end up calling dorun or doall on the seq in several places in the 
> code, which may lead to problems if you have side effects in them !
> So to prevent this risk : either the call to 'doall or 'dorun is 
> factorized, and it will certainly be factorized near the place where 
> the seq is generated (thus almost falling back to your second case 
> "you don't have generated the seq yet"), either you haven't side 
> effects at all, and you fall back to an idiomatic use of 'map or 
> another lazy-seq generating function, without the need to call 'doall 
> or 'dorun on them.
>
> HTH,
>
> -- 
> Laurent
>  
>
>
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
>
>
>
>
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: So what do we want for a Cells-alike ?

2009-03-03 Thread Jeffrey Straszheim

I'm pretty sure I don't want an agent based model.  I want clear
transactional semantics.  However, there is no reason both should not
exist.


On Mar 3, 9:11 am, Anand Patil 
wrote:
> On Mar 3, 1:04 pm, Rich Hickey  wrote:
>
> > I think it is important to embrace asynchrony and concurrency as
> > Clojure does. Any Cells-for-Clojure that presumes the world is a
> > single synchronous chain of events would be a misfit. The whole notion
> > of a 'current step' is suspect.
>
> I'd appreciate it if my asynchronous lazy cells got a look, as I've
> given them a few revisions now. They're 
> athttp://github.com/onyin/lazy-agent/tree.
> They don't have any global counter, but the diamond pattern is no
> problem for them. As noted in an earlier thread, my def-cell macro is
> not as nice as it could be, but it wouldn't be hard for someone who is
> good at macros to write a quick wrapper.
>
> The readme:
>
> Implements two types of agent-based 'cells' for Clojure: lazy agents
> and oblivious agents. These complement the auto-agents available in
> Clojure Contrib. Both allow for concurrent cell updates with
> respectably efficient scheduling and avoid unnecessarily repeating
> cell updates.
>
> If you deref a lazy cell, you'll see a map: {:value xxx :status
> yyy}. :status may be :needs-update, :updating, :up-to-date
> or :oblivious. If a cell is up-to-date or oblivious, :value gives the
> value of the cell.
>
> When a lazy agent's ancestor changes, its value changes to {:value
> nil :status :needs-update} but it does not compute its new value until
> it receives a message instructing it to do so. To send the update
> message to a group of agents, do (update a b c d e). To send the
> update message and wait for the values, do (evaluate a b c d e).
>
> Oblivious agents are even lazier than lazy agents. When an oblivious
> agent is up-to-date, its status is :oblivious. If an ancestor
> subsequently changes, the oblivious agent will not do anything. It
> needs to receive a 'force-need-update' message to change state to
> {:value nil :status :needs-update}, but then it starts watching its
> parents for changes like a lazy agent until it computes.
>
> Anand
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: So what do we want for a Cells-alike ?

2009-03-03 Thread Jeffrey Straszheim

I've actually been looking at Rete.  However, for my present purposes
I want something that just does computation dependency graphs.  Rete
is way heavier than I'm currently thinking.

On Mar 3, 8:12 am, Rich Hickey  wrote:
> On Mar 2, 10:41 pm, Jeffrey Straszheim 
> wrote:
>
>
>
> > There are a lot of "toy" cells implementations for Clojure, but as far as I
> > can tell none of them are really full-production ready libraries like K.
> > Tilton's.  I'm planning on starting a GUI based project and something cell's
> > like would be very helpful.  I may end up building it myself, and am
> > wondering what the community thinks is the best direction.
>
> > I have some thoughts of my own.
>
> > First off, Clojure is not Common Lisp (to say the least), so I don't think
> > we necessarily need to create as stateful a library as the original Cells.
> > I've used Cells-like architectures before in GUI apps (although not as a
> > separate abstract library), and don't really think it is the best way.
>
> > I'm thinking of a more static, "rules engine-ey" approach, with a small set
> > of input data, a dataflow mechanism over some rules, with dependency
> > management, parallelism (when requested), and support for fixed-point
> > recursion. However, since I'd like whatever I come up with to be reused by
> > the community, I'm intererested in everyone's input.
>
> Rete?
>
> There's Drools, an interface to which might be a lot of fun. When last
> I looked into it, it seemed needlessly painful due to Drools'
> inability to treat maps as facts (they wanted JavaBeans). I'm not sure
> if that is still the case.
>
> Rich
>
> 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
To unsubscribe from 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: So what do we want for a Cells-alike ?

2009-03-03 Thread Jeffrey Straszheim

I've actually been looking at Rete.  However, for my present purposes
I want something that just does computation dependency graphs.  Rete
is way heavier than I'm currently thinking.

On Mar 3, 8:12 am, Rich Hickey  wrote:
> On Mar 2, 10:41 pm, Jeffrey Straszheim 
> wrote:
>
>
>
> > There are a lot of "toy" cells implementations for Clojure, but as far as I
> > can tell none of them are really full-production ready libraries like K.
> > Tilton's.  I'm planning on starting a GUI based project and something cell's
> > like would be very helpful.  I may end up building it myself, and am
> > wondering what the community thinks is the best direction.
>
> > I have some thoughts of my own.
>
> > First off, Clojure is not Common Lisp (to say the least), so I don't think
> > we necessarily need to create as stateful a library as the original Cells.
> > I've used Cells-like architectures before in GUI apps (although not as a
> > separate abstract library), and don't really think it is the best way.
>
> > I'm thinking of a more static, "rules engine-ey" approach, with a small set
> > of input data, a dataflow mechanism over some rules, with dependency
> > management, parallelism (when requested), and support for fixed-point
> > recursion. However, since I'd like whatever I come up with to be reused by
> > the community, I'm intererested in everyone's input.
>
> Rete?
>
> There's Drools, an interface to which might be a lot of fun. When last
> I looked into it, it seemed needlessly painful due to Drools'
> inability to treat maps as facts (they wanted JavaBeans). I'm not sure
> if that is still the case.
>
> Rich
>
> 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
To unsubscribe from 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: So what do we want for a Cells-alike ?

2009-03-03 Thread Jeffrey Straszheim

Access to the previous value is an interesting idea.  I'm thinking of
putting together a lib where all updates are collection into
transactions (which would run *inside* of Clojure transactions, but
would have their own semantics also).  Something like this:

(update-model
   (update x 3)
   (update y (+ (val y) 7)))

Where update-model is a macro that makes sure everything gets
recomputed before commit.  It would be pretty straightforward to keep
the previous value around.

On Mar 3, 10:22 am, Raffael Cavallaro 
wrote:
> On Mar 3, 8:04 am, Rich Hickey  wrote:
>
> >  If B and C depend on A in such
> > a way that their values must be coordinated in order to be valid and
> > consistent, then maybe they shouldn't independently depend on A,
> > instead a transaction should fire on changes to A, which in turn
> > updates B and C. Then any downstream consumers of B and C could never
> > see inconsistent values, all without a notion of 'current step'.
>
> Certainly you can and should hide the notion of current step for
> *most* purposes. Using transactions is certainly a good way to do it;
> but you must expose it in some way or you won't be able to express the
> full range of dataflow models.
>
> Typically:
>
> ;; pseudocode
>
> (defmodel my-model
>(a :independent)
>(b (fn [a] (+ (* a 12) 3)))
>(c (fn [a] (+ a 7)))
>(d (fn [c b] (* c d 3.2
>
> Here the step is implicit, as each reference to another cell in the
> functions above really means "the value of that cell at the *same*
> step/time/data pulse."  However:
>
> 1.  failing to deal with this issue in the *implementation* of a
> dataflow
> library leads to the wrong semantics; the absence of this notion or
> any other means of dealing with it, (such as a transaction as you
> suggest)
> commonly leads to bugs in cells-alikes, including at least one clojure
> implementation.
>
> 2. there are certain types of models where one needs to be able to
> refer to previous pulses/steps. These include reflexive update
> functions, (where the value of a cell depends on its own value at some
> previous step/time/pulse), and time lags. With these types of
> dependencies, there must be some way to explicitly refer to step or
> pulse:
>
> ;pseudocode with time lag
>
> ((defmodel my-model
>(a :independent)
>(b (fn [a] (previous a 3))) ;; i.e., how many steps back
>(c (fn [a] (+ a 7)))
>(d (fn [c d] (* c d 3.2
>
> You can certainly hide the most common case (i.e., everything is at
> the same
> step/pulse), but it has to be there internally or the semantics will
> be
> wrong, and it has to be exposed in some way or you won't be able to
> express many interesting types of models in a simple, direct 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
To unsubscribe from 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: doall, dorun, doseq, for

2009-03-03 Thread Laurent PETIT
2009/3/3 Mark Volkmann 

>
> On Tue, Mar 3, 2009 at 9:12 AM, Laurent PETIT 
> wrote:
> > Hello Mark,
> >
> > Just one point :
> >
> > 2009/3/3 Mark Volkmann 
> >>
> >> Does this seem like a good way to choose between doall, dorun, doseq
> >> and for to evaluate all the items in sequences?
> >>
> >> Ask these questions:
> >>
> >> Do you already have the lazy sequence in a variable or do you still
> >> need to build it?
> >> If you already have it, use dorun or doall. Otherwise use doseq or for.
> >> While code inside a dorun or doall could build the sequence, using
> >> doseq and for are considered more idiomatic/readable.
> >> Also, they provide list comprehension features such as processing more
> >> than one sequence and filtering with :when/:while.
> >>
> >> For example, instead of using the following to get a new sequence
> >> where all the items are multiplied by two:
> >> (doall (map #(* % 2) my-coll))
> >> use this:
> >> (for [item my-coll] (* item 2))
> >
> > I don't think it is a good example, since it conveys the idea that it
> could
> > be interesting to use doall or for for mapping a coll to multiply its
> items.
> > This example, in which there is no side effect at all in the inner loop,
> is
> > really typical of the use of map ! And forcing the sequence there gives
> you
> > nothing (?)
> >
> > Maybe a more interesting example could be something that touches global
> > vars, or does IO, ... ?
>
> Very good point! With what I'm doing, simply multiplying items by two,
> you'd want the result to be an unevaluated, lazy sequence which is why
> map would be preferred.
>
> But supposing I was doing something like you suggested where I really
> do want to force the evaluation of all the items in the sequence, do
> my rules of thumb make sense?


I haven't thought really hard about it, what it written seems correct to me.

But I think the first point is a little bit dangerous without a side note :
"if you already have the seq, then call 'doall or 'dorun on it".
Indeed, if you're dealing with a seq that is passed around, you may end up
calling dorun or doall on the seq in several places in the code, which may
lead to problems if you have side effects in them !
So to prevent this risk : either the call to 'doall or 'dorun is factorized,
and it will certainly be factorized near the place where the seq is
generated (thus almost falling back to your second case "you don't have
generated the seq yet"), either you haven't side effects at all, and you
fall back to an idiomatic use of 'map or another lazy-seq generating
function, without the need to call 'doall or 'dorun on them.

HTH,

-- 
Laurent


>
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: So what do we want for a Cells-alike ?

2009-03-03 Thread Raffael Cavallaro



On Mar 3, 8:04 am, Rich Hickey  wrote:

>  If B and C depend on A in such
> a way that their values must be coordinated in order to be valid and
> consistent, then maybe they shouldn't independently depend on A,
> instead a transaction should fire on changes to A, which in turn
> updates B and C. Then any downstream consumers of B and C could never
> see inconsistent values, all without a notion of 'current step'.

Certainly you can and should hide the notion of current step for
*most* purposes. Using transactions is certainly a good way to do it;
but you must expose it in some way or you won't be able to express the
full range of dataflow models.

Typically:

;; pseudocode

(defmodel my-model
   (a :independent)
   (b (fn [a] (+ (* a 12) 3)))
   (c (fn [a] (+ a 7)))
   (d (fn [c b] (* c d 3.2

Here the step is implicit, as each reference to another cell in the
functions above really means "the value of that cell at the *same*
step/time/data pulse."  However:

1.  failing to deal with this issue in the *implementation* of a
dataflow
library leads to the wrong semantics; the absence of this notion or
any other means of dealing with it, (such as a transaction as you
suggest)
commonly leads to bugs in cells-alikes, including at least one clojure
implementation.

2. there are certain types of models where one needs to be able to
refer to previous pulses/steps. These include reflexive update
functions, (where the value of a cell depends on its own value at some
previous step/time/pulse), and time lags. With these types of
dependencies, there must be some way to explicitly refer to step or
pulse:

;pseudocode with time lag

((defmodel my-model
   (a :independent)
   (b (fn [a] (previous a 3))) ;; i.e., how many steps back
   (c (fn [a] (+ a 7)))
   (d (fn [c d] (* c d 3.2

You can certainly hide the most common case (i.e., everything is at
the same
step/pulse), but it has to be there internally or the semantics will
be
wrong, and it has to be exposed in some way or you won't be able to
express many interesting types of models in a simple, direct 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
To unsubscribe from 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: doall, dorun, doseq, for

2009-03-03 Thread Mark Volkmann

On Tue, Mar 3, 2009 at 9:12 AM, Laurent PETIT  wrote:
> Hello Mark,
>
> Just one point :
>
> 2009/3/3 Mark Volkmann 
>>
>> Does this seem like a good way to choose between doall, dorun, doseq
>> and for to evaluate all the items in sequences?
>>
>> Ask these questions:
>>
>> Do you already have the lazy sequence in a variable or do you still
>> need to build it?
>> If you already have it, use dorun or doall. Otherwise use doseq or for.
>> While code inside a dorun or doall could build the sequence, using
>> doseq and for are considered more idiomatic/readable.
>> Also, they provide list comprehension features such as processing more
>> than one sequence and filtering with :when/:while.
>>
>> For example, instead of using the following to get a new sequence
>> where all the items are multiplied by two:
>> (doall (map #(* % 2) my-coll))
>> use this:
>> (for [item my-coll] (* item 2))
>
> I don't think it is a good example, since it conveys the idea that it could
> be interesting to use doall or for for mapping a coll to multiply its items.
> This example, in which there is no side effect at all in the inner loop, is
> really typical of the use of map ! And forcing the sequence there gives you
> nothing (?)
>
> Maybe a more interesting example could be something that touches global
> vars, or does IO, ... ?

Very good point! With what I'm doing, simply multiplying items by two,
you'd want the result to be an unevaluated, lazy sequence which is why
map would be preferred.

But supposing I was doing something like you suggested where I really
do want to force the evaluation of all the items in the sequence, do
my rules of thumb make sense?

-- 
R. Mark Volkmann
Object Computing, Inc.

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

2009-03-03 Thread Laurent PETIT
Hello Mark,

Just one point :

2009/3/3 Mark Volkmann 

>
> Does this seem like a good way to choose between doall, dorun, doseq
> and for to evaluate all the items in sequences?
>
> Ask these questions:
>
> Do you already have the lazy sequence in a variable or do you still
> need to build it?
> If you already have it, use dorun or doall. Otherwise use doseq or for.
> While code inside a dorun or doall could build the sequence, using
> doseq and for are considered more idiomatic/readable.
> Also, they provide list comprehension features such as processing more
> than one sequence and filtering with :when/:while.
>
> For example, instead of using the following to get a new sequence
> where all the items are multiplied by two:
> (doall (map #(* % 2) my-coll))
> use this:
> (for [item my-coll] (* item 2))


I don't think it is a good example, since it conveys the idea that it could
be interesting to use doall or for for mapping a coll to multiply its items.
This example, in which there is no side effect at all in the inner loop, is
really typical of the use of map ! And forcing the sequence there gives you
nothing (?)

Maybe a more interesting example could be something that touches global
vars, or does IO, ... ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



doall, dorun, doseq, for

2009-03-03 Thread Mark Volkmann

Does this seem like a good way to choose between doall, dorun, doseq
and for to evaluate all the items in sequences?

Ask these questions:

Do you already have the lazy sequence in a variable or do you still
need to build it?
If you already have it, use dorun or doall. Otherwise use doseq or for.
While code inside a dorun or doall could build the sequence, using
doseq and for are considered more idiomatic/readable.
Also, they provide list comprehension features such as processing more
than one sequence and filtering with :when/:while.

For example, instead of using the following to get a new sequence
where all the items are multiplied by two:
(doall (map #(* % 2) my-coll))
use this:
(for [item my-coll] (* item 2))

Are you only interested in side effects of the evaluations or do you
need to retain the results?
If you only need side effects, use dorun or doseq. If you need the
results, use doall or for.

-- 
R. Mark Volkmann
Object Computing, Inc.

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

2009-03-03 Thread Chouser

On Tue, Mar 3, 2009 at 6:40 AM, David Sletten  wrote:
>
> I'd appreciate any feedback regarding my Clojure style. Any more
> natural ways to do things?

Looks good, thanks for sharing.

> (defn roman? [roman-string]
>   (and (not (empty? roman-string))
>        (re-matches
>         #"(?:M{0,3})(?:D?C{0,3}|C[DM])(?:L?X{0,3}|X[LC])(?:V?I{0,3}|I
> [VX])$"
>         roman-string)))

The normal idiom in Clojure is (seq x) instead of (not (empty? x)),
and that works fine for Strings.  Also, since you don't really need
the specific return value of the test expressions, 'when' might be a
better choice than 'and'.

> (defn roman-to-arabic-aux [roman-string]
>   (cond (empty? roman-string) 0
>         (empty? (rest roman-string)) (value (first roman-string))
>         (< (value (first roman-string)) (value (second roman-string)))
>         (- (roman-to-arabic-aux (rest roman-string))
>            (value (first roman-string)))
>         :else
>         (+ (value (first roman-string))
>            (roman-to-arabic-aux (rest roman-string)

To reduce the clutter here, you might consider using destructuring on
roman-string to get locals for the  first and rest parts:

user=> (let [[a & b] "fie"] [a b])
[\f (\i \e)]

You also might consider indenting the result expressions to help them
stand out more.  I like either:

(cond
  test1 (expr-fn
  arg1 arg2)
  test2 (expr-fn2
  argA argB))

or:

(cond
  test1
(expr-fn arg1 arg2)
  test2
(expr-fn2 argA argB))

> (def arabic-values '((1000 "M") (900 "CM") (500 "D") (400 "CD")
>                      (100 "C") (90 "XC") (50 "L") (40 "XL")
>                      (10 "X") (9 "IX") (5 "V") (4 "IV") (1 "I")))

You might consider using a vector of vectors here.  There's nothing
particularly wrong with what you've got, but I've been noticing
recently that almost every list you expressed directly in idiomatic
Clojure code is a function or macro call.  I think this is part of why
I've found Clojure code to be less difficult to read than CL.

It doesn't matter much in this case as the quote is clearly visible
and the literal numbers aren't likely to be confused with function
calls, but I thought I'd mention it anyway.

> (defn arabic-to-roman
>   ([n] (if (<= 1 n 3999)
>          (apply str (arabic-to-roman n arabic-values))
>          (format "%d cannot be converted." n)))
>   ([n num-list] (cond (empty? num-list) '()
>                       (zero? n) '()
>                       :else (let [[[arabic roman] & tail] num-list]
>                               (if (>= n arabic)
>                                 (cons roman (arabic-to-roman (- n
> arabic)
>                                                              num-list))
>                                 (arabic-to-roman n tail ))

You might consider using 'reduce' instead of recursion here.
Alternatively, it's interesting to note that because of the ease with
which you're destructuring arabic-values, it would be no more
difficult if you had a single list (or vector) of alternating numbers
and strings rather than nesting them.

--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
To unsubscribe from 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: emacs / swank / slime startup problem - ClassNotFoundException: swank.swank

2009-03-03 Thread Bradbev

On Mar 3, 4:46 am, Korny Sietsma  wrote:
> Hi folks;
>
> I have an intermittent problem that's driving me nuts.
> I'm running the emacs-starter-kit setup for editing clojure, recently
> updated from git, and when I first run "M-x slime", I often get the
> following messages:
> user=> user=> java.lang.IllegalArgumentException: URI has an authority
> component (NO_SOURCE_FILE:0)
> user=> user=> java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:9)
> user=> user=> java.lang.ClassNotFoundException: swank.swank 
> (NO_SOURCE_FILE:11)
>
> I then get a continual message of the form:
> Polling "/var/folders/9h/9h261S2vGcakoICm25U72k+++TI/-Tmp-/slime.21452"..
> (Abort with `M-x slime-abort-connection'.)
>
> ... and I have to abort.
> However, sometimes, generally when I've started trying to fiddle
> around with inserting println statements in the swank code, I run
> 'slime' again - and everything is good!
> Well, I still seem to get the
>    java.lang.IllegalArgumentException: URI has an authority component
> (NO_SOURCE_FILE:0)
> message, but slime/swank/clojure all seem to work.
>
> Any thoughts? Any ideas where to look?
> Note this is with MacPorts emacs Version 23.0.0 (NS 9.0-rc3)
>
> - Korny
> --
> Kornelis Sietsma  korny at my surname dot com
> kornys on gmail, twitter, facebook, etc.
> "Every jumbled pile of person has a thinking part
> that wonders what the part that isn't thinking
> isn't thinking of"
I got this when upgrading to the lazy branch.  I never figured out
what the actual problem is, but setting swank-clojure-compile-p (in
swank-clojure.el) to nil fixed it.
I use Aquamacs.

Cheers,
Brad
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Waterfront 148 (was: Waterfront - The Clojure-based editor for Clojure)

2009-03-03 Thread Konrad Hinsen

On Mar 3, 2009, at 11:46, Tom Ayerst wrote:

> If you pull trunk out of subversion you can build it locally with  
> Ant.  Would that do it?

Definitely, thanks!  I pulled the latest revision and built it by  
typing "ant". No compilation errors, but I can't run it either:

Can't load plugin custom-editor.clj. Reason:  
java.lang.ClassNotFoundException:  
javax.swing.filechooser.FileNameExtensionFilter (file.clj:171)
Can't load plugin context-menu.clj. Reason: nil
Can't load plugin file.clj. Reason: java.lang.ClassNotFoundException:  
javax.swing.filechooser.FileNameExtensionFilter (file.clj:171)
Can't load plugin problem-window.clj. Reason: nil
Can't load plugin undo.clj. Reason: java.lang.Exception: LazySeq used  
in 'if' (lexer.clj:0)
Can't load plugin comments.clj. Reason: java.lang.Exception: Unable  
to resolve symbol: create-undo-transaction in this context  
(comments.clj:48)
Can't load plugin line-column.clj. Reason: nil
Can't load plugin find.clj. Reason: java.lang.Exception: Unable to  
resolve symbol: create-undo-transaction in this context (find.clj:117)
Can't load plugin indicator.clj. Reason: nil
Can't load plugin output-window.clj. Reason: nil
Can't load plugin check-syntax.clj. Reason: java.lang.Exception:  
LazySeq used in 'if' (lexer.clj:0)
Can't load plugin indent.clj. Reason: java.lang.Exception: Unable to  
resolve symbol: create-undo-transaction in this context (indent.clj:125)
Can't load plugin paren-matching.clj. Reason: java.lang.Exception:  
LazySeq used in 'if' (lexer.clj:0)
Can't load plugin eval-as-you-type.clj. Reason: java.lang.Exception:  
LazySeq used in 'if' (lexer.clj:0)
java.lang.NullPointerException
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:26)
at net.sourceforge.waterfront.ide.plugins$set_font__1700.invoke(font- 
observer.clj:20)
at net.sourceforge.waterfront.ide.plugins$set_fonts__1703.invoke 
(font-observer.clj:26)
at net.sourceforge.waterfront.ide$dispatcher__550$fn__554.invoke 
(ui.clj:85)
...

It looks as if my installation lacks parts of Swing, but there also  
seem to be some lazy-seq-related bugs in Waterfront itself (my  
Clojure is compiled with clojure.assert-if-lazy-seq=true).

Is anyone running Waterfront successfully on a Mac with Java 1.5?

Konrad.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: So what do we want for a Cells-alike ?

2009-03-03 Thread Anand Patil

On Mar 3, 1:04 pm, Rich Hickey  wrote:
> I think it is important to embrace asynchrony and concurrency as
> Clojure does. Any Cells-for-Clojure that presumes the world is a
> single synchronous chain of events would be a misfit. The whole notion
> of a 'current step' is suspect.

I'd appreciate it if my asynchronous lazy cells got a look, as I've
given them a few revisions now. They're at 
http://github.com/onyin/lazy-agent/tree.
They don't have any global counter, but the diamond pattern is no
problem for them. As noted in an earlier thread, my def-cell macro is
not as nice as it could be, but it wouldn't be hard for someone who is
good at macros to write a quick wrapper.

The readme:

Implements two types of agent-based 'cells' for Clojure: lazy agents
and oblivious agents. These complement the auto-agents available in
Clojure Contrib. Both allow for concurrent cell updates with
respectably efficient scheduling and avoid unnecessarily repeating
cell updates.

If you deref a lazy cell, you'll see a map: {:value xxx :status
yyy}. :status may be :needs-update, :updating, :up-to-date
or :oblivious. If a cell is up-to-date or oblivious, :value gives the
value of the cell.

When a lazy agent's ancestor changes, its value changes to {:value
nil :status :needs-update} but it does not compute its new value until
it receives a message instructing it to do so. To send the update
message to a group of agents, do (update a b c d e). To send the
update message and wait for the values, do (evaluate a b c d e).

Oblivious agents are even lazier than lazy agents. When an oblivious
agent is up-to-date, its status is :oblivious. If an ancestor
subsequently changes, the oblivious agent will not do anything. It
needs to receive a 'force-need-update' message to change state to
{:value nil :status :needs-update}, but then it starts watching its
parents for changes like a lazy agent until it computes.

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

2009-03-03 Thread MikeM

>
> The only function I could find that takes a vector and returns a list
> instead of a vector or a sequence is the reverse function. Are there
> others?

Map and other lazy functions currently return a LazySeq -

(map #(+ %) [1 2 3]) => (2 3 4)

cons currently returns a Cons type -

(cons 0 [1 2 3]) => (0 1 2 3)

I refered to list types in the previous note, such as LazySeq and
Cons. I'm not suggesting your article discuss these specific types
that are returned by certain functions, but rather that some core
functions when provided a vector will return a type that does not have
the same performance characteristics as a vector.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: So what do we want for a Cells-alike ?

2009-03-03 Thread Rich Hickey



On Mar 2, 10:41 pm, Jeffrey Straszheim 
wrote:
> There are a lot of "toy" cells implementations for Clojure, but as far as I
> can tell none of them are really full-production ready libraries like K.
> Tilton's.  I'm planning on starting a GUI based project and something cell's
> like would be very helpful.  I may end up building it myself, and am
> wondering what the community thinks is the best direction.
>
> I have some thoughts of my own.
>
> First off, Clojure is not Common Lisp (to say the least), so I don't think
> we necessarily need to create as stateful a library as the original Cells.
> I've used Cells-like architectures before in GUI apps (although not as a
> separate abstract library), and don't really think it is the best way.
>
> I'm thinking of a more static, "rules engine-ey" approach, with a small set
> of input data, a dataflow mechanism over some rules, with dependency
> management, parallelism (when requested), and support for fixed-point
> recursion. However, since I'd like whatever I come up with to be reused by
> the community, I'm intererested in everyone's input.

Rete?

There's Drools, an interface to which might be a lot of fun. When last
I looked into it, it seemed needlessly painful due to Drools'
inability to treat maps as facts (they wanted JavaBeans). I'm not sure
if that is still the case.

Rich


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
To unsubscribe from 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: So what do we want for a Cells-alike ?

2009-03-03 Thread Rich Hickey



On Mar 3, 1:58 am, Raffael Cavallaro 
wrote:
> On Mar 2, 10:41 pm, Jeffrey Straszheim 
> wrote:
>
> > First off, Clojure is not Common Lisp (to say the least), so I don't think
> > we necessarily need to create as stateful a library as the original Cells.
> > I've used Cells-like architectures before in GUI apps (although not as a
> > separate abstract library), and don't really think it is the best way.
>
> I can certainly imagine a functional interface such that any "cell"
> will
> return a value that is a function of time (or step) and other cell(s)
> at
> the same time/step:
>
> (value-at-step d 1000) = (d-func (value-at-step c 1000) (value-at-step
> b 1000))
>
> its crucial that all the other cells any cell depends on be at the
> same step
> as the step we're trying to compute before we do the computation or
> we end up with multiple updates for the same time/step in certain
> dependency graphs. IOW simply making one cell's value a function
> of the value of some other cell(s) and *not* also a function of step/
> time
> loses for certain dependency graphs.
>
> The "diamond" pattern is the classic example:
>
> a is independent (or draws its value from GUI input, etc.)
> b and c both depend on a
> d depends on b and c.
>
>   a
>  / \
> b  c
>  \ /
>   d
> If we don't check the time/step/version of both b and c when a change
> to either triggers an update to d, we end up updating d twice, once
> with a broken value where only one of b or c is at the current step,
> and a second time with the correct value.
>
> I mention this because one the clojure cells-alikes  had/has this bug.
>
> A functional interface to this sort of library would need to be
> stateful
> under the covers in order to avoid lots of recomputation with long
> dependency chains. Memoization is one simple means - memoize
> is in clojure already, and you could keep a functional
> interface while avoiding unnecessary recomputation of past state
> transitions.

I think it is important to embrace asynchrony and concurrency as
Clojure does. Any Cells-for-Clojure that presumes the world is a
single synchronous chain of events would be a misfit. The whole notion
of a 'current step' is suspect.

You have watches on all of the reference types. They all have
concurrency and coordination semantics. If B and C depend on A in such
a way that their values must be coordinated in order to be valid and
consistent, then maybe they shouldn't independently depend on A,
instead a transaction should fire on changes to A, which in turn
updates B and C. Then any downstream consumers of B and C could never
see inconsistent values, all without a notion of 'current step'.

An concurrent alternative to a master 'current step' notion for recalc/
already-seen/reconciliation etc would be something like vector clocks.

I know designing a multithreaded Cells is more challenging than a
single-threaded one, but the benefits are likely to be abundant. Much
of the plumbing already exists in Clojure + Java's concurrent queues.

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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



emacs / swank / slime startup problem - ClassNotFoundException: swank.swank

2009-03-03 Thread Korny Sietsma

Hi folks;

I have an intermittent problem that's driving me nuts.
I'm running the emacs-starter-kit setup for editing clojure, recently
updated from git, and when I first run "M-x slime", I often get the
following messages:
user=> user=> java.lang.IllegalArgumentException: URI has an authority
component (NO_SOURCE_FILE:0)
user=> user=> java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:9)
user=> user=> java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:11)

I then get a continual message of the form:
Polling "/var/folders/9h/9h261S2vGcakoICm25U72k+++TI/-Tmp-/slime.21452"..
(Abort with `M-x slime-abort-connection'.)

... and I have to abort.
However, sometimes, generally when I've started trying to fiddle
around with inserting println statements in the swank code, I run
'slime' again - and everything is good!
Well, I still seem to get the
   java.lang.IllegalArgumentException: URI has an authority component
(NO_SOURCE_FILE:0)
message, but slime/swank/clojure all seem to work.

Any thoughts? Any ideas where to look?
Note this is with MacPorts emacs Version 23.0.0 (NS 9.0-rc3)

- Korny
-- 
Kornelis Sietsma  korny at my surname dot com
kornys on gmail, twitter, facebook, etc.
"Every jumbled pile of person has a thinking part
that wonders what the part that isn't thinking
isn't thinking of"

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

2009-03-03 Thread Mark Volkmann

On Tue, Mar 3, 2009 at 12:58 AM, zodoz  wrote:
>
> I'm just larning Clojure and have been able to figure out everything
> so far via trial-and-error.  However, I cannot for the LIFE of me
> figure out how to compile anything.  I have tried every possible setup
> I can think of and I all I have is a sneaking suspicion that its a
> Vista issue.
>
> Below I have listed my setup to make this as complete a question as I
> can, however the error I am getting is "java.io.IOException: The
> system cannot find the path specified (test.clj:1)" so I don't expect
> the problem to be with how my filesystem is setup but rather with
> classpaths.  Any suggestions and thanks in advance?
>
> I have a simple extraction of the latest files, inside the "clojure"
> folder I have renamed the orrigonal "src" folder to "srcb" so that I
> can single out only my code.  I have a test.clj file whose contents
> are (basically the example given on the main site):
> (ns test
>        (:gen-class))
>
> (defn -main
>        [gre]
>        (println (str "Hello " gre))
>
> I have the following folder/file setup:
> clojure/
> ->clojure/classes
> ->clojure/src
> -->clojure/src/test
> --->clojure/src/test/test.clj
> -->clojure/src/test.clj
> ->clojure/test.clj
>
> Each of these test.clj files have their own ns as either "test" or
> "test.test" depending on where they are in the filesystem.  The
> exception is the one in the clojure folder, this one I have tested it
> with both.

The step-by-step instructions at
http://www.ociweb.com/mark/clojure/article.html#Compiling might help,
especially step #8 related to setting the classpath.

-- 
R. Mark Volkmann
Object Computing, Inc.

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

2009-03-03 Thread Mark Volkmann

On Mon, Mar 2, 2009 at 8:45 PM, MikeM  wrote:
>
>> At the end of the Vectors section I say this:
>> "All the code examples provided above for lists also work for vectors."
>>
>> Do you think I should provide more detail than that?
>
> I missed that sentence. I think it's helpful to know that some
> functions return a list type when given a vector, others will maintain
> the vector type. This can be important for performance of subsequent
> operations.

The only function I could find that takes a vector and returns a list
instead of a vector or a sequence is the reverse function. Are there
others?

>> > Also, you mention that vectors are "not efficient when new items need
>> > to be added or removed quickly", but subvec should perhaps be
>> > mentioned as an exception.
>>
>> Can you elaborate on that? You might be teaching me something new.
>>
> If I understand correctly, subvec creates a new object that shares
> elements with the original vector with no copying.

subvec can't be used to remove items from the middle of a vector.
That's what I was going for even though I didn't state it very
clearly. The latest version of the article says the following about
vectors: "They are ideal when new items will be added to or removed
from the back (constant-time). They are efficient (constant time) for
finding (using nth) or changing (using assoc) items by index."

I added a sentence to the discussion about subvec to say that it
shares structure with the original.

-- 
R. Mark Volkmann
Object Computing, Inc.

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

2009-03-03 Thread Mark Volkmann

On Tue, Mar 3, 2009 at 6:22 AM, Rich Hickey  wrote:
>
> On Mar 2, 8:40 pm, Mark Volkmann  wrote:
>> On Mon, Mar 2, 2009 at 7:05 PM, Chouser  wrote:
>>
>> > On Mon, Mar 2, 2009 at 7:53 PM, Mark Volkmann  
>> > wrote:
>>
>> >> Currently what the article says about Vectors is "They are ideal when
>> >> items need to be retrieved by index, but not efficient when new items
>> >> need to be added or removed quickly." It doesn't distinguish between
>> >> the working in the middle or at the ends. It sounds like it should.
>>
>> >> Is it true that lists are more efficient than vectors when items need
>> >> to be added and removed from the middle? My goal is to say something
>> >> to help developers choose between using a list or a vector based on
>> >> the circumstances.
>>
>> > Lists provide the constant time add/remove at the front, while vectors
>> > provide essentially the same for the back.  Seqs always walk from
>> > front to back.  This is often sufficient information to choose between
>> > them.
>>
>> > Vectors provide essentially constant-time lookup by index (nth), while
>> > lists provide only linear-time lookup by index.
>>
>> > Lists provide no convenient or efficient mechanism for "changing" a
>> > value in the middle, while vectors provide essentially constant-time
>> > 'assoc' for any existing position.
>>
>> Thanks! It sounds like I was mistaken in thinking that the
>> implementation of Clojure lists was somewhat similar to
>> java.util.LinkedList and the implementation of Clojure vectors was
>> somewhat similar to java.util.ArrayList. I'll change the article to
>> say something similar to your feedback above.
>>
>
> Sounds like you might still be confused, as vectors do have
> characteristics very much like ArrayLists, sans mutability.

Currently the "Vectors" section starts like this:

"Vectors are also ordered collections of items. They are ideal when
new items will be added to or removed from the back (constant-time).
They are efficient (constant time) for finding (using nth) or changing
(using assoc) items by index."

I think it's that last sentence that hints at their similarity to
ArrayLists. The beginning of the "Collections" section explains that
all the Clojure collections are immutable. Do you recommend that I say
something stronger about the similarity between vectors and ArrayLists
or is it okay now?

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Compiling problem.

2009-03-03 Thread zodoz

I'm just larning Clojure and have been able to figure out everything
so far via trial-and-error.  However, I cannot for the LIFE of me
figure out how to compile anything.  I have tried every possible setup
I can think of and I all I have is a sneaking suspicion that its a
Vista issue.

Below I have listed my setup to make this as complete a question as I
can, however the error I am getting is "java.io.IOException: The
system cannot find the path specified (test.clj:1)" so I don't expect
the problem to be with how my filesystem is setup but rather with
classpaths.  Any suggestions and thanks in advance?

I have a simple extraction of the latest files, inside the "clojure"
folder I have renamed the orrigonal "src" folder to "srcb" so that I
can single out only my code.  I have a test.clj file whose contents
are (basically the example given on the main site):
(ns test
(:gen-class))

(defn -main
[gre]
(println (str "Hello " gre))

I have the following folder/file setup:
clojure/
->clojure/classes
->clojure/src
-->clojure/src/test
--->clojure/src/test/test.clj
-->clojure/src/test.clj
->clojure/test.clj

Each of these test.clj files have their own ns as either "test" or
"test.test" depending on where they are in the filesystem.  The
exception is the one in the clojure folder, this one I have tested it
with both.


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

2009-03-03 Thread Rich Hickey



On Mar 2, 8:40 pm, Mark Volkmann  wrote:
> On Mon, Mar 2, 2009 at 7:05 PM, Chouser  wrote:
>
> > On Mon, Mar 2, 2009 at 7:53 PM, Mark Volkmann  
> > wrote:
>
> >> Currently what the article says about Vectors is "They are ideal when
> >> items need to be retrieved by index, but not efficient when new items
> >> need to be added or removed quickly." It doesn't distinguish between
> >> the working in the middle or at the ends. It sounds like it should.
>
> >> Is it true that lists are more efficient than vectors when items need
> >> to be added and removed from the middle? My goal is to say something
> >> to help developers choose between using a list or a vector based on
> >> the circumstances.
>
> > Lists provide the constant time add/remove at the front, while vectors
> > provide essentially the same for the back.  Seqs always walk from
> > front to back.  This is often sufficient information to choose between
> > them.
>
> > Vectors provide essentially constant-time lookup by index (nth), while
> > lists provide only linear-time lookup by index.
>
> > Lists provide no convenient or efficient mechanism for "changing" a
> > value in the middle, while vectors provide essentially constant-time
> > 'assoc' for any existing position.
>
> Thanks! It sounds like I was mistaken in thinking that the
> implementation of Clojure lists was somewhat similar to
> java.util.LinkedList and the implementation of Clojure vectors was
> somewhat similar to java.util.ArrayList. I'll change the article to
> say something similar to your feedback above.
>

Sounds like you might still be confused, as vectors do have
characteristics very much like ArrayLists, sans mutability.

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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Roman Numerals

2009-03-03 Thread David Sletten

Here's a little toy to practice my basic Clojure skills. I didn't see  
any similar topic in the archives, so here we go...

This code performs conversions between Roman and Arabic numerals.  
Roman numerals are represented as strings and Arabic numerals are  
just integers. Arabic numerals in the range of 1 and 3999 inclusive  
are allowed. Conventionally, 3999 is the upper limit since the Roman  
numeral for 5000 (a V with a bar over it) cannot be represented in  
ASCII (although it exists in Unicode).

The function roman-to-arabic-aux correctly converts any valid Roman  
numeral. This can be exhaustively tested by comparing the Roman  
numeral output of Common Lisp's FORMAT function for example (e.g.,  
(format nil "~...@r" n)). The trick, however, is weeding out bogus  
strings representing invalid Roman numerals such as IVI, IXV, etc...  
For this purpose the function "roman?" uses a regular expression I  
cribbed from Perl's CPAN module Roman.pm (http://search.cpan.org/ 
~chorny/Roman-1.23/lib/Roman.pm).

arabic-to-roman performs the obvious conversion in the other direction.

Incidentally, the "cond" form in roman-to-arabic-aux seems to me  
harder to read in Clojure than it would be in CL with its additional  
set of grouping parentheses. When you can't fit both the predicate  
and the consequent expression on the same line it gets confusing.

I'd appreciate any feedback regarding my Clojure style. Any more  
natural ways to do things?

Aloha,
David Sletten

(def roman-values-map {\I 1 \V 5 \X 10 \L 50 \C 100 \D 500 \M 1000})

(defn value [roman]
   (get roman-values-map (Character/toUpperCase roman)))

(defn roman? [roman-string]
   (and (not (empty? roman-string))
(re-matches
 #"(?:M{0,3})(?:D?C{0,3}|C[DM])(?:L?X{0,3}|X[LC])(?:V?I{0,3}|I 
[VX])$"
 roman-string)))

(defn roman-to-arabic-aux [roman-string]
   (cond (empty? roman-string) 0
 (empty? (rest roman-string)) (value (first roman-string))
 (< (value (first roman-string)) (value (second roman-string)))
 (- (roman-to-arabic-aux (rest roman-string))
(value (first roman-string)))
 :else
 (+ (value (first roman-string))
(roman-to-arabic-aux (rest roman-string)

(defn roman-to-arabic [roman-string]
   (if (roman? roman-string)
 (roman-to-arabic-aux roman-string)
 (format "'%s' is not a valid Roman numeral." roman-string)))

(def arabic-values '((1000 "M") (900 "CM") (500 "D") (400 "CD")
  (100 "C") (90 "XC") (50 "L") (40 "XL")
  (10 "X") (9 "IX") (5 "V") (4 "IV") (1 "I")))

(defn arabic-to-roman
   ([n] (if (<= 1 n 3999)
  (apply str (arabic-to-roman n arabic-values))
  (format "%d cannot be converted." n)))
   ([n num-list] (cond (empty? num-list) '()
   (zero? n) '()
   :else (let [[[arabic roman] & tail] num-list]
   (if (>= n arabic)
 (cons roman (arabic-to-roman (- n  
arabic)
  num-list))
 (arabic-to-roman n tail ))


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Waterfront 148 (was: Waterfront - The Clojure-based editor for Clojure)

2009-03-03 Thread Tom Ayerst
If you pull trunk out of subversion you can build it locally with Ant.
Would that do it?

https://waterfront.svn.sourceforge.net/svnroot/waterfront/trunk

Cheers

Tom


2009/3/3 Konrad Hinsen 

>
> On 27.02.2009, at 15:14, Itay Maman wrote:
>
> > Revision 148 is available for download at
> > http://sourceforge.net/project/platformdownload.php?group_id=249246
> > It addresses some of the requests that were raised in this discussion:
> >
> > * Changed default location of the divider
> > * Fixed the "command-key" issue on Macs.
> > * Java 1.5 compilance (prev. 1.6)
>
> I still can't run it with Java 1.5:
>
> java.lang.UnsupportedClassVersionError: Bad version number in .class
> file (kit.clj:247)
>
> Is there a simple way to recompile everything on my machine?
>
> Konrad.
>
>
> >
>

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

2009-03-03 Thread Laurent PETIT
Please forgive about this defn! macro, it does not seem to play well in
practice.

I now share Konrad's thoughts : I don't know if what he want is feasible
without changes in clojure, or use of clojure non-public APIs.

2009/3/3 Laurent PETIT 

> Now that I rethink about it, wouldn't this version using eval be less than
> ideal as far as AOT compilation is concerned ?
>
> 2009/3/3 Laurent PETIT 
>
> So there we are with a version of defn, which I called defn! because it is
>> even more agressive than defn in its side effects, that could solve your
>> problem :
>>
>> (defmacro defn!
>>   "Like defn, but first ensures that if name is bound to something (e.g.
>> the name of a function
>>in a 'used' or 'required' namespace, it is first unbound)."
>>   [name & body]
>>   `(do
>>  (clojure.core/ns-unmap *ns* (quote ~name))
>>  (eval (quote (clojure.core/defn ~name ~...@body)
>>
>> I chose to use eval, even if it's not the usual recommended way, because I
>> really wanted to not duplicate the logic in defn regarding definition of
>> multiple arity functions, meta data, ...
>>
>> But I'm not sure it is correct to have twice ~name in the macro expansion.
>> I thought that as name is expected to be the name for a symbol without
>> evaluation (as is required for the name in defn), I could do this ?
>>
>> If you find this interesting, please feel free to add it to
>> clojure-contrib.
>>
>> I think the same thing could be done for defmacro (defmacro!), ... and
>> other defXYZ.. functions/macros as well .. ?
>>
>> HTH,
>>
>> --
>> Laurent
>>
>>
>> 2009/3/3 Christophe Grand 
>>
>>
>>> Konrad Hinsen a écrit :
>>> > On 03.03.2009, at 00:53, Laurent PETIT wrote:
>>> >
>>> >
>>> >> I'm able to do that from the REPL when done one by one :
>>> >> (clojure.core/ns-unmap *ns* (quote filter))
>>> >> (clojure.core/defn filter [] "oh my!")
>>> >>
>>> >> thus correctly redefining the binding of filter for the rest of use
>>> >> by the ns
>>> >>
>>> >> But I can't manage to get it work from a macro (indeed not even
>>> >> when directly called inside a do) :
>>> >>
>>> >> (do (clojure.core/ns-unmap *ns* (quote filter)) (clojure.core/defn
>>> >> filter [] "my map!"))
>>> >>
>>> >> What is wrong with me ? (Something with def I still haven't
>>> >> understood, I think)
>>> >>
>>> >
>>> > I can only confirm your observation, and say that I don't understand
>>> > it either!
>>> >
>>> In the first case, when you enter the second statement at the repl,
>>> filter is unmapped already so the compiler understands that it must
>>> create a var and intern it as my-ns/filter.
>>> In the second case, both statements are bundled in one expression: when
>>> the expression is compiled filter is still mapped in the current ns and
>>> the compiler refuses to compile the def form.
>>>
>>> Adding an eval can make that works:
>>>
>>> (do
>>>  (clojure.core/ns-unmap *ns* (quote filter))
>>>   (eval '(clojure.core/defn filter [] "my map!")))
>>>
>>>
>>> but it may be simpler to explore doing something like this:
>>>
>>> (do
>>>  (clojure.core/ns-unmap *ns* (quote filter))
>>>   (clojure.lang.Var/intern *ns* 'filter (fn[] "my map!")))
>>>
>>>
>>> Christophe
>>>
>>> --
>>> Professional: http://cgrand.net/ (fr)
>>> On Clojure: http://clj-me.blogspot.com/ (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
To unsubscribe from 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: Waterfront 148 (was: Waterfront - The Clojure-based editor for Clojure)

2009-03-03 Thread Konrad Hinsen

On 27.02.2009, at 15:14, Itay Maman wrote:

> Revision 148 is available for download at
> http://sourceforge.net/project/platformdownload.php?group_id=249246
> It addresses some of the requests that were raised in this discussion:
>
> * Changed default location of the divider
> * Fixed the "command-key" issue on Macs.
> * Java 1.5 compilance (prev. 1.6)

I still can't run it with Java 1.5:

java.lang.UnsupportedClassVersionError: Bad version number in .class  
file (kit.clj:247)

Is there a simple way to recompile everything on my machine?

Konrad.


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

2009-03-03 Thread Konrad Hinsen

On 02.03.2009, at 19:52, Konrad Hinsen wrote:

> At first look it seems your simplified version is indeed equivalent.
> I will look at it again tomorrow after a good night's sleep :-)

At second look, I still agree, so I update the implementation in  
clojure.contrib.monads.

Konrad.


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

2009-03-03 Thread Laurent PETIT
Now that I rethink about it, wouldn't this version using eval be less than
ideal as far as AOT compilation is concerned ?

2009/3/3 Laurent PETIT 

> So there we are with a version of defn, which I called defn! because it is
> even more agressive than defn in its side effects, that could solve your
> problem :
>
> (defmacro defn!
>   "Like defn, but first ensures that if name is bound to something (e.g.
> the name of a function
>in a 'used' or 'required' namespace, it is first unbound)."
>   [name & body]
>   `(do
>  (clojure.core/ns-unmap *ns* (quote ~name))
>  (eval (quote (clojure.core/defn ~name ~...@body)
>
> I chose to use eval, even if it's not the usual recommended way, because I
> really wanted to not duplicate the logic in defn regarding definition of
> multiple arity functions, meta data, ...
>
> But I'm not sure it is correct to have twice ~name in the macro expansion.
> I thought that as name is expected to be the name for a symbol without
> evaluation (as is required for the name in defn), I could do this ?
>
> If you find this interesting, please feel free to add it to
> clojure-contrib.
>
> I think the same thing could be done for defmacro (defmacro!), ... and
> other defXYZ.. functions/macros as well .. ?
>
> HTH,
>
> --
> Laurent
>
>
> 2009/3/3 Christophe Grand 
>
>
>> Konrad Hinsen a écrit :
>> > On 03.03.2009, at 00:53, Laurent PETIT wrote:
>> >
>> >
>> >> I'm able to do that from the REPL when done one by one :
>> >> (clojure.core/ns-unmap *ns* (quote filter))
>> >> (clojure.core/defn filter [] "oh my!")
>> >>
>> >> thus correctly redefining the binding of filter for the rest of use
>> >> by the ns
>> >>
>> >> But I can't manage to get it work from a macro (indeed not even
>> >> when directly called inside a do) :
>> >>
>> >> (do (clojure.core/ns-unmap *ns* (quote filter)) (clojure.core/defn
>> >> filter [] "my map!"))
>> >>
>> >> What is wrong with me ? (Something with def I still haven't
>> >> understood, I think)
>> >>
>> >
>> > I can only confirm your observation, and say that I don't understand
>> > it either!
>> >
>> In the first case, when you enter the second statement at the repl,
>> filter is unmapped already so the compiler understands that it must
>> create a var and intern it as my-ns/filter.
>> In the second case, both statements are bundled in one expression: when
>> the expression is compiled filter is still mapped in the current ns and
>> the compiler refuses to compile the def form.
>>
>> Adding an eval can make that works:
>>
>> (do
>>  (clojure.core/ns-unmap *ns* (quote filter))
>>   (eval '(clojure.core/defn filter [] "my map!")))
>>
>>
>> but it may be simpler to explore doing something like this:
>>
>> (do
>>  (clojure.core/ns-unmap *ns* (quote filter))
>>   (clojure.lang.Var/intern *ns* 'filter (fn[] "my map!")))
>>
>>
>> Christophe
>>
>> --
>> Professional: http://cgrand.net/ (fr)
>> On Clojure: http://clj-me.blogspot.com/ (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
To unsubscribe from 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: Namespaces, use, and refer

2009-03-03 Thread Laurent PETIT
So there we are with a version of defn, which I called defn! because it is
even more agressive than defn in its side effects, that could solve your
problem :

(defmacro defn!
  "Like defn, but first ensures that if name is bound to something (e.g. the
name of a function
   in a 'used' or 'required' namespace, it is first unbound)."
  [name & body]
  `(do
 (clojure.core/ns-unmap *ns* (quote ~name))
 (eval (quote (clojure.core/defn ~name ~...@body)

I chose to use eval, even if it's not the usual recommended way, because I
really wanted to not duplicate the logic in defn regarding definition of
multiple arity functions, meta data, ...

But I'm not sure it is correct to have twice ~name in the macro expansion. I
thought that as name is expected to be the name for a symbol without
evaluation (as is required for the name in defn), I could do this ?

If you find this interesting, please feel free to add it to clojure-contrib.

I think the same thing could be done for defmacro (defmacro!), ... and other
defXYZ.. functions/macros as well .. ?

HTH,

-- 
Laurent


2009/3/3 Christophe Grand 

>
> Konrad Hinsen a écrit :
> > On 03.03.2009, at 00:53, Laurent PETIT wrote:
> >
> >
> >> I'm able to do that from the REPL when done one by one :
> >> (clojure.core/ns-unmap *ns* (quote filter))
> >> (clojure.core/defn filter [] "oh my!")
> >>
> >> thus correctly redefining the binding of filter for the rest of use
> >> by the ns
> >>
> >> But I can't manage to get it work from a macro (indeed not even
> >> when directly called inside a do) :
> >>
> >> (do (clojure.core/ns-unmap *ns* (quote filter)) (clojure.core/defn
> >> filter [] "my map!"))
> >>
> >> What is wrong with me ? (Something with def I still haven't
> >> understood, I think)
> >>
> >
> > I can only confirm your observation, and say that I don't understand
> > it either!
> >
> In the first case, when you enter the second statement at the repl,
> filter is unmapped already so the compiler understands that it must
> create a var and intern it as my-ns/filter.
> In the second case, both statements are bundled in one expression: when
> the expression is compiled filter is still mapped in the current ns and
> the compiler refuses to compile the def form.
>
> Adding an eval can make that works:
>
> (do
>  (clojure.core/ns-unmap *ns* (quote filter))
>   (eval '(clojure.core/defn filter [] "my map!")))
>
>
> but it may be simpler to explore doing something like this:
>
> (do
>  (clojure.core/ns-unmap *ns* (quote filter))
>   (clojure.lang.Var/intern *ns* 'filter (fn[] "my map!")))
>
>
> Christophe
>
> --
> Professional: http://cgrand.net/ (fr)
> On Clojure: http://clj-me.blogspot.com/ (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
To unsubscribe from 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: Namespaces, use, and refer

2009-03-03 Thread Christophe Grand

Konrad Hinsen a écrit :
> On 03.03.2009, at 00:53, Laurent PETIT wrote:
>
>   
>> I'm able to do that from the REPL when done one by one :
>> (clojure.core/ns-unmap *ns* (quote filter))
>> (clojure.core/defn filter [] "oh my!")
>>
>> thus correctly redefining the binding of filter for the rest of use  
>> by the ns
>>
>> But I can't manage to get it work from a macro (indeed not even  
>> when directly called inside a do) :
>>
>> (do (clojure.core/ns-unmap *ns* (quote filter)) (clojure.core/defn  
>> filter [] "my map!"))
>>
>> What is wrong with me ? (Something with def I still haven't  
>> understood, I think)
>> 
>
> I can only confirm your observation, and say that I don't understand  
> it either!
>   
In the first case, when you enter the second statement at the repl, 
filter is unmapped already so the compiler understands that it must 
create a var and intern it as my-ns/filter.
In the second case, both statements are bundled in one expression: when 
the expression is compiled filter is still mapped in the current ns and 
the compiler refuses to compile the def form.

Adding an eval can make that works:

(do 
  (clojure.core/ns-unmap *ns* (quote filter)) 
  (eval '(clojure.core/defn filter [] "my map!")))


but it may be simpler to explore doing something like this:

(do 
  (clojure.core/ns-unmap *ns* (quote filter))
  (clojure.lang.Var/intern *ns* 'filter (fn[] "my map!")))


Christophe

-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---