vault backup: 2023-10-27 14:35:01

This commit is contained in:
2023-10-27 14:35:01 +02:00
parent 0a8d8cab37
commit 0fac88d66f
2 changed files with 25 additions and 7 deletions

View File

@ -57,3 +57,21 @@ val exists: (bool -> bool) -> bool list -> bool = <fun>
```
## Ex 2.5
```Ocaml
# let rec filter p : function
| [] -> []
| e::t -> if p e then
e::filter p t
else filter p t;;
val filter: ('a -> bool) -> 'a list -> 'a
```
## Ex 2.6
```Ocaml
let rec partition p l =
match l with
| [] -> ([], [])
| h==t> let (l1, l2) = partition p t in
if p h then (h::l1,l2)
else (l1, h::l2);;
val partition : ('a -> bool) -> 'a list -> 'a list * 'a list = <fun>