Re: interval trees..

2012-03-22 Thread martin_clausen
Christophe Grand  recently 
did a blog post on interval trees:  
http://clj-me.cgrand.net/2012/03/16/a-poor-mans-interval-tree/ 

On Monday, June 6, 2011 1:43:15 PM UTC+2, Sunil Nandihalli wrote:
>
> A simple googling revealed that interval trees can be implemented using 
> finger-trees .. but hmm. they are not ready yet.. :(
> Sunil.
>
> On Mon, Jun 6, 2011 at 5:05 PM, Sunil S Nandihalli <
> sunil.nandiha...@gmail.com> wrote:
>
>> Hello everybody,
>>  Is there any implementation of Interval 
>> Trees in 
>> Clojure. I found this Java 
>> implementation
>>  but 
>> it does not have remove operation. Even some other Java Implementation 
>> would do.
>> Thanks,
>> Sunil.
>>
>
>

-- 
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: ringMon 0.1.1 released

2012-03-22 Thread Shantanu Kumar
> I need  [ring/ring-jetty-adapter "1.0.1"] dependency so I can run
> ringMon in standalone mode.

For the experimental run I did using the ring-handler I have with
ringMon middleware I used only lein-ring:

https://github.com/weavejester/lein-ring

I didn't import anything from ring in my namespace. That's a nice way
to start Jetty server with a ring handler, but not sure how well that
suits ringMon-standalone mode requirements though.

Shantanu

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


first core.logic experiment

2012-03-22 Thread Cesare
Hi all,
I'm experimenting with clojure.core: very nice! This is a simple
planner for the Farmer Crosses River puzzle:


(def characters [:farmer :goat :wolf :cabbage])

;;; they all start on the left side of the river
(def _starting-state {:farmer :l, :goat :l :wolf :l :cabbage :l})

;;; they all must cross the river
(def _final-state {:farmer :r, :goat :r :wolf :r :cabbage :r})

(defn validstateo
  "constraints for state s"
  [s]
  (fresh [farm goat wolf cabb]
 (== s {:farmer farm, :goat goat, :wolf wolf, :cabbage cabb})
 (conde
  [(== farm goat)]  ; farmer is with goat
or...
  [(!= wolf goat) (!= cabb goat)]))) ; goat/wolf (or goat/
cabbage) not alone

(defn initialstateo [s]
  (== s _starting-state))

(defn finalstateo [s]
  (== s _final-state))

(defn doactiono [s a ns]  ; state action nextstate
  "action a change state s to state ns"
  (fresh [farm goat wolf cabb]
 (== s {:farmer farm, :goat goat, :wolf wolf, :cabbage cabb})
 (validstateo ns)  ; target state must be valid
 (conde
  ;; farmer travels with goat
  [(== a :bringgoat)
   (== farm goat) ; they must be on the same side
   (conde
;; flip side for them
[(== farm :l) (== ns {:farmer :r, :goat :r, :wolf
wolf, :cabbage cabb})]
[(== farm :r) (== ns {:farmer :l, :goat :l, :wolf
wolf, :cabbage cabb})])]
  ;; farmer travels with wolf
  [(== a :bringwolf)
   (== farm wolf)
   (conde
[(== farm :l) (== ns {:farmer :r, :goat
goat, :wolf :r, :cabbage cabb})]
[(== farm :r) (== ns {:farmer :l, :goat
goat, :wolf :l, :cabbage cabb})])]
  ;; farmer travels with cabbage
  [(== a :bringcabb)
   (== farm cabb)
   (conde
[(== farm :l) (== ns {:farmer :r, :goat goat, :wolf
wolf, :cabbage :r})]
[(== farm :r) (== ns {:farmer :l, :goat goat, :wolf
wolf, :cabbage :l})])]
  ;; farmer travels alone
  [(== a :travalone)
   (conde
[(== farm :l) (== ns {:farmer :r, :goat goat, :wolf
wolf, :cabbage cabb})]
[(== farm :r) (== ns {:farmer :l, :goat goat, :wolf
wolf, :cabbage cabb})])]
  )))


(defne plano
  "a plan is a sequence of (action, state) towards the final state"
  [plan]
  ([[[?a ?s]]] (finalstateo ?s))  ; last state must be final
  ([[[?a ?s] . ?r]]
 (fresh [a2 s2 r2]
(conso [a2 s2] r2 ?r)
(doactiono ?s a2 s2)
(plano ?r

(defn print-solution [sol]
  (let [formatstring (clojure.string/join
  ""
  (repeat (inc (count characters)) "%10s"))]
(print (format "%10s" "__ACTION__"))
(doseq [c characters] (print (format "%10s" c)))
(println)
(doseq [[a s] sol]
  (let [row (cons a (map (fn [f] (f s))
 characters))]
(println (apply (partial format formatstring) row))

This can be executed with:

(doseq [sol (set (run 1 [q]
(fresh [a s]
   (firsto q [a s])
   (initialstateo s)
   (plano q]
(print-solution sol))

This is the output:

__ACTION__   :farmer :goat :wolf  :cabbage
   _.0:l:l:l:l
:bringgoat:r:r:l:l
:travalone:l:r:l:l
:bringwolf:r:r:r:l
:bringgoat:l:l:r:l
:bringcabb:r:l:r:r
:travalone:l:l:r:r
:bringgoat:r:r:r:r


Due to lvar handling, I have problems in writing a more concise
version of doactiono: any idea?

Moreover, core.logic should be more informative, e.g. if I try to
execute:

user> (run* [q] (== q (firsto [1 2])))   ; wrong use of firsto and
wrong number of args passed to it

the only message printed is:

; Evaluation aborted.

In any case, thanks to core.logic authors!

Ciao

-- 
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: first core.logic experiment

2012-03-22 Thread David Nolen
Neat! I see that you figured out defne, you could probably simplify
doactiono with matche as well.

The Clojure REPL doesn't print exceptions by default, but I'm sure if you
print it out with (clojure.repl/pst *e) you'd see that it does let you know
that you called firsto with the wrong number of arguments.

David

On Thu, Mar 22, 2012 at 9:32 AM, Cesare  wrote:

> Hi all,
> I'm experimenting with clojure.core: very nice! This is a simple
> planner for the Farmer Crosses River puzzle:
>
>
> (def characters [:farmer :goat :wolf :cabbage])
>
> ;;; they all start on the left side of the river
> (def _starting-state {:farmer :l, :goat :l :wolf :l :cabbage :l})
>
> ;;; they all must cross the river
> (def _final-state {:farmer :r, :goat :r :wolf :r :cabbage :r})
>
> (defn validstateo
>  "constraints for state s"
>  [s]
>  (fresh [farm goat wolf cabb]
> (== s {:farmer farm, :goat goat, :wolf wolf, :cabbage cabb})
> (conde
>  [(== farm goat)]  ; farmer is with goat
> or...
>  [(!= wolf goat) (!= cabb goat)]))) ; goat/wolf (or goat/
> cabbage) not alone
>
> (defn initialstateo [s]
>  (== s _starting-state))
>
> (defn finalstateo [s]
>  (== s _final-state))
>
> (defn doactiono [s a ns]  ; state action nextstate
>  "action a change state s to state ns"
>  (fresh [farm goat wolf cabb]
> (== s {:farmer farm, :goat goat, :wolf wolf, :cabbage cabb})
> (validstateo ns)  ; target state must be valid
> (conde
>  ;; farmer travels with goat
>  [(== a :bringgoat)
>   (== farm goat) ; they must be on the same side
>   (conde
>;; flip side for them
>[(== farm :l) (== ns {:farmer :r, :goat :r, :wolf
> wolf, :cabbage cabb})]
>[(== farm :r) (== ns {:farmer :l, :goat :l, :wolf
> wolf, :cabbage cabb})])]
>  ;; farmer travels with wolf
>  [(== a :bringwolf)
>   (== farm wolf)
>   (conde
>[(== farm :l) (== ns {:farmer :r, :goat
> goat, :wolf :r, :cabbage cabb})]
>[(== farm :r) (== ns {:farmer :l, :goat
> goat, :wolf :l, :cabbage cabb})])]
>  ;; farmer travels with cabbage
>  [(== a :bringcabb)
>   (== farm cabb)
>   (conde
>[(== farm :l) (== ns {:farmer :r, :goat goat, :wolf
> wolf, :cabbage :r})]
>[(== farm :r) (== ns {:farmer :l, :goat goat, :wolf
> wolf, :cabbage :l})])]
>  ;; farmer travels alone
>  [(== a :travalone)
>   (conde
>[(== farm :l) (== ns {:farmer :r, :goat goat, :wolf
> wolf, :cabbage cabb})]
>[(== farm :r) (== ns {:farmer :l, :goat goat, :wolf
> wolf, :cabbage cabb})])]
>  )))
>
>
> (defne plano
>  "a plan is a sequence of (action, state) towards the final state"
>  [plan]
>  ([[[?a ?s]]] (finalstateo ?s))  ; last state must be final
>  ([[[?a ?s] . ?r]]
> (fresh [a2 s2 r2]
>(conso [a2 s2] r2 ?r)
>(doactiono ?s a2 s2)
>(plano ?r
>
> (defn print-solution [sol]
>  (let [formatstring (clojure.string/join
>  ""
>  (repeat (inc (count characters)) "%10s"))]
>(print (format "%10s" "__ACTION__"))
>(doseq [c characters] (print (format "%10s" c)))
>(println)
>(doseq [[a s] sol]
>  (let [row (cons a (map (fn [f] (f s))
> characters))]
>(println (apply (partial format formatstring) row))
>
> This can be executed with:
>
> (doseq [sol (set (run 1 [q]
>(fresh [a s]
>   (firsto q [a s])
>   (initialstateo s)
>   (plano q]
>(print-solution sol))
>
> This is the output:
>
> __ACTION__   :farmer :goat :wolf  :cabbage
>   _.0:l:l:l:l
> :bringgoat:r:r:l:l
> :travalone:l:r:l:l
> :bringwolf:r:r:r:l
> :bringgoat:l:l:r:l
> :bringcabb:r:l:r:r
> :travalone:l:l:r:r
> :bringgoat:r:r:r:r
>
>
> Due to lvar handling, I have problems in writing a more concise
> version of doactiono: any idea?
>
> Moreover, core.logic should be more informative, e.g. if I try to
> execute:
>
> user> (run* [q] (== q (firsto [1 2])))   ; wrong use of firsto and
> wrong number of args passed to it
>
> the only message printed is:
>
> ; Evaluation aborted.
>
> In any case, thanks to core.logic authors!
>
> Ciao
>
> --
> 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.c

Re: first core.logic experiment

2012-03-22 Thread Cesare
On Mar 22, 2:47 pm, David Nolen  wrote:
> Neat! I see that you figured out defne, you could probably simplify
> doactiono with matche as well.

ok, I'll try soon.

> The Clojure REPL doesn't print exceptions by default, but I'm sure if you
> print it out with (clojure.repl/pst *e) you'd see that it does let you know
> that you called firsto with the wrong number of arguments.

The fact is that this:

(run* [q] (firsto [1 2]))  ; wrong use of firsto

raise (correctly) an exception.

thanks a lot!

ciao

-- 
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-mode + aquamacs + paredit and character literals

2012-03-22 Thread Moritz Ulrich
Do you really need Aquamacs? My experience is that it causes more
trouble than it's worth.

I'd recommend using vanilla Emacs from [1] or building from source
with the --cocoa switch. Vanilla Emacs on OS X got so good you don't
really need Aquamacs anymore.
Looking at the Emacs Starter Kit from Phil Hagelberg might be helpful too.

[1]: http://emacsformacosx.com/

Cheers,
Moritz Ulrich

On Wed, Mar 21, 2012 at 21:06, JuanManuel Gimeno Illa
 wrote:
> I'm having problems typing character literals in aquamacs when clojure-mode
> and paredit are active. When I type the character \, emacs complains with:
>
> after 0 kwd macro iterations: Wrong type argument: characterp, -1
>
> Any idea of what is going on?
>
> Thanks,
>
> Juan 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



-- 
Moritz Ulrich

-- 
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-mode + aquamacs + paredit and character literals

2012-03-22 Thread JuanManuel Gimeno Illa
Thanks, I'll give it a try.

Juan Manuel

On Thursday, March 22, 2012 4:21:19 PM UTC+1, Moritz Ulrich wrote:
>
> Do you really need Aquamacs? My experience is that it causes more
> trouble than it's worth.
>
> I'd recommend using vanilla Emacs from [1] or building from source
> with the --cocoa switch. Vanilla Emacs on OS X got so good you don't
> really need Aquamacs anymore.
> Looking at the Emacs Starter Kit from Phil Hagelberg might be helpful too.
>
> [1]: http://emacsformacosx.com/
>
> Cheers,
> Moritz Ulrich
>
>

-- 
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-mode + aquamacs + paredit and character literals

2012-03-22 Thread László Török
I'm on OS X 10.6.8 with latest stable Aquamacs and
https://github.com/overtone/live-coding-emacs. Worked out of the box and is
the most amazing visual experience and programmer productivity I had with
Emacs so far.


Las

2012/3/22 Moritz Ulrich 

> Do you really need Aquamacs? My experience is that it causes more
> trouble than it's worth.
>
> I'd recommend using vanilla Emacs from [1] or building from source
> with the --cocoa switch. Vanilla Emacs on OS X got so good you don't
> really need Aquamacs anymore.
> Looking at the Emacs Starter Kit from Phil Hagelberg might be helpful too.
>
> [1]: http://emacsformacosx.com/
>
> Cheers,
> Moritz Ulrich
>
> On Wed, Mar 21, 2012 at 21:06, JuanManuel Gimeno Illa
>  wrote:
> > I'm having problems typing character literals in aquamacs when
> clojure-mode
> > and paredit are active. When I type the character \, emacs complains
> with:
> >
> > after 0 kwd macro iterations: Wrong type argument: characterp, -1
> >
> > Any idea of what is going on?
> >
> > Thanks,
> >
> > Juan 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
>
>
>
> --
> Moritz Ulrich
>
> --
> 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




-- 
László Török

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

G.Groups moderation appears to be broken

2012-03-22 Thread Stuart Sierra
Moderation will continue as soon as it's working again.
-S

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

New Clojure User Group for Columbus, OH

2012-03-22 Thread Matthew Boston
We're back on the radar!

After nearly a year of going dormant, the Columbus Clojure User Group 
(formerly Inclojure) is back up and running. The past several months we've 
have a consistent number of members showing up.

We have a new website www.columbusclojure.com and twitter 
https://twitter.com/columbusclojure. And our mailing list group 
is http://groups.google.com/group/columbusclojure.

If you're in the Columbus, OH area please join us on the first Wednesday of 
every month. We meet at the EdgeCase office in Powell. Address and details 
are on the website.

I hope to see some of you there.

-- 
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-scheme - Compiling Clojure to Scheme to C

2012-03-22 Thread Patrick Logan
Gambit Scheme especially has a great interface to C/C++/Objective-C. I've 
been happily using Gambit quite a bit for 20+ years, when it originated as 
gambit-68k for the Motorola 68000.

Gambit-C's been ported to iOS, Nintendo DS, etc.

In addition to the great C interface, it also has a great Unix/Posix 
interface, a great threads and message passing library (in the neighborhood 
of Erlang's performance for numbers of threads and messages per second), 
etc. It comes with Termite which is an Erlang-like programming model with 
mobile continuations.

So porting to Gambit provides some good avenues to explore.

-Patrick


On Wednesday, March 21, 2012 12:46:13 AM UTC-7, Nathan Sorenson wrote:
>
> I see the C code generation as an advantage, in that it becomes possible 
> to target any platform with a C compiler.
>
> Can Clozure compile to iOS? 
>
> Just a question, why Clojure->Scheme->C, instead of Clojure->Clozure? 
>>
>> That way there would no be any C compiler dependency. 
>>
>
On Wednesday, March 21, 2012 12:46:13 AM UTC-7, Nathan Sorenson wrote:
>
> I see the C code generation as an advantage, in that it becomes possible 
> to target any platform with a C compiler.
>
> Can Clozure compile to iOS? 
>
> Just a question, why Clojure->Scheme->C, instead of Clojure->Clozure? 
>>
>> That way there would no be any C compiler dependency. 
>>
>

-- 
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: G.Groups moderation appears to be broken

2012-03-22 Thread Sean Corfield
On Thu, Mar 22, 2012 at 11:12 AM, Stuart Sierra
 wrote:
> Moderation will continue as soon as it's working again.

FWIW, I ran into this on a group I moderate and temporarily switched
back to "old groups" which let me moderate users and messages...
-- 
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: understanding data structures, and other low-level stuff

2012-03-22 Thread Nic Long
Just want to say I sent this before all the other comments - including
the talk by Danie Spiewak and the Sedgewick and Wayne book on
Algorithms - so I'll definitely have a look at those too.

Thanks again for all the advice!

On Mar 20, 6:45 pm, Nic Long  wrote:
> Hey, just want to say thanks for all the advice! And Andy especially
> for the kind offer - I may well PM some specific questions once I
> start reading.
>
> The Cormen et al. book looks great - tough but exactly what I need -
> so I'm going to pick up a copy. And I'll also read the PhD thesis on
> Functional Data Structures suggested by Nuno.
>
> On Mar 19, 8:02 pm, Nuno Marques 
> wrote:
>
>
>
>
>
>
>
> > This book:
>
> > Purely Functional Data 
> > Structureshttp://www.cs.cmu.edu/~rwh/theses/okasaki.pdf
>
> > is a good read.
>
> > Though, It only contains a small reference (half a page) about persistent 
> > data structures.
>
> > On Mar 19, 2012, at 7:28 PM, Andy Fingerhut wrote:
>
> > > I've got my copy of Cormen, Leiserson, and Rivest's book with me now, 
> > > which is the 3rd edition, and looking in the index under "persistent" it 
> > > does have one exercise in chapter 13 on that topic, and a mention later 
> > > in the book that is a paragraph or two long with a reference to a 
> > > research paper.
>
> > > So while that book isn't a good reference for persistent data structures 
> > > in particular, it is a good reference for the more widely known (and some 
> > > not-so-widely known) mutable data structures.  If you learn at least a 
> > > few of those, then you are very well prepared to understand Clojure's 
> > > persistent data structures, too, and there are blog posts on the topic 
> > > that can get you a lot of the way there (once you understand the basics), 
> > > e.g.:
>
> > >http://blog.higher-order.net/2009/09/08/understanding-clojures-persis...
>
> > > The book does assume a knowledge of how basic arrays work, but those are 
> > > quite simple and hopefully my message below is nearly as much as there is 
> > > to know about them.  To get an understanding of data structures like hash 
> > > tables and some different kinds of trees, you can probably get there just 
> > > reading a few of the introductory sections at the beginning, and then 
> > > jump to those specific sections.  Save all the stuff on algorithms for 
> > > when and if you are interested.
>
> > > Andy
>
> > > On Mar 18, 2012, at 8:57 PM, Andy Fingerhut wrote:
>
> > >> Feel free to ask follow-up questions on the basics privately, since many 
> > >> Clojure programmers are probably already familiar with them, whereas 
> > >> follow-up questions on persistent data structures are very on-topic, 
> > >> since I would guess many people who have studied computer science and/or 
> > >> programming for a while may not be familiar with them.
>
> > >> The classic model of an array is based upon the implementation of 
> > >> physical RAM in a computer: a physical RAM, at a high level and leaving 
> > >> out details of variations, is a device where you either give it a 
> > >> command READ and an address, and it returns an 8-bit byte stored at that 
> > >> location, or you give it a WRITE command, an address, and an 8-bit 
> > >> value, and it stores the 8-bit value at the location given by the 
> > >> address.
>
> > >> A classic array is a one-dimensional structure indexed by an integer i, 
> > >> usually from 0 up to some maximum value N, and every item in the array 
> > >> stores an item of the same size and type, e.g. all 32-bit integers, or 
> > >> all pointers to some object elsewhere in the memory.  If every item fits 
> > >> in exactly B bytes, and the first item of the array begins at address A 
> > >> in the memory, then item i will be at address A+B*i in the memory.  In 
> > >> terms of performance, computers are designed to be able to access any 
> > >> address in their memory in the same amount of time, no matter what 
> > >> address it is stored at, so with a couple of instructions to calculate 
> > >> A+B*i, the computer can read or write any element of an array within a 
> > >> constant amount of time (constant meaning it doesn't get larger or 
> > >> smaller depending upon the size of the array -- it is always the same no 
> > >> matter the array's size).  With other non-array data structures like 
> > >> trees, accessing an element takes longer as the data structure grows to 
> > >> contain more items.
>
> > >> I don't recall if it covers persistent data structures like the ones 
> > >> most commonly used in Clojure, but Cormen, Leiserson, and Rivest's 
> > >> "Introduction to Algorithms" is used in many colleges as a text in 
> > >> courses on algorithms and data structures.  There are probably other 
> > >> books that would be better as a "primer", and it does assume you are 
> > >> comfortable with at least algebra and a bit more math, but if you got 
> > >> through a chapter of it and understood even half of it, you'd have 
> > >> learned something w

Re: Literate programming in emacs - any experience?

2012-03-22 Thread daly
On Tue, 2012-03-20 at 12:27 -0700, Tim Dysinger wrote:
> I'm using org-mode, org-babel & swank for a "living" document I'm
> writing. I'm generating a PDF which includes documentation, working
> clojure code that generates incanter graphs.  Also the generated
> incanter graphs are included in the generated (latex) PDF.
> 
> On Monday, January 23, 2012 3:14:09 AM UTC-10, Colin Yates wrote:
> Hi all,
> 
> 
> There are some excellent resources on this mailing list
> regarding literate resources, but they are more based around
> the theory rather than actual use.
You might find this of interest:

Literate Programming example with Clojure
http://youtu.be/mDlzE9yy1mk

It is a quick video of my normal literate programming workflow
(ignoring the usual git commits)

It shows 3 things:
  1) Extracting Clojure from the book and rebuilding the book PDF
  2) adding code chunks and rebuilding clojure and the book
  3) making text-only modifications and rebuilding only the PDF

> 
> 
> Has anybody got any "real world usage reports" regarding using
> literate programming in emacs?  In particular, does paredit
> and slime work inside the clojure "fragments" when using
> org.babel for example?
> 
> 
> Finally - how are people finding practising TDD with literate
> programming?  I imagine that Clojure's excellent REPL (+
> evaluating clojure forms from within a buffer) mean there are
> far less "type, extract tangled code, run tests" needed.
> Hmmm, not sure that is clear.  What I mean is, do people find
> that the ability to evaluate a clojure form from within
> org.babel (assuming that is possible!) is sufficient for TDD
> or do you find you need to type, extract the tangled code and
> then run lein (for example) to run the tests?

When you run 'make', as shown in the video, it rebuilds the program
and runs all the tests.

> 
> 
> Basically - how do y'all get on with TDDing in emacs following
> the approach of literate programming - any advice welcome!

Here is an interesting quote from Greg Wilson (http://vimeo.com/9270320)

>From a IBM 1970s study: "Hour for hour - the most effective way to get
bugs out of code is to sit and read the code, not to run it and not to
write unit tests. Code review is the best technique known for fixing
bugs. Get somebody else to read your code. Sixty to Ninety percent of
errors can be removed before the very first run of the program. And
hour for hour, if you have a choice of writing unit tests and reading
code, read the code."

Thus, literate programming, which explains the reasoning behind the
code and the issues involved, would seem to make code reviews be much
more effective. I would love to do a study about this but so far I
have not found any professors interested.

Tim Daly
d...@axiom-developer.org


-- 
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: SuperDevMode and SourceMaps for ClojureScript debugging

2012-03-22 Thread Brian Rowe
Any suggestions on how to get started on tackling that?

On Tuesday, March 20, 2012 5:05:40 PM UTC-4, David Nolen wrote:
>
> On Tue, Mar 20, 2012 at 2:45 PM, Alexander Zolotko wrote:
>
>> Ray Cromwell , 
>> a Google employee, has recently announced new feature in Chrome Dev Tools: 
>> SuperDevMode 
>> and 
>> SourceMaps.
>>  It 
>> helps to map source code written in programming language that targets 
>> JavaScript run-time (e.g. CoffeeScript) to resulting JavaScript code. Is 
>> it feasible to utilize it to debug ClojureScript in a browser? Please share 
>> your thoughts.
>
>
> Yep, looks promising and we definitely want to support it. Would love to 
> see someone tackle this project.
>
> 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: Literate programming in emacs - any experience?

2012-03-22 Thread Michael O'Keefe
Hey Tim,

Just wanted to say thanks for this post and this is a great discussion. I 
have the privilege of being able to spend a small amount of my time working 
on "official unofficial" projects at my work. I had seen an earlier post by 
you where I think you may have posted the same code to extract source from 
a literate file. I had always been intrigued by literate programming and 
your post especially inspired me to try it out.

I've now written a substantial amount of my project in Clojure in the 
literate style. I'm using the "HTML" version of the literate syntax + 
markdown and writing in vim. I just wanted to chime in that one of the 
biggest things I've noticed was how much more scrutinized my code has 
become. In trying to describe my code to the reader, I'm looking it over 
much more than I ever normally would and it's forcing me to really think 
about my design decisions.

Anyhow, just wanted to thank you for your inspirational words and I'm 
excited to check out your video.

Sincerely,

Michael O'Keefe

On Wednesday, February 1, 2012 5:51:53 AM UTC-7, daly wrote:
>
> On Wed, 2012-02-01 at 10:43 +, Sam Aaron wrote:
> > On 30 Jan 2012, at 17:07, daly wrote:
> > > 
> > > The key result was that I discovered what I call my personal
> > > "irreducible error rate". If I do 100 things I will make 3 errors.
> > > This was independent of the task. So typing 100 characters has
> > > 3 wrong letters which were mostly caught while typing. Writing
> > > 100 lines of code had 3 errors somewhere. Composing email
> > > introduces 3 errors per 100 lines of code.
> > 
> > I wonder if that rate has changed since the time you measured it. 
> > 
> Unfortunately not. However I am now able to identify several
> errors that I continue to make. The 2/3 keys get mistyped.
> The _/+ keys get mistyped. I seem unable to overcome this.
> Which is really bad considering my hobby is computer algebra.
>
> The largest contribution to my errors is using copy/paste.
> It is responsible for about 50% of all errors. If I could
> convince myself to stop using it my error rate would drop.
> On good days I don't use it but I get lazy.
>
> Curiously I do have a lower error rate in Lisp than I do in
> other languages. In C, for instance, I get caught by things
> like float to double conversions on calls, despite knowing
> about it. In Java I miss the null case checks despite being
> aware that Java is brain-dead about null. In Python I skip
> "self"ing things. In Javascript I miss the 'var' occasionally.
>
> Lisp "just works" and works just as I expect. It eliminates
> whole categories of errors. (The most annoying thing about
> Clojure is the "null pointer exceptions" from Java.) When
> I want solid, correct code I reach for Lisp. For random
> segment faults, C. For heap exhaustion or null pointers,
> Java, etc. Rich did a marvelous thing by forcing alter to
> require dosync. It eliminates a whole class of errors. 
>
> When I find a mistake I still try to find the root cause.
> Then I try to change what I do so the mistake cannot exist.
> This changes the type of possible errors but the 3% is still
> there. I just make "more sophisticated, higher level errors".
> I am hoping that Literate Programming will raise my errors
> to truly epic proportions :-)
>
> One of my personal motivations for literate programming is
> to eliminate errors. I have no tool that will catch errors
> in reasoning, missing cases, bad design, mindless stupidity,
> and horrible inefficiency. Writing an explanation of the
> code is the best way I have found to catch errors of this
> kind. 
>
> One of Rich's stated motivations for Clojure was that he
> found concurrent programming in various languages to be
> very error prone and wanted to create a language that would
> eliminate concurrent errors. In some sense, we are trying
> to achieve similar goals.
>
> So Literate Programming is not about tools. It is about a
> change in mindset. I want to be a better programmer and this
> is an effective tool to help me generate higher quality (ie
> less buggy) code.
>
> Tim Daly
>
>
>

-- 
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: into applied to transient vectors undocumented?

2012-03-22 Thread Leif
Huh.  That raises the question "Why doesn't 
clojure.lang.ITransientCollection extend clojure.lang.IEditableCollection, 
so the .asTransient method is idempotent?"  Would that make a circular 
reference?
--Leif

On Tuesday, March 20, 2012 3:32:28 PM UTC-7, Andy Fingerhut wrote:
>
> Sorry, I said something incorrect.  into cannot take transients as the 
> first arg.  It calls transient internally on the first arg for speed.  This 
> does not modify the value you passed in at all -- it creates a new 
> transient data structure from what you pass in.
>
> If you try calling transient on a data structure that is already a 
> transient, you get an error.  Thus this gives an error:
>
> user=> (def x [1 2 3])
> #'user/x
> user=> (def tx (transient x))
> #'user/tx
> user=> (into tx [5 6 7])
> ClassCastException clojure.lang.PersistentVector$TransientVector cannot be 
> cast to clojure.lang.IPersistentCollection  clojure.core/conj (core.clj:83)
> user=> (into x [5 6 7])
> [1 2 3 5 6 7]
>
> Andy
>
>
> On Mar 20, 2012, at 11:30 AM, Andy Fingerhut wrote:
>
> func! (bang) is a naming convention from the programming language Scheme 
> that Clojure often uses.  In general it means that the function mutates 
> data, i.e. it is not a pure function.  Clojure does not have a ! after all 
> of its core functions that do this, but it does after some.  In particular, 
> the functions that operate on transients like conj! assoc! persistent! etc. 
> mutate their arguments.
>
> Many (maybe most) regular collection functions do not take transients.  As 
> I said, I think it is an accident, not by design, that 'into' can take a 
> transient as an argument.  Originally it only took persistent collections 
> as arguments (perhaps also seqs, but those are immutable, too).
>
> Andy
>
> On Mar 20, 2012, at 11:17 AM, László Török wrote:
>
> Ok,
>
> so the pattern is:
>
> func! (bang) takes a transient and returns a transient
>
> regular collection functions MAY take a transient but ALWAYS return a 
> persistent collection, right? :)
>
> thx
> Las
>
> 2012/3/20 Andy Fingerhut 
>
>> into uses transient and persistent! for speed.  The fact that into can 
>> take a transient as input is an accidental consequence of that, I think. 
>>  Before into was changed to use transients internally, it could only take 
>> persistent data structures as input, and return a persistent data structure.
>>
>> Andy
>>
>> On Mar 20, 2012, at 10:32 AM, László Török wrote:
>>
>> Hi,
>>
>> While implementing qsort with clojure for fun, I thought about using 
>> transient vectors to speed up sorting vs the "naive" functional 
>> implementation.
>>
>> I need an *into!* version of *into *when joining two sorted subarrays 
>> and I was wondering why there isn't one.
>>
>> It seems that (source into) does in fact support a transient collection 
>> as the first argument, however it calls persistent! on the result.
>>
>> What was the rationale behind the decision? (Note: I'm not questioning 
>> it, just interested.)
>> Is there a particular reason why this feature remains undocumented? 
>>
>> -- 
>> László Török
>>
>>
>> -- 
>> 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
>
>
>
>
> -- 
> László Török
>
>
> -- 
> 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

newbie struggling with Clooj and jars

2012-03-22 Thread TI Explorer vet
I love the premise of Clojure and the simplicity of Clooj.  I used to write 
Lisp in Emacs years ago but I'd rather not dust off the Emacs brain cells.

I'm trying to write a simple Twitter client in Clojure. I've got 
twitter-apidownloaded and installed 
and can run the example with 'lein repl', but I 
can't get it to work with Clooj.  I compiled twitter-api into a jar and 
stuck it into a "jars" subfolder.  Then I tried this in the Clooj REPL:

(ns mynamespace

  (:use

   [twitter.oauth]

   [twitter.callbacks]

   [twitter.callbacks.handlers]

   [twitter.api.restful])

  (:import

   (twitter.callbacks.protocols SyncSingleCallback)))


and got the following error message:


# oauth/client__init.class or oauth/client.clj on classpath: >


I'm confused, because Clooj seems to think the jar is in its classpath:


 Classpath:

  /Users/david/Documents/coaching/TPG/TwitterBot/jars

  /Users/david/Documents/coaching/TPG/TwitterBot/src

  /Users/david/Documents/coaching/TPG/TwitterBot/twitter-api

  /Users/david/Documents/coaching/TPG/TwitterBot/jars/twitter-api-0.6.4.jar

 
I can write code in Clooj, save it to disk, and use 'lein run', but I'd 
rather be able to compile a function at a time like I used to in Lisp/Emacs 
and I'm assuming this is possible in Clooj.

What I am missing?

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

Tutorial: Clojure applications in Eclipse with Counterclockwise and Maven

2012-03-22 Thread Nicolas Duchenne
Hi Everyone,

I wrote an extensive tutorial in two parts about developing Clojure 
applications with Maven and Counterclockwise in Eclipse:

Clojure in Eclipse, Part 1: 
Maven:
 Develop, test and deploy a Clojure app in Eclipse with Maven only. Get 
into the details of the POM and understand Maven's concept of life-cycle.

Clojure in Eclipse, Part 2: Counterclockwise + 
Maven:
 
Develop comfortably and interactively with CCW. Fulfill all your workflow 
needs with the combination of CCW and Maven.

I wrote this in two parts, in particular to help understand what Maven is 
about and what each tool adds to the other. Also, there was a bit to say 
about how to make Eclipse, Maven and Clojure work together happily.

I hope you find it interesting and, even better, helpful. Do shout if I 
wrote anything wrong or if any of it is not understandable. 

Cheers,

Nico

-- 
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: revisiting community funding?

2012-03-22 Thread Mimmo Cosenza
Me too.
mimmo

On Tuesday, March 20, 2012 9:09:31 PM UTC+1, nchurch wrote:
>
> There was a brief period of community funding for Rich's work back in 
> 2010.  When that ended, we now know the result was Datomica huge 
> win. 
>
> But there are other people who work on Clojure and Clojurescript; 
> great things could happen from the focus that comes from being able to 
> work on them full time.  I know I'd be willing to give a couple 
> hundred to fund such an effort, and given how much people spend to go 
> to conferences, I'd be surprised if many others didn't feel the same 
> way.  And then there are now many companies that depend on Clojure. 
>
> I'm curious how Clojure/core would feel about this.  Is there still a 
> concern about creating "unreasonable expectations"?  Are there people 
> outside Clojure/core who would be willing to work on 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

I'm writing a Tempest clone in ClojureScript

2012-03-22 Thread Trevor Bentley
I'm teaching myself Clojure/ClojureScript/HTML5 via an excessively complex 
first project: a clone of the arcade game Tempest.  I thought it might be a 
handy resource to share since I've found surprisingly few ClojureScript 
examples.  More certainly couldn't hurt.

https://github.com/mrmekon/tempest-cljs

The game is nowhere close to done, but there's some functional drawing and 
movement code.  Collision detection is about the only thing left before it 
qualifies as a "game", albeit a terrible, unfinished one.  It isn't 
currently hosted anywhere, so you'll have to run it yourself, or make do 
with the screenshots.  I have 6 levels, one kind of enemy, and the player 
ship moves and shoots.  Level design is the most interesting part -- I 
wrote some level-generating code, so certain types of levels can be 
generated very easily. 

ClojureScript has been surprisingly solid and easy to work with.  I was 
considering using it for a startup I'm working with, and this project has 
done nothing to dissuade me.

-Trevor

-- 
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: beginner help with views in ClojureScript One?

2012-03-22 Thread Pierre-Henry Perret
Hi,
I have succeeded in creating another development page by restarting the vm.
I dont know why it is not recompiled when reloading the page...

Le vendredi 16 mars 2012 04:50:17 UTC+1, George Oliver a écrit :
>
> hi, I'm starting to modify the One sample application and can't get 
> the hang of rendering a new view. I've tried looking at some forked 
> projects but am coming up short. 
>
> I created a basic template  /templates/game.html: 
>
> <_within file="application.html"> 
>
>
>  
>   My game goes here.  
>  
>
>
>  
>
> I edited /public/design.html to add a link: 
>
>  
>   Form 
>   Greeting 
>   Play the game 
>  
>
> And now I can click on the link at http://localhost/design.html and 
> see the template. 
>
> To check if I can see this in Development mode, in one/sample/ 
> view.cljs I changed the render method for :init, 
>
> (defmethod render :init [_] 
>   (fx/my-initialize-views (:game snippets))) 
>
> And in one/sample/animation.cljs added: 
>
> (defn my-initialize-views 
>   [game-html] 
>   (let [content (xpath "//div[@id='content']")] 
> (destroy-children! content) 
> (set-html! content game-html) 
> )) 
>
> And in one/sample/snippets.clj modified the macro snippets: 
>
> (defmacro snippets 
>   "Expands to a map of HTML snippets which are extracted from the 
>   design templates." 
>   [] 
>   {:form (snippet "form.html" [:div#form]) 
>:greeting (snippet "greeting.html" [:div#greeting]) 
>:game (snippet "game.html" [:div#game])}) 
>
> However when I browse to Development the content div is empty -- the 
> html looks like: 
>
>  
>
>
>
>
>
>
>
>   
>
>
> Does anyone have some suggestions on how to display the game.html 
> template when first browsing to Development? Thanks. 
>
>

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

removing a hash-map from a set using hash-map's field.

2012-03-22 Thread Leandro Oliveira
Hi all, 

I have a set of hash like this:

#{{:id 1, :foo "bar"} {:id 2, :foo "car"}}

and I'd like to remove an item based on its id value. 

Unfortunately, disj requires that I pass the whole map as key to remove it.

Can I remove the map from the set only using the id?

My intention is to avoid a lookup on set to get the whole map back.

Any suggestions?


Thanks in advance.
leandro.

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

[OT] Any other italian Clojure users?

2012-03-22 Thread Marco Dalla Stella
Hi,

I just want to know if there are any other italian Clojure users in
the ml, maybe for open an Italian Clojure User Group and organize some
meetings...

Thanks,
-- 
Marco Dalla Stella
web: http://thediracsea.org
twitter: http://twitter.com/kra1iz3c

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


Use metadata instead of :require-macros for requiring macros from ClojureScript?

2012-03-22 Thread Evan Mezeske
Hi,

I'm working on some tools for making it easier to share generic Clojure 
code between Clojure and ClojureScript, and one problem that does not seem 
to have a pretty solution is that of requiring macros.  Clojure uses a 
regular (:require ...) whereas ClojureScript needs a (:require-macros ...). 
 I understand that the distinction is necessary for ClojureScript because 
macros are written in Clojure.

This difference in the (ns ...) form is troublesome when trying to share 
code between the two languages.  Right now, the only solution is to 
copy+edit the shared file (possibly with an automated tool) so that it has 
:require and :require-macros as appropriate.  This is not very pretty.

So that gets me to wondering, has anyone brought up the idea of using 
metadata to identify macro namespaces?  So instead of using 
:require-macros, :require would be used, but each namespace identifier 
would be inspected to see if it had ^{:macros true}.
 

; The existing way to require macros from ClojureScript:

(ns example.shared
  (:require-macros
[example.macros :as macros])
  (:require
[example.other :as other]))

 

(ns example.shared
  (:require
^:macros [example.macros :as macros]
[example.other :as other]))

-- 
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: ClojureScriptOne design

2012-03-22 Thread Pierre-Henry Perret
Le mardi 20 mars 2012 17:59:02 UTC+1, Pierre-Henry Perret a écrit :
>
> I have added a new model cljs file in my dev One app , but when I use it 
> in the controller, that one doesnt see it.
>
> Any idea, suggestion?
>
> Thanks
>

Also, to effectively recoompile the snippets macro, I'll have the whome JVM 
to restart...

By the way which is the recommended VM to work with ?

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

beginner - stuck in dependencies and possibly old versions

2012-03-22 Thread ted
Hi all,
I am very much a beginner with Clojure and have no experience with Java so 
please be gentle with me.
I've been playing around with numerous incarnations of Lisp but would like 
to settle on Clojure, however I cannot get my environment sorted.
I've installed Leiningen but when I try to do "lein plugin install 
swank-clojure 1.3.1" or "lein plugin install lein-oneoff 0.2.0" I get 
"[INFO] unable to find resource 'swank-clojure:swank-clojure:jar:1.3.1' in 
repository central (http://repo1.maven.org/maven2)" (or equivalent for 
lein-oneoff)
I'm sure it is something simple but I have no idea where to look and feel 
like I'm stuck at the first hurdle. Anybody any idea?
I think Leiningen is installed correctly as I can create new projects. I 
did notice however that the project.clj file as a default refers to clojure 
1.2.1 as opposed to clojure 1.3.0. It is very likely that I have old 
versions of Clojure floating around on my machine as I've played around 
with Clojure in the past. (I'd like to get rid of the old versions but not 
sure in which directory(/ies) they have been installed
Please let me know if I need to provide more info.
Thanks in advance
Ted

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

2012-03-22 Thread Brandon Bloom
SourceMap support is rapidly approaching general availability in Chrome and 
Firefox:

http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/

I'd love to see this happen and *may* be able to find time to help with 
implementation.

Any intel on existing attempts at this?

On Sunday, July 24, 2011 11:59:52 AM UTC-7, David Nolen wrote:
>
> On Sun, Jul 24, 2011 at 1:19 PM, John  wrote:
>
>> Is there any interest in having ClojureScript generate source maps?
>>
>> http://code.google.com/p/closure-compiler/wiki/SourceMaps
>>
>> There are a couple of ways to accomplish this.
>>
>
> I'm sure there is a considerable amount of interest in this.
>
> David 
>

On Sunday, July 24, 2011 11:59:52 AM UTC-7, David Nolen wrote:
>
> On Sun, Jul 24, 2011 at 1:19 PM, John  wrote:
>
>> Is there any interest in having ClojureScript generate source maps?
>>
>> http://code.google.com/p/closure-compiler/wiki/SourceMaps
>>
>> There are a couple of ways to accomplish this.
>>
>
> I'm sure there is a considerable amount of interest in this.
>
> 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

ClojureScript: how to get rid of "no longer a property access" warning

2012-03-22 Thread Tom Krestle
Hi,

Executing legitimate code in CLJS REPL produces expected result with a 
warning. Is this syntax wrong? Is there a way to disable the warning?

> (.getTime (js/Date.))
WARNING: The form (. (js/Date.) getTime) is no longer a property access. 
Maybe you meant (. (js/Date.) -getTime) instead?
1332339898277

Thanks,
Tom

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

2012-03-22 Thread Andru Gheorghiu
Thank you for the responses. I'm looking into the resources you gave
me.

Andru Gheorghiu

On Mar 21, 1:16 pm, Sanel Zukan  wrote:
>  I'm happy to see you are familiar with the subject :)
>
> I was thinking that a
>
> > similar program for Clojure could detect stack recursive functions and
> > replace them with their iterative counterparts, though this can be
> > somewhat difficult as various loop-holes can arise that would "fool"
> > the program.
>
> This isn't a big issue, as recursive functions aren't much advised in
> Clojure. However, ideal solution would be to detect tail calls and rewrite
> block in loop/recur combo. This would allow Clojure to fully reuse TCO
> without waiting for JVM to implement it (which will probably never happen).
>
> I suppose an approach can be found which makes the best out of both
>
> > worlds: a tree shaker and constant folding implementation + an
> > automated program which detects recursions and replaces them with more
> > efficient versions and a rule-based system to cover some cases which
> > the first approach misses.
>
> Using all this tasks would impose a bit of work to complete them all. I
> would advise taking smaller steps in form of real tasks, followed with
> rigorous tests. It can look like this:
>
>  * constant folding
>  * empty let removal
>  * lambda reduction
>  * TCO
>  * simplification (using Kibit or directly core.logic)
>  * ...
>
> If you decide to work on this, for the starting point you can look at
> "optimizer.scm" (from CHICKEN source) which is nicely summarized at [1] and
> Egi's code [2]. Both of them applies common techniques in quite readable
> manner. Of course, if someone else have additional resource, please share
> it :)
>
> Sanel
>
> [1]http://wiki.call-cc.org/chicken-internal-structure#the-optimizer-opti...
> [2]https://bitbucket.org/egi/compiler/src
>
>
>
>
>
>
>
> On Tuesday, March 20, 2012 7:30:41 PM UTC+1, Andru Gheorghiu wrote:
>
> > Thank you for the clarifications and the resources, I understand now
> > what tree shaking is. In fact, I had a project last year at our
> > college to implement (in Scheme) a constant folding optimizer for
> > Scheme programs, I now see the resemblance with what you described.
> > The program would optimize functions like:
>
> > (define some-function
> >     (lambda (x)
> >          (if (> x (+ 2 4))
> >             (- 7 (car ‘(1 2 3)))
> >             (cons x 4)))
>
> > Turning it into
>
> > (define some-function
> >     (lambda (x)
> >        (if (> x 6)
> >            6
> >            (cons x 4
>
> > Also, when finding conditional statements in which the test condition
> > is known (can be evaluated) to replace it with the code which runs on
> > the appropriate branch. For example, replacing:
>
> > (if (or #f #t)
> >     then-code
> >     else-code)
>
> > With
>
> > then-code
>
> > Same thing for cond.
>
> > Another part of the project was to classify recursive functions into
> > stack recursive, tree recursive or iterations. I was thinking that a
> > similar program for Clojure could detect stack recursive functions and
> > replace them with their iterative counterparts, though this can be
> > somewhat difficult as various loop-holes can arise that would "fool"
> > the program.
> > I suppose an approach can be found which makes the best out of both
> > worlds: a tree shaker and constant folding implementation + an
> > automated program which detects recursions and replaces them with more
> > efficient versions and a rule-based system to cover some cases which
> > the first approach misses.
>
> > Andru Gheorghiu
>
> > On Mar 20, 1:31 am, Sanel Zukan  wrote:
> > > Hi Andru and thank you for expressing interest in this proposal.
>
> > > > Could you please give more details (or examples) on the types of
> > > > optimizations the optimizer should be able to do? Also, what is a tree
> > > > shaker implementation?
>
> > > As David wrote, this is dead code elimination and in LISP world is also
> > > known as tree shaking. Contrary to pattern matching (for which you
> > > expressed desire), dead code elimination is usually more advanced
> > approach,
> > > sometimes requiring passing through the code multiple times, inspecting
> > > compiler facilities or simply doing a bunch of tricks to remove obvious
> > and
> > > not so obvious unused code.
>
> > > Take this example:
>
> > >   (defonce *always-true* true)
> > >   (if *always-true*
> > >      (println "Always executed")
> > >      (println "Never executed"))
>
> > > Matching this case could be hard for pattern matching tools; they often
> > do
> > > not understand the content outside given pattern. True optimizer would
> > pick
> > > up *always-true* and notice it will never be changed for this block.
> > > However, if I do some weird magic inside some function and globally
> > change
> > > the value of *always-true* at some point, optimizer should recognize
> > this
> > > case or would remove valid code.
>
> > > Also, often case for optimizers is 

Re: Passing data out of closure into the outer context

2012-03-22 Thread Tom Krestle

Thanks, man! I ended up using atoms.


On Tuesday, March 20, 2012 2:13:18 PM UTC-7, Cedric Greevey wrote:
>
> On Tue, Mar 20, 2012 at 11:16 AM, Tom Krestle  
> wrote:
> > Greetings,
> >
> > I've stumbled across the following problem, which I believe is common and
> > should have some sort of generic solution. Imagine I have
> >
> > ... ;; code inside defn
> > ;; I extract some information out of my atom in closure:
> > (swap! my-atom
> >   (fn [val]
> > (let [extracted-info1 (extract-something-from val)
> >   extracted-info2 (extract-something-else-from val)]
> > ;; update the atom
> > (-> val
> >   (assoc ...) (assoc) ;; out of swap!
> >
> > ;; still code inside defn
> > ;; now, here I need to use those extracted-info1, extracted-info2 that I 
> got
> > out of atom inside swap! operation
> > ;; What would be the common way to pass that information here? Using vals
> > doesn't sound right.
> >
> > Have a beer!
> > Tom
>
> The ugly way, as you noted, is to change the atom from some-map to
> [some-map extracted-info-from-last-swap].
>
> A less ugly way might be
>
> (let [ei (atom nil)]
>   (swap! my-atom
> ...
> (reset! ei extracted-info1)
> ...)
>   (do-things-with ei))
>
> If the swap! is retried, the ei atom will be reset! more than once,
> but it will after the swap! contain the extracted-info1 from the
> successful swap! of my-atom.
>
> The most functional way would be to see if you couldn't do the work
> with ei *inside* the closure. However, if it's expensive or
> side-effecty that doesn't play nice with swap! retrying. In that
> instance, you might want to think of replacing my-atom with my-ref and
> doing something like
>
> (dosync
>   (alter my-ref
> ...
> (send-off ei-agent ei-do-things-func extracted-info1)
> ...))
>
> Agent sends are held until a transaction commits, so the
> ei-do-things-func will be called only once for each transaction on
> my-ref.
>
>

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

GSoC: Browser-based Clojure(Script) editor

2012-03-22 Thread Martin Forsgren
Hello!
I am thinking of applying to GSoC and I found the proposal to continue
working on Chris Grangers Clojure(script)-editor in "Bret Victor-
style" really interesting.

I have some ideas on features that I think would be nice to have,
other than opening, saving and compiling files:

Visualization of functions à la Bret Victor (Let the user give example
input, then print the values of all local vars (and maybe return
values of function calls) at the side of the function). Using
clojure.tools.trace or CDT perhaps?
Possibility to add the example input and the corresponding expected
output as an unit test for the function.

Pluggable ui-widgets (like the slider and colorpicker in Brets talk).
Examples: slider, checkbox, colorpicker, filechooser, datepicker,
mouse movement recorder, piano?, whatever.
(predicate dispatch to determine what widget to choose? :)

Pluggable widgets for visualising data(structures) could also be
created.(Perhaps inline widgets? Although I think that most often
would be more annoying than helpful.)

Use kibit to highlight code that could be rewritten.

Visualising the call-stack (as Chris suggested)

Graphs of relations between namespaces.

What do you think? Do you have other ideas? What features do you think
one should focus on first ? Please give some feedback.

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


Frustrations in being moderated

2012-03-22 Thread Evan Mezeske
Hi,

I've been posting very lightly to this group for a few weeks now, and am an 
active member of the Clojure community (or so I'd like to think), and yet 
all my posts still have to go through human moderation.  I understand that 
there's probably something algorithmic going on behind the scenes that has 
not yet seen enough messages from me to determine that I should be 
unmoderated, but it would be nice if it could be expedited.

This is quite frustrating, and is a strong barrier to my further 
participation in the mailing list.  I often want to respond to other 
people's questions, but don't bother to do so, because in the 24-48 hours 
it takes my post to get through someone else will undoubtedly have answered 
it in my stead.  I doubt that I'm alone in being frustrated, and I'd wager 
that there are others who refrain from participating for the same reason.

I'm sure that some level of moderation is necessary to keep the list clean, 
but does it have to be so draconian?



Thanks,
-Evan

P.S. A few moments ago I accidentally fat-fingered the tab key and sent out 
a half-finished message.  Since I'm moderated, I can't quickly reply and 
fix that.  Please pardon the nonsensical note...



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

External sorting implementation in clojure

2012-03-22 Thread Nishant rayan
Hi,
I am working on a project that requires sorting a very large file.
Obviously sorting the file in memory is not an option.
My input is a file in csv format and i want an output file in the same
format sorted on all columns (from left to write).

Of course I can implement an external sorting
algorithmmyself
but just wanted to check if something like that exists (in clojure)
that I can use.


Thanks,
*Nishant
*

-- 
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: newbie struggling with Clooj and jars

2012-03-22 Thread Moritz Ulrich
I'm pretty sure you're missing the dependencies (in this case:
clj-oauth) for twitter-api in your Clooj classpath. Take a look at [1]
to see which.
The whole thing works in leiningen because it loads all necessary
dependencies for you.

I highly recommend to use leiningen for all dependency management,
don't copy jars around. A quick look at the readme of Clooj reveals
that it somehow supports leiningen :)

[1]: https://github.com/adamwynne/twitter-api/blob/master/project.clj

On Wed, Mar 21, 2012 at 20:42, TI Explorer vet  wrote:
> I love the premise of Clojure and the simplicity of Clooj.  I used to write
> Lisp in Emacs years ago but I'd rather not dust off the Emacs brain cells.
>
> I'm trying to write a simple Twitter client in Clojure. I've got twitter-api
> downloaded and installed and can run the example with 'lein repl', but I
> can't get it to work with Clooj.  I compiled twitter-api into a jar and
> stuck it into a "jars" subfolder.  Then I tried this in the Clooj REPL:
>
> (ns mynamespace
>
>   (:use
>
>[twitter.oauth]
>
>[twitter.callbacks]
>
>[twitter.callbacks.handlers]
>
>[twitter.api.restful])
>
>   (:import
>
>(twitter.callbacks.protocols SyncSingleCallback)))
>
>
> and got the following error message:
>
>
>> #> oauth/client__init.class or oauth/client.clj on classpath: >
>
>
> I'm confused, because Clooj seems to think the jar is in its classpath:
>
>
>  Classpath:
>
>   /Users/david/Documents/coaching/TPG/TwitterBot/jars
>
>   /Users/david/Documents/coaching/TPG/TwitterBot/src
>
>   /Users/david/Documents/coaching/TPG/TwitterBot/twitter-api
>
>   /Users/david/Documents/coaching/TPG/TwitterBot/jars/twitter-api-0.6.4.jar
>
>
> I can write code in Clooj, save it to disk, and use 'lein run', but I'd
> rather be able to compile a function at a time like I used to in Lisp/Emacs
> and I'm assuming this is possible in Clooj.
>
> What I am missing?
>
> --
> 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



-- 
Moritz Ulrich

-- 
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: Use metadata instead of :require-macros for requiring macros from ClojureScript?

2012-03-22 Thread Cedric Greevey
On Wed, Mar 21, 2012 at 1:12 AM, Evan Mezeske  wrote:
> Hi,
>
> I'm working on some tools for making it easier to share generic Clojure code
> between Clojure and ClojureScript, and one problem that does not seem to
> have a pretty solution is that of requiring macros.  Clojure uses a regular
> (:require ...) whereas ClojureScript needs a (:require-macros ...).  I
> understand that the distinction is necessary for ClojureScript because
> macros are written in Clojure.
>
> This difference in the (ns ...) form is troublesome when trying to share
> code between the two languages.  Right now, the only solution is to
> copy+edit the shared file (possibly with an automated tool) so that it has
> :require and :require-macros as appropriate.  This is not very pretty.
>
> So that gets me to wondering, has anyone brought up the idea of using
> metadata to identify macro namespaces?  So instead of using :require-macros,
> :require would be used, but each namespace identifier would be inspected to
> see if it had ^{:macros true}.
>
>
> ; The existing way to require macros from ClojureScript:
>
> (ns example.shared
>   (:require-macros
>     [example.macros :as macros])
>   (:require
>     [example.other :as other]))
>
>
>
> (ns example.shared
>   (:require
>     ^:macros [example.macros :as macros]
>     [example.other :as other]))

That might be one way to do it. The other obvious one is to implement
:require-macros in Clojure's ns macro, as a synonym for require, and
make sure require(-macros) is idempotent.

-- 
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: removing a hash-map from a set using hash-map's field.

2012-03-22 Thread Cedric Greevey
On Wed, Mar 21, 2012 at 5:00 PM, Leandro Oliveira  wrote:
> Hi all,
>
> I have a set of hash like this:
>
> #{{:id 1, :foo "bar"} {:id 2, :foo "car"}}
>
> and I'd like to remove an item based on its id value.
>
> Unfortunately, disj requires that I pass the whole map as key to remove it.
>
> Can I remove the map from the set only using the id?
>
> My intention is to avoid a lookup on set to get the whole map back.
>
> Any suggestions?

The only way immediately apparent to me is (into #{} (remove #(= :id
foo) input-set)), but that iterates over the whole set. You could stop
when :id foo got hit by using a loop/recur, and save half the
iterations on average.

I suggest a redesign instead: replace the set with a map. Your example
above would become:

{1 {:id 1, :foo "bar"}, 2 {:id 2, :foo "car"}}

-- 
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: removing a hash-map from a set using hash-map's field.

2012-03-22 Thread Cedric Greevey
On Thu, Mar 22, 2012 at 10:32 PM, Cedric Greevey  wrote:

(into #{} (remove #(= (:id %) foo) input-set))

> You could stop when :id foo got hit by using a loop/recur, and save half the
> iterations on average.

Clarification: stop comparing to match the :id key against the target.
You'd have to continue copying into the output, of course.

The map approach makes it easy via (dissoc the-map foo), as well as to
look up by id.

All of this also assumes that the :id numbers are unique. If they're
not, the map approach needs modifying, to e.g.

{:id 1 [{:id 1, :foo "bar"} {:id 1, :foo "baz"}], :id 2 [{:id 2, :foo "car"}]}

where each value is a bucket of potentially more than one object.

The removal algorithm likewise needs changing if the object is not to
remove ALL items with the target :id. If it's a specific item, you
need to find it in the bucket and remove it using a criterion beyond
the :id (and in the set case, just make the remove closure's test more
specific).

-- 
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: beginner - stuck in dependencies and possibly old versions

2012-03-22 Thread Benny Tsai
Hi Ted,

To answer your last question first, each project.clj determines the clojure 
version used by that project, so you don't really have to worry about old 
versions interfering or anything.

I'm running Lein 1.6.2, which is relatively old, and it defaults new 
project to 1.3.  If yours is using 1.2.1 as the default for new projects, I 
suspect it may be even more outdated, which may be the cause of your 
troubles.  What is the output if you run "lein version", and what OS are 
you running on?

On Wednesday, March 21, 2012 3:41:58 AM UTC-7, ted wrote:
>
> Hi all,
> I am very much a beginner with Clojure and have no experience with Java so 
> please be gentle with me.
> I've been playing around with numerous incarnations of Lisp but would like 
> to settle on Clojure, however I cannot get my environment sorted.
> I've installed Leiningen but when I try to do "lein plugin install 
> swank-clojure 1.3.1" or "lein plugin install lein-oneoff 0.2.0" I get 
> "[INFO] unable to find resource 'swank-clojure:swank-clojure:​jar:1.3.1' in 
> repository central (http://repo1.maven.org/maven2​)" (or equivalent for 
> lein-oneoff)
> I'm sure it is something simple but I have no idea where to look and feel 
> like I'm stuck at the first hurdle. Anybody any idea?
> I think Leiningen is installed correctly as I can create new projects. I 
> did notice however that the project.clj file as a default refers to clojure 
> 1.2.1 as opposed to clojure 1.3.0. It is very likely that I have old 
> versions of Clojure floating around on my machine as I've played around 
> with Clojure in the past. (I'd like to get rid of the old versions but not 
> sure in which directory(/ies) they have been installed
> Please let me know if I need to provide more info.
> Thanks in advance
> Ted
>

-- 
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: into applied to transient vectors undocumented?

2012-03-22 Thread Stephen Compall
On Mar 21, 2012, at 12:47 AM, Leif  wrote:

> That raises the question "Why doesn't clojure.lang.ITransientCollection 
> extend clojure.lang.IEditableCollection, so the .asTransient method is 
> idempotent?"

'into' ought not work on transients for the same reason that assoc and conj 
don't work on transients.

Idempotence [interpreted as identity over transients] would be even worse; it 
would mean that 'into' is not a pure function.

reduce conj! is a decent replacement.

-- 
Stephen Compall
Greetings from sunny Appleton!

-- 
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: beginner - stuck in dependencies and possibly old versions

2012-03-22 Thread Phil Hagelberg
ted  writes:

> I've installed Leiningen but when I try to do "lein plugin install
> swank-clojure 1.3.1" or "lein plugin install lein-oneoff 0.2.0" I get
> "[INFO] unable to find resource
> 'swank-clojure:swank-clojure:jar:1.3.1' in repository central (http:/
> /repo1.maven.org/maven2)" (or equivalent for lein-oneoff)

This is not an error; it's telling you it can't find it in one
repository, so it downloads it from another repository instead. Are
there any actual error messages when you try to use the plugins?

> It is very likely that I have old versions of Clojure floating around
> on my machine as I've played around with Clojure in the past. (I'd
> like to get rid of the old versions but not sure in which
> directory(/ies) they have been installed

The way Leiningen works you don't have to worry about old versions
floating around other than in your ~/.lein/plugins directory; everything
else is isolated; only the dependencies you declare in project.clj will
affect the current project.

-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: Parallel SSH and system monitoring in Clojure

2012-03-22 Thread Damon Snyder
Hi Chris,
Cool. Thanks for sharing with the group. I also worked on something
similar: https://github.com/drsnyder/gantry. I was getting frustrated
with our current Frankenstein version of capistrano and wanted to
tinker with building a basic remote execution and deployment tool
using clojure.

Damon

On Mar 15, 2:12 pm, Chris McBride  wrote:
> Hi,
>
>    I releases two simple clojure libraries to help running commands
> via SSH on multiple servers. Hopefully someone will find it useful.
>
>    http://info.rjmetrics.com/blog/bid/54114/Parallel-SSH-and-system-moni...
>    https://github.com/RJMetrics/Parallel-SSH
>    https://github.com/RJMetrics/Server-Stats
>
> Best,
> Chris McBride

-- 
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: I'm writing a Tempest clone in ClojureScript

2012-03-22 Thread David Nolen
Very cool :)

On Thu, Mar 22, 2012 at 8:14 PM, Trevor Bentley  wrote:

> I'm teaching myself Clojure/ClojureScript/HTML5 via an excessively complex
> first project: a clone of the arcade game Tempest.  I thought it might be a
> handy resource to share since I've found surprisingly few ClojureScript
> examples.  More certainly couldn't hurt.
>
> https://github.com/mrmekon/tempest-cljs
>
> The game is nowhere close to done, but there's some functional drawing and
> movement code.  Collision detection is about the only thing left before it
> qualifies as a "game", albeit a terrible, unfinished one.  It isn't
> currently hosted anywhere, so you'll have to run it yourself, or make do
> with the screenshots.  I have 6 levels, one kind of enemy, and the player
> ship moves and shoots.  Level design is the most interesting part -- I
> wrote some level-generating code, so certain types of levels can be
> generated very easily.
>
> ClojureScript has been surprisingly solid and easy to work with.  I was
> considering using it for a startup I'm working with, and this project has
> done nothing to dissuade me.
>
> -Trevor
>
>  --
> 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: ClojureScript source maps

2012-03-22 Thread David Nolen
There are no existing attempts. The first step would be just to get the
compiler to emit an optional source map. Bonus points if we can merge
source maps from the ClojureScript compiler and Closure advanced
compilation.

David

On Thu, Mar 22, 2012 at 6:05 AM, Brandon Bloom  wrote:

> SourceMap support is rapidly approaching general availability in Chrome
> and Firefox:
>
> http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
>
> I'd love to see this happen and *may* be able to find time to help with
> implementation.
>
> Any intel on existing attempts at this?
>
>
> On Sunday, July 24, 2011 11:59:52 AM UTC-7, David Nolen wrote:
>>
>> On Sun, Jul 24, 2011 at 1:19 PM, John  wrote:
>>
>>> Is there any interest in having ClojureScript generate source maps?
>>>
>>> http://code.google.com/p/**closure-compiler/wiki/**SourceMaps
>>>
>>> There are a couple of ways to accomplish this.
>>>
>>
>> I'm sure there is a considerable amount of interest in this.
>>
>> David
>>
>
> On Sunday, July 24, 2011 11:59:52 AM UTC-7, David Nolen wrote:
>>
>> On Sun, Jul 24, 2011 at 1:19 PM, John  wrote:
>>
>>> Is there any interest in having ClojureScript generate source maps?
>>>
>>> http://code.google.com/p/**closure-compiler/wiki/**SourceMaps
>>>
>>> There are a couple of ways to accomplish this.
>>>
>>
>> I'm sure there is a considerable amount of interest in this.
>>
>> 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
>

-- 
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: how to get rid of "no longer a property access" warning

2012-03-22 Thread David Nolen
There is no way to suppress the warning. It's been around for long enough
in my opinion, I think we should drop it before the next release.

David

On Wed, Mar 21, 2012 at 10:31 AM, Tom Krestle  wrote:

> Hi,
>
> Executing legitimate code in CLJS REPL produces expected result with a
> warning. Is this syntax wrong? Is there a way to disable the warning?
>
> > (.getTime (js/Date.))
> WARNING: The form (. (js/Date.) getTime) is no longer a property access.
> Maybe you meant (. (js/Date.) -getTime) instead?
> 1332339898277
>
> Thanks,
> Tom
>
>  --
> 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: SuperDevMode and SourceMaps for ClojureScript debugging

2012-03-22 Thread David Nolen
A pretty good overview here:
http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/

We need to modify the compiler so it produces an optional source map during
the emit phase.

David

On Tue, Mar 20, 2012 at 9:02 PM, Brian Rowe  wrote:

> Any suggestions on how to get started on tackling that?
>
>
> On Tuesday, March 20, 2012 5:05:40 PM UTC-4, David Nolen wrote:
>>
>> On Tue, Mar 20, 2012 at 2:45 PM, Alexander Zolotko wrote:
>>
>>> Ray Cromwell ,
>>> a Google employee, has recently announced new feature in Chrome Dev Tools: 
>>> SuperDevMode
>>> and 
>>> SourceMaps.
>>>  It
>>> helps to map source code written in programming language that targets
>>> JavaScript run-time (e.g. CoffeeScript) to resulting JavaScript code. Is
>>> it feasible to utilize it to debug ClojureScript in a browser? Please share
>>> your thoughts.
>>
>>
>> Yep, looks promising and we definitely want to support it. Would love to
>> see someone tackle this project.
>>
>> 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
>

-- 
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: how to get rid of "no longer a property access" warning

2012-03-22 Thread Chris Granger
+1 This confused a lot of people in my class :(

Cheers,
Chris.


On Fri, Mar 23, 2012 at 12:55 AM, David Nolen wrote:

> There is no way to suppress the warning. It's been around for long enough
> in my opinion, I think we should drop it before the next release.
>
> David
>
> On Wed, Mar 21, 2012 at 10:31 AM, Tom Krestle wrote:
>
>> Hi,
>>
>> Executing legitimate code in CLJS REPL produces expected result with a
>> warning. Is this syntax wrong? Is there a way to disable the warning?
>>
>> > (.getTime (js/Date.))
>> WARNING: The form (. (js/Date.) getTime) is no longer a property access.
>> Maybe you meant (. (js/Date.) -getTime) instead?
>> 1332339898277
>>
>> Thanks,
>> Tom
>>
>>  --
>> 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 Dev" group.
> To post to this group, send email to clojure-...@googlegroups.com.
> To unsubscribe from this group, send email to
> clojure-dev+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/clojure-dev?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: Frustrations in being moderated

2012-03-22 Thread Sean Corfield
On Tue, Mar 20, 2012 at 10:26 PM, Evan Mezeske  wrote:
> I'm sure that some level of moderation is necessary to keep the list clean,
> but does it have to be so draconian?

Hmm, I didn't even know the list was moderated (beyond first post
moderation which I'd assume was the norm on Google Groups). Perhaps
Clojure/core can comment on what the actual moderation policy is? And
maybe they can appoint some more moderators to help ease the burden?
-- 
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


New(er) Clojure cheatsheet hot off the presses

2012-03-22 Thread Andy Fingerhut
Alex Miller not only organizes conferences that are a blast to attend (i.e. 
Clojure/West, and I'm inclined to believe Strange Loop would be cool, too), he 
also puts up new versions of the Clojure cheatsheet when I ask him nicely.  
Here it is, in the usual place:

http://clojure.org/cheatsheet

Listed below are things that have changed since the version first published in 
late February.  A couple of the changes I list for cheatsheet version 1.3 
weren't in the previously published version, simply because I wasn't very 
fastidious about keeping my version numbers straight.

As before, most of the links go to the documentation on clojuredocs.org, which 
include not only the official built-in documentation, but also user-contributed 
examples and "see alsos".  Anyone willing to create a free ClojureDocs account 
and write more examples is welcome to do so.

If anyone has suggestions for what you would like to see added to the 
cheatsheet, especially _specific_ suggestions, feel free to send me email.  I'm 
especially interested in a short sweet example of extend-protocol in the style 
of the examples already on the sheet, any good links you would recommend to 
teach people how and when to use zippers, and a good tutorial on how to parse, 
extract data from, modify, and generate XML in Clojure.

Andy

--
March 22, 2012 - Clojure 1.3.0, sheet v1.4

Added (tutorial) entries in Namespace/Create and Loading/Load Libs
sections that link to this nice article:

http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html

Added links to more details on regular expressions in the
Strings/Regex section:
http://www.regular-expressions.info
http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

Added to Strings section: java.lang.String (abbreviated String in PDF
version to fit better) .indexOf .lastIndexOf, with links to
java.lang.String doc page.

Added to Collections/Lists and Vectors sections: .indexOf and
.lastIndexOf, with links to similar methods documented for
java.util.Vector.

Changed heading Destructuring in Special Forms section to "Binding
Forms / Destructuring", for people who might know it by one name but
not the other.

Added to Maps/Create: group-by
Added to IO/from reader: read

Added Numbers/Literals section with examples of literal syntax for
BigInt, Ratio, and BigDecimal.

Removed :doc from Metadata/Common section and added :const instead.
Doc strings are more commonly handled with the normal way to put them
in def or defn forms.

--
2012 Feb 23 - Clojure 1.3.0, sheet v1.3

Added new section Destructuring, with a link to a page containing
examples on clojure.org, and a list of the most commonly-used macros
that allow destructuring to be used within them.

Added biginteger, clojure.java.io/file and copy, and link to fs
project on GitHub for file manipulation functions.

-- 
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: peridot - a library for interacting with ring apps

2012-03-22 Thread Nelson Morris
peridot is a library for interacting with ring apps.  It is designed
to work with ->, keep cookies, and handle some actions like file
uploads as multipart.  It is similar in level/style to Rack::Test.  I
imagine it could be useful for testing.

https://github.com/xeqi/peridot

-
Nelson Morris

-- 
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: Use metadata instead of :require-macros for requiring macros from ClojureScript?

2012-03-22 Thread daly
On Thu, 2012-03-22 at 22:23 -0400, Cedric Greevey wrote:
> On Wed, Mar 21, 2012 at 1:12 AM, Evan Mezeske  wrote:
> > Hi,
> >
> > I'm working on some tools for making it easier to share generic Clojure code
> > between Clojure and ClojureScript, and one problem that does not seem to
> > have a pretty solution is that of requiring macros.  Clojure uses a regular
> > (:require ...) whereas ClojureScript needs a (:require-macros ...).  I
> > understand that the distinction is necessary for ClojureScript because
> > macros are written in Clojure.
> >
> > This difference in the (ns ...) form is troublesome when trying to share
> > code between the two languages.  Right now, the only solution is to
> > copy+edit the shared file (possibly with an automated tool) so that it has
> > :require and :require-macros as appropriate.  This is not very pretty.
> >
> > So that gets me to wondering, has anyone brought up the idea of using
> > metadata to identify macro namespaces?  So instead of using :require-macros,
> > :require would be used, but each namespace identifier would be inspected to
> > see if it had ^{:macros true}.
> >
> >
> > ; The existing way to require macros from ClojureScript:
> >
> > (ns example.shared
> >   (:require-macros
> > [example.macros :as macros])
> >   (:require
> > [example.other :as other]))
> >
> >
> >
> > (ns example.shared
> >   (:require
> > ^:macros [example.macros :as macros]
> > [example.other :as other]))
> 
> That might be one way to do it. The other obvious one is to implement
> :require-macros in Clojure's ns macro, as a synonym for require, and
> make sure require(-macros) is idempotent.
> 

If you use a literate programming style it would be easy to extract
the code segments that are specific to the Clojure or ClojureScript
targets. Each code segment would be in its own chunk and could be
a separate selection. In addition, you could explain why it was
necessary to use :require in Clojure and :require-macros in
ClojureScript, making it clear to other developers.

So you would write
\begin{chunk}{Clojure code}
(ns example.shared
  (:require
 ^:macros [example.macros :as macros]
 [example.other :as other]))
\end{chunk}

\begin{chunk}{ClojureScript code}
(ns example.shared
  (:require-macros
[example.macros :as macros])
  (:require
[example.other :as other]))
\end{chunk}

In the Clojure case you extract the chunk with
   tangle mydoc "Clojure code" >file
and in the ClojureScript case you extract it with
   tangle mydoc "ClojureScript code" >file

In this way you can mingle code for both platforms
and explain why they need to be different, which would
be useful for other developers using your code.

That way you don't have to write a Clojure macro to
cover code intended for ClojureScript.

Tim Daly



-- 
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: Use metadata instead of :require-macros for requiring macros from ClojureScript?

2012-03-22 Thread Evan Mezeske
Oops, I accidentally posted this before I finished typing it.  I guess most 
of what I was trying to convey made it through.

The second ns form I posted is my suggested approach.  It requires no 
modifications to the Clojure language, and would be pretty simple to 
implement in the ClojureScript compiler.  I'd be more than happy to 
implement such support if people thought it was desirable.

-Evan

On Tuesday, March 20, 2012 10:12:43 PM UTC-7, Evan Mezeske wrote:
>
> Hi,
>
> I'm working on some tools for making it easier to share generic Clojure 
> code between Clojure and ClojureScript, and one problem that does not seem 
> to have a pretty solution is that of requiring macros.  Clojure uses a 
> regular (:require ...) whereas ClojureScript needs a (:require-macros ...). 
>  I understand that the distinction is necessary for ClojureScript because 
> macros are written in Clojure.
>
> This difference in the (ns ...) form is troublesome when trying to share 
> code between the two languages.  Right now, the only solution is to 
> copy+edit the shared file (possibly with an automated tool) so that it has 
> :require and :require-macros as appropriate.  This is not very pretty.
>
> So that gets me to wondering, has anyone brought up the idea of using 
> metadata to identify macro namespaces?  So instead of using 
> :require-macros, :require would be used, but each namespace identifier 
> would be inspected to see if it had ^{:macros true}.
>  
>
> ; The existing way to require macros from ClojureScript:
>
> (ns example.shared
>   (:require-macros
> [example.macros :as macros])
>   (:require
> [example.other :as other]))
>
>  
>
> (ns example.shared
>   (:require
> ^:macros [example.macros :as macros]
> [example.other :as other]))
>
>

-- 
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: removing a hash-map from a set using hash-map's field.

2012-03-22 Thread Philip Potter
Might it be possible to use a map instead? Maps are designed to look values
up by a key which may differ from the value, which seems to be your use
case here.

If you have

{1 {:id 1, :foo "bar"},
2 {:id 2, :foo "car"}}

You can just do

(disj my-map 2)

To convert the original set into a map, you could do something like:

(into {} (map (juxt :id identity) my-set))

Phil
On Mar 23, 2012 2:59 AM, "Leandro Oliveira"  wrote:
>
> Hi all,
>
> I have a set of hash like this:
>
> #{{:id 1, :foo "bar"} {:id 2, :foo "car"}}
>
> and I'd like to remove an item based on its id value.
>
> Unfortunately, disj requires that I pass the whole map as key to remove
it.
>
> Can I remove the map from the set only using the id?
>
> My intention is to avoid a lookup on set to get the whole map back.
>
> Any suggestions?
>
>
> Thanks in advance.
> leandro.
>
> --
> 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