From Newsgroup: comp.lang.prolog
miniPROLOG is only 600 lines of web friendly PHP
working beautifully just have to add local variables
so it recurses down s [ s [ 0 ] ]
PROGRAM
----------------
num [ s N ]
num N
DATA
--------
num [ s N ]*
num 0
TRACE
-----------
---------------
query num [ s 0 ]
---------------
BIND1 query
FINDPRO query - query
FOUND PROGRAM query num [ s 0 ]
UNIFY2LIST 1 1 num [ s 0 ] - happy P*
BIND1 num [ s 0 ]
UNIFY num [ s 0 ] - happy P
#num#happy#
UNIFY2LIST 1 2 num [ s 0 ] - hot gaga
BIND1 num [ s 0 ]
UNIFY num [ s 0 ] - hot gaga
#num#hot#
UNIFY2LIST 1 3 num [ s 0 ] - friend gaga richard
BIND1 num [ s 0 ]
UNIFY num [ s 0 ] - friend gaga richard
#num#friend#
UNIFY2LIST 1 4 num [ s 0 ] - rich richard
BIND1 num [ s 0 ]
UNIFY num [ s 0 ] - rich richard
#num#rich#
UNIFY2LIST 1 5 num [ s 0 ] - bro pers1 bro1
BIND1 num [ s 0 ]
UNIFY num [ s 0 ] - bro pers1 bro1
#num#bro#
UNIFY2LIST 1 6 num [ s 0 ] - dot bro1 dot1
BIND1 num [ s 0 ]
UNIFY num [ s 0 ] - dot bro1 dot1
#num#dot#
UNIFY2LIST 1 7 num [ s 0 ] - frnd dot1 frnd1
BIND1 num [ s 0 ]
UNIFY num [ s 0 ] - frnd dot1 frnd1
#num#frnd#
UNIFY2LIST 1 8 num [ s 0 ] - niece P N*
BIND1 num [ s 0 ]
UNIFY num [ s 0 ] - niece P N
#num#niece#
UNIFY2LIST 1 9 num [ s 0 ] - fon PP FF*
BIND1 num [ s 0 ]
UNIFY num [ s 0 ] - fon PP FF
#num#fon#
UNIFY2LIST 1 10 num [ s 0 ] - num [ s N ]*
BIND1 num [ s 0 ]
UNIFY num [ s 0 ] - num [ s N ]
#num#num#
#[ s 0 ]#[ s N ]#
STRINGS [ s 0 ] - [ s N ]
#s 0#s N#
UNIFY s 0 - s N
#s#s#
#0#N#
N = 0
FOUND num [ s 0 ]
STAR 2 num [ s 0 ] - num [ s N ]
UNIFY num [ s 0 ] - num [ s N ]
#num#num#
#[ s 0 ]#[ s N ]#
STRINGS [ s 0 ] - [ s N ]
#s 0#s N#
UNIFY s 0 - s N
#s#s#
#0#N#
BIND1 num [ s 0 ]
BIND1 num [ s N ]
STAR 3 num [ s 0 ] - num [ s N ]
---------------
query num [ s 0 ]
---------------
BIND1 query
FINDPRO num [ s N ] - query
---------------
happy P hot P friend P R rich R
---------------
BIND1 happy P
FINDPRO num [ s N ] - happy P
---------------
niece P N bro P B dot B N
---------------
BIND1 niece P N
N = 0
FINDPRO num [ s N ] - niece P 0
---------------
fon PP FF niece PP NN frnd NN FF
---------------
BIND1 fon PP FF
FINDPRO num [ s N ] - fon PP FF
---------------
num [ s N ] num N
---------------
BIND1 num [ s N ]
FINDPRO num [ s N ] - num [ s N ]
FOUND PROGRAM num [ s N ] num N
UNIFY2LIST 2 1 num N - happy P*
BIND1 num N
N = 0
UNIFY num 0 - happy P
#num#happy#
UNIFY2LIST 2 2 num 0 - hot gaga
BIND1 num 0
UNIFY num 0 - hot gaga
#num#hot#
UNIFY2LIST 2 3 num 0 - friend gaga richard
BIND1 num 0
UNIFY num 0 - friend gaga richard
#num#friend#
UNIFY2LIST 2 4 num 0 - rich richard
BIND1 num 0
UNIFY num 0 - rich richard
#num#rich#
UNIFY2LIST 2 5 num 0 - bro pers1 bro1
BIND1 num 0
UNIFY num 0 - bro pers1 bro1
#num#bro#
UNIFY2LIST 2 6 num 0 - dot bro1 dot1
BIND1 num 0
UNIFY num 0 - dot bro1 dot1
#num#dot#
UNIFY2LIST 2 7 num 0 - frnd dot1 frnd1
BIND1 num 0
UNIFY num 0 - frnd dot1 frnd1
#num#frnd#
UNIFY2LIST 2 8 num 0 - niece P N*
BIND1 num 0
UNIFY num 0 - niece P N
#num#niece#
UNIFY2LIST 2 9 num 0 - fon PP FF*
BIND1 num 0
UNIFY num 0 - fon PP FF
#num#fon#
UNIFY2LIST 2 10 num 0 - num [ s N ]*
BIND1 num 0
UNIFY num 0 - num [ s N ]
#num#num#
#0#[ s N ]#
UNIFY2LIST 2 11 num 0 - num 0
BIND1 num 0
UNIFY num 0 - num 0
#num#num#
#0#0#
FOUND num 0
RUN REST
FINITO
RUN REST
YES
www.miniPROLOG.com
--- Synchronet 3.20a-Linux NewsLink 1.114