let string_of_list to_s
list = let print_list to_s
list = let isodd n = n mod 2 <> 0
let f ns =
let rec aux acc = function
| [], _ -> acc
| n :: ns, m :: ms when isodd n -> aux (m :: acc) (ns, ms)
| n :: ns, ms -> aux (n :: acc) (ns, ms)
in
List.rev
(aux
[] (ns, ms
)) let () =
p (f [6; 5; 4; 3; 2; 1]);
p (f [6; 5; 3; 1])
bGV0IHN0cmluZ19vZl9saXN0IHRvX3MgbGlzdCA9IAogICJbIiBeIFN0cmluZy5jb25jYXQgIiwgIiAoTGlzdC5tYXAgdG9fcyBsaXN0KSBeICJdIgpsZXQgcHJpbnRfbGlzdCB0b19zIGxpc3QgPSAKICBwcmludF9lbmRsaW5lIChzdHJpbmdfb2ZfbGlzdCB0b19zIGxpc3QpCmxldCBpc29kZCBuID0gbiBtb2QgMiA8PiAwCmxldCBmIG5zID0gCiAgbGV0IG1zID0gTGlzdC5zb3J0IGNvbXBhcmUgKExpc3QuZmlsdGVyIGlzb2RkIG5zKSBpbgogIGxldCByZWMgYXV4IGFjYyA9IGZ1bmN0aW9uCiAgICB8IFtdLCBfIC0+IGFjYwogICAgfCBuIDo6IG5zLCBtIDo6IG1zIHdoZW4gaXNvZGQgbiAtPiBhdXggKG0gOjogYWNjKSAobnMsIG1zKQogICAgfCBuIDo6IG5zLCBtcyAtPiBhdXggKG4gOjogYWNjKSAobnMsIG1zKQogIGluCiAgTGlzdC5yZXYgKGF1eCBbXSAobnMsIG1zKSkKbGV0ICgpID0gCiAgbGV0IHAgPSBwcmludF9saXN0IHN0cmluZ19vZl9pbnQgaW4KICBwIChmIFs2OyA1OyA0OyAzOyAyOyAxXSk7CiAgcCAoZiBbNjsgNTsgMzsgMV0pCg==