vitamin
1.0.0
ビタミンはあなたがそれを必要とする大きな力をあなたに与え、あなたがそうしないとき、あなたの邪魔をしません。
注:この言語は現在進行中のものですので、ほとんどのことが機能しないことを期待してください!
いくつかのプログラムの例でビタミンを知りましょう。
完全な説明については、言語リファレンスマニュアルを参照してください。
ドキュメントやその他の例は、Vitamin Language Webサイトにも反映されています。 Webサイトのコード抜粋は、構文ハイリッティングがあるため、読みやすいです!
シンプルなフィズのバズ
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ディレクトリに表示されます。
トト
デフォルトでは、ビタミンは、 res/libの内容物が~/.local/lib/vitaまたは/usr/lib/vitaに存在することを期待しています。また、他のライブラリパスを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=vitaminビジュアルスタジオコード:基本的な構文サポート
Vitaminエクステンション( ext install maxadamski.vitamin )をインストールする質問をしたり、提案をしたりするために、お気軽に問題を開いてください。
貢献は大歓迎です。