Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System
- exception UJEMNY_ARGUMENT;;
- let razyDwa x = 2 * x;;
- let past x=
- match x with
- | "run" -> "ran"
- | "do" -> "done"
- | "swim" -> "swam"
- | x -> x + "ed"
- | _ -> "blad"
- let rec silnia x =
- match x with
- | 0 -> 1
- | _ -> x*(silnia (x - 1));;
- let rec siln (n) =
- if (n = 0) then 1
- elif n > 0 then n * (siln (n-1))
- else raise UJEMNY_ARGUMENT;;
- let parz n =
- if (n % 2) = 0 then true
- else false;;
- let parz2 n = (n % 2) = 0;;
- let ( ---> ) p q = (not p) || q;;
- let czyItyCharWStringu (str:System.String) i ch = str.Chars(i) = ch;
- let rec ( ^^ ) m n=
- if n=0 then 1
- else m * (m^^(n-1));;
- let rec suma (m, n) =
- if (n = 0) then m
- else m + suma (m, n - 1) + n;;
- let rec tylkoMale (st:System.String, i:int) =
- if i <> 0 then (
- if (Char.IsUpper(st.[0])) then false
- else tylkoMale(st, i - 1)
- )
- else true;;
- let sprawdzString (st:System.String) = tylkoMale (st, st.Length - 1);;
- let rec ( & ) m n =
- match n with
- | 0 -> 0
- | 1 -> m
- | _ -> m + m * (n-1);;
- let mutable res = 0
- let mutable str = ""
- let rec wystOdItego (st:string, i:int, ch:char) =
- str <- st
- if (i > str.Length-1) then res
- else (
- str <- str.Substring(i,str.Length-i)
- printf "%A\n" str
- if str.[0] = ch then res <- res+1
- else res <- res
- wystOdItego(str, 1, ch)
- );;
- [<EntryPoint>]
- let main argv =
- let wynik = wystOdItego("dbcdadwdqqq",5,'d')
- printf "%A\n" wynik
- System.Console.ReadKey() |> ignore
- 0 // zwracanie kodu zakończenia w postaci liczby całkowitej
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement