Mercurial > forge
annotate main/general/inst/@dict/private/__lookup_compat__.m @ 9687:9df0cf7217ae octave-forge
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
author | carandraug |
---|---|
date | Tue, 13 Mar 2012 22:39:03 +0000 |
parents | 93dec4bcb93f |
children |
rev | line source |
---|---|
6624
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
1 ## Copyright (C) 2009 VZLU Prague, a.s., Czech Republic |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
2 ## |
9687
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
3 ## This program is free software; you can redistribute it and/or modify it under |
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
4 ## the terms of the GNU General Public License as published by the Free Software |
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
5 ## Foundation; either version 3 of the License, or (at your option) any later |
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
6 ## version. |
6624
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
7 ## |
9687
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
8 ## This program is distributed in the hope that it will be useful, but WITHOUT |
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
11 ## details. |
6624
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
12 ## |
9687
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
13 ## You should have received a copy of the GNU General Public License along with |
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
14 ## this program; if not, see <http://www.gnu.org/licenses/>. |
6624
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
15 |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
16 ## This replaces the missing functionality of "lookup" if on Octave 3.2. |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
17 |
9687
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
18 ## Author: Jaroslav Hajek <highegg@gmail.com> |
9df0cf7217ae
general: update licenses to GPLv3+ and DESCRIPTION to mention non GPL code
carandraug
parents:
6624
diff
changeset
|
19 |
6624
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
20 function lookup_func = __lookup_compat__ () |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
21 persistent octave32 = issorted ({"3.0.0", version, "3.3.0"}); |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
22 if (octave32) |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
23 lookup_func = @__my_lookup__; |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
24 else |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
25 lookup_func = @lookup; |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
26 endif |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
27 endfunction |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
28 |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
29 function ind = __my_lookup__ (table, y, opt = "") |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
30 |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
31 mopt = any (opt == 'm'); |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
32 bopt = any (opt == 'b'); |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
33 |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
34 opt(opt == 'm' | opt == 'b') = []; |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
35 |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
36 ind = lookup (table, y, opt); |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
37 if (numel (table) > 0) |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
38 if (ischar (table) || iscellstr (table)) |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
39 match = strcmp (table(max (1, ind)), y); |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
40 else |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
41 match = table(max (1, ind)) == y; |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
42 endif |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
43 else |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
44 match = false (size (y)); |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
45 endif |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
46 |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
47 if (mopt) |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
48 ind(! match) = 0; |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
49 elseif (bopt) |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
50 ind = match; |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
51 endif |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
52 endfunction |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
53 |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
54 |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
55 |
93dec4bcb93f
add @dict/isempty, @dict/length, hide __lookup_compat__
highegg
parents:
diff
changeset
|
56 |