Re: Lightweight lib/way to strip html from text

2012-09-06 Thread Richard Lyman
On Thu, Sep 6, 2012 at 11:41 AM, jamieorc jamie...@gmail.com wrote:
 Hey all, I'm looking for a lightweight way to strip html from a long String
 of text and leave just the text. I've come across JSoup, but at over 300kb
 for the lib, not quite lightweight.

 Suggestions?

 Cheers,
 Jamie


When you say 'html' do you mean any html that a modern or even older
browser would accept, or is a very restricted set of very clean html?

-Rich

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


Re: edn

2012-09-06 Thread Richard Lyman
On Thu, Sep 6, 2012 at 7:01 PM, Rich Hickey richhic...@gmail.com wrote:
 I've started to document a subset of Clojure's data format in an effort to 
 get it more widely used as a data exchange format, e.g. as an alternative to 
 JSON.

 Please have a look:

 https://github.com/richhickey/edn

 Rich


Thanks for sharing!

I've added a link on the wiki implementations page to an initial stab
at an Amotoen grammar for edn (
https://github.com/richhickey/edn/wiki/Implementations )

I'm very interested in any test data that I can code against. While
I'll be coming up with my own examples, since edn is so
straightforward, it could help to have a 'canonical' collection of
test data.

-Rich

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


Re: SaxParseException when using the Rome rss library

2012-08-19 Thread Richard Lyman
On Fri, Aug 17, 2012 at 5:26 PM, keedon keith.po...@gmail.com wrote:
 Hi,
 I've got a clojure problem and I'm hoping someone can help:

 I'm trying to parse an rss feed which contains illegal characters and I'm
 getting this error

 SAXParseException An invalid XML character (Unicode: 0x19) was found in the
 element content of the document.

 I've tried adding a function to remove control characters, but it doesn't
 seem to be working the filter function I've written is

 (defn remove-control [seq]
 (filter (fn [ch] (not (Character/isISOControl ch))) seq))

 Thanks for any help

 Keith


I'm not sure I can help, but I *am* interested in a sample of the RSS
that you're trying to work with.

Could you provide a sample?

-Rich

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


Re: Can you make Amotoen faster?

2012-08-03 Thread Richard Lyman
On Thu, Jul 19, 2012 at 7:09 AM, David Nolen dnolen.li...@gmail.com wrote:
 On Wed, Jul 18, 2012 at 10:12 PM, Richard Lyman richard.ly...@gmail.com 
 wrote:
 All,

 There's not much code, and (sadly) not much documentation, but what's
 there needs some performance love.

 https://github.com/richard-lyman/amotoen

 Notes:
  - jvisualvm doesn't like me this week so help there might be enough
 (I can't see anything other than clojure classes - I'd love to only
 see my code)

 Have you tried profiling with YourKit? They allow free usage for open
 source projects.

 David

YourKit was fantastic!! I especially loved the 'Hot Spots'
functionality--it led me right to the problems.

I've sped up Amotoen by several orders of magnitude on some of my
tests... I'm into the mid-twenty milliseconds on my self-check. It's
funny... I didn't believe it was that much faster - I had to step in
and verify that it was still creating the structures it needed to
instead of just bailing on an error or something.

Turns out that ref and dosync are *really* expensive. I always knew
there was a hit, but I never realized how much 'till now.

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


Re: Can you make Amotoen faster?

2012-07-19 Thread Richard Lyman
On Thu, Jul 19, 2012 at 7:09 AM, David Nolen dnolen.li...@gmail.com wrote:
 On Wed, Jul 18, 2012 at 10:12 PM, Richard Lyman richard.ly...@gmail.com 
 wrote:
 All,

 There's not much code, and (sadly) not much documentation, but what's
 there needs some performance love.

 https://github.com/richard-lyman/amotoen

 Notes:
  - jvisualvm doesn't like me this week so help there might be enough
 (I can't see anything other than clojure classes - I'd love to only
 see my code)

 Have you tried profiling with YourKit? They allow free usage for open
 source projects.

 David

I seem to remember looking into it at some point... I'll check it out again.

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


Can you make Amotoen faster?

2012-07-18 Thread Richard Lyman
All,

There's not much code, and (sadly) not much documentation, but what's
there needs some performance love.

https://github.com/richard-lyman/amotoen

Notes:
 - jvisualvm doesn't like me this week so help there might be enough
(I can't see anything other than clojure classes - I'd love to only
see my code)
 - reifying IPosition to a faster implementation seems like it has potential
 - I've used *warn-on-reflection* and fixed the single spot it mentioned
 - I'm not convinced that the code used in 'either' is the best, and
I'm a bit confused about why it's better than the two other
commented-out forms
 - Switching IPosition grammar-grammar away from a character-based
approach is an option, just one I'd like to avoid

It's a leiningen project, with 'lein test' being what I run to check
performance. The grammar parses itself 40 times and prints out how
long that took. The self-check method might be a good place to start
if walking through the code. Ignore the grammar samples, they haven't
been updated in a while. Basically the two 'core' files, under src and
test are all I'm working with right now.

Is it already as 'fast' as it can be??

-Rich

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


Re: Creating parsers in clojure

2012-02-03 Thread Richard Lyman
The little information you've provided leaves the field pretty open...

... but when I'm 'toying' around with ASTs I like Amotoen ('course I'm
probably biased. ;-)).

https://github.com/richard-lyman/amotoen

-Rich


On Fri, Feb 3, 2012 at 6:21 AM, Anna spiegl...@list.ru wrote:
 I'm new to clojure and I'm looking for code examples for building
 parsers in clojure on the fly using a grammar. I'm supposed to write a
 little SQL parser to experience with sql parse tree normalization's.
 Any recommendations?

 --

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


