Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

22
LINES

< > BotCompany Repo | #1002830 // Test class Prolog 4 (more complex rule parsing)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (4565L/30K/95K).

!752

static S code = [=[
  
  [
    if   [X < is < a < Y]
    and  [a < Y < has < a < Z]
    then [X < has < a < Z]
  ]
  
  [ mark < is < a < guy ]
  [ a < guy < has < a < gun ]
  
]=];

p {
  new Prolog p;
  p.upperCaseVariables = true;
  p.showStuff = true;
  p.addClauses(snlToTree(code));
  printStructure(p.solve(snlToTree("mark < has < a < X"))); // prints X = gun!
}

Author comment

Began life as a copy of #1002829

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002830
Snippet name: Test class Prolog 4 (more complex rule parsing)
Eternal ID of this version: #1002830/1
Text MD5: 459c373deb4cfc4f2003160e7ba12114
Transpilation MD5: af019328626573656ea9e6211ebebeb3
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-03-03 01:28:29
Source code size: 396 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 601 / 646
Referenced in: #1002832 - Test rewriting using prolog engine (OK)
#1002833 - A Thought Engine in JavaX
#1002844 - Test Prolog with NL
#3000382 - Answer for ferdie (>> t = 1, f = 0)