Skip to content

Instantly share code, notes, and snippets.

@Snektron
Snektron / radix-sort.zig
Created March 29, 2020 00:27
Zig radix sort
const std = @import("std");
const Log2Int = std.math.Log2Int;
const IntType = std.meta.IntType;
fn radix(comptime T: type, comptime bits: Log2Int(T), shift: Log2Int(T), value: T) IntType(false, bits) {
const RadixType = IntType(false, bits);
return @intCast(RadixType, (value >> shift) & std.math.maxInt(RadixType));
}
fn partialRadixSort(comptime T: type, comptime bits: Log2Int(T), shift: Log2Int(T), src: []const T, dst: []T) void {
@jordwalke
jordwalke / myComponent.ml
Last active December 13, 2021 17:32
React OCaml API
open ReactDOM
module MyComponent = struct
(* Component Properties *)
type props = {count: int}
(* Hey, state can be any type! *)
type state = string
(* Initializer *)