[ANN] Funcgo: writing Clojure using a Go-like syntax

2014-07-07 Thread Eamonn O'Brien-Strain
Announcing Funcgo (Functional Go), a new language with a Go-like syntax 
that compiles to Clojure.

See https://github.com/eobrain/funcgo

As a teaser, here is an example of some code:

func sumSquares(vec) {
loop(accum=0, v=vec) {
if isEmpty(v) {
accum
} else {
x int := first(v)
recur(accum + x * x, rest(v))
}
}
}
sumSquares([3, 4, 5, 10])
=> 150

__
Eamonn

-- 
You 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 embedded in a Java Application

2011-09-18 Thread Eamonn
Hi Meikel,Ken
Thank you so much for taking the time to reply to my question.  Meikel
Thanks for the code.  I will implement as described above.

On Sep 18, 6:28 pm, Meikel Brandmeyer  wrote:
> Hi Eamonn,
>
> if you find this too tedious to write and use it quite often, then there is 
> always the possibility to hide things a little bit behind a facade.
>
> class Clj {
>     static final Var seqVar = RT.var("clojure.core", "seq");
>     static final Var keywordVar = RT.var("clojure.core", "keyword");
>     static final Var hashMapVar = RT.var("clojure.core", "hash-map");
>
>     static Object seq(Object x) { return seqVar.invoke(x); }
>     static Object kw(String n) { return keywordVar.invoke(n); }
>     static Object kw(String n1, String n2) { return keywordVar.invoke(n1, 
> n2); }
>     static Object hashMap(Object... args) { return 
> hashMapVar.applyTo((clojure.lang.ISeq)seq(args)); }
>
> }
>
> This would make names a little bit more meaningful (less “invoke”s) for the 
> functions you use most. And you might use your own function names. Of course 
> this won't reach the sugar you get from Clojure itself.
>
> theMap = Clj.hashMap(Clj.kw("a"), 1, Clj.kw("b"), 2);
> foo.invoke(Clj.kw("a"), theMap);
>
> This translates directly into:
>
> (let [the-map (hash-map :a 1 :b 2)]
>   (foo :a the-map))
>
> It should be easy to understand what's going on despite the noise. I believe 
> Java devs are used to noise.
>
> And FWIW: Not quoting "13rabc" by accident in the other scenario will not 
> result in the Reader complaining but puzzled looks where this magical value 
> came from. I personally don't particular like these moments.
>
> My 0,02€. YMMV.
>
> Sincerely
> Meikel

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


Re: Clojure embedded in a Java Application

2011-09-17 Thread Eamonn
Hi Meikel
Thank you for your reply.  Is there a way to populate the HashMap
before passing it to the invoke method

I tried the following
Var keyword = RT.var("clojure.core", "keyword");
Var hashMap = RT.var("clojure.core", "hash-map");
hashMap.invoke(keyword.invoke("a"), 1);

then I created the following function
(defn foo[key paramMap](key paramMap))

Object result=foo.invoke(keyword.invoke("a"), hashMap);

But I got null returned but when I do as you suggest
Object result=foo.invoke(keyword.invoke("a"),
hashMap.invoke(keyword.invoke("a"), 1));
I get 1 returned

Any suggestions welcomed

On Sep 16, 9:56 am, "Meikel Brandmeyer (kotarak)" 
wrote:
> Hi,
>
> Am Donnerstag, 15. September 2011 23:39:10 UTC+2 schrieb Eamonn:
>
> > The code  works BUT if I try to pass in a map for example like so
> > Object result = foo.invoke( "hello","world","#{:a 1 :b 2}");
>
> This does not pass a map to the function, but the string "#{:a 1 :b 2}". And
> from your example I don't see where the class cast exception should come
> from. To create a clojure map use the normal hash-map function.
>
> Var keyword = RT.var("clojure.core", "keyword");
> Var hashMap = RT.var("clojure.core", "hash-map");
>
> foo.invoke("hello", "world", hashMap.invoke(keyword.invoke("a"), 1,
> keyword.invoke("b"), 2));
>
> Hope this helps.
>
> Sincerely
> Meikel

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


Clojure embedded in a Java Application

2011-09-16 Thread Eamonn
Hi

I'm new to Clojure so forgive me if this is a dumb question.  I want
to incorporate some Clojure into a Java application.

String rule="(str key val label)";
String str = "(ns test) " + "(defn foo [key val label] " +
rule +
")";
System.out.println(str);

Compiler.load(new StringReader(str));

// Get a reference to the foo function.
Var foo = RT.var("test", "foo");


// Call it!

Object result = foo.invoke( "hello","world","this is a test");

The code  works BUT if I try to pass in a map for example like so
Object result = foo.invoke( "hello","world","#{:a 1 :b 2}");

I always get a ClassCastException.  Am I doing something ridiculous
here?  Is it possible to pass in a Map from the Java world into the
Clojure code?

Also any comments on using Clojure within a Java app appreciated.  Is
it a good idea.  I was thinking of allowing rules to be dynamically
added to fields within a web application.

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


Re: clojure.contrib.test-contrib.test-jmx build error

2010-02-11 Thread Eamonn McManus
I think you're running into http://bugs.sun.com/view_bug.do?bug_id=6924497
which is unrelated to JMX itself but is a problem of incompatibility
between the JDK class library and the JVM, if for example you are
running with HotSpot Express. A fix should appear in a JDK 6 update
but in the meantime it's probably best to change the test so it
doesn't tickle this bug. One way to do that would be to look only at
MBeans with an ObjectName matching "java.lang:*".

Regards,
Éamonn McManus, JMX Spec Lead

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