%mathpiper,def="ListToString"


//Retract("ListToString", *);


10 # ListToString(list_IsList)_(Length(list) = 0) <-- "";



20 # ListToString(list_IsList) <--
[
    Local(resultString, character);
    
    resultString := "";
    
    ForEach(element, list)
    [
        If(IsString(element), character := element, character := ToString(element));
        
        resultString := resultString : character;
    ];
    
    resultString;

];

%/mathpiper





%mathpiper_docs,name="ListToString",categories="User Functions;Lists (Operations)",access="experimental"
*CMD ListToString --- converts a list into a string
*STD
*CALL
	ListToString(list)

*PARMS

{list} -- a list to be converted into a string

*DESC
This function converts each of the elementes in a list into a string and then concatenates these
strings into a single string.

*E.G.
In> ListToString({a,b,c,d})
Result: "abcd"

*SEE StringToList
%/mathpiper_docs



