vitamin
1.0.0
维生素赋予您强大的力量,您需要它,而当您不这样做时不会妨碍您。
注意:该语言目前是一种正在进行的工作,因此希望大多数事情不起作用!
通过一些示例程序了解维生素。
有关完整说明,请参阅语言参考手册。
文档和更多示例也会在维生素语言网站上反映。网站上的代码摘录更易于阅读,因为它们具有语法凸台!
简单的嘶嘶声
fizzbuzz(i: Int) =
case
of i mod 15 == 0 'FizzBuzz'
of i mod 3 == 0 'Fizz'
of i mod 5 == 0 'Buzz'
of _ Str(i)
for i in range(100)
print(fizzbuzz(i))
类型安全大小的向量
# Vectors of length `n` and element type `a` are pointers to mutable values of type `a`
unique Vector(n: Size, a: Type) = Record(items: &mut a)
# Parameters `n`, `m` and `a` will be computed and passed implicitly
concat(x: Vector($n, $a), y: Vector($m, a)) =
items = new(mut, a, count=n + m)
copy(from=x.items, to=items, count=n)
copy(from=y.items, to=offset(items, n), count=m)
(items=items) as Vector(n + m, a)
# Assume these vectors are defined somewhere else
a : Vector(3, Int)
b : Vector(2, Int)
assert type-of(concat(a, b)) == Vector(5, Int)
需要NIM 1.4.2和灵活。
chmod +x build
# install dependencies
./build setup
# run tests (optional)
./build test
# compile for the current architecture
./build维生素二进制vita将出现在bin目录中。
托多
默认情况下,维生素期望在~/.local/lib/vita或/usr/lib/vita中存在res/lib的内容。您还可以将其他库路径添加到VITAPATH环境变量(由结肠隔开的路径: 。
# assuming `vita` is in PATH
# run a program
vita script.v
# run an interactive session
vitavim:基本语法支持
res/vitamin.vim到vim/neovim syntax目录.vimrc : au BufRead,BufNewFile *.{v,vita} set filetype=vitaminVisual Studio代码:基本语法支持
Vitamin扩展( ext install maxadamski.vitamin ) 随时开放问题以提出问题或提出建议。
贡献非常欢迎。