ref: ba2df74c818ed89c0225f594c19e26681c588fb7
parent: 61a8c696bbf60bd9b1ba35d0d0fe2052aff614f4
author: henesy <unknown>
date: Fri Dec 11 20:31:50 EST 2020
add arrays(2) manual ;; lists(2): reference arrays(2) ;; arrays.m: change order of functions ;; .hgignore: ignore .orig files
--- a/.hgignore
+++ b/.hgignore
@@ -4,6 +4,7 @@
*.patch
*.diff
*.log
+*.orig
[8qkv965o].out
[8qkv965o].emu
obj.out
--- a/appl/lib/arrays.b
+++ b/appl/lib/arrays.b
@@ -3,17 +3,17 @@
include "arrays.m";
# Return the array 'a' for which 'f' is fulfilled on its contents
-filter[T](a: array of T, f: ref fn(x: T): int): array of T {
+filter[T](a: array of T, p: ref fn(x: T): int): array of T {
if(a == nil)
return nil;
- if(f(a[0]))
- return prepend(filter(tail(a), f), a[0]);
+ if(p(a[0]))
+ return prepend(filter(tail(a), p), a[0]);
if(len a < 2)
return nil;
- return filter(tail(a), f);
+ return filter(tail(a), p);
}
# Return the array 'a₀' with the function 'f' applied to its contents
--- a/man/2/lists
+++ b/man/2/lists
@@ -202,3 +202,5 @@
.SH BUGS
The current implementation of polymorphism is limited to reference types and strings,
which in turn limits use of this module.
+.SH SEE ALSO
+.IR arrays (2)
--- a/module/arrays.m
+++ b/module/arrays.m
@@ -2,23 +2,24 @@
{
PATH: con "/dis/lib/arrays.dis";
- filter: fn[T](a: array of T, f: ref fn(x: T): int): array of T;
-
- map: fn[T](a₀: array of T, f: ref fn(x: T): T): array of T;
-
- pair: fn[T₁, T₂](a₁: array of T₁, a₂: array of T₂): array of (T₁, T₂);
-
find: fn[T](a: array of T, x: T): array of T
for { T => Equals: fn(a, b: T): int; };
- prepend: fn[T](a₀: array of T, x: T): array of T;
-
append: fn[T](a₀: array of T, x: T): array of T;
+ prepend: fn[T](a₀: array of T, x: T): array of T;
+
tail: fn[T](a: array of T): array of T;
+ pair: fn[T₁, T₂](a₁: array of T₁, a₂: array of T₂): array of (T₁, T₂);
+
# Return a pretty string representing the array
stringify: fn[T](a: array of T): string
for { T => String: fn(a: self T): string; };
+
+ filter: fn[T](a: array of T, p: ref fn(x: T): int): array of T;
+
+ map: fn[T](a₀: array of T, f: ref fn(x: T): T): array of T;
+
};