Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.67 KB | None | 0 0
  1. (*  Vérifier qu'un texte est un palindrome:  *)
  2.  
  3.    
  4. let rec pal2(s) =
  5.             if s = ""  or  string_length(s) = 1
  6.             then true
  7.             else    
  8.                 if pr(s) <= `A`  &  pr(s) >= `Z`
  9.                 then pal2(char_of_int(int_of_char(pr(s)) + 32))
  10.                 else    
  11.                     if dr(s) <= `A`  &  dr(s) >= `Z`
  12.                     then pal2(char_of_int(int_of_char(dr(s)) + 32))
  13.                     else    
  14.                         if pr(s) = ` `  or  pr(s) = `'`  or  pr(s) = `-`  or   pr(s) = `_`  or  pr(s) = `,`
  15.                         then pal2(sp(s))
  16.                         else    
  17.                             if  dr(s) = ` `  or  dr(s) = `'`  or  dr(s) = `-`  or   dr(s) = `_`  or dr(s) = `,`
  18.                             then pal2(sd(s))
  19.                             else   
  20.                                 if pr(s) = dr(s)
  21.                                 then pal2(sp(sd(s)))
  22.                                 else false;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement