Advertisement
Guest User

Untitled

a guest
Jun 13th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local
  2.     fun rimuovi lista elemento = case lista of
  3.                                 [] => []
  4.                                 | li::ta => if (elemento = li) then (rimuovi ta elemento) else (li :: (rimuovi ta elemento));
  5.     fun noduplen_hid lista n = case lista of
  6.                                 [] =>  n
  7.                                 |li::ta => (noduplen_hid (rimuovi ta li) (n+1));
  8.                                
  9.     in fun noduplen lista = noduplen_hid lista 0
  10. end
  11. ;
  12.    
  13. noduplen [1];                              
  14. noduplen [1,2,3,4];                            
  15. noduplen [1,1,1,4];                            
  16. noduplen [2,4,1,4,1];                              
  17. noduplen [];                               
  18. noduplen [1,13,23,43,1];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement