Debian Codegraph @

rhino/examples/unique.js

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 // unique.js: read the contents of a file and print out the unique lines
8
9 defineClass("File")
10
11 // "arguments[0]" refers to the first argument at the command line to the
12 // script, if present. If not present, "arguments[0]" will be undefined,
13 // which will cause f to read from System.in.
14 var f = new File(arguments[0]);
15 var o = {}
16 var line;
17 while ((line = f.readLine()) != null) {
18 // Use JavaScript objects' inherent nature as an associative
19 // array to provide uniqueness
20 o[line] = true;
21 }
22 for (i in o) {
23 print(i);
24 }