!
! Lange 1997 gives a table for classical segregation analysis from Crow 
! 1965 of Cystic Fibrosis nuclear families,
!  s r a n         s = sibship size
! 10 3 1 1         r = number of affected offspring
!  9 3 1 1         a = number of probands
!  8 4 1 1         n = number of families of that type
!  7 3 2 1
!  7 3 1 1         MLE p = 0.2679 pi = 0.3594
!  7 2 1 1
!  7 1 1 1, 6 2 1 1, 6 1 1 1, 5 3 3 1, 5 3 2 1, 5 2 1 5, 5 1 1 2,
!  4 3 2 1, 4 3 1 2, 4 2 1 4, 4 1 1 6, 3 2 2 3, 3 2 1 3, 3 1 1 10,
!  2 2 2 2, 2 2 1 4, 2 1 1 18, 1 1 1 9.
!
eval (define (print x)  \
  (if (atom? x)  \
    (begin \
      (if (not (null? x)) (display x)) \
      (newline)) \
    (begin \
      (display (car x)) \
      (let loop ((x (cdr x))) \
        (if (atom? x) \
          (if (not (null? x)) \
            (begin (display " ") (display x))) \
          (begin (display " ") (display (car x)) \
                 (loop (cdr x) )))) \
      (newline))))
eval (define (seq m n) \
  (if (> m n) \
      '() \
      (cons m (seq (+ 1 m) n))))
eval (define (oneped ped s r a) \
  (begin  \
    (print (list ped 1 "x" "x" "m" "n" "n")) \
    (print (list ped 2 "x" "x" "f" "n" "n")) \
    (for-each  \
      (lambda (i) (print (list ped i "1" "2" "f" "y" "y")))  \
      (seq 3 (+ 2 a))) \
    (for-each  \
      (lambda (i) (print (list ped i "1" "2" "f" "y" "n")))  \
      (seq (+ 3 a) (+ 2 r))) \
    (for-each  \
      (lambda (i) (print (list ped i "1" "2" "f" "n" "n")))  \
      (seq (+ 3 r) (+ 2 s))) \
    (newline)))
eval (define (doped s r a n) \
  (begin \
   (let loop ((n n)) \
     (begin \
       (set! ped (+ 1 ped)) \
       (oneped ped s r a) \
       (if (> n 1) (loop (- n 1))))) \
    (newline))) 
eval (define ped 0)
file delete cftmp.ped
out cftmp.ped
eval (doped 10 3 1 1)  
eval (doped  9 3 1 1)  
eval (doped  8 4 1 1)  
eval (doped  7 3 2 1)  
eval (doped  7 3 1 1)  
eval (doped  7 2 1 1)  
eval (doped  7 1 1 1)  
eval (doped  6 2 1 1)  
eval (doped  6 1 1 1)  
eval (doped  5 3 3 1)  
eval (doped  5 3 2 1)  
eval (doped  5 2 1 5)  
eval (doped  5 1 1 2)  
eval (doped  4 3 2 1)  
eval (doped  4 3 1 2)  
eval (doped  4 2 1 4)  
eval (doped  4 1 1 6)  
eval (doped  3 2 2 3)  
eval (doped  3 2 1 3)  
eval (doped  3 1 1 10) 
eval (doped  2 2 2 2)  
eval (doped  2 2 1 4)  
eval (doped  2 1 1 18) 
eval (doped  1 1 1 9)
out
set loc cf aff
set loc proband aff
read ped cftmp.ped
run
freq cf
davie cf proband
davie cf
file delete cftmp.ped
