In [1]:
"Last value displayed"
Out[1]:
In [2]:
errors are displayed
In [3]:
Util.Html("<b>Inline HTML</b>") |> Display
Out[3]:
In [5]:
Util.Url("http://fsharp.org/img/logo/fsharp256.png") |> Display
Out[5]:
In [7]:
Util.Math("f(x) = sin(x)") |> Display
Out[7]:
In [8]:
let data = [ ("F#", 10); ("C#", 5); ("C++", 20); ("Java", 1); ]
Util.Table(data) |> Display
Out[8]:
In [9]:
1+11
Out[9]:
In [11]:
//#load "FSCharting.Gtk.fsx" // Mac/Linux
#load "FSCharting.fsx" // Windows
In [12]:
FSharp.Charting.Chart.Bar(data) |> Display
Out[12]:
In [13]:
FSharp.Charting.Chart.Line(data) |> Display
Out[13]:
In [14]:
let linspace (min : float, max : float, dx : float) =
if min > max then failwith (sprintf "min [%f] cannot be greater than max [%f]" min max)
if dx = 0.0 then failwith ("dx cannot be zero")
let x = ref min
seq {
while !x < max do
x := !x + dx
yield !x
}
In [15]:
let plot (data:seq<float>, cb) =
let results =
seq {
for x in data do
yield (x, cb(x))
}
FSharp.Charting.Chart.Line (results)
In [16]:
let x = linspace (-10.0, 10.0, 0.1)
plot(x, fun y -> sin(y)) |> Display
Util.Math "f(x) = sin(x)" |> Display
Out[16]:
In [17]:
(** This actually does animation when running *)
open System.Threading
for i in 1 .. 100 do
Clear() |> ignore
let x = linspace(-10.0 + float(i), float(i), 0.1) |> Seq.toArray
let c1 = plot(x, sin)
let c2 = plot(x, cos)
FSharp.Charting.Chart.Combine([c1; c2])
|> FSharp.Charting.Chart.WithSize(640, 480)
|> Display
|> ignore
Thread.Sleep(20)
Out[17]:
In [ ]: