Commit 894e45bc authored by Vincent Zweije's avatar Vincent Zweije
Browse files

Add foldpfun function to apply pfun in continuation based way

parent c577545d
......@@ -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
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment