Sorting

Definition

LISP is just beautiful at sorting. Verifying this was the best time out of the entire project. Unfortunately jatha failed the call - it would seem that some of the more advanced builtin functions have not been ported over. Some research was done on various search engines and discussion forums to determine the reason (perhaps 'sort' was buried elsewhere) - but nothing resulted from those attempts. I have no choice but to fail Jatha on the sort.

Common LISP Code

(sort '(8 2 3 1 6 5 4) #'<)
(sort '(3 2 9 7 1) #'>)

Common LISP Output

(1 2 3 4 5 6 8)
(9 7 3 2 1)

Java Code

package jathaverify;
import org.jatha.*;
import org.jatha.dynatype.*;
import java.util.*;
public class Main  {

    public Main() {
    }

    public static void main(String[] args) {
        Jatha myLisp  = new Jatha(false, false);
        myLisp.init();
        myLisp.start();

        try {
            List lisp = new ArrayList();

            lisp.add("(format t "My lucky number: ~D~%I prefer ~D wheels ~%Phones have ~D keys~%" 7 (list 2) 9)");

            Iterator i = lisp.iterator();
            while (i.hasNext()) {
                String query = i.next().toString();
                System.out.println(myLisp.eval(query));
             }

        } catch (Exception e) {
            System.err.println("LISP Exception: " + e);
        }

    }
}

Java Output (Jatha)

compile:
run:
ERROR: org.jatha.compile.UndefinedFunctionException: The function "SORT" is undefined.
ERROR: org.jatha.compile.UndefinedFunctionException: The function "SORT" is undefined.
(sort '(8 2 3 1 6 5 4) #'<) = "org.jatha.compile.UndefinedFunctionException: The function "SORT" is undefined."
(sort '(3 2 9 7 1) #'>) = "org.jatha.compile.UndefinedFunctionException: The function "SORT" is undefined."

Result

Doh!