numbat 1.23.0

A statically typed programming language for scientific computations with first class support for physical dimensions and units.
Documentation
use core::quantities
use core::lists
use plot::common

struct LinePlot<X: Dim, Y: Dim> {
  x_label: String,
  y_label: String,
  xs: List<X>,
  ys: List<Y>,
}
let _num_points_for_line_plot = 2000

fn line_plot<X: Dim, Y: Dim>(f: Fn[(X) -> Y], x_start: X, x_end: X) -> LinePlot<X, Y> =
  LinePlot {
    x_label: "",
    y_label: "",
    xs: xs,
    ys: map(f, xs)
  }
  where
    xs = linspace(x_start, x_end, _num_points_for_line_plot)

fn xlabel<X: Dim, Y: Dim>(label: String, plot: LinePlot<X, Y>) -> LinePlot<X, Y> =
  LinePlot {  # TODO: this would be much nicer with some form of struct update syntax: `plot { x_label: label }`
    x_label: label,
    y_label: plot.y_label,
    xs: plot.xs,
    ys: plot.ys,
  }

fn ylabel<X: Dim, Y: Dim>(label: String, plot: LinePlot<X, Y>) -> LinePlot<X, Y> =
  LinePlot {
    x_label: plot.x_label,
    y_label: label,
    xs: plot.xs,
    ys: plot.ys,
  }