Strings de tres maneras en F#
printfn formatea, sprintf devuelve, la interpolación con $ empalma.
// Three ways to build strings: printfn formats, sprintf returns,
// and $-interpolation splices inline.
let hive = "Bramble"
let weightKg = 32.6
printfn "%s weighs %.1f kg" hive weightKg
let label = sprintf "%s-%d" hive 2026
printfn "Label: %s" label
let report = $"{hive} is at {weightKg} kg before the flow"
printfn $"Report: {report}"
printfn $"Rounded up: {ceil weightKg}"
Cómo funciona
%.1ffija decimales en la familia printf.sprintfarma el string en vez de imprimirlo.$"{hive} is at {weightKg} kg"interpola en línea.
Palabras clave y builtins usados aquí
let
El intento, en números
- Líneas
- 13
- Caracteres a escribir
- 380
- Tokens
- 51
- Ritmo de tres estrellas
- 70 tpm
Al ritmo de tres estrellas de 70 tokens por minuto, este intento toma unos 44 segundos.
Paso 3 de 3 en Valores; paso 3 de 27 en Fundamentos del lenguaje.