%mathpiper,def="Echo"

//Retract("EchoInternal",*);

10 # EchoInternal(string_IsString) <--
[
  WriteString(string);
];

20 # EchoInternal(_item) <--
[
  Write(item);Space();
];






//Retract("Echo",*);

RulebaseListed("Echo",{firstParameter, parametersList});

//Handle no option call.
5 # Echo(_firstParameter) <-- Echo(firstParameter, {});


//Main routine.  It will automatically accept 1 or more option calls because the
//options come in a list.
10 # Echo(_firstParameter, parametersList_IsList) <--
[
    EchoInternal(firstParameter);
    ForEach(item,parametersList) EchoInternal(item);
    NewLine();
    
];


//Handle a single option call because the option does not come in a list for some reason.
20 # Echo(_firstParameter, _secondParameter) <-- Echo(firstParameter, {secondParameter});


//No argument Echo simply prints a newline.
Echo() := NewLine();



%/mathpiper

    %output,preserve="false"
      Result: True
.   %/output



%mathpiper_docs,name="Echo",categories="User Functions;Input/Output"
*CMD Echo --- high-level printing routine
*STD
*CALL
	Echo(item,item,item,...)

*PARMS

{item} -- the items to be printed


*DESC

If passed a single item, {Echo} will evaluate it and print it to the
current output, followed by a newline. If {item} is a string, it is
printed without quotation marks.

If {Echo} is called with a variable number of arguments, they will all
be printed with spaces inbetween them and finally a newline will be printed.

If no arguments are passed to {Echo}, it will simply output a newline.

{Echo} always returns {True}.

*E.G.
In> Echo(5+3);
Result: True
Side Effects:
8 


In> Echo("The square of two is ", 2*2);
Result: True
Side Effects:
The square of two is 4 


In> Echo({a,b,c});
Result: True
Side Effects:
{a,b,c} 

*SEE PrettyForm, Write, WriteString, RulebaseListed
%/mathpiper_docs

    %output,preserve="false"
      
.   %/output