Re: Looking for parser generator library

2012-01-28 Thread Richard Lyman
Have you looked at amotoen?

https://github.com/richard-lyman/amotoen

I'm not sure what your needs are...

-Rich



On Sat, Jan 28, 2012 at 8:19 AM, Roman Perepelitsa
roman.perepeli...@gmail.com wrote:
 I'm looking for a parser generator library. I stumbled upon fnparse, but
 unfortunately it doesn't work with clojure 1.3.

 Roman Perepelitsa.

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

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


Re: Building Clojure applications w/ Maven

2011-12-06 Thread Richard Lyman
Can you provide the pom you're using?

By 'build' do you mean AOT?

-Rich



On Tue, Dec 6, 2011 at 3:35 PM, Riccardo riccardo.novie...@gmail.com wrote:
 Hello, I am doing my dissertation project with Clojure and I am using
 Maven to build. It works on REPL and it build successfully, but the
 JAR file doesn't work, it says: Java Exception all the time. Any
 suggestion?

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

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


Re: Handling of unsigned bytes

2011-02-11 Thread Richard Lyman
I have to deal with them when processing AMF packets, and I use the
Netty library - it's amazing, you should look into it.

http://www.jboss.org/netty

-Rich


On Fri, Feb 11, 2011 at 10:22 AM, timc timgcl...@gmail.com wrote:
 How on earth is one supposed to do communication programming (not to
 mention handling binary files etc) without an unsigned byte type?

 I see that this issue has been talked about vaguely - is there a
 solution?

 Thanks

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


Re: getting started with clojure

2010-10-19 Thread Richard Lyman
On Tue, Oct 19, 2010 at 5:55 PM, ishkabible j...@ehrlichks.net wrote:
 lastly i have been messing around with new languages just to try them
 out.

Fantastic fun! I wish you the best of luck.

 in trying out coljure (only functional language i have tried yet)
 but i can compile anything longer than one line.

Are you using the 'repl'? That process can feel very different from
some styles of Clojure development.

 im using Coljure Box
 but im very confused as to how i am supposed to write code that dose
 more than one thing. basically how do i save files, compile them, then
 run them?

Clojure Box likely has a specific process that it advocates since it
uses ... clojure-mode and Slime, plus all the power of Emacs under
the hood.

While this development process works for some (most?) it doesn't work
so well for others.

I've documented one way of developing using Ant[1] and a certain
folder structure... which was OK for a while but I've since switched
to leiningen[2].

In the end all you _really_ need is to find a process that fits how
you're used to working. You can refer to the 'Getting Started' page on
the Assembla Wiki[3].

Again, good luck and have fun!

-Rich

[1] 
http://www.lithinos.com/Compiling-Clojure-Applications-and-Libraries-Round-2.html
[2] http://github.com/technomancy/leiningen
[3] http://www.assembla.com/wiki/show/clojure/Getting_Started

-- 
You 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: Flex as a Clojure Frontend

2010-08-16 Thread Richard Lyman
On Sun, Aug 15, 2010 at 9:13 PM, nchubrich nchubr...@gmail.com wrote:
 Thanks Rich--I'm actually interested in all kinds of configurations.
 For the time being, it will be a Flex frontend in the browser
 communicating with Clojure on the server.  In the future, we might
 want to make the Clojure part into a Java applet that runs on the
 client side and does computations while Flex handles the interface;
 finally, I'm also (in the long-term) interested in building standalone
 apps that use Flex/AIR for the interface and Clojure/Java for the
 backend.

 It all seems rather complicated, but I've found Flex to be the best
 way of programming interfaces (so far).

 Concerning BlazeDS and AMF: what is the advantage of that over just
 using straight HTTP with say JSON?  I know RTMP has push capability;
 any other reasons?

 -Nick.


Push has never been much of a selling point of RTMP for me, you could
use HTTP long-polling for a similar result. Bandwidth is probably the
largest selling point, with readability the biggest negative in
RTMP/AMF.

To understand what I mean about bandwidth, you could checkout:
http://www.jamesward.com/census/

-Rich

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


[ANN] clj-peg is dead

2010-08-16 Thread Richard Lyman
Since Amotoen does everything that clj-peg did, and since Amotoen does
it in a more maintainable way...

http://github.com/richard-lyman/amotoen

-Rich

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


Re: Flex as a Clojure Frontend

2010-08-15 Thread Richard Lyman
On Sat, Aug 14, 2010 at 1:40 PM, nchubrich nchubr...@gmail.com wrote:
 I'm wondering if anyone has any experience developing Clojure
 applications with a Flex interface, and if so, what is the best way of
 going about it.


I have quite a bit of experience. I've been writing an internal
implementation of the non-media parts of RTMP, so that your backend
can be anything that runs on the JVM (Java, Clojure, Scala, Groovy,
JRuby, etc.) and your frontend can be pure ActionScript.

The 'best way' probably depends on how you'll be deploying your
application. Are you going with some J2EE container, are you packaging
everything into a standalone app? (Or maybe something between the
two...)

 I also wonder if anyone has used Las3rI'm a little reluctant to
 use it because the Flash Builder programming environment is so
 effective.

 Thanks,

 Nick.

I don't have experience with Las3r - but it says it's a port of
Clojure (parts of) to run on the AVM2. That's pretty different than
the standard method of communication between a Flex frontend and a JVM
backend. If I were you I'd look at getting Jetty or Tomcat (JBoss if
you're very brave or previously-enterprise-skilled) to work with
BlazeDS - then you can write your Clojure code compiled to JARs and
expose the methods as AMF messagebrokers to a RemoteObject running
from Flex.

