Re: Looking for parser generator library

2012-02-07 Thread Evan Gamble
fnparse has been forked by John Poplett and updated to work with
clojure 1.3.

On Clojars it's at https://clojars.org/org.clojars.jpoplett/fnparse.

On Github it's at https://github.com/John-Poplett/fnparse

- Evan

On Jan 28, 7:19 am, Roman Perepelitsa 
wrote:
> I'm looking for a parser generator library. I stumbled upon fnparse, but
> unfortunately it doesn't work with clojure 1.3.
>
> Roman Perepelitsa.

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


Re: newline question

2012-02-07 Thread Chris Perkins
http://stackoverflow.com/questions/8707679/how-to-get-suppress-m-characters-in-my-clojurebox-emacsw32-repl-connected-to

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

Calling all Melbourne, Australia, Clojure users

2012-02-07 Thread James Sofra
Hi all,

I have been discussing recently possibly starting a Melbourne Clojure 
meetup.
We have a possible location scouted out already but I really don't have a 
good idea of who may be using Clojure in Melbourne.

I met a couple of people at the Conj last year so I am in contact with them 
and there is this list of people at 
http://clojure.meetup.com/members/au/melbourne/

If I can find enough interested people I will go ahead and organise 
something more official but for the moment I am just trying to scout out to 
see if there is any interest.

So please drop a note here, or you email me directly, to let me know if you 
are in Melbourne and interesting in catching up to chat about and hack 
Clojure.

BTW, anyone had any experience with meetup.com, is it worth paying the dues 
to use?

Cheers,
James Sofra

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

Re: Calling all Melbourne, Australia, Clojure users

2012-02-07 Thread Leonardo Borges
Hi James,

I'm currently using Meetup.com - http://www.meetup.com/clj-syd/ - to handle
our Sydney Clojure User Group. We're about to have our first open meeting -
the group was internal to ThoughtWorks before that.

So far I like Meetup's interface. Feel free to hit me up if I can be of any
help.

Also, do visit us if you ever come to Sydney.

Cheers,
Leonardo Borges
www.leonardoborges.com


On Tue, Feb 7, 2012 at 10:23 PM, James Sofra  wrote:

> Hi all,
>
> I have been discussing recently possibly starting a Melbourne Clojure
> meetup.
> We have a possible location scouted out already but I really don't have a
> good idea of who may be using Clojure in Melbourne.
>
> I met a couple of people at the Conj last year so I am in contact with
> them and there is this list of people at
> http://clojure.meetup.com/members/au/melbourne/
>
> If I can find enough interested people I will go ahead and organise
> something more official but for the moment I am just trying to scout out to
> see if there is any interest.
>
> So please drop a note here, or you email me directly, to let me know if
> you are in Melbourne and interesting in catching up to chat about and hack
> Clojure.
>
> BTW, anyone had any experience with meetup.com, is it worth paying the
> dues to use?
>
> Cheers,
> James Sofra
>
> --
> 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: Calling all Melbourne, Australia, Clojure users

2012-02-07 Thread Stuart Campbell
Hi James,

I'm currently only using Clojure for side projects, but I'm very keen to
catch up!

Stu

On 7 February 2012 22:23, James Sofra  wrote:

> Hi all,
>
> I have been discussing recently possibly starting a Melbourne Clojure
> meetup.
> We have a possible location scouted out already but I really don't have a
> good idea of who may be using Clojure in Melbourne.
>
> I met a couple of people at the Conj last year so I am in contact with
> them and there is this list of people at
> http://clojure.meetup.com/members/au/melbourne/
>
> If I can find enough interested people I will go ahead and organise
> something more official but for the moment I am just trying to scout out to
> see if there is any interest.
>
> So please drop a note here, or you email me directly, to let me know if
> you are in Melbourne and interesting in catching up to chat about and hack
> Clojure.
>
> BTW, anyone had any experience with meetup.com, is it worth paying the
> dues to use?
>
> Cheers,
> James Sofra
>
> --
> 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

Clojure and long auto-promotion to big decimal

2012-02-07 Thread Leandro Moreira
I thought clojure always did auto promotion between long and bigdecimal,
but I run repl today and I notice this:

