Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let lista1= [4;1;2;9;6;7;0;12;100];;
- let rec max(unsorted, value) =
- match (unsorted, value) with
- ([],_) ->value|
- (v1::rest, _)-> if v1 > value
- then max(rest, v1)
- else max(rest, value);;
- max(lista1, 0);;
- let rec remove(l, x) =
- match l with
- []->[]|
- (h::t)->if h = x
- then t
- else h::remove(t, x);;
- remove(lista1, 9);;
- let rec sort(unsorted, sorted) =
- match unsorted with
- []->sorted|
- (v1::rest)->sort(remove(unsorted, max(rest, v1)), max(rest, v1)::sorted);;
- let selectionSort(l) = sort(l, []);;
- selectionSort(lista1);;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement