Question: TASK 2: Analyse the following Java code in Figure 1 and 2. Rewrite the given program code using logic programming paradigm, Prolog. Your solution should

TASK 2:

Analyse the following Java code in Figure 1 and 2. Rewrite the given program code using logic programming paradigm, Prolog. Your solution should include recursive concept and demonstrate the query sample.

Part 1:

import java.util.*;

import java.util.stream.Collectors;

public class Filter {

public static List apply(

List lst, Double target){

return lst.stream()

.mapToDouble( Number::doubleValue )

.filter( elem -> elem > target )

.boxed()

.collect( Collectors.toCollection(

ArrayList::new ) );

}

public static void main(String[] args) {

// Integer[] nums = new Integer[] {1,2,3,4,5,6,7,8,9};

Double[] nums = new Double[] {2.1,3.2,4.3,5.4,6.5,7.6,8.7};

System.out.println(

Filter.apply( Arrays.asList(nums), 5.0 )

);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!