How to parse expressions with parenthesis

From: alex (alexmartin_6_at_yahoo.com)
Date: 03/27/04

  • Next message: Bart Demoen: "Re: Sublists question"
    Date: 27 Mar 2004 11:55:26 -0800
    
    

    Hi everybody.
     I'm new to prolog programming and I trying to make a program to
    simplify algebraic expressions. My problem is the following:
      I need to parse a term inside parenthesis, like X+10 in the
    following expression: (x+10)*x, but when I use some clauses to get the
    content, like:
     
    getTerms( (Term1)*Term2, Term1,Term2). %It just complains.
    getTerms(Term1*(Term2), Term1, Term2). %It just ignores parenthesis.

    Have you any idea about the way to make a clause that answer to the
    following query:

    ?- getTerms( (x+10)*x, Term1, Term2).

    In this way...

    Term1 = x+10
    Term2 = x

    Thanks all of you in advance.

    Alex


  • Next message: Bart Demoen: "Re: Sublists question"