aboutsummaryrefslogtreecommitdiff
path: root/src/interp/g-util.boot
diff options
context:
space:
mode:
Diffstat (limited to 'src/interp/g-util.boot')
-rw-r--r--src/interp/g-util.boot24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot
index f06675df..155d7985 100644
--- a/src/interp/g-util.boot
+++ b/src/interp/g-util.boot
@@ -40,12 +40,17 @@ namespace BOOT
module g_-util where
getTypeOfSyntax: %Form -> %Mode
pairList: (%List,%List) -> %List
+ mkList: %List -> %List
++
$interpOnly := false
--% Utility Functions of General Use
+mkList u ==
+ u => ["LIST",:u]
+ nil
+
ELEMN(x, n, d) ==
null x => d
n = 1 => car x
@@ -57,6 +62,25 @@ PPtoFile(x, fname) ==
SHUT stream
x
+ScanOrPairVec(f, ob) ==
+ $seen: local := MAKE_-HASHTABLE 'EQ
+
+ CATCH('ScanOrPairVecAnswer, ScanOrInner(f, ob)) where
+ ScanOrInner(f, ob) ==
+ HGET($seen, ob) => nil
+ PAIRP ob =>
+ HPUT($seen, ob, true)
+ ScanOrInner(f, QCAR ob)
+ ScanOrInner(f, QCDR ob)
+ nil
+ VECP ob =>
+ HPUT($seen, ob, true)
+ for i in 0..#ob-1 repeat ScanOrInner(f, ob.i)
+ nil
+ FUNCALL(f, ob) =>
+ THROW('ScanOrPairVecAnswer, true)
+ nil
+
++ Query properties for an entity in a given environment.
get: (%Thing,%Symbol,%List) -> %Thing