I work with Prolog arithmetic and have a program that generates an abstract syntax tree like plus(num(1),num(2)) , which is just 1+2 . This is done using DCG. In this example, plus(num(1),num(2)) matches the list of prefixes [+,1,2] .
My problem is that I want to allow num(x) greater than 3. For example, num(4) allowed, but not num(1) .
I'm doing it:
num(num(4)) --> [4]. num(num(5)) --> [5]. num(num(6)) --> [6]. num(num(7)) --> [7].
etc .. but would like to do something like num(num(x)) --> [x]. for numbers greater than 3. Any idea on how to approach this problem?
source share