SolPrologV2 – 独白2区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,SolPrologV2 – 独白2区块链毕设代写 是一篇很好的国外资料

SolPrologV2

A Prolog engine written in Solidity.

pragma solidity ^0.7.0;  // SPDX-License-Identifier: GPLv3  contract PrologContract {     struct Term {         string value;      // If empty, term is a list, otherwise it's a predicate.                            // value can represent an atom, variable, | or _.         Term[] children;     }      struct Rule {         Term head;         Term[] body;     }      Term[] predicates;     Rule[] rules;      function t(string memory value)                                                                             internal returns (Term memory) {}     function t(string memory value, Term memory term1)                                                          internal returns (Term memory) {}     function t(string memory value, Term memory term1, Term memory term2)                                       internal returns (Term memory) {}     function t(string memory value, Term memory term1, Term memory term2, Term memory term3)                    internal returns (Term memory) {}     function t(string memory value, Term memory term1, Term memory term2, Term memory term3, Term memory term4) internal returns (Term memory) {}      function list()                                                                           internal returns (Term memory) {}     function list(Term memory term1)                                                          internal returns (Term memory) {}     function list(Term memory term1, Term memory term2)                                       internal returns (Term memory) {}     function list(Term memory term1, Term memory term2, Term memory term3)                    internal returns (Term memory) {}     function list(Term memory term1, Term memory term2, Term memory term3, Term memory term4) internal returns (Term memory) {}      function rule(Term memory head, Term memory body1)                                                          internal returns (Rule memory) {}     function rule(Term memory head, Term memory body1, Term memory body2)                                       internal returns (Rule memory) {}     function rule(Term memory head, Term memory body1, Term memory body2, Term memory body3)                    internal returns (Rule memory) {}     function rule(Term memory head, Term memory body1, Term memory body2, Term memory body3, Term memory body4) internal returns (Rule memory) {}      function def(Term memory predicate) internal { /* predicates.push(...); */ }     function def(Rule memory rule)      internal { /* rules.push(...); */ } }  contract PrologExample is PrologContract {     constructor() {         /*         % Atom         adam.         eve.          % Predicate         man(adam).         man(peter).         man(paul).          woman(mary).         woman(eve).          parent(adam, peter).         parent(eve,  peter).         parent(adam, paul).         parent(mary, paul).          % Rule         father(F, C) :- man(F),   parent(F,C).         mother(M, C) :- woman(M), parent(M,C).          % Wildcard         is_father(F) :- father(F, _).         is_mother(M) :- mother(M, _).          % Operator         siblings(A, B) :- parent(P, A), parent(P, B), A = B.          % Multiple definitions         human(H) :- man(H).         human(H) :- woman(H).          % Recursive rule         descendant(D, A) :- parent(A, D).         descendant(D, A) :- parent(P, D), descendant(P, A).          % Nesting         make_date(Y, M, D, date(Y, M, D)).          % Arithmetic         get_year(date(Y, _, _), Y).         set_year(Y, date(_, M, D), date(Y, M, D)).         next_year(Today, NextYear) :- get_year(Today, Y), NY is Y + 1, set_year(NY, Today, NextYear).          % List         [].         head(H, [H|_]).         tail(T, [_|T]).         */          Term memory adam  = t("adam");         Term memory peter = t("peter");         Term memory paul  = t("paul");         Term memory eve   = t("eve");         Term memory mary  = t("mary");          Term memory A  = t("A");         Term memory B  = t("B");         Term memory C  = t("C");         Term memory D  = t("D");         Term memory H  = t("H");         Term memory F  = t("F");         Term memory M  = t("M");         Term memory P  = t("P");         Term memory T  = t("T");         Term memory Y  = t("Y");         Term memory NY  = t("NY");         Term memory Today  = t("Today");         Term memory NextYear  = t("NextYear");         Term memory _  = t("_");          def(adam);         def(eve);          def(t("man", adam));         def(t("man", peter));         def(t("man", paul));          def(t("woman", mary));         def(t("woman", eve));          def(t("parent", adam, peter));         def(t("parent", eve,  peter));         def(t("parent", adam, paul));         def(t("parent", adam, paul));          def(rule(t("father", F, C),             t("man",    F),             t("parent", F, C)         ));         def(rule(t("mother", t("M"), t("C")),             t("woman",  M),             t("parent", M, C)         ));          def(rule(t("is_father", F), t("father", F, _)));         def(rule(t("is_mother", M), t("mother", M, _)));          def(rule(t("siblings", A, B),             t("parent", P, A),             t("parent", P, B),             t("\=", A, B)         ));          def(rule(t("human", H), t("man",   H)));         def(rule(t("human", H), t("woman", H)));          def(rule(t("descendant", D, A),             t("parent", A, D)         ));         def(rule(t("descendant", D, A),             t("parent", P, D),             t("descendant", P, A)         ));          def(t("make_date", Y, M, D, t("date", Y, M, D)));          def(t("get_year", t("date", Y, _, _), Y));         def(t("set_year", Y, t("date", _, M, D), t("date", Y, M, D)));         def(rule(t("next_year", Today, NextYear),             t("get_year", Today, Y),             t("is", NY, t("+", Y, t("1"))),             t("get_year", NY, Today, NextYear)         ));          def(list());         def(t("head", H, list(H, t("|"), _)));         def(t("tail", T, list(_, t("|"), T)));     } }

