Thread: Right associative??

  1. #1
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489

    Right associative??

    Please read the following link:

    http://en.wikipedia.org/wiki/Shunting_yard_algorithm

    ... o1 is associative or left-associative and its precedence is less than (lower precedence) or equal to that of o2, or
    o1 is right-associative and its precedence is less than (lower precedence) that of o2 ...
    What is the meaning of 'right-associative' and 'right-to-left evaluation', please?

    I've wrote the algorithm and the last output is:
    3 4 2 * 1 5 - 2 ^ 3 ^ / +

    Something terribly wrong... T_T
    Last edited by audinue; 07-05-2008 at 02:52 PM.

  2. #2
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    If two operators have the same precedence,then which operator to be evaluated first is determined by the associativity rule.
    right associativity- the opearators are evaluted from right to left
    eg a=b=3;
    here both '=' have the same priority thus b=3 is assigned first due to right associativity
    left associativity- the opearators are evaluted from left to right
    eg a=3/2*5;
    both '/' and '*' have the same precedence and due to left ass. 3/2 is evaluated first.
    Hope u understand

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using Associative Arrays..
    By jewelz in forum C++ Programming
    Replies: 8
    Last Post: 03-23-2009, 04:02 PM
  2. How do maps keep elements ordered?
    By nucleon in forum C++ Programming
    Replies: 7
    Last Post: 11-08-2008, 03:39 PM
  3. How to use associative arrays in C
    By sreenu.daram in forum C Programming
    Replies: 2
    Last Post: 11-13-2005, 08:38 AM
  4. initialising an associative container
    By sayz0 in forum C++ Programming
    Replies: 5
    Last Post: 10-17-2001, 12:10 AM
  5. Using the STL map for one's own class
    By SilentStrike in forum C++ Programming
    Replies: 2
    Last Post: 09-21-2001, 08:06 PM