Sha256: 7120e19bfb2940a8fc4a3b58d9ffce0d1b3ad90f8260b95a126517e9fb809cb5

Contents?: true

Size: 607 Bytes

Versions: 396

Compression:

Stored size: 607 Bytes

Contents

module Diamond

let make letter =     
        
    let makeLine letterCount (row, letter) = 
        let outerSpaces  = "".PadRight(letterCount - row - 1)
        let innerSpaces = "".PadRight(if row = 0 then 0 else row * 2 - 1)

        if letter = 'A' then sprintf "%s%c%s" outerSpaces letter outerSpaces
        else sprintf "%s%c%s%c%s" outerSpaces letter innerSpaces letter outerSpaces
    
    let letters = ['A'..letter] |> List.mapi (fun x y -> x, y)

    letters @ (letters |> List.rev |> List.tail)
    |> List.map (makeLine letters.Length)
    |> List.reduce (fun x y -> sprintf "%s\n%s" x y)

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.97 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.96 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.95 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.94 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.93 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.92 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.91 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.90 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.89 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.88 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.87 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.86 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.85 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.84 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.83 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.82 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.81 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.80 tracks/fsharp/exercises/diamond/Example.fs
trackler-2.2.1.79 tracks/fsharp/exercises/diamond/Example.fs