Introduction

Importing

To add this library to an sbt project

libraryDependencies += "ai.dragonfly" %%% "slash" %  "0.3.1"

To use this library in ammonite / mill

import $ivy.`ai.dragonfly::slash:0.3.1

scala-cli

using dep ai.dragonfly::slash:0.3.1

Elevator pitch

import slash.vector.*
val aVector = Vec[3](1,2,3)
// aVector: Vec[3] = Array(1.0, 2.0, 3.0)
val times2 = aVector * 2
// times2: Vec[3] = Array(2.0, 4.0, 6.0)
aVector + times2
// res0: Vec[3] = Array(3.0, 6.0, 9.0)

But attemping to add a vector of the wrong dimension will fail at compile time

val oopsDimension = Vec.ones[2]
aVector + oopsDimension

// error:
// Found:    (repl.MdocSession.MdocApp.oopsDimension : slash.vector.Vec[(2 : Int)])
// Required: slash.vector.Vec[(3 : Int)]
// aVector + oopsDimension
//           ^^^^^^^^^^^^^

These typesafe operations are the same on the JVM, Native and JS platforms. They take advantge of a shim of the underlying native array definitions - thus maximisng performance, so that you don't have to. For further reading, see Design notes