Functions | |
if (nargs > 1 &&mod(nargs, 2)==0) narg_pairs | |
switch (t) case | |
otherwise | error ("substruct: expecting type to be one of \"()\", \"{}\", or \".\"") |
else | print_usage () |
endif endfunction!test | !x (1, 1).type |
!x (2, 1).type | |
!x (3, 1).type | |
!assert (x, y) | |
!error | assert (substruct) |
!error | assert (substruct(1, 2, 3)) |
!error | assert (substruct("x", 1)) |
!error | assert (substruct("()",[1, 2, 3])) |
!error | assert (substruct(".",{1, 2, 3})) |
Variables | |
function | retval |
typ = cell (narg_pairs, 1) | |
sub = cell (narg_pairs, 1) | |
k = 1 | |
for | i |
dot = false | |
endswitch | s = varargin{i+1} |
!y = substruct ("()", {1,2,3}, "{}", ":", ".", "foo") |
!assert | ( | x | , | |
y | ||||
) |
!x | ( | 3 | , | |
1 | ||||
) |
!x | ( | 2 | , | |
1 | ||||
) |
endif endfunction !test !x | ( | 1 | , | |
1 | ||||
) |
!error assert | ( | substruct(".",{1, 2, 3}) | ) |
!error assert | ( | substruct("()",[1, 2, 3]) | ) |
!error assert | ( | substruct("x", 1) | ) |
!error assert | ( | substruct(1, 2, 3) | ) |
!error assert | ( | substruct | ) |
if | ( | nargs | , | |
1 && | modnargs, 2 = =0 | |||
) |
else print_usage | ( | ) |
switch | ( | t | ) |
!y = substruct ("()", {1,2,3}, "{}", ":", ".", "foo") |
case dot = false |
k = 1 |
endswitch s = varargin{i+1} |
sub = cell (narg_pairs, 1) |
typ = cell (narg_pairs, 1) |