Re: More Swing Examples

2009-02-14 Thread Sean

Hi,
I was trying to run this snake program, written by Mark Volkmann

http://www.ociweb.com/mark/programming/ClojureSnake.html

I'm getting the following error:

Exception in thread "main" java.io.FileNotFoundException: Could not
locate clojure/contrib/import_static__init.class or clojure/contrib/
import_static.clj on classpath:  (snake.clj:0)
at clojure.lang.Compiler.eval(Compiler.java:4193)
at clojure.lang.Compiler.load(Compiler.java:4506)
at clojure.lang.Compiler.loadFile(Compiler.java:4473)
at clojure.main$load_script__5695.invoke(main.clj:206)
at clojure.main$init_opt__5698.invoke(main.clj:211)
at clojure.main$initialize__5708.invoke(main.clj:239)
at clojure.main$null_opt__5730.invoke(main.clj:264)
at clojure.main$legacy_script__5745.invoke(main.clj:295)
at clojure.lang.Var.invoke(Var.java:340)
at clojure.main.legacy_script(main.java:34)
at clojure.lang.Script.main(Script.java:20)

I built clojure from source (svn 1281).  Is there something I should
have configured after building?

Thanks.

On Feb 13, 12:23 pm, Emeka  wrote:
> http://clojure.googlegroups.com/web/2c-calculator.clj?gda=GfxNgEMAAAC...
>
> http://www.plt1.com/1070/even-smaller-snake/

--~--~-~--~~~---~--~~
You 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: More Swing Examples

2009-02-14 Thread Sean

This worked for me.

I downloaded the svn and built it.  Once I added the jar to my
classpath, I was good to go.  I did this by modifying the clj script I
use.

Thanks!

On Feb 14, 12:37 pm, Telman Yusupov  wrote:
> You need to download clojure-contrib 
> library:http://code.google.com/p/clojure-contrib/
>
> On Feb 14, 11:07 am, Sean  wrote:
>
> > Hi,
> > I was trying to run this snake program, written by Mark Volkmann
>
> >http://www.ociweb.com/mark/programming/ClojureSnake.html
>
> > I'm getting the following error:
>
> > Exception in thread "main" java.io.FileNotFoundException: Could not
> > locate clojure/contrib/import_static__init.class or clojure/contrib/
> > import_static.clj on classpath:  (snake.clj:0)
> >         at clojure.lang.Compiler.eval(Compiler.java:4193)
> >         at clojure.lang.Compiler.load(Compiler.java:4506)
> >         at clojure.lang.Compiler.loadFile(Compiler.java:4473)
> >         at clojure.main$load_script__5695.invoke(main.clj:206)
> >         at clojure.main$init_opt__5698.invoke(main.clj:211)
> >         at clojure.main$initialize__5708.invoke(main.clj:239)
> >         at clojure.main$null_opt__5730.invoke(main.clj:264)
> >         at clojure.main$legacy_script__5745.invoke(main.clj:295)
> >         at clojure.lang.Var.invoke(Var.java:340)
> >         at clojure.main.legacy_script(main.java:34)
> >         at clojure.lang.Script.main(Script.java:20)
>
> > I built clojure from source (svn 1281).  Is there something I should
> > have configured after building?
>
> > Thanks.
>
> > On Feb 13, 12:23 pm, Emeka  wrote:
>
> > >http://clojure.googlegroups.com/web/2c-calculator.clj?gda=GfxNgEMAAAC...
>
> > >http://www.plt1.com/1070/even-smaller-snake/
--~--~-~--~~~---~--~~
You 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: Clojure on CLR/DLR

2009-02-16 Thread Sean

David,
You have a great idea here with porting clojure to the CLR. The .NET
shops are just a popular as Java shops, and something like this could
go a long way to improving software written by a lot of people.  Your
initiative and hard work are to be commended.

How do you plan on solving the library problem?  As you mentioned,
there are several discrepancies between .NET and Java libraries.
Also, there will be applications written for a certain library that
might only be available in one of the platforms.  I know I have
several .JARs that work with legacy applications ( like SAP &
Oracle :) ) that I need to use.  If some else needs to maintain them,
I wouldn't want them to accidently try to run it on the wrong
platform.  If it can go wrong...

Of course, this is a problem open source systems have had for a while,
so it can be solved (apt,ASDF,rpm,rubygems...).  It'll just take some
work.

Good work overall, I'm looking forward to what you come up with.

On Feb 16, 7:17 pm, dmiller  wrote:
> On Feb 16, 5:33 pm, Chouser  wrote:
>
> > On Mon, Feb 16, 2009 at 5:43 PM, dmiller  wrote:
>
> > I don't know if you've looked at ClojureScript at all, but it's a
> > similar if noticeably less ambitious project to compile Clojure code to
> > JavaScript.  It's in clojure-contrib already, but in
> > trunk/clojurescript instead of trunk/src.  My reasons for this were
> > (1) I wasn't quite sure how to lay out the directory structure and
> > didn't want to mess up anyone else, and (2) it doesn't work with
> > Clojure trunk but instead requires a patch and rebuild of Clojure
> > itself.  This patch is stored right there in contrib as well.
>
> I have looked briefly at ClojureScript.
>
> Placement: I'm guessing a parallel off-trunk placement.  This code is
> completely independent of Clojure/JVM, except for the bootstrap *.clj
> files.  I have those included in the project, so I'm not broken by
> Clojure/JVM changes.
>
> Also, this code is not set up for casual play. You need to be in
> Visual Studio, download the DLR, connect Tab A to Slot B, etc.  I'm
> thinking it should not be in trunk/src by the criteria you cite.
>
> > This is the majority of what the ClojureScript patch changes -- moving
> > explicit uses of non-Clojure Java class names out of .clj files and
> > into clojure.lang.RT (or other appropriate Clojure classes) so that
> > the .clj can be loaded as-is.  RT and Numbers have to be ported by
> > hand anyway, so it's not significantly worse on that end.
>
> > I'd be very interested to compare notes and see if our needs have a
> > common solution.
>
> I need to make the same kinds of changes to the *.clj files.  This has
> not been automated yet, so being in synch is a matter of hand-
> editing.
>
> We most definitely need to compare notes.
>
> > Sounds great!  But there's one very important question you didn't
> > address.  What are you going to call it?  :-)
>
> > Seriously, though, since it seems likely that a majority of code
> > written to run on your port will not work on Clojure/JVM, because of
> > the runtime libs available (please correct me if I'm wrong), it's
> > important for a body of code to be able to clearly declare where it's
> > supposed to work.  A name that is used consistently can help, I would
> > think.
>
> This is 100% C#/.NET.
>
> I'm up for suggestions on the name.  The obvious ones:
>
>  - Clojure.net
>  - ClojureCLR
>  - IronClojure (paralleling IronPython/IronRuby, unless MS has Iron
> trademarked.)
>  - CLjR  (too cute)
>
> Perhaps Rich will have a preference.  He'll have to live with it
> longer than anyone and has branding/confusion issues to keep in mind.
>
> -- David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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 Questions

2009-02-21 Thread Sean

Hi everyone,
I'm working on cleaning up the wikibook some, and I've got a few
questions.  If anyone could answer, that would be a great help.

What is the minimum required JVM version for clojure?

What versions of Java have been tested?

What versions of Java are supported?

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



Database connection examples

2009-02-24 Thread Sean

Hi,
I'm trying to connect to a MYSQL instance.  I need a little help
making the intellectual connection from Clojure to JDBC.
Specifically, I was hoping someone could post/link to an working
example.

Bonus Points:  Provide a second example for Postgres.

Negative Points:  Provide an example for SQL Server or Oracle :)
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



Flatten a list

2009-02-24 Thread Sean

I've got the following list

(:a nil nil :b :a)

I want to call a "nil-killer" function, and get the following list

(:a :b :a)

How do I go about this?  Could someone post a quick example?
--~--~-~--~~~---~--~~
You 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: Flatten a list

2009-02-24 Thread Sean

Awesome!  Thanks guys!

