aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzweije2001-07-25 15:14:56 +0000
committerzweije2001-07-25 15:14:56 +0000
commit7a6e519e16ac7d1e5073fd1e5c7a26a697e6e5bf (patch)
treec2705b9db1b2bb0bacc68dbf594d645f23fe1f54
parentremoved underscoreModule from ParseState, this is now handled by the scanner (diff)
This commit was generated by cvs2svn to compensate for changes in r572,
which included commits to RCS files with non-trunk default branches. git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@573 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
-rw-r--r--sucl/pfun.dcl3
-rw-r--r--sucl/pfun.icl5
2 files changed, 8 insertions, 0 deletions
diff --git a/sucl/pfun.dcl b/sucl/pfun.dcl
index 49db62d..baea62f 100644
--- a/sucl/pfun.dcl
+++ b/sucl/pfun.dcl
@@ -28,6 +28,9 @@ postcomp :: (.ran1 -> .ran2) !(Pfun .dom .ran1) -> Pfun .dom .ran2
// Build a total function from a partial one by supplying a default value
total :: .ran !(Pfun dom .ran) dom -> .ran | == dom
+// Apply partial function with a default value
+foldpfun :: (.ran1 -> .ran2) .ran2 !(Pfun dom .ran1) dom -> .ran2 | == dom
+
// Domain restriction of a partial function
domres :: !.[dom] .(Pfun dom ran) -> Pfun dom ran | == dom
diff --git a/sucl/pfun.icl b/sucl/pfun.icl
index 14df397..c303b7d 100644
--- a/sucl/pfun.icl
+++ b/sucl/pfun.icl
@@ -54,6 +54,11 @@ total def (Restrict x p) arg
| arg==x = def
= total def p arg
+// Apply partial function with a default value
+foldpfun :: (.ran1 -> .ran2) .ran2 !(Pfun dom .ran1) dom -> .ran2 | == dom
+foldpfun found notfound pfun arg
+ = total notfound (postcomp found pfun) arg
+
domres :: !.[dom] .(Pfun dom ran) -> Pfun dom ran | == dom
domres domain oldpfun
= foldr adddom emptypfun domain