Warning, /frameworks/syntax-highlighting/autotests/folding/test.octave.fold is written in an unsupported language. File is not indexed.
0001 # This is test comment 0002 % this is another comment 0003 a = 3; b = 34; 0004 0005 <beginfold id='1'>function</beginfold id='1'> retval = avg (v) 0006 retval = 0; 0007 <beginfold id='1'>if</beginfold id='1'> (isvector (v)) 0008 retval = sum (v) / length (v); 0009 else 0010 error ("avg: expecting vector argument"); 0011 <endfold id='1'>endif</endfold id='1'> 0012 <endfold id='1'>endfunction</endfold id='1'> 0013 0014 <beginfold id='1'>if</beginfold id='1'> (rem (x, 2) == 0) 0015 printf ("x is even\n"); 0016 else 0017 printf ("x is odd\n"); 0018 <endfold id='1'>endif</endfold id='1'> 0019 0020 <beginfold id='1'>if</beginfold id='1'> (rem (x, 2) == 0) 0021 printf ("x is even\n"); 0022 elseif (rem (x, 3) == 0) 0023 printf ("x is odd and divisible by 3\n"); 0024 else 0025 printf ("x is odd\n"); 0026 <endfold id='1'>end</endfold id='1'> 0027 0028 <beginfold id='1'>if</beginfold id='1'> (rem(x,2) == 0) x = 5; elseif (rem (x,3) == 0) x = 3; else x = 0; <endfold id='1'>end</endfold id='1'> 0029 0030 cd .. 0031 0032 <beginfold id='1'>while</beginfold id='1'> (i <= 10) 0033 fib (i) = fib (i-1) + fib (i-2); 0034 i++; 0035 <endfold id='1'>endwhile</endfold id='1'> 0036 0037 <beginfold id='1'>classdef</beginfold id='1'> polynomial2 0038 <beginfold id='1'>properties</beginfold id='1'> 0039 poly = 0; 0040 <endfold id='1'>endproperties</endfold id='1'> 0041 0042 <beginfold id='1'>methods</beginfold id='1'> 0043 <beginfold id='1'>function</beginfold id='1'> p = polynomial2 (a) 0044 <beginfold id='1'>if</beginfold id='1'> (nargin > 1) 0045 print_usage (); 0046 <endfold id='1'>endif</endfold id='1'> 0047 0048 <beginfold id='1'>if</beginfold id='1'> (nargin == 1) 0049 <beginfold id='1'>if</beginfold id='1'> (isa (a, "polynomial2")) 0050 p.poly = a.poly; 0051 elseif (isreal (a) && isvector (a)) 0052 p.poly = a(:).'; # force row vector 0053 else 0054 error ("polynomial2: A must be a real vector"); 0055 <endfold id='1'>endif</endfold id='1'> 0056 <endfold id='1'>endif</endfold id='1'> 0057 <endfold id='1'>endfunction</endfold id='1'> 0058 0059 <beginfold id='1'>function</beginfold id='1'> disp (p) 0060 a = p.poly; 0061 first = true; 0062 <beginfold id='1'>for</beginfold id='1'> i = 1 : length (a); 0063 <beginfold id='1'>if</beginfold id='1'> (a(i) != 0) 0064 <beginfold id='1'>if</beginfold id='1'> (first) 0065 first = false; 0066 elseif (a(i) > 0 || isnan (a(i))) 0067 printf (" +"); 0068 <endfold id='1'>endif</endfold id='1'> 0069 <beginfold id='1'>if</beginfold id='1'> (a(i) < 0) 0070 printf (" -"); 0071 <endfold id='1'>endif</endfold id='1'> 0072 <beginfold id='1'>if</beginfold id='1'> (i == 1) 0073 printf (" %.5g", abs (a(i))); 0074 elseif (abs (a(i)) != 1) 0075 printf (" %.5g *", abs (a(i))); 0076 <endfold id='1'>endif</endfold id='1'> 0077 <beginfold id='1'>if</beginfold id='1'> (i > 1) 0078 printf (" X"); 0079 <endfold id='1'>endif</endfold id='1'> 0080 <beginfold id='1'>if</beginfold id='1'> (i > 2) 0081 printf (" ^ %d", i - 1); 0082 <endfold id='1'>endif</endfold id='1'> 0083 <endfold id='1'>endif</endfold id='1'> 0084 <endfold id='1'>endfor</endfold id='1'> 0085 0086 <beginfold id='1'>if</beginfold id='1'> (first) 0087 printf (" 0"); 0088 <endfold id='1'>endif</endfold id='1'> 0089 printf ("\n"); 0090 <endfold id='1'>endfunction</endfold id='1'> 0091 <endfold id='1'>endmethods</endfold id='1'> 0092 <endfold id='1'>endclassdef</endfold id='1'>