12 |
(FLINT.fkind * FLINT.fkind) |
(FLINT.fkind * FLINT.fkind) |
13 |
|
|
14 |
(* this is a known APL function, but I don't know its real name *) |
(* this is a known APL function, but I don't know its real name *) |
15 |
val filter : bool list * 'a list -> 'a list |
val filter : bool list -> 'a list -> 'a list |
16 |
|
|
17 |
(* A less brain-dead version of ListPair.all: returns false if |
(* A less brain-dead version of ListPair.all: returns false if |
18 |
* length l1 <> length l2 *) |
* length l1 <> length l2 *) |
19 |
val ListPair_all : ('a * 'b -> bool) -> 'a list * 'b list -> bool |
val ListPair_all : ('a * 'b -> bool) -> 'a list * 'b list -> bool |
20 |
|
|
21 |
|
val pow2 : int -> int |
22 |
|
|
23 |
(* This is not a proper transposition in that the order is reversed |
(* This is not a proper transposition in that the order is reversed |
24 |
* in the following way: transpose x = map rev (proper_trans x) *) |
* in the following way: transpose x = map rev (proper_trans x) *) |
25 |
exception Unbalanced |
exception Unbalanced |
26 |
val transpose : 'a list list -> 'a list list |
val transpose : 'a list list -> 'a list list |
27 |
|
|
28 |
val foldl3 : ('a * 'b * 'c * 'd -> 'd) -> 'd -> 'a list * 'b list * 'c list -> 'd |
val foldl3 : ('a * 'b * 'c * 'd -> 'd) -> 'd -> 'a list * 'b list * 'c list -> 'd |
29 |
end |
end |
30 |
|
|
47 |
{isrec=isrec', known=true, cconv=cconv', inline=inline}) |
{isrec=isrec', known=true, cconv=cconv', inline=inline}) |
48 |
end |
end |
49 |
|
|
50 |
fun filter ([],[]) = [] |
fun filter [] [] = [] |
51 |
| filter (true::fs,x::xs) = x::(filter(fs, xs)) |
| filter (true::fs) (x::xs) = x::(filter fs xs) |
52 |
| filter (false::fs,x::xs) = (filter(fs, xs)) |
| filter (false::fs) (x::xs) = (filter fs xs) |
53 |
| filter _ = bug "unmatched list length in filter" |
| filter _ _ = bug "unmatched list length in filter" |
54 |
|
|
55 |
fun ListPair_all pred = |
fun ListPair_all pred = |
56 |
let fun allp (a::r1, b::r2) = pred(a, b) andalso allp (r1, r2) |
let fun allp (a::r1, b::r2) = pred(a, b) andalso allp (r1, r2) |
59 |
in allp |
in allp |
60 |
end |
end |
61 |
|
|
62 |
|
fun pow2 n = Word.toInt(Word.<<(Word.fromInt 1, Word.fromInt n)) |
63 |
|
|
64 |
exception Unbalanced |
exception Unbalanced |
65 |
fun transpose [] = [] |
fun transpose [] = [] |
66 |
| transpose (xs::xss) = |
| transpose (xs::xss) = |