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,60 @@
|
||||
func sum(xs: []int): int {
|
||||
var total = 0
|
||||
for x in xs {
|
||||
total += x
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func squares(n: int): []int {
|
||||
var out: []int
|
||||
for i in 0..n {
|
||||
out.push(i * i)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func largest(xs: []int): int {
|
||||
var best = xs[0]
|
||||
for x in xs {
|
||||
if x > best {
|
||||
best = x
|
||||
}
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
func main() {
|
||||
var nums = [5, 3, 8, 1]
|
||||
print(nums, nums.len())
|
||||
print("sum:", sum(nums), "largest:", largest(nums))
|
||||
|
||||
nums.push(10)
|
||||
nums[0] = 50
|
||||
nums[1] += 7
|
||||
print(nums)
|
||||
print("popped", nums.pop(), "left", nums.len())
|
||||
|
||||
var sq = squares(6)
|
||||
print(sq)
|
||||
print(sq[1..4], sq[..2], sq[4..])
|
||||
|
||||
for i, x in sq {
|
||||
if i % 2 == 0 {
|
||||
print("sq[{i}] = {x}")
|
||||
}
|
||||
}
|
||||
|
||||
// an empty list needs a type
|
||||
var empty: []string
|
||||
print(empty, empty.len())
|
||||
empty.push("a")
|
||||
empty.push("b")
|
||||
print(empty, "{empty.len()} items")
|
||||
|
||||
var floats: []float = [1, 2.5, 3]
|
||||
print(floats)
|
||||
|
||||
var words = ["rex", "lang"]
|
||||
print(words[0] + "-" + words[1], words[0].len())
|
||||
}
|
||||
Reference in new issue
Block a user