(* 1000 1000 1000 1000 1000 1000 1000) raises overflow
(* 1000M 1000M 1000M 1000M 1000M 1000M 1000M) this is ok

So this was always working that way? or they've changed? (and if yes, why
they did that?)

thanks :)

ps: I'm using {:interim true, :major 1, :minor 4, :incremental 0,
:qualifier "master"}

-- 
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: ClojureScript One - Getting Started with ClojureScript

2012-02-07 Thread Tom Chappell
This problem is caused by the underlying Java library that is used to
launch the browser, which, under linux, only launches the proper
default browser if gnome is installed. Install enough gnome and it
will start to work.
-Tom

On Jan 25, 10:49 am, Raju Bitter  wrote:
> ClojureScriptOne is fantastic! Great work, thanks!
>
> I just have one question, am running it on Ubuntu Linux. How can I set
> the browser when I launch inferior/lisp script/cljs-repl? On Linux, a
> Java based browser window is opened, and the page is not rendered
> correctly?
>
> Thanks again,
> -Raju

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


Re: where is defalias in the new contrib github repositories

2012-02-07 Thread R Daneel
Many thanks for the detailed discussion!  I'm just going with (defn bar 
[args] (foo args)) - or the cascalog predicate equivalent - for now; I 
guess I can live without the metadata :)

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

read password from console

2012-02-07 Thread Stanley Cai
Hi,

When I wrote a utility in clojure, I found I cannot find a way to read
password from console. I use read-line for username, but would like not to
print the password on the console when reading password. Any hints?

Thanks,
-stanley

-- 
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: read password from console

2012-02-07 Thread Kevin Ilchmann Jørgensen
I truly hope you find something better than:
http://java.sun.com/developer/technicalArticles/Security/pwordmask/

One - not so portable way,  would be sending an \033]8m - invisible
char to the console beforehand ?

/Kevin



On Tue, Feb 7, 2012 at 10:26 AM, Stanley Cai  wrote:
> Hi,
>
> When I wrote a utility in clojure, I found I cannot find a way to read
> password from console. I use read-line for username, but would like not to
> print the password on the console when reading password. Any hints?
>
> Thanks,
> -stanley
>
> --
> 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: Clojure and long auto-promotion to big decimal

2012-02-07 Thread Aaron Cohen
This was the big change in clojure 1.3

See http://dev.clojure.org/display/doc/Enhanced+Primitive+Support

The expectation now is that if you are doing math that is going to
overflow, you can either introduce a bigint into the chain somewhere,
after which all the math will use bigints (contagion) or the writer of
the function can use the *' (prime) operator.

So the following are both fine, with the first usually being preferred
because it leaves the choice to the consumer.

 (* 1000M 1000 1000 1000 1000 1000 1000)
 (*' 1000 1000 1000 1000 1000 1000 1000)

On Mon, Feb 6, 2012 at 8:04 PM, Leandro Moreira
 wrote:
> I thought clojure always did auto promotion between long and bigdecimal, but
> I run repl today and I notice this:
>
> (* 1000 1000 1000 1000 1000 1000 1000) raises overflow
> (* 1000M 1000M 1000M 1000M 1000M 1000M 1000M) this is ok
>
> So this was always working that way? or they've changed? (and if yes, why
> they did that?)
>
> thanks :)
>
> ps: I'm using {:interim true, :major 1, :minor 4, :incremental 0, :qualifier
> "master"}
>
> --
> 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: read password from console

2012-02-07 Thread David Powell
If you have Java 6 (and you probably do), then look at:

http://docs.oracle.com/javase/6/docs/api/java/io/Console.html

Simple example:

  (String/valueOf (.readPassword (System/console) "Password:" nil))

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

[ANN] http.async.client v0.4.1 realeased

2012-02-07 Thread Hubert Iwaniuk
http.async.client is Asynchronous HTTP Client for Clojure and just got
v0.4.1 release.

This release is mainly community contributions.

Code: http://github.com/neotyk/http.async.client
Docs: http://neotyk.github.com/http.async.client/
Changelog: http://neotyk.github.com/http.async.client/changelog.html
Clojars: http://clojars.org/http.async.clietn

