Advertisement
Guest User

Untitled

a guest
Jun 10th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 2.29 KB | None | 0 0
  1. open System
  2.  
  3. let lista = [1;5;7;6;4;3;5;3;63;3;52;12;7;12;3]
  4.  
  5. let rec funkcja xs : int list =
  6.     match xs with
  7.     | [] -> []
  8.     | x::y::xs -> if (x > y) then x::funkcja xs else y::funkcja xs;
  9.     | x::xs -> x::funkcja xs;
  10.  
  11. let rec dodej lysta i : int list =
  12.     match lysta with
  13.     | [] -> []
  14.     | x::lysta -> x::i::dodej lysta i;
  15.  
  16. let rec liczString (wyraz:string) (znak:string) (dl: int) : int =
  17.     match dl with
  18.     | -1 -> 0
  19.     | dl -> if wyraz.[dl] = znak.[0] then 1 + (liczString wyraz znak (dl - 1)) else 0 + (liczString wyraz znak (dl - 1));
  20.  
  21. let wyraz = "asdasdasdddd";
  22. let znak = "d";
  23. let dl = wyraz.Length - 1;
  24.  
  25. let rec srednia (suma:float) (ilosc:int) =
  26.     let liczba = Console.ReadLine()
  27.     let liczbaC = Convert.ToDouble(liczba)
  28.     if liczbaC = 0.0 then (
  29.         if suma = 0.0 then Double.NaN else
  30.             (suma / (double ilosc))
  31.             ) else srednia (suma + liczbaC) (ilosc + 1);
  32.  
  33. // liczenie samogłosek
  34. let czySamogloska (c:char)  =
  35.     match c with
  36.     | 'a' | 'e' | 'i' | 'o' | 'u' | 'y' -> true
  37.     | _ -> false;
  38.  
  39. let rec liczSamogloski (wyraz:string) dl =
  40.     match dl with
  41.     | -1 -> 0
  42.     | _ -> if czySamogloska (Char.ToLower(wyraz.[dl])) = true then 1 + liczSamogloski wyraz (dl - 1) else 0 + liczSamogloski wyraz (dl - 1);
  43.  
  44.  
  45. // male Litery
  46. let isSmall (litera:char) =
  47.     if litera = Char.ToLower(litera) then true else false;
  48.  
  49. let rec maleLitery (wyraz:string) (dl: int) =
  50.     match dl with
  51.     | -1 -> true
  52.     | _ -> if isSmall wyraz.[dl] = true then maleLitery wyraz (dl - 1) else false;
  53.  
  54.  
  55. let rec listaCreate (n:int) (znak:char) : char list  =
  56.     match n with
  57.     | 0 -> []
  58.     | _ ->  znak::listaCreate (n - 1) znak;
  59.  
  60.  
  61. type sumShit = { name: string; dickSize: int }
  62. let me = { name =  "Tomek"; dickSize = 22};
  63.  
  64.  
  65. let rec threeList lista : int list =
  66.     match lista with
  67.     | x::y::z::xs -> (x + y + z)::threeList xs
  68.     | x::y::xs -> (x + y)::threeList xs
  69.     | x::xs -> x::threeList xs
  70.     | [] -> [];
  71.  
  72. let rec suma lista =
  73.     match lista with
  74.     | x::xs -> x + suma xs
  75.     | [] -> 0;
  76.  
  77. [<EntryPoint>]
  78. let main argv =
  79.     printfn "Hello World from F#!";
  80.     let l = [1;2;3;4;5]
  81.     let wyraz = suma l;
  82.     let x = listaCreate 8 'n'
  83.     printfn "%A" wyraz;
  84.     0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement