(Solved) : Please Finish Todo Sections Following Java Code Import Javautillist Import Javautilfunctio Q43969339 . . .
Please finish the TODO sections for the following java code
import java.util.List;
import java.util.function.Function;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import java.util.Comparator;
public class secondAssignment {
static <U,V> List<V> map(Iterable<U> l,Function<U,V> f) {
//TODO
return null;
}
static <U,V> V foldL(V e, Iterable<U>l,BiFunction<V,U,V> f){
//TODO
return null;
}
static <U,V> V foldR(V e, Iterable<U>l,BiFunction<U,V,V> f){
return null;
}
static <U> Iterable<U> filter(Iterable<U> l,Predicate<U> p){
//TODO
return null;
}
static <U> U minMum(Iterable<U> l,Comparator<U> c){
// write using fold. No other loops permitted.
//TODO
return null;
}
static <U extends Comparable<U>> intminPos(Iterable<U> l){
// write using fold. No other loops permitted.
return 0;
}
public static void main(String[] args) {
// (1) Use map to implement thefollowing behavior (described in Python). i.e given aList<T> create a List<Integer> of the hashes of theobjects.
// names = [‘Mary’, ‘Isla’,’Sam’]
// for i inrange(len(names)):
// names[i] = hash(names[i])
// (2) Use foldleft to calculatethe sum of a list of integers.
// i.e write a method: intsum(List<Integer> l)
// (3) Use foldRight to concatenatea list of strings i.e write a method
// String s (List<String>l)
// (4) consider an array ofPersons. Use filter to
// print the names of the Personswhose salary is
// greater than 100000
// (5) Use minVal to calculate theminimum of a List of
// Integers
// (6) Use minVal to calculate the maximum of a List of
// Integers
// (7) Use minPos to calculate theposition of the
// minimum in a List ofIntegers
// (8) Use minPos to calculatethe position of the
// maximum in a List of String
//TODO
}
}
class Person{
final int salary;
final String name;
Person(int salary, String name){
this.salary = salary;
this.name = name;
}
int getSalary() { return salary; }
String name() { return name;}
}
Expert Answer
Answer to Please finish the TODO sections for the following java code import java.util.List; import java.util.function.Function; i…
OR