diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-09-19 14:42:36 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-09-19 14:42:36 -0400 |
commit | 3bf0f6b7a465e3f24eff57633ee8aa3bbe41422a (patch) | |
tree | c66699a201ad33330f7547289548ce1fdf714f0f /demo/more/dlist.ur | |
parent | 142e0b28763660019a6fc0fc4a9383fb43b77407 (diff) |
Progress on sorting + filtering
Diffstat (limited to 'demo/more/dlist.ur')
-rw-r--r-- | demo/more/dlist.ur | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/demo/more/dlist.ur b/demo/more/dlist.ur index fe0cdd07..277f1219 100644 --- a/demo/more/dlist.ur +++ b/demo/more/dlist.ur @@ -260,6 +260,21 @@ fun size [t] (dl : dlist t) = Empty => return 0 | Nonempty {Head = hd, ...} => size' hd +fun numPassing' [t] (f : t -> signal bool) (dl'' : dlist'' t) = + case dl'' of + Nil => return 0 + | Cons (x, dl'') => + b <- f x; + dl'' <- signal dl''; + n <- numPassing' f dl''; + return (if b then n + 1 else n) + +fun numPassing [t] (f : t -> signal bool) (dl : dlist t) = + dl' <- signal dl; + case dl' of + Empty => return 0 + | Nonempty {Head = hd, ...} => numPassing' f hd + fun foldl [t] [acc] (f : t -> acc -> signal acc) = let fun foldl'' (i : acc) (dl : dlist'' t) : signal acc = |