as is
without express or implied warranty. Export of this
software outside of the United States of America may require an
export license.
$Id: TextUtilsFmt.m3.html,v 1.3 2010-04-29 17:17:56 wagner Exp $
MODULETextUtilsFmt EXPORTSTextUtils ; IMPORT TextList; IMPORT Text; PROCEDUREInfixFormat (sep : TEXT; list : TextList.T; ignoreNulls : BOOLEAN ) : TEXT = VAR res := ""; BEGIN IF ignoreNulls THEN list := StripNulls(list) END; WHILE list # NIL DO res := res & list.head; IF list.tail # NIL THEN res := res & sep END; list := list.tail END; RETURN res END InfixFormat; PROCEDUREStripNulls (list : TextList.T) : TextList.T = VAR res, strip : TextList.T := NIL; BEGIN WHILE list # NIL DO IF NOT Text.Equal("", list.head) THEN strip := TextList.Cons(list.head,strip) END; list := list.tail END; WHILE strip # NIL DO res := TextList.Cons(strip.head,res); strip := strip.tail END; RETURN res END StripNulls; BEGIN END TextUtilsFmt.