-Rich

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


Re: ClojureDocs.org

2010-07-11 Thread Richard Lyman
On Sun, Jul 11, 2010 at 8:14 AM, Phil Hagelberg p...@hagelb.org wrote:
 On Sat, Jul 10, 2010 at 11:23 PM, zkim zachary@gmail.com wrote:
 but what do you think about using Justin's codebase, or an Aleph-based 
 server to
 host the thing instead of Ruby/Rails? (see the link above for more details)

 I'm inclined to move forward with the Ruby / Rails for now.  The
 reason I went with rails is that (in my experience) none of the
 clojure web libraries are mature enough to do something like
 clojuredocs as quickly and easily as I personally would be able to do
 in rails.

 Could you provide details about what it was specifically that you
 found was lacking?

 -Phil


It sounded to me like he was only saying that he's more familiar with
Ruby/Rails than he is with Clojure. It seemed like it was a question
of 'time to finish and tweak' that's shortest for him if he wrote it
in Ruby/Rails.

Maybe this is a good opportunity to be able to compare two
implementations side-by-side. His excellent solution with one written
in Clojure that produces the same-ish website.

-Rich

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


Re: DSL with a grammar

2010-07-08 Thread Richard Lyman
On Thu, Jul 8, 2010 at 1:34 PM, Nicolas Oury nicolas.o...@gmail.com wrote:
 Sorry, that's why I had quote around my parse.
 I meant, use clojure reader to take a sequence in a macro and then parse
 it for my own DSL.
 So I shouldn't need any help from the reader (even if having some metas with
 line and character attached to thing would help)
 I do not want to go the parser generator way because I want the DSL to be
 tightly integrated with Clojure.

The clj-peg library allows for a grammar that is all Clojure code.
It's successor will be even more integrated.

Both _could_ be considered parser combinators... so you might not want
to rule out all parser combinators as not being tightly integrated.

Just FYI. I hope you find what you're looking for. :-)

-Rich

 Thanks for your answer,


 Nicolas.

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


Recommendations on prepping a library for 1.2 release?

2010-06-16 Thread Richard Lyman
I guess I'm mostly wondering where to get the best (continually
update-able best) version of 1.2 core (and contrib?) before it's
released.

I'd rather not go Lein or Maven2 - just a vanilla checkout and Ant if
that's still a supported build option.

Everything's on github - right? The simplest commands to grab the core
(and contrib?) from github as well as the commands to keep updating
every week or so until release would be fantastic.

All of this is assuming, hopefully incorrectly, that there's no
automated nightly JAR that's being produced and made available
somewhere.

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
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: Recommendations on prepping a library for 1.2 release?

2010-06-16 Thread Richard Lyman
On Wed, Jun 16, 2010 at 8:36 PM, David Nolen dnolen.li...@gmail.com wrote:
 On Wed, Jun 16, 2010 at 10:17 PM, Richard Lyman richard.ly...@gmail.com
 wrote:

 Everything's on github - right? The simplest commands to grab the core
 (and contrib?) from github as well as the commands to keep updating
 every week or so until release would be fantastic.

 git clone url, to get it
 git pull, to update it
 git fetch, to grab the other branches
 git checkout branch, to switch to a branch
 ant, to build the branch you are on.

Do I need any branches? What are the branches? I thought that when a
branch was stable it would be merged back into master (if I'm using
the right terms).


 All of this is assuming, hopefully incorrectly, that there's no
 automated nightly JAR that's being produced and made available
 somewhere.

 The clojure master branch is being built continuously here,
 http://build.clojure.org/

When you say master branch, do you mean just core, or does that include contrib?

Speaking of which: Should I still care about contrib? I remember
hearing that several items had been merged into core...

 David

Thanks for the quick and succinct response.
-Rich

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


Re: Macros, any reading suggestion?

2010-06-03 Thread Richard Lyman
On Thu, Jun 3, 2010 at 1:24 PM, Miki miki.teb...@gmail.com wrote:
 Hello alux,

 I still have some technical questions, but the main issue seems to be
 that I need to dive more deeply into the whole area of macro
 programming.
 You might find http://www.paulgraham.com/onlisp.html interesting.
 (The PDF version of the book is free to download there)

 It's about common lisp, but taught me a lot about macros.

 HTH,
 --
 Miki

I'd second the onlisp book.

In addition to that book, code is the best thing to understanding the
abilities that macros bring.

-Rich

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


Re: Calling for advice on a parser's location data

2010-05-02 Thread Richard Lyman
On Sun, May 2, 2010 at 6:29 PM, joshua-choi rbysam...@gmail.com wrote:
 I'm making a parsing library that can keep track of its location in a
 stream of tokens, and the tokens can be of any type—character, map,
 and so forth. I need advice on this question:

 Can you think of an instance where the location would not be a line
 number and column number, such as {:line 3, :column 25}?

Binary input wouldn't be required to have a concept of lines or columns.

 I'm deciding if I should bother with the trouble of making the
 location data structure independent and pluggable with my parser, or
 if I should make it always a line-column pair, which would make the
 API much simpler.

The clj-peg library requires pre-wrapping any input to be parsed in an
interface that provides quite a bit of flexibility like this.

I would agree that it makes it more complicated though.

-Rich

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


Re: jogl classpath not found

2010-03-11 Thread Richard Lyman
I'm not sure if this will help, but here's some tidbits from the day I spent
toying around with JOGL... I think it was version 1.1.1.

