Yup, that will do just fine it seems, ty!

On Monday, July 7, 2014 5:27:24 PM UTC+2, Mauro wrote:
>
> Couldn't you just use a function?  (If possible use functions and not 
> macros.) 
>
> function scatter(axes, axno, reim::Function, λno::Symbol, col) 
>     axes[axno][:scatter](sbox.kx, reim([OnePump.(λno)(0., momx, np) for 
> momx in sbox.kx]), s=15, alpha=0.2, color=col) 
> end 
>
>
>
> On Mon, 2014-07-07 at 16:05, andreib...@gmail.com <javascript:> wrote: 
> > Jacob, tnx for the quick reply and sorry about the redundant for loop. 
> This 
> > is how I decided to do it: 
> > 
> > macro scatter(axno, reim, λno, col) 
> >     :(*axes[$axno][:scatter](sbox.kx, $reim([OnePump.λ$λno(0., momx, np) 
> > for momx in sbox.kx]), s=15, alpha=0.2, color=$col) )* 
> > end 
> > 
> > fig, axes = plt.subplots(2,1, figsize=(8,6)) 
> > @scatter(1, real, 1, "orange") 
> > @scatter(1, real, 2, "blue") 
> > @scatter(2, imag, 1, "orange") 
> > @scatter(2, imag, 2, "blue") 
> > 
> > but i get `missing separator in tuple` when I define the macro. Any 
> clues 
> > why that might be? 
> > 
> > On Monday, July 7, 2014 3:40:58 PM UTC+2, Jacob Quinn wrote: 
> >> 
> >> I'm not sure I quite understand your example (your `i` variable is 
> never 
> >> used?), but macros just take zero or more expression/symbol arguments 
> and 
> >> return expressions, so you could easily do. 
> >> 
> >> macro orangeaxes() 
> >>     :(*axes[1][:scatter](kx, real([OnePump.λ1(0., momx, np) for momx in 
> >> kx]), s=15, alpha=0.4, color="orange") )* 
> >> end 
> >> macro axes() 
> >>     :(*axes[1][:scatter](kx, real([OnePump.λ2(0., momx, np) for momx in 
> >> kx]), s=15, alpha=0.2) )* 
> >> end 
> >> for i = 1:2 
> >>     @orangeaxes 
> >>     @axes 
> >>     @orangeaxes 
> >>     @axes 
> >> end 
> >> 
> >> Note the use of the `quote....end` shorthand `:(...)` in the macro 
> >> definitions so that an expression is returned. 
> >> 
> >> -Jacob 
> >> 
> >> 
> >> On Mon, Jul 7, 2014 at 6:04 AM, Andrei Berceanu <andreib...@gmail.com 
> >> <javascript:>> wrote: 
> >> 
> >>> axes[1][:scatter](kx, real([OnePump.λ1(0., momx, np) for momx in kx]), 
> >>> s=15, alpha=0.4, color="orange") 
> >> 
> >> 
> >> 
> >> 
>
> -- 
>
>

Reply via email to