.NET Environment

This notebook describes and creates the default .Net environment in Nextjournal, which supports F# and C#. Check out the showcase if you want to see what the environment contains. To see how it’s built, see setup.

Showcase

F#

open XPlot.Plotly
let openSeries =
    Scatter(
        name = "Open",
        x = [1; 2; 3; 4],
        y = [10; 15; 13; 17])
let closeSeries =
    Scatter(
        name = "Close",
        x = [2; 3; 4; 5],
        y = [16; 5; 11; 9])
[openSeries; closeSeries]
|> Chart.Plot
|> Chart.WithTitle "Open vs Close"
2.1s
F# Test (.NET (F#))
.NET

C#

using XPlot.Plotly;
var openSeries = new Graph.Scatter
{
    name = "Open",
    r = new[] {1, 2, 3, 4},
    t = new[] {45, 100, 150, 290}
};
var closeSeries = new Graph.Scatter
{
    name = "Close",
    r = new[] { 2,3,4,5 },
    t = new[] { 16, 45, 118, 90 }
};
openSeries.mode = "markers";
closeSeries.mode = "markers";
var chart = Chart.Plot(new[] {openSeries, closeSeries});
chart.WithTitle("Open vs Close");
chart.WithLayout(new Layout.Layout
            {
                orientation = -90
            });
display(chart);
2.3s
C# Test (.NET (C#))
.NET

Setup

Install .NET

Install Microsoft repo.

wget -q -O packages-microsoft-prod.deb \
  https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb 
dpkg -i packages-microsoft-prod.deb
1.0s
.NET (Bash)
apt-get -qq update
DEBIAN_FRONTEND=noninteractive apt-get install \
  dotnet-sdk-3.1
21.7s
.NET (Bash)
dotnet tool install --global dotnet-try
dotnet tool install --global Paket
10.2s
.NET (Bash)
dotnet new console -n fsharp
cd fsharp
dotnet add package FSharp.Data
dotnet add package Octokit
dotnet add package NodaTime
dotnet add package FSharp.Charting
dotnet add package XPlot.Plotly
#dotnet add package Angara.Charting
24.0s
.NET (Bash)
dotnet try jupyter install
4.9s
.NET (Bash)
rm -rf /tmp/* *.deb
du -hsx /
jupyter kernelspec list
1.6s
.NET (Bash)

Test F#

printfn "Hello World from F#!"
0.6s
F# Test (.NET (F#))
.NET
Console.WriteLine("A string: {0}", 42)
0.7s
F# Test (.NET (F#))
.NET
(12/4 + 5 + 7) * 4 - 18
0.2s
F# Test (.NET (F#))
.NET
42

Test C#

(12/4 + 5 + 7) * 4 - 18
0.2s
C# Test (.NET (C#))
.NET
42
Runtimes (3)
Runtime Languages (2)