This is part of the Ant file that I used:
...
java classname=clojure.lang.Compile fork=true
failonerror=true
classpath
pathelement location=${src_dir} /
pathelement location=${src_dir}/classes /
pathelement location=${clojure_jar} /
pathelement location=${contrib_jar} /
pathelement location=${jogl_jar} /
pathelement location=${gluegen_jar} /
/classpath
sysproperty key=clojure.compile.path
value=${src_dir}/classes /
arg line=${files_to_compile} /
/java
...

I can reproduce a similar error by commenting out the line for the jogl_jar.

Exception in thread main java.lang.ClassNotFoundException:
javax.media.opengl.GLCanvas (jogltest.clj:1)

Here's the Clojure file I used (be warned - it's very very bad Clojure
code):

(ns jogltest
(:import
(java.io BufferedReader InputStreamReader)
(java.awt Frame)
(java.awt.event WindowListener WindowAdapter KeyListener KeyEvent)
(javax.media.opengl GLCanvas GLEventListener GL GLAutoDrawable)
(javax.media.opengl.glu GLU)
(com.sun.opengl.util Animator))
(:gen-class))

(defn exit [a f]
(.stop a)
(.dispose f))


(defn -main [ args]
(println works)
(let [
rotateT 0
glu (new GLU)
canvas (new GLCanvas)
frame (new Frame Jogl 3D Shape/Rotation)
animator (new Animator canvas)]

(.addGLEventListener
canvas
(proxy [GLEventListener] []
 (display
  [#^GLAutoDrawable drawable]
  (doto (.getGL drawable)
(.glClear (. GL GL_COLOR_BUFFER_BIT))
(.glClear (. GL GL_DEPTH_BUFFER_BIT))
(.glLoadIdentity)
(.glTranslatef 0 0 -5)
(.glRotatef rotateT 1 0 0)
(.glRotatef rotateT 0 1 0)
(.glRotatef rotateT 0 0 1)
(.glRotatef rotateT 0 1 0)
(.glBegin (. GL GL_TRIANGLES))
; Front
(.glColor3f 0 1 1) (.glVertex3f 0 1 0) (.glColor3f 0 0 1) (.glVertex3f
-1 -1 1) (.glColor3f 0 0 0) (.glVertex3f 1 -1 1)
; Right Side Facing Front
(.glColor3f 0 1 1) (.glVertex3f 0 1 0) (.glColor3f 0 0 1) (.glVertex3f 1
-1 1) (.glColor3f 0 0 0) (.glVertex3f 0 -1 -1)
; Left Side Facing Front
(.glColor3f 0 1 1) (.glVertex3f 0 1 0) (.glColor3f 0 0 1) (.glVertex3f 0
-1 -1) (.glColor3f 0 0 0) (.glVertex3f -1 -1 1)
;Bottom
(.glColor3f 0 0 0) (.glVertex3f -1 -1 1) (.glColor3f 0.1 0.1 0.1)
(.glVertex3f 1 -1 1) (.glColor3f 0.2 0.2 0.2) (.glVertex3f 0 -1 -1)
(.glEnd))
  (def rotateT (+ 0.2 rotateT)))

 (displayChanged [drawable m d])

 (init
  [#^GLAutoDrawable drawable]
  (doto (.getGL drawable)
(.glShadeModel (. GL GL_SMOOTH))
(.glClearColor 0 0 0 0)
(.glClearDepth 1)
(.glEnable (. GL GL_DEPTH_TEST))
(.glDepthFunc (. GL GL_LEQUAL))
(.glHint (. GL GL_PERSPECTIVE_CORRECTION_HINT)
 (. GL GL_NICEST)))
  (.addKeyListener
   drawable
   (proxy [KeyListener] []
 (keyPressed
  [e]
  (when (= (.getKeyCode e) (. KeyEvent VK_ESCAPE))
(exit animator frame))

 (reshape
  [#^GLAutoDrawable drawable x y w h]
  (when ( h 0)
(let [gl (.getGL drawable)]
  (.glMatrixMode gl (. GL GL_PROJECTION))
  (.glLoadIdentity gl)
  (.gluPerspective glu 50 (/ w h) 1 1000)
  (.glMatrixMode gl (. GL GL_MODELVIEW))
  (.glLoadIdentity gl))

(doto frame
(.add canvas)
(.setSize 640 480)
(.setUndecorated true)
(.setExtendedState (. Frame MAXIMIZED_BOTH))
(.addWindowListener
 (proxy [WindowAdapter] []
   (windowClosing [e] (exit animator frame
(.setVisible true))
(.start animator)
(.requestFocus canvas)

;(Thread/sleep (* 1 1000))

)
)

Good luck!!
-Rich

P.s. - I switched to using JME... it had more of the features I was looking
for.

-- 
You 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: map not working in loop

2010-03-05 Thread Richard Lyman
On Fri, Mar 5, 2010 at 7:05 AM, Glen Rubin rubing...@gmail.com wrote:

 The following code does not work, when using (range 1 5) as coll
 input:


 (defn pyt [coll]
  (loop [b (rest (coll))]

(map  #(* % %) b)))


 The real code was more complicated, but I refined it to its simplest
 form while still producing the error.   (map f coll)  looks correct to
 me??  :(


I'm not sure what effect you're looking for, but...

Don't forget, map is lazy and the function you've supplied as the second
parameter doesn't modify b.

Depending on what outcome you're looking for, you might want to wrap the
call to map in a call to doall, or modify b and your second parameter so
that b is changed.

-Rich

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

Re: map not working in loop

2010-03-05 Thread Richard Lyman
On Fri, Mar 5, 2010 at 7:31 AM, Glen Rubin rubing...@gmail.com wrote:

 The problem was that coll was being called as a fcn as others pointed
 out.  You say the function being supplied as my second parameter does
 not modify my third parameter?

 (defn pyt [coll]
  (loop [b (rest coll)]
   (map  #(* % %) b)))

 I am taking the third parameter and squaring it.  Isn't that a
 modification?

 thx everybody for the help!

 On Mar 5, 7:15 am, Richard Lyman richard.ly...@gmail.com wrote:
  On Fri, Mar 5, 2010 at 7:05 AM, Glen Rubin rubing...@gmail.com wrote:
   The following code does not work, when using (range 1 5) as coll
   input:
 
   (defn pyt [coll]
(loop [b (rest (coll))]
 
  (map  #(* % %) b)))
 
   The real code was more complicated, but I refined it to its simplest
   form while still producing the error.   (map f coll)  looks correct to
   me??  :(
 
  I'm not sure what effect you're looking for, but...
 
  Don't forget, map is lazy and the function you've supplied as the second
  parameter doesn't modify b.
 
  Depending on what outcome you're looking for, you might want to wrap the
  call to map in a call to doall, or modify b and your second parameter so
  that b is changed.
 
  -Rich


Sorry for the miscommunication.

Clojure 1.0.0-
user= (def b '(1 2 3))
#'user/b
user= b
(1 2 3)
user= (map #(* % %) b)
(1 4 9)
user= b
(1 2 3)
user=

I didn't know if the real code used b inside the let after the call to map
and had expected it to be different.

-Rich

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

[ANN] clj-peg 0.7 (switch to EPL)

2010-02-13 Thread Richard Lyman
All,

I've switched the clj-peg library to be under the EPL.

This project adds support in Clojure for Parsing Expression
Grammarshttp://en.wikipedia.org/wiki/Parsing_expression_grammar.
In addition to the basic operators I've added tracking AST branches,
referring to tracked branches, gathering simple repetitions, and specifying
a repetition count. While the current version allows for expanding the types
of supported input to anything you'd like, future releases will include an
input wrapper to process binary structures.

A relevant post:
http://www.lithinos.com/Releasing-clj-peg-under-the-epl.html

The project page: http://www.lithinos.com/clj-peg/index.html

The beginning user manual:
http://www.lithinos.com/clj-peg/0.7.0/clj-peg-manual.pdf

-Rich

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

Re: [ANN] clj-peg 0.7 (switch to EPL)

2010-02-13 Thread Richard Lyman
On Sat, Feb 13, 2010 at 5:33 PM, Brendan Ribera brendan.rib...@gmail.comwrote:

 Cool! I'll probably make use of this soon. Any plans to get it set up on
 github for contributions?



No plans right now. I'm open to the idea, but I'd like to see what it's like
to work with contributions in the current setup.

I'd like to get it to v1.0 before I open it up more.

Let me know how using it goes I'm excited to see if it can help others.

-Rich

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

About releasing clj-peg under the EPL 1.0

2010-01-31 Thread Richard Lyman
I have a few questions I'm hoping to get some feedback on.


 = Releasing source code =
If I understand the EPL 1.0 correctly, under section 3(b) part IV, I'm
forced to release my source code - right?

I _cannot_ just release an AOT JAR under the EPL 1.0 and keep the source
code under a different licence - right?

Or does that only apply to everyone _other_ that the initial Contributor?


 = Other's commercial profit =
Under 2(a) and 2(b) I've pretty much given each Recipient full patent and
copyright permissions. There's nothing available to me if I want to profit
from it in the future. I have to change the license on some future release,
and even then they still would have the full permissions I had granted in
some past release - right?

Under 2(c), even though I've given the permissions I can, the Recipient
still might not be able to distribute my Contribution if my Contribution
infringes some third party patent for which the Recipient is required to
secure any rights that might be necessary. It seems odd that there could
still be some loophole... some way that I could benefit from the third-party
patent licensing - right?


This has been a fairly painful process for me, thanks for any helpful
feedback.
-Rich

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

Re: clj-peg v0.6 released

2010-01-10 Thread Richard Lyman
On Fri, Jan 8, 2010 at 11:07 AM, Paul Mooser taron...@gmail.com wrote:

 At some point, hopefully someone will write an open-source parsing
 library with liberal licensing terms for clojure.


Would you mind elaborating on your definitions for the terms open-source
and liberal licensing?

I'm not sure I like the current licensing scheme for clj-peg and I've spent
quite a bit of time thinking about how I should approach this project's
license in particular. I have two very different perspectives about this
issue.

On the one hand, if I were a user and not the developer I doubt I'd use this
library because I really don't like paying for software. I also would be a
bit wary of the 'except for commercial use' part in the license.

On the other hand, I've put a significant amount of time and energy into
this as a product. Money isn't what it used to be and I'm reluctant to lose
the potential extra income that a dual license might provide.

There is value in augmenting whatever reputation I have by providing the
code for free, but reputation alone doesn't pay the bills.

So... that's why I'm wondering if you would mind helping me understand your
point-of-view.

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

Re: [ANN] clj-peg v0.6 released

2010-01-08 Thread Richard Lyman
Currently I'm only providing the code in AOT form. If the JAR is on your
classpath everything in the manual works just fine.

Did that answer your question?

-Rich


2010/1/7 Michał Kwiatkowski constant.b...@gmail.com

 On Mon, Jan 4, 2010 at 11:27 PM, Richard Lyman richard.ly...@gmail.com
 wrote:
  This project adds support in Clojure for Parsing Expression Grammars.
  You'll be able to write pseudo-ebnfs directly in your Clojure code.

 Sounds nice, but where's the source code?

 Cheers,
 mk
-- 
You 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: clj-peg v0.6 released

2010-01-05 Thread Richard Lyman
I'm not familiar with Scala's parser combinators, in addition, I'm fuzzy on
the technical definition of a parser combinator.

I think I'd call it a parser combinator, since the grammar is embedded in
the code using native Clojure data structures, evaluation can be delayed,
and grammar definitions can be modified at runtime before the parser is
generated.

What key parts to the definition of parser combinator would need to be met
in order to be comparable to Scala's parser combinators?

-Rich


On Tue, Jan 5, 2010 at 6:00 AM, Seth seth.schroe...@gmail.com wrote:

 I forgot to appreciate having something like clg-peg to play with...
 no clue where my manners went. Is this comparable at all to Scala's
 parser combinators?


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

Re: [ANN] clj-peg v0.6 released

2010-01-05 Thread Richard Lyman
For now I'd rather be compensated if someone were planning on using clj-peg
commercially. I'm not sure how much I'd charge for a commercial-friendly
license, and I don't have an automated process for handling billing and
production of a differently licensed product, so I'm reluctant to move that
direction for now.

If you were interested in licensing clj-peg under different terms I'm
willing to discuss it outside of this mailing list.

Did that answer your question?

-Rich



On Tue, Jan 5, 2010 at 8:17 AM, Stefan Tilkov stefan.til...@innoq.comwrote:

 Richard, can you elaborate on the license?

 The license page says Permission is granted to use and redistribute this
 software except for commercial use […]

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

[ANN] clj-peg v0.6 released

2010-01-04 Thread Richard Lyman
All,

This project adds support in Clojure for Parsing Expression Grammars.
You'll be able to write pseudo-ebnfs directly in your Clojure code.

Currently, this...
 Expr  - [Sum $]
 Sum   - [Product (* [SumOp Product])]
 Product   - [Value (* [ProductOp Value])]
 Value - (| Num Sum)
 Num   - JSONNumber
 SumOp - #^[+-]
 ProductOp - #^[*/]
... turns into a parser with only a few extra lines of code (three more
lines would be comfortable).

The grammar reads quite easily as well. The production for the non-terminal
Sum could be read, A Sum is a Product followed by zero-or-more of the SumOp
Product pair.

Project page: http://www.lithinos.com/clj-peg/index.html
Manual: http://www.lithinos.com/clj-peg/0.6.10/clj-peg-manual.pdf

-Rich

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

Re: clj-peg v0.6 released

2010-01-04 Thread Richard Lyman
Oh, sorry!

I was thinking about releasing this version last week - but with the new
year likely taking precedence I thought I'd wait.

Maybe next time I'll send you a version a few days before I announce it. ;-)

-Rich



On Mon, Jan 4, 2010 at 3:32 PM, Anniepoo annie6...@yahoo.com wrote:

 Sweet!

 Wish I'd had this a few days ago, I just spent the last few days
 writing parsers.


-- 
You 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: clj-peg v0.6 released

2010-01-04 Thread Richard Lyman
Yeah, the management software for my site is in flux. Getting RSS done is on
the todo list, but not very high.

There really aren't pre-releases - when I have a version to release I
announce it here as soon as it's available. I hadn't thought that there
might actually be people interested in pre-releases... thanks for the
suggestion. Maybe adding RSS feeds back in should take a higher priority.

-Rich



On Mon, Jan 4, 2010 at 8:25 PM, Seth seth.schroe...@gmail.com wrote:

 An RSS feed might help early adopters test prereleases, but it's been
 explicitly disabled?

 On Jan 4, 5:43 pm, Richard Lyman richard.ly...@gmail.com wrote:
  Oh, sorry!
 
  I was thinking about releasing this version last week - but with the new
  year likely taking precedence I thought I'd wait.
 
  Maybe next time I'll send you a version a few days before I announce it.
 ;-)
 
  -Rich
 
 
 
  On Mon, Jan 4, 2010 at 3:32 PM, Anniepoo annie6...@yahoo.com wrote:
   Sweet!
 
   Wish I'd had this a few days ago, I just spent the last few days
   writing parsers.


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

[ANN] clj-peg 0.4

2009-07-08 Thread Richard Lyman
Version 0.4 brings modifications to the syntax for declaring grammars as
well as suggestions about avoiding the exponential runtimes that can occur.

Here is a post walking through these
changeshttp://www.lithinos.com/New-syntax-and-linear-runtime-options-in-clj-peg.html
.

-Rich

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



Re: Questions / guidelines for adopting Clojure

2009-07-07 Thread Richard Lyman
On Tue, Jul 7, 2009 at 6:08 AM, Roman Roelofsen 
roman.roelof...@googlemail.com wrote:


 Hi all!


Hello! Welcome to the group.

snip

* Syntax *

 I never used a LISP-like language before and I can't read the clojure
 code as fluent as code from different languages. Take for example this
 scala snippet:

 (0 until 100) map (_ * 2) filter (_ % 3 == 0)

 I can easily read this line from left to right (just like english) and
 instantly see whats going on. By contrast, I have to read the clojure
 version a couple of times to understand it:

 (filter #(= 0 (rem % 3)) (map #(* 2 %) (range 100)))

 Is this just a matter of pratice? Do you find it easy to read the
 clojure version?


I find it easier to read Clojure code when I don't have everything on one
line. In other languages I've been able to put everything on one line and
survive, but in CL and Clojure it has always read better on multiple lines.
For instance, the code you provided could be written like:

(filter   #(= 0 (rem % 3))
  (map   #(* 2 %)
(range 100)))

Then the parts of the code and their relations can be easier to find. Now I
can easily tell that whatever comes out of the call to map is being filtered
- without caring about what is 'under' the call to map. This ability to
ignore the parts that are 'inside' some deeper code has helped me in reading
Clojure code.

large snip



 Sorry for the long posting and thanks a lot for reading it ;-)


I don't mind the long posting. You had everything sectioned out nicely.

Cheers,

 Roman



Good luck with learning Clojure, I hope you continue to enjoy it..

-Rich

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



[ANN] clj-peg

2009-07-03 Thread Richard Lyman
I'm a little apprehensive about sharing this project with others, but I
thought I might as well try.

I'm very interested in any feedback, but for now the license is a
bit-non-open.
There are modifications that I'm still wanting to make to the core before I
fully open the license.

Here's a bit of info:
 - clj-peg is intended to eventually support Parser Expression
Grammarshttp://en.wikipedia.org/wiki/Parsing_expression_grammar(it
does a good job as is).
 - It's released as an AOT compiled pair of JARs (I'd love feedback on this
approach to distributing a Clojure library).
 - It is in _no_ way optimized. (I'm pretty sure current runtimes are
exponential in the worst case.)
 - The project page is at: http://www.lithinos.com/clj-peg/
 - An intro post is at: http://www.lithinos.com/Intro-to-clj-peg.html

A sample of the syntax that I'm currently using (though I'm really not happy
with it yet):
Expr  - (=ast expr-ast (=s Sum (=e)))
Sum   - (=ast sum-ast (=s Product (=* (=s SumOp Product
Product   - (=ast product-ast (=s Value (=* (=s ProductOp Value
Value - (=ast value-ast (=o Num (=s LParen Expr RParen)))
Num   - (=ast num-ast (=+ NumChar))
SumOp - #^[+-]
ProductOp - #^[*/]
LParen- (
RParen- )
NumChar   - #^[0-9]

What does everyone think?

-Rich

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



Re: How to call function (or Java method) using string name?

2009-04-27 Thread Richard Lyman
There's a section on the wiki with almost the exact same title:

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

If I'm understanding the question correctly that should do what you're
wanting to do.

-Rich


On Sun, Apr 26, 2009 at 11:50 AM, timc timgcl...@gmail.com wrote:


 Thanks Stuart.

 I have figured out another way, which is much more general (and uses
 the lowest level of how Clojure works).

 (defn evalStr [s] (clojure.lang.Compiler/eval (clojure.lang.RT/
 readString s)))

 will (attempt to) execute any valid form (i.e. the string that is the
 source of the form).

 Thus: (evalStr (+ 1 2)) -- 3


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



[ANN] Compiling Clojure applications using Ant

2009-04-11 Thread Richard Lyman
Searching for 'clojure ant compile' returns pages that talk about the
process of compiling the Clojure and Contrib JARs - but I couldn't find
pointers on setting up a project to use Ant, so...

http://www.lithinos.com/Compiling-Clojure-applications-using-Ant.html

What do you guys think?

-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: [ANN] Compiling Clojure applications using Ant

2009-04-11 Thread Richard Lyman
Cool. Thanks for the pointer to clojure.lang.Compile and the reminder about
failonerror - I'll update it as soon as I can.

I'll also look into coming up with a clearer explanation of the app
variable.

Thanks!
-Rich



On Sat, Apr 11, 2009 at 3:55 PM, John D. Hume duelin.mark...@gmail.comwrote:


 On Sat, Apr 11, 2009 at 3:49 PM, Richard Lyman richard.ly...@gmail.com
 wrote:
  http://www.lithinos.com/Compiling-Clojure-applications-using-Ant.html
 
  What do you guys think?
 
  -Rich

 It's a bit simpler to use clojure.lang.Compile as a main class.
 Here's the relevant bit from one of my build.xmls:

  target name=compile depends=clean,init
java classname=clojure.lang.Compile
  classpathref=project.classpath
  fork=true
  failonerror=true
  classpath path=${src.dir} /
  sysproperty key=clojure.compile.path value=${classes.dir} /
  arg value=clj-record.boot /
/java
  /target


 http://github.com/duelinmarkers/clj-record/blob/c8235e7d854c0049a785d7773665cb6c62efb024/build.xml#L30

 I strongly recommend failonerror=true so that your build will abort
 if compilation fails. (If you stick with the clojure.main -e
 (compile... approach I think you'll find clojure.main doesn't exit
 with an error code, so it won't work. There's another recent thread
 about that and I'm planning to open an issue and submit a patch for it
 when I have a chance. clojure.lang.Compile does exit with an error
 when compilation fails, so the above will fail a build appropriately.)

 Also, I'd recommend being clearer in describing the app variable. It
 will need to be a Clojure namespace that when loaded will (one way or
 another) load in all of your Clojure code. If someone is building a
 library, it's relatively likely there is no such namespace.

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

 


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

2009-02-24 Thread Richard Lyman
It's probably already been changed.

They've had a really fast response time here for things like that.

-Richard



On Tue, Feb 24, 2009 at 10:08 AM, Marko marko.van.doo...@gmail.com wrote:


 Strange, I'm sure I saw 7 this morning and not 36. Either I was
 delusional or somebody changed it already.
 


--~--~-~--~~~---~--~~
You 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: Invoking Java method through method name as a String

2009-02-22 Thread Richard Lyman
This is _so_ awesome!!

Thanks a ton for your patient help Tim, and others.

In the end I also had to switch the use of into-array to to-array, since
into-array expects all the elements to be the same type, and my args were of
varying types. Using to-array worked since it cast each element to the
Object type before passing it along.

Again, thanks a ton. I'd been working for quite a while on trying to get
this knot tied off.

I'm going to make a page on the Wiki about this, hopefully no one else will
need to go through this again. :-)

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



[Solved] Re: Invoking Java method through method name as a String

2009-02-22 Thread Richard Lyman
I've added a section on the Wiki under the examples:

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

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



Invoking Java method through method name as a String

2009-02-21 Thread Richard Lyman
I have an instance of the Java class in a variable.
I have the method arguments in a vector.
I have the method name as a String.

I've tried so many different ways to invoke that method on that class and
pass those parameters. I've tried macros, reflection, and read/eval. None of
the ways I've tried feel right, and none of them have worked so far. Rather
than dump all the failed code, here's some pseudo-code that I wish worked...

(prn Result: 
   (apply (memfn-from-string nameOfMethod)
 class-instance
 [arg1 arg2 arg3]))

Any pointers? What am I not seeing? Am I wanting too much?

Thanks!
-Richard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Invoking Java method through method name as a String

2009-02-21 Thread Richard Lyman
Thanks for the quick response! :-)

This works fine when the method name is not in a var, but if you try:

user= (defmacro my-invoke [method-str instance  args]
 `(. ~instance ~(symbol method-str) ~...@args))
nil
user= (my-invoke toString 5)
5
user= (def command toString)
#'user/command
user= (my-invoke command 5)
java.lang.IllegalArgumentException: No matching field found: command for
class java.lang.Integer (NO_SOURCE_FILE:0)
user=


The macro is processed before the expression is eval'd - right? That's why
the call to symbol inside the macro returns 'command' as the method you're
invoking - right?

I'm not sure I'm understanding everything here, but it seems like I'm
needing a way to delay the evaluation of that part of the macro until the
value bound to the command var can be inserted...

-Richard




On Sat, Feb 21, 2009 at 6:15 AM, Timothy Pratley
timothyprat...@gmail.comwrote:


 Hi Richard,

 As you probably know, Clojure java interop requires the method to be a
 symbol:
 user= (. 5 toString)
 5

 So if you want to invoke a method from a string, you can convert the
 string to symbol first:
 user= (symbol toString)
 toString

 Great! but (. 5 (symbol toString)) wont work because (symbol
 toString) is not evaluated. Instead it gets transformed into
 5.symbol(toString) which is not what we want :( :(
 However with a little trickery we can still do it (please excuse
 ugliness - my macro-fu is weak):

 (defmacro my-invoke [method-str instance  args]
  `(. ~instance ~(symbol method-str) ~...@args))

 user= (my-invoke toString 5)
 5



 Regards,
 Tim.
 


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

2009-02-21 Thread Richard Lyman
From the http://clojure.org/getting_started page:

Clojure is delivered in a zip file containing a single .jar, clojure.jar, a
readme, the CPL license and the source code in a src subdirectory. It uses
the ASM 3.0 bytecode library http://asm.objectweb.org/, and the current
alpha distribution includes it.
Javahttp://java.sun.com/javase/downloads/index.jsp1.5 or greater is
required.

Good luck! :-)

-Richard



On Sat, Feb 21, 2009 at 11:57 AM, Christian Vest Hansen 
karmazi...@gmail.com wrote:


 I *think* that Clojure does not require anything from Java 6, and thus
 can work on any compliant Java 5 or greater.

 On Sat, Feb 21, 2009 at 3:13 PM, Sean francoisdev...@gmail.com wrote:
 
  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!
  
 



 --
 Venlig hilsen / Kind regards,
 Christian Vest Hansen.

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Invoking Java method through method name as a String

2009-02-21 Thread Richard Lyman
Cool... that looks like it got me past the 'method-as-a-string' problem, but
now I'm getting errors with not finding a matching method on the class by
that name. I'm guessing that this means there was a problem matching the
type signature of the method.

The arguments to the method are stored in a 'clojure.lang.PersistentVector',
and if I duplicate the method I'm trying to access but set the only
parameter to be typed as 'clojure.lang.PersistentVector', then it works. The
new method with the new type signature works. Which to me means that we're
passing all the arguments to the method still inside their original vector -
right?

I guess I'm still stuck on how to expand the vector of arguments in place...
and I'm really not very sure what you're doing with the '' in the
parameters for the str-invoke. Is that a way of slurping all the remaining
parameters into a vector? If so, then aren't I needing to do the opposite?

I tried removing the , and into-array - that didn't work. I tried changing
the method into a macro so I could splice in the vector of args - that
didn't work. This is getting frustrating. Everything else has been so
relatively easy to do until now.

I really appreciate your help in walking me through my lack of
understanding.

If I'm following you correctly I think we're here:

user= (defn str-invoke [instance method-str  args]
(clojure.lang.Reflector/invokeInstanceMethod instance method-str (into-array
args)))
#'user/str-invoke
user= (def i sampleString)
#'user/i
user= (def m substring)
#'user/m
user= (def args [2,3])
#'user/args
user= (str-invoke i m args)
java.lang.IllegalArgumentException: Unexpected param type (NO_SOURCE_FILE:0)
user= (str-invoke i m 2 3)
m
user=

-Rich



On Sat, Feb 21, 2009 at 4:19 PM, Timothy Pratley
timothyprat...@gmail.comwrote:


 How embarrassing!

 This works much better:

 (defn str-invoke [method-str instance  args]
  (clojure.lang.Reflector/invokeInstanceMethod instance method-str (to-
 array args)))

 (let [ts toString, ct compareTo]
  (println (str-invoke ts 5))
  (println (str-invoke ct 5 4))
  (println (str-invoke ct 5 5)))

 ie: this is just using reflection as pmf suggested, however I think
 this form is more convenient as Clojure's Reflector class does all the
 hard work of matching the parameters for you. I'm sure someone will
 post a macro solution, but hopefully this will do till then.


 Regards,
 Tim.


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