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
import std.stdio, std.range, std.algorithm; | |
static immutable int[] KEYS = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4]; | |
void main() { | |
stdin.byLine.dropOne.each!((i, line) => writefln("Case #%d: %d", i+1, line.map!(c => (c == ' ' ? 1 : KEYS[c - 'a'])).sum)); | |
} |
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
// Simple citro2d sprite drawing example | |
// Images borrowed from: | |
// https://kenney.nl/assets/space-shooter-redux | |
#include <citro2d.h> | |
#include <assert.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> |
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
import std.string : format; | |
struct Soa(T, long n) { | |
static foreach (member; T.tupleof) { | |
mixin(format("typeof(member)[n] %s;", member.stringof)); | |
} | |
T opIndex(size_t index) const { | |
T result = void; |
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
void func(size_t size)() { | |
static foreach (p; 0..size) { | |
perform_some_action(p); | |
} | |
} | |
void perform_some_action(size_t p) { | |
import std.stdio : writeln; | |
writeln(p); | |
} |
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
// Simple citro2d sprite drawing example | |
// Images borrowed from: | |
// https://kenney.nl/assets/space-shooter-redux | |
#include <citro2d.h> | |
#include <assert.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> |
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 | |
set -e | |
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG | |
trap 'echo FAILED COMMAND: $previous_command' EXIT | |
#------------------------------------------------------------------------------------------- | |
# This script will download packages for, configure, build and install a GCC cross-compiler. | |
# Customize the variables (INSTALL_PATH, TARGET, etc.) to your liking before running. | |
# If you get an error and need to resume the script from some point in the middle, | |
# just delete/comment the preceding lines before running it again. |
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
// Tries to implement bitfields in the most ergonomic way I can think of. | |
// Inspired in part by what D's standard library did before the language supported bitfields. | |
#insert #run bitfields_struct( | |
"Thing", | |
bf("a", u32, 4), | |
bf("b", u32, 4), | |
bf("c", s32, 4), | |
bf("d", u32, 4), | |
); |
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
Simp :: #import "Simp"; | |
Input :: #import "Input"; | |
#import "Basic"; | |
#import "Random"; | |
#import "Math"; | |
#import "Window_Creation"; | |
#import "GL"; | |
Render_Texture :: struct { |