Skip to content

Commit

Permalink
Remove unused op_args
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonwillard committed Feb 24, 2020
1 parent d8c1d75 commit beea559
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
16 changes: 3 additions & 13 deletions kanren/assoccomm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,22 @@

from toolz import sliding_window

from unification import isvar, var, reify, unify
from unification import reify, unify, var

from cons.core import ConsError, ConsPair, car, cdr
from cons.core import ConsPair, car, cdr

from etuples import etuple

from .core import conde, eq, ground_order, lall, succeed
from .goals import itero, permuteo
from .facts import Relation
from .graph import term_walko
from .term import term, operator, arguments
from .term import term

associative = Relation("associative")
commutative = Relation("commutative")


def op_args(x):
"""Break apart x into an operation and tuple of args."""
if isvar(x):
return None, None
try:
return operator(x), arguments(x)
except (ConsError, NotImplementedError):
return None, None


def flatten_assoc_args(op_predicate, items):
for i in items:
if isinstance(i, ConsPair) and op_predicate(car(i)):
Expand Down
7 changes: 0 additions & 7 deletions tests/test_assoccomm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
eq_assoc,
eq_assoccomm,
assoc_args,
op_args,
flatten_assoc_args,
assoc_flatten,
)
Expand Down Expand Up @@ -84,12 +83,6 @@ def results(g, s=None):
return tuple(g(s))


def test_op_args():
assert op_args(var()) == (None, None)
assert op_args(add(1, 2, 3)) == (Add, (1, 2, 3))
assert op_args("foo") == (None, None)


def test_eq_comm():
x, y, z = var(), var(), var()

Expand Down

0 comments on commit beea559

Please sign in to comment.