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
| /* Vec */ | |
| #include <stdarg.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #define LAST_OF(array, length) array[length-1] | |
| size_t get_capacity(size_t length) | |
| { |
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #define DEFAULT_START 0 | |
| #define DEFAULT_STEP(START, STOP) START < STOP ? 1 : -1 | |
| #define TO_INT(STR) (int)strtol(STR, NULL, 10) | |
| #define IS_HELP_FLAG(STR) (!strcmp(STR, "--help")) || (!strcmp(STR, "-h")) |
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
| // only works on Compiler Explorer with x86-64 gcc | |
| // gcc hello.c -o hello && ./hello | |
| extern int(puts)(char const *); | |
| char static *message = "Hello World!\n"; | |
| __attribute__((used)) void f(void) | |
| { | |
| puts(message); |
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
| from __future__ import annotations | |
| import abc | |
| import dataclasses | |
| import enum | |
| import typing | |
| from collections.abc import Callable | |
| T1 = typing.TypeVar("T1") | |
| T2 = typing.TypeVar("T2") |
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
| import os | |
| import sys | |
| # Printing? No. | |
| del sys.stdout | |
| # Really, no. | |
| del sys.__stdout__ | |
| # Errors? "uhhhh object address: [...] lost sys.stderr" | |
| del sys.stderr | |
| # Recovery of stderr: no |
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
| import os | |
| __annotations__ = globals() | |
| fib: \ | |
| (lambda n: | |
| n if n <= 1 else fib(n - 2) + fib(n - 1)) | |
| main: \ | |
| (lambda: |
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
| refined Nat n where | |
| n :: (Integer t) => t | |
| n >= 0 |
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
| import Data.Foldable (foldr1) | |
| {- | |
| Fold a list of values into an elevated operator. | |
| This allows applying an operator on a list which values type do not | |
| support the operator, but can be casted to a type which does. | |
| The `toLifted` function casts every value of `values` to a type that `op` | |
| accepts, then `fromLifted` casts back the result to the `values` type. |
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
| # | |
| # ~/.bashrc | |
| # | |
| # If not running interactively, don't do anything | |
| [[ $- != *i* ]] && return | |
| [[ -f ~/.welcome_screen ]] && . ~/.welcome_screen | |
| _set_liveuser_PS1() { |
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
| module (~python { | |
| def fib(n: int) -> int: | |
| if n <= 1: | |
| return n | |
| return fib(n - 2) + fib(n - 1) | |
| }) MyModule | |
| function MyModule.fib fib | |
| function (args::List<String>) -> UInt8 { |