Skip to content

Commit

Permalink
complete internal overhaul and add basic tcp
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7d8 committed Feb 26, 2025
1 parent 6c16925 commit 37a44bd
Show file tree
Hide file tree
Showing 19 changed files with 832 additions and 444 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bad-lang-2"
version = "0.2.1"
version = "0.3.0"
edition = "2024"

[[bin]]
Expand Down
28 changes: 12 additions & 16 deletions samples/bogosort.bl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ fn is_sorted(n) {
if (#lt(len, 2)) {
return true
}

let prev = array#get(n, 0)
prev = array#get(n, 0)
// This double assignment is because the language
// is broken currently
let j = null
j = 1
let sorted = null
sorted = true

let j = 1
let sorted = true
loop {
if (#eq(j, len)) {
sorted = true
Expand All @@ -28,29 +25,28 @@ fn is_sorted(n) {

fn bogosort(n) {
let len = array#len(n)
// Non-fn scope variables seem broken atm
let i = null
let new_pos = null
let tmp = null

loop {
if (is_sorted(n)) {
break
}
i = 0
let i = 0
loop {
if (#gt(#=("{} + 1", i), len)) {
break
}
new_pos = math#round(rng#rand_range(0, #=("{} - 1", len)))
tmp = array#get(n, new_pos)

let new_pos = math#round(rng#rand_range(0, #=("{} - 1", len)))
let tmp = array#get(n, new_pos)

array#set(n, new_pos, array#get(n, i))
array#set(n, i, tmp)
i++
}
}
}

let numbers = [5, 4, 3, 2, 1, 0, -1]
let numbers = [5, -1, 4, 3]

io#println("Before:")
io#println(numbers)
Expand All @@ -61,4 +57,4 @@ io#println("After:")
io#println(numbers)
io#println("In:")
io#println(#=("{} - {}", end, start))
io#println("s")
io#println("s")
2 changes: 2 additions & 0 deletions samples/random.bl
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
loop {
// Always NaN
io#println(rng#rand_range(nan, 100))

// f64 in [0, 1)
io#println(rng#rand())

// f64 in [0, 9] intersection N
io#println(math#round(rng#rand_range(0, #=("{} - 1", 10))))
}
Loading

0 comments on commit 37a44bd

Please sign in to comment.