General FizzBuzz: Difference between revisions
→{{header|Java}}
Line 1,830:
*/
public static void main(String[] args) {
BiFunction<Integer,String,String> formatter = (i,printThis) -> "".equals(printThis)?Integer.toString(i):printThis;▼
▲ List<Function<Integer,String>> cycle_functions = new ArrayList<>();
List<Function<Integer,String>> cycle_functions = Stream.of(args)
.map(make_cycle_function::apply)
.collect(Collectors.toList());
Function<Integer,String> moduloTesters = i -> cycle_functions.stream()
.map(fcn->fcn.apply(i))
.collect(Collectors.joining());
BiFunction<Integer,String,String> formatter =
▲
Function<Integer,String> fizzBuzz = i -> formatter.apply(i,moduloTesters.apply(i));
▲ .filter(arg->arg.contains("="))
▲ String[] parts = arg.split("=");
▲ cycle_functions.add(j-> j%(Integer.parseInt(parts[0]))==0?parts[1]:"");
IntStream.rangeClosed(0,Integer.parseInt(args[args.length-1]))
.mapToObj(Integer::valueOf)
|