Difference between revisions of "JavaScript/Higher-order programming/Print.js"

From Spherical
Jump to: navigation, search
(syntax highlight)
(category only on noinclude)
 
Line 29: Line 29:
 
}();
 
}();
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
<noinclude>[[Category:Scripts]]</noinclude>

Latest revision as of 00:38, 15 June 2013

var Print = function () {
  var fullString = "";
 
  function clear() {
    fullString = "";
  }
 
  function print(value) {
    fullString += value.toString();
  }
 
  function printLine(value) {
    if (value)
      print(value);
    print("\n");
  }
 
  function display() {
    Abort(fullString + "\n");
  }
 
  return {
    clear: clear,
    print: print,
    printLine: printLine,
    display: display
  };
}();