update ski_evaluators
[lambda.git] / code / lambda.js
index 83ae7c4..955254b 100644 (file)
@@ -487,10 +487,10 @@ function sub(tree, v, arg) {
   if (tree.car == null) return (tree);
 
   // perform alpha reduction to prevent variable collision
   if (tree.car == null) return (tree);
 
   // perform alpha reduction to prevent variable collision
-  if (isBindingForm(tree)) 
-       return (new cons (tree.car, 
+  if (isBindingForm(tree))
+       return (new cons (tree.car,
                                          sub(sub(tree.cdr,         // inner sub = alpha reduc.
                                          sub(sub(tree.cdr,         // inner sub = alpha reduc.
-                                                         tree.cdr.car.cdr, 
+                                                         tree.cdr.car.cdr,
                                                          fresh(tree.cdr.car.cdr)),
                                                  v,
                                                  arg)));
                                                          fresh(tree.cdr.car.cdr)),
                                                  v,
                                                  arg)));
@@ -504,7 +504,7 @@ var i = 0;
 function fresh(string) {
   i = i+1;
   if (typeof(string) != "string") return (string);
 function fresh(string) {
   i = i+1;
   if (typeof(string) != "string") return (string);
-  return (new cons (null,  
+  return (new cons (null,
                                        string.substring(0,1) + (i).toString()));
 }
 
                                        string.substring(0,1) + (i).toString()));
 }
 
@@ -533,11 +533,11 @@ function mapReduce(tree) {
 function convert(tree) {
        if (isLet(tree)) {
          return (sub(tree.cdr.car, tree.car.cdr.car.cdr, tree.car.cdr.cdr.car));}
 function convert(tree) {
        if (isLet(tree)) {
          return (sub(tree.cdr.car, tree.car.cdr.car.cdr, tree.car.cdr.cdr.car));}
-       else 
+       else
          if (isConvertable(tree)) {
                return (sub(tree.car.cdr.cdr.car, tree.car.cdr.car.cdr, tree.cdr.car));}
          else return(tree);
          if (isConvertable(tree)) {
                return (sub(tree.car.cdr.cdr.car, tree.car.cdr.car.cdr, tree.cdr.car));}
          else return(tree);
-} 
+}
 
 // Is of form ((let var arg) body)?
 function isLet(tree) {
 
 // Is of form ((let var arg) body)?
 function isLet(tree) {
@@ -547,7 +547,7 @@ function isLet(tree) {
   if (tree.cdr == null) return (false);
   if (tree.cdr.car == null) return (false);
   return(true);
   if (tree.cdr == null) return (false);
   if (tree.cdr.car == null) return (false);
   return(true);
-}  
+}
 
 // Is of form ((lambda var body) arg)?
 function isConvertable(tree) {
 
 // Is of form ((lambda var body) arg)?
 function isConvertable(tree) {
@@ -557,14 +557,14 @@ function isConvertable(tree) {
   if (tree.cdr == null) return (false);
   if (tree.cdr.car == null) return (false);
   return(true);
   if (tree.cdr == null) return (false);
   if (tree.cdr.car == null) return (false);
   return(true);
-}  
+}
 
 // Is of form (lambda var body)?
 function isBindingForm(tree) {
   if (tree == null) return (false);
   if (tree.car == null) return (false);
   if (tree.car.car != null) return (false);
 
 // Is of form (lambda var body)?
 function isBindingForm(tree) {
   if (tree == null) return (false);
   if (tree.car == null) return (false);
   if (tree.car.car != null) return (false);
-  if ((tree.car.cdr != "lambda") 
+  if ((tree.car.cdr != "lambda")
          && (tree.car.cdr != "let")
          && (tree.car.cdr != "exists")
          && (tree.car.cdr != "forall")
          && (tree.car.cdr != "let")
          && (tree.car.cdr != "exists")
          && (tree.car.cdr != "forall")
@@ -583,7 +583,7 @@ function isBindingForm(tree) {
 function treeToString(tree) {
   if (tree == null) return ("")
   if (tree.car == null) return (tree.cdr)
 function treeToString(tree) {
   if (tree == null) return ("")
   if (tree.car == null) return (tree.cdr)
-  if ((tree.car).car == null) 
+  if ((tree.car).car == null)
        return (treeToString(tree.car) + " " + treeToString(tree.cdr))
   return ("(" + treeToString(tree.car) + ")" + treeToString(tree.cdr))
 }
        return (treeToString(tree.car) + " " + treeToString(tree.cdr))
   return ("(" + treeToString(tree.car) + ")" + treeToString(tree.cdr))
 }
@@ -592,7 +592,7 @@ function treeToString(tree) {
 function treeToStringRaw(tree) {
   if (tree == null) return ("@")
   if (typeof(tree) == "string") return (tree);
 function treeToStringRaw(tree) {
   if (tree == null) return ("@")
   if (typeof(tree) == "string") return (tree);
-  return ("(" + treeToStringRaw(tree.car) + "." + 
+  return ("(" + treeToStringRaw(tree.car) + "." +
                                treeToStringRaw(tree.cdr) + ")")
 }
 
                                treeToStringRaw(tree.cdr) + ")")
 }
 
@@ -624,7 +624,7 @@ function formatTree(tree) {
   return (output)
 }
 
   return (output)
 }
 
-function mytry(form) { 
+function mytry(form) {
   i = 0;
   form.result.value = formatTree((stringToTree(form.input.value)));
   // form.result.value = formatTree(fixedPoint(stringToTree(form.input.value)));
   i = 0;
   form.result.value = formatTree((stringToTree(form.input.value)));
   // form.result.value = formatTree(fixedPoint(stringToTree(form.input.value)));