Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.14 KB | None | 0 0
  1. type osoba = {nazwa: string; wiek : int}
  2.  
  3. let rec listSzukaj (czN:string)(dane:osoba list) : osoba list =
  4.      match dane with
  5.      | [] -> []
  6.      | h::t -> if h.nazwa.EndsWith(czN) then h::listSzukaj czN t
  7.                else listSzukaj czN t
  8.      //List.filter (fun x -> x.nazwa.Contains(czN)) dane
  9.  
  10. let listSortuj (dane:osoba list) = List.sortBy (fun x -> x.nazwa) dane
  11.  
  12. type drzewo<'a> =
  13.     | Lisc of 'a
  14.      | Wezel of ('a * (drzewo<'a> list))
  15.  
  16. let rec dodajWiel = function
  17.      | [], b -> b
  18.      | _ as a, [] -> a
  19.      | ah::at, bh::bt -> (ah + bh)::dodajWiel(at, bt)
  20.  
  21. let rec aplikujRozniczke st l =
  22.      match l with
  23.      | [] -> []
  24.      | h::t -> (st * h) :: aplikujRozniczke (st + 1.0) t
  25.  
  26. let rozniczkuj (w:float list) =
  27.      match w with
  28.      | [] -> []
  29.      | [h] -> []
  30.      | h::t -> aplikujRozniczke 1.0 t
  31.  
  32.  
  33. [<EntryPoint>]
  34. let main argv =
  35.      printfn "%A" <| [ for i in 1..10 do yield i*i ]
  36.      printfn "%A" <| listSortuj [{nazwa="Bcd"; wiek=1};
  37.          {nazwa="Zxc"; wiek=2};
  38.          {nazwa="Def"; wiek=3}]
  39.      printfn "%A" <| rozniczkuj [-5.0; 6.0; 4.0; -2.0; 0.0; 1.0]
  40.      0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement