Rename the language from Dino to Rex
Files use .rex, the command is rex, and the crate, runtime prefixes, docs, editor files and examples all use the new name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2f44f09b6a
commit
7cf9727bcd
94 files changed
+858
-858
No files matched your search
@@ -0,0 +1,45 @@
|
||||
func primes_up_to(n: int): []int {
|
||||
var is_prime: []bool
|
||||
for i in 0..n + 1 {
|
||||
is_prime.push(true)
|
||||
}
|
||||
is_prime[0] = false
|
||||
is_prime[1] = false
|
||||
for i in 2..n + 1 {
|
||||
if is_prime[i] {
|
||||
for j in i * i..n + 1 step i {
|
||||
is_prime[j] = false
|
||||
}
|
||||
}
|
||||
}
|
||||
var out: []int
|
||||
for i, p in is_prime {
|
||||
if p {
|
||||
out.push(i)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func bubble_sort(xs: []int): []int {
|
||||
var n = xs.len()
|
||||
for i in 0..n {
|
||||
for j in 0..n - i - 1 {
|
||||
if xs[j] > xs[j + 1] {
|
||||
var tmp = xs[j]
|
||||
xs[j] = xs[j + 1]
|
||||
xs[j + 1] = tmp
|
||||
}
|
||||
}
|
||||
}
|
||||
return xs
|
||||
}
|
||||
|
||||
func main() {
|
||||
var ps = primes_up_to(60)
|
||||
print(ps)
|
||||
print("count:", ps.len())
|
||||
var unsorted = [9, 4, 7, 1, 8, 2]
|
||||
var sorted = bubble_sort(unsorted)
|
||||
print(unsorted, "->", sorted)
|
||||
}
|
||||
Reference in new issue
Block a user