This release features:
1 Upgrade AHC to 1.7.0
2 Issues #26, #27, #28
3 Improved logging
4 Tested against Clojure 1.4.0-beta1

Thank you for contributions: Justin Kramer, Brian Tatnall and Karsten Lang.

Hope you enjoy it,
Hubert

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


Persistent collections and garbage collection

2012-02-07 Thread pron
Hi. I have a question:
I love Clojure's persistent collections, but don't they generate many 
long-lived objects (that go to the surving generations) that are hard to 
garbage-collect? After all, the discarded nodes after "modification" are 
not necessarily short lived. It seems like they would behave badly from the 
GC perspective. Am I wrong?

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

Clarification on ClojureScript libraries

2012-02-07 Thread Base
Hi All -

I am finding that I am confused on the differences of using clojure
libraries vs using Clojurescript libraries.

For the former, it is easy enough to just add the reference to the
project.clj and it automagically appears in the lib.

Does the same hold true for Clojurescript libraries?  I cannot seem to
get this to work correctly and end up dropping the files in the
directory defined in the :source-path in the project.clj.

Thanks
Base

-- 
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: Clarification on ClojureScript libraries

2012-02-07 Thread David Nolen
On Tue, Feb 7, 2012 at 11:18 AM, Base  wrote:

> Hi All -
>
> I am finding that I am confused on the differences of using clojure
> libraries vs using Clojurescript libraries.
>
> For the former, it is easy enough to just add the reference to the
> project.clj and it automagically appears in the lib.
>
> Does the same hold true for Clojurescript libraries?  I cannot seem to
> get this to work correctly and end up dropping the files in the
> directory defined in the :source-path in the project.clj.
>
> Thanks
> Base
>

It should be that easy but it isn't yet. Discussion, coordination (with
Lein), and patches welcome :)

David

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

2012-02-07 Thread Base
Well, that explains why i cant get this stuff working like that!!

Thanks David.

On Feb 7, 11:22 am, David Nolen  wrote:
> On Tue, Feb 7, 2012 at 11:18 AM, Base  wrote:
> > Hi All -
>
> > I am finding that I am confused on the differences of using clojure
> > libraries vs using Clojurescript libraries.
>
> > For the former, it is easy enough to just add the reference to the
> > project.clj and it automagically appears in the lib.
>
> > Does the same hold true for Clojurescript libraries?  I cannot seem to
> > get this to work correctly and end up dropping the files in the
> > directory defined in the :source-path in the project.clj.
>
> > Thanks
> > Base
>
> It should be that easy but it isn't yet. Discussion, coordination (with
> Lein), and patches welcome :)
>
> David

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

2012-02-07 Thread Sean Corfield
On Tue, Feb 7, 2012 at 8:18 AM, Base  wrote:
> For the former, it is easy enough to just add the reference to the
> project.clj and it automagically appears in the lib.
>
> Does the same hold true for Clojurescript libraries?  I cannot seem to
> get this to work correctly and end up dropping the files in the
> directory defined in the :source-path in the project.clj.

I just went thru this last night with Chris Granger's jayq wrapper for jQuery.

I added a standard project.clj dependency on the library [jayq
"0.1.0-SNAPSHOT"] and lein deps brought it in as expected.

Things worked fine in :whitespace and :simple mode (:optimizations)
but broke in :advanced mode. The reason was that externs (declarations
of library names) was not picked up from the classpath (yet). The fix
was to run:

jar xf lib/jayq-*.jar externs

in my project to extract the externs folder (containing the jquery.js
declarations) into the top-level of my project. Forcing a recompile of
the cljs then solved the problem.

Another problem I ran into initially was not specifying :output-dir in
the compilation options. The compiler caches the source cljs and
compiled js and when I updated the jayq library (to pick up a fix from
Chris - thank you!), the old source was still being used. Once I
specified :output-dir I could see the problem and removing the
generated files (or using lein cljsbuild clean) emptied that cache and
forcing a recompile picked up the new source from the jayq JAR.

Oh, and my first problem was that with multiple :use clauses for
different cljs files in my ns declaration, the compiler seemed to get
confused about which namespace symbols lived in so it would produce
example.core.$.call(...) instead of jayq.core.$.call(...) or
example.core.by_id(...) instead of example.util.by_id(...). I finally
gave up on :use'ing multiple cljs code packages. I've had similar
problems with :require but can't track down the specific situation
that works vs fails (yet).

