Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System
- open System.Runtime.InteropServices
- type prostytutka = {imie:string; wiek:int}
- let prost1 = {imie="Roksana"; wiek=21}
- let rec suma (fl_list:list<float>) =
- match fl_list with
- | head :: tail -> head + suma tail
- | [] -> 0.0
- let lista = [1.1; 1.2; 1.3]
- let str = "XXX"
- let rec zliczanie_znakow(st:string, ch:char, i:int, n:int) =
- match i with
- | 0 -> if st.[0] = ch then n+1 else n
- | _ -> if st.[0] = ch then zliczanie_znakow(st, ch, i-1, n+1) else zliczanie_znakow(st, ch, i-1, n);
- let rec licz (str:string, znak:char) =
- match str.Length with
- | 0 -> 0
- | _ -> if(str.[0] = znak) then licz(str.[1..], znak) + 1 else licz(str.[1..], znak );
- let listaa = [1.1;2.2;3.3;1.0]
- let rec sumlist(lista:float list) =
- match lista.Length with
- | 0 -> 0.0
- | _ -> sumlist(lista.[1..]) + lista.[0]
- let rec silnia(n) =
- match n with
- |0 |1 -> 1
- |_ -> silnia(n-1) * n
- let rec potega(k, n) =
- match n with
- | 0.0 -> 1.0
- | _ -> if n > 0.0 then potega(k, n-1.0) * k
- else 1.0/potega(k, -n)
- let rec wdol(n) =
- match n with
- | 0 -> []
- | _ -> n::wdol(n-1)
- let calkowite :int list= [1;2;3;4]
- let rec sumator(lista : int list) =
- match lista.Length with
- | 0 -> 0
- | _ -> if ((lista.[0] % 2) = 0)
- then sumator(lista.[1..]) + lista.[0]
- else sumator(lista.[1..])
- let rec sum4(lista:float list) =
- match lista with
- | head::head2::head3::head4::tail -> (head+head2+head3+head4)::sum4(tail)
- | head::head2::head3::tail -> (head+head2+head3)::sum4(tail)
- | head::head2::tail -> head::sum4(tail)
- | head::tail -> head::sum4(tail)
- | [] -> []
- let rec sum_head(lista) =
- match lista with
- | head :: tail -> sum_head(tail) + head
- | _ -> 0
- let rec zlicz_znak_own(str:string, ch:char) =
- match str.Length with
- | 0 -> 0
- | _ -> if (str.[0] = ch) then 1 + zlicz_znak_own(str.[1..], ch) else zlicz_znak_own(str.[1..], ch)
- let rec sumator_own(lista:float list) =
- match lista.Length with
- | 0 -> 0.0
- | _ -> lista.[0] + sumator_own(lista.[1..] )
- let rec checkElementIfInList(f:float, lista2:float list) =
- match lista2.Length with
- | 0 -> false
- | _ -> if (lista2.[0] = f) then true
- else checkElementIfInList(f, lista2.[1..])
- let rec intersec(lista1:float list,lista2:float list) =
- match lista1.Length with
- | 0 -> []
- | _ -> if (checkElementIfInList(lista1.[0],lista2)) then lista1.[0]::intersec(lista1.[1..],lista2)
- else intersec(lista1.[1..],lista2)
- [<EntryPoint>]
- let main argv =
- printfn "Suma %A" (suma(lista))
- printfn "Zliczone iksy %A" (zliczanie_znakow(str, 'X' ,str.Length-1, 0))
- printfn "Dane kurwy %A" (prost1)
- printfn "Liczałka %A" (licz(str, 'X'))
- printfn "Lista sumator %A" (sumlist(listaa))
- (silnia(4)) |> printfn "Slnia z 4: %A"
- (potega(2.0, -3.0)) |> printfn "potega 2 do 3: %A"
- (wdol(8)) |> printfn "odlicanie w dol: %A"
- printfn "Suma parzystych %A" (sumator(calkowite))
- printfn "add3 %A" (sum4(listaa))
- printfn "sum by head::tail %A" (sum_head(calkowite))
- printfn "zlicza znak own = %A" (zlicz_znak_own("TwojaSara", 'a'))
- printfn "sumator own = %A" (sumator_own([1.1;2.2;3.3]))
- let lista1 = [1.0;2.0;3.0;4.0;5.0]
- let lista2 = [1.0;0.0;0.0;0.0;0.0;5.0;0.0;0.0;0.0;0.0;3.0]
- let inter = intersec(lista1,lista2)
- printfn "wpolne som 1 i 5 i 3 = %A" inter
- ignore(Console.ReadKey(true))
- 0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement