summaryrefslogtreecommitdiff
path: root/appl/lib/lists.b
diff options
context:
space:
mode:
Diffstat (limited to 'appl/lib/lists.b')
-rw-r--r--appl/lib/lists.b13
1 files changed, 8 insertions, 5 deletions
diff --git a/appl/lib/lists.b b/appl/lib/lists.b
index 2210c33e..52e007bb 100644
--- a/appl/lib/lists.b
+++ b/appl/lib/lists.b
@@ -88,18 +88,21 @@ last[T](l: list of T): T
}
# delete the first instance of x in l
-delete[T](x: T, l: list of T): list of T
+delete[T](x: T, al: list of T): list of T
for { T => eq: fn(a, b: T): int; }
{
- o: list of T;
- for(; l != nil; l = tl l)
+ for(l := al; l != nil; l = tl l){
if(T.eq(x, hd l)){
+ o: list of T;
+ for(; al != l; al = tl al)
+ o = hd al :: o;
l = tl l;
for(; o != nil; o = tl o)
l = hd o :: l;
- break;
+ return l;
}
- return l;
+ }
+ return al;
}
pair[T1, T2](l1: list of T1, l2: list of T2): list of (T1, T2)