Small problems but frustratingly hard to debug because a) the
compilation produces giant JS files in non-advanced mode and
incomprehensible JS files in advanced mode and b) the g-Closure
compiler is a big black box so it's really hard to tell what's going
on. I also (sometimes) got an HTTP request for /deps.js which no one
on IRC seemed to be able to explain (so I just created an empty
deps.js file to shut it up).

ClojureScript is very promising - and I much prefer writing Clojure to
writing JS - but as soon as you stray from a specific published
example or from the simplest possible thing that works, you can get
into a landmine-filled world of frustration at the moment. Things are
improving rapidly tho'...
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.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: newline question

2012-02-07 Thread Mark Engelberg
Thanks.

I'm curious: did something change in 1.3 to make Clojure's newline not
respect the platform it is running on?

I had a similar situation the other day, independent of Emacs, where I
wrote out a file which had been "join"ed (clojure.string) with "\n", and
the resulting file didn't seem to obey Windows conventions, even though I'm
running on Windows.

-- 
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: newline question

2012-02-07 Thread David Powell
\n in Java and Clojure is just line feed.
The Windows line ending is \r\n.
println and similar now use the platform appropriate line ending.  This was
changed some time ago.

Emacs displays ^M if you have a mix of \n and \r\n in the same buffer.

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

Destructuring a seq of maps

2012-02-07 Thread Manuel Paccagnella

I've some questions about destructuring a seq of maps, like:

1. Is it possible?
2. If yes, does it have any sense?
3. And if it's possible and is reasonable, how can I do it?

For example, let's say that I have a list of maps like this:

(def something [{:a 1 :b 2}
{:a 2 :b 5}
{:a 3 :b 7}])

And let's say that I want a function that returns the sum of all :a 
values of the something seq. I could write the function in this way:


