drop some libc functions, octal numerals, io.println, mem.read32
This commit is contained in:
@@ -20,7 +20,7 @@ func main[] : I64
|
||||
else if op == '-'
|
||||
str.set(memory, p, memory[p]-1)
|
||||
else if op == '.'
|
||||
c.printf("%c", memory[p])
|
||||
io.print_char(memory[p])
|
||||
else if op == ','
|
||||
str.set(memory, p, c.getchar())
|
||||
else if op == '['
|
||||
|
||||
@@ -4,4 +4,4 @@ func main[] : I64
|
||||
for i in 0..1000
|
||||
if i % 5 == 0 | i % 3 == 0
|
||||
sum = sum + i
|
||||
io.print_i64(sum)
|
||||
io.println_i64(sum)
|
||||
@@ -4,4 +4,4 @@ func main[] : I64
|
||||
for i in 0..2000000
|
||||
if math.is_prime(i)
|
||||
sum = sum + i
|
||||
io.print_i64(sum)
|
||||
io.println_i64(sum)
|
||||
@@ -16,6 +16,6 @@ func main[] : I64
|
||||
while true
|
||||
n = n + i
|
||||
if num_divisors(n) > 500
|
||||
io.print_i64(n)
|
||||
io.println_i64(n)
|
||||
break
|
||||
i = i + 1
|
||||
@@ -3,4 +3,4 @@ func main[] : I64
|
||||
37107287533 + 46376937677 + 74324986199 + 91942213363 + 23067588207 + 89261670696 + 28112879812 + 44274228917 + 47451445736 + 70386486105 + 62176457141 + 64906352462 + 92575867718 + 58203565325 + 80181199384 + 35398664372 + 86515506006 + 71693888707 + 54370070576 + 53282654108 + 36123272525 + 45876576172 + 17423706905 + 81142660418 + 51934325451 + 62467221648 + 15732444386 + 55037687525 + 18336384825 + 80386287592 + 78182833757 + 16726320100 + 48403098129 + 87086987551 + 59959406895 + 69793950679 + 41052684708 + 65378607361 + 35829035317 + 94953759765 + 88902802571 + 25267680276 + 36270218540 + 24074486908 + 91430288197 + 34413065578 + 23053081172 + 11487696932 + 63783299490 + 67720186971 + 95548255300 + 76085327132 + 37774242535 + 23701913275 + 29798860272 + 18495701454 + 38298203783 + 34829543829 + 40957953066 + 29746152185 + 41698116222 + 62467957194 + 23189706772 + 86188088225 + 11306739708 + 82959174767 + 97623331044 + 42846280183 + 55121603546 + 32238195734 + 75506164965 + 62177842752 + 32924185707 + 99518671430 + 73267460800 + 76841822524 + 97142617910 + 87783646182 + 10848802521 + 71329612474 + 62184073572 + 66627891981 + 60661826293 + 85786944089 + 66024396409 + 64913982680 + 16730939319 + 94809377245 + 78639167021 + 15368713711 + 40789923115 + 44889911501 + 41503128880 + 81234880673 + 82616570773 + 22918802058 + 77158542502 + 72107838435 + 20849603980 + 53503534226
|
||||
|> str.from_i64()
|
||||
|> str.substr(0, 10)
|
||||
|> io.print()
|
||||
|> io.println()
|
||||
@@ -19,4 +19,4 @@ func main[] : I64
|
||||
if seq > max
|
||||
max = seq
|
||||
max_index = i
|
||||
io.print_i64(max_index)
|
||||
io.println_i64(max_index)
|
||||
@@ -6,4 +6,4 @@ func main[] : I64
|
||||
for i in 1..r+1
|
||||
out = out * (n - (r - i)) / i
|
||||
|
||||
io.print_i64(out)
|
||||
io.println_i64(out)
|
||||
@@ -10,4 +10,4 @@ func main[] : I64
|
||||
b = a + b
|
||||
a = temp
|
||||
|
||||
io.print_i64(sum)
|
||||
io.println_i64(sum)
|
||||
@@ -8,4 +8,4 @@ func main[] : I64
|
||||
else
|
||||
f = f + 1
|
||||
|
||||
io.print_i64(n)
|
||||
io.println_i64(n)
|
||||
@@ -10,4 +10,4 @@ func main[] : I64
|
||||
out = a * b
|
||||
mem.free(s)
|
||||
mem.free(s_rev)
|
||||
io.print_i64(out)
|
||||
io.println_i64(out)
|
||||
@@ -3,4 +3,4 @@ func main[] : I64
|
||||
|
||||
for i in 1..21
|
||||
out = math.lcm(out, i)
|
||||
io.print_i64(out)
|
||||
io.println_i64(out)
|
||||
@@ -8,4 +8,4 @@ func main[] : I64
|
||||
square_of_sum = square_of_sum + i
|
||||
square_of_sum = square_of_sum * square_of_sum
|
||||
|
||||
io.print_i64(square_of_sum - sum_of_squares)
|
||||
io.println_i64(square_of_sum - sum_of_squares)
|
||||
@@ -6,6 +6,6 @@ func main[] : I64
|
||||
if math.is_prime(i)
|
||||
found = found + 1
|
||||
if found == 10001
|
||||
io.print_i64(i)
|
||||
io.println_i64(i)
|
||||
break
|
||||
i = i + 1
|
||||
@@ -11,4 +11,4 @@ func main[] : I64
|
||||
j = j + 1
|
||||
if s > out
|
||||
out = s
|
||||
io.print_i64(out)
|
||||
io.println_i64(out)
|
||||
@@ -3,5 +3,5 @@ func main[] : I64
|
||||
for b in 1..1000
|
||||
let c: I64 = 1000 - b - a
|
||||
if a * a + b * b == c * c
|
||||
io.print_i64(a * b * c)
|
||||
io.println_i64(a * b * c)
|
||||
return 0
|
||||
@@ -3,7 +3,7 @@ func main[] : I64
|
||||
let b: I64 = 1
|
||||
|
||||
while a < 100000
|
||||
io.print_i64(a)
|
||||
io.println_i64(a)
|
||||
let temp: I64 = b
|
||||
b = a + b
|
||||
a = temp
|
||||
@@ -2,13 +2,13 @@ func main[] : I64
|
||||
let answer: I64 = math.abs(math.urandom()) % 100
|
||||
|
||||
while true
|
||||
io.print("Guess a number: ")
|
||||
io.println("Guess a number: ")
|
||||
let guess: I64 = io.read_stdin() |> str.trim() |> str.parse_i64()
|
||||
|
||||
if guess == answer
|
||||
io.print("You win!")
|
||||
io.println("You win!")
|
||||
break
|
||||
else if guess < answer
|
||||
io.print("Too low!")
|
||||
io.println("Too low!")
|
||||
else
|
||||
io.print("Too high!")
|
||||
io.println("Too high!")
|
||||
@@ -1,2 +1,2 @@
|
||||
func main[] : I64
|
||||
io.print("Hello, World!")
|
||||
io.println("Hello, World!")
|
||||
@@ -4,12 +4,12 @@ func main[] : I64
|
||||
array.push(arr, math.abs(math.urandom() % 1000))
|
||||
|
||||
for i in 0..array.size(arr)
|
||||
io.print_i64(array.nth(arr, i))
|
||||
io.print("------------")
|
||||
io.println_i64(array.nth(arr, i))
|
||||
io.println("------------")
|
||||
|
||||
alg.quicksort(arr)
|
||||
|
||||
for i in 0..array.size(arr)
|
||||
io.print_i64(array.nth(arr, i))
|
||||
io.println_i64(array.nth(arr, i))
|
||||
|
||||
array.free(arr)
|
||||
@@ -1,4 +1,4 @@
|
||||
// musl doesnt like dlopen, needs to be compiled with -m -C="/usr/local/lib/libraylib.a -lm"
|
||||
// needs to be compiled with -m -C="/usr/local/lib/libraylib.a -lm"
|
||||
|
||||
func main[] : I64
|
||||
extern InitWindow
|
||||
@@ -11,11 +11,6 @@ func main[] : I64
|
||||
extern DrawRectangle
|
||||
extern IsKeyDown
|
||||
|
||||
let KEY_W: I64 = 87
|
||||
let KEY_S: I64 = 83
|
||||
let KEY_A: I64 = 65
|
||||
let KEY_D: I64 = 68
|
||||
|
||||
let x: I64 = 200
|
||||
let y: I64 = 200
|
||||
|
||||
@@ -23,13 +18,13 @@ func main[] : I64
|
||||
SetTargetFPS(60)
|
||||
|
||||
while !WindowShouldClose()
|
||||
if IsKeyDown(KEY_W) & 255
|
||||
if IsKeyDown(87) & 255 // W
|
||||
y = y - 10
|
||||
if IsKeyDown(KEY_S) & 255
|
||||
if IsKeyDown(83) & 255 // S
|
||||
y = y + 10
|
||||
if IsKeyDown(KEY_A) & 255
|
||||
if IsKeyDown(65) & 255 // A
|
||||
x = x - 10
|
||||
if IsKeyDown(KEY_D) & 255
|
||||
if IsKeyDown(68) & 255 // D
|
||||
x = x + 10
|
||||
|
||||
BeginDrawing()
|
||||
|
||||
@@ -18,10 +18,10 @@ func rule110_step[state: Array] : Array
|
||||
func print_state[state: Array]: Void
|
||||
for i in 0..array.size(state)
|
||||
if array.nth(state, i)
|
||||
c.putchar('#')
|
||||
io.print_char('#')
|
||||
else
|
||||
c.putchar(' ')
|
||||
io.print("")
|
||||
io.print_char(' ')
|
||||
io.println("")
|
||||
|
||||
func main[] : I64
|
||||
let SIZE: I64 = 60
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
// musl doesnt like dlopen, needs to be compiled with -m
|
||||
// needs to be compiled with -m -C="-lX11"
|
||||
|
||||
func main[] : I64
|
||||
let x11: Ptr = c.dlopen("libX11.so", 2)
|
||||
|
||||
let XOpenDisplay: Ptr = c.dlsym(x11, "XOpenDisplay")
|
||||
let XDefaultRootWindow: Ptr = c.dlsym(x11, "XDefaultRootWindow")
|
||||
let XCreateSimpleWindow: Ptr = c.dlsym(x11, "XCreateSimpleWindow")
|
||||
let XMapWindow: Ptr = c.dlsym(x11, "XMapWindow")
|
||||
let XSelectInput: Ptr = c.dlsym(x11, "XSelectInput")
|
||||
let XNextEvent: Ptr = c.dlsym(x11, "XNextEvent")
|
||||
let XBlackPixel: Ptr = c.dlsym(x11, "XBlackPixel")
|
||||
let XWhitePixel: Ptr = c.dlsym(x11, "XWhitePixel")
|
||||
let XSetForeground: Ptr = c.dlsym(x11, "XSetForeground")
|
||||
let XCreateGC: Ptr = c.dlsym(x11, "XCreateGC")
|
||||
let XDefaultScreen: Ptr = c.dlsym(x11, "XDefaultScreen")
|
||||
let XDrawString: Ptr = c.dlsym(x11, "XDrawString")
|
||||
extern XOpenDisplay
|
||||
extern XDefaultRootWindow
|
||||
extern XCreateSimpleWindow
|
||||
extern XMapWindow
|
||||
extern XSelectInput
|
||||
extern XNextEvent
|
||||
extern XBlackPixel
|
||||
extern XWhitePixel
|
||||
extern XSetForeground
|
||||
extern XCreateGC
|
||||
extern XDefaultScreen
|
||||
extern XDrawString
|
||||
|
||||
let dpy: Ptr = XOpenDisplay(0)
|
||||
let screen: Ptr = XDefaultScreen(dpy)
|
||||
|
||||
Reference in New Issue
Block a user