Create a new Reducer object
@param txt The raw reduce JavaScript source
@return The compiled reduce function
354734
public static Reducer create(String txt) {
        Context cx = Context.enter();
        try {
            return new Reducer(txt, cx);
        } finally {
            Context.exit();
        }
    }
496853
def run_reducer(self, stdin=sys.stdin, stdout=sys.stdout):
        
        self.init_hadoop()
        self.init_reducer()
        outputs = self._reduce_input(self.internal_reader((line[:-1] for line in stdin)), self.reducer, self.final_reducer)
        self.writer(outputs, stdout)
438846
@Nonnull
    public <T> Word<T> transform(Function<? super I, ? extends T> transformer) {
        int len = length();
        Object[] array = new Object[len];
        int i = 0;
        for (I symbol : this) {
            array[i++] = transformer.apply(symbol);
        }
        return new SharedWord<>(array);
    }
1316085
static <V> TextProcessor<V> create(TextElement<V> element) {

        return new TextProcessor<>(
            element, false, Locale.ROOT, TextWidth.WIDE, OutputContext.FORMAT, Leniency.SMART, 0);

    }
1336274
private static Object reduceMethod(Context cx, int id, Scriptable scope,
                                       Scriptable thisObj, Object[] args)
    {
        Scriptable o = ScriptRuntime.toObject(cx, scope, thisObj);

        long length = getLengthProperty(cx, o, false);
        Object callbackArg = args.length > 0 ? args[0] : Undefined.instance;
        if (callbackArg == null || !(callbackArg instanceof Function)) {
            throw ScriptRuntime.notFunctionError(callbackArg);
        }
        Function f = (Function) callbackArg;
        Scriptable parent = ScriptableObject.getTopLevelScope(f);
        // hack to serve both reduce and reduceRight with the same loop
        boolean movingLeft = id == Id_reduce;
        Object value = args.length > 1 ? args[1] : Scriptable.NOT_FOUND;
        for (long i = 0; i < length; i++) {
            long index = movingLeft ? i : (length - 1 - i);
            Object elem = getRawElem(o, index);
            if (elem == Scriptable.NOT_FOUND) {
                continue;
            }
            if (value == Scriptable.NOT_FOUND) {
                // no initial value passed, use first element found as inital value
                value = elem;
            } else {
                Object[] innerArgs = { value, elem, index, o };
                value = f.call(cx, parent, parent, innerArgs);
            }
        }
        if (value == Scriptable.NOT_FOUND) {
            // reproduce spidermonkey error message
            throw ScriptRuntime.typeError0("msg.empty.array.reduce");
        }
        return value;
    }
935839
public static R create(String text) {
        R run = factory.createR();
        setText(run, text);
        return run;
    }
113485
public static <T> Reducer<PersistentList<T>,T> toPersistentListReversed() {
        return Reducer.fromMonoid(Monoids.concatPersistentCollection(Seq.empty()), a -> Seq.of(a));
    }
202723
function reportReducer (summary, report) {
  summary.errors += report.error.count
  summary.warnings += report.warn.count
  return summary
}
1217390
public static PrimitiveObject hadoop2Primitive(Writable object) {
        if (object instanceof NullWritable) {
            return new PrimitiveObject(NULL, null);
        }

        if (object instanceof ByteWritable) {
            return new PrimitiveObject(BYTE, ((ByteWritable) object).get());
        } else if (object instanceof IntWritable) {
            return new PrimitiveObject(INTEGER, ((IntWritable) object).get());
        } else if (object instanceof LongWritable) {
            return new PrimitiveObject(LONG, ((LongWritable) object).get());
        } else if (object instanceof DoubleWritable) {
            return new PrimitiveObject(DOUBLE, ((DoubleWritable) object).get());
        } else if (object instanceof FloatWritable) {
            return new PrimitiveObject(FLOAT, ((FloatWritable) object).get());
        } else if (object instanceof BooleanWritable) {
            return new PrimitiveObject(BOOLEAN, ((BooleanWritable) object).get());
        } else if (object instanceof Text) {
            return new PrimitiveObject(STRING, ((Text) object).toString());
        } else if (object instanceof ArrayWritable) {
            ArrayWritable aw = (ArrayWritable) object;
            if (aw.get().length == 0) {
                return new PrimitiveObject(ARRAY, true, STRING, new ArrayList<String>());
            }

            int type = NULL;
            List<Object> l = new ArrayList<Object>();
            for (Writable w : aw.get()){
                PrimitiveObject no = hadoop2Primitive(w);
                type = no.getType();
                l.add(no.getObject());
            }

            return new PrimitiveObject(ARRAY, true, type, l);
        } else if (object instanceof MapWritable) {
            MapWritable mw = (MapWritable) object;
            if (mw.size() == 0) {
                return new PrimitiveObject(MAP, true, STRING, STRING, new HashMap<String, String>());
            }

            int keyType = NULL;
            int valueType = NULL;
            Map<Object, Object> m = new HashMap<Object, Object>();
            for (Entry<Writable, Writable> entry : mw.entrySet()){
                PrimitiveObject keyNo = hadoop2Primitive(entry.getKey());
                PrimitiveObject valueNo = hadoop2Primitive(entry.getValue());
                keyType = keyNo.getType();
                valueType = valueNo.getType();
                m.put(keyNo.getObject(), valueNo.getObject());
            }

            return new PrimitiveObject(MAP, true, keyType, valueType, m);
        }

        throw new ClassCastException("cast object not found");
    }