(defn do-sum [some-coll]
  (reduce + (map #(:a %) some-coll)))

Not a big deal, but I wonder if there is a better way to do it. 
Destructuring could be one answer I thought, since I need only the value 
corresponding to the :a key of every map in the seq. But I didn't 
figured out how to do it yet.


Any ideas?

Manuel

--
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: Destructuring a seq of maps

2012-02-07 Thread Aaron Cohen
On Tue, Feb 7, 2012 at 3:28 PM, Manuel Paccagnella
 wrote:
> I've some questions about destructuring a seq of maps, like:
>
> 1. Is it possible?
> 2. If yes, does it have any sense?
> 3. And if it's possible and is reasonable, how can I do it?
>
> For example, let's say that I have a list of maps like this:
>
>        (def something [{:a 1 :b 2}
>                        {:a 2 :b 5}
>                        {:a 3 :b 7}])
>
> And let's say that I want a function that returns the sum of all :a values
> of the something seq. I could write the function in this way:
>
>        (defn do-sum [some-coll]
>          (reduce + (map #(:a %) some-coll)))
>
> Not a big deal, but I wonder if there is a better way to do it.
> Destructuring could be one answer I thought, since I need only the value
> corresponding to the :a key of every map in the seq. But I didn't figured
> out how to do it yet.
>
> Any ideas?

Well, destructuring requires a literal, so you have to know exactly
the structure you're wanting to pick apart. For your specific example,
I can write a destructuring usage that will work, but there's no way
to do it in a general way.

user=>(defn do-sum [[{a1 :a} {a2 :a} {a3 :a}]]
          (+ a1 a2 a3))
#'user/do-sum

user=>(do-sum something)
6

-- 
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: Destructuring a seq of maps

2012-02-07 Thread Manuel Paccagnella

On 02/07/2012 09:37 PM, Aaron Cohen wrote:

Well, destructuring requires a literal, so you have to know exactly
the structure you're wanting to pick apart. For your specific example,
I can write a destructuring usage that will work, but there's no way
to do it in a general way.

user=>(defn do-sum [[{a1 :a} {a2 :a} {a3 :a}]]
   (+ a1 a2 a3))
#'user/do-sum

user=>(do-sum something)
6



As I suspected. I'd say it makes sense.

Thank you for your reply Aaron!

--
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: Destructuring a seq of maps

2012-02-07 Thread Cedric Greevey
On Tue, Feb 7, 2012 at 3:28 PM, Manuel Paccagnella
 wrote:
> And let's say that I want a function that returns the sum of all :a values
> of the something seq. I could write the function in this way:
>
>        (defn do-sum [some-coll]
>          (reduce + (map #(:a %) some-coll)))
>
> Not a big deal, but I wonder if there is a better way to do it.

One better way:

(defn do-sum [some-coll]
  (reduce + (map :a some-coll)))

Keywords can be used as functions. That's probably tidy enough not to
feel the need to do something else, such as destructuring.

-- 
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: Destructuring a seq of maps

2012-02-07 Thread Manuel Paccagnella

On 02/07/2012 09:48 PM, Cedric Greevey wrote:

One better way:

 (defn do-sum [some-coll]
   (reduce + (map :a some-coll)))

Keywords can be used as functions.


Sure!


That's probably tidy enough not to
feel the need to do something else, such as destructuring.



Yes, I understand. I'm starting to wrap my head around destructuring 
right now and I'm working to grasp it's use and structure.


All replies has been quite useful so far. Thank 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


[ANN] Clojure Hangman

2012-02-07 Thread Jozef Wagner
Hi,

I'm going to speak about Clojure at our small university workshop. People 
will hear about Clojure for the first time, and they do not have a good CS 
background. I've prepared some introductory slides for the talk and I've 
also prepared a practical demonstration to show interactive and dynamic 
programming in Clojure + swank + emacs.

After polishing the game a bit I'm making slides and a practical 
presentation public. The result is a playable and nice looking hangman 
game, with source code full of comments.

You can get the game and go through the tutorial at 
https://github.com/wagjo/hangman

Hopefully it will help some newcomers to get to know Clojure better.

Jozef Wagner

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

Re: Looking for parser generator library

2012-02-07 Thread Roman Gonzalez
I released yesterday zetta-parser (http://github.com/van-clj/zetta-parser) 
through the van-clj group (http://van-clj.github.com), this library is a 
port of Haskell's attoparsec. 

The difference between this and the ones I've seen so far is that zetta 
allows you to use a parser without having all the input available, you can 
put the input that is available now, and you'll get back a continuation 
function that will receive the remaining input later on.

It uses internally the clojure's algo.monads library, and also provides an 
Applicative Functor interface, has plenty of tests, some examples and all 
combinators are documented. It's a little rough over the edges, but is 
ready for a trial if you are interested. We over the van-clj group will try 
to use as much as we can for our problems.

Cheers.

rg.-

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

Re: Looking for parser generator library

2012-02-07 Thread Cedric Greevey
On Tue, Feb 7, 2012 at 5:46 PM, Roman Gonzalez  wrote:
> I released yesterday zetta-parser (http://github.com/van-clj/zetta-parser)
> through the van-clj group (http://van-clj.github.com), this library is a
> port of Haskell's attoparsec.

Haskell has a parser library named for a distance of approximately
three centimetres? :)

-- 
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: Destructuring a seq of maps

2012-02-07 Thread Asim Jalis
I frequently find myself passing around maps that are basically structs. I
use this macro to destructure the fields into let variables.

; Macro.

(defmacro def-fields [struct-name & fields]
  (let [field-symbol-vector (->> fields (map name) (map symbol) vec)
arg (gensym)
body (gensym)
macro-name (symbol (str "let-" struct-name))]
`(defmacro ~macro-name [~arg & ~body]
  `(let [{:keys ~'~field-symbol-vector} ~~arg] ~@~body

; How to use it.

(def-fields person :first-name :last-name :city)

(defn print-person [p]
  (let-person p
(println "First name:" first-name)
(println "Last name:" last-name)
(println "City:" city)))

(def person1 {:first-name "John" :last-name "Smith" :city "San Francisco"})
(print-person person1)

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

Transactional Synchronization in Haswell

2012-02-07 Thread edlich
Hi all,

will this RTM have a big language effect on Clojure and other
languages?

http://software.intel.com/en-us/blogs/2012/02/07/transactional-synchronization-in-haswell/

Best
Stefan Edlich

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