re: Daily Challenge #88 - Recursive Ninjas VIEW POST

FULL DISCUSSION
 

Reason

let rec chirp = (times: int, ~result: string="", ()) =>
  switch (times) {
  | 0 => result ++ "."
  | _ =>
    switch (result) {
    | "" => chirp(times - 1, ~result=result ++ "chirp", ())
    | __ => chirp(times - 1, ~result=result ++ "-chirp", ())
    }
  };

Elm


chirp : Int -> String
chirp times =
    case times of
        1 ->
            "chirp."
        _ ->
            "chirp-" ++ (chirp <| times - 1)
code of conduct - report abuse