留学生代考 Analyse the following Java code in Figure 1 and 2. Rewrite the given progr

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.
import java.util.*;

Copyright By PowCoder代写 加微信 powcoder

import java.util.stream.Collectors:
public class Filter {
public static ListNumber> apply(
List lst, Double target) {
return lst.stream()
.mapToDouble( Number: : doubleValue)
•filter( elem -> elem > target )
.collect Collectors.toCollection(
ArrayList: :new ) ) :
public static void main(String[] args)
botsterl’ owns nee oontroet”2.4,3:2.4:3,9:7,8:941.6.8.m.
System.out.println(
Filter.apply( Arrays.asList (nums), 5.0 )
Figure I: Filter the numeric elements based on target value

import java.util.*;
import java.util.stream.*:
public class Demo {
public static void main(String[] args) {
String[][] lst =
{ “a”, “b” I, { “c”, “d”, “e”, “f” }
Stream stream = Arrays.stream(lst);
System.out.println( stream
• flatMap( arr
-> Arrays. stream(arr)
.collect ( Collectors. toCollection( LinkedList: :new )
Figure 2: Joining the elements from the array objects as a collection of obiects

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com