Carbon is a programming language created in 2020 by Chandler Carruth and Jon Ross-Perkins.
#292on PLDB | 4Years Old |
git clone https://github.com/carbon-language/carbon-lang
Carbon Language's main repository: documents, design, implementation, and related tools. (NOTE: Carbon Language is experimental; see README)
package Sorting api;
fn Partition[T:! Comparable & Movable](s: Slice(T))
-> i64 {
var i: i64 = -1;
for (e: T in s) {
if (e <= s.Last()) {
++i;
Swap(&s[i], &e);
}
}
return i;
}
fn QuickSort[T:! Comparable & Movable](s: Slice(T)) {
if (s.Size() <= 1) {
return;
}
let p: i64 = Partition(s);
QuickSort(s[:p - 1]));
QuickSort(s[p + 1:]));
}
package sample api;
fn Square(x: i32) -> i32 {
return x * x;
}
fn Main() -> i32 {
return Square(12);
}