diff options
Diffstat (limited to 'src/vylist.ml')
-rw-r--r-- | src/vylist.ml | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/vylist.ml b/src/vylist.ml new file mode 100644 index 0000000..c7d0396 --- /dev/null +++ b/src/vylist.ml @@ -0,0 +1,17 @@ +let rec find p xs = + match xs with + | [] -> None + | x :: xs' -> if (p x) then (Some x) + else find p xs' + +let rec remove p xs = + match xs with + | [] -> [] + | x :: xs' -> if (p x) then xs' + else x :: (remove p xs) + +let rec replace p x xs= + match xs with + | [] -> [] + | x' :: xs' -> if (p x') then x :: xs' + else x' :: (replace p x xs') |