Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sigma-andex/scala-fast-vect
Fast 🐆, type-safe vectors for Scala
https://github.com/sigma-andex/scala-fast-vect
dependent-types scala vect
Last synced: about 2 months ago
JSON representation
Fast 🐆, type-safe vectors for Scala
- Host: GitHub
- URL: https://github.com/sigma-andex/scala-fast-vect
- Owner: sigma-andex
- Created: 2022-12-19T16:39:15.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-03T21:12:30.000Z (about 2 years ago)
- Last Synced: 2024-10-27T16:13:10.009Z (3 months ago)
- Topics: dependent-types, scala, vect
- Language: Scala
- Homepage:
- Size: 12.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# scala-fast-vect 🐆
Fast, type-safe vector libary for Scala. This library is a port of my Purescript library [`purescript-fast-vect`](https://github.com/sigma-andex/purescript-fast-vect) and both libs are heavily inspired by [Idris](https://www.idris-lang.org/). A vector is list with its size encoded in the type.
## Usage
```scala
import fastvect.*
import fastvect.list.{given, *}val zero: Vect[0, String] = Vect.empty[String]
val one: Vect[1, String] = Vect.singleton("a")
val h: String = one.head
val as: Vect[100, String] = Vect.replicate[100, String]("a")
val bs: Vect[200, String] = Vect.replicate[200, String]("b")
val cs: Vect[300, String] = as ++ bs
val ds = cs.drop[99]
val es: String = as.index[99]
val l1: String = Vect.singleton("a").last
val fives: Option[Vect[5, String]] =
Vect.from[5, String](List("a", "b", "c", "d"))
val xs: Vect[3, String] = (Vect.replicate("a"): Vect[2, String]) :+ "b"
val ys: Vect[4, String] = "c" +: xs
val zs = Vect.from[5, Int](List(1,2,3,4))
```