Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added decimal arithmatic devices and fixed crash bug if unknown device

  • Loading branch information...
commit ab758ab7da9dd871f9c5b46100fa51dd2eae67e0 1 parent 650c7eb
@EnKrypt authored
Showing with 8 additions and 8 deletions.
  1. BIN  Lisp.class
  2. +8 −8 Lisp.java
View
BIN  Lisp.class
Binary file not shown
View
16 Lisp.java
@@ -77,23 +77,23 @@ public static String eval(String arg[]){
// System.out.println(i+" : "+arg[i]);
// }
if (arg[0].equalsIgnoreCase("add")){
- int cres=0;
+ double cres=0;
for (int i=1;i<arg.length;i++){
- cres+=Integer.parseInt(arg[i]);
+ cres+=Double.parseDouble(arg[i]);
}
return ""+cres;
}
else if (arg[0].equalsIgnoreCase("sub")){
- int cres=Integer.parseInt(arg[1]);
+ double cres=Double.parseDouble(arg[1]);
for (int i=2;i<arg.length;i++){
- cres-=Integer.parseInt(arg[i]);
+ cres-=Double.parseDouble(arg[i]);
}
return ""+cres;
}
else if (arg[0].equalsIgnoreCase("mul")){
- int cres=Integer.parseInt(arg[1]);;
+ double cres=Double.parseDouble(arg[1]);;
for (int i=2;i<arg.length;i++){
- cres*=Integer.parseInt(arg[i]);
+ cres*=Double.parseDouble(arg[i]);
}
return ""+cres;
}
@@ -298,8 +298,8 @@ else if (arg[0].equalsIgnoreCase("runlambda")){
try{
devi=mkdev.get(arg[0]).toString();
}
- catch(NullPointerException npe){
- devi="";
+ catch(Exception npe){
+ return "";
}
return "("+devi+param+")";
}
Please sign in to comment.
Something went wrong with that request. Please try again.