File: related_spouses.ll

package info (click to toggle)
lifelines 3.0.50-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 11,140 kB
  • ctags: 6,517
  • sloc: ansic: 57,468; xml: 8,014; sh: 4,255; makefile: 848; yacc: 601; perl: 170; sed: 16
file content (74 lines) | stat: -rw-r--r-- 2,242 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * @progname       related_spouses.ll
 * @version        2.0
 * @author         Eggert
 * @category       
 * @output         Text
 * @description    

This program identifies spouses with known common ancestors.  For each
marriage of related spouses, the spouses' names are printed, along
with the first common ancestor in each branch of the ancestry tree,
and the number of intervening generations for the husband and wife,
respectively.

related_spouses - a LifeLines program to identify related spouses
	by Jim Eggert (eggertj@atc.ll.mit.edu)
	Version 1,  31 March 1993 (first release)
	Version 2,  15 March 1995 (use new set functions, generation numbers)

*/

proc main() {
    indiset(husb_ancestors)
    indiset(wife_ancestors)
    indiset(common_ancestors)
    forfam(family,fnum) {
	if (hubby,husband(family)) {
	    if (wifey,wife(family)) {
/* find common ancestors */
		indiset(oneset)
		addtoset(oneset,hubby,0)
		set(husb_ancestors,ancestorset(oneset))
		addtoset(husb_ancestors,hubby,0)
		indiset(oneset)
		addtoset(oneset,wifey,0)
		set(wife_ancestors,ancestorset(oneset))
		addtoset(wife_ancestors,wifey,0)
		set(common_ancestors,intersect(husb_ancestors,wife_ancestors))
		set(cnum,lengthset(common_ancestors))

/* find lowest common ancestors (common_ancestors - too_common_ancestors) */
		if (cnum) {
/* Make wife ancestor generation table wcat */
		    indiset(wca)
		    set(wca,intersect(wife_ancestors,husb_ancestors))
		    table(wcat)
		    forindiset(wca,person,wgen,wnum) {
			insert(wcat,key(person),wgen)
		    }

		    indiset(lowest_common_ancestors)
		    set(lowest_common_ancestors,
			difference(common_ancestors,
				   ancestorset(common_ancestors)))
		    set(lca_length,lengthset(lowest_common_ancestors))
/* print out lowest common ancestors */
		    key(family) " "
		    key(husband(family)) " " name(husband(family))
		    " and "
		    key(wife(family)) " " name(wife(family))
		    "\n have " d(lca_length)
		    " lowest common ancestor"
		    if (gt(lca_length,1)) { "s" }
		    col(60) "hgen" col(70) "wgen\n"
		    forindiset(lowest_common_ancestors,lca,hgen,lnum) {
			"  " key(lca) " " name(lca)
			col(60) d(hgen)
			col(70) d(lookup(wcat,key(lca))) "\n"
		    }
		}
	    }
	}
    }
}