LoginSignup
2
2

More than 1 year has passed since last update.

.Net Core で F# を使う

Last updated at Posted at 2018-03-08

次のベージを参考にしました。
Getting started with F# and .NET Core

次のバージョンで確認しました。

$ dotnet --version
6.0.302

サンプルプログラムの用意

mkdir example
cd example
dotnet new console -lang f#
dotnet add package Newtonsoft.Json

Program.fs が出来るので、そのファイルを次のように改造します。改行コードも変更して構いません。

Program.fs
// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main argv =
    printfn "こんにちは"
    printfn "Hello World from F#!"
    printfn "2022年8月7日"
    0 // return an integer exit code

コンパイル

dotnet build

実行

$ dotnet run
こんにちは
Hello World from F#!
2022年8月7日

実行ファイル(バイナリー)を作成するには、

dotnet publish -c release -r linux-x64

作成した実行ファイル(バイナリー)を実行

$ ./bin/release/net6.0/linux-x64/example
こんにちは
Hello World from F#!
2022年8月7日

C# の使い方はこちら
Linux で .Net Core を使う

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2