public static Expr[] toExprArray(Expr sexp) throws RuntimeError {
		if (sexp == EMPTY_LIST)
			return new Expr[0];

		List<Expr> result = new ArrayList<Expr>();
		if (!(sexp instanceof Pair))
			result.add(sexp);
		else {
			while (true) {
				result.add(car(sexp));
				if (cdr(sexp) instanceof Pair)
					sexp = cdr(sexp);
				else {
					if (cdr(sexp) != EMPTY_LIST)
						result.add(cdr(sexp));
					break;
				}
			}
		}
		return result.toArray(new Expr[0]);
	}