« Fsharp » : différence entre les versions
De Banane Atomic
Aller à la navigationAller à la recherche
Ligne 28 : | Ligne 28 : | ||
<kode lang='fs'> | <kode lang='fs'> | ||
printf "Enter a value: " | printf "Enter a value: " | ||
let input = | let input = Console.ReadLine() | ||
printfn "Entered value: %s" input | printfn "Entered value: %s" input | ||
</kode> | </kode> |
Version du 24 septembre 2022 à 11:55
Command line
dotnet fsi # start F# Interactive dotnet fsi script.fsx # run script.fsx dotnet new console -o fsharp1 -lang f# |
printf
let s = "value" printfn "text %A text" s |
Format | Type |
---|---|
%A | any |
%s | string |
%i | integer |
%b | boolean |
Console input
printf "Enter a value: " let input = Console.ReadLine() printfn "Entered value: %s" input |
.vscode/launch.json |
{ "configurations": [ { "console": "integratedTerminal" // // switch from internalConsole to integratedTerminal to allow console input in VS code } ] } |
Dev env
- VScode
- Ionide for F# extension → intellisense
- fantomas-fmt → format F#
Create launch and tasks
- Disable the Ionide for F# extension
- Run → Run Without Debugging
- Select environment: .NET 5+ and .NET Core (this create the launch.json file)
- Open launch.json → Add Configuration → .NET: Launch .NET Core Console App
- Fill target-framework = net6.0 and project-name = myproject
- Run → Run Without Debugging
- Configure Task → Create tasks.json file from template → Select a Task Template: .NET Core