Re: Clojure vs Scala - anecdote

2011-09-06 Thread Ambrose Bonnaire-Sergeant
Thanks for sharing Sean, very interesting!

Ambrose

-- 
You 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 vs Scala - anecdote

2011-09-06 Thread Sean Corfield
I just wanted to share this experience from World Singles...

Back in November 2009, we started developing with Scala. We needed a
long-running process that published large volumes of changes from our
member database as XML packets published to a custom search engine.
The mapping from half a dozen tables in the database to a flat XML
schema was pretty complex and the company had tried a number of
solutions with mixed success in the past. I introduced Scala based on
the promises of performance, concurrency and type safety - and
conciseness (especially with XML being a native data type in Scala).

We've been running the Scala publishing daemons in production for most
of two years. Generally they work pretty well but, under stress, they
tend to hit Out of Memory exceptions and, after a lot of poking
around, we became fairly convinced it was due (at least in part) to
the default actor implementation in Scala. Scala is going to fold in
Akka soon and we had been considering migrating to Akka anyone...

But having introduced Clojure this year (after experimenting with it
since about May last year), we figured we'd have a short spike to
create a Clojure version of the Scala code to see how it worked out.

It took about 15 hours to recreate the publishing daemon in Clojure
and get it to pass all our tests. Today we ran a "soak test"
publishing nearly 300,000 profiles in one run. The Scala code would
fail with OoM exceptions if we hit it with 50,000 profiles in one run
(sometimes less). The Clojure code sailed thru and is still happily
running - so we'll be replacing the Scala code during our next
production build.

The other aspect that's interesting is that the Scala code totaled
about 1,000 lines (about 31k characters of code). The Clojure
replacement is just under 260 lines (around 11.5k characters of code).
Neither code base has much in the way of comments (*ahem* - I'm not
proud of that, just pointing out that there's no "noise" offsetting
the code comparison). That doesn't include unit tests either, it's
just the raw production code. The form of the Clojure code mostly
follows the form of the Scala code, most of the same functions - it
was very functional Scala - with some refactoring to helper functions
to make it more modular and more maintainable.

The net result is (obviously) that we'll be taking the Clojure
publishing daemon to production and we'll be dropping Scala
completely.

Kudos to Rich Hickey and the Clojure/core team for creating a great
general purpose language that can solve big problems - thank you!
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
You 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: lambda function returning a constant?

2011-09-06 Thread Phil Hagelberg
On Tue, Sep 6, 2011 at 7:32 PM, julianrz  wrote:
> I come from Scala experience, where it is easy to define a quick
> lambda function returning a constant or another simple expression,
> e.g. "=> true" is a function with no args and returning true. Things
> like that are sometimes useful to pass into higher-order functions
> expecting a function, not a constant. I guess I should forgo the macro
> and go directly with (fn  [] true)

Have you tried (constantly true)? The main difference is that it will
ignore all arguments, but perhaps it's a more concise way of
expressing what you want.

-Phil

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

2011-09-06 Thread Glen Stampoultzis
On 7 September 2011 01:17, Justin Kramer  wrote:

> Prompted by a question on IRC a couple days ago, I built a tool that allows
> you to browse the dependency graph of Clojure projects from GitHub &
> Clojars:
>
> http://clojuresphere.herokuapp.com/
>
> You can see dependencies of a project, but also projects which depend on
> it. You can also see how many projects depend on a specific version
> (combined current & historical usage).
>
> There are caveats, which you can read about on GitHub:
> https://github.com/jkk/clojuresphere
>
> If anyone is interested in having this sort of thing added to Clojars,
> ClojureDocs, or other community sites, let me know.
>
>
>
Very nice tool. I found a lot of libraries I haven't yet got on Clojure
Libraries [1]. I might see if I can link through to the corresponding page
on clojuresphere.

[1] http://clojure-libraries.appspot.com

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

Re: lambda function returning a constant?

2011-09-06 Thread Michael Gardner
On Sep 6, 2011, at 10:43 PM, Armando Blancas wrote:

> For something like "=> true" try:
> user=> (defmacro => [expr] `(fn [] ~expr))
> #'user/=> (macroexpand-1 '(=> true))
> (clojure.core/fn [] true)

Alternatively: (constantly true)

-- 
You 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: lambda function returning a constant?

2011-09-06 Thread Armando Blancas
> (#(true)), is this not calling a function that has no arguments and
> returns true? But it still gives same exception

Not really:
user=> (macroexpand-1 '#(true))
(fn* [] (true))

> I guess I should forgo the macro
> and go directly with (fn  [] true)

For something like "=> true" try:
user=> (defmacro => [expr] `(fn [] ~expr))
#'user/=> (macroexpand-1 '(=> true))
(clojure.core/fn [] true)

-- 
You 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 1.3 Beta 3

2011-09-06 Thread Brent Millare
I'm confused about the notes on section 2.2 Better Exception
Reporting.

There is a link to the Error Handling notes but it only lists several
approaches for handling errors, but it doesn't describe how messages
will be reported better in this release.

I feel this would be a good place to provide some examples.

-Brent

On Sep 5, 11:18 pm, cran1988  wrote:
> I love you all !!!

-- 
You 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 1.3: "defs can now have docstrings"; how so?

2011-09-06 Thread Ken Wesson
On Tue, Sep 6, 2011 at 9:13 AM, Meikel Brandmeyer (kotarak)  
wrote:
> user=> (def foo "A foo" :foo)
> #'user/foo
> user=> (doc foo)
> -
> user/foo
>   A foo
> nil

Hrm. Doc on a var not bound to a function or macro doesn't print its
(default) value?

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
You 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: Re: clojure and emacs

2011-09-06 Thread mmwaikar
I too used to do lein swank from the cmd prompt and then used to load emacs 
and then used to M-x slime-connect.

However I've come to know three modes in emacs - multi-term, shell and 
eshell mode (which is like a command prompt in emacs), so you can do M-x 
multi-term, M-x shell or M-x eshell.

Each has its own peculiarities but it's better than switching between a cmd 
prompt and emacs.

Manoj.

-- 
You 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: lambda function returning a constant?

2011-09-06 Thread julianrz
Thanks, I realize my example is a bit of a corner case, and feels a
little artificial:) It came after some narrowing down a larger problem

Another thing that appeared curious to me, is that Clojure apparently
counts unique %'s inside the #() definition to determine arity of the
macro. But does this mean that macros with no arguments should be
legal?
How about this:

