Menu

[Solved]Java Assignment Implement Lisp Programming Language Interface Use Write Two Functions One Q37223097

I have a Java assignment to implement a lisp programminglanguage interface and use it to write two functions. One todetermine the size of a list, and another to check formembership.

Specifications:

  1. Implement the interface ILispMethodsList<T> two methods.See source file for documentation. Note that this is a genericinterface.
  2. Call your implemented class LispMethodsList<T>. Note thatthis is a generic class.
  3. P6 class is the main test driver & I will provide. You willuse an object of type LispMethodsList<> to help write tworecursive functions (see below).
    1. Methods (see P6.java for document
      • private static int length_rec(ILispMethodsList<Character>lp, List<Character> container)
      • private static boolean member(ILispMethodsList<Character>lp, List<Character> container, Character c)
  4. Sample output:

A

B C D E

5

True

ILispMethodsInterface

import java.util.List;

public interfaceILispMethodsList<T> {

    T car(List<T>obj);

   

    List<T>cdr(List<T> oList);

}

Test Driver

import java.util.ArrayList;

import java.util.Arrays;

import java.util.List;

import java.util.Objects;

public class P6 {

    public static void main(String[] args) {

        Character[] m = {‘A’, ‘B’, ‘C’, ‘D’, ‘E’ };

        List<Character>letters = new ArrayList<>(Arrays.asList(m));

       ILispMethodsList<Character> lp = newLispMethodsList<>();

        // test my car andcdr methods

       System.out.println(lp.car(letters));

        List<Character>rm = lp.cdr(letters);

        for (Character c :rm) {

           System.out.print(c + ” “);

        }

       System.out.println();

        // test recursivemethods

        int n =length_rec(lp, letters);

       System.out.println(n);

        Character x =’C’;

       System.out.println(member(lp, letters, x));

       System.out.println();

    }

private static int length_rec(ILispMethodsList<Character>lp, List<Character> container) {

        // your complete thiscode

    }

    private static booleanmember(ILispMethodsList<Character> lp, List<Character>container, Character c) {

        // you complete thiscode

    }

}

Expert Answer


Answer to I have a Java assignment to implement a lisp programming language interface and use it to write two functions. One to de… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *