summaryrefslogtreecommitdiff
path: root/test/files/run/lisp.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-08-04 15:36:09 +0000
committerMartin Odersky <odersky@gmail.com>2003-08-04 15:36:09 +0000
commit5cbecc3b89757f6996c199e73518b8387d4a5a6a (patch)
tree83d6522f8172b62e0bced4c4c312c16939d69f6f /test/files/run/lisp.scala
parentf014b416aa6099f9031f60f1ccdb19a9ced74382 (diff)
downloadscala-5cbecc3b89757f6996c199e73518b8387d4a5a6a.tar.gz
scala-5cbecc3b89757f6996c199e73518b8387d4a5a6a.tar.bz2
scala-5cbecc3b89757f6996c199e73518b8387d4a5a6a.zip
*** empty log message ***
Diffstat (limited to 'test/files/run/lisp.scala')
-rw-r--r--test/files/run/lisp.scala27
1 files changed, 16 insertions, 11 deletions
diff --git a/test/files/run/lisp.scala b/test/files/run/lisp.scala
index c8c166a76c..2eb58528ab 100644
--- a/test/files/run/lisp.scala
+++ b/test/files/run/lisp.scala
@@ -288,18 +288,23 @@ object LispAny with Lisp {
def lookup(n: String): Data = lispError("undefined: " + n);
}
- def asList(x: Data): List[Data] =
- if (x is List[Data]) x as List[Data]
- else lispError("malformed list: " + x);
+ def asList(x: Data): List[Data] = x match {
+ case y: List[Data] => y
+ case _ => lispError("malformed list: " + x)
+ }
- def asBoolean(x: Data): boolean =
- if (x == 0) false else true;
+ def asInt(x: Data): int = x match {
+ case y: int => y
+ case _ => lispError("not an integer: " + x)
+ }
- def asInt(x: Data): int =
- if (x is int) x as int else lispError("not an integer: " + x);
+ def asString(x: Data): String = x match {
+ case y: java.lang.String => y
+ case _ => lispError("not a string: " + x)
+ }
- def asString(x: Data): String =
- if (x is java.lang.String) x as java.lang.String else lispError("not a string: " + x);
+ def asBoolean(x: Data): boolean =
+ if (x == 0) false else true;
def normalize(x: Data): Data = x match {
case 'and :: x :: y :: Nil =>
@@ -368,7 +373,7 @@ object LispAny with Lisp {
case y :: ys => " " + lisp2string(y) + list2string(ys)
}
"(" + lisp2string(y) + list2string(ys) + ")"
- case _ => if (x is String) "\"" + x + "\""; else x.toString()
+ case _ => if (x.isInstanceOf[String]) "\"" + x + "\""; else x.toString()
}
def apply(fn: Data, args: List[Data]): Data = fn match {
@@ -452,7 +457,7 @@ class LispUser(lisp: Lisp) {
def run = {
- System.out.println(string2lisp("(lambda (x) (+ (* x x) 1))") as Object);
+ System.out.println(string2lisp("(lambda (x) (+ (* x x) 1))").asInstanceOf[Object]);
System.out.println(lisp2string(string2lisp("(lambda (x) (+ (* x x) 1))")));
System.out.println();