Re: classpath in clojure box

2010-01-14 Thread brian

Shawn Hoover wrote:


On Wed, Jan 13, 2010 at 8:38 PM, brian > wrote:



I was wondering if this is the right statement for setting the
external  classpath?

setq swank-clojure-classpath


Another way is to use M-x swank-clojure-project. You enter a directory 
and it automatically adds that directory/src to the classpath. You 
could drop all of the shcloj-code\code into, say,

this didn't work

c:\projects\shcloj\src. M-x swank-clojure-project and at the prompt 
c:\projects\shcloj. Then try (require 'examples.introduction).


If that doesn't work, check the value of swank-clojure-classpath after 
the REPL starts: C-h v swank-clojure-classpath. Make sure it looks 
good and then fire up SysInternals ProcMon and filter on *.clj and see 
where the system is really looking.

Shawn,

The above didn't work, but apparently it doesn't pick up my .emacs file, 
which has


(setq swank-clojure-classpath
(list "c:/shcloj-code/code/examples"))

itknows where home is, when it boots up, the default is my home dir, 
where .emacs is



when i do C-h v

swank-clojure-classpath is a variable defined in `swank-clojure.el'.
Its value is
("c:/Program Files/Clojure Box/emacs/site-lisp/../../swank-clojure/src" 
"c:/shcloj-code/code/examples" "c:/Program Files/Clojure 
Box/lib/clojure-contrib.jar" "c:/Program Files/Clojure 
Box/lib/clojure.jar" "c:/Program Files/Clojure 
Box/lib/commons-codec-1.3.jar" "c:/Program Files/Clojure 
Box/lib/commons-fileupload-1.2.1.jar" "c:/Program Files/Clojure 
Box/lib/commons-io-1.4.jar" "c:/Program Files/Clojure 
Box/lib/compojure.jar" "c:/Program Files/Clojure 
Box/lib/grizzly-http-servlet-1.9.10.jar" "c:/Program Files/Clojure 
Box/lib/grizzly-http-webserver-1.9.10.jar" "c:/Program Files/Clojure 
Box/lib/jetty-6.1.15.jar" "c:/Program Files/Clojure 
Box/lib/jetty-util-6.1.15.jar" "c:/Program Files/Clojure 
Box/lib/servlet-api-2.5-20081211.jar")


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

Re: classpath in clojure box

2010-01-14 Thread Michael Wood
2010/1/14 brian :
> Shawn Hoover wrote:
>>
>> On Wed, Jan 13, 2010 at 8:38 PM, brian > > wrote:
>>
>>
>>    I was wondering if this is the right statement for setting the
>>    external  classpath?
>>
>>    setq swank-clojure-classpath
>>
>>
>> Another way is to use M-x swank-clojure-project. You enter a directory and
>> it automatically adds that directory/src to the classpath. You could drop
>> all of the shcloj-code\code into, say,
>
> this didn't work
>
>> c:\projects\shcloj\src. M-x swank-clojure-project and at the prompt
>> c:\projects\shcloj. Then try (require 'examples.introduction).

Just a thought:

Add "c:/shcloj-code/code" (without the "examples") to your classpath
and then (use 'examples.introduction) as mentioned by Sean above.

I haven't tried this myself or looked at the code, but I suspect
that's what the problem is.

>> If that doesn't work, check the value of swank-clojure-classpath after the
>> REPL starts: C-h v swank-clojure-classpath. Make sure it looks good and then
>> fire up SysInternals ProcMon and filter on *.clj and see where the system is
>> really looking.
>
> Shawn,
>
> The above didn't work, but apparently it doesn't pick up my .emacs file,
> which has
>
> (setq swank-clojure-classpath
>    (list "c:/shcloj-code/code/examples"))
>
> itknows where home is, when it boots up, the default is my home dir, where
> .emacs is
>
>
> when i do C-h v
>
> swank-clojure-classpath is a variable defined in `swank-clojure.el'.
> Its value is
> ("c:/Program Files/Clojure Box/emacs/site-lisp/../../swank-clojure/src"
> "c:/shcloj-code/code/examples" "c:/Program Files/Clojure
> Box/lib/clojure-contrib.jar" "c:/Program Files/Clojure Box/lib/clojure.jar"
> "c:/Program Files/Clojure Box/lib/commons-codec-1.3.jar" "c:/Program
> Files/Clojure Box/lib/commons-fileupload-1.2.1.jar" "c:/Program
> Files/Clojure Box/lib/commons-io-1.4.jar" "c:/Program Files/Clojure
> Box/lib/compojure.jar" "c:/Program Files/Clojure
> Box/lib/grizzly-http-servlet-1.9.10.jar" "c:/Program Files/Clojure
> Box/lib/grizzly-http-webserver-1.9.10.jar" "c:/Program Files/Clojure
> Box/lib/jetty-6.1.15.jar" "c:/Program Files/Clojure
> Box/lib/jetty-util-6.1.15.jar" "c:/Program Files/Clojure
> Box/lib/servlet-api-2.5-20081211.jar")

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

Re: classpath in clojure box

2010-01-14 Thread brian

Michael Wood wrote:

2010/1/14 brian :
  

Shawn Hoover wrote:


On Wed, Jan 13, 2010 at 8:38 PM, brian mailto:brw...@gmail.com>> wrote:


   I was wondering if this is the right statement for setting the
   external  classpath?

   setq swank-clojure-classpath


Another way is to use M-x swank-clojure-project. You enter a directory and
it automatically adds that directory/src to the classpath. You could drop
all of the shcloj-code\code into, say,
  

this didn't work



c:\projects\shcloj\src. M-x swank-clojure-project and at the prompt
c:\projects\shcloj. Then try (require 'examples.introduction).
  


Just a thought:

Add "c:/shcloj-code/code" (without the "examples") to your classpath
and then (use 'examples.introduction) as mentioned by Sean above.

I haven't tried this myself or looked at the code, but I suspect
that's what the problem is.

  


gee, i thought that would work, but nope


If that doesn't work, check the value of swank-clojure-classpath after the
REPL starts: C-h v swank-clojure-classpath. Make sure it looks good and then
fire up SysInternals ProcMon and filter on *.clj and see where the system is
really looking.
  

Shawn,

The above didn't work, but apparently it doesn't pick up my .emacs file,
which has

(setq swank-clojure-classpath
   (list "c:/shcloj-code/code/examples"))

itknows where home is, when it boots up, the default is my home dir, where
.emacs is


when i do C-h v

swank-clojure-classpath is a variable defined in `swank-clojure.el'.
Its value is
("c:/Program Files/Clojure Box/emacs/site-lisp/../../swank-clojure/src"
"c:/shcloj-code/code/examples" "c:/Program Files/Clojure
Box/lib/clojure-contrib.jar" "c:/Program Files/Clojure Box/lib/clojure.jar"
"c:/Program Files/Clojure Box/lib/commons-codec-1.3.jar" "c:/Program
Files/Clojure Box/lib/commons-fileupload-1.2.1.jar" "c:/Program
Files/Clojure Box/lib/commons-io-1.4.jar" "c:/Program Files/Clojure
Box/lib/compojure.jar" "c:/Program Files/Clojure
Box/lib/grizzly-http-servlet-1.9.10.jar" "c:/Program Files/Clojure
Box/lib/grizzly-http-webserver-1.9.10.jar" "c:/Program Files/Clojure
Box/lib/jetty-6.1.15.jar" "c:/Program Files/Clojure
Box/lib/jetty-util-6.1.15.jar" "c:/Program Files/Clojure
Box/lib/servlet-api-2.5-20081211.jar")



  


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

Re: classpath in clojure box

2010-01-14 Thread brian

Michael Wood wrote:

2010/1/14 brian :
  

Shawn Hoover wrote:


On Wed, Jan 13, 2010 at 8:38 PM, brian mailto:brw...@gmail.com>> wrote:


   I was wondering if this is the right statement for setting the
   external  classpath?

   setq swank-clojure-classpath


Another way is to use M-x swank-clojure-project. You enter a directory and
it automatically adds that directory/src to the classpath. You could drop
all of the shcloj-code\code into, say,
  

this didn't work



c:\projects\shcloj\src. M-x swank-clojure-project and at the prompt
c:\projects\shcloj. Then try (require 'examples.introduction).
  


Just a thought:

Add "c:/shcloj-code/code" (without the "examples") to your classpath
and then (use 'examples.introduction) as mentioned by Sean above.

I haven't tried this myself or looked at the code, but I suspect
that's what the problem is.

  

I take that back,it did! hurray!

here I called (take 10 fibs) and worked , instead of  "(take 10 
introduction.fibs)" which is what the book says



If that doesn't work, check the value of swank-clojure-classpath after the
REPL starts: C-h v swank-clojure-classpath. Make sure it looks good and then
fire up SysInternals ProcMon and filter on *.clj and see where the system is
really looking.
  

Shawn,

The above didn't work, but apparently it doesn't pick up my .emacs file,
which has

(setq swank-clojure-classpath
   (list "c:/shcloj-code/code/examples"))

itknows where home is, when it boots up, the default is my home dir, where
.emacs is


when i do C-h v

swank-clojure-classpath is a variable defined in `swank-clojure.el'.
Its value is
("c:/Program Files/Clojure Box/emacs/site-lisp/../../swank-clojure/src"
"c:/shcloj-code/code/examples" "c:/Program Files/Clojure
Box/lib/clojure-contrib.jar" "c:/Program Files/Clojure Box/lib/clojure.jar"
"c:/Program Files/Clojure Box/lib/commons-codec-1.3.jar" "c:/Program
Files/Clojure Box/lib/commons-fileupload-1.2.1.jar" "c:/Program
Files/Clojure Box/lib/commons-io-1.4.jar" "c:/Program Files/Clojure
Box/lib/compojure.jar" "c:/Program Files/Clojure
Box/lib/grizzly-http-servlet-1.9.10.jar" "c:/Program Files/Clojure
Box/lib/grizzly-http-webserver-1.9.10.jar" "c:/Program Files/Clojure
Box/lib/jetty-6.1.15.jar" "c:/Program Files/Clojure
Box/lib/jetty-util-6.1.15.jar" "c:/Program Files/Clojure
Box/lib/servlet-api-2.5-20081211.jar")



  


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

Re: I'm going to teach Clojure at university - suggestions/comments?

2010-01-14 Thread Jeff Rose
Dober dan gospodine,

A few years ago I taught two semesters of web application programming
to undergraduates using Ruby on Rails.  None of them had any
experience with either programming in Ruby or developing for the web
before we started, but by most accounts it was a success.  Maybe some
of what we learned can help you...

We structured the class as if we were all working on an open source
project together.  We setup a Subversion repository and a mailing
list, and asked everyone to brainstorm project ideas during the first
few weeks of the course while they were learning the basics of Ruby
through a series of short programming exercises.  Eventually every
student submitted an idea or two, and they all voted to create a wiki
like system that supported multi-media in a nice way.  From there on,
we operated in two week cycles.  At the beginning of each cycle we
would have a class discussion about what features to work on, which
bugs to fix, how to design important parts of the system, etc.
Everyone had to choose something they wanted to work on, submit a
short description of what they would do and how they plan on doing it,
and then do it.  Communication on the mailing list started slow.
People were nervous about embarrassing themselves in front of their
classmates, and everyone was just starting in Ruby.  The first commits
to the source tree were also pretty small and quite often very buggy.
Every time a student came to us with questions we would ask them to
first post it to the list though, and every time someone found a bug
we asked them to post it so we can put it on the TODO list for next
cycle.

For the first 5-6 weeks of the project we spent most of the lectures
going through code together, teaching more detailed lectures on web
app architecture, routing HTTP requests, model-view-controller, object
relational mapping, view templates, a little about javascript, etc.
Every lecture started with a clarification section though.  Typically
about 10 minutes covering concepts that we could tell people were
struggling with by looking at their patches each week.

Eventually it really took off.  Traffic on the mailing list literally
doubled every couple weeks from the start to the finish of the
semester, and submissions to the source tree kept getting more
interesting and more effective.  There were plenty of bumps in the
road, social problems between competing interests, and all the other
student/open-source debates that come up, but that was also part of
the reason for doing the course the way we did it.  By the end of the
semester they had a working application with lots of cool
functionality to demo to the rest of the faculty, and not only did the
students seem more confident in terms of picking up a new language and
a new technology, but they were also comfortable joining mailing lists
and taking part in the greater software development community.

My advice would be to have a lecture plan for every week, whether you
get to it or not.  Students feel it when the course lacks structure,
and in turn they will lose motivation and discipline also.  Try to
setup some policies in the beginning in terms of how assignments work,
when things are due, and what kind of code you expect, and then stick
with it.  I guess this is kind of generic advice, but especially in a
class that feels less traditional I think it's even more important to
have this kind of stability for the students.  It was definitely the
more challenging part of teaching for us, but when we succeeded it was
obvious.

Good luck!

-Jeff

P.S.  The great thing about the internet and the software world is
that it doesn't really matter where you are.  If your students learn
the right skills and practice lots I think they have a good chance of
finding work remotely or creating sites/services that can be used by
the rest of the world.  Don't let a limited local economy limit their
ambitions.

> Hi,
>
> This semester I'm teaching a course at MSc studies, and I decided to
> base it on Clojure. Sorry, It's not a sign that Clojure gets the
> ground in USA - I'm in South-Eastern Europe, at University of Belgrade
> (cca 90.000 students altogether, the largest university in the region,
> but underdeveloped economy comparing to EU).
> The course title is not that important, as I am free to organize it as
> I like (for the curious, it's "Tools and Methods of Software
> Engineering").
>
> In this region, Lisp is non-existent in the industry, which is usually
> based on Java, Oracle stack or Microsoft stack, plus the usual PHP in
> smaller projects and with the hobbyist crowd.
> The undergraduate courses are based on Java and in a smaller extent
> C#, so it's a usual "traditional" programming mindset.
> The faculty I'm teaching at is an exotic mixture of management /
> information systems departments, so even inf. syst. students attend
> more management-related than IS-related courses. So, not many typical
> geeks are going to be in the crowd. This course is a part o

Re: I'm going to teach Clojure at university - suggestions/comments?

2010-01-14 Thread Dragan Djuric
Thanks Jeff, that was a really interesting report.

I'd like to do something like this - unfortunately, it's difficult to
enforce here because many students would start the riots (just
kidding) :)

As for the local economy, it's not a problem in a sense of employment
opportunity - half of them eventually move to EU, Canada or USA. The
problem is more with the alternative/exotic/emerging languages - they
simply want something that guarantees employment locally and abroad
(Java/.NET), and they are right.

On Jan 14, 11:55 am, Jeff Rose  wrote:
> Dober dan gospodine,
>
> A few years ago I taught two semesters of web application programming
> to undergraduates using Ruby on Rails.  None of them had any
> experience with either programming in Ruby or developing for the web
> before we started, but by most accounts it was a success.  Maybe some
> of what we learned can help you...
>
> We structured the class as if we were all working on an open source
> project together.  We setup a Subversion repository and a mailing
> list, and asked everyone to brainstorm project ideas during the first
> few weeks of the course while they were learning the basics of Ruby
> through a series of short programming exercises.  Eventually every
> student submitted an idea or two, and they all voted to create a wiki
> like system that supported multi-media in a nice way.  From there on,
> we operated in two week cycles.  At the beginning of each cycle we
> would have a class discussion about what features to work on, which
> bugs to fix, how to design important parts of the system, etc.
> Everyone had to choose something they wanted to work on, submit a
> short description of what they would do and how they plan on doing it,
> and then do it.  Communication on the mailing list started slow.
> People were nervous about embarrassing themselves in front of their
> classmates, and everyone was just starting in Ruby.  The first commits
> to the source tree were also pretty small and quite often very buggy.
> Every time a student came to us with questions we would ask them to
> first post it to the list though, and every time someone found a bug
> we asked them to post it so we can put it on the TODO list for next
> cycle.
>
> For the first 5-6 weeks of the project we spent most of the lectures
> going through code together, teaching more detailed lectures on web
> app architecture, routing HTTP requests, model-view-controller, object
> relational mapping, view templates, a little about javascript, etc.
> Every lecture started with a clarification section though.  Typically
> about 10 minutes covering concepts that we could tell people were
> struggling with by looking at their patches each week.
>
> Eventually it really took off.  Traffic on the mailing list literally
> doubled every couple weeks from the start to the finish of the
> semester, and submissions to the source tree kept getting more
> interesting and more effective.  There were plenty of bumps in the
> road, social problems between competing interests, and all the other
> student/open-source debates that come up, but that was also part of
> the reason for doing the course the way we did it.  By the end of the
> semester they had a working application with lots of cool
> functionality to demo to the rest of the faculty, and not only did the
> students seem more confident in terms of picking up a new language and
> a new technology, but they were also comfortable joining mailing lists
> and taking part in the greater software development community.
>
> My advice would be to have a lecture plan for every week, whether you
> get to it or not.  Students feel it when the course lacks structure,
> and in turn they will lose motivation and discipline also.  Try to
> setup some policies in the beginning in terms of how assignments work,
> when things are due, and what kind of code you expect, and then stick
> with it.  I guess this is kind of generic advice, but especially in a
> class that feels less traditional I think it's even more important to
> have this kind of stability for the students.  It was definitely the
> more challenging part of teaching for us, but when we succeeded it was
> obvious.
>
> Good luck!
>
> -Jeff
>
> P.S.  The great thing about the internet and the software world is
> that it doesn't really matter where you are.  If your students learn
> the right skills and practice lots I think they have a good chance of
> finding work remotely or creating sites/services that can be used by
> the rest of the world.  Don't let a limited local economy limit their
> ambitions.
>
>
>
> > Hi,
>
> > This semester I'm teaching a course at MSc studies, and I decided to
> > base it on Clojure. Sorry, It's not a sign that Clojure gets the
> > ground in USA - I'm in South-Eastern Europe, at University of Belgrade
> > (cca 90.000 students altogether, the largest university in the region,
> > but underdeveloped economy comparing to EU).
> > The course title is not that important, as

Re: classpath in clojure box

2010-01-14 Thread Shawn Hoover
On Thu, Jan 14, 2010 at 3:17 AM, brian  wrote:

> The above didn't work, but apparently it doesn't pick up my .emacs file,
> which has
>
> (setq swank-clojure-classpath
>(list "c:/shcloj-code/code/examples"))
>
> itknows where home is, when it boots up, the default is my home dir, where
> .emacs is
>
>
> when i do C-h v
>
> swank-clojure-classpath is a variable defined in `swank-clojure.el'.
> Its value is
> ("c:/Program Files/Clojure Box/emacs/site-lisp/../../swank-clojure/src"
> "c:/shcloj-code/code/examples" "c:/Program Files/Clojure
> Box/lib/clojure-contrib.jar" "c:/Program Files/Clojure Box/lib/clojure.jar"
> "c:/Program Files/Clojure Box/lib/commons-codec-1.3.jar" "c:/Program
> Files/Clojure Box/lib/commons-fileupload-1.2.1.jar" "c:/Program
> Files/Clojure Box/lib/commons-io-1.4.jar" "c:/Program Files/Clojure
> Box/lib/compojure.jar" "c:/Program Files/Clojure
> Box/lib/grizzly-http-servlet-1.9.10.jar" "c:/Program Files/Clojure
> Box/lib/grizzly-http-webserver-1.9.10.jar" "c:/Program Files/Clojure
> Box/lib/jetty-6.1.15.jar" "c:/Program Files/Clojure
> Box/lib/jetty-util-6.1.15.jar" "c:/Program Files/Clojure
> Box/lib/servlet-api-2.5-20081211.jar")
>

Actually it's there, buried between the swank-clojure/src and
clojure-contrib.jar. It's Clojure Box's fault on the ordering, but it would
only matter if you were trying to put your own version of swank-clojure on
the classpath.
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Help needed regarding the "let"

2010-01-14 Thread Graham Fawcett
Hi,

On Wed, Jan 13, 2010 at 1:30 AM, Manish  wrote:
> Thanx for ur response,
> Actually We are using string builder in our project, String Builder
> causing the memory leak in as I google, Thats the main reason i want
> to set the StringBuilder object to nil,
> We are using the htmlunit core js library for fetching the web pages
> which require the javascript enabled. The Decompiler.java using a
> variable StringBuilder result = new  StringBuilder(); Netbeans
> profiler showing that this is the object consuming maximum of memory
> causing memory leak. Thats the reason only I want to set the
> StringBuilder object in our project to null. I also found on net that
> strbuilder.toString() also causing the memory leak. So in place of
> toString() we are trying to use substring(0). Like:
>
> (defn #^String element-text
>  ([thing]
>     (let [delimiter #s""]
>       (element-text thing delimiter)
>       ))
>  ([thing #^String delimiter]
>     (if (instance? Node thing)
>       (node-text thing)
>       (let [buf (StringBuilder.)]
>         (doseq [#^Node e thing]
>           (node-text e buf delimiter))
>         (let [res (.substring buf 0)]
>           (.setLength buf 0)
>           res)

Substrings do indeed share memory with their parent strings, and this
will prevent the parents from being garbage-collected.

Try changing this:

  (let [res (.substring buf 0)]
          (.setLength buf 0)
          res))

to:

(String. buf)

and see if your memory problem goes away. Allocating a new String
should copy the StringBuilder buffer, not sharing any storage with it,
and letting the StringBuffer storage be reclaimed.

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

NYC Clojure Users Group Meeting for Jan 28th - I reserved a bigger space!

2010-01-14 Thread Eric Thorsen
I've reserved a larger space to accommodate 55 people (we were out of
room). There will be desks in the front and rows of seats in the back
so come a bit early if you want a desk.
For more details, see the full listing:
http://www.meetup.com/Clojure-NYC/calendar/12228936/

When: Thursday, January 28, 2010 6:30 PM

Where:
NYC Seminar and Conference Center
71 West 23rd Street
NY, NY 10010
1-866-807-1114

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

[ANN] units.clj - unit conversion functions without repeating yourself

2010-01-14 Thread Scott Jaderholm
Hi,

I created a library that provides unit conversion functions[1] for
several common units and allows you to define new units conversions
with a single equation.

The library does a few interesting things automatically:

First, if you define inches-to-feet, it will create feet-to-inches for you.
Second, if you define inches-to-feet and feet-to-meters, it will
create inches-to-meters and meters-to-inches for you.
Third, it will create the equivalent square and cubic functions as well.

So for inches, feet, yards, meters, centimeters, millimeters, miles,
and kilometers, if you specify 7 equations this library will define
168 conversion functions for you (56 each for length, area, and
volume).

The code is at http://gist.github.com/276662#file_units.clj

I'd love to receive feedback.

Thanks,
Scott

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

NullPointerException from #'> et al.

2010-01-14 Thread C. Florian Ebeling
Hi,

out of curiosity, what is the reasoning behind this behavior (I'm
pretty sure it is intended):

(= nil 1)
=> false

(> nil 1) ;; NullPointerException

Same behavior for >= <= etc.

Florian



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

Re: NullPointerException from #'> et al.

2010-01-14 Thread ataggart
What do you think should be the boolean result of (> nil 1)?

Since the inequality functions only work with Numbers, and nil is not
a Number.  The only way to make that work would be to impute some
default numerical value to nil, which would probably introduce more
problems than it solved.


On Jan 14, 7:57 am, "C. Florian Ebeling" 
wrote:
> Hi,
>
> out of curiosity, what is the reasoning behind this behavior (I'm
> pretty sure it is intended):
>
> (= nil 1)
> => false
>
> (> nil 1) ;; NullPointerException
>
> Same behavior for >= <= etc.
>
> Florian
>
> --
> Florian Ebeling
> florian.ebel...@gmail.com
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: NullPointerException from #'> et al.

2010-01-14 Thread C. Florian Ebeling
> What do you think should be the boolean result of (> nil 1)?
>
> Since the inequality functions only work with Numbers, and nil is not
> a Number.  The only way to make that work would be to impute some
> default numerical value to nil, which would probably introduce more
> problems than it solved.

I agree. It only looks inconsistent when you assume nil is treated
uniformly by these comparison function, which does not make sense.
Sorry, this question was probably a tad stupid :)


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

Re: [ANN] units.clj - unit conversion functions without repeating yourself

2010-01-14 Thread Brian
This is more java related but there is a java library and application (
http://futureboy.us/frinkdocs/) that provides a set of very powerful unit
conversion tools.


On Thu, Jan 14, 2010 at 10:49 AM, Scott Jaderholm wrote:

> Hi,
>
> I created a library that provides unit conversion functions[1] for
> several common units and allows you to define new units conversions
> with a single equation.
>
> The library does a few interesting things automatically:
>
> First, if you define inches-to-feet, it will create feet-to-inches for you.
> Second, if you define inches-to-feet and feet-to-meters, it will
> create inches-to-meters and meters-to-inches for you.
> Third, it will create the equivalent square and cubic functions as well.
>
> So for inches, feet, yards, meters, centimeters, millimeters, miles,
> and kilometers, if you specify 7 equations this library will define
> 168 conversion functions for you (56 each for length, area, and
> volume).
>
> The code is at http://gist.github.com/276662#file_units.clj
>
> I'd love to receive feedback.
>
> Thanks,
> Scott
>
> Notes
> [1] For a reliable alternative, see JScience.org
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: deftype and macros

2010-01-14 Thread Konrad Hinsen

On 14.01.2010, at 08:35, Konrad Hinsen wrote:

This one failed yesterday on my office computer, but now I tried it  
again at home and it works fine:

..

I'll check again on my office machine later today.


It failed indeed, but after recompilation of Clojure and Contrib it  
works fine now. Sorry for the false alarm!


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

Compilation-aware code?

2010-01-14 Thread ataggart
Some people have had issues with c.c.logging in that it looks for a
suitable logging implementation at macro-expansion-time (by simply
trying to import the necessary classes), which thus also occurs during
AOT compilation; the down-side is that if the desired logging lib is
not on the classpath during compilation, the java.util.logging
implementation gets selected into the compiled code.  There are
solutions to move this choice to runtime, though it adds some overhead
to every invocation, even if the respective log level is disabled.

It occurs to me it would be very nice indeed if I could provide
alternate implementations depending on whether the clojure code was
being executed as a .clj or an AOTC'd .class file.  Knowing this would
further allow the specification of env vars to influence the resulting
code, e.g., telling c.c.logging that even though it's being AOTC'd, it
can choose the logging impl right away since it's on the classpath
(thus negating the performance hit of a runtime selection).

Does anyone have a sense of whether or not this is possible already
or, if not, worth doing?
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Compilation-aware code?

2010-01-14 Thread Cyrus Harmon

hmm... perhaps one could have a form called something like ... oh, I dunno, 
maybe ... eval-when! And then one could have situations like :compile-toplevel 
and :load-toplevel and, maybe, :execute. Nah... that's a crazy idea; never 
mind...

:)

Cyrus

On Jan 14, 2010, at 9:22 AM, ataggart wrote:

> Some people have had issues with c.c.logging in that it looks for a
> suitable logging implementation at macro-expansion-time (by simply
> trying to import the necessary classes), which thus also occurs during
> AOT compilation; the down-side is that if the desired logging lib is
> not on the classpath during compilation, the java.util.logging
> implementation gets selected into the compiled code.  There are
> solutions to move this choice to runtime, though it adds some overhead
> to every invocation, even if the respective log level is disabled.
> 
> It occurs to me it would be very nice indeed if I could provide
> alternate implementations depending on whether the clojure code was
> being executed as a .clj or an AOTC'd .class file.  Knowing this would
> further allow the specification of env vars to influence the resulting
> code, e.g., telling c.c.logging that even though it's being AOTC'd, it
> can choose the logging impl right away since it's on the classpath
> (thus negating the performance hit of a runtime selection).
> 
> Does anyone have a sense of whether or not this is possible already
> or, if not, worth doing?
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

Re: Compilation-aware code?

2010-01-14 Thread ataggart
I'm detecting sarcasm, but it's not clear to me what point you're
trying to make.  Care to be more helpful or enlightening?


On Jan 14, 12:09 pm, Cyrus Harmon  wrote:
> hmm... perhaps one could have a form called something like ... oh, I dunno, 
> maybe ... eval-when! And then one could have situations like 
> :compile-toplevel and :load-toplevel and, maybe, :execute. Nah... that's a 
> crazy idea; never mind...
>
> :)
>
> Cyrus
>
> On Jan 14, 2010, at 9:22 AM, ataggart wrote:
>
>
>
> > Some people have had issues with c.c.logging in that it looks for a
> > suitable logging implementation at macro-expansion-time (by simply
> > trying to import the necessary classes), which thus also occurs during
> > AOT compilation; the down-side is that if the desired logging lib is
> > not on the classpath during compilation, the java.util.logging
> > implementation gets selected into the compiled code.  There are
> > solutions to move this choice to runtime, though it adds some overhead
> > to every invocation, even if the respective log level is disabled.
>
> > It occurs to me it would be very nice indeed if I could provide
> > alternate implementations depending on whether the clojure code was
> > being executed as a .clj or an AOTC'd .class file.  Knowing this would
> > further allow the specification of env vars to influence the resulting
> > code, e.g., telling c.c.logging that even though it's being AOTC'd, it
> > can choose the logging impl right away since it's on the classpath
> > (thus negating the performance hit of a runtime selection).
>
> > Does anyone have a sense of whether or not this is possible already
> > or, if not, worth doing?
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: NullPointerException from #'> et al.

2010-01-14 Thread ataggart


On Jan 14, 9:00 am, "C. Florian Ebeling" 
wrote:
> > What do you think should be the boolean result of (> nil 1)?
>
> > Since the inequality functions only work with Numbers, and nil is not
> > a Number.  The only way to make that work would be to impute some
> > default numerical value to nil, which would probably introduce more
> > problems than it solved.
>
> I agree. It only looks inconsistent when you assume nil is treated
> uniformly by these comparison function, which does not make sense.

Perhaps you should use compare, which doesn't have the numerical
restriction and also works well with nil.
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: NullPointerException from #'> et al.

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

Re: Compilation-aware code?

2010-01-14 Thread Cyrus Harmon

I was referring to common lisp's eval-when special operator:

http://www.lispworks.com/documentation/HyperSpec/Body/s_eval_w.htm

cyrus

On Jan 14, 2010, at 12:22 PM, ataggart wrote:

> I'm detecting sarcasm, but it's not clear to me what point you're
> trying to make.  Care to be more helpful or enlightening?
> 
> 
> On Jan 14, 12:09 pm, Cyrus Harmon  wrote:
>> hmm... perhaps one could have a form called something like ... oh, I dunno, 
>> maybe ... eval-when! And then one could have situations like 
>> :compile-toplevel and :load-toplevel and, maybe, :execute. Nah... that's a 
>> crazy idea; never mind...
>> 
>> :)
>> 
>> Cyrus

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

Re: units.clj - unit conversion functions without repeating yourself

2010-01-14 Thread Mike Davis


On Jan 14, 10:12 am, Brian  wrote:
> This is more java related but there is a java library and application 
> (http://futureboy.us/frinkdocs/) that provides a set of very powerful unit
> conversion tools.

I have always liked the units tool available here:  
http://www.gnu.org/software/units/.
I have never looked at the code, but the data file defines literally
1000s of units.  Check out the units.dat file in the distribution if
you are interested.

>
> On Thu, Jan 14, 2010 at 10:49 AM, Scott Jaderholm wrote:
>
> > Hi,
>
> > I created a library that provides unit conversion functions[1] for
> > several common units and allows you to define new units conversions
> > with a single equation.
>

I presume the name of your program and the one I referenced above is a
coincidence?  Seems like the natural name for a program of this sort.

>
> > I'd love to receive feedback.
>
> > Thanks,
> > Scott
>

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

Re: Redis-Clojure: NoRouteToHostException

2010-01-14 Thread mudphone
Timothy,

Thanks for the suggestion.  Creating a million keys within the same
with-server is possible, without seeing the NoRouteToHostException.
So, hitting with-server so many times in so short a time period is
definitely a bad idea (duh).

So, I think there is a problem with how my larger program (not in the
gist) is using the redis-clojure library.  I'm still seeing
intermitted problems with "Not able to read expected number or bytes"
which might be related.  I'll post here if it turns out that it's
related.

Also, thanks for the dotimes/doseq suggestion.  I hadn't worried about
it, since it was just a quick example.  But, thanks for the tip.

Regards,
Kyle

On Jan 13, 1:29 pm, Timothy Pratley  wrote:
> 2010/1/14 mudphone :
>
> > I believe it has to do with opening too many sockets on the Redis
> > server, rather than the total number of members in the set.
>
> Sounds possible. It would be worthwhile seeing if
> (redis/with-server REDIS-SPEC
>   (dotimes [i 10] (redis/sadd "large-set" (random-value i
> works as expected (ie: using just one connection) to help isolate the problem.
>
> From looking 
> athttp://github.com/ragnard/redis-clojure/blob/master/src/redis/interna...
> it appears that the sockets are cleaned up... so I'm thinking it is
> actually more likely that the sockets are closed, but that you use
> them all so fast that none are available before you request a new one
> because their timeout has not expired. Sockets bind to a fixed remote
> host port and a (usually) random local port. But the local ports
> cannot be reused immediately (there is a timeout) unless the socket
> specifically is set as reuse. If you ran out of sockets I would expect
> an exception more like "no file descriptors". You could run netstat
> when your program is half-way done to get a better picture.
>
> > Any suggestions appreciated.
>
> Consider using dotimes, or doseq instead of loop/recur
> (doseq [i (range 10 0 -1)] (println i))  ;; if you want to count down
> instead of up
>
> I'm not a Redis user yet so apologies if not helpful.
>
> Regards,
> Tim.
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: NullPointerException from #'> et al.

2010-01-14 Thread Timothy Pratley
2010/1/15 C. Florian Ebeling :
> I agree. It only looks inconsistent when you assume nil is treated
> uniformly by these comparison function, which does not make sense.


I quite often wish to compare comparable objects that are not numbers
and wrote some simple operators to do that:
user=> ( ( ( ( ((fnil 0 0 <) nil 1)
true
user=> ((fnil 0 0 <) 1 nil)
false

You can find the implementation for both object comparator operators
and fnil from my github if you are interested:
http://github.com/timothypratley/strive/blob/master/clj/timothypratley/extensions.clj



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

StackOverflowError possible with seq ?

2010-01-14 Thread mudphone
Is it possible that the Clojure core seq function can cause a stack
overflow (since it calls itself)?

Or is there some other manner in which misuse of a lazy seq could
cause this?  In the stack trace below, I'm seeing repeated calls to
"seq" in clojure core, until the stack is blown.

Thanks,
Kyle

Exception in thread "main" java.lang.StackOverflowError
(session_master_boot.clj:19)
at clojure.lang.Compiler.eval(Compiler.java:4617)
at clojure.lang.Compiler.eval(Compiler.java:4593)
at clojure.lang.Compiler.load(Compiler.java:4931)
at clojure.lang.Compiler.loadFile(Compiler.java:4898)
at clojure.main$load_script__6637.invoke(main.clj:210)
at clojure.main$init_opt__6640.invoke(main.clj:215)
at clojure.main$initialize__6650.invoke(main.clj:243)
at clojure.main$null_opt__6672.invoke(main.clj:268)
at clojure.main$legacy_script__6687.invoke(main.clj:299)
at clojure.lang.Var.invoke(Var.java:359)
at clojure.main.legacy_script(main.java:32)
at clojure.lang.Script.main(Script.java:20)
Caused by: java.lang.StackOverflowError
at clojure.core$seq__3835.invoke(core.clj:103)
at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:56)
at clojure.lang.RT.seq(RT.java:440)
at clojure.core$seq__3835.invoke(core.clj:103)
at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:56)
at clojure.lang.RT.seq(RT.java:440)
at clojure.core$seq__3835.invoke(core.clj:103)
at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:56)
at clojure.lang.RT.seq(RT.java:440)
at clojure.core$seq__3835.invoke(core.clj:103)
at clojure.core$concat__3960$fn__3970.invoke(core.clj:427)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:56)
at clojure.lang.RT.seq(RT.java:440)
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

ANN: dgraph 1.0, a dependency graph library for Clojure

2010-01-14 Thread Constantine Vetoshev
I would like to announce the release of dgraph 1.0, a dependency graph
implementation for Clojure.

http://github.com/gcv/dgraph

dgraph provides a mostly pure functional data structure whose nodes
behave like cells in a spreadsheet. Data changes in stored nodes cause
their dependent computed nodes to invalidate and recalculate
themselves. Dependency graphs are immutable, just like Clojure's built-
in persistent data structures, so "changing" a stored node actually
augments an existing graph and returns a new one with shared
structure.

I wrote this to simplify UI programming, and it has helped reduce the
pain significantly. The README file in the GitHub repository has some
usage examples and ideas.

Comments and bug reports welcome.

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

Many foolish questions

2010-01-14 Thread Simon Brooke
OK, I'm trying to get seriously stuck in, and the first thing I'm
trying to do is reimplement an inference engine I first wrote in
Portable Standard Lisp and then in InterLisp-D in /idiomatic/ Clojure.
So please have patience with me...

If one has something which is strongly typed, is it idiomatic to make
a Java class to hold it?

I want a structure like this

(defstruct feature :name :default)

but I want in addition to constrain the binding of :name to be always
a Clojure keyword and the binding of :default to be always a boolean -
the Clojure values either true or false.

I've tried

(defstruct feature [#^Keyword :name] :default)

but the reader spits an illegal argument exception. Is there different
syntax which the reader could parse? Or am I using the wrong kind of
thing?

Of course given that a struct is immutable I could have a make-feature
function which has type-hinted args:

(defn
#^{:doc "Make a feature safely"}
make-feature [#^Keyword name #^bool default]
(struct-map feature :name name :default default))

This works and does sort-of what I want - I can't guarantee that
nothing outside my make-feature function will make features but I
don't think I need to. However, it feels clunky - I instinctively feel
there must be a better way. Is this what deftype should be used for?
If so, where is it documented? The book I'm using - Stuart Halloway's
'Programming Clojure' - doesn't seem to have it (or if it has I've
missed it). Also, I don't seem to have deftype in my 1.1.0 rc3 build :

cc.journeyman.dtree.dtree=> (doc deftype)
java.lang.Exception: Unable to resolve var: deftype in this context
(NO_SOURCE_FILE:20)

I've also grepped the source code of clojure and failed to find it.

While we're on this point I'm delighted with the #^{:doc ...}
metadata! The way this works with the (doc thing) function is elegant
and useful. I'm also delighted with the way that keywords and maps are
functions onto each other:

cc.journeyman.dtree.dtree=> (def alive (make-feature :Alive true))
#'cc.journeyman.dtree.dtree/alive
cc.journeyman.dtree.dtree=> (:name alive)
:Alive
cc.journeyman.dtree.dtree=> (alive :name)
:Alive

This is very, very pretty.






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

2010-01-14 Thread Timothy Pratley
Hi Constantine,

Very interesting! I'll definitely be trying this out. To give me a
head-start, are there key differences with clojure.contrib.dataflow so
I can better understand?


Regards,
Tim.


2010/1/15 Constantine Vetoshev :
> I would like to announce the release of dgraph 1.0, a dependency graph
> implementation for Clojure.
>
> http://github.com/gcv/dgraph
>
> dgraph provides a mostly pure functional data structure whose nodes
> behave like cells in a spreadsheet. Data changes in stored nodes cause
> their dependent computed nodes to invalidate and recalculate
> themselves. Dependency graphs are immutable, just like Clojure's built-
> in persistent data structures, so "changing" a stored node actually
> augments an existing graph and returns a new one with shared
> structure.
>
> I wrote this to simplify UI programming, and it has helped reduce the
> pain significantly. The README file in the GitHub repository has some
> usage examples and ideas.
>
> Comments and bug reports welcome.
>
> Thanks,
> Constantine Vetoshev
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: units.clj - unit conversion functions without repeating yourself

2010-01-14 Thread Simon Brooke
On 14 Jan, 15:49, Scott Jaderholm  wrote:
> Hi,
>
> I created a library that provides unit conversion functions[1] for
> several common units and allows you to define new units conversions
> with a single equation.
>
> The code is athttp://gist.github.com/276662#file_units.clj
>
> I'd love to receive feedback.

Speaking as a complete Clojure newbie, I'm well impressed! I
downloaded that, had a wee look, though, 'H'mmm... I wonder how you'd
extend this to handle things like celsius/fahrenheit where there isn't
just a simple linear equivalence', and dammit, you've got there
already.

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

how can i better write this (reflection, str)?

2010-01-14 Thread Raoul Duke
hi,

i'm guessing there is a more Clojure-y and compact way to do this. any
suggestions would be appreciated. thank you.

(defn reflection-dump [o]
  (let [methods (.getDeclaredMethods o)
method-count (alength methods)
method-dumps (map (fn [i] (str " " i ": " (nth methods i))) (range 0
method-count))
method-dump-str (apply str (interpose "\n" method-dumps))
header-str (str o " has " method-count
(cond
 (= method-count 0) " methods."
 (= method-count 1) " method:"
 true " methods:"))
full-str (if (> method-count 0)
   (concat header-str "\n" method-dump-str)
   header-str)]
(apply str full-str)))
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Creating an object given a class object

2010-01-14 Thread evins.mi...@gmail.com


On Jan 12, 1:50 am, Konrad Hinsen  wrote:
> On 11 Jan 2010, at 23:09, .Bill Smith wrote:
>
> > Every class object has a newInstance method:
>
> > user=> (Class/forName "java.util.HashMap")
> > java.util.HashMap
> > user=> (.newInstance (Class/forName "java.util.HashMap"))
> > #
> > user=>
>
> > Is that what you are looking for?
>
> It seems close, but it doesn't work for me. From experimenting I have  
> the impression that this works only for constructors with no arguments.
>
> I found some stuff in the Java docs on reflection that could work, but  
> this is getting very complicated... I'll first see if I can do without.
>
> Thanks,
>    Konrad.

I have this lying around for situations where I need to call an
arbitrary constructor:

(defn construct [desc]
  (let [dclass (:class desc)
initargs (to-array (:initargs desc))
initclasses (make-array Class (count initargs))]
(doseq [i (range 0 (count initclasses))]
  (aset initclasses i (class (aget initargs i
(let [constructor (. dclass (getConstructor initclasses))]
  (if constructor
(. constructor (newInstance initargs))
(throw (Exception. (format "no %s constructor for args: %s"
   (str dclass) (map str
initclasses

Why the rigamarole with make-array and aset, rather than to-array or
into-array? To ensure that I *always* get a Class[], even when the
input list is empty (the reflection calls are finicky about that).
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Many foolish questions

2010-01-14 Thread Richard Newman

but the reader spits an illegal argument exception. Is there different
syntax which the reader could parse? Or am I using the wrong kind of
thing?


Wrong kind of thing. defstruct defines a struct-map, which is simply a  
map with some guaranteed keys. It doesn't make any assertions about  
the values of those keys.


You could (as you did) define a creator function for a map (doesn't  
have to be a struct-map) that checks the types of its arguments and  
errors otherwise, but -- as you observed -- generally Clojure is not  
designed to do this kind of static type checking. It's a dynamic  
language.


The "new new" work in Rich's non-mainline branches allows much more  
flexibility in avoiding the need to drop down to Java to achieve this  
kind of object definition, but that's not in 1.1.


You might be interested in this:

http://www.assembla.com/wiki/show/clojure/Datatypes


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

Re: I'm going to teach Clojure at university - suggestions/comments?

2010-01-14 Thread Eric Lavigne
>> The issue that is
>> particularly interesting to me to explore is how alien Clojure is to
>> Java programmers, what are subjective and objective causes, and how
>> hard is to overcome each of the identified issues.
>
> This sounds very interesting. I try to explain the point of lisp to
> java programmers from time to time and I find it very difficult. When
> the conversation is about clojure I usually just point out that it's
> made for multi core because that's easier to understand and a good
> selling point, but that really doesn't have much to do with the lisp
> aspect.

A year ago, I delivered a presentation about Clojure to a local Java
user group. I talked about advantages of Lisp/Clojure and demonstrated
Clojure's ability to interoperate with the Java libraries and code
with which they were familiar. Everyone nodded their heads, said it
was interesting and that they understood, and mostly forgot about it.

 
http://ericlavigne.wordpress.com/2009/02/11/clojure-presentation-at-gatorjug/

A couple weeks ago, I used Clojure to win a contest sponsored by that
group. In an afternoon, I wrote a web application in 100 lines of
Clojure.

 http://ericlavigne.net:8054/

 http://www.codetown.us/group/contesttown/forum/topics/wari-contest-1

 http://github.com/ericlavigne/island-wari

I was asked to discuss my code at the same group. We had no projector
that day, so I actually wrote out my code, 10 lines at a time, on a
whiteboard and explained how it worked. A lot of that time ended up
being spent explaining various sequence functions like map, filter,
and remove. Everyone was amazed at what Clojure could do with so
little code. They were amazed by this strange, expression-oriented
style of programming that didn't contain any statements. There was
lots of discussion, and when I was busy writing more code the audience
would break out into side discussions about coding style and whether
concise code was even a good thing (one person claimed that they
deliberately wrote verbosely so that they could understand their code
later). One audience member said that he had already seen one Clojure
presentation (mine) and two Scala presentations, and that he was
finally having an "aha" moment and starting to understand what
functional programming meant. They have asked me to continue talking
about my little program next month, as everyone is still very curious
about Clojure.


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

Re: how can i better write this (reflection, str)?

2010-01-14 Thread .Bill Smith
You might change the method-dumps definition to this:

method-dumps (map (fn [i x] (str " " i ": " x)) (range 0 method-count)
methods)

It isn't more compact but I suppose it's more Clojure-y.

On Jan 14, 6:49 pm, Raoul Duke  wrote:
> hi,
>
> i'm guessing there is a more Clojure-y and compact way to do this. any
> suggestions would be appreciated. thank you.
>
> (defn reflection-dump [o]
>   (let [methods (.getDeclaredMethods o)
> method-count (alength methods)
> method-dumps (map (fn [i] (str " " i ": " (nth methods i))) (range 0
> method-count))
> method-dump-str (apply str (interpose "\n" method-dumps))
> header-str (str o " has " method-count
> (cond
>  (= method-count 0) " methods."
>  (= method-count 1) " method:"
>  true " methods:"))
> full-str (if (> method-count 0)
>(concat header-str "\n" method-dump-str)
>header-str)]
> (apply str full-str)))
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: how can i better write this (reflection, str)?

2010-01-14 Thread Adrian Cuthbertson
How about;

(defn reflection-dump [o]
 (let [methods (seq (.getDeclaredMethods o)) ]
   (str
 o " has " (count methods) "methods...\n"
 (second (reduce (fn [[i st] meth] [(inc i) (str st "meth" i ": "
meth "\n")]) [0 ""] methods)

(print (reflection-dump java.io.InputStream))
class java.io.InputStream has 9 methods
meth0: public void java.io.InputStream.close() throws java.io.IOException
meth1: public synchronized void java.io.InputStream.mark(int)
meth2: public synchronized void java.io.InputStream.reset() throws
java.io.IOException
meth3: public abstract int java.io.InputStream.read() throws java.io.IOException
meth4: public int java.io.InputStream.read(byte[]) throws java.io.IOException
meth5: public int java.io.InputStream.read(byte[],int,int) throws
java.io.IOException
meth6: public long java.io.InputStream.skip(long) throws java.io.IOException
meth7: public int java.io.InputStream.available() throws java.io.IOException
meth8: public boolean java.io.InputStream.markSupported()

- Rgds, Adrian

On Fri, Jan 15, 2010 at 2:49 AM, Raoul Duke  wrote:
> hi,
>
> i'm guessing there is a more Clojure-y and compact way to do this. any
> suggestions would be appreciated. thank you.
>
> (defn reflection-dump [o]
>  (let [methods (.getDeclaredMethods o)
>        method-count (alength methods)
>        method-dumps (map (fn [i] (str " " i ": " (nth methods i))) (range 0
> method-count))
>        method-dump-str (apply str (interpose "\n" method-dumps))
>        header-str (str o " has " method-count
>                        (cond
>                         (= method-count 0) " methods."
>                         (= method-count 1) " method:"
>                         true " methods:"))
>        full-str (if (> method-count 0)
>                   (concat header-str "\n" method-dump-str)
>                   header-str)]
>    (apply str full-str)))
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Bug with Clojure 1.2 REPL (aka master branch) ?

2010-01-14 Thread Perry Trolard
On Jan 12, 8:58 pm, aria42  wrote:
> I was seeing this error too and I reckoned it was because my
> clojure.contribwas not compatible with clojure core. I think if
> you're using1.2master of clojure you need 1.1 master ofcontrib. Is that right?

The 1.1 new branch of Contrib is compatible, at least for the moment,
with the 1.2 master of Clojure.

Has there been talk about making an official 1.2-compatible Contrib?
Or, I suppose, after the 1.1 RC2 is accepted, Contrib development will
track Clojure's HEAD & make a 1.1-compatible branch?

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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Funding Clojure 2010

2010-01-14 Thread Brian Goslinga
I think it would be useful if there was some way to (mostly)
automatically donate $10/month.
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Funding Clojure 2010

2010-01-14 Thread Giancarlo Angulo
I second this.
=
angol
=
-|-^...@^_^, =|+^_^X++~_~,@-
www.onthe8spot.com
http://www.facebook.com/giancarlo.angulo
http://twitter.com/Neoryder



On Fri, Jan 15, 2010 at 1:29 PM, Brian Goslinga wrote:

> I think it would be useful if there was some way to (mostly)
> automatically donate $10/month.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en