SolPrologV2

用坚固的文字写的序言引擎。

pragma solidity ^0.7.0;  // SPDX-License-Identifier: GPLv3  contract PrologContract {     struct Term {         string value;      // If empty, term is a list, otherwise it's a predicate.                            // value can represent an atom, variable, | or _.         Term[] children;     }      struct Rule {         Term head;         Term[] body;     }      Term[] predicates;     Rule[] rules;      function t(string memory value)                                                                             internal returns (Term memory) {}     function t(string memory value, Term memory term1)                                                          internal returns (Term memory) {}     function t(string memory value, Term memory term1, Term memory term2)                                       internal returns (Term memory) {}     function t(string memory value, Term memory term1, Term memory term2, Term memory term3)                    internal returns (Term memory) {}     function t(string memory value, Term memory term1, Term memory term2, Term memory term3, Term memory term4) internal returns (Term memory) {}      function list()                                                                           internal returns (Term memory) {}     function list(Term memory term1)                                                          internal returns (Term memory) {}     function list(Term memory term1, Term memory term2)                                       internal returns (Term memory) {}     function list(Term memory term1, Term memory term2, Term memory term3)                    internal returns (Term memory) {}     function list(Term memory term1, Term memory term2, Term memory term3, Term memory term4) internal returns (Term memory) {}      function rule(Term memory head, Term memory body1)                                                          internal returns (Rule memory) {}     function rule(Term memory head, Term memory body1, Term memory body2)                                       internal returns (Rule memory) {}     function rule(Term memory head, Term memory body1, Term memory body2, Term memory body3)                    internal returns (Rule memory) {}     function rule(Term memory head, Term memory body1, Term memory body2, Term memory body3, Term memory body4) internal returns (Rule memory) {}      function def(Term memory predicate) internal { /* predicates.push(...); */ }     function def(Rule memory rule)      internal { /* rules.push(...); */ } }  contract PrologExample is PrologContract {     constructor() {         /*         % Atom         adam.         eve.          % Predicate         man(adam).         man(peter).         man(paul).          woman(mary).         woman(eve).          parent(adam, peter).         parent(eve,  peter).         parent(adam, paul).         parent(mary, paul).          % Rule         father(F, C) :- man(F),   parent(F,C).         mother(M, C) :- woman(M), parent(M,C).          % Wildcard         is_father(F) :- father(F, _).         is_mother(M) :- mother(M, _).          % Operator         siblings(A, B) :- parent(P, A), parent(P, B), A = B.          % Multiple definitions         human(H) :- man(H).         human(H) :- woman(H).          % Recursive rule         descendant(D, A) :- parent(A, D).         descendant(D, A) :- parent(P, D), descendant(P, A).          % Nesting         make_date(Y, M, D, date(Y, M, D)).          % Arithmetic         get_year(date(Y, _, _), Y).         set_year(Y, date(_, M, D), date(Y, M, D)).         next_year(Today, NextYear) :- get_year(Today, Y), NY is Y + 1, set_year(NY, Today, NextYear).          % List         [].         head(H, [H|_]).         tail(T, [_|T]).         */          Term memory adam  = t("adam");         Term memory peter = t("peter");         Term memory paul  = t("paul");         Term memory eve   = t("eve");         Term memory mary  = t("mary");          Term memory A  = t("A");         Term memory B  = t("B");         Term memory C  = t("C");         Term memory D  = t("D");         Term memory H  = t("H");         Term memory F  = t("F");         Term memory M  = t("M");         Term memory P  = t("P");         Term memory T  = t("T");         Term memory Y  = t("Y");         Term memory NY  = t("NY");         Term memory Today  = t("Today");         Term memory NextYear  = t("NextYear");         Term memory _  = t("_");          def(adam);         def(eve);          def(t("man", adam));         def(t("man", peter));         def(t("man", paul));          def(t("woman", mary));         def(t("woman", eve));          def(t("parent", adam, peter));         def(t("parent", eve,  peter));         def(t("parent", adam, paul));         def(t("parent", adam, paul));          def(rule(t("father", F, C),             t("man",    F),             t("parent", F, C)         ));         def(rule(t("mother", t("M"), t("C")),             t("woman",  M),             t("parent", M, C)         ));          def(rule(t("is_father", F), t("father", F, _)));         def(rule(t("is_mother", M), t("mother", M, _)));          def(rule(t("siblings", A, B),             t("parent", P, A),             t("parent", P, B),             t("\=", A, B)         ));          def(rule(t("human", H), t("man",   H)));         def(rule(t("human", H), t("woman", H)));          def(rule(t("descendant", D, A),             t("parent", A, D)         ));         def(rule(t("descendant", D, A),             t("parent", P, D),             t("descendant", P, A)         ));          def(t("make_date", Y, M, D, t("date", Y, M, D)));          def(t("get_year", t("date", Y, _, _), Y));         def(t("set_year", Y, t("date", _, M, D), t("date", Y, M, D)));         def(rule(t("next_year", Today, NextYear),             t("get_year", Today, Y),             t("is", NY, t("+", Y, t("1"))),             t("get_year", NY, Today, NextYear)         ));          def(list());         def(t("head", H, list(H, t("|"), _)));         def(t("tail", T, list(_, t("|"), T)));     } }

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/16590.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 !
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » SolPrologV2 – 独白2区块链毕设代写

提供最优质的资源集合

立即查看 了解详情