File: interestset.li

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 (51 lines) | stat: -rw-r--r-- 1,274 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
/*
 * @progname    interestset.li
 * @version     1.0
 * @author      Vincent Broman
 * @category
 * @output      indiset function value
 * @description Extracts subset of the database which are close to direct ancestors
 */


/*
 * Return the set of people who are wide-sense ancestors
 * of the given individual, plus the children of these wide-sense ancestors,
 * where a wide-sense ancestor is either the given individual himself/herself,
 * or a parent or step-parent of a wide-sense ancestor.
 */
func interestingforebearsof( indi) {
    indiset( res)
    addtoset( res, indi, key( indi))

    set( pf, parents( indi))
    if( not( pf)) { return( res) }

    if( h, husband( pf)) {
	set( res, union( res, interestingforebearsof( h)))
	families( h, f, sp, ctf) {
	    if( sp) {
		set( res, union( res, interestingforebearsof( sp)))
	    }
	    children( f, ch, ctc) {
		addtoset( res, ch, key( ch))
	    }
	}
	set( hk, key( h))
    } else {
	set( hk, "")
    }
    if( w, wife( pf)) {
	families( w, f, sp, cth) {
	    /* add only husbands not the father */
	    if( and( sp, nestr( hk, key( sp)))) {
		set( res, union( res, interestingforebearsof( sp)))
	    } else {
		children( f, ch, ctcc) {
		    addtoset( res, ch, key( ch))
		}
	    }
	}
    }
    return( res)
}