Start a new Kumite
AllAgda (Beta)BF (Beta)CCFML (Beta)ClojureCOBOL (Beta)CoffeeScriptCommonLisp (Beta)CoqC++CrystalC#D (Beta)DartElixirElm (Beta)Erlang (Beta)Factor (Beta)Forth (Beta)Fortran (Beta)F#GoGroovyHaskellHaxe (Beta)Idris (Beta)JavaJavaScriptJulia (Beta)Kotlinλ Calculus (Beta)LeanLuaNASMNim (Beta)Objective-C (Beta)OCaml (Beta)Pascal (Beta)Perl (Beta)PHPPowerShell (Beta)Prolog (Beta)PureScript (Beta)PythonR (Beta)RacketRaku (Beta)Reason (Beta)RISC-V (Beta)RubyRustScalaShellSolidity (Beta)SQLSwiftTypeScriptVB (Beta)
Show only mine

Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.

You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.

A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.

Ad
Ad

Raise 2 to the power 10 without using Math.pow or defining your own function.

Make it in one expression.

let x = let rec pow2 n = match n with | 0 -> 1 | _ -> 2 * pow2 (n - 1) in pow2 10
printfn "%i" x

power function

let rec power a n = match n with | 0 -> 1 | _ -> a * power a (n - 1)

printfn "%i" (power 2 4)
printfn "%i" (power 3 3)
printfn "%i" (power 4 2)

rev function (rec)

let rec reverse xs =
    match xs with
    | [] -> xs
    | head :: tail -> reverse tail @ [head]

printfn "%A" (reverse [1;2;3;4;5])
wichuFailed Tests

Factorial

let rec factorial = function | 0 -> 1 | n -> factorial(n - 1) * n

printfn "%i" (factorial 0)
printfn "%i" (factorial 1)
printfn "%i" (factorial 2)
printfn "%i" (factorial 3)
printfn "%i" (factorial 4)
printfn "%i" (factorial 5)
printfn "%i" (factorial 6)
let rec times (s : string) n = match n with | 1 -> s | _ -> s + times s (n - 1)

printfn "%s" (times "*" 5)
printfn "%s" (times "he " 5)
wichuFailed Tests

List Ops

let list = [1; 2; 1; 3; 5; 4; 6; 7]

printfn "%A" (list |> List.rev)
printfn "%A" (list |> List.distinct)
printfn "%A" (list |> List.sort)
printfn "%A" (list |> List.sortDescending)
printfn "%A" (list |> List.sum)
printfn "%A" (list |> List.min)
printfn "%A" (list |> List.max)
printfn "%A" (list |> List.toArray)
printfn "%A" (list |> List.toArray |> List.ofArray)
printfn "%A" (list |> List.append [8; 9])
printfn "%A" (list |> List.contains 5)
printfn "%A" (list |> List.exists(fun x -> x = 3))
printfn "%A" (list |> List.forall(fun x -> x < 8))
printfn "%A" (list |> List.find(fun x -> x = 1))
printfn "%A" (list |> List.findIndex(fun x -> x = 5))
printfn "%A" (list |> List.filter(fun x -> x = 1))
printfn "%A" (list |> List.map(fun x -> x + 1))
printfn "%A" (list |> List.mapi(fun i x -> (i, x)))
printfn "%A" (list |> List.reduce(fun acc x -> acc + x * x))
printfn "%A" (list |> List.fold(fun acc x -> acc + x * x) -100)
printfn "%A" (list |> List.chunkBySize(3))
let rec len xs =
    match xs with
    | [] -> 0
    | head :: tail -> 1 + len tail

printfn "%i" (len [])
printfn "%i" (len [1])
printfn "%i" (len [1;2;3])
printfn "%i" (len [1;1;1;1;1])
let rec sum xs =
    match xs with
    | [] -> 0
    | head :: tail -> head + sum tail

printfn "%i" (sum [])
printfn "%i" (sum [1])
printfn "%i" (sum [1;2;3])
printfn "%i" (sum [1;1;1;1;1])
printfn "%i" (sum [1..100])
let rec maxR xs =
    match xs with
    | [] -> failwith "Empty list"
    | [head] -> head
    | head :: tail -> max head (maxR tail)   

printfn "%i" (maxR [1])
printfn "%i" (maxR [1;2;3])
printfn "%i" (maxR [1;1;1;1;1])
printfn "%i" (maxR [1;1;2;1;1])
printfn "%i" (maxR [1..100])
wichuFailed Tests

Jessica Jones

type Person = { FirstName : string; LastName : string }

let jj = { FirstName = "Jessica"; LastName = "Jones" }

let { FirstName = firstName } = jj
let { LastName = lastName } = jj

printfn "%s" firstName
printfn "%s" lastName