From 5cbecc3b89757f6996c199e73518b8387d4a5a6a Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 4 Aug 2003 15:36:09 +0000 Subject: *** empty log message *** --- test/files/run/lisp.scala | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'test/files/run/lisp.scala') 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(); -- cgit v1.2.3