fork download
  1. process.stdin.resume()
  2. process.stdin.setEncoding('utf8')
  3. var rl = require("readline").createInterface(process.stdin, process.stdout)
  4.  
  5. String.prototype.words = function() { return this.match(/\S+/g) || [] }
  6. function words(f) { return function (l) { l.words().forEach(f) } }
  7. function uniq(f) {
  8. var seen = {}
  9. return function (w) { if (!(w in seen)) { seen[w] = true; f(w) } }
  10. }
  11. rl.on('line', words(uniq(function(w) { console.log(w) })))
Success #stdin #stdout 0.07s 11184KB
stdin
aaa bbb ccc bbb aaa
ddd ccc eee aaa fff
fff ccc aaa ggg eee
stdout
aaa
bbb
ccc
ddd
eee
fff