| 1 |
/* |
| 2 |
* @progname count_dup.ll |
| 3 |
* @version 1.0 |
| 4 |
* @author anon |
| 5 |
* @category |
| 6 |
* @output Text |
| 7 |
* @description |
| 8 |
* Count dups among ancestors? |
| 9 |
*/ |
| 10 |
|
| 11 |
global(cnttab) |
| 12 |
global(indtab) |
| 13 |
global(undone) |
| 14 |
global(allind) |
| 15 |
global(maxcount) |
| 16 |
global(maxindi) |
| 17 |
|
| 18 |
proc main() { |
| 19 |
|
| 20 |
list(undone) |
| 21 |
list(allind) |
| 22 |
table(cnttab) |
| 23 |
table(indtab) |
| 24 |
|
| 25 |
getindi(person) |
| 26 |
set(maxcount,0) |
| 27 |
set(maxindi,person) |
| 28 |
call addaperson(person) |
| 29 |
set(c,0) |
| 30 |
|
| 31 |
while (person,dequeue(undone)) { |
| 32 |
incr(c) |
| 33 |
/* print(d(c)," ",key(person),"\n") */ |
| 34 |
if(eq(mod(c,1000), 0)) { |
| 35 |
print(d(c)," ",d(maxcount)," ",key(maxindi)," ",name(maxindi),"\n") |
| 36 |
} |
| 37 |
if (p,father(person)) { call addaperson(p) } |
| 38 |
if (p,mother(person)) { call addaperson(p) } |
| 39 |
} |
| 40 |
|
| 41 |
while(p,dequeue(allind)) { |
| 42 |
set(count,lookup(cnttab,key(p))) |
| 43 |
d(count) " " key(p) " " name(p) " " title(p) "\n" |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
proc addaperson(p) |
| 48 |
{ |
| 49 |
enqueue(undone,p) |
| 50 |
set(count,lookup(cnttab,key(p))) |
| 51 |
if(ne(count,0)) { |
| 52 |
set(count, add(count,1)) |
| 53 |
if(gt(count, maxcount)) { |
| 54 |
set(maxcount, count) |
| 55 |
set(maxindi, p) |
| 56 |
} |
| 57 |
} else { |
| 58 |
set(count,1) |
| 59 |
insert(indtab, key(p), p) |
| 60 |
enqueue(allind,p) |
| 61 |
} |
| 62 |
insert(cnttab, key(p), count) |
| 63 |
} |