This file contains hidden or 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
| getPairs :: [Int] -> [(Int, Int)] | |
| getPairs [] = [] | |
| getPairs [_] = [] | |
| getPairs (x:y:xs) = (x,y) : getPairs (y:xs) | |
| getDiff :: [(Int, Int)] -> [Int] | |
| getDiff [] = [] | |
| getDiff ((x1, x2):xs) = (x2 - x1) : getDiff xs | |
| generate :: [Int] -> [[Int]] |
This file contains hidden or 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/bash | |
| setxkbmap -option caps:ctrl_modifier no & | |
| do_dwm () | |
| { | |
| slstatus & | |
| picom -b & | |
| nitrogen --restore & | |
| dunst -font "iosveka" & |
This file contains hidden or 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; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |