BellNumbers
The Bell numbers as a lazy indexed collection.
Wikipedia
Bell numberMathWorldBellNumberWikidataQ816063DLMF26.7.iOEISA000110Wolfram LanguageBellBSageMathsage.combinat.combinat.bell_number(n)mathlib4Nat.bellBellNumbersThe number of set partitions of an -set, an infinite indexed collection.Details
- A lazy indexed collection: , and unranks exactly via a memoised Bell (Aitken's) triangle, bigint throughout -- .
- OEIS A000110, starting exactly at its offset-0 term: ; already exceeds .
- Membership goes through Element: is true, is false.
Definition
Epsil, as the implementation runs it.
count()
PositiveInfinityunrank(_r)
Apply((hs_l: integer) => Apply((hs_n: integer) => Fold(
Function(hs_t if False else Join(
hs_t,
[Fold(
Function(hs_a +
Binomial(hs_m - 1, hs_j - 1) *
hs_t[hs_j], hs_a, hs_j),
0,
Range(1, hs_m, 1),
)],
), hs_t, hs_m),
[1],
Range(1, hs_l, 1),
), 0), _r)[_r + 1]rank(_x)
Apply(
(hs_b: integer) => Apply(
(hs_all: list<integer>) => Fold(
Function(
(hs_i if hs_p < 0 &&
hs_all[hs_i + 1] ==
_x else hs_p) if hs_i < Length(hs_all) else hs_p,
hs_p,
hs_i,
),
-1,
Range(
0,
hs_b,
1,
),
),
Apply((hs_l: integer) => Apply(
(hs_n: integer) => Fold(Function(
hs_t if hs_t[Length(hs_t)] > _x else Join(hs_t, [Fold(Function(hs_a +
Binomial(hs_m - 1, hs_j - 1) *
hs_t[hs_j], hs_a, hs_j), 0, Range(1, hs_m, 1))]),
hs_t,
hs_m,
), [1], Range(1, hs_l, 1)),
0,
), hs_b),
),
Apply(
(fl_r: list<integer>) => fl_r[2],
Fold(
Function([
(fl_s[1] - fl_s[1] % 2 ^ fl_k) / 2 ^ fl_k,
fl_s[2] + fl_k,
] if fl_s[1] >= 2 ^ fl_k else fl_s, fl_s, fl_k),
[_x + 2, 0],
[
8_192,
4_096,
2_048,
1_024,
512,
256,
128,
64,
32,
16,
8,
4,
2,
1,
],
),
) + 3,
) if _x >= 0 else -1valid(_x)
Apply(
(hs_b: integer) => Apply(
(hs_all: list<integer>) => Fold(
Function(
(hs_i if hs_p < 0 &&
hs_all[hs_i + 1] ==
_x else hs_p) if hs_i < Length(hs_all) else hs_p,
hs_p,
hs_i,
),
-1,
Range(
0,
hs_b,
1,
),
),
Apply((hs_l: integer) => Apply(
(hs_n: integer) => Fold(Function(
hs_t if hs_t[Length(hs_t)] > _x else Join(hs_t, [Fold(Function(hs_a +
Binomial(hs_m - 1, hs_j - 1) *
hs_t[hs_j], hs_a, hs_j), 0, Range(1, hs_m, 1))]),
hs_t,
hs_m,
), [1], Range(1, hs_l, 1)),
0,
), hs_b),
),
Apply(
(fl_r: list<integer>) => fl_r[2],
Fold(
Function([
(fl_s[1] - fl_s[1] % 2 ^ fl_k) / 2 ^ fl_k,
fl_s[2] + fl_k,
] if fl_s[1] >= 2 ^ fl_k else fl_s, fl_s, fl_k),
[_x + 2, 0],
[
8_192,
4_096,
2_048,
1_024,
512,
256,
128,
64,
32,
16,
8,
4,
2,
1,
],
),
) + 3,
) >= 0 if _x >= 0 else FalseEnumeration
Examples
1 more kept as data, checked against the oracles See also: Count, At, Element, FubiniNumbers, PartitionNumbers