Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package prob2;
- import java.util.List;
- import java.util.function.Function;
- import java.util.stream.Collectors;
- import java.util.stream.IntStream;
- public class LambdaLibrary {
- public final static String IMPLEMENT = "implement!";
- // sample query
- public final static TriFunction<List<Employee>, Integer, Integer, List<Employee>> SAMPLE = (
- list, namelength, year) -> list.stream()
- .filter(e -> e.getName().length() > namelength)
- .filter(e -> e.getYearOfBirth() > year)
- .collect(Collectors.toList());
- // int[] testItem1 = {-351, 2342, 46, 17, 14, 4002, 12};
- //Extract subarray of even integers from an array of integers
- public final static Function<int[],List<Integer>> CHANGE_TO_LIST = x->IntStream.of(x).boxed().collect(Collectors.toList());
- public final static Function<List<Integer>,List<Integer>> GET_SUBSTRING = (x)-> x.stream()
- .filter(y->{return y%2==0;}).collect(Collectors.toList());
- // int[] testItem2 = {-1, -3, 5, 11, 213};
- // //Compute sum of squares of an input array of integers
- public final static Function<List<Integer>, Integer> SUM_OF_SQUARE = x->x.stream()
- .mapToInt(y->(int)Math.pow(y, 2)).sum();
- // //Find all transactions from year 2011 and sort them by value (small to high).
- public final static Function<List<Transaction>,List<Transaction>> FOR_YEAR_2011= (List<Transaction> x)-> x.stream()
- .filter(x-((Transaction) x).getYear()==2011)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement