re: Daily Challenge #88 - Recursive Ninjas VIEW POST

FULL DISCUSSION
 

F#, used an uint8 so you can't call chirp with an argument < 0.

module DailyChallenge

let chirp (n : uint8) : string =
    "chirp"
    |> Seq.replicate (int n)
    |> String.concat "-"

This assumes that the . in the example belongs to the comment, not the actual chirp output. In case the . is necessary, the following step can be added at the end of the pipeline:

    |> sprintf "%s."

Tests:

module DailyChallengeTests

open FsUnit.Xunit
open Xunit
open DailyChallenge

[<Fact>]
let ``single chirp``() = 
    chirp 1uy |> should equal "chirp"

[<Fact>]
let ``4 chirps``() = 
    chirp 4uy |> should equal "chirp-chirp-chirp-chirp"

[<Fact>]
let ``0 chirps``() = 
    chirp 0uy |> should equal ""
code of conduct - report abuse