WebPPL Unofficial Reference Manual

Contents

  • Philosophy: docs that don’t lie
  • Data shapes and call forms
  • Distributions
  • Functional Programming
    • Functional programming basics
    • Cache (memoization)
  • Cookbook (patterns and “when to use what”)
WebPPL Unofficial Reference Manual
  • Functional Programming
  • Edit on GitHub

Functional Programming

WebPPL looks like JavaScript, but in practice it should be treated as a functional fraction of JavaScript.

Contents

  • Functional programming basics
    • WebPPL is a functional subset of JavaScript
    • What “functional programming” means here
    • A useful mental model
    • Key terms (short definitions)
    • Why this matters in probabilistic programming
    • Common pitfalls (and the FP-friendly alternative)
    • Executable micro-example: closures
    • Where to go next
  • Cache (memoization)
    • What cache does
    • Why this matters for functional programming
    • When cache is safe: pure/deterministic computations
    • Example: caching an expensive deterministic computation
    • When cache is a modeling tool: one latent value per key
    • Good modeling example: a stable latent trait per individual
    • When cache is dangerous: you accidentally remove independence
    • Bad example: you wanted a fresh coin flip every time
    • A simple rule of thumb
    • See also
    • Executable example
Previous Next

© Copyright 2026.

Built with Sphinx using a theme provided by Read the Docs.