@@ -0,0 +1,1847 @@
+class List %7B%0A  public int head;%0A  public List tail;%0A  %0A  public List(int h, List t) %7B%0A    head = h;%0A    tail = t;%0A  %7D %0A%7D%0A%0Apublic class Main %7B%0A  public static void main(String%5B%5D args) %7B%0A    List L1 = list(1, list(2, list(3, null)));%0A    List L2 = list(5, list(6, list(7, null)));%0A    write(%22L1 is %22);write_list(L1);%0A    writeln(%22L1 length is %22 + length(L1));%0A    writeln(%22L1 sum is %22 + sum(L1));%0A    writeln(%22L1 last element is %22 + last(L1));%0A    writeln(%22Are there duplicated elements is L1? %22 + duplicated(L1));%0A    write(%22L1 reversed WITHOUT accumulator is %22);write_list(reverse(L1));%0A  %7D%0A  %0A  static List list(int head, List tail) %7B%0A    return new List(head, tail);%0A  %7D%0A  %0A  static int head(List xs) %7B%0A    return xs.head;%0A  %7D%0A  %0A  static List tail(List xs) %7B%0A    return xs.tail;%0A  %7D%0A  %0A  static boolean empty(List xs) %7B%0A    return xs == null;%0A  %7D%0A  %0A  static int length(List xs) %7B%0A    if (empty(xs)) return 0;%0A    return 1 + length(tail(xs));%0A  %7D%0A  %0A  static int sum(List xs) %7B%0A    if (empty(xs))%0A      return 0;%0A    return head(xs) + sum(tail(xs));%0A  %7D%0A%0A  static int last(List xs) %7B%0A    if (empty(tail(xs)))%0A      return head(xs);%0A    return last(tail(xs));%0A  %7D%0A%0A  static boolean member(int x, List xs) %7B%0A    if (empty(xs))%0A      return false;%0A    if (x == head(xs))%0A      return true;%0A    return member(x , tail(xs));%0A  %7D%0A%0A  static boolean duplicated(List xs) %7B%0A    if (empty(xs))%0A      return false;%0A    if (member(head(xs), tail(xs)))%0A      return true;%0A    return duplicated(tail(xs));%0A  %7D%0A  %0A  static void reverse(List xs) %7B%0A    %0A  %7D%0A  %0A  static void write_list(List xs) %7B%0A    if (empty(xs))%0A      write(%22%5Cn%22);%0A    else %7B%0A      write(%22 %22 +head(xs) + %22 %22);%0A      write_list(tail(xs));%0A    %7D%0A  %7D%0A%0A  static void write(String str) %7B%0A    System.out.print(str);%0A  %7D%0A  %0A  static void writeln(String str) %7B%0A    write(str);%0A    write(%22%5Cn%22);%0A  %7D%0A%7D%0A

Add recursived list in Java