IO<Result<List<Integer>>>numbers=Console.print("Enter the given numbers: ")// print the first prompt
.flatMap(Console::readLine)// read the list of numbers in string form
.map(Countdown0::readNumbers);// convert it to a result of list of integers
IO<Result<Integer>>number=Console.print("Enter the target number: ")// print the second prompt
.flatMap(Console::readLine)// read a number in string form
.map(Countdown0::read);// convert it to result of integer
IO<Result<List<Expr>>>exprs=numbers.flatMap(ns->number.map(n->ns.flatMap(ns_->n.map(n_->solutions_(ns_,n_)))));// compute the solution to a result of list of Expr
returntitle.flatMap(x->exprs.flatMap(Console::printLine));// print the solution
}
/**
* Using imperative Java. This may be composed through imperative techniques such as calling in sequence,
* conditional execution (if...else, switch...case) and loops.
*/
publicstaticvoidmain2(){
System.out.println("\nCOUNTDOWN NUMBERS GAME SOLVER");