Jump to content

The Science of Programming/SwayPresentations/Objects/right

From Wikibooks, open books for an open world
   function right(items)
       {
       var slots = items . constructor . parameters;
       var lhs = slots[0];
       var rhs = slots[1];
       if (type(items . (lhs)) == :OBJECT
       && items . constructor == items . (lhs) . constructor)
           {
           var x = items . (lhs);
           items . (lhs) = x . (rhs);
           x . (rhs) = items;
           right(x);
           }
       else
           {
           items;
           }
       }