Strings

Definition

A string is a kind of Lisp data object which contains a sequence of characters. The Lisp syntax for a string consists of the characters in the string with a " before and another " after. A " that is part of the string must be written as " and a \ that is part of the string must be written as \\ - so basically a string in LISP is the same as a string in Java. Essentially LISP strings are arrays; and LISP arrays are functions. So it is back to square one.

Common LISP Code

(char "def" 1)
(aref "def" 1)
(concatenate 'string "ghds" "fsafds")

Common LISP Output

#\e
#\e
ghdsfsafds

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("(char "def" 1)");
            lisp.add("(aref "def" 1)");
            lisp.add("(concatenate 'string "ghds" "fsafds")");
            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:
(char "def" 1) = #\e
(aref "def" 1) = #\e
(concatenate 'string "ghds" "fsafds") = "ghdsfsafds"
BUILD SUCCESSFUL (total time: 1 second)

Result

Awesome!