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

22
LINES

< > BotCompany Repo | #1005185 // prolog_tryToDeriveLastLine

JavaX fragment (include)

static int prolog_tryToDeriveLastLine_maxSteps = 1000;

static bool prolog_tryToDeriveLastLine(S data) {
  // make Prolog interpreter
  new Prolog p;
  p.upperCaseVariables = true;
  //p.showStuff = true;
  p.addTheory(dropLastLine(rtrim(data)), programID());
  Lisp pivot = nlParse(lastLine(rtrim(data)));
  // try to derive last statement from the rest
  new LinkedHashSet<Lisp> set;
  Collector<Lisp> c = limitedSearchCollector(set, prolog_tryToDeriveLastLine_maxSteps, pivot);
  p.rewriteInto(c);
  print("Found " + nl(set, "statement") + ":");
  //printIndent(snlAllToText(l));
  printIndent(nlUnparseLines(asList(set)));
  print();
  print("Pivot statement: " + nlUnparse(pivot));
  bool found = set.contains(pivot);
  print("Pivot statement found? " + yn(found));
  ret found;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005185
Snippet name: prolog_tryToDeriveLastLine
Eternal ID of this version: #1005185/1
Text MD5: 74a516339c03716afda18551e08f8e2c
Author: stefan
Category: javax / prolog
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-10-19 16:03:51
Source code size: 806 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 419 / 435
Referenced in: [show references]