list:
LIST
OF
REF => {
op: IO.ROPE ← NARROW[list.first];
wiggle: BOOL ← op.Equal["~"]; -- highest
infix: BOOL ← op.Equal["*"] OR op.Equal["+"] OR wiggle;
args: LIST OF IO.ROPE ← NIL;
FOR list ← list.rest, list.rest
WHILE list#
NIL
DO
args ← CONS[ToRopeBasic[list.first, ~infix], args] ENDLOOP;
IF wiggle THEN {IF args.rest#NIL THEN SIGNAL BadTree; RETURN[Rope.Cat["~", args.first]]};
IF ~(top AND infix) THEN rope ← ")"; -- cross or function
FOR args ← args, args.rest
WHILE args#
NIL
DO
rope ← Rope.Cat[args.first, rope];
IF args.rest#
NIL
THEN {
IF infix
THEN rope ← Rope.Cat[" ", op, " ", rope]
ELSE rope ← Rope.Cat[", ", rope]} ENDLOOP;
IF ~(top AND infix) THEN rope ← Rope.Cat["(", rope];
IF ~infix THEN rope ← Rope.Cat[op, rope]};