• IMPERATIVE LANGUAGE does everything PROLOG can do !!

    From Graham Cooper@21:1/5 to All on Mon Feb 20 08:30:10 2023
    The core of prolog is with 2 or more lines in the Tail

    neice( P K ) :-
    sibling( P S )
    kid( S K )

    Prolog goes through the records of sibling and unifies S to S
    and answer a KID of that SIBLING.

    ----------------------------------------------------

    NOW this can be done imperatively

    neice brad [?]

    YES

    andL sib brad
    andR dot mary maryson

    ============================

    4 neice brad
    P=brad
    K=
    neice brad

    4 1 and sib P blank dot var2 blank
    2 and sib brad blank
    A=sib
    W=brad
    X=blank
    B=dot
    and sib brad blank

    2 1 if
    2 2 eq W blank
    2 5 if
    2 6 eq X blank
    2 7 clear X
    2 8 endif
    2 9 A W X
    6 sib brad X
    T=brad
    sib brad X

    6 1 if
    6 2 sis T S
    9 sis brad S
    S=mary
    sis brad mary

    6 3 else
    2 10 echo andL
    2 11 print A
    2 12 print W
    2 13 print X
    2 14 echo newline
    2 15 if
    2 16 eq Y blank
    2 19 if
    2 20 eq Z blank
    2 21 clear Z
    2 22 endif
    2 23 if
    2 24 eq Y var1
    2 27 if
    2 28 eq Y var2
    2 29 let Y X
    2 30 endif
    2 31 if
    2 32 eq Z var1
    2 35 if
    2 36 eq Z var2
    2 39 if
    2 40 B Y Z
    14 dot Y Z
    Y=mary
    Z=maryson
    dot mary maryson

    2 41 echo andR
    2 42 print B
    2 43 print Y
    2 44 print Z
    2 45 echo newline
    2 46 else



    ----------------------------- CODE -------------------------

    and A W X B Y Z
    -if
    -eq W blank
    -clear W
    -endif
    -if
    -eq X blank
    -clear X
    -endif
    -A W X
    -echo andL
    -print A
    -print W
    -print X
    -echo newline
    -if
    -eq Y blank
    -clear Y
    -endif
    -if
    -eq Z blank
    -clear Z
    -endif
    -if
    -eq Y var1
    -let Y W
    -endif
    -if
    -eq Y var2
    -let Y X
    -endif
    -if
    -eq Z var1
    -let Z W
    -endif
    -if
    -eq Z var2
    -let Z X
    -endif
    -if
    -B Y Z
    -echo andR
    -print B
    -print Y
    -print Z
    -echo newline
    -else
    -clear W
    -clear X
    -clear Y
    -clear Z
    -next
    -and A W X B Y Z

    bothparentsofkid M L
    -and kid M blank kid L blank

    neice P
    -and sib P blank dot var2 blank

    auntieuncle N
    -and kid blank N sib var1 blank

    sib P K
    -if
    -sister P K
    -else
    -brother P K
    -endif

    kid P K
    -if
    -son P K
    -else
    -dot P K
    -endif

    brother P K
    -if
    -bro P K
    -else
    -sis K P
    -endif

    sister P K
    -if
    -sis P K
    -else
    -bro K P
    -endif


    sis alan zeta
    sis brad mary
    bro brad nelly
    bro carl tom
    son alan joe
    son mary joe
    son nelly nellyson
    dot mary maryson
    son a b
    dot c d



    DOES EVERYTHING PROLOG DOES !

    www.new.math.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)