Capitalize in F#

Published on 06 April 2026 (Updated: 06 April 2026)

Welcome to the Capitalize in F# page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

open System

module Capitalizer =
    let private capitalize (input: string) =
        let chars = input.ToCharArray()
        chars.[0] <- Char.ToUpper chars.[0]
        String chars

    let run input = capitalize input |> Ok

module Helpers =
    let private (|NonEmptyString|_|) (s: string) =
        if String.IsNullOrWhiteSpace s then None else Some s

    let parseArgs =
        function
        | [| NonEmptyString input |] -> Ok input
        | _ -> Error "Usage: please provide a string"

    let handleResult =
        function
        | Ok result ->
            printfn "%s" result
            0
        | Error msg ->
            eprintfn "%s" msg
            1

[<EntryPoint>]
let main argv =
    argv |> Helpers.parseArgs |> Result.bind Capitalizer.run |> Helpers.handleResult

Capitalize in F# was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.