Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type osoba = {nazwa: string; wiek : int}
- let rec listSzukaj (czN:string)(dane:osoba list) : osoba list =
- match dane with
- | [] -> []
- | h::t -> if h.nazwa.EndsWith(czN) then h::listSzukaj czN t
- else listSzukaj czN t
- //List.filter (fun x -> x.nazwa.Contains(czN)) dane
- let listSortuj (dane:osoba list) = List.sortBy (fun x -> x.nazwa) dane
- type drzewo<'a> =
- | Lisc of 'a
- | Wezel of ('a * (drzewo<'a> list))
- let rec dodajWiel = function
- | [], b -> b
- | _ as a, [] -> a
- | ah::at, bh::bt -> (ah + bh)::dodajWiel(at, bt)
- let rec aplikujRozniczke st l =
- match l with
- | [] -> []
- | h::t -> (st * h) :: aplikujRozniczke (st + 1.0) t
- let rozniczkuj (w:float list) =
- match w with
- | [] -> []
- | [h] -> []
- | h::t -> aplikujRozniczke 1.0 t
- [<EntryPoint>]
- let main argv =
- printfn "%A" <| [ for i in 1..10 do yield i*i ]
- printfn "%A" <| listSortuj [{nazwa="Bcd"; wiek=1};
- {nazwa="Zxc"; wiek=2};
- {nazwa="Def"; wiek=3}]
- printfn "%A" <| rozniczkuj [-5.0; 6.0; 4.0; -2.0; 0.0; 1.0]
- 0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement