Skip to main content

¿ — Roll / Deal

Function. Keys: Alt-/. Hanzi: 掷/抽 (擲/抽). Ranks: 0 monadic, 0 0 dyadic

¿N: uniform draw from ιN. ¿0: U(0,1). Pervasive.

¿6 ∊ ι6ₓ           ⍝ $t

M¿N: M draws without replacement from ιN.

≢3¿10             ⍝ 3ₓ
≢∪3¿10            ⍝ 3ₓ

Bounds are nonnegative whole numbers; M≤N. Exact arguments give exact integer draws. Where integers wrap, under static kinds or at a fixed width, Roll gives integers for integer bounds, and an integer bound of 0, which would roll a float, raises DOMAIN. A float bound of 0 still rolls a float, as ¿0 does. Dyalog APL writes Roll and Deal as ?, which BPL uses for predicates.

¿ draws from the session’s generator, which starts from a seed that the operating system supplies. •prefs ["seed":n] seeds it with the nonnegative whole number n. •rand makes a separate generator and describes how draws advance its stream, including in maps.

•prefs ["seed":42] ◇ a←¿6 6 6 ◇ •prefs ["seed":42] ◇ a≡¿6 6 6    ⍝ $t