aboutsummaryrefslogtreecommitdiff
path: root/frontend/utilities.dcl
diff options
context:
space:
mode:
authormartinw2000-09-20 14:12:40 +0000
committermartinw2000-09-20 14:12:40 +0000
commit1fbac5e0d5a52c98f9db47b64b7f3436d1b98de4 (patch)
tree9bca90abd09bafb5d382850feade36dcf570f7f5 /frontend/utilities.dcl
parentno message (diff)
new Bag type: :: Bag x = Pair (Bag x) (Bag x) | Single x | Empty
using this for accumulators is more elegant than using lists git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@216 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
Diffstat (limited to 'frontend/utilities.dcl')
-rw-r--r--frontend/utilities.dcl5
1 files changed, 5 insertions, 0 deletions
diff --git a/frontend/utilities.dcl b/frontend/utilities.dcl
index 909f859..664375b 100644
--- a/frontend/utilities.dcl
+++ b/frontend/utilities.dcl
@@ -115,3 +115,8 @@ iterateSt op st :== iterate_st op st
revAppend :: ![a] ![a] -> [a] // Reverse the list using the second argument as accumulator.
revMap :: !(.a -> .b) ![.a] !u:[.b] -> u:[.b]
+:: Bag x = Empty | Single !x | Pair !(Bag x) !(Bag x)
+
+uniqueBagToList :: !*(Bag x) -> [x] // exploits reuse of unique nodes (if compiled with that option)
+bagToList :: !(Bag x) -> [x]
+isEmptyBag :: !(Bag x) -> Bool