Skip to content

Instantly share code, notes, and snippets.

@yuce
Created March 24, 2019 07:58
Show Gist options
  • Save yuce/34ef496c0bd884777f7cce897102a878 to your computer and use it in GitHub Desktop.
Save yuce/34ef496c0bd884777f7cce897102a878 to your computer and use it in GitHub Desktop.
PySWIP retract
>>> from pyswip import Prolog
>>> p = Prolog()
>>> p.assertz("foo(bar)")
>>> p.assertz("foo(bar)")
>>> list(p.query("foo(X)"))
[{'X': 'bar'}, {'X': 'bar'}]
>>> p.retract("foo(bar)")
>>> list(p.query("foo(X)"))
[{'X': 'bar'}]
>>> p.assertz("foo(bar)")
>>> list(p.query("foo(X)"))
[{'X': 'bar'}, {'X': 'bar'}]
>>> p.retractall("foo(bar)")
>>> list(p.query("foo(X)"))
[]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment