Salam,
I was wondering if anyone could help me with this mode function in ML?
fun
insert_place (a,_) = a;fun
mode nil = 0| mode (h::t) = letfun
sorted (x,y) (x',y') = if y>y' then (x,y) else (x',y') fun item(nil,current,number_of) = sorted current number_of |item (h
::t, (x,y), number_of) = if h = x then item (t,(x,y+1),number_of)else
item (t,(h,1), sorted (x,y) number_of)in
insert_place (item(t, (h,1),(h,1))) end;
It is not 100% correct as the sorted function does not work properley!
I have found this code on an internet site but i do not understand how it works. I was told the steps to create a mode function in ml:
- Write a function to insert an item in the list, in the right place in the list.
- Write a function to sort the list and to identify if an item is in a list.
- Write a function to deduct the list.
- Write a function to count number of times an item appears in a list.
- Write a function to count number of times each item in one list appears in a second list.
- Write a function to identify maximum value in a list.
- Write a function to calculate Mode.
I am not very good at ml so i was unable to create my own mode function. Any help would be greatly appriciated.
Thank you
_______________________________________________ Developer mailing list [email protected] http://lists.arabeyes.org/mailman/listinfo/developer

