06.07.2013 Views

Scilab Bag Of Tricks - Claymore

Scilab Bag Of Tricks - Claymore

Scilab Bag Of Tricks - Claymore

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

end<br />

...<br />

end // while<br />

end<br />

for p = i : icurs-1<br />

this_diff = [lst1(p), string(-p)];<br />

diff = [diff; this_diff];<br />

end<br />

// re-sync<br />

i = icurs;<br />

The complete listing of this function can be found in Chapter 8.<br />

The last example also shows that we are switching between several style paradigms:<br />

• Neither the “One statement per line” rule is followed consistently,<br />

if equ(lst1(icurs), lst2(j)), break, end<br />

could be<br />

if equ( lst1(icurs), lst2(j) ) then<br />

break<br />

end<br />

• Nor is the intra-line spacing always consistent with the guidelines presented here:<br />

for p = i : icurs-1<br />

could be<br />

for p = i:icurs-1<br />

Chapter 3. Style<br />

The Golden Rule is that there are no golden rules... This is best known under the term ‘freedom’.<br />

3.3. Single Quotes vs. Double Quotes<br />

Single or double quotes enclose literal strings in <strong>Scilab</strong>. The opening quotes must match the closing<br />

ones, otherwise single and double quotes can be used interchangingly.<br />

The single quote, used as postfix operator, has the additional meaning of Hermitian (complex)<br />

transpostion. This double use almost causes not problems, but if you want to play it extra save, using<br />

double quotes for strings only adds clarity to your scripts.<br />

32

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!