Nextjournal / Dec 18 2019
.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.Plotlylet 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.deb1.0s
.NET (Bash)
apt-get -qq updateDEBIAN_FRONTEND=noninteractive apt-get install \ dotnet-sdk-3.121.7s
.NET (Bash)
dotnet tool install --global dotnet-trydotnet tool install --global Paket10.2s
.NET (Bash)
dotnet new console -n fsharpcd fsharpdotnet add package FSharp.Datadotnet add package Octokitdotnet add package NodaTimedotnet add package FSharp.Chartingdotnet add package XPlot.Plotly#dotnet add package Angara.Charting24.0s
.NET (Bash)
dotnet try jupyter install4.9s
.NET (Bash)
rm -rf /tmp/* *.debdu -hsx /jupyter kernelspec list1.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 - 180.2s
F# Test (.NET (F#))
.NET
42
Test C#
(12/4 + 5 + 7) * 4 - 180.2s
C# Test (.NET (C#))
.NET
42