Re: Rounding the edges of an Emacs beginner

2011-09-14 Thread Timothy Washington
Nice. Thanks Peter. I use the n, p and v navigations now, but always want to
do that vim / Ctrl-d thing, lol. I figure I just need to spend some time
getting used to emacs' navigation idioms. It's going to take a lot of doing
to pull me away from vim habits.

Tim


On Wed, Sep 14, 2011 at 8:50 PM, Peter Buckley wrote:

> ** In emacs you can give a number to preface many commands, e.g. C-37 C-n
> will perform "next line" 37 times, and C-37 C-p will perform "previous line"
> 37 times. You can setup keybindings for these as well, but I find the basic
> navigation commands like C-v/M-v (up/down a page) and C-l (center current
> line in the buffer) to be sufficient.
> --
> *From: * Timothy Washington 
> *Sender: * clojure@googlegroups.com
> *Date: *Wed, 14 Sep 2011 20:08:28 -0400
> *To: *
> *ReplyTo: * clojure@googlegroups.com
> *Subject: *Re: Rounding the edges of an Emacs beginner
>
> Far out - this is great stuff. Thanks guys.
>
> Wrt to moving down (or up) a block, vim-style, what I mean is the following
> (all functionality in 'Command Mode').
>
> In Vim , you press *Ctrl-d* and *Ctrl-u* to go down and up a block
> respectively. Depending on the size of your window, it moves the cursor
> about 1/3rd of the way down (or up) the screen. This is very handy to have
> when just browsing a buffer. You can be more precise by pressing 37k, to
> move the cursor up 37 lines, etc.
>
> For whatever reason, I haven't been able to find something similar in
> Emacs.
>
>
> Tim
>
>
> On Wed, Sep 14, 2011 at 3:53 AM, Stefan Kamphausen  > wrote:
>
>> Hi,
>>
>> just a few follow-ups...
>>
>> On Wednesday, September 14, 2011 4:13:47 AM UTC+2, frye wrote:
>>
>>- ? howto list modes engaged
>>
>> Aside from the already mentioned C-h m (aka M-x describe-mode) you will
>> want to use
>>
>> * C-h k (M-x describe-key) followed by some keybinding to find out what
>> that keybinding does
>> * C-h w (M-x where-is) followed by the name of some command to find out
>> what keybinding exists for that command
>> * C-h a PATTERN (M-x apropos) to search for PATTERN in command names and
>> variables (ah, I miss hyper-apropos from XEmacs)
>> * C-h v VARIABLE (M-x describe-variable) to see the documentation for a
>> variable in ELisp (use C-c C-d d on Clojure symbols to see their
>> documentation from SLIME)
>> * C-h f FUNCTION (M-x describe-function) to see docs for an Elisp-function
>> * and finally C-h ? to find out what other help is available
>>
>> The built-in help system of Emacs is one of its greatest strengths.
>>
>>>
>>>-
>>>
>>>? Can you use Emacs / Slime / CDT (debugging) with Ruby / Rails
>>>
>>> ? howto do Code completion (clojure, and elisp )
>>>
>>>
>>> Try TAB in the REPL and M-TAB in a Clojure-buffer when you are connected
>> to a running image.
>>
>>
>>> As a VIM'er, I'm trying to do the following using emacs navigation, but
>>> seem to have missed the levers to pull. I'm using a vim navigation
>>> plugin , which helps a lot.
>>>
>>>
>>>- ? set line numbers
>>>
>>>
>> I use linum.el written by  Markus Triska:
>> (when (try-require 'linum) ;; try require is just a minor wrapper which
>> checks, whether a lib is available
>>   (global-linum-mode))
>>
>>
>>>- ? go to line 'n'
>>>
>>> Since my fingers are used to M-g I bind that key to goto-line :
>> (global-set-key (kbd "M-g") #'goto-line)
>>
>>
>>>- ? how to jump to matching parentheses
>>>
>>> Meta with left and right cursor keys. Actually those are forward-sexpand
>> backward-sexp
>>
>>>
>>>- ? move down a chunk like in vim
>>>
>>> What does that mean?
>>
>>>
>>>- ? yank 'n' lines -> emacs yank puts back some 'killed' text ; HOWTO
>>>copy
>>>
>>> Mark things by first enabling the mark with C-SPC. Move around using your
>> usual command.  Copy to the kill-ring with M-w or cut the text and copy it
>> to the kill-ring using C-w.  After that you can yank (Emacsspeak for
>> 'paste') from the kill ring with C-y.  Try M-y right after a C-y to get
>> older elements on the kill-ring. For marking, try what C-M-SPC does, also
>> hit it several times in a row.
>> Warning: if your finger's memory learns this, using modern IDEs may feel
>> awkward.
>>
>> Regards,
>> Stefan
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
>  --
> 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 th

Re: confusion with map and dosync

2011-09-14 Thread Matt Hoyt
You only need the do sequence in queue-copy-fetch but not in process-indexes 
should be "You only need the dosync in queue-copy-fetch but not in 
process-indexes."
 
Matt Hoyt



From: Matt Hoyt 
To: "clojure@googlegroups.com" 
Sent: Thursday, September 15, 2011 1:01 AM
Subject: Re: confusion with map and dosync


Map is lazy so it only gets called when you need something from the sequence.  
To force it to be called you use doall so it would be (doall (map 
queue-copy-fetch fetches-seq)).

You only need the do sequence in queue-copy-fetch but not in process-indexes.
 
Matt Hoyt



From: c.taylor 
To: Clojure 
Sent: Thursday, September 15, 2011 12:39 AM
Subject: confusion with map and dosync

I'm sure this is very straightforward but can someone enlighten me why
queue copy fetch is seemingly never called from within process-indexes
(the 'pre add' line is printed but the 'adding' debug line is never
printed). I've verified the correct contents of fetches-seq.  For a
bonus point can I ask if need the dosync inside q-c-f if its only ever
called from p-i ?

Any comments on style appreciated too.

(defn- queue-copy-fetch [cfetch]
  (println "adding " cfetch)
  (dosync
    (alter copy-fetch-queue conj cfetch)))

(defn process-indexes []
  (while (seq @index-process-queue)
    (let [an-index (qpop index-process-queue)
          index-source (:source (:fetch an-index))
          index-content (:doc-seq
 an-index)
          links-seq ((:copy-link-selector index-source) index-content)
          fetches-seq (map (partial fetch index-source) links-seq)]
      (println   "pre add")
      (dosync (map queue-copy-fetch fetches-seq)



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

-- 
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: confusion with map and dosync

2011-09-14 Thread Luc Prefontaine
Map returns a lazy sequence, the list of values is not realized yet,
you need to consume the lazy seq to obtain the values.

You should use (doseq [f fetches-seq] (queue-copy-fetch f))) if you have only 
side effects to generate and do
not care about reusing the values returned by queue-copy-fetch. doseq returns 
nil.

If you need to reuse the results from the calls later, look at doall. This one 
will retain
the head as in:

(doall (map queue-copy-fetch fetches-seq))

It takes some time to get used to lazy sequences. Look carefully at the API doc 
to
spot fns that return lazy sequences. It's not because the REPL gives an output 
that you are
not dealing with a lazy sequence. The REPL will consume the lazy seq if it's 
the last result
available and walk through it to print you an output.

Luc P.

On Wed, 14 Sep 2011 22:39:42 -0700 (PDT)
"c.taylor"  wrote:

> I'm sure this is very straightforward but can someone enlighten me why
> queue copy fetch is seemingly never called from within process-indexes
> (the 'pre add' line is printed but the 'adding' debug line is never
> printed). I've verified the correct contents of fetches-seq.  For a
> bonus point can I ask if need the dosync inside q-c-f if its only ever
> called from p-i ?
> 
> Any comments on style appreciated too.
> 
> (defn- queue-copy-fetch [cfetch]
>   (println "adding " cfetch)
>   (dosync
> (alter copy-fetch-queue conj cfetch)))
> 
> (defn process-indexes []
>   (while (seq @index-process-queue)
> (let [an-index (qpop index-process-queue)
>   index-source (:source (:fetch an-index))
>   index-content (:doc-seq an-index)
>   links-seq ((:copy-link-selector index-source) index-content)
>   fetches-seq (map (partial fetch index-source) links-seq)]
>   (println   "pre add")
>   (dosync (map queue-copy-fetch fetches-seq)
> 
> 
> 



-- 
Luc P.


The rabid Muppet

-- 
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: confusion with map and dosync

2011-09-14 Thread Matt Hoyt
Map is lazy so it only gets called when you need something from the sequence.  
To force it to be called you use doall so it would be (doall (map 
queue-copy-fetch fetches-seq)).

You only need the do sequence in queue-copy-fetch but not in process-indexes.
 
Matt Hoyt



From: c.taylor 
To: Clojure 
Sent: Thursday, September 15, 2011 12:39 AM
Subject: confusion with map and dosync

I'm sure this is very straightforward but can someone enlighten me why
queue copy fetch is seemingly never called from within process-indexes
(the 'pre add' line is printed but the 'adding' debug line is never
printed). I've verified the correct contents of fetches-seq.  For a
bonus point can I ask if need the dosync inside q-c-f if its only ever
called from p-i ?

Any comments on style appreciated too.

(defn- queue-copy-fetch [cfetch]
  (println "adding " cfetch)
  (dosync
    (alter copy-fetch-queue conj cfetch)))

(defn process-indexes []
  (while (seq @index-process-queue)
    (let [an-index (qpop index-process-queue)
          index-source (:source (:fetch an-index))
          index-content (:doc-seq an-index)
          links-seq ((:copy-link-selector index-source) index-content)
          fetches-seq (map (partial fetch index-source) links-seq)]
      (println   "pre add")
      (dosync (map queue-copy-fetch fetches-seq)



-- 
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: heaps in clojure

2011-09-14 Thread Sunil S Nandihalli
Thanks Jason,
 I think some sort of priority queue may be the solution.
Thanks,
Sunil.

On Wed, Sep 14, 2011 at 12:39 AM, Jason Wolfe  wrote:

> There is java.util.PriorityQueue, which is heap-based:
>
>
> http://download.oracle.com/javase/1,5.0/docs/api/java/util/PriorityQueue.html
>
> -Jason
>
>
> On Sep 13, 4:44 am, Sunil S Nandihalli 
> wrote:
> > Hi Everybody,
> >  I have a very large, but with finite size, collection. I would like to
> get
> > like first 10 elements in the sorted list . I would use a heap if I were
> in
> > c++ .. is there a inbuilt implementation of this in clojure? .. Is there
> > some other way to achieve this? some sort of lazy sort would be perfect.
> I
> > know I need the full collection to start with .. but that is fine.
> > 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
>

-- 
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: heaps in clojure

2011-09-14 Thread Sunil S Nandihalli
Hi chouser,
 Thanks for your response. but correct me if I am wrong.. wouldn't
sorted-set completely sort the complete collection without actually taking
into account that only the first few elements are needed?
Thanks,
Sunil.

On Tue, Sep 13, 2011 at 7:15 PM, Chouser  wrote:

> On Tue, Sep 13, 2011 at 7:44 AM, Sunil S Nandihalli
>  wrote:
> > Hi Everybody,
> >  I have a very large, but with finite size, collection. I would like to
> get
> > like first 10 elements in the sorted list . I would use a heap if I were
> in
> > c++ .. is there a inbuilt implementation of this in clojure? .. Is there
> > some other way to achieve this? some sort of lazy sort would be perfect.
> I
> > know I need the full collection to start with .. but that is fine.
>
> A seq on a sorted set should be pretty efficient.
>
> (take 3 (sorted-set 8 2 1 4 6 9 7 3))
> ;=> (1 2 3)
>
> --Chouser
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

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

confusion with map and dosync

2011-09-14 Thread c.taylor
I'm sure this is very straightforward but can someone enlighten me why
queue copy fetch is seemingly never called from within process-indexes
(the 'pre add' line is printed but the 'adding' debug line is never
printed). I've verified the correct contents of fetches-seq.  For a
bonus point can I ask if need the dosync inside q-c-f if its only ever
called from p-i ?

Any comments on style appreciated too.

(defn- queue-copy-fetch [cfetch]
  (println "adding " cfetch)
  (dosync
(alter copy-fetch-queue conj cfetch)))

(defn process-indexes []
  (while (seq @index-process-queue)
(let [an-index (qpop index-process-queue)
  index-source (:source (:fetch an-index))
  index-content (:doc-seq an-index)
  links-seq ((:copy-link-selector index-source) index-content)
  fetches-seq (map (partial fetch index-source) links-seq)]
  (println   "pre add")
  (dosync (map queue-copy-fetch fetches-seq)



-- 
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: Generating Bash scripts from Clojure

2011-09-14 Thread Hugo Duncan
On Wed, 14 Sep 2011 15:34:25 -0400, Denis Labaye   
wrote:


I played with it a little bit, can't make the latest version (0.7) to  
work, only the 0.5.


The current version will require you use (with-script-language  
:pallet.stevedore.bash/bash …) to specify bash as the target language


So far it seems pretty cool. I am not sure yet how to unit test the  
"clojure bash scripts" but the repl is much more confortable than the  
raw bash shell.


The stevedore tests might provide inspiration.


And by the way the marginalia doc is awesome !


Thanks. There is also:
  http://pallet.github.com/pallet/reference/reference_script.html

(which needs updating and moving to go with the rest of the stevedore docs)

--
Hugo Duncan

--
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: Rounding the edges of an Emacs beginner

2011-09-14 Thread Peter Buckley
In emacs you can give a number to preface many commands, e.g. C-37 C-n will 
perform "next line" 37 times, and C-37 C-p will perform "previous line" 37 
times. You can setup keybindings for these as well, but I find the basic 
navigation commands like C-v/M-v (up/down a page) and C-l (center current line 
in the buffer) to be sufficient. 

-Original Message-
From: Timothy Washington 
Sender: clojure@googlegroups.com
Date: Wed, 14 Sep 2011 20:08:28 
To: 
Reply-To: clojure@googlegroups.com
Subject: Re: Rounding the edges of an Emacs beginner

Far out - this is great stuff. Thanks guys.

Wrt to moving down (or up) a block, vim-style, what I mean is the following
(all functionality in 'Command Mode').

In Vim , you press *Ctrl-d* and *Ctrl-u* to go down and up a block
respectively. Depending on the size of your window, it moves the cursor
about 1/3rd of the way down (or up) the screen. This is very handy to have
when just browsing a buffer. You can be more precise by pressing 37k, to
move the cursor up 37 lines, etc.

For whatever reason, I haven't been able to find something similar in
Emacs.


Tim


On Wed, Sep 14, 2011 at 3:53 AM, Stefan Kamphausen
wrote:

> Hi,
>
> just a few follow-ups...
>
> On Wednesday, September 14, 2011 4:13:47 AM UTC+2, frye wrote:
>
>- ? howto list modes engaged
>
> Aside from the already mentioned C-h m (aka M-x describe-mode) you will
> want to use
>
> * C-h k (M-x describe-key) followed by some keybinding to find out what
> that keybinding does
> * C-h w (M-x where-is) followed by the name of some command to find out
> what keybinding exists for that command
> * C-h a PATTERN (M-x apropos) to search for PATTERN in command names and
> variables (ah, I miss hyper-apropos from XEmacs)
> * C-h v VARIABLE (M-x describe-variable) to see the documentation for a
> variable in ELisp (use C-c C-d d on Clojure symbols to see their
> documentation from SLIME)
> * C-h f FUNCTION (M-x describe-function) to see docs for an Elisp-function
> * and finally C-h ? to find out what other help is available
>
> The built-in help system of Emacs is one of its greatest strengths.
>
>>
>>-
>>
>>? Can you use Emacs / Slime / CDT (debugging) with Ruby / Rails
>>
>> ? howto do Code completion (clojure, and elisp )
>>
>>
>> Try TAB in the REPL and M-TAB in a Clojure-buffer when you are connected
> to a running image.
>
>
>> As a VIM'er, I'm trying to do the following using emacs navigation, but
>> seem to have missed the levers to pull. I'm using a vim navigation 
>> plugin,
>> which helps a lot.
>>
>>
>>- ? set line numbers
>>
>>
> I use linum.el written by  Markus Triska:
> (when (try-require 'linum) ;; try require is just a minor wrapper which
> checks, whether a lib is available
>   (global-linum-mode))
>
>
>>- ? go to line 'n'
>>
>> Since my fingers are used to M-g I bind that key to goto-line :
> (global-set-key (kbd "M-g") #'goto-line)
>
>
>>- ? how to jump to matching parentheses
>>
>> Meta with left and right cursor keys. Actually those are forward-sexp and
> backward-sexp
>
>>
>>- ? move down a chunk like in vim
>>
>> What does that mean?
>
>>
>>- ? yank 'n' lines -> emacs yank puts back some 'killed' text ; HOWTO
>>copy
>>
>> Mark things by first enabling the mark with C-SPC. Move around using your
> usual command.  Copy to the kill-ring with M-w or cut the text and copy it
> to the kill-ring using C-w.  After that you can yank (Emacsspeak for
> 'paste') from the kill ring with C-y.  Try M-y right after a C-y to get
> older elements on the kill-ring. For marking, try what C-M-SPC does, also
> hit it several times in a row.
> Warning: if your finger's memory learns this, using modern IDEs may feel
> awkward.
>
> Regards,
> Stefan
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

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

Re: Mocking out namespaces

2011-09-14 Thread Stuart Sierra
You can't easily prevent the loading of B unless it's in a separate 
directory that isn't part of your classpath during testing.

You could define B-mock to load B and then redefine all the symbols.

-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

Re: Rounding the edges of an Emacs beginner

2011-09-14 Thread Timothy Washington
Hey Benjamin,


Thanks for the tips !! Have no fears about my passion for vim  :)


I'm actually using vimclojure now, and it has fabulous command completions
for clojure functions, which I love. I did get the nailgun server setup, and
connected. But 1) there's a lot of gymnastics involved in getting it running
(although it is quite nice, once your setup is going). The one thing that I
crave is that debugging integration. It's actually a limitation of vim, not
nailgun - either vim's lack of threads, or it's communication channel does
not allow for these kinds of symbols to go both ways (you can just send from
ng-client).


But I still used, and will continue to use vim for most tasks (I much prefer
it's navigation to emacs'). The first main carrot pulling me to try emacs
now is 'evil' , emac's newest vim
plugin. The wrinkles are fast being ironed out, and it does the basic
navigation and editing that I expect from a vim. I'm actually eager to see
how much .vimrc settings I can get into 'evil'. So the other emacs carrot
for me, is that swank / slime debugging integration. It looks quite handy,
and I'm keen on tools that can get me closer to the code, reducing my time
to develop.


Cheers

Tim


On Wed, Sep 14, 2011 at 7:44 AM, Benjamin Klüglein <
scheibenk...@googlemail.com> wrote:

>  Hi Tim,
>
> back when I started diving into Clojure I had the very same plan, teach me
> Emacs to write Clojure.
> Somewhere down the road I realized that I can have almost everything, that
> I hoped to gain by picking up Emacs, in VIM too. VimClojure and
> lein-vimclojure**, once set up, delivered everything I was looking for.
> Ok, everything but debugging!
> Which, thanks to the ability to use tracing right inside a vim repl, I
> don't miss that much as I missed my buddies . and * back then... :-)
>
> I definitely don't want to discourage you from looking into Emacs, which
> without a question is a great text editor, I just wanted to note that there
> are working setups for VIM too. :-)
>
> Regards,
> Ben
>
> Am 14.09.2011 04:13, schrieb Timothy Washington:
>
> Hey all,
>
>
>  So I'm still an avid vim user. But I see a lot of power in the swank
> slime setup, and have been teaching myself emacs to try to leverage it.
> There are still a few tricks I haven't got. Maybe my notes are just
> disorganised, but I was hoping fellow Clojurians can chime in.
>
>
>
>- ? getting an error when I i) "M-x slime-connect" or ii) send a form
>(+1 1) to swank ; this is after i) a "lein swank" then ii) in another 
> window
>"emacs" M-x connect . ** Evaluating Slime forms seems to work after that
>
>
>  webkell@ubuntu:~/Projects/bkell$ lein swank
>
> Listening for transport dt_socket at address: 36109
>
> Connection opened on localhost port 4005.
>
> exception in read loop
>
> java.lang.Exception: Error reading swank message *# this happens when
> slime tries to connect with M-x slime-connect *
>
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>
> ...
>
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>
> ...
>
> at clojure.lang.Var.applyTo(Var.java:518)
>
> at clojure.main.main(main.java:37)
>
> exception in control loop
>
> java.lang.InterruptedException
>
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:1961)
>
> ...
>
> at swank.util.concurrent.mbox$receive.invoke(mbox.clj:28)
>
> at swank.core$control_loop.invoke(core.clj:401)
>
> ...
>
> at swank.swank$connection_serve$fn__1720.doInvoke(swank.clj:20)
>
> ...
>
> at java.lang.Thread.run(Thread.java:619)
>
>
>
>
>- ? howto do Code completion (clojure, and elisp )
>- ? close a slime-repl connection
>- ? howto list modes engaged
>- ? Also need to increase my skills navigating the debugger. Is this still
>the reference  to use
>-
>
>? Can you use Emacs / Slime / CDT (debugging) with Ruby / Rails
>
>
>  As a VIM'er, I'm trying to do the following using emacs navigation, but
> seem to have missed the levers to pull. I'm using a vim navigation 
> plugin,
> which helps a lot.
>
>- ? set line numbers
>- ? go to line 'n'
>- ? how to jump to matching parentheses
>- ? move down a chunk like in vim
>- ? yank 'n' lines -> emacs yank puts back some 'killed' text ; HOWTO
>copy
>
>
>  Thanks
> Tim
>
>
>  --
> 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

Re: Rounding the edges of an Emacs beginner

2011-09-14 Thread Timothy Washington
Far out - this is great stuff. Thanks guys.

Wrt to moving down (or up) a block, vim-style, what I mean is the following
(all functionality in 'Command Mode').

In Vim , you press *Ctrl-d* and *Ctrl-u* to go down and up a block
respectively. Depending on the size of your window, it moves the cursor
about 1/3rd of the way down (or up) the screen. This is very handy to have
when just browsing a buffer. You can be more precise by pressing 37k, to
move the cursor up 37 lines, etc.

For whatever reason, I haven't been able to find something similar in
Emacs.


Tim


On Wed, Sep 14, 2011 at 3:53 AM, Stefan Kamphausen
wrote:

> Hi,
>
> just a few follow-ups...
>
> On Wednesday, September 14, 2011 4:13:47 AM UTC+2, frye wrote:
>
>- ? howto list modes engaged
>
> Aside from the already mentioned C-h m (aka M-x describe-mode) you will
> want to use
>
> * C-h k (M-x describe-key) followed by some keybinding to find out what
> that keybinding does
> * C-h w (M-x where-is) followed by the name of some command to find out
> what keybinding exists for that command
> * C-h a PATTERN (M-x apropos) to search for PATTERN in command names and
> variables (ah, I miss hyper-apropos from XEmacs)
> * C-h v VARIABLE (M-x describe-variable) to see the documentation for a
> variable in ELisp (use C-c C-d d on Clojure symbols to see their
> documentation from SLIME)
> * C-h f FUNCTION (M-x describe-function) to see docs for an Elisp-function
> * and finally C-h ? to find out what other help is available
>
> The built-in help system of Emacs is one of its greatest strengths.
>
>>
>>-
>>
>>? Can you use Emacs / Slime / CDT (debugging) with Ruby / Rails
>>
>> ? howto do Code completion (clojure, and elisp )
>>
>>
>> Try TAB in the REPL and M-TAB in a Clojure-buffer when you are connected
> to a running image.
>
>
>> As a VIM'er, I'm trying to do the following using emacs navigation, but
>> seem to have missed the levers to pull. I'm using a vim navigation 
>> plugin,
>> which helps a lot.
>>
>>
>>- ? set line numbers
>>
>>
> I use linum.el written by  Markus Triska:
> (when (try-require 'linum) ;; try require is just a minor wrapper which
> checks, whether a lib is available
>   (global-linum-mode))
>
>
>>- ? go to line 'n'
>>
>> Since my fingers are used to M-g I bind that key to goto-line :
> (global-set-key (kbd "M-g") #'goto-line)
>
>
>>- ? how to jump to matching parentheses
>>
>> Meta with left and right cursor keys. Actually those are forward-sexp and
> backward-sexp
>
>>
>>- ? move down a chunk like in vim
>>
>> What does that mean?
>
>>
>>- ? yank 'n' lines -> emacs yank puts back some 'killed' text ; HOWTO
>>copy
>>
>> Mark things by first enabling the mark with C-SPC. Move around using your
> usual command.  Copy to the kill-ring with M-w or cut the text and copy it
> to the kill-ring using C-w.  After that you can yank (Emacsspeak for
> 'paste') from the kill ring with C-y.  Try M-y right after a C-y to get
> older elements on the kill-ring. For marking, try what C-M-SPC does, also
> hit it several times in a row.
> Warning: if your finger's memory learns this, using modern IDEs may feel
> awkward.
>
> Regards,
> Stefan
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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] Clojure 1.3 RC0

2011-09-14 Thread Sean Corfield
On Wed, Sep 14, 2011 at 9:43 AM, Aaron Bedra  wrote:
> And the supporting ticket in JIRA
>
> http://dev.clojure.org/jira/browse/CLJ-31

Nice. Now I understand better why this was disabled.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: Neighbors function from The Joy of Clojure

2011-09-14 Thread Chouser
On Wed, Sep 14, 2011 at 3:35 PM, Fogus  wrote:
>> diagonals as neighbors.  We don't think we take advantage of the
>> flexibility anywhere in the book, so perhaps your version would indeed
>> be better.

I meant to say "I" didn't think.  Sorry, didn't mean to put words in
your mouth, Fogus.

> It was used again only briefly in section 11.2 to define the legal
> moves that a king can make in chess, which of course includes
> diagonals.  :-)

Ah, indeed.  Sorry to mislead.

--Chouser

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


Re: Neighbors function from The Joy of Clojure

2011-09-14 Thread Leonardo Borges
It certainly helped :)

I played around with it last night after chouser's response and it all made 
sense, thanks!

Cheers,

Leonardo Borges
www.leonardoborges.com

On 15/09/2011, at 1:39 AM, Sean Corfield  wrote:

> On Wed, Sep 14, 2011 at 5:58 AM, Leonardo Borges
>  wrote:
>> (defn neighbors
>>   ([size yx] (neighbors [[-1 0] [1 0] [0 -1] [0 1]] size yx))
>>   ([deltas size yx]
>> (filter (fn [new-yx]
>>   (every? #(< -1 % size) new-yx))
>>  (map #(map + yx %) deltas
>> 
>> This syntax made me scratch my head since I believe it was the first
>> time I saw it.
> 
> In case it wasn't clear from Chouser's response, the key difference is
> that this declares two versions of neighbors, one that takes three
> arguments and one that takes four - essentially overloading on arity.
> Here's an example from some of our code at World Singles:
> 
> (defn save-row
>  "Given a table name (string), a record and an optional
>   key-gen function, either insert it after applying the
>   key-gen function (if no pk) or update it. In both
>   cases, return the pk. The default key-gen function
>   is a no-op (identity).
>   When operating on a MongoDB collection, the logic is
>   much simpler because the pk is always :_id and key
>   generation is always handled by MongoDB. Also, we
>   always return the entire updated record (since we
>   can run functions against the database)."
>  ([table record](save-row table record identity :id 0))
>  ([table record key-gen](save-row table record key-gen :id 0))
>  ([table record key-gen pk] (save-row table record key-gen pk 0))
>  ([table record key-gen pk retry]
>...))
> 
> Mostly we call this as (save-row :table-name {:some "record"}) but we
> can also supply a key generation function (save-row :table-name {:some
> "record"} add-uuid), for tables that don't have a generated PK column,
> and we can specify the PK name if it isn't :id (save-row :table-row
> {:some "record"} identity :email).
> 
> Ignore retry - we need to refactor that into a private helper function
> :) It's part of the machinery that let's automatically retry
> operations on MongoDB if the replica set has no active primary node
> since it can take a while to failover...
> 
> Hope that helps?
> -- 
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
> Railo Technologies, Inc. -- http://www.getrailo.com/
> 
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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] CfP for ACCU Conference April 24-28, 2012. Barcelo Oxford Hotel, Oxford, UK

2011-09-14 Thread Giovanni Asproni

Hi all,

I'm sending this on behalf of Jon Jagger, the Conference Chair. It is a great 
conference.


ACCU is a non-profit organisation run by software enthusiasts for
software enthusiasts.

ACCU warmly invites you to propose a session for this leading software
development conference.

Call for Proposals - ACCU 2012
April 24-28, 2012. Barcelo Oxford Hotel, Oxford, UK
Submission website:https://www.conftool.pro/accu2012/
Submission deadline: 16th of October 2011
twitter: @accu2012 #accu2012

More details can be found here
http://accu.org/index.php/conferences/accu_conference_2012/accu2012_Call_for_Papers

The conference has always benefited from the strength of its
programme. Please help us make 2012 another successful event.

Jon Jagger
Conference Chair

--
Asprotunity Limited
http://asprotunity.com
Twitter: @gasproni
Mobile: +44 (0) 791 746 0453

--
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: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread Chouser
On Wed, Sep 14, 2011 at 3:58 PM, octopusgrabbus
 wrote:
> Alan:
>
> I may have misunderstood what I've read both in books, blogs, and the
> Clojure site, but it seems that writing recursive functions in the loop ..
> recur style is the preferred style. I also remember most of the texts
> currently out on Clojure say use the higher level sequence functions rather
> than recursion. I get it.
>
> I wanted to do this particular exercise without the aid of Clojure.zip.

I would highly recommend using zip for such things, because otherwise
you have to write code like this:

(defn skl [tree]
  (loop [[self & todo :as src] [tree], dst [()]]
(cond
  (empty? src)   dst
  (not (coll? self)) (recur todo (first dst))
  (empty? self)  (recur todo (conj (first dst) (rest dst)))
  :else  (recur (list* (first self) (rest self) todo) [dst]

Jonathan Claggett helped write that.  I'm not sure there was ever a
moment where we both understood it simultaneously.

It essentially does what zippers do, but holds the data in a
loop/recur frame rather than a data structure.  Any further
explanation is left as an exercise to the reader.

--Chouser

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


Re: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread Laurent PETIT
Hi,

2011/9/14 Alan Malloy 

> You can prefer anything you want, but (a) to say that Clojure prefers
> loop/recur is nonsense, and (b) you can't make an incorrect algorithm
> work just by preferring it. Jeff is correct that your algorithm
> requires space for each level of the tree, and so cannot be converted
> into a constant-space algorithm. You can convert it into loop/recur by
> using up a bunch of heap instead of a bunch of stack, but there's
> rarely much point to doing that.
>

Well, not quite, since with the JVM it's faster to consume the stack and get
a StackOverflowException, than it is to get an OutOfMemoryException, no ?

It's certainly possible to convert this algorithm without consuming stack
proportionnally to the depth of the tree. But as you said, in the end this
would probably reimplement something along the lines of clojure.zip. Maybe
more specialized, maybe faster ...


>
> On Sep 14, 9:38 am, octopusgrabbus  wrote:
> > Jeff:
> >
> > loop .. recur syntax is Clojure's preferred method of recursion.
> >
> > This is a routine to return the skeleton of a sequence, not its values.
> >
> > cmn
>
> --
> 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: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread Laurent PETIT
2011/9/14 Meikel Brandmeyer 

> Hi,
>
> Am 14.09.2011 um 16:54 schrieb octopusgrabbus:
>
> > (defn skl
> >   [tree]
> >   (map skl (filter seq? tree)))
> >
>
> Is that what you want?
>
> (defn skl
>  [tree]
>  (loop [output []
> tree   (seq tree)]
>(if tree
>  (let [fst (first tree)]
>(if (seq? fst)
>  (recur (conj output (skl fst)) (next tree))
>  (recur output (next tree
>  output)))
>
>
Hi Meikel,

I haven't paid enough attention to be sure not to say nonsense, but by
seeing in your code a recursive call to skl makes me think the code still
can blow up the stack ?

Sincerely,

-- Laurent


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

-- 
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: Mocking out namespaces

2011-09-14 Thread Jonathan Fischer Friberg
You could call the mock file B_mock.clj
then

(require '[B-mock :as B])

Jonathan

On Wed, Sep 14, 2011 at 5:19 PM, Brian Hurt  wrote:

> Say I have two name spaces, A and B, with A depending on B.  I want to test
> namespace A, replacing module B with a mock B for testing purposes-
> preferably without having to load B at all (B sucks in a bunch of stuff,
> like dependencies on databases and external web sites and etc. that I don't
> want to deal with in testing).  What is the easy, clojure-approved,
> mechanism for doing this?  I tried:
>
> (ns B)
>
> ; mock defns
>
> (ns user)
>
> (require 'A)
>
> but this still load the "real" B, and A still calls the "real" B, and not
> the mock B.
>
> Thanks.
>
> Brian
>
>  --
> 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: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread octopusgrabbus
Alan: 

I may have misunderstood what I've read both in books, blogs, and the 
Clojure site, but it seems that writing recursive functions in the loop .. 
recur style is the preferred style. I also remember most of the texts 
currently out on Clojure say use the higher level sequence functions rather 
than recursion. I get it. 

I wanted to do this particular exercise without the aid of Clojure.zip.

-- 
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: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread octopusgrabbus
Thanks. I'll have a look.

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

2011-09-14 Thread Tom Hickey
Hi all,

With sign-off from Rich, I have pushed my defrecord work onto master.

Please try it out and let me know if you experience any issues.

Cheers,
Tom Hickey

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


Re: Thoughts on CUDA + Clojure

2011-09-14 Thread Gary

The Aparapi project was open sourced today take a look at
http://aparapi.googlecode.com.  Although previous comments had listed
concerns with Aparapi code restrictions, it would be great to work
with developers of languages like Clojure to see what features of
Aparapi might be useful.

Gary


On Sep 9, 12:24 pm, Timothy Baldridge  wrote:
> > If it is not,
> > then looking at Aparapi might be the better choice, and the AMD
> > developers have openly stated that they would like to work with
> > someone from the Clojure community on getting their openCL api working
> > with Clojure.
>
> Sadly, Aparapi is very, very limited. Here is an example:
>
> http://developer.amd.com/zones/java/assets/README.html
>
> Sadly, Clojure code will probably never meet all those requirements.
> It may be possible to carefully craft code so that it will follow the
> requirements listed, but at that point you might as well just use a
> s-expression to opencl translator.
>
> Timothy

-- 
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: Neighbors function from The Joy of Clojure

2011-09-14 Thread Fogus
> diagonals as neighbors.  We don't think we take advantage of the
> flexibility anywhere in the book, so perhaps your version would indeed
> be better.

It was used again only briefly in section 11.2 to define the legal
moves that a king can make in chess, which of course includes
diagonals.  :-)

-- 
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: Generating Bash scripts from Clojure

2011-09-14 Thread Denis Labaye
Hi,

Thanks, I didn't knew this lib.

I played with it a little bit, can't make the latest version (0.7) to work,
only the 0.5.

So far it seems pretty cool. I am not sure yet how to unit test the "clojure
bash scripts" but the repl is much more confortable than the raw bash shell.

And by the way the marginalia doc is awesome !

Denis

On Tue, Sep 13, 2011 at 7:14 AM, Ambrose Bonnaire-Sergeant <
abonnaireserge...@gmail.com> wrote:

> Hi,
>
> Check out Stevedore: https://github.com/pallet/stevedore
>
> Example:
> http://hugoduncan.org/post/2010/shell_scripting_in_clojure_with_pallet.xhtml
>
> User group: http://groups.google.com/group/pallet-clj
>
> Thanks,
> Ambrose
>
> On Tue, Sep 13, 2011 at 1:09 PM, Denis Labaye wrote:
>
>> Hi,
>>
>> I have to write a bunch of Bash scripts, and not a lot of time :)
>> The final script would perform a full install, provisionning, sanity
>> checks, ... in one command.
>>
>> I wonder if I could generate them using Clojure.
>>
>> Of course the output script(s) won't have the Clojure runtime.
>>
>> Any advices / thoughts?
>>
>> Thanks,
>>
>> Denis
>>
>> --
>> 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

-- 
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: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread Alan Malloy
You can prefer anything you want, but (a) to say that Clojure prefers
loop/recur is nonsense, and (b) you can't make an incorrect algorithm
work just by preferring it. Jeff is correct that your algorithm
requires space for each level of the tree, and so cannot be converted
into a constant-space algorithm. You can convert it into loop/recur by
using up a bunch of heap instead of a bunch of stack, but there's
rarely much point to doing that.

On Sep 14, 9:38 am, octopusgrabbus  wrote:
> Jeff:
>
> loop .. recur syntax is Clojure's preferred method of recursion.
>
> This is a routine to return the skeleton of a sequence, not its values.
>
> cmn

-- 
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: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread Meikel Brandmeyer
Hi,

Am 14.09.2011 um 16:54 schrieb octopusgrabbus:

> (defn skl
>   [tree]
>   (map skl (filter seq? tree)))
> 

Is that what you want?

(defn skl
  [tree]
  (loop [output []
 tree   (seq tree)]
(if tree
  (let [fst (first tree)]
(if (seq? fst)
  (recur (conj output (skl fst)) (next tree))
  (recur output (next tree
  output)))

Sincerely
Meikel

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


Re: ^long vs (long arg)

2011-09-14 Thread Mark Rathwell
On Wed, Sep 14, 2011 at 2:21 PM, Mark Rathwell  wrote:
> The distinction is that you type hint function parameters to tell the
> compiler that this function parameter will always be of the specified
> type.  You coerce something that may or may not be of a desired type,
> but is known to cleanly convert to that type.
>
> So:
>
> (defn add-two [^long x]
>  (+ x 2))
> ;=> #'user/add-two
>
> (add-two (long 1.2))
> ;=> 3
>

Should have noted that obviously calling 'add-two' with 1.2 would
coerce to long, but the point is about what the code is saying (if it
could talk).


> On Wed, Sep 14, 2011 at 2:03 PM, Sergey Didenko
>  wrote:
>> What is the intended difference between type hinting like "^long" and
>> type coercing like "(long arg)"?
>>
>> For example my gut feeling for this case is to use ^long but it is forbidden:
>>
>> (loop [^long x 0]
>> ...)
>>
>> "Can't type hint a local with a primitive initializer"
>>
>> So I use
>>
>> (loop [x (long 0)]
>> ...)
>>
>> But not quite sure if it's right.
>>
>> --
>> 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: ^long vs (long arg)

2011-09-14 Thread Mark Rathwell
The distinction is that you type hint function parameters to tell the
compiler that this function parameter will always be of the specified
type.  You coerce something that may or may not be of a desired type,
but is known to cleanly convert to that type.

So:

(defn add-two [^long x]
  (+ x 2))
;=> #'user/add-two

(add-two (long 1.2))
;=> 3


On Wed, Sep 14, 2011 at 2:03 PM, Sergey Didenko
 wrote:
> What is the intended difference between type hinting like "^long" and
> type coercing like "(long arg)"?
>
> For example my gut feeling for this case is to use ^long but it is forbidden:
>
> (loop [^long x 0]
> ...)
>
> "Can't type hint a local with a primitive initializer"
>
> So I use
>
> (loop [x (long 0)]
> ...)
>
> But not quite sure if it's right.
>
> --
> 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: ^long vs (long arg)

2011-09-14 Thread Sergey Didenko
I mean in Clojure 1.3 .

-- 
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] Clojure 1.3 RC0

2011-09-14 Thread Paul Stadig
Yeah it makes sense and is vaguely familiar now. I should have read the 
changelog. In our case we have a with-channel macro that expands into a try 
that I think could be moved up to a higher level and not be recuring across 
a try.


Thanks,
Paul

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

^long vs (long arg)

2011-09-14 Thread Sergey Didenko
What is the intended difference between type hinting like "^long" and
type coercing like "(long arg)"?

For example my gut feeling for this case is to use ^long but it is forbidden:

(loop [^long x 0]
...)

"Can't type hint a local with a primitive initializer"

So I use

(loop [x (long 0)]
...)

But not quite sure if it's right.

-- 
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] Clojure 1.3 RC0

2011-09-14 Thread Aaron Bedra
And the supporting ticket in JIRA

http://dev.clojure.org/jira/browse/CLJ-31

On 09/14/2011 12:05 PM, Sean Corfield wrote:
> On Wed, Sep 14, 2011 at 8:45 AM, Paul Stadig  wrote:
>> This compiles fine in 1.2.1, but fails in 1.3.0-RC0
> Intentional removal:
>
> https://github.com/clojure/clojure/blob/master/changes.txt
>
> "1.3 Disallow recur across try"

-- 
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: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread octopusgrabbus
Jeff:

loop .. recur syntax is Clojure's preferred method of recursion.

This is a routine to return the skeleton of a sequence, not its values.

cmn

-- 
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: why expressions in macro are not evaluated?

2011-09-14 Thread Michael Gardner
On Sep 13, 2011, at 2:39 AM, jingguo wrote:

> I get a_message printed twice if I paste the code in a clojure REPL.
> But I save the code into a file called foo.clj and use "clj foo.clj"
> to run it. I get nothing in stdout. It seems that (printf "a_message
> \n")
> is not evaluated. Can anybody explain this behavior? Thanks.

`for' yields a lazy sequence, whose elements are not actually evaluated until 
they are used. The REPL automatically prints the result of each expression you 
evaluate, which is the only thing that's causing those printfs to get 
evaluated. Try using `doseq' instead.

-- 
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: Problem with insert-values (clojure.contrib.sql)

2011-09-14 Thread Sean Corfield
On Wed, Sep 14, 2011 at 12:51 AM, finbeu  wrote:
> Yes, if I understand it correctly, instead of db, I just use the pooled-db
> It would be good to have an example that connects the pooled db stuff with
> the normal db stuff.

Ah, that would make it clearer..

> (defn db-update-or-insert
>   "Updates or inserts a fruit"
>   [record]
>   (sql/with-connection pooled-db

It would be (sql/with-connection @pooled-db .. or (sql/with-connection
(db-connection) ..

I like the function wrapper because it's easy to forget the deref (@).
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: [ANN] Clojure 1.3 RC0

2011-09-14 Thread Sean Corfield
On Wed, Sep 14, 2011 at 8:45 AM, Paul Stadig  wrote:
> This compiles fine in 1.2.1, but fails in 1.3.0-RC0

Intentional removal:

https://github.com/clojure/clojure/blob/master/changes.txt

"1.3 Disallow recur across try"
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread Jeff Palmucci
In general, you can't convert recursion into loops. Recursion has
stack frames, loops don't.

I can't really tell what you are trying to do here because your
example just walks the interior nodes of the expression tree, doing
nothing. Can you clarify with a more complete example?

-- 
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] Clojure 1.3 RC0

2011-09-14 Thread Paul Stadig
For unsupported behavior it seemed to work pretty well in our code :), but 
perhaps it was just a timebomb. In our case it was several layers of macros 
obscuring the recur across try.

I guess we'll have to figure out how to rewrite around it, when we get 
around to picking up 1.3.


Paul

-- 
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] Clojure 1.3 RC0

2011-09-14 Thread David Nolen
It was unsupported behavior in 1.2.1. Now you get error sooner.

David

On Wed, Sep 14, 2011 at 11:45 AM, Paul Stadig  wrote:

> This compiles fine in 1.2.1, but fails in 1.3.0-RC0
>
> (defn foo [[bar & baz]]
>   (try
> (if (seq baz)
>   (if (= bar 99)
> (throw (Exception. "FAIL"))
> (recur baz))
>   bar)
> (catch Exception e
>   :fail)))
>
> You get a compiler error: java.lang.UnsupportedOperationException: Cannot
> recur across try
>
> I assume there is a reason for this? Or should it be considered a bug?
>
>
> Paul
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

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

Re: [ANN] Clojure 1.3 RC0

2011-09-14 Thread Paul Stadig
This compiles fine in 1.2.1, but fails in 1.3.0-RC0

(defn foo [[bar & baz]]
  (try
(if (seq baz)
  (if (= bar 99)
(throw (Exception. "FAIL"))
(recur baz))
  bar)
(catch Exception e
  :fail)))

You get a compiler error: java.lang.UnsupportedOperationException: Cannot 
recur across try

I assume there is a reason for this? Or should it be considered a bug?


Paul

-- 
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: Neighbors function from The Joy of Clojure

2011-09-14 Thread Sean Corfield
On Wed, Sep 14, 2011 at 5:58 AM, Leonardo Borges
 wrote:
> (defn neighbors
>   ([size yx] (neighbors [[-1 0] [1 0] [0 -1] [0 1]] size yx))
>   ([deltas size yx]
>     (filter (fn [new-yx]
>               (every? #(< -1 % size) new-yx))
>      (map #(map + yx %) deltas
>
> This syntax made me scratch my head since I believe it was the first
> time I saw it.

In case it wasn't clear from Chouser's response, the key difference is
that this declares two versions of neighbors, one that takes three
arguments and one that takes four - essentially overloading on arity.
Here's an example from some of our code at World Singles:

(defn save-row
  "Given a table name (string), a record and an optional
   key-gen function, either insert it after applying the
   key-gen function (if no pk) or update it. In both
   cases, return the pk. The default key-gen function
   is a no-op (identity).
   When operating on a MongoDB collection, the logic is
   much simpler because the pk is always :_id and key
   generation is always handled by MongoDB. Also, we
   always return the entire updated record (since we
   can run functions against the database)."
  ([table record](save-row table record identity :id 0))
  ([table record key-gen](save-row table record key-gen :id 0))
  ([table record key-gen pk] (save-row table record key-gen pk 0))
  ([table record key-gen pk retry]
...))

Mostly we call this as (save-row :table-name {:some "record"}) but we
can also supply a key generation function (save-row :table-name {:some
"record"} add-uuid), for tables that don't have a generated PK column,
and we can specify the PK name if it isn't :id (save-row :table-row
{:some "record"} identity :email).

Ignore retry - we need to refactor that into a private helper function
:) It's part of the machinery that let's automatically retry
operations on MongoDB if the replica set has no active primary node
since it can take a while to failover...

Hope that helps?
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: Neighbors function from The Joy of Clojure

2011-09-14 Thread Leonardo Borges
Ah, got ya. Did not think of that :)

Thanks for the insight!

Cheers,
Leonardo Borges
www.leonardoborges.com



On Wed, Sep 14, 2011 at 11:29 PM, Chouser  wrote:
> On Wed, Sep 14, 2011 at 8:58 AM, Leonardo Borges
>  wrote:
>> Hi Guys,
>> I'm pretty new to clojure and to the list as well - this being my 1st
>> message - so hello everyone :)
>> I'm going through the book The Joy of Clojure which, pardon the pun,
>> I'm enJOYing a lot and stumbled upon this function to find neighbors
>> of a location in a 2D matrix:
>
> Glad you like the book [careful avoidance of pun intended]!
>
>> (defn neighbors
>>   ([size yx] (neighbors [[-1 0] [1 0] [0 -1] [0 1]] size yx))
>>   ([deltas size yx]
>>     (filter (fn [new-yx]
>>               (every? #(< -1 % size) new-yx))
>>      (map #(map + yx %) deltas
>>
>> This syntax made me scratch my head since I believe it was the first
>> time I saw it. However, upon closer analysis it seems it could be
>> rewritten like this, yielding the same result:
>>
>> (defn neighbors-1 [size yx]
>>   (let [deltas [[-1 0] [1 0] [0 -1] [0 1]]]
>>     (filter (fn [new-yx]
>>               (every? #(< -1 % size) new-yx))
>>       (map #(map + yx %) deltas
>>
>> The second version feels a lot easier on my eyes. Am I missing
>> something or they are really equivalent? And if so, why is the first
>> syntax supported or better yet, when is it best to use it?
>
> The main difference is that the first version allows you to pass in
> your own deltas.  This could be useful if you wanted to include
> diagonals as neighbors.  We don't think we take advantage of the
> flexibility anywhere in the book, so perhaps your version would indeed
> be better.
>
> --Chouser
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Mocking out namespaces

2011-09-14 Thread Brian Hurt
Say I have two name spaces, A and B, with A depending on B.  I want to test
namespace A, replacing module B with a mock B for testing purposes-
preferably without having to load B at all (B sucks in a bunch of stuff,
like dependencies on databases and external web sites and etc. that I don't
want to deal with in testing).  What is the easy, clojure-approved,
mechanism for doing this?  I tried:

(ns B)

; mock defns

(ns user)

(require 'A)

but this still load the "real" B, and A still calls the "real" B, and not
the mock B.

Thanks.

Brian

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

How to convert general recursion to loop .. recur syntax

2011-09-14 Thread octopusgrabbus
I need help -- ideas, other places or examples to look at, etc -- in 
converting this function

(defn skl
  [tree]
  (map skl (filter seq? tree)))

to loop .. recur syntax. 

I've been testing it with 

(def test_data1 '(1 (2 3) ( ) (( )) :a))
(def test_data2 '(1 2 (3 4) (5 ( 6 7 8

I'm trying to do this without the clojure.zip library.
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

Re: Reuse of generic Clojure/ClojureScript code?

2011-09-14 Thread David Nolen
As far as I know, coming up with a solution for this under consideration.

David

On Wed, Sep 14, 2011 at 8:59 AM, Dave Sann  wrote:

> Hi,
>
> I have been using clojure for personal projects for a while now. I am
> starting to work with clojurescript.
>
> I have a number of utilities and libraries that I use in clojure. I can
> port much of these wholesale to clojurescript if I copy functions to cljs
> files.
>
> Generally, my feeling is that I would like to be able to separate "generic
> clojure" from "jvm clojure" from "js clojure". Where "generic clojure"
> relies only on common capabilities of clojure or clojurescript. "jvm
> clojure" uses specific jvm/java libs and "js clojure" uses specifically js
> libs or capabilities.
>
> As I understand it, even if I do this, I cannot use
> clojurescript-compatible clj files in a clojurescript build. (i.e compile
> the clj file as cljs).
>
> Presumably, I could link or rename the files, but I think that in the long
> run this would be a maintenance challenge. Likewise for copying - if the
> code is meant to be the same.
>
> Does anyone have opinions about how to maximise reuse of existing generic
> clojure code as cljs code in this manner? ( I know you can require-macros -
> but this does not work for : defn - for example - unless I am mistaken)
>
> Do people feel that this sort of separation would be useful or of marginal
> benefit?
>
> As a corollary (if separation and reuse were possible):
>  - it would be quite useful to he able to define a library as being
> intended to be generic. The compiler would raise an error if a non-generic
> capability was employed somewhere in the library dependencies (i.e some
> inter-op or platform specific lib)
>
>  - and to be able to require/use a "jvm" or "js" specific implementation of
> a library (implementing the same api/functions) depending on the compilation
> context...
>
> It may be that some of this is possible with macros etc...my depth of
> knowledge is limited.
>
> I am interested to hear opinions...
>
>
> Cheers
>
> Dave
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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: "case" on primitives warning in 1.3-RC0

2011-09-14 Thread Sergey Didenko
Indeed. Then clojure.core/rand-int should be improved I guess.

> The default case in `case' (what a sentence) is not paired like in
> `cond'.  You want something like:

-- 
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: dropped into clojure and lein! compojure file for project.clj?

2011-09-14 Thread Shouxun Yang
According to http://clojars.org/compojure , the current line for
project.clj is just:
[compojure "0.6.5"]

On Tue, Sep 13, 2011 at 10:41 PM, deltag  wrote:
> I have been dropped into a clojure project which was abandoned some time ago
> and now reactivated..So, I am picking up clojure and lein simultaneously.
> In every project.clj file, this compojure reference cannot be resolved.  Is
> there another reference that is more recent?
>
> [org.clojars.stuarthalloway/compojure "0.3.3-SNAPSHOT"]
>
> many thanks for any help.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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: Binding *out*

2011-09-14 Thread Stuart Sierra
Hi Nick,

*out* and *err* are already dynamic, which is what allows `binding` to work. 
You can the  root binding of any Var (even non-dynamic Vars) with `def` or 
`alter-var-root`.

-Stuart Sierra

-- 
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: Binding *out*

2011-09-14 Thread Dave Ray
Hey,

I don't have a comment on how *out* and *err* are implemented, but
here's a solution for your particular problem. Runtime/exec returns a
java.lang.Process [1] object which has getInputStream and
getOutputStream methods corresponding to System/out and System/err of
the spawned process respectively. So, grab those and fire off a couple
of futures to copy the streams to files. A very rough sketch:

(let [in (.getInputStream proc)]
  (future
 (clojure.java.io/copy in (clojure.java.io/output-stream
"output-file.txt"

repeat for getErrorStream.

In fact, when you're starting processes with exec you *always* want to
do something like this even if you're throwing away the output.
Otherwise the stdout buffer for the spawned process will eventually
fill up and it will block leaving you wondering why it randomly
stopped working.

HTH,

Dave

[1] http://download.oracle.com/javase/6/docs/api/java/lang/Process.html

On Wed, Sep 14, 2011 at 9:15 AM, Nick Mudge  wrote:
> I have a clojure program with which I would like all stdout and stderr
> to be written to a file.
>
> Of course there is Unix IO redirection but I am starting my program
> from within another clojure program using "(.exec (Runtime/getRuntime)
> clj-program-command env)" and that doesn't support IO redirection. Of
> course I could use the "bash -c" command within the command to start
> my program but it does make things a bit messier with all the quotes
> and escaping of quotes, and anyway I would like to achieve this
> objective within my clojure program.
>
> I found out that System/out and System/err are separate and different
> than *out* and *err*. Changing *out* or *err* does not change System/
> out or System/err. My program includes the Jetty server which is
> written in Java so it writes to System/out and System/err and not to
> *out* and *err*. So to change all stdout and stderr to write to a file
> I need to change System/out, System/err and *out* and *err*.
>
> I can do this like so in my core.clj file:
>
> (System/setOut (PrintStream. (FileOutputStream. "/home/user/myproject/
> log.txt" true) true))
> (System/setErr (PrintStream. (FileOutputStream. "/home/user/myproject/
> log.txt" true) true))
>
> (binding [*out* (java.io.PrintWriter. System/out)
>             *err*  (java.io.PrintWriter. System/err)]
>  (start-my-app))
>
> The only way I know of changing *out* and *err* is to wrap my entire
> program inside the "binding" function.
>
> I was wondering what is thought of the idea of making *out* and *err*
> dynamic vars? If they were dynamic I could do the following which I
> think is nicer and more elegant:
>
> (System/setOut (PrintStream. (FileOutputStream. "/home/user/myproject/
> log.txt" true) true))
> (System/setErr (PrintStream. (FileOutputStream. "/home/user/myproject/
> log.txt" true) true))
> (def *out* (java.io.PrintWriter. System/out))
> (def *err* (java.io.PrintWriter. System/err))
>
> Better yet, it would be nice if I changed *out* and *err* and that
> caused System/out and System/err to change too. So I could do:
>
> (def *out* (java.io.PrintWriter. (FileOutputStream. "/home/user/
> myproject/log.txt" true))
> (def *err* (java.io.PrintWriter. (FileOutputStream. "/home/user/
> myproject/log.txt" true))
>
> And System/out and System/err would also change.
>
> Thoughts?
>
> --
> 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: Neighbors function from The Joy of Clojure

2011-09-14 Thread Chouser
On Wed, Sep 14, 2011 at 8:58 AM, Leonardo Borges
 wrote:
> Hi Guys,
> I'm pretty new to clojure and to the list as well - this being my 1st
> message - so hello everyone :)
> I'm going through the book The Joy of Clojure which, pardon the pun,
> I'm enJOYing a lot and stumbled upon this function to find neighbors
> of a location in a 2D matrix:

Glad you like the book [careful avoidance of pun intended]!

> (defn neighbors
>   ([size yx] (neighbors [[-1 0] [1 0] [0 -1] [0 1]] size yx))
>   ([deltas size yx]
>     (filter (fn [new-yx]
>               (every? #(< -1 % size) new-yx))
>      (map #(map + yx %) deltas
>
> This syntax made me scratch my head since I believe it was the first
> time I saw it. However, upon closer analysis it seems it could be
> rewritten like this, yielding the same result:
>
> (defn neighbors-1 [size yx]
>   (let [deltas [[-1 0] [1 0] [0 -1] [0 1]]]
>     (filter (fn [new-yx]
>               (every? #(< -1 % size) new-yx))
>       (map #(map + yx %) deltas
>
> The second version feels a lot easier on my eyes. Am I missing
> something or they are really equivalent? And if so, why is the first
> syntax supported or better yet, when is it best to use it?

The main difference is that the first version allows you to pass in
your own deltas.  This could be useful if you wanted to include
diagonals as neighbors.  We don't think we take advantage of the
flexibility anywhere in the book, so perhaps your version would indeed
be better.

--Chouser

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


Binding *out*

2011-09-14 Thread Nick Mudge
I have a clojure program with which I would like all stdout and stderr
to be written to a file.

Of course there is Unix IO redirection but I am starting my program
from within another clojure program using "(.exec (Runtime/getRuntime)
clj-program-command env)" and that doesn't support IO redirection. Of
course I could use the "bash -c" command within the command to start
my program but it does make things a bit messier with all the quotes
and escaping of quotes, and anyway I would like to achieve this
objective within my clojure program.

I found out that System/out and System/err are separate and different
than *out* and *err*. Changing *out* or *err* does not change System/
out or System/err. My program includes the Jetty server which is
written in Java so it writes to System/out and System/err and not to
*out* and *err*. So to change all stdout and stderr to write to a file
I need to change System/out, System/err and *out* and *err*.

I can do this like so in my core.clj file:

(System/setOut (PrintStream. (FileOutputStream. "/home/user/myproject/
log.txt" true) true))
(System/setErr (PrintStream. (FileOutputStream. "/home/user/myproject/
log.txt" true) true))

(binding [*out* (java.io.PrintWriter. System/out)
 *err*  (java.io.PrintWriter. System/err)]
  (start-my-app))

The only way I know of changing *out* and *err* is to wrap my entire
program inside the "binding" function.

I was wondering what is thought of the idea of making *out* and *err*
dynamic vars? If they were dynamic I could do the following which I
think is nicer and more elegant:

(System/setOut (PrintStream. (FileOutputStream. "/home/user/myproject/
log.txt" true) true))
(System/setErr (PrintStream. (FileOutputStream. "/home/user/myproject/
log.txt" true) true))
(def *out* (java.io.PrintWriter. System/out))
(def *err* (java.io.PrintWriter. System/err))

Better yet, it would be nice if I changed *out* and *err* and that
caused System/out and System/err to change too. So I could do:

(def *out* (java.io.PrintWriter. (FileOutputStream. "/home/user/
myproject/log.txt" true))
(def *err* (java.io.PrintWriter. (FileOutputStream. "/home/user/
myproject/log.txt" true))

And System/out and System/err would also change.

Thoughts?

-- 
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: two form assert does not exist in 1.3.0-master-SNAPHOT

2011-09-14 Thread Stuart Sierra
There are no new JARs being published at build.clojure.org.  New releases 
(both numbered and -SNAPSHOT) are being published to oss.sonatype.org.

-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

Reuse of generic Clojure/ClojureScript code?

2011-09-14 Thread Dave Sann
Hi,

I have been using clojure for personal projects for a while now. I am 
starting to work with clojurescript. 

I have a number of utilities and libraries that I use in clojure. I can port 
much of these wholesale to clojurescript if I copy functions to cljs files.

Generally, my feeling is that I would like to be able to separate "generic 
clojure" from "jvm clojure" from "js clojure". Where "generic clojure" 
relies only on common capabilities of clojure or clojurescript. "jvm 
clojure" uses specific jvm/java libs and "js clojure" uses specifically js 
libs or capabilities.

As I understand it, even if I do this, I cannot use clojurescript-compatible 
clj files in a clojurescript build. (i.e compile the clj file as cljs).

Presumably, I could link or rename the files, but I think that in the long 
run this would be a maintenance challenge. Likewise for copying - if the 
code is meant to be the same.

Does anyone have opinions about how to maximise reuse of existing generic 
clojure code as cljs code in this manner? ( I know you can require-macros - 
but this does not work for : defn - for example - unless I am mistaken)

Do people feel that this sort of separation would be useful or of marginal 
benefit?

As a corollary (if separation and reuse were possible):
 - it would be quite useful to he able to define a library as being intended 
to be generic. The compiler would raise an error if a non-generic capability 
was employed somewhere in the library dependencies (i.e some inter-op or 
platform specific lib)

 - and to be able to require/use a "jvm" or "js" specific implementation of 
a library (implementing the same api/functions) depending on the compilation 
context...

It may be that some of this is possible with macros etc...my depth of 
knowledge is limited.

I am interested to hear opinions...


Cheers

Dave

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

Neighbors function from The Joy of Clojure

2011-09-14 Thread Leonardo Borges
Hi Guys,
I'm pretty new to clojure and to the list as well - this being my 1st
message - so hello everyone :)
I'm going through the book The Joy of Clojure which, pardon the pun,
I'm enJOYing a lot and stumbled upon this function to find neighbors
of a location in a 2D matrix:

(defn neighbors
  ([size yx] (neighbors [[-1 0] [1 0] [0 -1] [0 1]] size yx))
  ([deltas size yx]
    (filter (fn [new-yx]
              (every? #(< -1 % size) new-yx))
     (map #(map + yx %) deltas

This syntax made me scratch my head since I believe it was the first
time I saw it. However, upon closer analysis it seems it could be
rewritten like this, yielding the same result:

(defn neighbors-1 [size yx]
  (let [deltas [[-1 0] [1 0] [0 -1] [0 1]]]
    (filter (fn [new-yx]
              (every? #(< -1 % size) new-yx))
      (map #(map + yx %) deltas

The second version feels a lot easier on my eyes. Am I missing
something or they are really equivalent? And if so, why is the first
syntax supported or better yet, when is it best to use it?

Cheers,
Leonardo Borges
www.leonardoborges.com

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


Re: Rounding the edges of an Emacs beginner

2011-09-14 Thread Benjamin Klüglein
Hi Tim,

back when I started diving into Clojure I had the very same plan, teach
me Emacs to write Clojure.
Somewhere down the road I realized that I can have almost everything,
that I hoped to gain by picking up Emacs, in VIM too. VimClojure and
lein-vimclojure**, once set up, delivered everything I was looking for.
Ok, everything but debugging!
Which, thanks to the ability to use tracing right inside a vim repl, I
don't miss that much as I missed my buddies . and * back then... :-)

I definitely don't want to discourage you from looking into Emacs, which
without a question is a great text editor, I just wanted to note that
there are working setups for VIM too. :-)

Regards,
Ben

Am 14.09.2011 04:13, schrieb Timothy Washington:
>
> Hey all, 
>
>
> So I'm still an avid vim user. But I see a lot of power in the swank
> slime setup, and have been teaching myself emacs to try to leverage
> it. There are still a few tricks I haven't got. Maybe my notes are
> just disorganised, but I was hoping fellow Clojurians can chime in. 
>
>
>   * ? getting an error when I i) "M-x slime-connect" or ii) send a
> form (+1 1) to swank ; this is after i) a "lein swank" then ii) in
> another window "emacs" M-x connect . ** Evaluating Slime forms
> seems to work after that 
>
>
> webkell@ubuntu:~/Projects/bkell$ lein swank
>
> Listening for transport dt_socket at address: 36109
>
> Connection opened on localhost port 4005.
>
> exception in read loop
>
> java.lang.Exception: Error reading swank message*# this happens when
> slime tries to connect with M-x slime-connect *
>
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>
> ...
>
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>
> ...
>
> at clojure.lang.Var.applyTo(Var.java:518)
>
> at clojure.main.main(main.java:37)
>
> exception in control loop
>
> java.lang.InterruptedException
>
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:1961)
>
> ...
>
> at swank.util.concurrent.mbox$receive.invoke(mbox.clj:28)
>
> at swank.core$control_loop.invoke(core.clj:401)
>
> ...
>
> at swank.swank$connection_serve$fn__1720.doInvoke(swank.clj:20)
>
> ...
>
> at java.lang.Thread.run(Thread.java:619)
>
>
>
>   * ? howto do Code completion (clojure, and elisp ) 
>   * ? close a slime-repl connection 
>   * ? howto list modes engaged 
>   * ? Also need to increase my skills navigating the debugger. Is this
> still the reference
>  to use 
>  *
>
> ? Can you use Emacs / Slime / CDT (debugging) with Ruby / Rails  
>
>
> As a VIM'er, I'm trying to do the following using emacs navigation,
> but seem to have missed the levers to pull. I'm using a vim navigation
> plugin , which helps a lot. 
>
>   * ? set line numbers 
>   * ? go to line 'n' 
>   * ? how to jump to matching parentheses 
>   * ? move down a chunk like in vim 
>   * ? yank 'n' lines -> emacs yank puts back some 'killed' text ;
> HOWTO copy 
>
>
> Thanks 
>
> Tim 
>
>
> -- 
> 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

dropped into clojure and lein! compojure file for project.clj?

2011-09-14 Thread deltag
I have been dropped into a clojure project which was abandoned some time ago 
and now reactivated..So, I am picking up clojure and lein simultaneously.
In every project.clj file, this compojure reference cannot be resolved.  Is 
there another reference that is more recent?

[org.clojars.stuarthalloway/compojure "0.3.3-SNAPSHOT"]

many thanks for any help.



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

why expressions in macro are not evaluated?

2011-09-14 Thread jingguo
I write a simple macro and an invocation of the macro. Here is the
code:

(defmacro my-macro
  [& body]
  `(for [cur-date# ["2011-09-04" "2011-09-05"]]
 (do ~@body)
   )
)

(my-macro
(printf "a_message\n")
)

I get a_message printed twice if I paste the code in a clojure REPL.
But I save the code into a file called foo.clj and use "clj foo.clj"
to run it. I get nothing in stdout. It seems that (printf "a_message
\n")
 is not evaluated. Can anybody explain this behavior? 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


Re: N00b alert! - A question on immutable/mutable data structures...

2011-09-14 Thread Trevor
ahh,... I see.
Thank you all - you've been very helpful.
Trevor



On Sep 14, 12:31 am, Stuart Campbell  wrote:
> I knew there must be a nicer way to write that :)
>
> On 14 September 2011 16:22, Meikel Brandmeyer (kotarak)  wrote:
>
>
>
>
>
>
>
> > Or:
>
> > (swap! user-queues update-in [k] (fnil conj
> > clojure.lang.PersistentQueue/EMPTY) v)
>
> > Sincerely
> > Meikel
>
> >  --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

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


Fund raising takes shape!

2011-09-14 Thread Laurent PETIT
What a wonderful Clojure community!

My fund raising campaign to help me attend the Conj is already
half-complete.

For all of those who have already contributed, I'd like to thank you again!
Being part of such a supporting community fills me with joy and makes me
proud.

Please note I've created a dedicated page explaining the motivations behind
this fund raising campaign, as well as a status indicator:
http://code.google.com/p/counterclockwise/wiki/ConjTripFunding

I'd like to draw your attention on a point of interest: I'm a really poor
swimmer ... so I'd prefer be able to book a plane for traveling back to
France. Follow me ? (twitter pun intended) :-)

Cheers,

-- 
Laurent Petit

-- 
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: "case" on primitives warning in 1.3-RC0

2011-09-14 Thread Tassilo Horn
Sergey Didenko  writes:

> Is this the intended behavior? Note the present/missing default clause
>
> user> (set! *warn-on-reflection* true)
> user> (case (rand-int 3) 0 :zero 1 :one 2 :two)
> Performance warning, NO_SOURCE_FILE:1 - case has int tests, but tested
> expression is not primitive.
> :two
> user> (case (rand-int 3) 0 :zero 1 :one 2 :two :default 3)
> :two

The default case in `case' (what a sentence) is not paired like in
`cond'.  You want something like:

,
| user> (case (rand-int 10) 0 :zero 1 :one 2 :two :other)
| Performance warning, NO_SOURCE_FILE:1 - case has int tests, but tested 
expression is not primitive.
| :other
`

I think the problem with the reflection warning is that `rand-int'
returns a Long.  This version seems to wor:

,
| (case (int (rand-int 10))
|0:zero
|1:one
|2:two
|:other)
`

Bye,
Tassilo

-- 
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: trace-forms macro

2011-09-14 Thread Jonathan Fischer Friberg
It was tested with 1.2.1

Jonathan

On Wed, Sep 14, 2011 at 9:09 AM, Sergey Didenko wrote:

> Looks interesting. Did you use it with Clojure 1.3 or earlier?
>
> --
> 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

"case" on primitives warning in 1.3-RC0

2011-09-14 Thread Sergey Didenko
Is this the intended behavior? Note the present/missing default clause

user> (set! *warn-on-reflection* true)
user> (case (rand-int 3) 0 :zero 1 :one 2 :two)
Performance warning, NO_SOURCE_FILE:1 - case has int tests, but tested
expression is not primitive.
:two
user> (case (rand-int 3) 0 :zero 1 :one 2 :two :default 3)
:two

-- 
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: two form assert does not exist in 1.3.0-master-SNAPHOT

2011-09-14 Thread Sergey Didenko
Apparently not: "1.3.0-master-SNAPSHOT/ 20-Dec-2010"

> there used to be http://build.clojure.org/snapshots, but I don't know
> whether it's still cared for.

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


Re: Calling a Java call with array from Clojure

2011-09-14 Thread Luc Prefontaine
On any platform, calling conventions are fictions enforced at the machine code 
level by compilers :)
It's not specific to the JVM.

Luc P.

On Tue, 13 Sep 2011 19:33:54 -0700 (PDT)
Alan Malloy  wrote:

> Varargs are a fiction of javac, and do not exist at the bytecode
> level. In real life, this method takes two args, a String and a
> String[]. Use into-array to create a string array, and pass that as
> the second arg.
> 
> On Sep 13, 6:21 pm, ron peterson  wrote:
> > I have a following API call that I need to make from Clojure:
> >
> > class A
> >
> > doSomething(java.lang.String arg1, String... args)
> >
> > so I tried
> >
> > (def a (new A))   ;this works
> >
> > (.doSomething a "abc" "efg" "hij")
> >
> > ;this doesn't work giving me no matching method found: doSomething
> > for class A
> 



-- 
Luc P.


The rabid Muppet

-- 
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: two form assert does not exist in 1.3.0-master-SNAPHOT

2011-09-14 Thread Meikel Brandmeyer (kotarak)
Hi,

there used to be http://build.clojure.org/snapshots, but I don't know 
whether it's still cared for.

Sincerely
Meikel

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

Re: two form assert does not exist in 1.3.0-master-SNAPHOT

2011-09-14 Thread Sergey Didenko
I see, there is no "clojure-1.3.0-master-SNAPSHOT.jar" in maven and I
should use "1.3.0-RC0"

>  I see, my lein - maven thinks that the latest
> clojure-1.3.0-master-SNAPSHOT.jar was built in January.
>
>> current master seems to disagree with you:
>> https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L4222
>

-- 
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: two form assert does not exist in 1.3.0-master-SNAPHOT

2011-09-14 Thread Sergey Didenko
 I see, my lein - maven thinks that the latest
clojure-1.3.0-master-SNAPSHOT.jar was built in January.

> current master seems to disagree with you:
> https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L4222

-- 
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: two form assert does not exist in 1.3.0-master-SNAPHOT

2011-09-14 Thread Meikel Brandmeyer (kotarak)
Hi,

current master seems to disagree with you:
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L4222

Sincerely
Meikel

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

Re: Rounding the edges of an Emacs beginner

2011-09-14 Thread Stefan Kamphausen
Hi,

just a few follow-ups...

On Wednesday, September 14, 2011 4:13:47 AM UTC+2, frye wrote:

   - ? howto list modes engaged 

Aside from the already mentioned C-h m (aka M-x describe-mode) you will want 
to use 

* C-h k (M-x describe-key) followed by some keybinding to find out what that 
keybinding does
* C-h w (M-x where-is) followed by the name of some command to find out what 
keybinding exists for that command
* C-h a PATTERN (M-x apropos) to search for PATTERN in command names and 
variables (ah, I miss hyper-apropos from XEmacs)
* C-h v VARIABLE (M-x describe-variable) to see the documentation for a 
variable in ELisp (use C-c C-d d on Clojure symbols to see their 
documentation from SLIME)
* C-h f FUNCTION (M-x describe-function) to see docs for an Elisp-function
* and finally C-h ? to find out what other help is available

The built-in help system of Emacs is one of its greatest strengths.

>
>- 
>
>? Can you use Emacs / Slime / CDT (debugging) with Ruby / Rails  
>
> ? howto do Code completion (clojure, and elisp ) 
>
>
> Try TAB in the REPL and M-TAB in a Clojure-buffer when you are connected to 
a running image. 
 

> As a VIM'er, I'm trying to do the following using emacs navigation, but 
> seem to have missed the levers to pull. I'm using a vim navigation 
> plugin, 
> which helps a lot. 
>
>
>- ? set line numbers 
>
>
I use linum.el written by  Markus Triska:
(when (try-require 'linum) ;; try require is just a minor wrapper which 
checks, whether a lib is available
  (global-linum-mode))


>- ? go to line 'n' 
>
> Since my fingers are used to M-g I bind that key to goto-line :
(global-set-key (kbd "M-g") #'goto-line)


>- ? how to jump to matching parentheses 
>
> Meta with left and right cursor keys. Actually those are forward-sexp and 
backward-sexp 

>
>- ? move down a chunk like in vim 
>
> What does that mean? 

>
>- ? yank 'n' lines -> emacs yank puts back some 'killed' text ; HOWTO 
>copy 
>
> Mark things by first enabling the mark with C-SPC. Move around using your 
usual command.  Copy to the kill-ring with M-w or cut the text and copy it 
to the kill-ring using C-w.  After that you can yank (Emacsspeak for 
'paste') from the kill ring with C-y.  Try M-y right after a C-y to get 
older elements on the kill-ring. For marking, try what C-M-SPC does, also 
hit it several times in a row.
Warning: if your finger's memory learns this, using modern IDEs may feel 
awkward.

Regards,
Stefan

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

Re: Problem with insert-values (clojure.contrib.sql)

2011-09-14 Thread finbeu
Yes, if I understand it correctly, instead of db, I just use the pooled-db

It would be good to have an example that connects the pooled db stuff with 
the normal db stuff.

(defn db-update-or-insert
  "Updates or inserts a fruit"
  [record]
  (sql/with-connection pooled-db
(sql/update-or-insert-values
 :fruit
 ["name=?" (:name record)]
 record)))

-- 
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: Overtone 0.3 released

2011-09-14 Thread Sam Aaron
I should also mention that we have a cheat sheet too:

http://cloud.github.com/downloads/overtone/overtone/overtone-cheat-sheet.pdf

Thanks to Steve Tayon for such an excellent template.

Sam

---
http://sam.aaron.name

On 13 Sep 2011, at 00:03, Sam Aaron wrote:

> Hey everyone,
> 
> I've just pushed out a shiny new Overtone release to Clojars. Although it's 
> only been a little over a month since the last release, there's been quite a 
> lot of work committed that it definitely warranted a new number and a little 
> release party! So update your music project dependencies to 0.3.0, sync your 
> deps and start playing with the new functionality. A great place to start is 
> the new algorithmic piano example:
> 
> https://github.com/overtone/overtone/blob/master/test/example/extemp_piano.clj
> 
> So, what's happened? Well, the key highlights are:
> 
> * An example system
> * Binary/Unary UGen documentation
> * The unification of Binary/Unary UGen calling semantics with standard UGen 
> fns.
> * A selection of interesting new algo/music fns
> * Useful UGen documentation lookup fns: ug-doc, find-ug, find-ug-doc
> 
> More detailed highlights are as follows:
> 
> https://github.com/overtone/overtone/blob/master/CHANGELOG.md
> 
> Enjoy!
> 
> Sam
> 
> ---
> http://sam.aaron.name

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


two form assert does not exist in 1.3.0-master-SNAPHOT

2011-09-14 Thread Sergey Didenko
Despite of what written here: http://dev.clojure.org/display/doc/1.3
there is no two form assert in 1.3.0-master-SNAPHOT

-- 
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: trace-forms macro

2011-09-14 Thread Sergey Didenko
Looks interesting. Did you use it with Clojure 1.3 or earlier?

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

2011-09-14 Thread Sean Corfield
On Wed, Sep 14, 2011 at 12:05 AM, Sergey Didenko
 wrote:
> Also bear in mind that due to the functional nature of Clojure you can
> debug a lot of problems using tracing, like clojure.contrib.trace (for
> < 1.3)

Coming soon to 1.3! Luc Prefontaine has volunteered to maintain this
library as clojure.tools.cli going forward (which will work with 1.2
and 1.3 BTW).
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: debugging

2011-09-14 Thread Sergey Didenko
Also bear in mind that due to the functional nature of Clojure you can
debug a lot of problems using tracing, like clojure.contrib.trace (for
< 1.3), C-c C-t in Emacs, or this handy macro:

(defmacro dbg[x] `(let [x# ~x] (println "dbg:" '~x "=" x#) x#))

(func1 (func2 arg1) arg2) -> (dbg (func1 (dbg (func2 arg1)) arg2))

Stolen from here:
http://stackoverflow.com/questions/2352020/debugging-in-clojure

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