JavaScript/Higher-order programming/Print.js

From Spherical
Revision as of 00:38, 15 June 2013 by Apollolux (talk | contribs) (category only on noinclude)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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
  };
}();