30251
private static <T, K> org.apache.flink.api.common.operators.SingleInputOperator<?, T, ?> translateSelectorFunctionReducer(
		SelectorFunctionKeys<T, ?> rawKeys,
		ReduceFunction<T> function,
		TypeInformation<T> inputType,
		String name,
		Operator<T> input,
		int parallelism,
		CombineHint hint) {
		@SuppressWarnings("unchecked")
		final SelectorFunctionKeys<T, K> keys = (SelectorFunctionKeys<T, K>) rawKeys;

		TypeInformation<Tuple2<K, T>> typeInfoWithKey = KeyFunctions.createTypeWithKey(keys);
		Operator<Tuple2<K, T>> keyedInput = KeyFunctions.appendKeyExtractor(input, keys);

		PlanUnwrappingReduceOperator<T, K> reducer = new PlanUnwrappingReduceOperator<>(function, keys, name, inputType, typeInfoWithKey);
		reducer.setInput(keyedInput);
		reducer.setParallelism(parallelism);
		reducer.setCombineHint(hint);

		return KeyFunctions.appendKeyRemover(reducer, keys);
	}
3515
function reportReducer (linter, summary, filePath) {
  const fileContents = fs.readFileSync(filePath, {encoding: 'utf8'})
  const file = linter.process(fileContents)

  if (file.messages.length !== 0) {
    this.printFilePath(filePath)

    file.messages.forEach((message) => {
      const severity = message.fatal ? 'error' : 'warning'
      this.printLintItem(message.line, message.column, severity, message.message, message.ruleId)

      if (message.fatal) {
        summary.errors += 1
      } else {
        summary.warnings += 1
      }
    })

    console.log('') // logging empty line
  }

  return summary
}
22690
function arrayReduce (array, callback, initialValue) {
  if (array) {
    var len, reduceMethod
    var index = 0
    var context = this
    var previous = initialValue
    var isInitialVal = arguments.length > 2
    var keyList = baseExports.keys(array)
    if (array.length && array.reduce) {
      reduceMethod = function () {
        return callback.apply(context, arguments)
      }
      if (isInitialVal) {
        return array.reduce(reduceMethod, previous)
      }
      return array.reduce(reduceMethod)
    }
    if (isInitialVal) {
      index = 1
      previous = array[keyList[0]]
    }
    for (len = keyList.length; index < len; index++) {
      previous = callback.call(context, previous, array[keyList[index]], index, array)
    }
    return previous
  }
}
366307
function readReduceDeclarations(jsonConfigIn = '') {
		if (jsonConfigIn) {
			jsonConfig = jsonConfigIn;
			reduceRulesListName = jsonConfig.declaration_names;
			reduceRulesListSelector = jsonConfig.selectors;

			switch (typeof reduceRulesListSelector) {
				case 'string':
					if (reduceRulesListSelector.length) {
						reduceRulesListSelector = reduceRulesListSelector.replace(/^\s+|\s+$/g,'');
						reduceRulesListSelector = reduceRulesListSelector.replace(/\r?\n|\r/g,'');
						reduceRulesListSelector = reduceRulesListSelector.split(',');
						reduceRulesListSelectorCount = reduceRulesListSelector.length;
					} else {
						reduceRulesListSelector = null;
					}
					break;
				case 'object': 
					// reduceRulesListSelectorPName
					var tmp = [];
					for (var i in reduceRulesListSelector) {
						tmp.push(i);
						reduceRulesListSelectorPName[i] = reduceRulesListSelector[i].replace(/^\s+|\s+$/g,'').replace(/\r?\n|\r/g,'').split(',');
					}
					reduceRulesListSelector = tmp;
					reduceRulesListSelectorCount = reduceRulesListSelector.length;
					break;
			}
			
			//by name
			if (reduceRulesListName.length) {
					
				if (typeof reduceRulesListName == 'string') {
					
					reduceRulesListName = reduceRulesListName.replace(/^\s+|\s+$/g,'');
					reduceRulesListName = reduceRulesListName.split(',');
					reduceRulesListNameCount = reduceRulesListName.length;
				} else if (typeof reduceRulesListName == 'object' || typeof reduceRulesListName == 'array') {
					
					reduceRulesListName = reduceRulesListName.filter(function(entry) { return entry.trim() !== ''; });
					reduceRulesListNameCount = reduceRulesListName.length;
				}
			} else {
				reduceRulesListName = null;
			}

			hasReadReduceDeclarations = true;
			CPEVENTS.emit('CONFIG_READ_REDUCE_PROPS_END', OPTIONS);

		} else {

			var jsonConfig = '';
			readStream = fs.createReadStream(CONFIG_REDUCE_DECLARATIONS, 'utf8');	
			readStream.on('data', function(chunk) {  
				jsonConfig += chunk;
			}).on('end', function() {

				jsonConfig = JSON.parse(jsonConfig);

				reduceRulesListName = jsonConfig.declaration_names;
				reduceRulesListSelector = jsonConfig.selectors;

				switch (typeof reduceRulesListSelector) {
					case 'string':
						if (reduceRulesListSelector.length) {
							reduceRulesListSelector = reduceRulesListSelector.replace(/^\s+|\s+$/g,'');
							reduceRulesListSelector = reduceRulesListSelector.replace(/\r?\n|\r/g,'');
							reduceRulesListSelector = reduceRulesListSelector.split(',');
							reduceRulesListSelectorCount = reduceRulesListSelector.length;
						} else {
							reduceRulesListSelector = null;
						}
						break;
					case 'object': 
						// reduceRulesListSelectorPName
						var tmp = [];
						for (var i in reduceRulesListSelector) {
							tmp.push(i);
							reduceRulesListSelectorPName[i] = reduceRulesListSelector[i].replace(/^\s+|\s+$/g,'').replace(/\r?\n|\r/g,'').split(',');
						}
						reduceRulesListSelector = tmp;
						reduceRulesListSelectorCount = reduceRulesListSelector.length;
						break;
				}
				
				//by name
				if (reduceRulesListName.length) {
						
					if (typeof reduceRulesListName == 'string') {
						
						reduceRulesListName = reduceRulesListName.replace(/^\s+|\s+$/g,'');
						reduceRulesListName = reduceRulesListName.split(',');
						reduceRulesListNameCount = reduceRulesListName.length;
					} else if (typeof reduceRulesListName == 'object' || typeof reduceRulesListName == 'array') {
						
						reduceRulesListName = reduceRulesListName.filter(function(entry) { return entry.trim() !== ''; });
						reduceRulesListNameCount = reduceRulesListName.length;
					}
				} else {
					reduceRulesListName = null;
				}

				hasReadReduceDeclarations = true;
				CPEVENTS.emit('CONFIG_READ_REDUCE_PROPS_END', OPTIONS);


			}).on('error', function(e) {
				CPEVENTS.emit('CONFIG_READ_REDUCE_PROPS_ERROR', OPTIONS);
				console.log(error("Reduce Properties Config File read error: Something went wrong while reading the file, check your config_reduce_declarations.json and please try again."));
				console.log(e);
				process.exit(1);
			});
		}

	}
1301946
public static Stream<String> buildTokenStream(String text,
            String delimiter) {
        return JMStream.buildStream(delimiter == null ? new StringTokenizer(
                text) : new StringTokenizer(text, delimiter))
                .map(o -> (String) o);
    }
1227047
public static <T> Reducer<PersistentList<T>,T> toPersistentVector() {
        return Reducer.fromMonoid(Monoids.concatPersistentCollection(Vector.empty()), a -> Vector.of(a));
    }
464223
public static <T> Reducer<PersistentSet<T>,T> toPersistentSet() {
        return Reducer.fromMonoid(Monoids.concatPersistentCollection(HashSet.empty()), a -> HashSet.of(a));
    }
680584
def create(fmt):
        
        w = None
        if fmt == 'tree':
            w = AsciiTreeGraphRenderer()
        elif fmt == 'dot':
            w = DotGraphRenderer(image_format='dot')
        elif fmt == 'png':
            w = DotGraphRenderer(image_format='png')
        elif fmt == 'ndot':
            w = NativeDotGraphRenderer()
        elif fmt == 'obo':
            w = OboFormatGraphRenderer()
        elif fmt == 'obog':
            w = OboJsonGraphRenderer()
        else:
            w = SimpleListGraphRenderer()
        return w