Conditionals

Definition

Validation for conditional when.

Common LISP Code

(when t
    (setq a 5)
    (+ a 6)
  )

(setq x 'z)

(case x
  (d 5)
  ((g t) 2)
  ((z r) 3)
  (otherwise 8)
)

Common LISP Output

11
Z
3

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("(when t (setq a 5) (+ a 6) )");
            lisp.add("(setq x 'z)");
            lisp.add("(case x (d 5)((g t) 2)((z r) 3)(otherwise 8))");
            Iterator i = lisp.iterator();
            while (i.hasNext()) {
                String query = i.next().toString();
                System.out.println(query + " = " + myLisp.eval(query));
             }

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

    }
}

Java Output (Jatha)

compile:
run:
(when t (setq a 5) (+ a 6) ) = 11
(setq x 'z) = Z
(case x (d 5)((g t) 2)((z r) 3)(otherwise 8)) = 3
BUILD SUCCESSFUL (total time: 0 seconds)

Result

Sweet!