(#(true)), is this not calling a function that has no arguments and
returns true? But it still gives same exception



I come from Scala experience, where it is easy to define a quick
lambda function returning a constant or another simple expression,
e.g. "=> true" is a function with no args and returning true. Things
like that are sometimes useful to pass into higher-order functions
expecting a function, not a constant. I guess I should forgo the macro
and go directly with (fn  [] true)

I think all of this confusion could have been avoided if the compiler
did a better error message, e.g. actually citing the definition of #()
and what it expanded into? Would improve usability. Even macroexpand
does not provide any useful info in this case...

Certainly macros are not for the fainthearted anyway, but all
literature seems to go into #() really fast, so it will be stumbled
upon by novices

Julian

On Sep 6, 12:44 pm, Laurent PETIT  wrote:
> 2011/9/4 julianrz 
>
> > Hello All,
> > I am new to Clojure. Surprised why this code does not work:
>
> > user=> (filter #(%) [1 2 3])
> > ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn
>
> > Here my intent behind #(%) is to define a lambda function returning
> > its argument. Since Clojure defines truth on any type, it should be
> > acceptable as filter function, and the result should be the original
> > array
>
> > Some narrowing down. What's #(%) really good for?
>
> Hello,
>
> #(%) is a macro which expands to (fn* [p1#] (p1#))
>
> #(%) could only be 'useful' if % is a callable without arguments.
>
> What you seem to be after is the builtin function named identity : identity
> returns its argument :
>
> Clojure> (filter ident­ity [1 true false­ nil])­
> (1 true)
> Clojure>
>
> HTH,
>
> --
> Laurent
>
>
>
> > user=> #(%)
> > #
>
> > so it is a function
>
> > user=> (#(%))
> > ArityException Wrong number of args (0) passed to: user$eval26$fn
>
> > Ok, here not enough arguments supplied, fair enough. Let's fix that:
> > user=> (#(%) 1)
> > ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn
>
> > Same problem as the first example. So Clojure understands this is a
> > function, knows it takes some arguments, but cannot call it? What's
> > wrong? The following works:
>
> > (user=> (filter (fn [a] a) [1 2 3])
> > (1 2 3)
>
> > So apparently it has something to do with the fact that #() is
> > shorthand. So in my case, it produces a function which cannot be
> > used... In fact, it seems to just yield the constant, not a function.
> > Ask me, it should work (auto-wrap the constant in a function) or the
> > expression should be illegal. I think it deserves better
> > diagnostics...
>
> > Also, in Practical Clojure book, it says: "The shothand function form
> > #(* %1 %2) is actually identical to the longer form (fn [x y] (* x y))
> > before it is even seen by the compiler." If you literally apply this
> > rule, you will get
>
> > ((fn[x] (1)) 1)
>
> > which throws same exception, not surprisingly, since it tries to
> > evaluate 1 as a fucntion. What it should have done is transform the
> > expression into
>
> > ((fn[x] 1) 1)
>
> > which works fine... Special-case it?
>
> > What do you think?
>
> > Julian
>
> > --
> > You 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: ANN: ClojureSphere - browse the Clojure ecosystem

2011-09-06 Thread Justin Kramer
Thanks, glad you like it.

Note that dependents are listed for an artifact ID ("clojure-contrib") when 
any version of the dependent depends on any version of that artifact ID. So 
some of those libs may have already migrated to the new clojure contrib 
libs. Clicking a version will show which specific versions are dependent:

http://clojuresphere.herokuapp.com/clojure-contrib/org.clojure/1.2.0

Will probably make some changes to clarify that...

Justin

On Tuesday, September 6, 2011 7:03:23 PM UTC-4, Sean Corfield wrote:
>
> On Tue, Sep 6, 2011 at 8:17 AM, Justin Kramer  wrote:
> > Prompted by a question on IRC a couple days ago, I built a tool that 
> allows
> > you to browse the dependency graph of Clojure projects from GitHub &
> > Clojars:
> > http://clojuresphere.herokuapp.com/
>
> This is very cool Justin!
>
> I see that clojure.contrib has about 1,400 projects that depend on
> it... all of which need to be migrated to the new, modular contrib
> libraries at some point! :)
>
> http://clojuresphere.herokuapp.com/clojure-contrib
> -- 
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
> Railo Technologies, Inc. -- http://www.getrailo.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>
>

-- 
You 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: On Lisp with Clojure

2011-09-06 Thread Brian Goslinga
On Sep 6, 11:20 am, Michael Jaaka 
wrote:
> Btw. it looks like Clojure is missing an ability to program reader.
>
> It would allow to program a syntax.
This is by design as there is no good way to namespace syntax.

> The tail recursion and continuations also would be awesome.
Those aren't provided because the tight integration with the JVM makes
it impossible.

-- 
You 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: defrecord == premature optimization?

2011-09-06 Thread Stuart Halloway
> Am Dienstag, 6. September 2011 schrieb Alasdair MacLeod :
> I guess the only gotcha is if a function treats the record as a map
> and
> tries to access a field by putting the record in function position:
> 
> user=> (defrecord Person [first last])
> user.Person
> user=> ((Person. "Joe" "Bloggs"):first )
> java.lang.ClassCastException: user.Person cannot be cast to
> clojure.lang.IFn (NO_SOURCE_FILE:0)
> 
> That's kind of bad, IMO.
> 
> Is that on purpose? What's the rationale?

This is by design. Function position indicates that the data structure is a 
collection, not a (logical) record.

> Aren't defrecords supposed to be drop-in specializations of  maps?

Where maps are used as records, but not where maps are used as collections.

Stu

Stuart Halloway
Clojure/core
http://clojure.com

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

Re: ANN: ClojureSphere - browse the Clojure ecosystem

2011-09-06 Thread Sean Corfield
On Tue, Sep 6, 2011 at 8:17 AM, Justin Kramer  wrote:
> Prompted by a question on IRC a couple days ago, I built a tool that allows
> you to browse the dependency graph of Clojure projects from GitHub &
> Clojars:
> http://clojuresphere.herokuapp.com/

This is very cool Justin!

I see that clojure.contrib has about 1,400 projects that depend on
it... all of which need to be migrated to the new, modular contrib
libraries at some point! :)

http://clojuresphere.herokuapp.com/clojure-contrib
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
You 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: defrecord == premature optimization?

2011-09-06 Thread Herwig Hochleitner
Am Dienstag, 6. September 2011 schrieb Alasdair MacLeod :
>
> I guess the only gotcha is if a function treats the record as a map
> and
> tries to access a field by putting the record in function position:
>
> user=> (defrecord Person [first last])
> user.Person
> user=> ((Person. "Joe" "Bloggs"):first )
> java.lang.ClassCastException: user.Person cannot be cast to
> clojure.lang.IFn (NO_SOURCE_FILE:0)
>

That's kind of bad, IMO.

Is that on purpose? What's the rationale?

Aren't defrecords supposed to be drop-in specializations of  maps?


-- 
__
Herwig Hochleitner

-- 
You 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: lambda function returning a constant?

2011-09-06 Thread Alan Malloy
As Laurent says, you should just use the built-in `identity` function,
but you can write it yourself: as you noticed, (fn [x] x) works, but
if you want to do it with the shorthand syntax you can use #(do %).

On Sep 4, 1:56 pm, julianrz  wrote:
> Hello All,
> I am new to Clojure. Surprised why this code does not work:
>
> user=> (filter #(%) [1 2 3])
> ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn
>
> Here my intent behind #(%) is to define a lambda function returning
> its argument. Since Clojure defines truth on any type, it should be
> acceptable as filter function, and the result should be the original
> array
>
> Some narrowing down. What's #(%) really good for?
>
> user=> #(%)
> #
>
> so it is a function
>
> user=> (#(%))
> ArityException Wrong number of args (0) passed to: user$eval26$fn
>
> Ok, here not enough arguments supplied, fair enough. Let's fix that:
> user=> (#(%) 1)
> ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn
>
> Same problem as the first example. So Clojure understands this is a
> function, knows it takes some arguments, but cannot call it? What's
> wrong? The following works:
>
> (user=> (filter (fn [a] a) [1 2 3])
> (1 2 3)
>
> So apparently it has something to do with the fact that #() is
> shorthand. So in my case, it produces a function which cannot be
> used... In fact, it seems to just yield the constant, not a function.
> Ask me, it should work (auto-wrap the constant in a function) or the
> expression should be illegal. I think it deserves better
> diagnostics...
>
> Also, in Practical Clojure book, it says: "The shothand function form
> #(* %1 %2) is actually identical to the longer form (fn [x y] (* x y))
> before it is even seen by the compiler." If you literally apply this
> rule, you will get
>
> ((fn[x] (1)) 1)
>
> which throws same exception, not surprisingly, since it tries to
> evaluate 1 as a fucntion. What it should have done is transform the
> expression into
>
> ((fn[x] 1) 1)
>
> which works fine... Special-case it?
>
> What do you think?
>
> Julian

-- 
You 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: lambda function returning a constant?

2011-09-06 Thread Laurent PETIT
2011/9/4 julianrz 

> Hello All,
> I am new to Clojure. Surprised why this code does not work:
>
> user=> (filter #(%) [1 2 3])
> ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn
>
> Here my intent behind #(%) is to define a lambda function returning
> its argument. Since Clojure defines truth on any type, it should be
> acceptable as filter function, and the result should be the original
> array
>
> Some narrowing down. What's #(%) really good for?
>

Hello,

#(%) is a macro which expands to (fn* [p1#] (p1#))

#(%) could only be 'useful' if % is a callable without arguments.

What you seem to be after is the builtin function named identity : identity
returns its argument :

Clojure> (filter ident­ity [1 true false­ nil])­
(1 true)
Clojure>

HTH,

-- 
Laurent



>
> user=> #(%)
> #
>
> so it is a function
>
> user=> (#(%))
> ArityException Wrong number of args (0) passed to: user$eval26$fn
>
> Ok, here not enough arguments supplied, fair enough. Let's fix that:
> user=> (#(%) 1)
> ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn
>
> Same problem as the first example. So Clojure understands this is a
> function, knows it takes some arguments, but cannot call it? What's
> wrong? The following works:
>
> (user=> (filter (fn [a] a) [1 2 3])
> (1 2 3)
>
> So apparently it has something to do with the fact that #() is
> shorthand. So in my case, it produces a function which cannot be
> used... In fact, it seems to just yield the constant, not a function.
> Ask me, it should work (auto-wrap the constant in a function) or the
> expression should be illegal. I think it deserves better
> diagnostics...
>
> Also, in Practical Clojure book, it says: "The shothand function form
> #(* %1 %2) is actually identical to the longer form (fn [x y] (* x y))
> before it is even seen by the compiler." If you literally apply this
> rule, you will get
>
> ((fn[x] (1)) 1)
>
> which throws same exception, not surprisingly, since it tries to
> evaluate 1 as a fucntion. What it should have done is transform the
> expression into
>
> ((fn[x] 1) 1)
>
> which works fine... Special-case it?
>
> What do you think?
>
> Julian
>
> --
> You 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: defrecord == premature optimization?

2011-09-06 Thread Alasdair MacLeod
> The types created by defrecord implement the same interfaces as maps,
> so they can be used as maps.

I guess the only gotcha is if a function treats the record as a map
and
tries to access a field by putting the record in function position:

user=> (defrecord Person [first last])
user.Person
user=> ((Person. "Joe" "Bloggs"):first )
java.lang.ClassCastException: user.Person cannot be cast to
clojure.lang.IFn (NO_SOURCE_FILE:0)
user=>

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


lambda function returning a constant?

2011-09-06 Thread julianrz
Hello All,
I am new to Clojure. Surprised why this code does not work:

user=> (filter #(%) [1 2 3])
ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn

Here my intent behind #(%) is to define a lambda function returning
its argument. Since Clojure defines truth on any type, it should be
acceptable as filter function, and the result should be the original
array

Some narrowing down. What's #(%) really good for?

user=> #(%)
#

so it is a function

user=> (#(%))
ArityException Wrong number of args (0) passed to: user$eval26$fn

Ok, here not enough arguments supplied, fair enough. Let's fix that:
user=> (#(%) 1)
ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn

Same problem as the first example. So Clojure understands this is a
function, knows it takes some arguments, but cannot call it? What's
wrong? The following works:

(user=> (filter (fn [a] a) [1 2 3])
(1 2 3)

So apparently it has something to do with the fact that #() is
shorthand. So in my case, it produces a function which cannot be
used... In fact, it seems to just yield the constant, not a function.
Ask me, it should work (auto-wrap the constant in a function) or the
expression should be illegal. I think it deserves better
diagnostics...

Also, in Practical Clojure book, it says: "The shothand function form
#(* %1 %2) is actually identical to the longer form (fn [x y] (* x y))
before it is even seen by the compiler." If you literally apply this
rule, you will get

((fn[x] (1)) 1)

which throws same exception, not surprisingly, since it tries to
evaluate 1 as a fucntion. What it should have done is transform the
expression into

((fn[x] 1) 1)

which works fine... Special-case it?

What do you think?

Julian

-- 
You 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: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Nico Kruger
On 4 September 2011 20:40, Dennis Haupt  wrote:
>
> Am 04.09.2011 19:08, schrieb Justin Kramer:
>> On Sunday, September 4, 2011 12:21:23 PM UTC-4, HamsterofDeath
>> wrote:
>>
>>
>> Some other comments:
>>
>> - Nested defns are not good.
>
> why? imo, nested function/method definitions are a tool to fine-tune
> accessibility. just like public/private, but much more powerful. why
> shouldn't i use that? why make everything flat and confuse the next
> guy who's trying to figure out which def is supposed to be used by him
> and which is a helper function?
>

You are quite correct. Nested function definitions are in fact a good
idea, for precisely the reasons you mention. If a function is only to
be used locally, within another function then you should make it a
local function. However, using nested defn's is not the way to do
this, as defn always creates a top-level binding for a function, as is
described by the following REPL session:

user=> (defn outside [x]
 (defn inside [y]
 (println y))
 (inside x)
 (println x))
#'user/outside
user=> (outside 10)
10
10
nil
user=> (inside 10)
10
nil

As you can see, I can call the inside function from the top-level
scope, even though the defn is nested inside another defn.

The answer to doing what you want is anonymous functions. Using local
anonymous functions solves the problem by ensuring that the function
does not enter the global namespace. Anonymous functions are created
with the fn special form,  http://clojure.org/special_forms#fn . The
trick is you can of course use let to bind a local-name to an
anonymous function within your outer function. Adapting the previous
example using anonymous functions, and then using "let" to bind them
to a local name, would look like this:

user=> (defn outside [x]
  (let [inside (fn [y] (println y))]
 (inside x)
 (println x))

user=> (outside 10)
10
10
nil
user=> (inside 10)
java.lang.Exception: Unable to resolve symbol: inside in this context
(NO_SOURCE_FILE:22)

As you can see, the anonymous function is now bound to the local name
"inside" only within the"outside" function, and is not accessible from
outside.

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

2011-09-06 Thread myriam abramson
Yes, keeping track of all those versions is tricky. At the moment, the Lein
method in emacs seems simple enough. We'll see.

On Sat, Sep 3, 2011 at 10:06 PM, Li Zhixiong wrote:

> Basically, the problem I get is due to version conflict between
> swank-clojure and slime, I download the same version as swank-clojure, that
> is, 20100404, then it works.
>
>
> On Sun, Sep 4, 2011 at 8:19 AM, myriam abramson wrote:
>
>>
>> Thanks. I am getting some slime errors unfortunately. I'll have to track
>> that down.
>>
>> On Thu, Sep 1, 2011 at 1:36 PM, Paul Nakata  wrote:
>>
>>> On Thursday, September 1, 2011 10:03:13 AM UTC-7, melipone wrote:

 I do like "lein repl" on the command line. How can I have that in emacs?

 Basically, if I have a project in Lein, how can I do a (require
 'projectname) and have all the libraries loaded in emacs?
 I'm just using M-x inferior-lisp at this point. I find swank-clojure too
 complex for right now. Maybe later.

 TIA
 melipone
>>>
>>>
>>> I use clojure-jack-in as described here: http://technomancy.us/149 ,
>>> although if you find swank-clojure too complex for you it may not be a great
>>> fit. I have personally found clojure-jack-in to be very simple and easy to
>>> use; I would advocate at least trying it 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 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
>>
>
>
>
> --
> Best regard!
> Yours sincerely, Li Zhixiong
>
>
>  --
> You 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: Re: clojure and emacs

2011-09-06 Thread labwork07
Thanks, that's a good idea and best of all, it's working for me! I didn't  
know the Mx cd command to change default directory.


On Sep 3, 2011 9:40pm, Benny Tsai  wrote:

Sorry, what I meant to say in the last line is:


And as long as you start emacs somewhere in your lein project directory  
(or "Mx cd" to it), you'll automatically be dropped into the main  
namespace (if you have one defined via :main in project.clj), and the  
other project namespaces will be available to (require ...) in your REPL  
buffer.


On Saturday, September 3, 2011 7:32:28 PM UTC-6, Benny Tsai wrote:You can  
set "lein repl" as your inferior lisp program via:



Mx describe-variableinferior-lisp-program


And as long as you start emacs somewhere in your lein project directory  
(or "Mx cd" to it), you'll have all the libraries loaded in your REPL  
buffer.


On Thursday, September 1, 2011 11:03:13 AM UTC-6, melipone wrote:I do  
like "lein repl" on the command line. How can I have that in emacs?
Basically, if I have a project in Lein, how can I do a  
(require 'projectname) and have all the libraries loaded in emacs?
I'm just using Mx inferior-lisp at this point. I find swank-clojure too  
complex for right now. Maybe later.



TIA
melipone







--



You 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: JVM 7 support (invokedynamic)

2011-09-06 Thread Tal Liron

  
  
On 09/06/2011 08:42 AM, Paul Stadig wrote:

  So far all I have done is update the bundled ASM and modify
  Clojure to emit Java7 class files, but I'm getting VerifyErrors
  (same as Tal). It's possible that this is a bug in the way that
  ASM automatically calculates stack maps, or perhaps it is the best
  that ASM can do, in which case the Clojure compiler would have to
  be modified to do bookkeeping around stack maps.

Cool! I'm making some progress with some folk on the ASM mailing
list. We might crack this yet.

-Tal
  




-- 
You 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: On Lisp with Clojure

2011-09-06 Thread Michael Jaaka
And last tough is that maybe there should be a build in support for
trees.
Trees are to maps like lists to vectors.
They have different characteristic on CRUD operations and CPU/RAM
resources.
With reader macros it would be possible to implement it by even not
bothering Rich Hickey.

Also there is another thought, that it would be nice to introduce
symbols priorities (like there are priorities for evaluation of
arithmetic notation),
so we could omit some parentheses (code would be compact like in
python or ruby). The would be back during the compile-time.
So with something like:

%(
  let a (do-some-comp 2 3)
  if a
(do-other-thing a)
map (fn [ d e ] ) list 1 2 3
)

It would be available for macros and during evaluation time as:

(let[ a (do-some-comp 2 3) ] (if a  (do-other-thing a) (map (fn [ d
e ] ) (list 1 2 3)))

As you can see I can mix the code, to point the order of evaluation,
but for the rest the priorities resolves the order.
Note that the reader should have knowledge of lines (in its meta data
context).


-- 
You 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: not= counterintuitive?

2011-09-06 Thread ax2groin
The clojure.contrib.combinatorics/combinations does do exactly what I
was trying to do, although I was doing the problem as an exercise in
how to do it, and not in really needing combinations for something
else. The combinatorics library certainly does it in a more generic
way.

Since I knew that I was dealing with numbers as input, I actually
ended up using (> m n o) as my test condition, which has the same
effect of guaranteeing all the numbers are distinct. I was looking for
unique sets where order didn't matter.

Thanks for the input, all!

-- 
You 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: On Lisp with Clojure

2011-09-06 Thread Michael Jaaka
Btw. it looks like Clojure is missing an ability to program reader.


It would allow to program a syntax.

==
9. The whole language always available. There is no real distinction
between read-time, compile-time, and runtime. You can compile or run
code while reading, read or run code while compiling, and read or
compile code at runtime.

Running code at read-time lets users reprogram Lisp's syntax; running
code at compile-time is the basis of macros; compiling at runtime is
the basis of Lisp's use as an extension language in programs like
Emacs; and reading at runtime enables programs to communicate using s-
expressions, an idea recently reinvented as XML.
==

The tail recursion and continuations also would be awesome.
Btw. Clojure looks like tweaked Arc. Good point that it is supporting
container data structures - lists, vectors, maps and sets.

-- 
You 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: On Lisp with Clojure

2011-09-06 Thread Michael Jaaka
Well, these attempts stop very quickly.

But I have found code extract from the book

http://lib.store.yahoo.net/lib/paulgraham/onlisp.lisp

maybe someone with good knowledge could port it?

On Sep 2, 1:16 pm, Eric Lavigne  wrote:
> > Is there any project on github which goal is to implement all code
> > from On Lisp book in Clojure?
>
> Michael Fogus and Stuart Halloway have both ported parts of On Lisp to 
> Clojure.
>
> Michaelhttp://blog.fogus.me/tag/onlisp/
>
> Stuarthttp://thinkrelevance.com/blog/2008/12/12/on-lisp-clojure.htmlhttps://github.com/stuarthalloway/onlisp-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
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: ClojureSphere - browse the Clojure ecosystem

2011-09-06 Thread Dave Ray
On Tue, Sep 6, 2011 at 11:28 AM, Chouser  wrote:
> On Tue, Sep 6, 2011 at 11:17 AM, Justin Kramer  wrote:
>> Prompted by a question on IRC a couple days ago, I built a tool that allows
>> you to browse the dependency graph of Clojure projects from GitHub &
>> Clojars:
>> http://clojuresphere.herokuapp.com/
>
> Very nice!  Thanks for creating this.
>
> --Chouser
>

Yeah, very cool! And I especially like this comment in the source:

  ;; we don't need no stinkin database

:)

Dave

-- 
You 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: ClojureSphere - browse the Clojure ecosystem

2011-09-06 Thread Chouser
On Tue, Sep 6, 2011 at 11:17 AM, Justin Kramer  wrote:
> Prompted by a question on IRC a couple days ago, I built a tool that allows
> you to browse the dependency graph of Clojure projects from GitHub &
> Clojars:
> http://clojuresphere.herokuapp.com/

Very nice!  Thanks for creating this.

--Chouser

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

2011-09-06 Thread Justin Kramer
Prompted by a question on IRC a couple days ago, I built a tool that allows 
you to browse the dependency graph of Clojure projects from GitHub & 
Clojars:

http://clojuresphere.herokuapp.com/

You can see dependencies of a project, but also projects which depend on it. 
You can also see how many projects depend on a specific version (combined 
current & historical usage).

There are caveats, which you can read about on 
GitHub: https://github.com/jkk/clojuresphere

If anyone is interested in having this sort of thing added to Clojars, 
ClojureDocs, or other community sites, let me know.

Justin

-- 
You 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: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am 06.09.2011 16:28, schrieb Meikel Brandmeyer (kotarak):
> 
> Am Dienstag, 6. September 2011 15:57:16 UTC+2 schrieb Mark
> Rathwell:
> 
> You want an anonymous function:
> 
> (fn [x] (= x 2))
> 
> or the equivalent shorthand form:
> 
> #(= % 2)
> 
> Or even more short-hand: #{2} (for all 2s not in #{nil false})
> 
> Scary.

too scary.

= % 2 is just right.
> 
> 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


- -- 

-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOZjOCAAoJENRtux+h35aGWtoQANQYreEZ89NTmsYIEwKCzTpp
EVgOz22QNCL+AfxfCDZ0rfPSBrsE1vWi7DJCUZv7TDJNGsvr7sT8FjbeE4FOtJp6
afV5GDqxOTTjP5xi7db3Cc9XbHorodLyfvpfqfkoOxkjkj+yjrqXfgTISteMjvjF
6gtlDFUpLwc9Q6gbt4o+521JE4TABlcEUhzJyGzHmdg9c7vxD1GtQLno5uBA5Dih
SvNjBbrujKyxvkii2Eaoupg12PVMdYsETjl+GpFcQWkLyfDteivwsBfVbtBLF7sM
8p+qhqm44hGp/d820vZwCYNTeA8NaGm4Zrnm9ksETFAClHIfzu+x8RwtVB6IaTUy
wBMkewSEt1ixbNn7xRbraCsR6LFatcsbIlx99VLGFUq5q0Vl/8Eco3uhL7R/x1kI
qaInDHa+dYksl81paEPu9LhX5kLITLNfZU1yQ1TstA4G0N9W6bX8sKt1bdQ2HDZo
QIIGylSg/x8NBuhzAUDWd8VqoUK+G4JbRfqiHBifLB/hfAwK1THeb4iI4hDjpk3n
2YkdS/i061Az/d50zncOV+7mzCLEDvxMxS+fabQyMDLhGcQ4MrbBwK/Wq4mvb38l
X0XP7hgBUIAPY5l6MbFK2u21KLYrmvlDHSK77+y3GpSCrA9/QhRybedi5i8/JdHi
bkMbAIJZjtx7wO82YGLG
=H1Fa
-END PGP SIGNATURE-

-- 
You 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: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

> 

> or the equivalent shorthand form:
> 
> #(= % 2)
> 

should i ever write a bigger app with clojure, it will be filled with
these. i like them.
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOZi37AAoJENRtux+h35aGzQEP/RlGgWN0hRuCTBjyR7/692DH
oTpAdu06MFU3jT7dPiXy1lHG/ZBZantNaHKALLKfREV+yHCnoQJUuGXRRUn1lDrF
uMmMreujblbeviL9h+S0pJ9q1yTk/MH4+ceHUpM2FzPjSYpsok1OKwGFG7T2Diwb
eg61TAQKV82Uwu9+06LnEwHdySs3JRfKUp4BPjGHYxXEFTQIZGVnFXbjgY5iP4xr
Fi9EBZhdROF8dEk26mxWhxMLoyVx1ZdKe6bnNeAjKsTFnnnGxmot2fgtsJFxM/Rg
D5bSpyEWnw6MlJgpUwDOfASCEbGDCS/oaF5pij7045apJLSVro1Py0/+D5TBiuwI
OVq9mCURWeevHTISlUKHFskwJ6PlQ0rUxuXdoU+IEjdEXOw4+W9DJ4fMKk/HbDku
SteyTeA3xOk4lLIIeq1t1Fhv0FwDFPisa2UcqEV6yMcrC4J9TySEnKl4hynbT+On
g+VXDbTAJucCF4ltFTjPCZyAzZe5A4G6NktBlZ8NvBblERthbsLIX3JZMfoayxSv
Fe5KVsrcbn88VSxVUOrZ9/RHsG+3QYsMRfRTlTCw/8hlVfP3Wg8t3ieieFVIavMg
G1KwUMDDyUaeWt01BZU1c3NqA8NsjBYjukET2tnc35BKetb32I8qeRHu4W9K60Qf
9CHjRZb6IH1J1BLdKCzR
=WeGr
-END PGP SIGNATURE-

-- 
You 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: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Meikel Brandmeyer (kotarak)

Am Dienstag, 6. September 2011 15:57:16 UTC+2 schrieb Mark Rathwell:
>
> You want an anonymous function:
>
> (fn [x] (= x 2))
>
> or the equivalent shorthand form:
>
> #(= % 2)
>
Or even more short-hand: #{2} (for all 2s not in #{nil false})

Scary.

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: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


> It was not a syntax error.  Your expression just had the wrong
> return value.  I don't see how an IDE could help here.
> 
> 

by type inference. i don't know how far an ide could track the types
in clojure since it's completely lacking any type annotations, but in
scala it works really well (although it stops at method declarations,
there you have to add type annotations) and such an error (returning
the wrong type in a situation where it's clear what is expected) would
have been highlighted at coding time (even before compilation)

the ideal situation would be something like

(def x [foo] (+ 5 foo))

here, the ide could look into "+" and check which types could be put
into "+" without making it crash ;). that information must provided
somehow (hard coded into ide, provided as parsable documentation,
whatever) at all basic functions. this would enable the ide to
recursively traverse the call tree and figure out what can be applied
to which function.

in my example, it would be
"x" is called with a parameter "foo".
"foo" is given to "+" as the second parameter of a 2 parameter list.
let's look into "+". oh i see, it has to be a java.lang.Number. is it?
yes -> k. no -> highlight "(x param)" as an error.






-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOZi28AAoJENRtux+h35aGtQMQAKAemGLyIRP+6h9KaL3ix3U+
qOgupgqNGNtkDZ2ibYlYRfunJKRm8KLwVnh/0jiTBukY8ppOJTgTuUde6abcl10G
pYomKWPNZBxTRAYI4nRtTKk9cEj0yx3CLYislbk4buxgmLCLNSBOLBmWBD7F8Rxz
fR++KLiJJR7JJ/HszrGPr54Vo7AnI1Rfk1+FcX19UJnmIj1qdfLWq8wTSA6oy063
ZinLUBl+3OfATDJlxUMPJdPOjHMDfQ13MlksUVJq4696rhKjvVdMpIpb9REOmg/Y
+ZxKVLBKr+8RruzDcUJwoiVrJOi6f1pXIMzqsKDhaqhDJwr0iHhY98SjkQBAyozI
tLPQmnudMEB6gS7F2/aW2idZ9WD+XiUyoCt2FwplVJqBveBWTAUAXWdpeAl0rmVG
Qjh5hiUgHs4W8X7qmlTzsZPFlwJ+rYZoHzqaw6HcWnGX9H6gv2ExM1+ELJ25dTHh
0AJZl26WLZ7eXZNAeO62FDET64RR3Oib6tVDTzP41IdLzjUx+zwFjfQFOVlEE/Cx
m5azpk8d11zytG2nlcC58Yg8SBz0ZGyTtv4JJ139JqJdVzpYeol7QXZbkrgY5w3/
DQ5+bW7QjqxmD4FbjTcIDcxWcyg+SXda5p4O1ZqxQSWhNa6EzLrWPLufFBfsNyQa
kUjdYxBTJkgtbhl8jxLb
=6RyY
-END PGP SIGNATURE-

-- 
You 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: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Mark Rathwell
You want an anonymous function:

(fn [x] (= x 2))

or the equivalent shorthand form:

#(= % 2)

Sent from my iPhone

On Sep 6, 2011, at 9:35 AM, Dennis Haupt  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> figured it out, i the () were a bit messed up. the working code:
> 
> (def open 0)
> (def p1 1)
> (def p2 2)
> (def emptyfield [open open open open open open open open open])
> 
> (defn indexOf [x y] (+ x (* y 3)))
> 
> (defn withmove [x,y,player,field]
>  (assoc field (indexOf x y) player))
> 
> (defn winner [field]
>  (letfn [(slashOwnedBy [player] (= [player] (distinct [(nth field 0)
> (nth field 4) (nth field 8)])))
>  (backslashOwnedBy [player] (= [player] (distinct [(nth field
> 2) (nth field 4) (nth field 6)])))
>  (rowOwnedBy [row player]
>(let [beginIndex (indexOf 0 row)
>  currow (subvec field beginIndex (+ 3 beginIndex))]
>  (= [player] (distinct currow
>  (colOwnedBy [col player]
>(let [beginIndex (indexOf col 0)
>  curcol (take-nth 3 (drop beginIndex field))]
>  (= [player] (distinct curcol
>  (winPred [player]
>(loop [cnt 0]
>  (if (= cnt 3)
>(or (slashOwnedBy player) (backslashOwnedBy player))
>(or (rowOwnedBy cnt player) (colOwnedBy cnt player)
> (recur (inc cnt))]
>(let [winnerIfExists (filter winPred [p1 p2])]
>  (if (empty? winnerIfExists) open (first winnerIfExists)
> 
> 
> (let [moves [[2 0 p1] [1 1 p1] [0 2 p1]]]
>  (defn fold [field nextmove]
>(withmove (nth nextmove 0) (nth nextmove 1) (nth nextmove 2) field))
>  (let [endstate (reduce fold emptyfield moves)]
>(println (winner endstate
> 
> a few questions:
> is there a better way than
> (= player (distinct currow))
> ?
> 
> i'd like to write something like:
> (every? (= parameter player) currow
> 
> do i have to define the function via letfn before, or is there a way
> to do it nested in the code?
> 
> and more importantly: is there an ide that can point out syntax
> errors? intellij idea can detect some parentheses/braces problems, but
> i managed to trick it by adding too many ( and ). i got weird
> exceptions and had to check everything manually.
> 
> Am 04.09.2011 19:57, schrieb Sergey Didenko:
>> Dennis, may I suggest you to read this great article on Clojure: 
>> http://java.ociweb.com/mark/clojure/article.html
>> 
>> 
>> 
>> -- You 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
> 
> 
> - -- 
> 
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2.0.14 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iQIcBAEBAgAGBQJOZiGMAAoJENRtux+h35aGuSwP+gPkuR9tAyHUKUhqCrkFgtiJ
> cuuD47EHMyws/IMwqra1RTBaCAaZbJLx9m4sFn9/KLhbGni7fzTt+zAJy1yxyW21
> RaqZJC43VgG6xmDQYVt54aY9zzHz3MkI3eXZBY6Wsd0yquu2NZjnleEvoUNzwsnI
> nLi0nsyLkLMX6b/QdDj48XaatfeG48i5M+H9MlF7EpesoIntUEHhXRVhK1BnOeCk
> ctd4bo0brdszBes7UhZl9abisaiW1vf+rWAAD8HPqcFg4tWUS//SRRmFyEUJtusc
> GXwiPI5Meu0fKHKJv5EhQl87BD3lG+vLUn1XspYYmrZKn5G0ZxL7v/L5ol1g7Zs4
> doSVsWCkR3zMwyaQgrvj/IuvIMxhWhgXGYwdEBHstPJephlwCRC5sOQCLvjwJB6H
> LEV0nx3m2GiWGH+jOqJ2M+j/OwsYNfPxEPRICLpUjm3lR+Whb1l+OL0fMwREgYkS
> ySeto5Q2pI+pkwZc1PsM2YMUEBjBToZroIlMZw6N6IUuQPFNJBcHPakRNDUs93Du
> nmg8kCGy+thBedbky7KxDW1bmBNFYxEWR2iASXkkIjhUdyrn3hVOxz1D1a6rM3Cb
> S2CdXZG5HeiCsqghyQ/m36bqlLf8CTsFz60lb4Q0Wncpn/EDTSyYq76RRPfGoMBu
> Nec7CzUkF8sat1lrZKxy
> =v1mG
> -END PGP SIGNATURE-
> 
> -- 
> You 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: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Stefan Kamphausen
Hi,

On Tuesday, September 6, 2011 3:35:08 PM UTC+2, HamsterofDeath wrote:
>
>
> (every? (= parameter player) currow
> i'd like to write something like:
>
> do i have to define the function via letfn before, or is there a way
> to do it nested in the code?
>

you can create a function anytime using either the read-syntax #() or a call 
to fn:
 

(every? #(= % player) currow)

(every? (fn [param] (= param player)) currow)

This creates local closures.  In such a case, if player is 'rather 
constant', you might want to use partial, but I didn't look at your code 
closely.

> and more importantly: is there an ide that can point out syntax
> errors? intellij idea can detect some parentheses/braces problems, but
> i managed to trick it by adding too many ( and ). i got weird
> exceptions and had to check everything manually.
>

It was not a syntax error.  Your expression just had the wrong return 
value.  I don't see how an IDE could help here.
 

Kind regards,
Stefan 

-- 
You 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: JVM 7 support (invokedynamic)

2011-09-06 Thread Paul Stadig
I started on some work to use invokedynamic instructions (instead of
reflection) for calling Java interop. I based my work on 1.3beta2, and my
goal was just to see how much of a performance difference it could make (if
any).

So far all I have done is update the bundled ASM and modify Clojure to emit
Java7 class files, but I'm getting VerifyErrors (same as Tal). It's possible
that this is a bug in the way that ASM automatically calculates stack maps,
or perhaps it is the best that ASM can do, in which case the Clojure
compiler would have to be modified to do bookkeeping around stack maps.

I even tried moving to ASM trunk to see if it made any difference, but it
didn't.

Anyway, I pushed a couple of branches to my fork of Clojure:

https://github.com/pjstadig/clojure/tree/indy-3.3.2

and

https://github.com/pjstadig/clojure/tree/indy-trunk

Perhaps when ASM 4.0 is finalized it will be a different story.


Paul

On Mon, Aug 29, 2011 at 7:05 PM, Tal Liron  wrote:

>  On 08/29/2011 06:01 PM, Aaron Bedra wrote:
>
> The version of ASM that is bundled in Clojure is very old.  This will
> likely cause problems.  You are correct in looking to ASM 4 since it has
> started supported the JSR-292 stuff and other Java 7 changes.  I am
> planning on doing an extraction, update, and re-packaging of ASM in
> Clojure as soon as Programming Clojure hits the printers.  This most
> likely won't get started until October though because of conferences.
>
>  I've already done that for my branch (that was a task in itself! needed a
> little monkeypatching to support Clojure's DynamicClassLoader), so you may
> want to leave it to me.
>
> My code is in quite a messy state now and I'm embarrassed to make it public
> quite yet...
>
> BTW, does somebody have an Eclipse Java code formatter configuration for
> Clojure's wacky coding style?
>
> -Tal
>
> --
> You 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: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

thx, that's what i figured out a moment ago. i am used to allknowing ides

Am 06.09.2011 15:25, schrieb Stefan Kamphausen:
> hi,
> 
> why does clojure want to cast the result to IFn?
> 
> 
> if I parse that correctly, you have two parens around the 
> let-expression.  That leads to Clojure evaluating the
> let-expression, taking the result (which is the return value of the
> line you mentioned: a Boolean) and trying to call that as a
> function.
> 
> Consider:
> 
> user=> ((let [x :dont-care] +) 3 4) 7
> 
> Hope, this helps.
> 
> Stefan
> 
> -- You 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


- -- 

-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOZiHUAAoJENRtux+h35aGYNEQALHei3B68cM+QR/U4pRC2FkK
cKmHplrziwWcnXysac9cSC9F4mmcDw+JnnYyB4YI4pCb9El8i8E6a53J5GvilOFX
xG8HF6aUxaifticyQS7kpgG47VgeoaT5VKWcpZLFqZM6axSc8MIJ2ArRNCCMZMw3
bLcTEgk0JGWqjeub2b3/pUhFWI23EaCAv4BszKCnGYqhuG847+Ks3Vd0XFO1gKAo
fwEC0QipX2+0T3rrZuF3AjKQpmEN2+iEpE7sTxrgjICXbnEzGAfK395HWc0Kn8KC
+IXI3K2fMkJRB3M1rqRfRf+luxbw48oPgQa/uos/iK4dPcwkODhNCQwq9PFKkNp1
W9j+rLRRm5+n3p/HfIV4GTB3skKY0ij/X00NtsrCE7OM+bs03zAj6qE5ike/bwxv
XEuUSaqR1vR3LgZ5ii6OW1tev1N86cw7Mi7yQBtAFilXEZ/En5dSdEwRTVjDRSoD
nL59wjTNUZUcVTpQ5I4RUTEm8LX+/5d2bU/LHYVjqV49fxY0eDF6f5eMvBXwANo5
I+l/4uf37K3TD+hXGZkh0DcPdxeyltTRoetbtx+OQg64wFxCzz6nxnOytiDInmyD
+k763My95U4Ex9gIxV6r0NSoJb8hcfQEKdru1Liktghc/wMtiBWfuhgRfOO0rZU/
+oP03MYnZzFZD4Hgakz0
=+Tuc
-END PGP SIGNATURE-

-- 
You 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: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

figured it out, i the () were a bit messed up. the working code:

(def open 0)
(def p1 1)
(def p2 2)
(def emptyfield [open open open open open open open open open])

(defn indexOf [x y] (+ x (* y 3)))

(defn withmove [x,y,player,field]
  (assoc field (indexOf x y) player))

(defn winner [field]
  (letfn [(slashOwnedBy [player] (= [player] (distinct [(nth field 0)
(nth field 4) (nth field 8)])))
  (backslashOwnedBy [player] (= [player] (distinct [(nth field
2) (nth field 4) (nth field 6)])))
  (rowOwnedBy [row player]
(let [beginIndex (indexOf 0 row)
  currow (subvec field beginIndex (+ 3 beginIndex))]
  (= [player] (distinct currow
  (colOwnedBy [col player]
(let [beginIndex (indexOf col 0)
  curcol (take-nth 3 (drop beginIndex field))]
  (= [player] (distinct curcol
  (winPred [player]
(loop [cnt 0]
  (if (= cnt 3)
(or (slashOwnedBy player) (backslashOwnedBy player))
(or (rowOwnedBy cnt player) (colOwnedBy cnt player)
(recur (inc cnt))]
(let [winnerIfExists (filter winPred [p1 p2])]
  (if (empty? winnerIfExists) open (first winnerIfExists)


(let [moves [[2 0 p1] [1 1 p1] [0 2 p1]]]
  (defn fold [field nextmove]
(withmove (nth nextmove 0) (nth nextmove 1) (nth nextmove 2) field))
  (let [endstate (reduce fold emptyfield moves)]
(println (winner endstate

a few questions:
is there a better way than
(= player (distinct currow))
?

i'd like to write something like:
(every? (= parameter player) currow

do i have to define the function via letfn before, or is there a way
to do it nested in the code?

and more importantly: is there an ide that can point out syntax
errors? intellij idea can detect some parentheses/braces problems, but
i managed to trick it by adding too many ( and ). i got weird
exceptions and had to check everything manually.

Am 04.09.2011 19:57, schrieb Sergey Didenko:
> Dennis, may I suggest you to read this great article on Clojure: 
> http://java.ociweb.com/mark/clojure/article.html
> 
> 
> 
> -- You 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


- -- 

-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOZiGMAAoJENRtux+h35aGuSwP+gPkuR9tAyHUKUhqCrkFgtiJ
cuuD47EHMyws/IMwqra1RTBaCAaZbJLx9m4sFn9/KLhbGni7fzTt+zAJy1yxyW21
RaqZJC43VgG6xmDQYVt54aY9zzHz3MkI3eXZBY6Wsd0yquu2NZjnleEvoUNzwsnI
nLi0nsyLkLMX6b/QdDj48XaatfeG48i5M+H9MlF7EpesoIntUEHhXRVhK1BnOeCk
ctd4bo0brdszBes7UhZl9abisaiW1vf+rWAAD8HPqcFg4tWUS//SRRmFyEUJtusc
GXwiPI5Meu0fKHKJv5EhQl87BD3lG+vLUn1XspYYmrZKn5G0ZxL7v/L5ol1g7Zs4
doSVsWCkR3zMwyaQgrvj/IuvIMxhWhgXGYwdEBHstPJephlwCRC5sOQCLvjwJB6H
LEV0nx3m2GiWGH+jOqJ2M+j/OwsYNfPxEPRICLpUjm3lR+Whb1l+OL0fMwREgYkS
ySeto5Q2pI+pkwZc1PsM2YMUEBjBToZroIlMZw6N6IUuQPFNJBcHPakRNDUs93Du
nmg8kCGy+thBedbky7KxDW1bmBNFYxEWR2iASXkkIjhUdyrn3hVOxz1D1a6rM3Cb
S2CdXZG5HeiCsqghyQ/m36bqlLf8CTsFz60lb4Q0Wncpn/EDTSyYq76RRPfGoMBu
Nec7CzUkF8sat1lrZKxy
=v1mG
-END PGP SIGNATURE-

-- 
You 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: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Stefan Kamphausen
hi,

> why does clojure want to cast the result to IFn?
>

if I parse that correctly, you have two parens around the let-expression.  
That leads to Clojure evaluating the let-expression, taking the result 
(which is the return value of the line you mentioned: a Boolean) and trying 
to call that as a function.

Consider:

 user=> ((let [x :dont-care] +) 3 4)
 7

Hope, this helps.

Stefan

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

Aw: Clojure 1.3: "defs can now have docstrings"; how so?

2011-09-06 Thread Meikel Brandmeyer (kotarak)
user=> (def foo "A foo" :foo)
#'user/foo
user=> (doc foo)
-
user/foo
  A foo
nil

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: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

i tried using letfn insteaf of defn for inner functions.

(def open 0)
(def p1 1)
(def p2 2)
(def emptyfield [open open open open open open open open open])

(defn indexOf [x y] (+ x (* y 3)))

(defn withmove [x,y,player,field]
  (assoc field (indexOf x y) player))

(defn winner [field]
  (letfn [(rowOwnedBy [row player]
((let [beginIndex (indexOf 0 row)
   currow (subvec field beginIndex (+ 3 beginIndex))]
   (= [player] (distinct currow)))
  ))
  (colOwnedBy [col player]
((let [beginIndex (indexOf col 0)
   curcol (take-nth 3 (drop beginIndex field))]
   (= [player] (distinct curcol)))
  ))
  (winPred [player]
((loop [cnt 0]
   (if (= cnt 3) false (or (rowOwnedBy cnt player)
(colOwnedBy cnt player) (recur (inc cnt)))]
((let [winnerIfExists (filter winPred [p1 p2])]
   (if (empty? winnerIfExists) open (first winnerIfExists))


(let [moves [[0 0 p1] [1 0 p1] [2 0 p1]]]
  (defn fold [field nextmove]
(withmove (nth nextmove 0) (nth nextmove 1) (nth nextmove 2) field))
  (let [endstate (reduce fold emptyfield moves)]
(println (winner endstate


i'm getting an exception:
Caused by: java.lang.RuntimeException: java.lang.ClassCastException:
java.lang.Boolean cannot be cast to clojure.lang.IFn

in this line:
(= [player] (distinct currow)))

why does clojure want to cast the result to IFn?


Am 04.09.2011 19:57, schrieb Sergey Didenko:
> Dennis, may I suggest you to read this great article on Clojure: 
> http://java.ociweb.com/mark/clojure/article.html
> 
> 
> 
> -- You 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


- -- 

-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOZhuaAAoJENRtux+h35aGaF0P/1xnMYA/gUuvGsBnmM5VmGBQ
ncU9+3E8h4EKClatl0rdo+B4BLObYsyg7Xb3IPVdGCf5lofQVOneX2Uk41tVvM/Q
E98uxotCMUjVcaOuEtLUMNBOQCy0q31erOzdKlaaecQ2KTY+GvBRRxpAbo33uqmP
DaGmSiyzTGkVp9PhKcMzEjneSOagEA6oG0cOOInarfQS8Q7gQXP6Wir63kVcps72
yhtNuJmhyTOQQ7H2c+j/+mawk12YHPmD4TmLLg2/cG3ZEeaGdWS2DeWL8FVKuZ4/
grYnP1PldaOCTsrcDDCEwkM/eNxCSVqopz3LIS7oyhr8eEp9j1/Gkko56YZZYWhL
ITHE083+QZ7gi/F+kQmz3Yrd8ZCeoWW7mL18d8qMppRZYlrtywwhKnFARU24VYvB
hh+9Twtv22oqBnQmP3Xf2kisaFGHaf8ke1yz1upvB2L996xo/wRI7rirxWQUZtOi
XLYZIowcPRf27gpTpSFplqO+92awA4pcvOgpqUuIb3FYBmSuIQI9MatQ3IzaHh9T
tlF6hqFWvgkzR98CBnM2RpgE//qb0sM/DC0/lth5jUoULRN3rmpMUiSIvdwDS8TH
60ipp6IG/m8Ou+rqlEF33oPQU8DKVF26DmS5X7zWB/36VioqmuD/STov3qIabAfx
Pw4JDW8nmQwcDb4gSjPI
=Pw61
-END PGP SIGNATURE-

-- 
You 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 1.3: "defs can now have docstrings"; how so?

2011-09-06 Thread Ben Smith-Mannschott
http://dev.clojure.org/display/doc/1.3

def's can already have doc strings, though it's not very convenient:

(def ^{:doc "documentation"} x 1)

Can someone give me a simple example?

// Ben

-- 
You 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: generic math, comparator and arithmetic libs

2011-09-06 Thread Konrad Hinsen
On 6 Sep, 2011, at 12:43 , Sam Aaron wrote:

>> I have added a plain function not= to clojure.algo.generic.comparison as a 
>> convenience, it is just the negation of generic =.
> 
> Would this still allow the overriding of not= to do somethign different to 
> the negation of generic =. If not, how might I achieve this?

Just define your own multimethod not= instead!

Konrad.

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


Re: generic math, comparator and arithmetic libs

2011-09-06 Thread Sam Aaron

On 6 Sep 2011, at 11:33, Konrad Hinsen wrote:
> 
> I must assume that nobody read that message, as there should have been loud 
> complaints. There is obviously no difference in performance between = and 
> not=, as the result of either one is known as soon as one can decide equality 
> OR non-equality.
> 
> I have added a plain function not= to clojure.algo.generic.comparison as a 
> convenience, it is just the negation of generic =.
> 

Would this still allow the overriding of not= to do somethign different to the 
negation of generic =. If not, how might I achieve this?

Sam

---
http://sam.aaron.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
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: generic math, comparator and arithmetic libs

2011-09-06 Thread Konrad Hinsen
On 1 Sep, 2011, at 14:51 , Konrad Hinsen wrote:

> On 1 Sep, 2011, at 10:35 , Alan Malloy wrote:
> 
>> I don't see any reason for it to include !=, which can be implemented
>> as (not (= a b)). Conversely, <= could be implemented as (or (< a b)
>> (= a b)), but if either of those is expensive operations he gives you
>> a chance to do a more-optimized <=.
> 
> Right, and that's also the reason why there should be not=, with a default 
> implementation that does (not (= ...)). It can be expensive to establish 
> equality for a complex data structure, whereas inequality can be ascertained 
> at the first difference encountered.

I must assume that nobody read that message, as there should have been loud 
complaints. There is obviously no difference in performance between = and not=, 
as the result of either one is known as soon as one can decide equality OR 
non-equality.

I have added a plain function not= to clojure.algo.generic.comparison as a 
convenience, it is just the negation of generic =.

The freshly migrated version of clojure.contrib.generic is now available at

http://github.com/clojure/algo.generic

Tested with Clojure 1.3 beta 3.

Konrad.

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