This text is italic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
types.h - a header file for Rust/Jai like types in C. | |
Copyright (C) 2023 marvhus | |
This program is free software: you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation, either version 3 of the License, or | |
(at your option) any later version. | |
This program is distributed in the hope that it will be useful, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Coroutine: # I JUST WANT STRUCTS, BUT THIS LANGUAGE WONT LET ME | |
def __init__(self, start, end, name): | |
self.iterator = Coroutine.coroutine(start, end, name) | |
self.is_done = False | |
def next(self): | |
if not self.is_done: | |
self.is_done = next(self.iterator) | |
return self.is_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/jai | |
#import "Basic"; | |
Rule :: struct { | |
num: u32; | |
str: string; | |
} | |
fizzbuzz :: (rules: [] Rule, max: u32) { | |
msg: String_Builder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COUNT :: 1_000_000; | |
arr : [COUNT] bool; | |
sieve :: () { | |
// Computer primes using sieve of Eratosthenes | |
for 1..arr.count-1 { arr[it] = true; } | |
arr[1] = false; | |
for idx: 2..(COUNT / 2) - 1 { | |
j := 2 * idx; | |
while j < COUNT { | |
arr[j] = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
u8_to_string :: (c: u8) -> string { | |
buff: String_Builder; | |
init_string_builder(*buff); | |
append(*buff, c); | |
return builder_to_string(*buff); | |
} | |
u8_to_string :: (cs: []u8) -> string { | |
buff: String_Builder; | |
init_string_builder(*buff); | |
for c: cs { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Small script to count lines in .jai files | |
# Cloc doesn't support jai, so I just made this for now | |
files=$(find $1 -name "*.jai") | |
if [ "$1" == "" ]; then | |
echo "No path" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main :: () { | |
print("What is your name?\n> "); | |
name := input(); | |
print("Hello, %!\n", name); | |
} | |
#import "Basic"; | |
#if OS == .LINUX { | |
#import "POSIX"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fizzbuzz :: (low: u32, high: u32) { | |
_print :: (str: string) #expand { | |
print("%", str); | |
`already_printed = true; | |
} | |
for i: low..high { | |
already_printed := false; | |
if i % 3 == 0 then _print("Fizz"); | |
if i % 5 == 0 then _print("Buzz"); | |
if !already_printed then print("%", i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs; | |
const CHARSET: &[u8] = b"QWlKoxp3mT9EeRb4YzgG6rNj1OLvZ5SDfMBaXtP8JyIFVH07uh2wicdnUAC#@q"; | |
fn encode(input: String) -> String { | |
let input_bytes = input.as_bytes(); | |
let mut output = Vec::new(); | |
let mut temp = 0u32; | |
let mut temp_len = 0u8; |
OlderNewer