[0ee160]: examples / findall / fc_findall.krb Maximize Restore History

Download this file

fc_findall.krb    47 lines (39 with data), 1.5 kB

# fc_findall.krb

collect_siblings
    foreach
        family.child_of($child, $father, $mother)
        python siblings = []
        forall
            family.child_of($sibling, $father, $mother)
            check $sibling != $child
            python siblings.append($sibling)
        $siblings = tuple(siblings)
    assert
        family.siblings_of($child, $siblings)
        
collect_cousins
    foreach
        family.child_of($child, $father, $mother)

        python cousins = []
        forall
            family.siblings_of($father, $father_siblings)            
            forall
                $father_sibling in $father_siblings
                family.child_of($cousin, $father_sibling, $_)
                python cousins.append($cousin)

            forall
                $father_sibling in $father_siblings
                family.child_of($cousin, $_, $father_sibling)
                python cousins.append($cousin)
        
        forall
            family.siblings_of($mother, $mother_siblings)
            forall
                $mother_sibling in $mother_siblings
                family.child_of($cousin, $_, $mother_sibling)
                python cousins.append($cousin)
            
            forall
                $mother_sibling in $mother_siblings
                family.child_of($cousin, $mother_sibling, $_)
                python cousins.append($cousin)
        
        $cousins = tuple(cousins)
    assert
        python print "%s has %s as cousins" % ($child, $cousins)