Skip to content

Commit

Permalink
Merged in unstable/SW-17379-improve-functor-representation (pull requ…
Browse files Browse the repository at this point in the history
…est yuce#3)

SW-17379 Improve functor representation in lists

Approved-by: Guglielmo Gemignani <gemignani@magazino.eu>
  • Loading branch information
Omar Abdelwanis committed Mar 20, 2019
2 parents 5a02e25 + 9e0dc2b commit 1546b4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyswip/prolog.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def query(cls, query, maxresult=-1, catcherrors=True, normalize=True):


def normalize_values(values):
from pyswip.easy import Atom
if isinstance(values, Atom):
from pyswip.easy import Atom, Functor
if isinstance(values, (Atom, Functor)):
return values.value
elif isinstance(values, dict):
return {key: normalize_values(v) for key, v in values.items()}
Expand Down
5 changes: 5 additions & 0 deletions tests/test_prolog.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def test_prolog_strings(self):
p.assertz('some_string_fact("abc")')
self.assertEqual([{"S": b"abc"}], list(p.query("some_string_fact(S)")))

def test_prolog_functor_in_list(self):
p = pl.Prolog()
p.assertz('f([g(a,b),h(a,b,c)])')
self.assertEqual([{"L": ['g(a, b)', 'h(a, b, c)']}], list(p.query("f(L)")))

def test_prolog_read_file(self):
"""
See: https://github.com/yuce/pyswip/issues/10
Expand Down

0 comments on commit 1546b4c

Please sign in to comment.