difficult exercise in racket sheme programming??????????
A function named occurrences that takes as parameters two arguments, a and b. If a is not a list
then the function should return #f. Otherwise it should return the number of times b is found in
the list a. For example, if a is (3 4 2 53 3 5 4) and b is 3 the function should return 2
public static int occurrences(ArrayList<Integer> a, int b){
if
(a.getClass().getName().equals("java.util.ArrayList")){
int k=0;
for (int
i=0;i<a.size();i++)
if (a.get(i)==b)
k++;
return
k;
}else
return -1;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
JavaJSPJSF