On Feb 24, 10:42 pm, Timothy Pratley  wrote:
> user=> (remove nil? '(:a nil nil :b :a))
> (:a :b :a)
>
> On Feb 25, 2:38 pm, Sean  wrote:
>
> > I've got the following list
>
> > (:a nil nil :b :a)
>
> > I want to call a "nil-killer" function, and get the following list
>
> > (:a :b :a)
>
> > How do I go about this?  Could someone post a quick example?
--~--~-~--~~~---~--~~
You 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: Flatten a list

2009-02-24 Thread Sean



On Feb 24, 11:35 pm, David Sletten  wrote:
> On Feb 24, 2009, at 6:07 PM, David Sletten wrote:
>
>
>
> > (defn kill-nil
> >    ([l] (kill-nil l '()))
> >    ([l result] (cond (nil? l) (reverse result)
> >                      (nil? (first l)) (recur (rest l) result)
> >                      true (recur (rest l) (cons (first l) result )
>
> I forgot to ask...
>
> In Lisp, rather than repeatedly testing for an optional argument like  
> this:
> (defun kill-nil (l &optional (result '()))
>    (cond ((endp l) (nreverse result))
>          ((null (first l)) (kill-nil (rest l) result))
>          (t (kill-nil (rest l) (cons (first l) result )
>
> I would preserve the interface to the user (i.e., single arg) but  
> eliminate the decisions regarding the optional arg from the recursive  
> calls:
> (defun kill-nil (l)
>    (labels ((kill-nil-aux (l result)
>               (cond ((endp l) (nreverse result))
>                     ((null (first l)) (kill-nil-aux (rest l) result))
>                     (t (kill-nil-aux (rest l) (cons (first l)  
> result ))
>      (kill-nil-aux l '(
>
> In the Clojure version above there doesn't seem to be any penalty  
> since the "recur" only occurs after the correct arity has been selected.
>
> Is this correct? How about a more traditional recursion?
> (defn kill-nil
>    ([l] (kill-nil l '()))
>    ([l result] (cond (nil? l) (reverse result)
>                      (nil? (first l)) (recur (rest l) result)
>                      true (kill-nil (rest l) (cons (first l)  
> result )
>
> Is there a penalty deciding which arity to use on each call?

It depends if I'm on your lawn.

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



Compojure File I/O

2009-03-05 Thread Sean

This is repeated from the compojure group.

Hi,
I'm developing an app that lets users upload files. I checked the
docs and tests, and I didn't notice anything about uploading files.
Is there a standard way of doing this in compojure, or do I need to
interact with the java servlet directly?
--~--~-~--~~~---~--~~
You 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: Clojure Cookbook

2009-03-09 Thread Sean

There's some in the wikibook

http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Cookbook

Also

http://en.wikibooks.org/wiki/Clojure_Programming/Examples

I've been trying to tidy it up a little, and would love the help.  Add
you own stuff!

Sean

On Mar 9, 10:00 pm, David Sletten  wrote:
> Has anyone done any work towards assembling a cookbook of Clojure  
> recipes along the lines of the Perl/Ruby Cookbooks? Even something  
> less formal such as the Common Lisp Cookbook would be useful (http://
> cl-cookbook.sourceforge.net/index.html).
>
> It would be good to have something like this in place to support the  
> increased interest in Clojure that Stu Halloway's book will generate.
>
> Aloha,
> David Sletten
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: filter1 interesting?

2009-03-15 Thread Sean

I would call it "Obvious"

On Mar 15, 8:00 am, linh  wrote:
> I like that, that makes the code selfdescribing (is there such a word
> in english?)
>
> On Mar 14, 2:58 pm, Craig Andera  wrote:
>
> > What about overloading first to accept a predicate?
>
> > (first even? (iterate inc 1)) => 2
>
> > On Sat, Mar 14, 2009 at 8:58 AM, e  wrote:
>
> > >> Christophe Grand suggest (seek ...), which I personally like.
>
> > > IMHO
> > > seek is pretty good for a number of reasons: short, implies first result.
> > > Minor objection would be that folks may not think it's what they want
> > > because of how it's used in C where they'd expect it to take a number of
> > > bytes and a block. (filter-one ...) or (find-first ...) are both ok to me
> > > ... and preferable to (first (filter ...)) the latter being an idiom you
> > > have to discover on your own.  Another very minor problem with the idiom 
> > > is
> > > that the docs say that filter returns a lazy sequence, but it doesn't say
> > > that the order has to be the same as how the original sequence would be
> > > consumed.  Having an actual function makes the concept of "first" 
> > > concrete.
> > > It unties it from filter having to be the implementation.
>
> > > yeah (seek ...) is pretty good.
--~--~-~--~~~---~--~~
You 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: Clojure Web Framework, what I want to add

2009-03-16 Thread Sean

I'm not sure if some of the design inputs make sense, specifically
Spring and Hibernate.

Point 1 - I've found the strength of Spring to be making up for the
weaknesses of Java.  Once you have first class functions, macros, and
multi-methods (to name a few), Spring doesn't bring much to the table
any more.  Add in a few Unix utilities like cron and others, you
remove the rest of the features.

Point 2 - As for Hibernate, ORM doesn't make much sense with a
functional language either.  The SQL library in clojure-contrib lets
you load a map, and you can create way more interesting queries with
clojure than hibernate.  S-expressions are that powerful.

Point 3 - I'd follow Rails example and use strong defaults, and resort
to XML only when necessary.

Point 4 - Sounds good.

Point 5 - Have you looked into compojure?  It does a really good job
of turning s-expressions into HTML.

Point 5 (the second one) - See compojure again.

Point 6 & 7 - This is where a lot of work is to be done.  I'm not sure
how to respond right now.  I'll think about it.

Point 8 - This is why clojure is awesome.  I'll leave this as an
exercise to the user :)

Point 9 - Yeah, this would be a great feature.

That's my thoughts.

On Mar 16, 7:17 pm, BerlinBrown  wrote:
> After many years (decade) of web development, here are the things that
> I want in a framework, mostly based in clojure:
>
> What do you think and what you add.  This is ambitious and just a
> "ideas" of what I would add.  What would you want from your ideal
> framework?
>
> 1. Based on Spring Framework for middleware:
> Reason: there are years and years and years of development spent on
> spring and there are many things done right.  If I were integrating
> with any other third party libraries, I would use spring.  Spring is
> added to my framework.
>
> 2. Based on Hibernate for ORM mapping:
> Reason: the defacto standard for ORM mapping with Java.  And also used
> by NHibernate.  There is a lot of support for most popular databases.
>
> 3. Clojure/Lisp based configuration AND default XML configurations.
> This has become the standard way to configure a J2EE web application
> including spring and hibernate.  But I would like a lisp oriented
> configuration.
>
> 4. Easy mapping to URLs.  I like python's approach for URL mapping
>
> 5. Clojure based, framework based server pages AND JSPs.  I have
> always hated some aspects of JSP and ASPs, etc, etc.  They are just
> too complicated.  I would want to use Clojure code within the
> framework oriented server page and other predefined tags.
>
> 5. Lift like reusable server pages.  Lift has an interesting approach
> for resuing the same page.  E.g. you have an if-else statement within
> the page.
>
> If request == GET
> ...render this
> if request == POST
>  ...render this.
> if URL == 'abc.html'
>  .. render this.
>
> I want to embed this in my framework.  You only touch one page, but
> you get different outputs depending on the request method or URL, etc,
> etc.
>
> 6. Use of Clojure syntactic sugar -- TO BE DETERMINED.   There is the
> ability to use powerful Clojure constructs  with this framework but I
> haven't figured out how yet.
>
> 7. Better integration of CSS, Javascript, HTML.   A lot of a web
> application still resides with the client side.   I have yet to see an
> web framework that addresses client development (besides GWT).   Maybe
> something as simple as server page tags for CSS?  Javascript?
>
> 8.  Additional third party libraries:
>
> Lucene, iText, jFreeChart, optional Terracotta integration
> 
>
> Other optional/additional thoughts.
>
> 9. Clear separation between back-end and front-end layers
--~--~-~--~~~---~--~~
You 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: Clojure Web Framework, what I want to add

2009-03-16 Thread Sean

Okay, if you have to work with something rpe-existing that makes more
sense.  My main point is that if I were started from scratch, I'd do
it different.

On Mar 16, 8:12 pm, Berlin Brown  wrote:
> On Mar 16, 7:52 pm, Jeffrey Straszheim 
> wrote:
>
> > I'd love to see something built around very-high scalability, using NIO and
> > thread pools and such.
>
> > On Mon, Mar 16, 2009 at 7:40 PM, Sean  wrote:
>
> > > I'm not sure if some of the design inputs make sense, specifically
> > > Spring and Hibernate.
>
> > > Point 1 - I've found the strength of Spring to be making up for the
> > > weaknesses of Java.  Once you have first class functions, macros, and
> > > multi-methods (to name a few), Spring doesn't bring much to the table
> > > any more.  Add in a few Unix utilities like cron and others, you
> > > remove the rest of the features.
>
> > > Point 2 - As for Hibernate, ORM doesn't make much sense with a
> > > functional language either.  The SQL library in clojure-contrib lets
> > > you load a map, and you can create way more interesting queries with
> > > clojure than hibernate.  S-expressions are that powerful.
>
> > > Point 3 - I'd follow Rails example and use strong defaults, and resort
> > > to XML only when necessary.
>
> > > Point 4 - Sounds good.
>
> > > Point 5 - Have you looked into compojure?  It does a really good job
> > > of turning s-expressions into HTML.
>
> > > Point 5 (the second one) - See compojure again.
>
> > > Point 6 & 7 - This is where a lot of work is to be done.  I'm not sure
> > > how to respond right now.  I'll think about it.
>
> > > Point 8 - This is why clojure is awesome.  I'll leave this as an
> > > exercise to the user :)
>
> > > Point 9 - Yeah, this would be a great feature.
>
> > > That's my thoughts.
>
> > > On Mar 16, 7:17 pm, BerlinBrown  wrote:
> > > > After many years (decade) of web development, here are the things that
> > > > I want in a framework, mostly based in clojure:
>
> > > > What do you think and what you add.  This is ambitious and just a
> > > > "ideas" of what I would add.  What would you want from your ideal
> > > > framework?
>
> > > > 1. Based on Spring Framework for middleware:
> > > > Reason: there are years and years and years of development spent on
> > > > spring and there are many things done right.  If I were integrating
> > > > with any other third party libraries, I would use spring.  Spring is
> > > > added to my framework.
>
> > > > 2. Based on Hibernate for ORM mapping:
> > > > Reason: the defacto standard for ORM mapping with Java.  And also used
> > > > by NHibernate.  There is a lot of support for most popular databases.
>
> > > > 3. Clojure/Lisp based configuration AND default XML configurations.
> > > > This has become the standard way to configure a J2EE web application
> > > > including spring and hibernate.  But I would like a lisp oriented
> > > > configuration.
>
> > > > 4. Easy mapping to URLs.  I like python's approach for URL mapping
>
> > > > 5. Clojure based, framework based server pages AND JSPs.  I have
> > > > always hated some aspects of JSP and ASPs, etc, etc.  They are just
> > > > too complicated.  I would want to use Clojure code within the
> > > > framework oriented server page and other predefined tags.
>
> > > > 5. Lift like reusable server pages.  Lift has an interesting approach
> > > > for resuing the same page.  E.g. you have an if-else statement within
> > > > the page.
>
> > > > If request == GET
> > > > ...render this
> > > > if request == POST
> > > >  ...render this.
> > > > if URL == 'abc.html'
> > > >  .. render this.
>
> > > > I want to embed this in my framework.  You only touch one page, but
> > > > you get different outputs depending on the request method or URL, etc,
> > > > etc.
>
> > > > 6. Use of Clojure syntactic sugar -- TO BE DETERMINED.   There is the
> > > > ability to use powerful Clojure constructs  with this framework but I
> > > > haven't figured out how yet.
>
> > > > 7. Better integration of CSS, Javascript, HTML.   A lot of a web
> > > > application still resides with the client side.   I have yet to see an
> > 

Unit Testing Macros

2009-03-17 Thread Sean

   Hey everyone,
   I'm writing a macro library for myself, and I'm thinking about
publishing it.  Before I do so, I'd like to write & run some unit
tests for it.  I was hoping the crowd could chime in on how they test
macros.  Any links & examples would be great.  Thanks!



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

2009-03-18 Thread Sean

Thanks to everyone who replied.  After looking at the examples & a
night's sleep, this makes sense.

On Mar 18, 12:38 pm, Stuart Sierra 
wrote:
> On Mar 17, 6:06 pm, Sean  wrote:
>
> >    I'm writing a macro library for myself, and I'm thinking about
> > publishing it.  Before I do so, I'd like to write & run some unit
> > tests for it.  I was hoping the crowd could chime in on how they test
> > macros.  Any links & examples would be great.  Thanks!
>
> Hi Sean,
>
> You can generally test a macro like any other function -- call it,
> then check that the result is what you want.  The exact form a macro
> expands to is usually an implementation detail, not a behavior.
>
> -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: March 20th 2009 Rich Hickey Appreciation Day!

2009-03-21 Thread Sean

On Mar 20, 10:33 pm, Aaron Brooks  wrote:
Here, here!

+1 +1 +1 ... !!

Dear God man!  This is wrong!

(fact (fact (+ 1 1 1 ...)))


>
> On Fri, Mar 20, 2009 at 2:26 PM, Rayne  wrote:
>
> > I Anthony Simpson, with the support of fellow Clojurists hereby
> > declare March 20th, the first day of spring, Rich Hickey appreciation
> > day!
>
> > Rich Hickey has certainly done a lot for us, making this wonderful
> > language and continuing to take his time to work on it. He is
> > dedicated and he wants to bring Clojure along with it's users to
> > heights that Lisp has never been before. In just some 2 years, Rich
> > has gathered together a vibrant and large community of users and
> > contributors who believe in Clojure's future immensely . One such
> > contributor who believes in Clojure enough to write an entire book on
> > it! Clojure gains more attention and support everyday.
>
> > I believe in the bright future that Rich Hickey believes exists for
> > Clojure. I believe that with this community, and with such a wonderful
> > creator as Rich Hickey, Clojure will achieve it's goals and meet the
> > destiny that Rich is writing for it.
>
> > I thank you Rich Hicky for all your work on Clojure. I thank you for
> > all the time you've spent building this community and giving us one of
> > the most awesome languages that have existed. Thank you for caring
> > about us enough to listen to the community before making big changes,
> > I believe in Clojure and I will be here watching it evolve with you!
>
> > If you would like to thank Rich Hickey for all he has done for us, you
> > can post in this thread, or tell him yourself in the #Clojure IRC
> > channel. :)
>
> > March 20th 2009 Rich Hickey Appreciation Day
>
> > -Rayne
--~--~-~--~~~---~--~~
You 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 mmap/duck_streams for binary data

2009-03-22 Thread Sean

Could you throw this on github, so we can easily follow along with
improvements?

On Mar 22, 8:25 pm, "zoglma...@gmail.com"  wrote:
> While playing around and implementing straight up Humman compression,
> I wrote a handful of utilities to conveinently play with byte and bit
> streams because I didn't see anything too helpful in the mmap and
> duck_stream files.
>
> What I wrote would need to be changed to better work with the existing
> code and to increase performance, but does anyone think that it would
> be helpful to add these things for playing with binary data into
> contrib?
>
> ; to exercise everything -- use this to copy a file -- obviously
> change the files
> (time (to-file "/Users/kaz/Desktop/Programming Clojure-copy.pdf" (bit-
> to-byte-stream (byte-to-bit-stream (to-byte-stream "/Users/kaz/Desktop/
> Programming Clojure.pdf")
>
> ; to play with Huffman compress/decompression
> (compress-file "/Users/kaz/Desktop/onlisp.pdf" "/Users/kaz/Desktop/
> onlisp.pdf.compress")
> (uncompress-file "/Users/kaz/Desktop/onlisp.pdf.compress" "/Users/kaz/
> Desktop/onlisp2.pdf")
>
> ;-- 
> --
> ;-- setup files to act like streams at the bit level
> -
> ;-- 
> --
> (defn array-to-list [arr list-size]
>    (loop [index 0 accum []]
>      (if (or (= index (alength arr)) (= index list-size))
>        accum
>        (recur (inc index) (conj accum (aget arr index))
>
> (defn list-to-array [l array-type arr-size]
>   (let [arr-size (min arr-size (count l))
>         arr (make-array array-type arr-size)]
>     (loop [index 0 l l]
>       (if (= index arr-size)
>         arr
>         (do
>           (aset arr index (first l))
>           (recur (inc index) (rest l)))
>
> (defn num-to-bits [num size]
>   (loop [num num size size accum nil]
>     (if (= size 0)
>       accum
>       (let [next-n (bit-shift-right num 1)
>             next-bit (bit-xor num (bit-shift-left next-n 1))]
>         (recur next-n (dec size) (cons next-bit accum))
>
> (import '(java.io FileInputStream FileOutputStream))
> (defn to-byte-stream [filename]
>    (let [bufsize 65536
>         is (FileInputStream. filename)
>         read-buf
>            (fn []
>              (let [buf (make-array (Byte/TYPE) bufsize)
>                    num-read (.read is buf 0 bufsize)]
>                (if (= num-read -1)
>                  (do
>                    (.close is)
>                    nil)
>                  (array-to-list buf num-read
>         read-all
>            (fn read-all []
>              (let [next-buf (read-buf)]
>                (if (nil? next-buf)
>                  nil
>                  (lazy-cat next-buf (read-all)]
>      (read-all)))
>
> (defn byte-to-bit-stream [l]
>    (if (nil? l)
>      nil
>      (lazy-cat (num-to-bits (first l) 8) (byte-to-bit-stream (rest
> l)
>
> (defn bits-to-num [l num-bit-size]
>    (let [cnt (count (take num-bit-size l))]
>      (if (< cnt num-bit-size)
>         (bits-to-num (lazy-cat l (take (- num-bit-size cnt) (repeat
> 0))) num-bit-size)
>        (loop [l l size num-bit-size accum 0]
>         (if (= size 0)
>           (list accum l)
>           (recur (rest l) (dec size) (bit-or (bit-shift-left accum 1)
> (first l
>
> (defn bit-to-byte-stream [l]
>    (if (nil? l)
>      nil
>      (let [[next-byte rst] (bits-to-num l 8)]
>        (lazy-cons next-byte (bit-to-byte-stream rst)
>
> (defn to-file [filename byte-stream]
>   (let [os (FileOutputStream. filename)]
>     (loop [bytes byte-stream bytes-written 0]
>       (if (nil? bytes)
>         (do
>           (.close os)
>           bytes-written)
>         (let [[bytes rest-bytes] (split-at 65536 bytes)
>               buf (list-to-array (map byte bytes) (Byte/TYPE) 65536)
>               wrote-now (alength buf)]
>           (do
>              (.write os buf 0 wrote-now)
>              (recur rest-bytes (+ bytes-written wrote-now
>
> ;-- 
> --
> ;-- Using byte/bit streams to do huffman -
> ;-- 
> --
>
> (defn get-occurances [l]
>  (loop [l l accum {}]
>    (if (empty? l)
>      accum
>      (let [next (first l)
>             current-count (if (nil? (accum next)) 0 (accum next))
>             next-accum (assoc accum next (inc current-count))]
>         (recur (rest l) next-accum)
>
> (defn tree-has-children? [tree]
>  (and (not (nil? tree)) (or (not (nil? (tree :left-child))) (not (nil?
> (tree :right-child))
> (defn tree-has-lchild? [tree]
>  (and (not (nil? tree)) (not (nil? (tree :left-child)
> (defn tree-has-rchild? [tree]
>  (and (not (nil? tree)) (not (nil? (tree :right-child

Proposed Change to str-utils

2009-03-23 Thread Sean

Hello Everyone,
I've been reviewing the str-utils package, and I'd like to propose a
few changes to the library.  I've included the code at the bottom.

USE MULTI-METHODS

I'd like to propose re-writing the following methods to used multi-
methods.  Every single method will take an input called input-string.

*re-split[input-string & remaining-inputs](...)*

The remaining inputs can be dispatched based on a regex pattern, a
list of patterns, or a map.

regex pattern - splits a string into a list, like it does now.
e.g. (re-split "1 2 3\n4 5 6" #"\n") => ("1 2 3" "4 5 6")

list - this splits each element either like a map or a regex.  The map
operator is applied recursively to each element
e.g. (re-split "1 2 3\n4 5 6" (list #"\n" #"\s+")) => (("1" "2" "3")
("4" "5" "6"))

map - this splits each element based on the inputs of the map.  It is
how options are passed to the method.
e.g (re-split "1 2 3" {:pattern #"\s+" :limit 2 :marshal-fn #
(java.lang.Double/parseDouble %)}) => (1.0 2.0)
The :pattern and :limit options are relatively straightforward.
The :marshal-fn is mapped after the string is split.

These items can be chained together, as the following example shows
e.g. (re-split "1 2 3\n4 5 6" (list #"\n" {:pattern #"\s+" :limit
2 :marshal-fn #(java.lang.Double/parseDouble %)})) => ((1.0 2.0) (4.0
5.0))

In my opinion, the :marshal-fn is best used at the end of the list.
However, it could be used earlier in the list, but a exception will
most likely be thrown.


*re-partion[input-string & remaining-inputs]

This methods behaves like the original re-partition method, with the
remaining-inputs being able to a list or a pattern.  I don't see a
need to change the behavior of this method at the moment.

*re-gsub[input-string & remaining-inputs]

This method can take a list or two atoms as the remaining inputs.

Two atoms -
e.g. (re-gsub "1 2 3 4 5 6" #"\s" "") => "123456"

A paired list
e.g (re-gsub "1 2 3 4 5 6" '((#"\s" " ) (#"\d" "D"))) => "DD"

*re-sub[input-string & remaining-inputs]

Again, this method can take a list or two atoms as the remaining
inputs.

Two atoms
e.g. (re-sub "1 2 3 4 5 6" #"\d" "D") => "D 2 3 4 5 6"

A paired list
e.g (re-sub "1 2 3 4 5 6" '((#"\d" "D") (#"\d" "E"))) => "D E 3 4 5 6"

NEW PARSING HELPERS
I've created four methods, str-before, str-before-inc, str-after, str-
after-inc.  They are designed to help strip off parts of string before
a regex.

(str-before "Clojure Is Awesome" #"\s") => "Clojure"
(str-before-inc "Clojure Is Awesome" #"\s") => "Clojure "
(str-after "Clojure Is Awesome" #"\s") => "Is Awesome"
(str-after-inc "Clojure Is Awesome" #"\s") => " Is Awesome"

These methods can be used to help parse strings

(str-before (str-after "" #"") => ;the stuff in the
middle

NEW INFLECTORS
I've added a few inflectors that I am familiar with from Rails.  My
apologies if their origin is anther language.  I'd be interested in
knowing where the method originated

str-reverse
This methods reverses a string
e.g. (str-reverse "Clojure") => "erujolC"

trim
This is a convenience wrapper for the trim method java supplies
e.g. (trim "  Clojure  ") => "Clojure"

strip
This is an alias for trim.  I accidently switch between *trim* and
*strip* all the time.
e.g. (strip "  Clojure  ") => "Clojure"

ltrim
This method removes the leading whitespace
e.g. (ltrim "  Cloure  ") => "Clojure  "

rtrim
This method removes the trailing whitespace
e.g. (ltrim "  Cloure  ") => "  Clojure"

downcase
This is a convenience wrapper for the toLowerCase method java supplies
e.g. (downcase "Clojure") => "clojure"

upcase
This is a convenience wrapper for the toUpperCase method java supplies
e.g. (upcase "Clojure") => "CLOJURE"

capitalize
This method capitalizes a string
e.g (capitalize "clojure") => "Clojure"

titleize, camelize, dasherize, underscore
These methods manipulate "sentences", producing a consistent output.
Check the unit tests for more examples
(titleize "clojure iS Awesome") => "Clojure Is Awesome"
(camleize "clojure iS Awesome") => "clojureIsAwesome"
(dasherize "clojure iS Awesome") => "clojure-is-awesome"
(underscore "clojure iS Awesome") => "clojure_is_awesome"

*FINAL THOUGHTS*
There are three more methods, str-join, chop, and chomp that were
already in str-utils.  I change the implementation of the methods, but
the behavior should be the same.

There is a big catch with my proposed change.  The signature of re-
split, re-partition, re-gsub and re-sub changes.  They will not be
backwards compatible, and will break code.  However, I think the
flexibility is worth it.

*TO-DOs*
There are a few more things I'd like to add, but that could done at a
later date.

*Add more inflectors

The following additions become pretty easy if the propsed re-gsub is
included:

*Add HTML-escape function (like Rails' h method)
*Add Javascript-escape function (like Rails' javascript-escape method)
*Add SQL-escape function

Okay, that's everything I can think of for now.  I'd like to thank the
Stuart Sierr

Re: Proposed Change to str-utils

2009-03-23 Thread Sean

Okay, it's up. Still new to github. Sorry about that.  I *think* it's
here:

http://github.com/francoisdevlin/clojure-str-utils-proposal/tree/master

I'm not sure what the directory structure should be for everything
still.  Perhaps somebody can point out how it should be done.

I'll put the original post in the README

Long story short:  multi-methods could be awesome

Sean

On Mar 23, 9:27 pm, David Nolen  wrote:
> Looks interesting and maybe even very useful. Why not put your code on
> Github or some other public repo of your liking. It's much nicer than
> pasting all this code ;)
>
> On Mon, Mar 23, 2009 at 9:18 PM, Sean  wrote:
>
> > Hello Everyone,
> > I've been reviewing the str-utils package, and I'd like to propose a
> > few changes to the library.  I've included the code at the bottom.
>
> > USE MULTI-METHODS
>
> > I'd like to propose re-writing the following methods to used multi-
> > methods.  Every single method will take an input called input-string.
>
> > *re-split[input-string & remaining-inputs](...)*
>
> > The remaining inputs can be dispatched based on a regex pattern, a
> > list of patterns, or a map.
>
> > regex pattern - splits a string into a list, like it does now.
> > e.g. (re-split "1 2 3\n4 5 6" #"\n") => ("1 2 3" "4 5 6")
>
> > list - this splits each element either like a map or a regex.  The map
> > operator is applied recursively to each element
> > e.g. (re-split "1 2 3\n4 5 6" (list #"\n" #"\s+")) => (("1" "2" "3")
> > ("4" "5" "6"))
>
> > map - this splits each element based on the inputs of the map.  It is
> > how options are passed to the method.
> > e.g (re-split "1 2 3" {:pattern #"\s+" :limit 2 :marshal-fn #
> > (java.lang.Double/parseDouble %)}) => (1.0 2.0)
> > The :pattern and :limit options are relatively straightforward.
> > The :marshal-fn is mapped after the string is split.
>
> > These items can be chained together, as the following example shows
> > e.g. (re-split "1 2 3\n4 5 6" (list #"\n" {:pattern #"\s+" :limit
> > 2 :marshal-fn #(java.lang.Double/parseDouble %)})) => ((1.0 2.0) (4.0
> > 5.0))
>
> > In my opinion, the :marshal-fn is best used at the end of the list.
> > However, it could be used earlier in the list, but a exception will
> > most likely be thrown.
>
> > *re-partion[input-string & remaining-inputs]
>
> > This methods behaves like the original re-partition method, with the
> > remaining-inputs being able to a list or a pattern.  I don't see a
> > need to change the behavior of this method at the moment.
>
> > *re-gsub[input-string & remaining-inputs]
>
> > This method can take a list or two atoms as the remaining inputs.
>
> > Two atoms -
> > e.g. (re-gsub "1 2 3 4 5 6" #"\s" "") => "123456"
>
> > A paired list
> > e.g (re-gsub "1 2 3 4 5 6" '((#"\s" " ) (#"\d" "D"))) => "DD"
>
> > *re-sub[input-string & remaining-inputs]
>
> > Again, this method can take a list or two atoms as the remaining
> > inputs.
>
> > Two atoms
> > e.g. (re-sub "1 2 3 4 5 6" #"\d" "D") => "D 2 3 4 5 6"
>
> > A paired list
> > e.g (re-sub "1 2 3 4 5 6" '((#"\d" "D") (#"\d" "E"))) => "D E 3 4 5 6"
>
> > NEW PARSING HELPERS
> > I've created four methods, str-before, str-before-inc, str-after, str-
> > after-inc.  They are designed to help strip off parts of string before
> > a regex.
>
> > (str-before "Clojure Is Awesome" #"\s") => "Clojure"
> > (str-before-inc "Clojure Is Awesome" #"\s") => "Clojure "
> > (str-after "Clojure Is Awesome" #"\s") => "Is Awesome"
> > (str-after-inc "Clojure Is Awesome" #"\s") => " Is Awesome"
>
> > These methods can be used to help parse strings
>
> > (str-before (str-after "" #"") => ;the stuff in the
> > middle
>
> > NEW INFLECTORS
> > I've added a few inflectors that I am familiar with from Rails.  My
> > apologies if their origin is anther language.  I'd be interested in
> > knowing where the method originated
>
> > str-reverse
> > This met

Re: Annotations and gen-class

2009-03-24 Thread Sean

Some working code would make it a lot easier to understand *exactly*
what you're looking for.  Do you think you could post a few quick
methods on github?  If memory serves, the reflections package should
be a good place to start.

However, you'd need to ask *why* you need this.

If the answer is "I need to work with and modify a pre-existing, pre-
tested, needs-to-stay-in-production application", then this is a great
idea.  Clojrue should help you glue your components together.

If your answer is "I'm making a brand new application", or "This is
for a side project", this might be a bad approach.  Annotations
generally are used to make up for a weakness in the Java language.
Some Clojure language features could probably do the job better

* Dynamic Typing
* First class functions
* Sequence functions. such as map/reduce/filter etc.
* Macros

Specifically, I think Guice (and other DI tools) should be avoided.
They are the antithesis of functional programming, and first class
functions will make your life much easier.  Try re-thinking about a
problem in a functional style.  I'm willing to bet that you'll have a
solution that is easier to write, easier to test, and will scale
better.

On Mar 24, 9:57 am, Matt Revelle  wrote:
> Support for using JVM annotations with Clojure code has come up  
> several times before,
> I'd like a feature request issue to be created and to start discussing  
> the implementation.
>
> It seems that an "annotations" metadata tag could contain all  
> annotations for an object,
> and any annotations that persist to runtime would need bytecode  
> emitted.  This appears straightforward,
> but I wonder if there will be a problem using Method or Parameter  
> annotations.
>
> The motivation for this is to support Java libraries which depend on  
> annotations at runtime for discovery and metadata persistence.
> Being able to integrate a class generated by gen-class with, for  
> example, a Java project using Guice would be handy.
>
> Thoughts?
>
> -Matt
--~--~-~--~~~---~--~~
You 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: parallel iteration

2009-03-24 Thread Sean

@Rowdy

Take the time to do the interleave example by hand.  You'll it does
exactly what you want in one pass.

On Mar 24, 10:10 am, Rowdy Rednose  wrote:
> Thanks guys, these solutions look much better already.
>
> But do I always have to have these 2 steps
> * merge collection
> * split collection
>
> It feels a bit inefficient, I don't know if it actually is, though.
>
> On Mar 24, 8:05 pm, Phlex  wrote:
>
> > On 24/03/2009 1:06, pmf wrote:
>
> > > On Mar 24, 12:01 am, Rowdy Rednose  wrote:
>
> > >> Hi group,
>
> > >> say I have 2 sequences
>
> > >> (def seq-a '("a1" "a2" "a3"))
> > >> (def seq-b '("b1" "b2" "b3"))
>
> > >> and want to iterate over them in parallel, like this
>
> > >> (par-doseq [a seq-a b seq-b] (prn a b))
>
> > >> which should print
>
> > >> "a1" "b1"
> > >> "a2" "b2"
> > >> "a3" "b3"
>
> > > A combination of the interleave and partition functions would probably
> > > do what you want:
>
> > > (partition 2 (interleave [:a :b :c] [:d :e :f]))
>
> > > (Wrap it in a doall to force your side effects.)
>
> > Another one :
>
> > (doseq [[a b] (map vector '(1 2 3) '(a b c))]
> >    (println a b))
>
> > (defmacro par-doseq [bindings & body]
> >    (let [bindings (partition 2 bindings)]
> >      `(doseq [~(vec (map first ,bindings)) (map vector ~@(map second
> > ,bindings))]
> >         ~...@body)))
>
> > cara.nio.echo=> (par-doseq [a '(1 2 3) b '(a b c)] (println a b))
> > 1 a
> > 2 b
> > 3 c
> > nil
>
> > Sacha
--~--~-~--~~~---~--~~
You 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: Proposed Change to str-utils

2009-03-24 Thread Sean

Okay, I've made some changes to my proposed str-utils.  I've also got
a few answers to some of the issues Stuart raised.

New Changes

1. re-strip is now lazy
I re-wrote this method to used the re-partition method in str-utils.
This enables the laziness, and helped be consolidate my Java
interactions into fewer functions.

2. re-strip options changed
I removed the ability to pass a :limit option.  I replaced it
with :offset and :length options.  Seemed to make the function more
flexible :)

3. created nearby function
The nearby function returns a lazy sequence of strings "nearby" the
input string.  It's inspired by the Norvig spellchecker example.  I'd
like to propose adding this method to the library, because I'm
interested in what uses creative people will have for it.

4. Added README.html
This file contains usage on every method in my proposed str-utils

Response to Stuart's Issues
You've raised some good points with my proposal.  However, I think
there is some hidden value in including the functions in the library.

1. Repeated
The main reason I have for including the repeated methods
(trim,strip,downcase,upcase) in the str-utils library is program
flow.  Take the following two examples

(map downcase a-list)

(map #(. % toLowerCase) a-list)

It's my purely subjective opinion that the first method reads much
nicer.  I'm also a web developer, so I do a lot of string processing.
I have a subjective preference for functions that make code more
concise, and my code will read a little shorter with the downcase
function in it.

I guess my main argument is that a more concise way of stating the
same thing does add value.  For example, the jQuery selector can be
called using the function jQuery().  However, it is always written $()
to save time.  In my view, the $() shortcut does add value.  This is
why I think you should consider adding my repeated methods to str-
utils.

2.  Methods in Apache Commons
The second issue you raise is with methods like capitalize, that are
available in Apache Commons.  First of all, the exact reasoning I went
through above could easily be applied to the following s-exp

(map capitalize a-list)

However, I believe there is an additional reason for including these
methods in the library.  By requiring Apache Commons, you've increased
the number of jars I need to maintain.  Granted, a lot of people are
used to using the commons.  It is still one more thing that requires
maintenance, though.  By making capitalize (and others) part of
contrib, it reduces the amount of work I have to do to get this
functionality.

In conclusion, I'd recommend making the str-utils one of the slickest
libraries in Clojure.  As developers, we know how strong string
manipulation makes writing code easier.  If Clojure has incredible
string support, developers will be more impressed.  Let's go out of
our way to make string manipulation in Clojure easier than in any
other language.

Besides, once we get a kick-ass string library working, we can then
abstract the routines to work on any pattern of symbols, and give our
macro writers a boost.

Sean

On Mar 24, 2:22 pm, Stuart Sierra  wrote:
> On Mar 23, 9:46 pm, Sean  wrote:
>
> >http://github.com/francoisdevlin/clojure-str-utils-proposal/tree/master
>
> > I'm not sure what the directory structure should be for everything
> > still.  Perhaps somebody can point out how it should be done.
>
> > I'll put the original post in the README
>
> > Long story short:  multi-methods could be awesome
>
> Hi Sean,
>
> This is interesting.  One quick comment, though: the trim, strip,
> upcase, and downcase functions don't add anything to the original Java
> methods.  Rich and others have warned against adding wrapper functions
> just to hide Java.
>
> Some of these functions, like capitalize, are available in Apache
> Commons Lang, the "StringUtils" class.
>
> -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: Proposed Change to str-utils

2009-03-25 Thread Sean

Perry,

1.  Thanks for the tip on using type hints!  I just added them to my
code and pushed it to github

2.  If you take a close look at my re- * methods, I actually tried to
enforce an arity of 2 on as many methods as I could.  This way the
methods would read like so

(re-split input-sting  work-instructions)
(re-partition input-sting  work-instructions)
(re-gsub  input-sting  work-instructions)
(re-sub   input-sting  work-instructions)

However, this didn't quite work with the lowest levels of re-gsub and
re-sub, and forcing a map at the lowest level didn't feel right.

3.  Library location is a slight issue.  I agree these methods are in
a completely different category than downcase, upcase, etc.  The
current str-utils.clj file has these methods in it.  That is why they
started there.  There may be a case for creating a separate regex-
utils library, and I know I have a few more parsing methods I'd like
to propose in the near future.  At the current moment, I personally
prefer to have everything in one file.  We'll see how big things get,
though.

To Everyone,
I'd like to add Perry's type-hinting argument to the list of reasons
these changes should be in contrib.  Pooling our efforts to create a
high performance version of the code does add value beyond a simple
wrapper.

A *fast*, tested and slick string library  is even better than a
tested and slick string library.

Sean

On Mar 25, 3:08 pm, Perry Trolard  wrote:
> Whatever it's worth as a datum, my experience is that I usually find
> myself writing upcase, downcase, titlecase functions in most
> applications, because
>
>  (1) they're prettier & more succinct when passed as first-class
> (downcase vs. #(.toLowerCase %))
>  (2) I can add type hints once, in the downcase, upcase, etc.
> functions, instead of doing so at each invocation (#(.toLowerCase
> #^String %))
>
> I think (2)'s the most compelling reason. The type-hinting situation
> in Clojure is currently pretty impressive, I've found; a relatively
> small number of hints strategically placed usually eliminate most or
> all of the reflection that occurs in my first draft of functions. But
> many string-processing operations -- for whatever reason -- usually
> need a manual hint.
>
> I agree that it's not desirable to balloon the Clojure API with thin
> wrappers on the Java APIs, but, like pc, think this might be an
> exception.
>
> I'm less sure about the other proposed changes to str-utils -- the
> variable-arity versions of re-split, -partition, -sub, -gsub. Maybe a
> regex-parse lib in contrib would be a better place?
>
> 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: Proposed Change to str-utils

2009-03-28 Thread Sean

Yesterday a coworker need a few excel spreadsheets (tab delimited)
stitched together.  I took this as an opportunity to test run my
proposed string functions.  Here's what I found:

Good stuff
* Having re-split be lazy is awesome.  This made partially traversing
a row super quick.
* The str-before/after methods were useful for trimming headers.
* Having :offset in re-split was also useful for skipping the first
few lines.
* Passing an options map is useful.
* I needed to create a hashmap with one of the columns as a key.
Having trim as a clojure function made the code cleaner.
* I couldn't have delivered what my coworker needed without the
currently existing chop and chomp functions.  Thanks to the original
str-utils authors!

Bad Stuff
* Some of the proposed mutlimethod functions look cool on paper, but
don't get used in practice.  Suppling a list to re-split and re-
partition is not as useful as I thought, and I needed to use a normal
map operation instead
* The :marshal-fn parameter wasn't as useful as I thought, either.
Again, I used a normal map operation instead.

The biggest challenge was learning to write the stitcher application
in a functional style.  Once my brian started to make the switch from
Ruby to Clojure, it really helped.  Anyway, the code it on github, and
now has a build.xml file, so you can build that jar.  I'd really
appreciate more feedback on the library.

I hope other people find this useful.  Happy Hacking!


On Mar 26, 1:55 am, Tom Faulhaber  wrote:
> Having great string and regex manipulation is a must for anything that
> will be used as a scripting language and I think this should be
> conveniently available in Clojure.
>
> So, yes, I agree that these functions are ones that it makes sense to
> wrap.
>
> I'm not (yet, at least) commenting specifically on Sean's proposal,
> because I haven't had time to look at it in depth,
>
> Tom
--~--~-~--~~~---~--~~
You 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: Setting up Clojure on OS X

2009-03-30 Thread Sean

Mark,
This is a great writeup on installing clojure.  As an OSX nerd, my
main problem is getting an editor up and running.  Maybe you could add
a section on setting up an editor?  I know the wiki was a good place
to start.

On Mar 30, 7:02 am, Mark Reid  wrote:
> Hi,
>
> I've just written a blog post describing how I set up Clojure on my
> Mac:
>
>    http://mark.reid.name/sap/setting-up-clojure.html
>
> My main aims were to make it easy to configure the classpath for
> various projects while still having a single Clojure command I can run
> from anywhere to open a interactive session or run a script. Hopefully
> others might find this useful as well.
>
> Feedback is appreciated as I am new to Clojure and acutely aware that
> I may not be doing things in the most elegant way.
>
> Mark
> --http://mark.reid.name
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



LZW compression

2009-03-30 Thread Sean

Hi,
Does anyone know of a good compression library in java or clojure?  A
quick google didn't reveal much useful.  I need an LZW filter for an
app I'm working on.

Sean
--~--~-~--~~~---~--~~
You 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: Please suggest a way to learn just enough Java for Clojure

2009-03-30 Thread Sean

There is a pair of java books I cut my teeth on, an I would recommend
them to anyone.

Core Java Volumes I & II, by Horstman and Cornell.

Amazing reference, two of the best technical books I've ever read.
Cover usage, gives code examples, and a tremendous amount of history &
theory (for their audience, anyway).  The best place to start with
Java, IMO.

On Mar 30, 4:39 pm, David Nolen  wrote:
> There's a few posts on the mailing list suggesting some good starting
> points.  You can get far in Clojure without resorting to Java but it
> definitely helps to know some if you really want to advance your knowledge
> of Clojure's inner workings as well as get it to interoperate with Java
> libraries.
>
> On Mon, Mar 30, 2009 at 12:41 PM, Santanu  wrote:
>
> > Hi Everybody,
>
> > (Sorry if this post appears twice, but the first post seems to have
> > vanished)
>
> > I have recently downloaded Clojure and am learning it.
>
> > As of now, I feel that to do anything substantial with Clojure, I have
> > to
> > be able to know how to access the Java libraries from within Clojure.
>
> > But the problem is, I don't know Java. I know C, some Scheme, little
> > bit
> > Haskell, etc. but no Java. I am not interested in Java anyway. I
> > downloaded
> > Java documentation and am trying to go through interesting looking
> > functions to try and use from within Clojure. But with no knowledge of
> > Java, I am having problems exploring the various functions in the Java
> > libraries.
>
> > Could you please suggest any Java book (and the relevant chapters)
> > that
> > will teach me _just_enough_ Java so that I can understand how to use
> > the Java
> > library documentation effectively.
>
> > Thanks in advance.
>
> > Regards,
> > Santanu Chatterjee
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



doseq vs. map

2009-04-02 Thread Sean

Hi everyone,
I'm working with awt to do create an image renderer.  This is
obviously an application where side effects are desired.  My first
attempt was this:

(map #(form-with-side-effects %) a-list)

This didn't do what I expected.  After a little while, I found the
doseq macro.  I re-wrote my code like this:

(doseq [atom a-list]
  (form-with-side-effects atom))

And now everything works great.  What I don't understand is why the
doseq macro is required instead of the mapping operation.  Could
somebody explain why Clojure has this different form for functions
that have side effects?

Sean


--~--~-~--~~~---~--~~
You 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: doseq vs. map

2009-04-02 Thread Sean

Thanks for the response everyone!  I was able to get it working.  If I
understand what everyone is saying, the following statement is true:

In Clojure, laziness is the rule not the exception.



On Apr 2, 10:29 pm, Matt Revelle  wrote:
> Were you in #clojure earlier?  This came up there and pjstadig and I
> raced to implement "domap" and then slashus2 pointed out there was no
> need for it to be a macro.
>
> http://gist.github.com/89249
>
> (defn domap
>   "A map for side-effects.  The argument order is the same as map, but
> unlike map the function results are not retained.  Takes a function
> followed by any number of collections and applies the function to the
> first item in each coll, then the second etc.  Returns nil."
>   [fn & colls]
>   (let [num-colls (count colls)]
>     (doseq [args (partition num-colls (apply interleave colls))]
>       (apply fn args
>
> On Apr 2, 10:20 pm, Daniel Jomphe  wrote:
>
> > Daniel Jomphe wrote:
> > > Basically, since your map wasn't needed, it wasn't "realized"/
> > > executed. Laziness.
>
> > Better said:
>
> > Basically, since your map's results weren't used, it wasn't
> > "realized"/
> > evaluated. That's why you didn't see your expected side effects.
> > Laziness.
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



Array of primitives

2009-04-02 Thread Sean

I'm working with AWT, and there is a method that requires a float[]
(The java.awt.BasicStroke constructor).  Is it possible to directly
create an array of primitives directly in Clojure, or do I need to
create a utility class in Java?
--~--~-~--~~~---~--~~
You 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: A large Clojure deployment

2009-04-07 Thread Sean

Okay wow...  it'll take some time to fully appreciate this.

Can you comment on your hardware stack?  How many servers are you
using?  Is there an RDBMS in there somewhere?

How was deployment?

Looks awesome, thanks for sharing!

On Apr 7, 10:41 am, Stuart Sierra  wrote:
> Here:  http://www.altlaw.org/
>
> About 4000 lines of Clojure code, 2500 of Java, powering a web site
> with well over a million pages, averaging around 10,000 visitors a
> day.
>
> Some of what I'm using:
> Restlet
> StringTemplate
> Solr
> Hadoop
> Apache Java Commons
> markdownj
> cpdetector
> JRuby
>
> Most of the code is online, GPL'd, athttp://github.com/lawcommons
>
> -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: ATTN contrib authors: Automatic documentation for clojure.contib

2009-04-14 Thread Sean

This feature would be very useful, as I know I spend too much time in
re-implementing stuff that exists in contrib. However, contrib isn't
the only library that needs to be documented.  Besides the doc-string
metadata, is there any type of Clojure-doc, similar to Java-doc?

Is there utility to generate HTML docs that is part of Clojure contrib/
core?

On Apr 14, 7:37 am, Rich Hickey  wrote:
> On Apr 13, 11:14 pm, Tom Faulhaber  wrote:
>
>
>
> > [This is specifically for contrib authors, but also for anyone whose
> > interested.]
>
> > There was some discussion (or maybe the wailing and gnashing of teeth)
> > about the fact that there's lots of cool functionally coming into
> > clojure.contrib but no easily accessible documentation. I had been
> > thinking about this already and figured maybe I'd set up the framework
> > for fixing it.
>
> > My idea is to use the namespace and var metadata to auto-generate a
> > set of documentation that has:
> > - an overview page that lists the namespaces in contrib and presents a
> > summary of each derived from the namespace metadata.
> > - each entry on the namespace overview page will have a link to an API
> > page for that namespace. That page will be basically like the API page
> > on clojure.org.
> > - probably should have an index page as well, but I haven't thought
> > about it much.
> > - an ability to link from a namespace to a custom created piece of
> > documentation (like the nice DatalogOverview that Jeffery wrote).
>
> > I've written the code that builds (a first cut of) this stuff from the
> > namespaces. It uses the following metadata:
>
> > On the namespace:
> > - :author to supply a string with the author(s) name(s)
> > - :wiki-doc to supply a wiki specific doc string (that can include
> > wiki markup) or, if that doesn't exist, we fall back to
> > - :doc the default doc string
>
> > On the vars, I use:
> > :wiki-doc and :doc, as above
> > :macro - to indicate if it's a macro
> > :arglists to grab the arglist
>
> > The last two are set automatically by defn and defmacro.
>
> > AUTHORS PLEASE NOTE: In order for this to be useful these fields need
> > to be filled in for your contributions. The system will work without
> > it, just not as nicely.
>
> > The next stage of my plan is to build a robot that watches the
> > subversion repository and updates the doc on every checkin. Therefore
> > the doc will typically correspond to the tip of the tree.
>
> > To avoid thinking too hard, I'm planning to use the wiki on
> > clojure.contrib's googlecode page because (a) there's almost nothing
> > on it now and (b) it's easy to use subversion to update stuff there.
> > Whether this is the right place long-term is another question that we
> > can worry about once it's running.
>
> > Does all of this seem like the right direction? Comments? Suggestions?
>
> The wiki on clojure.contrib's googlecode page is definitely the right
> place for the contrib docs, contrib members should please feel free to
> use it. That's one of the reasons I moved to googlecode.
>
> Thanks,
>
> 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: [ClojureScript] Re: clojure.spec

2016-05-28 Thread sean
Is it likely that we’ll see a common clojure.spec implementation in .cljc files 
rather than separate .clj / .cljs files?

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: David Nolen

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [ANN] Clojure 1.9.0-alpha5

2016-06-07 Thread sean
Thanks Alex. Based on what crossclj.info shows, I suspect you may be right that 
almost no one cares 😊

https://crossclj.info/fun/clojure.core.incubator/seqable?.html

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: Alex Miller

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [ANN] Clojure 1.9.0-alpha5

2016-06-07 Thread sean
As a completely non-scientific data point, we had precisely one place in our 
30k+ lines of code where we can use bigdec? And there is also precisely one 
place we could use biginteger? 😊

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: Alex Miller

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [ANN] clojure-future-spec, a backport of clojure.spec for 1.8

2016-06-30 Thread sean
I can’t help but think you’re making it way more complicated than it needs to 
be.

Define ::config in example.spec, and in example.core use :example.spec/config 
(and, yes, require the example.spec namespace).

You need to avoid circular namespace dependencies.

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: Sam Estep

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Thoughts on clojure.spec

2016-07-18 Thread sean
Well, both Alex and Rich have said the change is deliberate and there are no 
plans to change that decision – and Rich talked about ways you can add return 
value testing manually based on specs (if you want, but he won’t help you) – so 
it seems like a “closed” topic to me? (and Alex has shut down a couple of other 
threads that have continued on past a clear line of decision)

I was sad to see :ret checking go away but I accept Rich’s line of thinking on 
this and I’ll adjust my workflow accordingly. I find Rich’s point that 
instrumentation is now about ensuring functions are _called_ correctly rather 
than trying to establish that they _behave_ correctly oddly compelling, now 
that I’ve had some time to think about it and play with it 😊

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: Beau Fabry

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: can clojure java.jdbc function 'result-set-seq' add option to supportcustom 'result-set-read-column' ?

2016-08-06 Thread sean
Hi Joe,

I’m starting to see more requests for per-database customization in a 
multi-database environment so this is definitely something I’d consider. Could 
you create a JIRA issue for tracking purposes, along with any suggestions you 
have about how this might work – and remain performant? 
http://dev.clojure.org/jira/browse/JDBC

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: Xiangtao Zhou

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: can clojure java.jdbc function 'result-set-seq' add option tosupportcustom 'result-set-read-column' ?

2016-08-07 Thread sean
Thank you! I’ll take a look at this while I’m back at work this week. 

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: Xiangtao Zhou

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [ANN] Clojure 1.9.0-alpha11

2016-08-19 Thread sean
The cljsbuild.crossover namespace has (import …) instead of (:import …) – file 
a bug report against that project so the maintainer can update it to be 
compatible with Clojure 1.9.0.

The error message says In: [3 0] so you can see it is the 0th element of the 
item with index 3 in the ns form that failed the spec.

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: Rangel Spasov

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-20 Thread sean
I disagree (strongly) with your position here Brian. I’ll try to explain 
clearly why but first a little background…

At World Singles, we’ve always done multi-version testing against the stable 
version of Clojure that we plan to use in production and also against the very 
latest master SNAPSHOT. This gives us an early heads up when a breaking change 
is introduced. When the ns spec hit master, our build broke. We had three 
namespaces with incorrect syntax – based on the documentation and what all the 
books and tutorials show – so we simply fixed them (one was require, two were 
import). Luckily none of the libraries we rely on had similar breakages.

Then we moved to Alpha 11 and found another namespace with require – clearly 
our tests don’t have sufficient coverage (duly noted, JIRA issue to follow I 
expect).

Despite having to fix our code, we welcome the stricter compiler checking here. 
There are very few things in language design that frustrate me more than 
preserving bad compiler behavior in the name of “backward compatibility” on the 
grounds that “if we fix this, people who have code that we never intended to 
work will see breakages, and be forced to correct their bad code”. That’s what 
you’re asking for here: that Clojure/core preserve unintended behavior so that 
people who have code that works “accidentally” aren’t forced to modify their 
code to match what has always been intended.

Why do I feel so strongly about this? A few things… I built one of the first 
ANSI-validated C compilers which focused on “the letter of the law” as far as 
flagging undefined, unspecified, and implementation-defined behavior. After 
that, I was on the ANSI C++ Standards Committee for eight years where we had to 
deal with this same sort of issue over and over again in terms of deciding what 
unintended legacy behaviors should be enshrined as standard vs outlawed (vs 
pushed to one of those three behaviors). After all that standards work, I then 
had to deal with Macromedia / Adobe ColdFusion on and off since 2001: a product 
that values backward compatibility so deeply that it repeatedly does exactly 
what you’re asking Clojure/core to do – it won’t fix any number of bugs because 
they might break unintentionally working code. You can’t begin to imagine what 
decades of that position does to a language – it’s a horrible, inconsistent, 
mess of a language, full of special cases, warts, and surprising behavior. I 
wouldn’t wish that on any sane developer.

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: Brian Marick

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: results from sort-by are not sorted

2019-05-05 Thread sean
(sort-by #{:age} …) will use the set #{:age} as the keyfn, and both (#{:age} {:age 3, :name “luo”}) and (#{:age} {:age 1, :name “sheng”}) both return :age – because both maps contain the key in the set. As far as sort-by is concerned, both hash maps compare equal. What you want is (sort-by :age …) so you the keyfn pulls the value corresponding to :age out of the hash maps. That will produce 3 from {:age 3, :name “luo”} and 1 from {:age 1, :name “sheng”} so they will sort appropriately. Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEANAn Architect's View -- http://corfield.org/"If you're not annoying somebody, you're not really alive."-- Margaret Atwood From: sheng.peisi@gmail.comSent: Sunday, May 5, 2019 7:48 PMTo: ClojureSubject: results from sort-by are not sorted Hey there,  in my lein repl,  (sort-by #{:age} [{:age 3,:name "luo"},{:age 1,:name "sheng"}])  returns  ({:age 3, :name "luo"} {:age 1, :name "sheng"})  rather than  ({:age 1, :name "sheng"}, {:age 3, :name "luo"}).  Why?-- You received this message because you are subscribed to the GoogleGroups "Clojure" group.To post to this group, send email to clojure@googlegroups.comNote that posts from new members are moderated - please be patient with your first post.To unsubscribe from this group, send email toclojure+unsubscr...@googlegroups.comFor more options, visit this group athttp://groups.google.com/group/clojure?hl=en--- You received this message because you are subscribed to the Google Groups "Clojure" group.To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com.For more options, visit https://groups.google.com/d/optout. 



-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: No "clojure --version" switch

2019-05-07 Thread sean
Or just type:   clojureor:  clj And it announces the version and starts a REPL – which is documented usage. I think one of the “issues” here is that clojure / clj are scripts that have an inherent version behind them (clojure -Sdescribe) but the version of Clojure that they run with is context-dependent. deps.edn can specify any Clojure back to … Clojure 1.1 it seems: seanc@DESKTOP-QU2UJ1N:~$ clojure -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.1.0"}}}'Clojure 1.1.0user=> *clojure-version*{:major 1, :minor 1, :incremental 0, :qualifier ""}user=> Given that, I think that a –version option on clojure would be misleading since it is not reporting the version of the clojure / clj scripts. Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEANAn Architect's View -- http://corfield.org/"If you're not annoying somebody, you're not really alive."-- Margaret Atwood From: Alan ThompsonSent: Tuesday, May 7, 2019 4:50 PMTo: clojureSubject: No "clojure --version" switch Seems we should have the "--version" switch that is pretty universal.  Right now, the best one can do is  > clojure --eval "(clojure-version)""1.10.0" which is hard for a new user to figure out.  Jira ticket? Alan-- You received this message because you are subscribed to the GoogleGroups "Clojure" group.To post to this group, send email to clojure@googlegroups.comNote that posts from new members are moderated - please be patient with your first post.To unsubscribe from this group, send email toclojure+unsubscr...@googlegroups.comFor more options, visit this group athttp://groups.google.com/group/clojure?hl=en--- You received this message because you are subscribed to the Google Groups "Clojure" group.To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/CAN67zA0yrhNhfx2vwH%3D-oy1kbJPA0EyGwwvg%2BFX3kyV4tgz3Qg%40mail.gmail.com.For more options, visit https://groups.google.com/d/optout. 



-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/5cd24a6f.1c69fb81.bb91f.699f%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.


RE: Re: [ANN] Cognitect Labs' aws-api 0.8.345

2019-07-06 Thread sean
That’s new in Clojure 1.10. I thought Cognitect AWS stuff required 1.10 from the get-go but I assume you had it working on 1.9? Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEANAn Architect's View -- http://corfield.org/"If you're not annoying somebody, you're not really alive."-- Margaret Atwood From: Hadil SabbaghSent: Saturday, July 6, 2019 1:50 PMTo: ClojureSubject: Re: [ANN] Cognitect Labs' aws-api 0.8.345 Since installing aws-api 0.8.345, I am getting the following error: ```Unable to resolve symbol: requiring-resolve in this context, compiling:(cognitect/aws/http.clj:63:10)```On Saturday, July 6, 2019 at 12:14:59 PM UTC-7, David Chelimsky wrote:Cognitect Labs' aws-api 0.8.345 is now available! CHANGESUpdate pom.xml with same deps as deps.edn #86README: https://github.com/cognitect-labs/aws-api/API Docs: https://cognitect-labs.github.io/aws-api/Changelog: https://github.com/cognitect-labs/aws-api/blob/master/CHANGES.mdLatest Releases of api, endpoints, and all services: https://github.com/cognitect-labs/aws-api/blob/master/latest-releases.edn -- You received this message because you are subscribed to the GoogleGroups "Clojure" group.To post to this group, send email to clojure@googlegroups.comNote that posts from new members are moderated - please be patient with your first post.To unsubscribe from this group, send email toclojure+unsubscr...@googlegroups.comFor more options, visit this group athttp://groups.google.com/group/clojure?hl=en--- You received this message because you are subscribed to the Google Groups "Clojure" group.To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/4d2f950b-db35-4437-9172-e1e36b0502ef%40googlegroups.com.For more options, visit https://groups.google.com/d/optout. 



-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/5d21151a.1c69fb81.f193c.dbd6%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.


RE: clojure.spec

2016-05-23 Thread sean
I was a bit puzzled by the :req-un / :opt-un stuff in maps. Am I right that 
there is a requirement here for the keys to be namespaced but the actual 
namespace is completely irrelevant / ignored?

(defn thing [m]
  (+ (:a m) (:b m) (or (:c m) 1)))
(s/fdef thing
:args (s/cat :map (s/and (s/keys :req-un [:x/a :y/b]
 :opt-un [:z/c])
 (s/map-of keyword? number?)))
:ret  number?)

I tried several namespace prefixes here and it seemed I can use anything and 
they don’t even need to be consistent.

Wouldn’t it be easier to just allow un-namespaced keywords here? Or is there 
some aspect of the namespacing here that I’m missing?

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: Rich Hickey

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: clojure.spec

2016-05-23 Thread sean
OK, that explains a lot. Thank you. That needs to be clarified on the web page 
I think…

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: Alex Miller

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [ANN] Clojure 1.9.0-alpha1

2016-05-24 Thread sean
Bear in mind that you can catch the exception thrown by a pre-/post-condition 
so printing to stdout is not the right behavior.

Are you thinking about something like this?

(when-not (s/valid? spec arg)
  (throw (AssertionError. (with-out-str (s/explain spec arg))
  (ex-info “SpecFailure” (s/explain-data spec arg)

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org

From: Mark Engelberg

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


cond-> variant?

2014-02-11 Thread sean
I use cond-> quite a lot but I find myself often wanting a version that uses 
predicate functions rather than expressions which would seem more “threaded”. 
Am I just missing a better way to write these things?


For example:


(cond-> accounts

  (empty? accounts) (conj “stuff”))


That just screams for something like:


(condp-> accounts

  empty? (conj “stuff”))


Then you could thread the predicates:


(condp-> a

  p1 (f1 args)

  p2 (f2 args))


which would be:


(let [x (if (p1 a) (f1 a args) a)]

  (if (p2 x) (f2 x args) x))


Suggestions?






Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org
World Singles, LLC - http://worldsingles.com

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


Re: soft question: should remote channels appear like local channels

2014-01-30 Thread sean
My question would be “Why not?”


If you have a client using core.async and a server using core.async and you 
have a library that feeds data from certain channels back and forth over 
websockets, then you have channels everywhere.


So I’m not sure why you think your “con” is actually a thing?






Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org
World Singles, LLC - http://worldsingles.com






From: t x
Sent: ‎Thursday‎, ‎January‎ ‎30‎, ‎2014 ‎9‎:‎43‎ ‎PM
To: clojure@googlegroups.com





Hi,

With apologies for a soft question:

This question is NOT:

  I'm in a situation where client = cljs, server = clj, and I want to
figure out how to setup a core.async channel, using pr-str and
edn/read-string, where I can seamlessly push data back and forth
between client and server.

This question is:

  Should I do the above?

  The pro being: yay, channels everywhere, everything looks the same.

  The con being: a local core.async channel and a remote core.async
channel over a websocket are _NOT_ the same thing, and thus should not
appear to be the same thing.

## Responses:

Although detailed responses are always appreciated, given the nature
of this "soft" question, responses of "go read _link_" are perfectly
welcome too.

I suspect someone in this world has thought deeply about the question,
written up their insights, and pointing me at this primary resource
(rather than trying to summarize it in a three paragraph email) is
perfectly fine too.

Thanks!

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

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Atomic execution of a SELECT and UPDATE

2010-07-12 Thread Sean
To learn Clojure, I'm writing a system that could be compared to
fold...@home. I have a database table of jobs that need to be done,
where each row has an id, some data, and a status. The server that
issues these jobs to clients is multi-threaded, and I want to ensure
that it never issues the same job to two clients. I do a SELECT on the
table to get the id and the data, and then an UPDATE to mark the row
with that id as being checked out (the SELECT only grabs a row that
has a not-checked-out status). The obvious problem with this, is that
another thread might select the same row between the SELECT and
UPDATE. I've thought of a few possibilities, but as I'm new to
clojure, I was hoping for some advice on which would be best practice,
and if I'm making bad assumptions.

1) I add a constraint to my UPDATE, so that it only updates rows that
aren't checked out. If the execution of this statement returns a 0, I
know there was a collision, and I SELECT a different row until the
UPDATE returns 1. I fear that if this cycled once, it would cycle
constantly until the server quieted down.

2) I perform all this SQL inside a dosync transaction. The call to
JDBC's excuteUpdate would be the very last action, and the only side-
effect. As I know very little about the inner workings of dosync, I
fear I may be missing something obvious.

3) Perhaps some combination of #2, with autoCommit turned off, and/or
rolling the database back to a saved state in the event of failure?
Can't quite wrap my head around the best way to do this.

Any thoughts or pointers? Help would be very much appreciated. Thanks!

Sean

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


REPL

2010-09-08 Thread Sean
Hi,

I'm new to Clojure. This is also my first time posting here.
When I use REPL and print something out, I always get a nil printed.
For example, (print "Clojure"), I got: clojurenil. Where does the nil
come from?

Thanks a lot!

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

2008-12-11 Thread Sean Spencer
That was one of the best explanations of code as data I've ever read.
Kudos!

On Thu, Dec 11, 2008 at 4:44 PM, Randall R Schulz  wrote:

>
> On Thursday 11 December 2008 13:37, Paul Barry wrote:
> > I've been reading the latest chapter from Stuart's book, Chapter 7:
> > Macros, and he makes this statement:
> >
> > "Clojure has no special syntax for code. Code is simply Clojure data.
> > This is true for normal functions, but also for special forms and
> > macros. Consider a language with syntax, such as Java. ..."
> >
> > It seems to me that just like all lisps, Clojure has syntax.  The
> > first and most obvious piece of syntax is the parenthesises.  Lists
> > start with an open paren and end with a closing paren.  This is
> > syntax and you can't change it with a macro.
>
> Punctuation is not syntax. Lisp can be said to have a syntax, that of
> the S-Expression. Beyond that, as someone else pointed out in another
> thread here recently, when we write Lisp code, we're basically writing
> directly the AST that other languages would need a parser implementing
> a complicated grammar to produce.
>
>
> > Next is the single quote, which is just an alias for quote.
> > Somewhere along the line, someone decided that (quote foo) was too
> > verbose and they wanted 'foo to be syntactic sugar for (quote foo).
> > That wasn't and can't be done as a macro.  For example, if I wanted
> > to define my own single quote, say $foo, I can't without modifying
> > the parser.
> >
> > Clojure goes on to add a lot of syntax.  The literal syntax for
> > vectors [], maps {}, sets #{}, functions #(), keywords :, etc. are
> > all syntax, not possible with macros, and then there are all the
> > "reader macros" that are listed in Section 2.2, Comment ;, Deref @,
> > Meta ^, Metadata #^, regex #"", syntax-quote `, unquote ~,
> > unquote-splicing ~@, and var-quote #'.
>
> All these things are syntactic sugar. Shorthand ways to write things
> that have vanilla S-Expression counterparts. Again, I would not call
> them syntax.
>
>
> > So is it really valid to claim Clojure has no syntax?
>
> Very nearly so.
>
>
> Randall Schulz
>
> >
>

--~--~-~--~~~---~--~~
You 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: android app development with clojure

2009-02-06 Thread Sean Spencer
I looked into this briefly; I'm amazed at the progress you've made.  Please
keep updating!

On Fri, Feb 6, 2009 at 11:29 AM, Remco van 't Veer wrote:

>
> Got startup time down to 5 seconds by completely eliminating the use
> of lispreader and putting of loading the xml, set and zip namespaces.
> There's no clear bottlenecks left to fix.
>
>
> On Fri, Feb 6, 2009 at 1:06 AM, Remco van 't Veer 
> wrote:
> > I've managed to get to startup time down from 12 seconds to 7 on the
> > emulator and hope get it below 4 seconds tomorrow.  A lot of time is
> > spend in LispReader when the core constants are initialized.  I've
> > altered the compiler to emit type specific code for the basic cases,
> > thus bypassing LispReader.  Need to learn more about GeneratorAdapter,
> > and need sleep, before I can speedup the loading of, for instance, seq
> > contants.
> >
> > My changes are available at github; http://github.com/remvee/clojure
> >
> > Remco
> >
> >
> > On Wed, Feb 4, 2009 at 5:55 PM, Remco van 't Veer 
> wrote:
> >> Having a lisp to do android app development is definately worth some
> efford.
> >> Kawa already has some android support in svn trunk but it doesn't seem
> in a
> >> usable state; my experiments break because a lot of expressions do not
> seem
> >> to compile AOT. The parts that do compile are very fast on the other
> hand.
> >>
> >> But if it comes down to app development I would of course prefer clojure
> >> over kawa's schema and scheme over java..
> >>
> >> I hope to do some tracing to find out what slowing down the startup
> later
> >> this week and will keep the list in formed. If anybody has any
> suggestions
> >> please yes pretty please.
> >>
> >> Remco
> >>
> >> On Feb 4, 2009 3:59 PM, "igorrumiha"  wrote:
> >>
> >> On Feb 4, 10:12 am, "Remco van 't Veer"  wrote: >
> >> Caching Reflector.getMethods,...
> >>
> >> I would also be interested in running Clojure on the Android. I tried
> >> running a "Hello world" application on the emulator but the startup
> >> time od 15 seconds put me off. There is definitely room for
> >> improvement. I don't have much experience in Java (zero would be the
> >> best description) so I don't really know where to start with
> >> profiling.
> >>
> >> I've run the application through the Instrumentation mechanism and the
> >> trace shows me that much of the time is spent in a huge amount of
> >> calls to some character compare methods (something like 20 calls)
> >> (I don't have the trace with me right now so I don't have the exact
> >> numbers and I don't know the exact method name).
> >>
> >> I find this curious when I know that all code is compiled ahead of
> >> time. When I get the chance I will recreate that call graph an upload
> >> it to the files section.
> >>
> >> --
> >> IgorR
> >> >>
> >>
> >
>
> >
>

--~--~-~--~~~---~--~~
You 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: ATTN contrib authors: Automatic documentation for clojure.contib

2009-04-15 Thread Sean Devlin

Check out the thread below in the Compojure group.  Specifically, look
for the comment by Brain Carper

http://groups.google.com/group/compojure/browse_thread/thread/67d92ceb4128a375?hl=en

Brian's code:

http://briancarper.net/clojure/compojure-doc.clj

This might be an alternate approach to the problem.

On Apr 14, 5:59 pm, Tom Faulhaber  wrote:
> Jason,
>
> Thanks for the offer. I may take you up on it as I get this into
> "production" such as it is.
>
> Sean,
>
> Nothing that I found in contrib (but who knows, there's no
> documentation :-)). Rich posted some code (which I'm using in a
> modified version in the center of things) for doing the API paage for
> clojure.org here:http://paste.lisp.org/display/77339
>
> When I get my code looking anything other than nasty (and anyone who's
> looked at pprint knows that's a low bar!), I'll at least put it up on
> github. Eventually I may add it to contrib, too, if the community
> feels it should go (but let's solve the problem ahead of us).
>
> Laurent,
>
> You seem to be going in the opposite direction from Konrad and I would
> worry about the duplication. I would be more inclined to think about a
> single markup format for :doc strings that could be converted for the
> various uses. But that's really a language change at some level, so
> I'd rather defer that until we see how this stuff is used.
>
> But to be honest, I haven't read your comments that closely because
> today has been a long day. Maybe later tonight...
>
> Thanks for all the feedback, guys!
>
> Tom
--~--~-~--~~~---~--~~
You 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: Possible contrib contribution: clojure.contrib.timing

2009-04-15 Thread Sean Devlin

Start by putting your code on github or something similar :)

On Apr 14, 8:01 pm, Chris  wrote:
> While playing around with clojure I've found the (time ...) macro
> isn't as powerful as I'd like.  To fix this I made a timing library to
> help me figure out where all my runtime is going.  If other people
> find it useful I'd like to get it into contrib.
>
> Simple overview of clojure.contrib.timing:
>
> clojure.contrib.timing/with-timing
> ([expr {:name :timing-map}])
>   "Executes 'expr', returns result of expr, and records its time to
> execute.  Each time to execute is saved for processing later.  This
> allows you to get mean/median/mode/cumulative runtimes for the
> expression.
>     - expr: The expression to evaluate
>     - name: value to name expression, defaults to (str expr).
>       timing-map: Reference to a map of recorded timings.  Defaults to
> the shared global *timings."
>
> clojure.contrib.timing/analyze-timing
>   "Returns a hashmap of 'name' : '(analysis-func timing-list)'.  All
> times are converted to milli seconds.  If timing-map is not given it
> defaults to the shared global *timings*."
>   ([analysis-func timing-map]
>
> There are some other helper funcs/macros, but the above two are the
> most important.  Future work here could give us a nice performance
> timing library written in clojure, and powerful enough to allow
> clojure programs to know how fast they are and tune themselves (think
> serialized vs. parallelism, hostnames to connect to, etc...).
>
> The timing-map is a ref to a map.  Each value is a list of every
> runtime of the expression.  Every time the expression runs it's time-
> to-run is cons-ed to the front of that expression's timing list.
>
> Storing of the runtime into the ref is a side-effect of (with-
> timing ...).  I was torn on this point, but I think it's the right
> thing to do for now; performance is a side effect of code execution,
> so it isn't that horrible for it to be stored as a side-effect.  This
> is how the original (time ...) macro works; it reports the runtime to
> stdout instead of returning it.
>
> I'm not sure what the protocol here is for getting this thing out for
> review and possible inclusion.  Is anyone interested?  How do I get my
> changes out there for people to review?
>
> Thanks!
>  Chris
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



Oracle and Clojure

2009-04-20 Thread Sean Devlin

Okay, I'm willing to bet this crowd has already seen this:

http://www.sun.com/third-party/global/oracle/index.jsp

Any thoughts on how this affects Clojure?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Oracle and Clojure

2009-04-20 Thread Sean Devlin

I guess I should have stated my initial concern better.  I've had to
use several Oracle products in the past (PL/SQL & 9i), and they
weren't developer friendly.  I'm worried about the JVM becoming less
open than it currently is.  I can see a lot of technologies that drive
the open source world, and this group, being compromised

*Java language documentation
*Will NetBeans be developed any longer?  Oracle has their own Java
IDE, and it sucks royally.
*Will Oracle stop providing the JVM and JDK for free?  This will have
a HUGE affect on continued JVM adoption and WORA in ten years.
*Will Java continue to be open source?
*What the hell is going to happen to JDBC?

Of course, I won't even begin to get into MySQL issues.  Time to
install Postgres...

Has anyone here been able to install Clojure on IcedTea?

On Apr 20, 9:22 am, hank williams  wrote:
> On Mon, Apr 20, 2009 at 9:13 AM, Sean Devlin  wrote:
>
> > Okay, I'm willing to bet this crowd has already seen this:
>
> >http://www.sun.com/third-party/global/oracle/index.jsp
>
> > Any thoughts on how this affects Clojure?
>
> No effect.
>
>
>
> --
> blog: whydoeseverythingsuck.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
To unsubscribe from 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: Oracle and Clojure

2009-04-21 Thread Sean Devlin

Thanks to *everyone* for responding!  I can see that I was over
reacting yesterday.  Time for me to stop worrying and get back to
coding.

Sean

On Apr 21, 2:05 am, Adrian Cuthbertson 
wrote:
> There are some precedents - the acquisition of SleepyCat (berkeley db,
> et al) - still readily available under GPL compatible licenses.
>
> On Tue, Apr 21, 2009 at 7:47 AM, AlamedaMike  wrote:
>
> >>> I can see a lot of technologies that drive the open source world, and 
> >>> this group, being compromised
>
> > Nothing's going to happen, for the simple reason that the cost to
> > Oracle's reputation would far outweigh anything they might gain from
> > charging for open-source products. The ultimate effect would be to
> > simply route around any attempt to close the sources or to restrict
> > changes.
>
> > Oracle didn't become the world's third largest software company by
> > being stupid.
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



Google announcement, version 1.0 & SCM Holy War (not really)

2009-04-24 Thread Sean Devlin

There recently was a ton of traffic about SCM in the "Path to 1.0"
thread.  Google made the following announcement:

http://google-code-updates.blogspot.com/2009/04/mercurial-support-for-project-hosting.html

Does this make changing the SCM tool to Hg a real possibility?  While
this might not be such a big deal for Clojure core, I would *LOVE* an
easy way to fork contrib, and I bet I'm not the only one.

Can this be part of the 1.0 push?


--~--~-~--~~~---~--~~
You 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: Clojure 1.0

2009-05-04 Thread Sean Devlin

Thank you and congrats!

On May 4, 9:46 am, AlamedaMike  wrote:
|> Congratulations, Rich! And thanks for all your hard work. Having a
1.0
|> release out to help adoption in the workplace environments that we
|> need to get into.

Indeed, this is the case where I work.  Having a stable version to
target will make it possible for me to develop projects on the clock.

--~--~-~--~~~---~--~~
You 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, SAP and JCo

2009-05-04 Thread Sean Devlin

Hi,
Has anyone else here been using Clojure to interact with SAP?  Or, are
there any JCo experts in the house?

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



Help: Java code works, Clojure code doesn't

2009-05-05 Thread Sean Devlin

Okay, I've got code that works in Java but I can't get working in
Clojure.  Here's the code in Java

public class TutorialConnect1 extends Object {
  JCO.Client mConnection;
  public TutorialConnect1() {
try {
  // Change the logon information to your own system/user
  mConnection = JCO.createClient(...); //Connection parameters
  mConnection.connect();
  System.out.println(mConnection.getAttributes());
  mConnection.disconnect();
}
catch (Exception ex) {
  ex.printStackTrace();
  System.exit(1);
}
  }
  public static void main (String args[]) {
TutorialConnect1 app = new TutorialConnect1();
  }
}

It simply prints some connection attributes about my system.  Here's
the same code in Clojure

(let [sap-con (com.sap.mw.jco.JCO/createClient ... )] ;connection
attributes
   (do
 (. sap-con connect)
 (println (. sap-con getAttributes))
 (. sap-con disconnect)))

I can successfully create the connection object in Clojure, but I get
an error in the following s-exp

(. sap-con connect)

The error I get is :

#

The SAP library I'm using does rely on some native methods.  The only
guess I have right now is that the native methods are being linked to
properly.

Can anyone give me a hand?

Sean
--~--~-~--~~~---~--~~
You 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: Help: Java code works, Clojure code doesn't

2009-05-05 Thread Sean Devlin

That's a really good point, thanks for mentioning.  Unfortunately,
after looking into this, it's not the culprit.  The java code's
classpath is a _subset_ of the clojure code's classpath.  Also, the
DsrIPassport class doesn't exist.  It was depricated years ago...

The Clojure code appears to be initialized differently from the Java
code.

I'll try adding a dummy class, see if that works...

On May 5, 11:41 am, David Chamberlin  wrote:
> It sounds like you maybe haven't included all the necessary stuff in
> your classpath.
>
> If you are testing in REPL, then you need to include everything you
> need in the classpath the the invoked JVM, for example:
>
> java -classpath my-jar-file-containing-DsrlPassport.jar;clojure.jar
> clojure.main
>
> On 5 May, 15:54, Sean Devlin  wrote:
>
> > Okay, I've got code that works in Java but I can't get working in
> > Clojure.  Here's the code in Java
>
> > public class TutorialConnect1 extends Object {
> >   JCO.Client mConnection;
> >   public TutorialConnect1() {
> >     try {
> >       // Change the logon information to your own system/user
> >       mConnection = JCO.createClient(...); //Connection parameters
> >       mConnection.connect();
> >       System.out.println(mConnection.getAttributes());
> >       mConnection.disconnect();
> >     }
> >     catch (Exception ex) {
> >       ex.printStackTrace();
> >       System.exit(1);
> >     }
> >   }
> >   public static void main (String args[]) {
> >     TutorialConnect1 app = new TutorialConnect1();
> >   }
>
> > }
>
> > It simply prints some connection attributes about my system.  Here's
> > the same code in Clojure
>
> > (let [sap-con (com.sap.mw.jco.JCO/createClient ... )] ;connection
> > attributes
> >                            (do
> >                              (. sap-con connect)
> >                              (println (. sap-con getAttributes))
> >                              (. sap-con disconnect)))
>
> > I can successfully create the connection object in Clojure, but I get
> > an error in the following s-exp
>
> > (. sap-con connect)
>
> > The error I get is :
>
> > # > writer/DsrIPassport (NO_SOURCE_FILE:0)>
>
> > The SAP library I'm using does rely on some native methods.  The only
> > guess I have right now is that the native methods are being linked to
> > properly.
>
> > Can anyone give me a hand?
>
> > Sean
--~--~-~--~~~---~--~~
You 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: Help: Java code works, Clojure code doesn't

2009-05-05 Thread Sean Devlin

Another great idea.  Following this technique, the Java code executed
perfectly when called from Clojure. Time to check my configuration
again.  Thanks for the tip!

On May 5, 12:59 pm, Adrian Cuthbertson 
wrote:
> Perhaps you could try calling your java class directly from the repl...
>
> (TutorialConnect1.)
>
> That might highlight the problem - your java stack strace might give
> some clues. It does sound like a classpath problem of some sort.
>
> Rgds, Adrian.
>
> On Tue, May 5, 2009 at 6:04 PM, Sean Devlin  wrote:
>
> > That's a really good point, thanks for mentioning.  Unfortunately,
> > after looking into this, it's not the culprit.  The java code's
> > classpath is a _subset_ of the clojure code's classpath.  Also, the
> > DsrIPassport class doesn't exist.  It was depricated years ago...
>
> > The Clojure code appears to be initialized differently from the Java
> > code.
>
> > I'll try adding a dummy class, see if that works...
>
> > On May 5, 11:41 am, David Chamberlin  wrote:
> >> It sounds like you maybe haven't included all the necessary stuff in
> >> your classpath.
>
> >> If you are testing in REPL, then you need to include everything you
> >> need in the classpath the the invoked JVM, for example:
>
> >> java -classpath my-jar-file-containing-DsrlPassport.jar;clojure.jar
> >> clojure.main
>
> >> On 5 May, 15:54, Sean Devlin  wrote:
>
> >> > Okay, I've got code that works in Java but I can't get working in
> >> > Clojure.  Here's the code in Java
>
> >> > public class TutorialConnect1 extends Object {
> >> >   JCO.Client mConnection;
> >> >   public TutorialConnect1() {
> >> >     try {
> >> >       // Change the logon information to your own system/user
> >> >       mConnection = JCO.createClient(...); //Connection parameters
> >> >       mConnection.connect();
> >> >       System.out.println(mConnection.getAttributes());
> >> >       mConnection.disconnect();
> >> >     }
> >> >     catch (Exception ex) {
> >> >       ex.printStackTrace();
> >> >       System.exit(1);
> >> >     }
> >> >   }
> >> >   public static void main (String args[]) {
> >> >     TutorialConnect1 app = new TutorialConnect1();
> >> >   }
>
> >> > }
>
> >> > It simply prints some connection attributes about my system.  Here's
> >> > the same code in Clojure
>
> >> > (let [sap-con (com.sap.mw.jco.JCO/createClient ... )] ;connection
> >> > attributes
> >> >                            (do
> >> >                              (. sap-con connect)
> >> >                              (println (. sap-con getAttributes))
> >> >                              (. sap-con disconnect)))
>
> >> > I can successfully create the connection object in Clojure, but I get
> >> > an error in the following s-exp
>
> >> > (. sap-con connect)
>
> >> > The error I get is :
>
> >> > # >> > writer/DsrIPassport (NO_SOURCE_FILE:0)>
>
> >> > The SAP library I'm using does rely on some native methods.  The only
> >> > guess I have right now is that the native methods are being linked to
> >> > properly.
>
> >> > Can anyone give me a hand?
>
> >> > Sean
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



RESOLVED: Java code works, Clojure code doesn't

2009-05-05 Thread Sean Devlin

Yeah, it was a classpath error.  I had to create the following dummy
object:

com.sap.jdsr.writer.DsrIPassport

Once I did that and added it to the classpath, I was golden.  Turns
out this is a known error with SAP JCo

Thanks everyone!

On May 5, 1:49 pm, Sean Devlin  wrote:
> Another great idea.  Following this technique, the Java code executed
> perfectly when called from Clojure. Time to check my configuration
> again.  Thanks for the tip!
>
> On May 5, 12:59 pm, Adrian Cuthbertson 
> wrote:
>
> > Perhaps you could try calling your java class directly from the repl...
>
> > (TutorialConnect1.)
>
> > That might highlight the problem - your java stack strace might give
> > some clues. It does sound like a classpath problem of some sort.
>
> > Rgds, Adrian.
>
> > On Tue, May 5, 2009 at 6:04 PM, Sean Devlin  
> > wrote:
>
> > > That's a really good point, thanks for mentioning.  Unfortunately,
> > > after looking into this, it's not the culprit.  The java code's
> > > classpath is a _subset_ of the clojure code's classpath.  Also, the
> > > DsrIPassport class doesn't exist.  It was depricated years ago...
>
> > > The Clojure code appears to be initialized differently from the Java
> > > code.
>
> > > I'll try adding a dummy class, see if that works...
>
> > > On May 5, 11:41 am, David Chamberlin  wrote:
> > >> It sounds like you maybe haven't included all the necessary stuff in
> > >> your classpath.
>
> > >> If you are testing in REPL, then you need to include everything you
> > >> need in the classpath the the invoked JVM, for example:
>
> > >> java -classpath my-jar-file-containing-DsrlPassport.jar;clojure.jar
> > >> clojure.main
>
> > >> On 5 May, 15:54, Sean Devlin  wrote:
>
> > >> > Okay, I've got code that works in Java but I can't get working in
> > >> > Clojure.  Here's the code in Java
>
> > >> > public class TutorialConnect1 extends Object {
> > >> >   JCO.Client mConnection;
> > >> >   public TutorialConnect1() {
> > >> >     try {
> > >> >       // Change the logon information to your own system/user
> > >> >       mConnection = JCO.createClient(...); //Connection parameters
> > >> >       mConnection.connect();
> > >> >       System.out.println(mConnection.getAttributes());
> > >> >       mConnection.disconnect();
> > >> >     }
> > >> >     catch (Exception ex) {
> > >> >       ex.printStackTrace();
> > >> >       System.exit(1);
> > >> >     }
> > >> >   }
> > >> >   public static void main (String args[]) {
> > >> >     TutorialConnect1 app = new TutorialConnect1();
> > >> >   }
>
> > >> > }
>
> > >> > It simply prints some connection attributes about my system.  Here's
> > >> > the same code in Clojure
>
> > >> > (let [sap-con (com.sap.mw.jco.JCO/createClient ... )] ;connection
> > >> > attributes
> > >> >                            (do
> > >> >                              (. sap-con connect)
> > >> >                              (println (. sap-con getAttributes))
> > >> >                              (. sap-con disconnect)))
>
> > >> > I can successfully create the connection object in Clojure, but I get
> > >> > an error in the following s-exp
>
> > >> > (. sap-con connect)
>
> > >> > The error I get is :
>
> > >> > # > >> > writer/DsrIPassport (NO_SOURCE_FILE:0)>
>
> > >> > The SAP library I'm using does rely on some native methods.  The only
> > >> > guess I have right now is that the native methods are being linked to
> > >> > properly.
>
> > >> > Can anyone give me a hand?
>
> > >> > Sean
--~--~-~--~~~---~--~~
You 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: Add JNDI lookup support for contrib/sql

2009-05-09 Thread Sean Devlin

+1

On May 9, 2:33 am, Mark Derricutt  wrote:
> Hi,
>
> Can we add the following to contrib's sql namespace, it simply adds "jndi"
> as a db-spec scheme ( I also raised this 
> ashttp://code.google.com/p/clojure-contrib/issues/detail?id=39, which google
> decided to set as a defect and I can't change):
>
> Index: src/clojure/contrib/sql/internal.clj
> ===
> --- src/clojure/contrib/sql/internal.clj (revision 776)
> +++ src/clojure/contrib/sql/internal.clj (working copy)
> @@ -56,17 +56,19 @@
>      :subprotocol (required) a String, the jdbc subprotocol
>      :subname     (required) a String, the jdbc subname
>      (others)     (optional) passed to the driver as properties."
> -  [{:keys [datasource username password classname subprotocol subname]
> +  [{:keys [jndi datasource username password classname subprotocol subname]
>      :as db-spec}]
>    (when classname
>      (clojure.lang.RT/loadClassForName classname))
> -  (if datasource
> -    (if username
> -      (.getConnection datasource username password)
> -      (.getConnection datasource))
> -    (java.sql.DriverManager/getConnection
> -     (format "jdbc:%s:%s" subprotocol subname)
> -     (as-properties (dissoc db-spec :classname :subprotocol :subname)
> +  (if jndi
> +    (.getConnection (.lookup (javax.naming.InitialContext.) jndi))
> +    (if datasource
> +      (if username
> +        (.getConnection datasource username password)
> +        (.getConnection datasource))
> +      (java.sql.DriverManager/getConnection
> +       (format "jdbc:%s:%s" subprotocol subname)
> +       (as-properties (dissoc db-spec :classname :subprotocol
> :subname))
>
>  (defn with-connection*
>    "Evaluates func in the context of a new connection to a database then
>
> --
> Discouragement is a dissatisfaction with the past, a distaste for the
> present, and a distrust of the future - Maree De Jong, Life 
> NZ.http://www.talios.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
To unsubscribe from 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: Designing an SQL-based application

2009-05-11 Thread Sean Devlin

Here are my thoughts on the three approaches:

Approach #1:  This seems the most straightforward.  I'd write a
function that takes a map of conditions, and returns a list of
tuples.  You can then do what you want with the list of tuples.

Approach #2:  Remember the first rule of macro club:  Don't write
macros if a function will do.  From what you've described, this
application wraps a simple SELECT * FROM... , and a macro is overkill.

Approach #3:  This is a good approach once you hit the limits of the
first approach, and before you move on to the second approach.

I've written SQL apps in Clojure too.  And I've used approaches 1 and
3.  I only use approach 2 when I really have to, and I try to have the
macro do as little as possible.

In summary, try approaches:

1 -> 3 -> 2

I'll try to throw some code on github this evening so you can see an
example of what I do, and you can decide if it's a good fit for your
application.

Sean

On May 11, 4:05 am, Janico Greifenberg  wrote:
> Hi,
>
> I'm writing an RSS-reader using compojure and clojure.contrib.sql. As
> this is my first project in a functional language, I'm not sure about
> how to design the application. The concrete question I'm having right
> now, is how to encapsulate database queries in functions. For my
> RSS-reader, a basic operations is to display lists of feeds that I
> retrieve with the following code:
>
> (sql/with-connection db
>   (sql/with-query-results
>     feeds
>     ["select id, title from feeds order by title"]
>
> As this happens at a few places in the code, I would like to
> encapsulate it somehow. I see several approaches to this, but I'm
> uncertain which of them is the most idiomatic way to do this in
> Clojure.
>
> (1) The straightforward approach seems to be a function that returns
> the feeds. However, I would have to call (doall feeds) to get the data
> out of the internals of contrib.sql/JDBC and into my application. So I
> guess this would not be the most efficient way.
>
> (2) Another idea is to create a function or macro with-feeds that
> wraps the query and creates a binding to be used inside the body.
>
> (3) Or I could have a function that takes another function as a
> parameter which gets called inside with-query-results and gets feeds
> as parameter.
>
> Which of these variants -- or another one that I did not think of --
> would you recommend?
>
> Janico
--~--~-~--~~~---~--~~
You 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: Designing an SQL-based application

2009-05-11 Thread Sean Devlin

Okay, good point about approach #2.  As I mentioned earlier, I'd use
approach #3 first.  Here's how I'd write your macro as a function

(defn process-feeds
  [feeds body]
  (body feeds))

And I'd call it like this

(process-feeds (get-feeds-s-exp ...) (fn [feeds] body))

The first thing I'd like to mention is that this is VERY similar to
your with-feeds macro.  I think your general approach is sound.
Following is simply my thoughts and opinions on avoiding a macro in
this case.

I like this approach better because it segregates the calling from the
processing, and it lets you test each routine independently.  Also,
forcing the second argument to be a function encourages defining the
function, which in turn encourages testing.

Now, I've made an assumption, and that is the process-feeds has no
side effects.  If you are doing something that is sequential, not
functional (like opening/closing a resource), then a macro makes
sense.

My thoughts in a pithy sound-byte:

If you are abstracting away a function, try to use a function.
If you are abstracting away a sequence, it's the right time to use a
macro.

There are other classes of problems in the function-vs-macro debate,
and I we can save those for another day :)

On May 11, 12:04 pm, Victor Rodriguez  wrote:
> On Mon, May 11, 2009 at 11:32 AM, Sean Devlin  
> wrote:
>
> > Here are my thoughts on the three approaches:
>
> > Approach #1:  This seems the most straightforward.  I'd write a
> > function that takes a map of conditions, and returns a list of
> > tuples.  You can then do what you want with the list of tuples.
>
> > Approach #2:  Remember the first rule of macro club:  Don't write
> > macros if a function will do.  From what you've described, this
> > application wraps a simple SELECT * FROM... , and a macro is overkill.
>
> Yes, you should not write a macro when a function will do, but I think
> you might be misinterpreting the "spirit" of the rule.
>
> Also, the "bottom-up" aspect of programming in Lisp should be kept in
> mind.  In other words, you want to "write a language for solving your
> problem", and you should definitively use macros for that.
>
> So, if a "with-feeds" macro makes sense for the application, do write
> it!  Just make sure the macro is simply syntax sugar for your
> functions.  Following a pattern common in Scheme (at least), the
> implementation would run along the lines of:
>
> (defn call-with-feeds
>   [f]
>   "Call a function with the feeds as an argument"
>   ...)
>
> (defmacro with-feeds
>   [feeds & body]
>   `(call-with-feeds (fn [~feeds] ~...@body)))
>
> Kind regards,
>
> Victor Rodriguez.
>
> > Approach #3:  This is a good approach once you hit the limits of the
> > first approach, and before you move on to the second approach.
>
> > I've written SQL apps in Clojure too.  And I've used approaches 1 and
> > 3.  I only use approach 2 when I really have to, and I try to have the
> > macro do as little as possible.
>
> > In summary, try approaches:
>
> > 1 -> 3 -> 2
>
> > I'll try to throw some code on github this evening so you can see an
> > example of what I do, and you can decide if it's a good fit for your
> > application.
>
> > Sean
>
> > On May 11, 4:05 am, Janico Greifenberg  wrote:
> >> Hi,
>
> >> I'm writing an RSS-reader using compojure and clojure.contrib.sql. As
> >> this is my first project in a functional language, I'm not sure about
> >> how to design the application. The concrete question I'm having right
> >> now, is how to encapsulate database queries in functions. For my
> >> RSS-reader, a basic operations is to display lists of feeds that I
> >> retrieve with the following code:
>
> >> (sql/with-connection db
> >>   (sql/with-query-results
> >>     feeds
> >>     ["select id, title from feeds order by title"]
>
> >> As this happens at a few places in the code, I would like to
> >> encapsulate it somehow. I see several approaches to this, but I'm
> >> uncertain which of them is the most idiomatic way to do this in
> >> Clojure.
>
> >> (1) The straightforward approach seems to be a function that returns
> >> the feeds. However, I would have to call (doall feeds) to get the data
> >> out of the internals of contrib.sql/JDBC and into my application. So I
> >> guess this would not be the most efficient way.
>
> >> (2) Another idea is to create a function or macro with-feeds that
> >> wraps the query and creates 

Re: Macros applied to entire programs

2009-05-11 Thread Sean Devlin

Macros are definitely the tool to do this.  Take a look here at Paul
Graham's "The Roots of Lisp".  In it you'll get an idea of why eval is
so powerful, and why macros are exactly the tool for the job you're
thinking of.

http://lib.store.yahoo.net/lib/paulgraham/jmc.ps

I'll let someone else answer "how" with respect to Clojure.

Sean

On May 11, 11:42 pm, Mark Reid  wrote:
> Hi,
>
> I'm quite new to macros so forgive me if this is a naïve question, but
> is it possible to write macros that are applied to an entire Clojure
> program?
>
> The reason I ask is that, in other threads in this group, some simple
> transformations to improve efficiency of Clojure programs were
> mentioned. In particular, it seems converting `(+ 1 2 3)` to `(+ 1 (+
> 2 3))` can speed things up. Applying such a transformation to my own
> code would be a mindless pattern matching job, and thus perfect for
> automation.
>
> Any suggestions how I might write a Clojure program that takes as
> input another Clojure program and outputs a third one that is
> optimised but semantically equivalent to the input? Are macros the
> right tool for the job in this case?
>
> Thanks,
>
> Mark.
> --http://mark.reid.name
--~--~-~--~~~---~--~~
You 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: Macros applied to entire programs

2009-05-12 Thread Sean Devlin

One thing hit me as I went to bed last night about this problem:

Writing a macro to optimize an s-exp *is* writing a compiler.

The good news is that you *don't* have to write a parser.  There is
some low hanging fruit here (like the + macro described above), but I
imagine there will be a lot of subtle cases that make it very
difficult do to this job.  The biggest issue I see is that you could
accidently apply a macro that creates MORE work for the JVM.

So I'd recommend doing something for the easy cases, and let the JVM
do its job for everything else.

Sean

On May 12, 7:12 am, Paul Stadig  wrote:
> You could write a Clojure program that took in a Clojure program and spit
> out an optimized Clojure program. You could do something similar to the
> meta-circular evaluator, where you step through the program (which is just a
> data structure) recursively matching the head each time against different
> symbols. In your case you could match against '+ and do something special,
> but as Konrad mentioned there are some difficulties with that.
>
> Another possibility would be to write a macro called my-+ or ++ or
> something, and use that instead. This would be a simple solution, because
> you wouldn't have to rewrite all of the matching for all of the different
> forms. The only problem would be that you'd have to change any existing
> code, but at least that way you'd be optimizing the parts of your code that
> need it and it would be clear what you are doing. You could also exclude
> clojure.core/+ from your namespace and write a macro called + that would
> then call clojure.core/+. I'm not sure if the following code works and is
> bug-free, but it'd be something like:
>
> (ns test
>   (:refer-clojure :exclude [+]))
>
> (defmacro +
>   ([] 0)
>   ([a] `(clojure.core/+ ~a))
>   ([a b] `(clojure.core/+ ~a ~b))
>   ([a b & c] `(clojure.core/+ ~a (+ ~b ~...@c
>
> There are some "challenges" to having '+ or my-+ or ++ be a macro, it means
> that you would have to wrap it with a function literal before you could pass
> it to functions like 'map.
>
> It is true that '+ gets inlined with two arguments, so it is faster than
> calling it with three or more arguments. Another possibility would be to
> just discipline yourself to use the two argument form instead of the three
> or more argument form.
>
> Paul
>
> On Mon, May 11, 2009 at 11:42 PM, Mark Reid  wrote:
>
> > Hi,
>
> > I'm quite new to macros so forgive me if this is a naïve question, but
> > is it possible to write macros that are applied to an entire Clojure
> > program?
>
> > The reason I ask is that, in other threads in this group, some simple
> > transformations to improve efficiency of Clojure programs were
> > mentioned. In particular, it seems converting `(+ 1 2 3)` to `(+ 1 (+
> > 2 3))` can speed things up. Applying such a transformation to my own
> > code would be a mindless pattern matching job, and thus perfect for
> > automation.
>
> > Any suggestions how I might write a Clojure program that takes as
> > input another Clojure program and outputs a third one that is
> > optimised but semantically equivalent to the input? Are macros the
> > right tool for the job in this case?
>
> > Thanks,
>
> > Mark.
> > --
> >http://mark.reid.name
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



str-utils change proposal, round 2

2009-05-13 Thread Sean Devlin

Hello again everyone,
I've added a few new routines to a string library I've been working
on.  I mentioned it about a month ago, as a proposed change to str-
utils.

Original Thread:
http://groups.google.com/group/clojure/browse_thread/thread/42152add46b851a0#

Github:
http://github.com/francoisdevlin/clojure-str-utils-proposal/tree/master

Most notable I've created two new functions in this addition,

str-take
str-drop

They have a simple form

(str-take 7 "Clojure Is Awesome") = > "Clojure"
(str-drop 8 "Clojure Is Awesome") = > "Is Awesome"

But the can also take a regex

(str-take #"\s+" "Clojure Is Awesome") = > "Clojure"
(str-drop #"\s+" "Clojure Is Awesome") = > "Is Awesome"

You can check the tests and README.html for more usage.

I'm looking for feedback.  If anyone else has string functions that I
haven't covered, let me know.

Thanks,
Sean
--~--~-~--~~~---~--~~
You 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: str-utils change proposal, round 2

2009-05-14 Thread Sean Devlin

I guess I don't quite see what you're asking for.

If I understand you right, here's how I would do your task today:

(def input-string (slurp "My File.csv"))

;And using my re-split fn...

(re-split input-string '(#"[\r\n]" #","))

This would return a list of rows & cols, and could then be manipulated
appropriately.  You cold even do something like this:

(re-split input-string '({:pattern #"[\r\n]" :offset 1} #","))

And it would drop the first line, as this is usually header
information.

Could you give me an example of what you envision?  What would a high
level call look like?

On May 14, 3:07 am, Wilson MacGyver  wrote:
> would you consider adding support of a split by passing a delimiter?
> since parsing csv/tsv is a pretty common task.
>
> I know it can be done by using re-split. but it seems to occur
> common enough that it's not a bad idea.
>
>
>
> On Thu, May 14, 2009 at 1:12 AM, Sean Devlin  wrote:
>
> > Hello again everyone,
> > I've added a few new routines to a string library I've been working
> > on.  I mentioned it about a month ago, as a proposed change to str-
> > utils.
>
> > Original Thread:
> >http://groups.google.com/group/clojure/browse_thread/thread/42152add4...
>
> > Github:
> >http://github.com/francoisdevlin/clojure-str-utils-proposal/tree/master
>
> > Most notable I've created two new functions in this addition,
>
> > str-take
> > str-drop
>
> > They have a simple form
>
> > (str-take 7 "Clojure Is Awesome") = > "Clojure"
> > (str-drop 8 "Clojure Is Awesome") = > "Is Awesome"
>
> > But the can also take a regex
>
> > (str-take #"\s+" "Clojure Is Awesome") = > "Clojure"
> > (str-drop #"\s+" "Clojure Is Awesome") = > "Is Awesome"
>
> > You can check the tests and README.html for more usage.
>
> > I'm looking for feedback.  If anyone else has string functions that I
> > haven't covered, let me know.
>
> > Thanks,
> > Sean
>
> --
> Omnem crede diem tibi diluxisse supremum.
--~--~-~--~~~---~--~~
You 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: str-utils change proposal, round 2

2009-05-14 Thread Sean Devlin

Stuart,

Excellent point about delimiters, parsing CSV is much more
sophisticated than my simple s-exp.

However, since you're writing a parser you've worked with strings a
lot :)  I use something like str-take/str-drop all the time in my
parsers.  So if you could answer a few questions...

1.  Would str-take/drop make your code any easier to write?
2.  Would str-take/drop make your code any easier to maintain?
3.  What would you add (or remove) from the two functions to help your
parsing?
4.  If str-take/drop were part of a standard library, would you be
more likely to use them?
5.  If str-take/drop were part of a standard library, would you be
more likely to write about them in your book :-p (Excellent work,
btw!  Can't wait for print version!)

Happy Hacking.
Sean

On May 14, 9:14 am, Stuart Halloway  wrote:
> FYI: I am working on an open-source CSV parser in Clojure. Splitting  
> on delimiters is rarely enough in my experience.
>
> Stu
>
> > would you consider adding support of a split by passing a delimiter?
> > since parsing csv/tsv is a pretty common task.
>
> > I know it can be done by using re-split. but it seems to occur
> > common enough that it's not a bad idea.
>
> > On Thu, May 14, 2009 at 1:12 AM, Sean Devlin  
> >  wrote:
>
> >> Hello again everyone,
> >> I've added a few new routines to a string library I've been working
> >> on.  I mentioned it about a month ago, as a proposed change to str-
> >> utils.
>
> >> Original Thread:
> >>http://groups.google.com/group/clojure/browse_thread/thread/42152add4...
>
> >> Github:
> >>http://github.com/francoisdevlin/clojure-str-utils-proposal/tree/master
>
> >> Most notable I've created two new functions in this addition,
>
> >> str-take
> >> str-drop
>
> >> They have a simple form
>
> >> (str-take 7 "Clojure Is Awesome") = > "Clojure"
> >> (str-drop 8 "Clojure Is Awesome") = > "Is Awesome"
>
> >> But the can also take a regex
>
> >> (str-take #"\s+" "Clojure Is Awesome") = > "Clojure"
> >> (str-drop #"\s+" "Clojure Is Awesome") = > "Is Awesome"
>
> >> You can check the tests and README.html for more usage.
>
> >> I'm looking for feedback.  If anyone else has string functions that I
> >> haven't covered, let me know.
>
> >> Thanks,
> >> Sean
>
> > --
> > Omnem crede diem tibi diluxisse supremum.
--~--~-~--~~~---~--~~
You 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: str-utils change proposal, round 2

2009-05-14 Thread Sean Devlin

Hmmm... it sounds like there would be use for a "string table utils"
or something like that.

On May 14, 11:12 am, Daniel Lyons  wrote:
> On May 14, 2009, at 7:14 AM, Stuart Halloway wrote:
>
>
>
> > FYI: I am working on an open-source CSV parser in Clojure. Splitting
> > on delimiters is rarely enough in my experience.
>
> That would be wonderful. I have wrapped OpenCSV for my own purposes  
> but would of course prefer not having another library dependency. My  
> code wound up like this:
>
> (import 'java.io.FileReader 'au.com.bytecode.opencsv.CSVReader))
>
> (defn read-csv [filename]
>    (let [reader (CSVReader. (FileReader. filename))]
>      (map vec (take-while identity (repeatedly #(.readNext reader))
>
> I'd welcome anyone's remarks about that.
>
> One thing I have in my CSV toolkit which might be of general utility  
> is a function which reads the first row sans '#' as column names and  
> returns hashes. So if you have this CSV file:
>
> #name,age,language
> Daniel,27,Clojure
> David,26,Python
>
> You get this seq as a result: ({:name "Daniel", :age "27", :language  
> "Clojure"} {:name "David", :age "26", :language "Python"})
>
> I'm not quite sure what to call such a function, and I find this  
> function's implementation seriously ugly. I'd appreciate anyone's  
> feedback to clean it up.
>
> (defn csv->relation
>    "Parses a CSV file and returns a seq of dictionaries."
>    [filename]
>    (let
>        [data (read-csv filename)
>         [[pre-col1 & columns] & rows] data
>         col1 (if (= \# (.charAt pre-col1 0)) (.substring pre-col1 1)  
> pre-col1)
>         headers (map keyword (cons col1 columns))]
>      (map #(apply
>            hash-map
>            (mapcat list headers %))
>          rows)))
>
> Thanks,
>
> —
> Daniel Lyonshttp://www.storytotell.org-- Tell It!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: lazy-cat

2009-05-16 Thread Sean Devlin

Clearly you are all dog people.  Lazy cat is redundant.

On May 16, 3:55 pm, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 16.05.2009 um 21:48 schrieb George Jahad:
>
> > I can't come up with  a reason to use lazy-cat over concat.  Is it
> > just around for backwards compatibility, or am I missing something?
>
> > (defmacro lazy-cat
> >  [& colls]
> >  `(concat ~@(map #(list `lazy-seq %) colls)))
>
> There is a difference! Consider the following:
>
> (concat (make-foo-seq) (make-bar-seq))
> vs.
> (lazy-cat (make-foo-seq) (make-bar-seq))
>
> In the first case the function are called immediately.
> In the second case the function call is delayed until
> they are accessed the first time.
>
> Sincerely
> Meikel
>
>  smime.p7s
> 5KViewDownload
--~--~-~--~~~---~--~~
You 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: lazy-cat

2009-05-16 Thread Sean Devlin

I'm sorry, it's an Americanism.  By "Dog People", I meant someone that
prefers a dog as a pet, not a cat.  It was meant as a joke.

You're right, I should be more considerate of the international
audience, and careful to make my tone more clear.  Thank you for
speaking up.

Sean

On May 16, 4:13 pm, Laurent PETIT  wrote:
> 2009/5/16 Sean Devlin :
>
>
>
> > Clearly you are all dog people.
>
> Hello,
>
> What means calling others "dog people" exactly ?
>
> Not being a native english person, I'm unsure whether the above is an
> insult, is ironic, or something else ?
>
> Anyway, the above sentence, without any smiley of some sort to explain
> the intended tone, really denotes from what has been seen so far in
> this ml, and I hope this kind of think will be kept at least for irc,
> if not for private correspondance only.
>
> My 0,02 € (but being from a "dog people", maybe this does not count as
> if it had been written by a not "dog people" ?),
>
> --
> Laurent
>
> >  Lazy cat is redundant.
>
> > On May 16, 3:55 pm, Meikel Brandmeyer  wrote:
> >> Hi,
>
> >> Am 16.05.2009 um 21:48 schrieb George Jahad:
>
> >> > I can't come up with  a reason to use lazy-cat over concat.  Is it
> >> > just around for backwards compatibility, or am I missing something?
>
> >> > (defmacro lazy-cat
> >> >  [& colls]
> >> >  `(concat ~@(map #(list `lazy-seq %) colls)))
>
> >> There is a difference! Consider the following:
>
> >> (concat (make-foo-seq) (make-bar-seq))
> >> vs.
> >> (lazy-cat (make-foo-seq) (make-bar-seq))
>
> >> In the first case the function are called immediately.
> >> In the second case the function call is delayed until
> >> they are accessed the first time.
>
> >> Sincerely
> >> Meikel
>
> >>  smime.p7s
> >> 5KViewDownload
--~--~-~--~~~---~--~~
You 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: lazy-cat

2009-05-16 Thread Sean Devlin

I was making a joke about housecats.

Maybe I should file a bug report saying cat should default to being
lazy :)

Again, sorry for the confusion.

On May 16, 4:34 pm, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 16.05.2009 um 21:58 schrieb Sean Devlin:
>
> > Lazy cat is redundant.
>
> concat != lazy-cat. lazy-cat is obviously not redundant.
>
> Sincerely
> Meikel
>
>  smime.p7s
> 5KViewDownload
--~--~-~--~~~---~--~~
You 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: Clojure at JavaOne

2009-05-21 Thread Sean Devlin

The duck streams library should give some examples the Java crowd will
be ready to appreciate.  That, or maybe use the with-open macro.

My $.02

On May 21, 7:42 am, Rich Hickey  wrote:
> On May 21, 3:39 am, mikel  wrote:
>
>
>
> > On May 18, 7:36 am, Rich Hickey  wrote:
>
> > > I'll be doing two sessions involving Clojure at JavaOne this June. One
> > > is a traditional talk (TS-4164), the other is as a participant in the
> > > Script Bowl 2009: A Scripting Languages Shootout (PAN-5348).
>
> > > The 'script' bowl is a friendly competition, basically a place to show
> > > off your language and seek audience acclaim.
>
> > > "Scripting language gurus returning from 2008 are Groovy, JRuby,
> > > Jython, and Scala. This year there is also a new kid on the block:
> > > Clojure."
>
> > > There are two very brief rounds, 4 minutes per language each round .
>
> > > round 1: Core language and libraries round (show something really cool
> > > with the core language and libraries)
>
> > > round 2: Community round (show some significant community
> > > contributions)
>
> > > Note there is no comparative aspect, each language presenter talks up
> > > their own language and the audience decides, so it's not an
> > > opportunity to draw contrasts explicitly. It's about being pro-
> > > Clojure, not anti- anything else.
>
> > > The audience is Java developers, many of whom will have never seen
> > > Clojure or any Lisp.
>
> > > I'd appreciate some suggestions *and help* preparing demos for the
> > > Script Bowl. What (that could be demonstrated in 4 minutes) would make
> > > you think - 'Clojure looks cool, I need to look into it'? What
> > > community contribution(s) should we showcase?
>
> > Show something that does a lot of visible work quickly with very
> > little code, where the code is still very readable and easy to
> > understand.
>
> > Show how to do something that Java programmers have to do pretty
> > often, and that requires many lines of code, but which requires very
> > few lines of code in Clojure, yet the code is still very
> > understandable.
>
> > Show how someone can look at a running demo and ask for a different
> > feature, and you can implement the feature and have it show up in the
> > running demo without needing to stop and restart it.
>
> > Show how you can run a demo with a bug in it, trigger the bug, to
> > cause a break, fix the bug while in the break, and resume the demo
> > with the corrected code.
>
> > Show how you can do all of this from a nice interactive session, but
> > also quickly and easily package the demo app as a jarfile that you can
> > deploy like any other jarfile.
>
> > Show how easy it is to look at the guts of any Java instance or class,
> > and how easy it is to instantiate and use classes and interfaces.
>
> > Take a concurrent Java example that exhibits hard-to-debug threading
> > issues (this should address pain that any server-side Java programmer
> > has felt), and show how they go away in the presence of Clojure's
> > safety guarantees.
>
> > Finally, show them that they don't lose performance by gaining these
> > features.
>
> And in the second 4 minutes? :)
>
> 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
-~--~~~~--~~--~--~---



some vs. every?

2009-05-26 Thread Sean Devlin

I just noticed a quirk in the core API.  The some and every? functions
have different naming conventions.  Is there a reason for this?  If
not I think renaming/creating an alias some? would be very helpful.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: some vs. every?

2009-05-26 Thread Sean Devlin

To add to my own post:

There is also a discrepancy in what is returned from the two

(some identity [1 2 3]) -> 1
(every? identity [1 2 3]) -> true

I would expect the following to occur

(some identity [1 2 3]) -> true

Granted, it's all the same to an if statement.  However, current
behavior of some has the added use:

(first (filter identity [1 2 3])) -> 1
(some identity [1 2 3]) -> 1

Is the equivalence a fluke, or is this by design?  Is there any
promise that some will continue to behave this way in the future?  If
so, it seems like a bad alias for (first (filter...))

Just more to discuss

On May 26, 9:02 am, Sean Devlin  wrote:
> I just noticed a quirk in the core API.  The some and every? functions
> have different naming conventions.  Is there a reason for this?  If
> not I think renaming/creating an alias some? would be very helpful.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: some vs. every?

2009-05-26 Thread Sean Devlin

Okay, excellent counterexample for some.  I understand that behavior
now.

I guess I should focus on my main point, changing/aliasing the name to
some? to be consistent with every?

On May 26, 9:34 am, Laurent PETIT  wrote:
> Hi,
>
> (comp first filter) and some are not equivalent.
>
> Consider this less simple case:
>
> user=> (defn negate-or-nil [x] (when (even? x) (- x)))
> #'user/negate-or-nil
> user=> (first (filter negate-or-nil [1 2 3]))
> 2
> user=> (some negate-or-nil [1 2 3])
> -2
> user=>
>
> some returns the result of the predicate, filter returns the seq item
> for which predicate matches.
>
> Concerning the result of some, it seems better to return a more
> meaningful value, because it still can be used as logical true, e.g.
> in an if or when construct ...
>
> 2009/5/26 Sean Devlin :
>
>
>
> > To add to my own post:
>
> > There is also a discrepancy in what is returned from the two
>
> > (some identity [1 2 3]) -> 1
> > (every? identity [1 2 3]) -> true
>
> > I would expect the following to occur
>
> > (some identity [1 2 3]) -> true
>
> > Granted, it's all the same to an if statement.  However, current
> > behavior of some has the added use:
>
> > (first (filter identity [1 2 3])) -> 1
> > (some identity [1 2 3]) -> 1
>
> > Is the equivalence a fluke, or is this by design?  Is there any
> > promise that some will continue to behave this way in the future?  If
> > so, it seems like a bad alias for (first (filter...))
>
> > Just more to discuss
>
> > On May 26, 9:02 am, Sean Devlin  wrote:
> >> I just noticed a quirk in the core API.  The some and every? functions
> >> have different naming conventions.  Is there a reason for this?  If
> >> not I think renaming/creating an alias some? would be very helpful.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: some vs. every?

2009-05-26 Thread Sean Devlin

Oops, thanks

On May 26, 9:45 am, Laurent PETIT  wrote:
> Please refer to Chouser's answer for your main point,
>
> Regards,
>
> --
> laurent
>
> 2009/5/26 Sean Devlin :
>
>
>
> > Okay, excellent counterexample for some.  I understand that behavior
> > now.
>
> > I guess I should focus on my main point, changing/aliasing the name to
> > some? to be consistent with every?
>
> > On May 26, 9:34 am, Laurent PETIT  wrote:
> >> Hi,
>
> >> (comp first filter) and some are not equivalent.
>
> >> Consider this less simple case:
>
> >> user=> (defn negate-or-nil [x] (when (even? x) (- x)))
> >> #'user/negate-or-nil
> >> user=> (first (filter negate-or-nil [1 2 3]))
> >> 2
> >> user=> (some negate-or-nil [1 2 3])
> >> -2
> >> user=>
>
> >> some returns the result of the predicate, filter returns the seq item
> >> for which predicate matches.
>
> >> Concerning the result of some, it seems better to return a more
> >> meaningful value, because it still can be used as logical true, e.g.
> >> in an if or when construct ...
>
> >> 2009/5/26 Sean Devlin :
>
> >> > To add to my own post:
>
> >> > There is also a discrepancy in what is returned from the two
>
> >> > (some identity [1 2 3]) -> 1
> >> > (every? identity [1 2 3]) -> true
>
> >> > I would expect the following to occur
>
> >> > (some identity [1 2 3]) -> true
>
> >> > Granted, it's all the same to an if statement.  However, current
> >> > behavior of some has the added use:
>
> >> > (first (filter identity [1 2 3])) -> 1
> >> > (some identity [1 2 3]) -> 1
>
> >> > Is the equivalence a fluke, or is this by design?  Is there any
> >> > promise that some will continue to behave this way in the future?  If
> >> > so, it seems like a bad alias for (first (filter...))
>
> >> > Just more to discuss
>
> >> > On May 26, 9:02 am, Sean Devlin  wrote:
> >> >> I just noticed a quirk in the core API.  The some and every? functions
> >> >> have different naming conventions.  Is there a reason for this?  If
> >> >> not I think renaming/creating an alias some? would be very helpful.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: quote vs quasiquote

2009-05-26 Thread Sean Devlin

I would lead the desired term with ~'

For example:

`(+ 1 2)
=> (clojure.core/+ 1 2)

`(~'+ 1 2)
=> (+ 1 2)

This is very useful when defining a function in a macro

On May 26, 2:30 pm, kyle smith  wrote:
> user> (def nums '(1 2 3))
> #'user/nums
> user> (def funs '((+ (1 2 3)) (- (1 2 3
> #'user/funs
> user> funs
> ((+ (1 2 3)) (- (1 2 3)))
> user> (def funs `((+ ~nums) (- ~nums)))
> #'user/funs
> user> funs
> ((clojure.core/+ (1 2 3)) (clojure.core/- (1 2 3)))
>
> I would expect these two approaches to be the same, but when using
> quasiquote, it qualifies my functions.  How can I prevent this
> (without copy & paste)?
--~--~-~--~~~---~--~~
You 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: Macro Writing Helper?

2009-05-28 Thread Sean Devlin

CuppoJava,

Could you give us a little more information what you're trying to do?
What type of macro-macros are you writing?

On May 28, 4:58 am, Konrad Hinsen  wrote:
> On 28.05.2009, at 03:11, CuppoJava wrote:
>
> > I'm using macroexpand-1 right now, but it's not terribly useful as
> > backquotes expand to something nasty.
>
> > Given:
> > (defmacro mymacro []
> >   `(level1 `(level2)))
>
> > I would like to see it expanded to:
> > (user/level1 `(level2))
>
> That's not possible, because the replacement happens *before* macro  
> expansion. The backquote is expanded by the reader.
>
> To see what happens, just type
>
>         `(level1 `(level2))
>
> into the REPL. The result is
>
>         (user/level1 (clojure.core/seq (clojure.core/concat (clojure.core/
> list (quote user/level2)
>
> 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: Macro Writing Helper?

2009-05-28 Thread Sean Devlin

Okay, this looks a lot like the ruby yeild statement.  Is that what
inspired you?

On May 28, 12:50 pm, CuppoJava  wrote:
> That's unfortunate. It would have made matters much easier for me.
>
> The macro I'm attempting to write is:
>
> (defblockfn my_block_fn [arg1 arg2 func]
>   (op1 arg1)
>   (func)
>   (op2 arg2))
>
> Becomes:
>
> (defn -my_block_fn [arg1 arg2 func]
>   (op1 arg1)
>   (func)
>   (op2 arg2))
> (defmacro my_block_fn [arg1 arg2 & tail]
>   `(-my_block_fn arg1 arg2 (fn [] ~...@tail)))
>
> The recursive backquotes are really confusing me. I would be extremely
> appreciative if someone can explain step-by-step how to reason with
> backquotes within backquotes.
>   -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Macro Writing Helper?

2009-05-28 Thread Sean Devlin

Okay, great.  That's my background too.

Without discussing a specific application, I think what you're looking
for can be achieved by normal macros and functions in Clojure.  I'll
try implement the collect method in Clojure, and hopefully that will
explain things.

Let's start by creating a collect function.

(defn collect
  [pred coll]
  (loop [remaining coll
 output []]
(if (empty? remaining)
  output
  (recur (rest remaining)
(conj output (pred (first remaining)))

And a quick test shows

(collect (fn[x](* 2 x)) [1 2 3])
=>[2 4 6]

Notice that the clojure collect takes a function, pred as an
argument.  The s-expression (pred (first remaining)) automatically
applies the right function do to the *pure genius* that is eval.  It's
pretty slick.

Here's my best attempt at writing an all-purpose collect-m macro.
It's ugly, and I don't like it.

(defmacro collect-m
  [coll & body]
  `(let [~'pred (fn [~'elemen...@body)]
 (loop [~'remaining ~coll
 ~'output []]
(if (empty? ~'remaining)
  ~'output
  (recur (rest ~'remaining)
(conj ~'output (~'pred (first ~'remaining

(collect-m [1 2 3] (* 2 element))
=>[2 4 6]

Notice that the term element is fixed as a parameter name.  I assume
that there is ONLY on input in the function.  The macro is ugly to
read.  Maybe someone else can do better.

Revisiting the function version, notice:

(collect (fn[x](* 2 x)) [1 2 3])

Feels very similar to

[1, 2, 3].collect(){|x| 2*x}

You have much more control of the function.

The main point I'm getting at is that I don't think the blockfn macro
approach is the way to go.  Either write a function that take
functions, or use a traditional macro.

Hope this helps.

Sean


On May 28, 1:37 pm, CuppoJava  wrote:
> Haha. You got it. I discovered Lisp after using Ruby. Ruby was
> actually the language that helped me realize what a good idea
> functional programming is.
--~--~-~--~~~---~--~~
You 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: Macro Writing Helper?

2009-05-28 Thread Sean Devlin



On May 28, 3:01 pm, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 28.05.2009 um 20:11 schrieb Sean Devlin:
>
> > Without discussing a specific application, I think what you're looking
> > for can be achieved by normal macros and functions in Clojure.  I'll
> > try implement the collect method in Clojure, and hopefully that will
> > explain things.
>
> > Let's start by creating a collect function.
>
> > (defn collect
> >  [pred coll]
> >  (loop [remaining coll
> >         output []]
> >    (if (empty? remaining)
> >      output
> >      (recur (rest remaining)
> >        (conj output (pred (first remaining)))
>
> This can be written more concise with reduce:
>
> (defn collect
>    [f coll]
>    (reduce #(conj %1 (f %2)) (empty coll) coll))
>
> Whenever you do loop/recur and return one argument
> when the input is used up, you probably can turn it into
> a nice reduce.

1.  collect is the ruby version of map, not reduce.  An interesting
use of reduce, though.
2.  I was trying to show how one would explicitly write map.  I agree,
using standard clojure is much much much better.

>
>
>
> > And a quick test shows
>
> > (collect (fn[x](* 2 x)) [1 2 3])
> > =>[2 4 6]
>
> > Notice that the clojure collect takes a function, pred as an
> > argument.  The s-expression (pred (first remaining)) automatically
> > applies the right function do to the *pure genius* that is eval.  It's
> > pretty slick.
>
> > Here's my best attempt at writing an all-purpose collect-m macro.
> > It's ugly, and I don't like it.
>
> > (defmacro collect-m
> >  [coll & body]
> >  `(let [~'pred (fn [~'elemen...@body)]
> >     (loop [~'remaining ~coll
> >         ~'output []]
> >    (if (empty? ~'remaining)
> >      ~'output
> >      (recur (rest ~'remaining)
> >        (conj ~'output (~'pred (first ~'remaining
>
> > (collect-m [1 2 3] (* 2 element))
> > =>[2 4 6]
>
> Please don't write a macro like that! This captures
> the names you chose for your locals. Imagine a
> call like this (collect-m (do-something-with-another pred) ...),
> where the pred comes from outside the macro. This
> call will fail, because you captured pred in your macro
> expansion. Use auto-gensym via the # suffix.
>
> `(let [pred# ...])
>
> This will generate and new symbol like pred__AUTO_412
> or something similar, which is unlikely to be used by the
> surrounding code, which calls the macro.
>
> The parameter problem can be solved by providing an
> additional parameter, which is then used in the function
> argument vector.
>

This is exactly the problem I wanted to highlight, thanks for
providing a better way to write that macro.

>
>
> > Notice that the term element is fixed as a parameter name.  I assume
> > that there is ONLY on input in the function.  The macro is ugly to
> > read.  Maybe someone else can do better.
>
> > Revisiting the function version, notice:
>
> > (collect (fn[x](* 2 x)) [1 2 3])
>
> > Feels very similar to
>
> > [1, 2, 3].collect(){|x| 2*x}
>
> > You have much more control of the function.
>
> > The main point I'm getting at is that I don't think the blockfn macro
> > approach is the way to go.  Either write a function that take
> > functions, or use a traditional macro.
>
> I find this defblockfn actually quite interesting. A lot of macros
> boil down to wrap some body in a thunk and pass it to a driver
> function, which does the work, which can be defered to runtime.
> This approach has several advantages:
>
> - smaller code size since the macro expands to a simply function call
> - changing the logic in the driver function does not require  
> recompilation
>    of the macro users.
> - the driver function is easier to write than the macro
>
> So maybe 95% of my macros are paired with a function.
>

This is exactly why I think creating defblockfn is a bad idea.  We
already have a perfectly good macro facility in clojure.  Let's use
what we've got.

> YMMV of course...
>
> Sincerely
> Meikel
>
>  smime.p7s
> 5KViewDownload
--~--~-~--~~~---~--~~
You 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: Macro Writing Helper?

2009-05-28 Thread Sean Devlin



On May 28, 3:10 pm, CuppoJava  wrote:
> Thank you Meikel for going to the trouble of writing out the full
> macro. It's going to take me a while to decipher it, and hopefully
> grasp some understanding at the end of it.

"I find defblockfn very useful for functions that take a single
function as one of the parameters."

Could you provide and example?  I don't see how this isn't
accomplished by a normal function.


>
> Macros are much harder and more error-prone to write than functions,
> so almost all of my macros do nothing but wrap a body in a function.
>
> "One technique, which was
> helpful was to just call the defblockfn macro and then
> expand the call to freshly defined macro.
>
> (defblockfn foo [a b c] ...)
> (macroexpand-1 '(foo :a :b :c)) "
>
> Could you explain a bit more what you mean by that? I don't quite
> understand what you're saying, but it sounds potentially very useful.
>
> Thanks again
>   -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Macro Writing Helper?

2009-05-28 Thread Sean Devlin

Okay, good to know.  It's interesting to see other approaches.  It's
how we collectively get better.

My $.02:

(with_file "myfile.txt"
 #(write "asdf")
(close))

Sean

On May 28, 3:23 pm, CuppoJava  wrote:
> It's useful in all the cases where a blocks are useful in Ruby. It
> simply saves typing out "(fn [])" and IMO makes the code look a little
> cleaner.
>
> eg.
> (with_file "myfile.txt"
>   (write "asdf")
>   (close))
>
> compared to.
> (with_file "myfile.txt"
>   (fn []
>     (write "asdf")
>     (close)))
>
> There's arguably no difference. I just prefer the first one.
>   -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Macro Writing Helper?

2009-05-28 Thread Sean Devlin

That's true.  Good job Meikel, macro master!

On May 28, 3:31 pm, CuppoJava  wrote:
> Correction: By "My macro" I, of course, mean "Meikel's macro" since
> you're the one that actually got it working.
>
> Have to give credit where it's due. =)
--~--~-~--~~~---~--~~
You 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: Macro Writing Helper?

2009-05-28 Thread Sean Devlin

Likewise.  Good discussion.

On May 28, 4:49 pm, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 28.05.2009 um 22:23 schrieb CuppoJava:
>
> > Thanks to Meikel and Sean for their input and help.
>
> You are welcome. :)
>
> Sincerely
> Meikel
>
>  smime.p7s
> 5KViewDownload
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



Programming Clojure Arrives!

2009-05-28 Thread Sean Devlin

I just got my copy of Programming Clojure in the mail today.  This is
the only time I expect to see the book in pristine condition, as I
know it will get bookmarked, highlighted, and well used in a hurry.

Congratulations Stuart!
--~--~-~--~~~---~--~~
You 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: The thread ring problem

2009-05-29 Thread Sean Devlin

Would type hints help at all?

On May 29, 11:40 am, Laurent PETIT  wrote:
> Hi,
>
> Here is my attempt, for the real benchmark test, it has an honorable
> result of 62 sec. (if there is no flaw in my algorithm, of course).
>
> ;; file shootout/ring.clj
> (ns shootout.ring
>   (:gen-class))
>
> (def n-threads 503)
> (def nb-pass   5000)
>
> (defn main
>   "main function calling the benchmark test."
>   [n-threads N print-result-fn]
>   (let [start-time (System/nanoTime)
>         agents  (into [] (map #(agent {:name (inc %)}) (range n-threads)))
>         send-to (fn this [i token-val]
>                   (send (nth agents (mod i n-threads))
>                             (fn [state t-val]
>                               (if (= t-val N)
>                                 (print-result-fn (:name state) start-time)
>                                 (this (inc i) (inc t-val)))
>                               state)
>                             token-val))]
>     (send-to 0 0)
>     nil))
>
> (defn repl-print-result-fn [thread-id start-time]
>   (println "\n"
>            "thread number: " thread-id "\n"
>            "time   (secs): " (/ (- (System/nanoTime) start-time) 
> 10.0)))
>
> (defn benchmark-print-result-fn [thread-id _]
>   (println thread-id))
>
> (defn -main []
>   (main n-threads nb-pass benchmark-print-result-fn))
>
> (defn repl-test [nb-pass]
>   (main n-threads nb-pass repl-print-result-fn))
>
> ;; repl session
> Clojure
> 1:1 user=> (use 'shootout.ring)
> nil
> 1:2 user=> (do (repl-test 1000) (repl-test 5000))
> nil
> 1:3 user=>
>  thread number:  498
>  time   (secs):  0.128037133
>
>  thread number:  292
>  time   (secs):  62.724999733
>
> on a recent machine
>
> (and yes, I know something similar is on the clojure agents page, but
> sometimes it's rewarding not to look at the solution too early :-)
>
> Cheers,
>
> --
> Laurent
>
> 2009/5/29 Alvaro Vilanova Vidal :
>
> > Thanks, seems that I misunderstood Agents :)
>
> > The solution of Christian works well with full load, but maybe slow for the
> > benchmark. In my core2duo, with full load, takes about 28mins to compute the
> > result.
>
> > user=> (do (println (System/nanoTime)) (start 5000))
> > 22651751153117
> > #
> > user=> 292 ( 24319344452689 )
> > user=> (/ (- 24319344452689 22651751153117) 600.0)
> > 27.79322165954
>
> > 2009/5/29 Christian Vest Hansen 
>
> >> On Fri, May 29, 2009 at 4:29 PM, Laurent PETIT 
> >> wrote:
> >> > when I try it with the 50,000,000 number of times the token is
> >> > exchanged (which is the number to be used for the benchmark)
>
> >> Oh, right. I only noticed the 1000 mentioned at the bottom. Also, the
> >> (time ...) makes no sense.
>
> >> > How would one fix this?
>
> >> With a CountDownLatch? That's what I'm currently trying.
>
> >> > 2009/5/29 Christian Vest Hansen :
>
> >> >> For kicks, I made an implementation* using agents:
>
> >> >>http://gist.github.com/119946
>
> >> >> I think that you may not want to use the STM so much and instead
> >> >> figure out a different approach to sending the token around the ring.
>
> >> >> *it may be a bit liberal in its interpretation of the rules... didn't
> >> >> read them that carefully.
>
> >> >> On Fri, May 29, 2009 at 2:32 PM, Alvaro Vilanova Vidal
> >> >>  wrote:
>
> >> >>> Hi everyone,
> >> >>> I am a newbie in clojure world, so I have some newbie's questions :)
> >> >>> To
> >> >>> learn about clojure, I am trying to do the thread ring problem of clgb
> >> >>> in
> >> >>> clojure. The rules of problem are here, and my attempt here. It seems
> >> >>> that
> >> >>> works well, but I can only test it with a small load (5 - 15 threads,
> >> >>> 503 is
> >> >>> the target) because it runs extremely slow. I tried to use atoms,
> >> >>> hints, and
> >> >>> change the implementation, but always is slower. What am I doing
> >> >>> wrong? And,
> >> >>> by the way, why can't I compile the class?
>
> >> >>> Thanks a lot.
>
> >> >> --
> >> >> Venlig hilsen / Kind regards,
> >> >> Christian Vest Hansen.
>
> >> --
> >> Venlig hilsen / Kind regards,
> >> Christian Vest Hansen.
>
> > --
> > Álvaro Vilanova,
> >http://alvivi.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
-~--~~~~--~~--~--~---



Feedback on clipboard library

2009-06-01 Thread Sean Devlin

Hello Everyone,
I've created a library for interacting with the clipboard.  It's a
wrapper for the AWT clipboard library.You can find it here:

http://github.com/francoisdevlin/devlinsf-clojure-utils/tree/master

*Note - I changed the location of my string library for anyone
following that.

== Clipboard Utilities ==

Namespace: lib.devlinsf.clip-utils

This is designed to support ad-hoc data processing and spreadsheet
wrangling.  Also, it could be useful for adding custom cut and paste
to your own Swing applications.

Currently only moving text objects between applications is supported.
There a few known quirks with set-clip! in OS X.  Seems to work fine
on XP.  Have not tested Vista or any variants of Linux.

=== Clipboard Usage ===

Here's a quick rundown of how to use the methods.

 Cut & Paste 
Assume "Clojure is Awesome" is on the clipboard

# Use the get-clip function to return the data as a string.

user=>(get-clip)
"Clojure is Awesome"

user=>(count (get-clip))
18

# Use the set-clip! function to paste a string to the clipboard.
user=>(set-clip! "Clojure is Great")
;"Clojure is Great" is now on the clipboard

 Cut & Paste S-exps 
Assume the following is in the clipboard
(+ 2 2)

# Use the read-clip function to return the clipboard data as an S-exp
(if applicable).

user=>(read-clip)
(+ 2 2)

user=>(count (read-clip))
3

# Use the eval-clip function to evaluate the S-exp in the clipboard
(if applicable).

user=>(eval-clip)
4

 Storing Clippings 

# Use the defclip macro to store the clipping in a variable.

user=>(defclip a-symbol)
;a-symbol now stores the contents of the clipboard.  Great for REPL
hacking.

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

2009-06-02 Thread Sean Devlin

This would encourage documenting structs, so I think this is a good
idea.

Sean

On Jun 2, 11:31 am, Stuart Halloway  wrote:
> I would like to see defstruct take an optional docstring. Would such a  
> patch be welcome?
>
> Stu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread Sean Devlin

I don't know either, but you can use the following work around

(defn my-seq[object]
  (instance? clojure.lang.Seqable object))

(my-seq []) =>true
(my-seq {}) =>true
(my-seq #{}) =>true
(my-seq '()) =>true

(my-seq :a) => false
(my-seq 'a-symbol) => false

Still, it would be nice to know the right way to do this...

On Jun 3, 12:53 pm, CuppoJava  wrote:
> Hi,
> Is there a function that will return true iff calling seq on it's
> argument will not throw an error? I thought it was seq?, but (seq? [1
> 2 3]) returns false.
>
>   -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Macro Writing Helper?

2009-06-03 Thread Sean Devlin

Could you throw together some live examples and unit tests?

On Jun 3, 1:10 pm, CuppoJava  wrote:
> In case anybody else found defblockfn useful, here's the final
> version. The original didn't work when you used destructuring in the
> argument list of the function.
>
> (defn remove_destructuring [params]
>   (map (fn [arg]
>          (if (or (vector? arg) (map? arg))
>            (gensym)
>            arg))
>        params))
> (defmacro defblockfn [function params & body]
>   (let [tempfn (symbol (str function "*"))
>         macro_params (butlast (remove_destructuring params))]
>     `(do (defn ~tempfn ~params ~...@body)
>          (defmacro ~function [...@macro_params & tail#]
>            `(~'~tempfn ~...@macro_params (fn [] ~...@tail#))
>
> -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Where does the language end and the libraries begin?

2009-06-04 Thread Sean Devlin

There was this language wiritten in '58 that can do just that. It's
called LISP.

Here's Paul Grahams paper on eval:

http://lib.store.yahoo.net/lib/paulgraham/jmc.ps

Get to the part where he defines eval, and let your brain stay on that
for a while.  You'll see WHY macros work, and never ever go back to
anything else.

On Jun 4, 1:34 am, CuppoJava  wrote:
> I've always considered the core part of the language to be the portion
> that cannot be written in the language itself.
>
> I don't think you can write an Clojure if form in Clojure.
>
> When we talk about implementing Clojure entirely in Clojure, we don't
> actually mean implementing the language in itself. We mean something
> more along the lines of implementing Clojure v2 in Clojure v1.
>
> In case I'm mistaken, however, I would be absolutely fascinated by a
> language written in itself.
>   -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: defnk addition to c.c.def

2009-06-04 Thread Sean Devlin

Gut gemacht!

Absolutely amazing Meikel.  Now get some well earned sleep.

Sean

On Jun 4, 6:22 pm, Meikel Brandmeyer  wrote:
> Hi again,
>
> Am 05.06.2009 um 00:06 schrieb Meikel Brandmeyer:
>
> > The docstring is a bit contorted but I'm too sleepy now,
> > to get that right...
>
> And of course I'm too sleepy to miss the keyword to
> symbol conversion
>
> (defmacro defnk
>    "Define a function accepting keyword arguments. Symbols up to the  
> first
>    keyword in the parameter list are taken as positional arguments.  
> Then
>    an alternating sequence of keywords and defaults values is  
> expected. The
>    values of the keyword arguments are available in the function body by
>    virtue of the symbol corresponding to the keyword (cf. :keys  
> destructuring).
>    defnk accepts an optional docstring as well as an optional metadata  
> map."
>    [fn-name & fn-tail]
>    (let [[fn-name [args & body]] (name-with-attributes fn-name fn-tail)
>          [pos kw-vals]           (split-with symbol? args)
>          syms                    (map #(-> % name symbol) (take-nth 2  
> kw-vals))
>          values                  (take-nth 2 (rest kw-vals))
>          sym-vals                (apply hash-map (interleave syms  
> values))
>          de-map                  {:keys (vec syms)
>                                   :or   sym-vals}]
>      `(defn ~fn-name
>         [...@pos & options#]
>         (let [~de-map (apply hash-map options#)]
>           ~...@body
>
> Sincerely
> Meikel
>
>  smime.p7s
> 5KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: defnk addition to c.c.def

2009-06-05 Thread Sean Devlin

I'm writing a numerical methods library, and I already found a use for
you macro.  Here's the old way:

(defn solve
  [f & params]
  (let [param-map (merge
{:start 1
 :target 0
 :diff-method :forward
 :iter-method :newton
 :epsilon 0.0001
 :max-iters 100}
(apply hash-map params))
diff-method (param-map :diff-method)
iter-method (param-map :iter-method)
start (param-map :start)
target (param-map :target)
max-iters (param-map :max-iters)
epsilon (param-map :epsilon)
f-point #(- (f %) target)
iter-methods {:newton (fn[x]
(- x (/ (f-point x) ((f-prime f-
point :diff-method diff-method) x}
iterator (iter-methods iter-method)]
(loop [x start
   iter-count 0]
  (let [next-x (iterator x)]
  (cond
(< (java.lang.Math/abs (- (f-point x) (f-point next-x)))
epsilon) next-x
(> iter-count max-iters) (do
   (println "Maximum number of
iterations reached")
   nil)
true (recur next-x (inc iter-count)))


And here's the new way with your macro

(defnk solve-key
  [f
   :start 1
   :target 0
   :diff-method :forward
   :iter-method :newton
   :epsilon 0.0001
   :max-iters 100]
  (let [f-point #(- (f %) target)
iter-methods {:newton (fn[x]
(- x
   (/ (f-point x)
  ((f-prime f-point :diff-method 
diff-method) x}
iterator (iter-methods iter-method)]
(loop [x start
   iter-count 0]
  (let [next-x (iterator x)]
(cond
 (< (java.lang.Math/abs (- (f-point x) (f-point next-x)))
epsilon) next-x
 (> iter-count max-iters) (do
(println "Maximum number of iterations 
reached")
nil)
 true (recur next-x (inc iter-count)))

So it's paying off already!

On Jun 4, 7:02 pm, "Stephen C. Gilardi"  wrote:
> On Jun 4, 2009, at 6:54 PM, Sean Devlin wrote:
>
> > Gut gemacht!
>
> > Absolutely amazing Meikel.  Now get some well earned sleep.
>
> > Sean
>
> I agree. It's a really beautiful piece of code, packed full of Clojure  
> goodness.
>
> Nicely done!
>
> I checked it into clojure.contrib.def:
>
>        http://code.google.com/p/clojure-contrib/source/detail?r=889
>
> Thanks!
>
> --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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



  1   2   3   4   5   6   7   8   9   10   >