Code Explainers

Code explainers tagged #lookup-tables

ruby
class UserAgentParser
  BROWSERS = [
    [/Edg\/([\d.]+)/, "Edge"],
    [/OPR\/([\d.]+)/, "Opera"],

Parsing user-agent strings in Ruby

regex pattern-matching lookup-tables
Intermediate 8 steps
ruby
class Pluralizer
  IRREGULARS = {
    "person" => "people",
    "child" => "children",

Building an English pluralizer in Ruby

regular-expressions lookup-tables string-manipulation
Intermediate 8 steps
rust
use std::sync::OnceLock;
 
static CRC_TABLE: OnceLock<[u32; 256]> = OnceLock::new();
 

Table-driven CRC32 with lazy init in Rust

checksums lazy-initialization lookup-tables
Intermediate 8 steps