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
#include <stdlib.h> | |
#include <stdint.h> | |
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) | |
typedef enum { | |
SIDE_LEFT = 0, | |
SIDE_RIGHT, | |
SIDE_COUNT, | |
} AVL_Side; |
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
template<class> | |
class Function {}; | |
template<class R, class ...Args> | |
class Function<R(Args...)> { | |
private: | |
template<class F> | |
static R type_erase(const void *fn, Args... args) { | |
return (*(const F*)fn)(args...); | |
} |
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
/* | |
arena.h - Zap's personal approach to arena allocation | |
USAGE | |
This is an STB-style single-header library. | |
#define ARENA_IMPLEMENTATION // (in *one* C file) | |
#include "arena.h" | |
#define ARENA_ALLOC and ARENA_DEALLOC to avoid using malloc/free and create a | |
custom backend for the allocator. |
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 Queue { | |
#start = 0 | |
#end = 0 | |
#len = 0 | |
#cap = 1 << 10 | |
#cap_mask = this.#cap - 1 | |
#data = new Array(this.#cap) |
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
from mpmath import pi | |
import mpmath | |
mpmath.mp.dps = 20 | |
def generate_cos(): | |
weights = [-1, 0, 1, 0] | |
fac = 1 | |
pow = 1 |
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
#ifndef SQRT_HPP | |
#define SQRT_HPP | |
#include <type_traits> | |
template <typename T> | |
constexpr T sqrt(T value) { | |
if constexpr (std::is_integral_v<T>) { | |
T op = value; | |
T res = 0; |
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
async function safe_eval(code) { | |
const mod_code = `export default () => ${code}` | |
const mod_blob = new Blob([mod_code], { type: "text/javascript" }) | |
const mod_url = URL.createObjectURL(mod_blob) | |
const mod = await import(mod_url) | |
URL.revokeObjectURL(mod_url) | |
return mod.default() | |
} |
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
#ifndef JS_PRINTF_H | |
#define JS_PRINTF_H | |
// This is free and unencumbered software released into the public domain. | |
// Anyone is free to copy, modify, publish, use, compile, sell, or distribute this | |
// software, either in source code form or as a compiled binary, for any purpose, | |
// commercial or non-commercial, and by any means. | |
// In jurisdictions that recognize copyright laws, the author or authors of this | |
// software dedicate any and all copyright interest in the software to the public | |
// domain. We make this dedication for the benefit of the public at large and to |
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
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
// Version 2, December 2004 | |
// | |
// Copyright (C) 2023 Zap | |
// | |
// Everyone is permitted to copy and distribute verbatim or modified | |
// copies of this license document, and changing it is allowed as long | |
// as the name is changed. | |
// | |
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
const ITEM = Math.PI | |
const input = new Array(2000000).fill(ITEM) | |
Deno.bench({group: "grow", baseline: true}, function deque_grow(timer) { | |
const deque = new Deque() | |
for (let i = 0; i < 1000; ++i) deque.pushBack(ITEM) | |
timer.start() | |
for (let i = 0; i < 20; ++i) { |
NewerOlder