Bladeren bron

Add negation function and clean up string library a little.

Matt Coles 9 jaren geleden
bovenliggende
commit
01851a6f73
2 gewijzigde bestanden met toevoegingen van 3 en 7 verwijderingen
  1. 3 0
      lib/stdlib.js
  2. 0 7
      lib/str.js

+ 3 - 0
lib/stdlib.js

@@ -65,6 +65,9 @@ const builtins = {
65 65
   or: function (pred1, pred2) { 
66 66
     return pred1 || pred2
67 67
   },
68
+  neg: function (pred) {
69
+    return !pred
70
+  },
68 71
   modulo: function (arg1, arg2) {
69 72
     return {
70 73
       value: (arg1.value % arg2.value)

+ 0 - 7
lib/str.js

@@ -1,6 +1,3 @@
1
-const global_obj = {}
2
-const function_defs = {}
3
-const warnings = {}
4 1
 const builtins = {
5 2
   concat: function () {
6 3
     let str = ""
@@ -22,10 +19,6 @@ const my_handler = {
22 19
       console.error("Undefined function call! No such function: ", prop)
23 20
     }
24 21
   }, 
25
-  set: function (target, prop, data) {
26
-    if (prop === 'w') data.map((w) => warnings.w = true)
27
-    else console.error("Attempting to set unknown property on interpreter! How did you do that?")
28
-  }
29 22
 }
30 23
 
31 24
 const proxy_obj = new Proxy({}, my_handler)