An minimal example of/module for interfacing with clingo.js, an Emscripten-compiled Javascript port of Clingo (which was originally written in C++, and which you usually run as a program on the command line). This lets you run Clingo in the browser, without having to call out to a server!
Copy this entire directory to seed code for a new browser-based ASP project, or copy just clingo.js and clingon.js, and make sure to include them and jQuery in your html or Require dependencies.
Then, you can write your ASP code in .lp files, and name them in your call to clingon.loadASP (filename, callback)
.
See main.js
for examples of how to use clingon functions.
...to load separate .lp files using AJAX requests
Easy mode: include this line in your index.html:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
https://potassco.org/doc/start/
Clingo was made by the Potassco group (the Potsdam Answer Set Solving Collection) at the University of Potsdam. Clingo was first compiled into Javascript using Emscripten by Adam M. Smith, who was also a huge, generous force for teaching and advocating for Answer Set Programming for expressive computing in the Expressive Intelligence Studio at UCSC, where I first encountered it. The interface code in clingon.js was developed from code by Adam and Kate Compton, who is also a great advocate and inspiration.