Advertisement
oipus1

split

Nov 21st, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.82 KB | None | 0 0
  1. // ------------------------------------funzione SPLIT delle istruzioni e argomenti-----------------------------------------------------------------
  2.  
  3. let rec separa (xs : char list) : string  =
  4.     match xs with
  5.     [] ->""
  6.     | z::zs -> if z = ' '
  7.                then  ""
  8.                else  string z + separa zs;;
  9.  
  10. let rec avanti (xs : char list) : char list =
  11.     match xs with
  12.     []->[]
  13.     |z::zs -> if z = ' '
  14.               then  zs
  15.               else  avanti zs;;
  16.  
  17. let rec split (xs : char list) : string list =
  18.     match xs with
  19.     [] -> []
  20.     | z::zs ->if z=' '
  21.               then split (avanti xs)
  22.               else [separa xs] @ split (avanti xs);;
  23.  
  24. // ------------------------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement