Search code examples
prolog

Same predicate with same number of arguments, but different arguments type


I want to write a predicate that takes these arguments: predicate(X, Y). predicate(X, (Y, Z)). (Second parameter can be an atom or a pair). Is it possible to do this only by pattern matching?


Solution

  • You cannot specify that a parameter is atomic using just pattern matching; you'd need a predicate to test for this.