Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exception UJEMNY_ARGUMENT ;;
- let rec ( ^^ ) b p =
- if p = 0 then 1
- elif p < 0 then -1
- else b * (b ^^ (p - 1))
- let rec suma m n =
- if n = 0 then m
- elif n > 0 then m + n + suma m (n - 1)
- else raise UJEMNY_ARGUMENT
- let tylkoMaleLitery s =
- Array.forall(fun el -> System.Char.ToLower el = el) (Seq.toArray s)
- let rec mRn m n =
- if n = 0 then 0
- elif n = 1 then m
- elif n > 0 then m + mRn m (n - 1)
- else raise UJEMNY_ARGUMENT
- let rec wystOdItego (str: string, i, ch) =
- if str = "" then 0
- elif i <= str.Length then 0
- elif (str.Substring i).StartsWith ch then 1 + wystOdItego (str.Substring 1) 0 ch
- else -1
- [<EntryPoint>]
- let main _ =
- printf "^^: %d %d %d\n" (2 ^^ 4) (2 ^^ 0) (2 ^^ -1)
- printf "suma: %d %d %d\n" (suma 2 4) (suma 2 0) (suma 2 -1)
- printf "tylkoMaleLitery abc %b Abc %b '' %b" (tylkoMaleLitery "abc") (tylkoMaleLitery "Abc") (tylkoMaleLitery "")
- printf "\nmRn %d %d %d %d" (mRn 4 5) (mRn 4 0) (mRn 4 1) (mRn -4 2)
- printf "\nwystOdItego %d" (wystOdItego "abccab" 2 "a")
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement