File: context-lua.lp

package info (click to toggle)
gringo 5.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,128 kB
  • sloc: cpp: 210,867; ansic: 37,507; python: 11,271; yacc: 825; javascript: 627; sh: 368; xml: 364; makefile: 102
file content (30 lines) | stat: -rw-r--r-- 468 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#script (lua)

State = { }
State.__index = State

function State.new(val)
    local x = { value = val }
    setmetatable(x, State)
    return x
end

function State:test(value)
    return self.value + value.number
end

function State:on_model(m)
    print(tostring(m))
end

function State:run(prg)
    prg:ground({{"base", {}}}, self)
    prg:solve{on_model=function (...) self:on_model(...) end}
end

function main(prg)
    x = State.new(21)
    x:run(prg)
end

#end.