Posted by
CARL Philippe (LBP) on
URL: http://imagej.273.s1.nabble.com/Algorithmic-issue-tp5016298p5016304.html
Dear Curtis,
I thank you very much for having pefectly understand what I was looking for, as well as giving me the solution.
In fact I wanted to eliminate one (of the two) levels of indentation needed by the code I gave as example.
Indeed, I have a huge macro calling several plugins where I want to increase the complexity at several places within the code.
And I was convinced this issue could be solved with the addition of only one indentation level, but unfortunatelly I wasn't able to figure out how.
Thus I thought again about the words of Feyman who said:
"There is always an easy way to explain everything, it is just very hard to find it".
And now you gave me the solution, it was indeed very easy.
But without your help, it was very very hard!!!
So thanks a lot four your answer and help.
Kindest regards,
Philippe
Le Lundi 2 Mai 2016 19:12 CEST, Curtis Rueden <
[hidden email]> a écrit:
> Hi Philippe,
>
> If you use one of the scripting languages instead of the macro language,
> there are many ways with varying levels of elegance and obfuscation,
> depending on your taste.
>
> For example, here is an SO post discussing this issue for Python:
>
http://stackoverflow.com/q/6981717/1207769>
> And here is some awesome stuff with Groovy:
>
http://naleid.com/blog/2008/12/01/groovy-makes-iteration-easy>
> My personal taste regarding for+if is to eliminate the extra level of
> indentation by using the "continue" keyword (or equivalent in whatever
> language you are using), as in:
>
> boola = newArray(true, false, true, true, false);
> for(i = 0; i != boola.length; i++) {
> if (!boola[i]) continue;
> print(boola[i]);
> }
>
> Regards,
> Curtis
>
> --
> Curtis Rueden
> LOCI software architect -
http://loci.wisc.edu/software> ImageJ2 lead, Fiji maintainer -
http://imagej.net/User:Rueden> Did you know ImageJ has a forum?
http://forum.imagej.net/>
>
> On Mon, May 2, 2016 at 11:39 AM, Philippe CARL <
[hidden email]>
> wrote:
>
> > Dear all,
> >
> > I would have a question that is not specifically ImageJ related, but rather
> > with programming in general.
> >
> > Indeed, please consider the following macro code:
> >
> > boola = newArray(true, false, true, true, false);
> >
> > for(i = 0; i != boola.length; i++)
> >
> > if(boola[i])
> >
> > print(boola[i]);
> >
> > Would there be a way to combine the for and if loops within a single one
> > giving the same result than higher?
> >
> > I thank you very much in advance about your lighting concerning this
> > question.
> >
> > My best regards,
> >
> > Philippe
> >
> >
> >
> > Philippe CARL
> >
> > Laboratoire de Biophotonique et Pharmacologie
> >
> > UMR 7213 CNRS - Université de Strasbourg
> >
> > Faculté de Pharmacie
> >
> > 74 route du Rhin
> >
> > 67401 ILLKIRCH
> >
> > Tel : +33(0)3 68 85 41 84
> >
> >
> > --
> > ImageJ mailing list:
http://imagej.nih.gov/ij/list.html> >
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html