git » jacl.git » commit 062a0aa

prstr utility

author Alan Dipert
2020-08-05 04:13:00 UTC
committer Alan Dipert
2020-08-05 04:13:00 UTC
parent 4983d9a2c2bf14918294e14b5bd58e4c2c2b9f77

prstr utility

jacl.js +14 -0

diff --git a/jacl.js b/jacl.js
index cb12ab7..c9577e6 100644
--- a/jacl.js
+++ b/jacl.js
@@ -2417,3 +2417,17 @@ window.addEventListener('DOMContentLoaded', async () => {
   //QUnit.start();
   await startRepl();
 });
+
+const prstr = obj => {
+  if (obj instanceof LispSymbol) {
+    return obj.name;
+  } else if (obj === null) {
+    return "nil";
+  } else if (List.isProperList(obj)) {
+    return "("
+      + List.toArray(obj).map(prstr).join(' ')
+      + ")";
+  } else {
+    return obj.toString();
+  }
+}