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.

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

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 in

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 al

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

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=> (de

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

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 th

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

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 thi

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 spec

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

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"):

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.

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"):f

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

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 Clojur

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 use

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 sh

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

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

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

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

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

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

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

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 co

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

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

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 p

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

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:

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 mess

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 ann

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 op

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

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 em

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 >

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 (

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

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 fr

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

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 t

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

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

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 opera