Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
I can't print char from string

I tried this:

open System
let main() =
    let mutable str1 = "qwerty"
    printfn "%c" str1[0]
main()

got this:

error FS0597: Successive arguments should be separated by spaces or tupled, and arguments involving function or method applications should be parenthesized

I found this site: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/strings and here it's working I don't know why. I found other sites, where everyone said about parentheses

open System
let main() =
    let mutable str1 = "qwerty"
    printfn "%c" (str1[0])
main()

and got this:

error FS0003: This value is not a function and cannot be applied

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

If you want to print a single character from a string you actually need to put a dot in between the object and the squared brackets.

printfn "%c" str1.[0]

MSFT docs: Access elements

Here writes Microsoft:

You can access array elements by using a dot operator (.) and brackets ([ and ]).

However, their example actually also does not include the dot. Nevertheless, in order to access array elements, you need to use the dot operator.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda