Map eats println output?

2011-10-17 Thread Walter van der Laan
Hi,

When I run this expression:

(map (fn [x] (println x) x) (range 5))

I expect to get (0 1 2 3 4) but instead I get (0 1 2 3 4 0 1 2 3 4)

It seems like the println output is included in the result list.

Am I missing something?

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

Re: Map eats println output?

2011-10-17 Thread Baishampayan Ghose
 When I run this expression:
 (map (fn [x] (println x) x) (range 5))

 I expect to get (0 1 2 3 4) but instead I get (0 1 2 3 4 0 1 2 3 4)
 It seems like the println output is included in the result list.
 Am I missing something?

The REPL is fooling you.

(def *x (map (fn [x] (println x) x) (range 5)))
;= user/*x

(count *x)
;= 5

(map identity *x)
;= (0 1 2 3 4)

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.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: Map eats println output?

2011-10-17 Thread Walter van der Laan
That's a big relieve.

Thanks for the answer!

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

when quotes and when syntax-quotes?

2011-10-17 Thread Guofeng Zhang
Hi,

I am reading Joy of Clojure, there is the following sample in 8.1.1:
(defn contextual-eval [ctx expr]
  (eval
`(let [~@(mapcat (fn [[k v]] [k `'~v]) ctx)]
   ~expr)))

And the sample output:
(contextual-eval {'a 1, 'b 2} '(+ a b))
;= 3
(contextual-eval {'a 1, 'b 2} '(let [b 1000] (+ a b)))
;= 1001

I do not understand why `'~v has be to used this way. If I used `~v instead 
(that is, remove the quote), it still works. So my question is, why ~v needs 
to be first quoted and then syntax-quoted?

Thanks for your help!

-- 
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 Mobile BOF at the Clojure/conj?

2011-10-17 Thread Federico Brubacher
This seems interesting, if there's not a BOF let's meet  informally  anyway
!

On Mon, Oct 17, 2011 at 1:40 AM, Frank Siebenlist 
frank.siebenl...@gmail.com wrote:

 Is there any interest to organize some form of ClojureScript Mobile BOF
 at the Clojure/conj?

 (some informal, ad hoc get-together where developers can share experiences
 and show-off some of their work related to making ClojureScript work on the
 mobile devices)

 The only thing we would need is an available meeting place after the
 official track is finished for the day with ideally a projector and enough
 interested folks…

 Anyone from the Clojure/conj org committee who could comment on the
 desirability and feasibility?
 I'd be happy to volunteer to help if needed.

 Thanks, FrankS.

 PS. Personally, I'm currently having a lot of fun with
 ClojureScript+Sencha-Touch+PhoneGap, and my company (most probably) will use
 that for commercial product development soon. ClojureScript is still
 somewhat raw and rough, though, and the ability to share experiences f2f
 with fellow-victims would be very much appreciated.

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




-- 
Federico Brubacher
@fbru02

-- 
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 Mobile BOF at the Clojure/conj?

2011-10-17 Thread Frank Siebenlist
The hotel bar may be a good backup venue ;-)

On Oct 17, 2011, at 9:17 AM, Federico Brubacher wrote:

 This seems interesting, if there's not a BOF let's meet  informally  anyway ! 
 
 On Mon, Oct 17, 2011 at 1:40 AM, Frank Siebenlist 
 frank.siebenl...@gmail.com wrote:
 Is there any interest to organize some form of ClojureScript Mobile BOF at 
 the Clojure/conj?
 
 (some informal, ad hoc get-together where developers can share experiences 
 and show-off some of their work related to making ClojureScript work on the 
 mobile devices)
 
 The only thing we would need is an available meeting place after the official 
 track is finished for the day with ideally a projector and enough interested 
 folks…
 
 Anyone from the Clojure/conj org committee who could comment on the 
 desirability and feasibility?
 I'd be happy to volunteer to help if needed.
 
 Thanks, FrankS.
 
 PS. Personally, I'm currently having a lot of fun with 
 ClojureScript+Sencha-Touch+PhoneGap, and my company (most probably) will use 
 that for commercial product development soon. ClojureScript is still 
 somewhat raw and rough, though, and the ability to share experiences f2f with 
 fellow-victims would be very much appreciated.
 
 --
 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
 
 
 
 -- 
 Federico Brubacher
 @fbru02

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


Is there a reader setting support BigDecimal by default?

2011-10-17 Thread Scott Hickey
In some versions of Scheme or Lisp, there is a flag that you can set so that 
the reader will create exact numbers by default (BigDecimal) instead of 
inexact doubles.

Is there a way to do this in Clojure?

Scott Hickey

-- 
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: when quotes and when syntax-quotes?

2011-10-17 Thread Marshall T. Vandegrift
Guofeng Zhang guof...@radvision.com writes:

 I do not understand why `'~v has be to used this way. If I used
 `~v instead (that is, remove the quote), it still works. So my
 question is, why ~v needs to be first quoted and then syntax-quoted?

I'm not the most experienced Clojure programmer, but I'll have a go:

The key is to count the levels of quoting, and make sure they match what
you need at each level for each form.  Using just `~ is (almost) a
no-op.  Putting ' in between them yields the a form containing the
quoted *value* of v, which is equivalent to the (possibly clearer)
`(quote ~v).  The quoting comes into play for symbols, because quoting
captures any symbols as literal symbol objects vs whatever they resolve
to in the lexical scope.  If you pass {'a 'one} in for the ctx argument
to contextual-eval as-is, then the symbol `one' ends up quoted in the
generated let, and `a' properly bound to the symbol object.  If you
modify the function to *not* quote the value, then an unquoted `one' get
inserted instead, and the function throws an error because `one' is
unbound.

HTH,

-Marshall

-- 
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: when quotes and when syntax-quotes?

2011-10-17 Thread Stephen Compall
On Mon, 2011-10-17 at 04:32 +, Guofeng Zhang wrote:
 `(let [~@(mapcat (fn [[k v]] [k `'~v]) ctx)]
 
 And the sample output:
 (contextual-eval {'a 1, 'b 2} '(+ a b))
 
 I do not understand why `'~v has be to used this way. If I used `~v 
 instead (that is, remove the quote), it still works. So my question is, why 
 ~v needs to be first quoted and then syntax-quoted?

It appears to work the same in both of your samples because the numbers,
e.g. 1 and 2, are self-evaluating.

Try (contextual-eval '{a (+), b (1 2)} '(concat a b)) to see the
difference.  (Hint: it should yield (+ 1 2), literally.)

-- 
Stephen Compall
^aCollection allSatisfy: [:each|aCondition]: less is better

-- 
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: when quotes and when syntax-quotes?

2011-10-17 Thread Alan Malloy
On Oct 17, 12:50 pm, Marshall T. Vandegrift llas...@gmail.com
wrote:
 Guofeng Zhang guof...@radvision.com writes:
  I do not understand why `'~v has be to used this way. If I used
  `~v instead (that is, remove the quote), it still works. So my
  question is, why ~v needs to be first quoted and then syntax-quoted?

 I'm not the most experienced Clojure programmer, but I'll have a go:

 The key is to count the levels of quoting, and make sure they match what
 you need at each level for each form.  Using just `~ is (almost) a
 no-op.

Not just almost, but actually.

-- 
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: Is there a reader setting support BigDecimal by default?

2011-10-17 Thread Meikel Brandmeyer
Hi,

you are looking for 1.3M?

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: Is there a reader setting support BigDecimal by default?

2011-10-17 Thread Scott Hickey
I've been using 1.2 but I would be OK with a solution in any version.

Scott Hickey

-- 
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: Is there a reader setting support BigDecimal by default?

2011-10-17 Thread Meikel Brandmeyer
Hi,

I meant this:

Clojure 1.2.0
user= (type 1.0M)
java.math.BigDecimal

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


Get the name of keyword/symbol in clojurescript

2011-10-17 Thread Jonathan Fischer Friberg
Hi,

As I understand it, clojurescript uses some unicode characters to identify
keywords/symbols.
I guess that's why (str 'a) gives me ï·‘'a
I thought that this was intentional, and that (name 'a) would give me a,
but I got the same result as with (str).

So how do I extract the name from a symbol or keyword in clojurescript?
Also, is this behavior intentional, and if so, why?

-- 
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: Get the name of keyword/symbol in clojurescript

2011-10-17 Thread David Nolen
Are you using ClojureScript HEAD? If you are and you are still seeing this
under what conditions (advanced mode, browser REPL, etc.) ?

David

On Mon, Oct 17, 2011 at 6:41 PM, Jonathan Fischer Friberg 
odysso...@gmail.com wrote:

 Hi,

 As I understand it, clojurescript uses some unicode characters to identify
 keywords/symbols.
 I guess that's why (str 'a) gives me ï·‘'a
 I thought that this was intentional, and that (name 'a) would give me a,
 but I got the same result as with (str).

 So how do I extract the name from a symbol or keyword in clojurescript?
 Also, is this behavior intentional, and if so, why?

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

trouble setting up emacs

2011-10-17 Thread Bruce Gordon
I am trying to follow the directions at 
http://dev.clojure.org/display/doc/Getting+Started+with+Emacs.
1. I want to install the Emacs Starter Kit. The directions at
http://dev.clojure.org/display/doc/Getting+Started+with+Emacs mention
GNU Emacs 23 or 24 is recommended, however  
https://github.com/technomancy/emacs-starter-kit
says You'll need Emacs 24.  The directions say precompiled versions
are readily available for Debian-based systems I'm using a Debian
based system. so I went to http://emacs.naquadah.org/.
a. I executed wget -q -O - http://emacs.naquadah.org/key.gpg | sudo
apt-key add -
b. I'm now confused as to which version I want: Stable? If so I should
then follow the directions to add 2 lines to /etc/apt/sources.list,
and then what do I do?

2. Once I get emacs 24 installed, the directions sort of leave off
with  In both cases, you need to launch a Clojure instance with the
correct classpath settings. This is most commonly done using a build
tool such as Leiningen. For instructions see the Build Tools section
of Getting Started. Going to http://dev.clojure.org/display/doc/Getting+Started
and perusing the Build Tools doesn't explain how to setup and launch a
Clojure instance. I see some explanations at
http://blog.bensmann.com/setting-up-a-clojure-development-environment
but don't know if that includes some obsolete directions.

thanks, -Bruce

-- 
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: trouble setting up emacs

2011-10-17 Thread Phil Hagelberg
On Mon, Oct 17, 2011 at 8:32 PM, Bruce Gordon brucebgor...@gmail.com wrote:
 I am trying to follow the directions at 
 http://dev.clojure.org/display/doc/Getting+Started+with+Emacs.
 1. I want to install the Emacs Starter Kit. The directions at
 http://dev.clojure.org/display/doc/Getting+Started+with+Emacs mention
 GNU Emacs 23 or 24 is recommended, however  
 https://github.com/technomancy/emacs-starter-kit
 says You'll need Emacs 24.

Emacs 23 or newer is needed for Clojure support. Emacs 24 is needed
for the Starter Kit.

 I'm using a Debian
 based system. so I went to http://emacs.naquadah.org/.
 a. I executed wget -q -O - http://emacs.naquadah.org/key.gpg | sudo
 apt-key add -
 b. I'm now confused as to which version I want: Stable? If so I should
 then follow the directions to add 2 lines to /etc/apt/sources.list,
 and then what do I do?

That page lists a number of packages all starting with
emacs-snapshot. So if you want to use the terminal version only, try
emacs-snapshot-nox; if you want a debug build, emacs-snapshot-dbg,
etc.

 2. Once I get emacs 24 installed, the directions sort of leave off
 with  In both cases, you need to launch a Clojure instance with the
 correct classpath settings. This is most commonly done using a build
 tool such as Leiningen. For instructions see the Build Tools section
 of Getting Started.

The next section labeled Slime and Swank Clojure links to the readme
for swank-clojure, which explains how to use M-x clojure-jack-in; the
simplest way to get a slime session going. It should probably be
cleaned up a bit since it's accumulated some cruft over the months,
but it's all correct.

-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


Presented 'Introduction to Clojure' at Silicon Valley Code Camp on October 8th

2011-10-17 Thread Abbas
Hi,

I had the honor of doing a presentation on 'Introduction to Clojure'
at Silicon Valley Code Camp on October 8th. It was the first
presentation on Clojure at SVCC 
http://www.siliconvalley-codecamp.com/Sessions.aspx.
The importance to Clojure could be felt being given the first time
slot of the two day camp. My slide deck is posted at
http://www.slideshare.net/theceo/introduction-to-clojure-9639369 .
Hope people find it useful and hope I have not made any glaring
mistakes. Please feel free to check it out.

Happy programming clojure,
Abbas

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