diff options
author | dos-reis <gdr@axiomatics.org> | 2011-10-01 14:02:30 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-10-01 14:02:30 +0000 |
commit | 73374b314b15f2a313718d0e347a1050d1d1a405 (patch) | |
tree | e893bb8f428e229c04445ffc11fdc0a2f3f6a1f5 /src/boot/utility.boot | |
parent | 4cb6f558586ccd4893c2acd088bba66654f6bf19 (diff) | |
download | open-axiom-73374b314b15f2a313718d0e347a1050d1d1a405.tar.gz |
* boot/utility.boot: Define BOOTTRAN namespace.
(setUnion): New.
(setDifference): New.
* boot/translator.boot (packageBody): New.
(translateToplevel): Use it. Translate namespace definition.
* boot/tokens.boot: Replace bitmask with bitref.
Do not translate setDifference and setUnion.
* boot/parser.boot (bpDef): Now include namespace definition.
(bpComma): Remove namespace rule as subsumed by Where rule.
* boot/Makefile.in: Remove dependencies on initial-env.lisp.
(AXIOM_LOCAL_LISP_sources): Remove as unused,
(boot_sources): Remove as redundant with boot_SOURCES.
* boot/initial-env.lisp: Remove.
Diffstat (limited to 'src/boot/utility.boot')
-rw-r--r-- | src/boot/utility.boot | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/boot/utility.boot b/src/boot/utility.boot index 5e620d82..4d4d5961 100644 --- a/src/boot/utility.boot +++ b/src/boot/utility.boot @@ -37,14 +37,18 @@ --% by the Boot translator. Others are handy library functions. --% -import initial_-env +namespace BOOTTRAN == + import namespace System + import namespace AxiomCore + namespace BOOTTRAN module utility (objectMember?, symbolMember?, stringMember?, charMember?, scalarMember?, listMember?, reverse, reverse!, lastNode, append, append!, copyList, substitute, substitute!, - setDifference, applySubst, applySubst!, applySubstNQ, - remove,removeSymbol,atomic?,finishLine,subStringMatch?) where + setDifference, setUnion, setIntersection, + applySubst, applySubst!, applySubstNQ, + remove,removeSymbol,atomic?,finishLine) where substitute: (%Thing,%Thing,%Thing) -> %Thing substitute!: (%Thing,%Thing,%Thing) -> %Thing append: (%List %Thing,%List %Thing) -> %List %Thing @@ -53,11 +57,16 @@ module utility (objectMember?, symbolMember?, stringMember?, lastNode: %List %Thing -> %Maybe %Node %Thing removeSymbol: (%List %Thing, %Symbol) -> %List %Thing remove: (%List %Thing, %Thing) -> %List %Thing + setDifference: (%List %Thing,%List %Thing) -> %List %Thing + setUnion: (%List %Thing,%List %Thing) -> %List %Thing + setIntersection: (%List %Thing,%List %Thing) -> %List %Thing atomic?: %Thing -> %Boolean finishLine: %Thing -> %Void firstNonblankPosition: (%String,%Short) -> %Maybe %Short firstBlankPosition: (%String,%Short) -> %Maybe %Short +%defaultReadAndLoadSettings() + --% ++ Return true if `x' is an atom of a quotation. @@ -233,6 +242,19 @@ setDifference(x,y) == p := rest p rest l +++ Return the union of two lists of objects, with no duplicates. +setUnion(x,y) == + z := nil + for a in x | not objectMember?(a,z) repeat + z := [a,:z] + for a in y | not objectMember?(a,z) repeat + z := [a,:z] + reverse! z + +++ Return the intersection of two lists of objects, with no duplicates. +setIntersection(x,y) == + [a for a in x | objectMember?(a,y)] + --% removal removeSymbol(l,x) == |