(************************************************* list_utils.ml Additional List functions Copyright (C) 2001 Brock Wilcox [awwaiid@deathonastick.org] Released under the terms of the GNU GPL See www.gnu.org for more information HISTORY / NOTES 2001.02.20.05.19 - Added ref list push and pop 2001.01.29.20.56 - Created *************************************************) let rec find_index_aux index item = function | [] -> print_string "HERE!";print_newline(); raise Not_found | h::t -> if (h=item) then index else find_index_aux (index + 1) item t let find_index item l = find_index_aux 0 item l let max l base = List.fold_left (function a -> function b -> max a b) base l let max_index l base = find_index (max l base) l (* These are actually ref list utils... but eh *) let pop ref_list = ref_list := List.tl !ref_list; List.hd !ref_list let push ref_list item = ref_list := item::(!ref_list); () let push_list ref_list l2 = ref_list := l2@(!ref_list); () (* End of list_utils.ml *)