| 1 |
/* |
| 2 |
* @progname count_paternal_desc.ll |
| 3 |
* @version 2.0 |
| 4 |
* @author Eggert |
| 5 |
* @category |
| 6 |
* @output Text |
| 7 |
* @description |
| 8 |
|
| 9 |
This program counts paternal descendants of a person by generation. |
| 10 |
Only unique individuals in each generation are counted. |
| 11 |
A person counts in all the generations he/she is in, |
| 12 |
but only counts once in the grand total. |
| 13 |
Male paternal descendants are also counted separately. |
| 14 |
|
| 15 |
count_paternal_desc - a LifeLines descendants counting program |
| 16 |
by Jim Eggert ([email protected]) |
| 17 |
Version 1, 1 August 1994 |
| 18 |
Version 2, 16 February 1995, use lengthset(), print(,) |
| 19 |
*/ |
| 20 |
|
| 21 |
proc main () |
| 22 |
{ |
| 23 |
getindimsg(person,"Enter person to count paternal descendants of") |
| 24 |
indiset(thisgen) |
| 25 |
indiset(allgen) |
| 26 |
indiset(allmalegen) |
| 27 |
addtoset(thisgen, person, 0) |
| 28 |
if (male(person)) { addtoset(allmalegen, person, 0) } |
| 29 |
print("Counting generation ") |
| 30 |
"Number of paternal descendants of " key(person) " " name(person) |
| 31 |
" by generation:\n" |
| 32 |
set(gen,neg(1)) |
| 33 |
while(lengthset(thisgen)) { |
| 34 |
indiset(thismalegen) |
| 35 |
forindiset(thisgen,person,val,count) { |
| 36 |
if (male(person)) { |
| 37 |
addtoset(thismalegen,person,0) |
| 38 |
} |
| 39 |
} |
| 40 |
incr(gen) |
| 41 |
print(d(gen)," ") |
| 42 |
"Generation " d(gen) " has " d(lengthset(thisgen)) |
| 43 |
" paternal descendant" |
| 44 |
if (gt(lengthset(thisgen),1)) { "s" } |
| 45 |
" of which " d(lengthset(thismalegen)) " are male.\n" |
| 46 |
set(thisgen,childset(thismalegen)) |
| 47 |
set(allgen,union(allgen,thisgen)) |
| 48 |
set(allmalegen,union(allmalegen,thismalegen)) |
| 49 |
} |
| 50 |
"Total unique paternal descendants in generations 1-" d(gen) |
| 51 |
" is " d(lengthset(allgen)) |
| 52 |
" of which " d(lengthset(allmalegen)) |
| 53 |
" are male paternal descendants.\n" |
| 54 |
} |