Skip to content

BellNumbers ​

The Bell numbers 1,1,2,5,15,52,…1, 1, 2, 5, 15, 52, … as a lazy indexed collection.

BellNumbersThe number of set partitions of an nn-set, an infinite indexed collection.

Domain: Collections

Details
  • A lazy indexed collection: Count(BellNumbers)=+∞Count(BellNumbers) = +\infty, and At(BellNumbers,k)At(BellNumbers, k) unranks Bk−1B_{k-1} exactly via a memoised Bell (Aitken's) triangle, bigint throughout -- At(BellNumbers,5)=B4=15At(BellNumbers, 5) = B_4 = 15.
  • OEIS A000110, starting exactly at its offset-0 term: 1,1,2,5,15,52,203,…1, 1, 2, 5, 15, 52, 203, …; B25B_{25} already exceeds 2532^{53}.
  • Membership goes through Element: Element(15,BellNumbers)Element(15, BellNumbers) is true, Element(10,BellNumbers)Element(10, BellNumbers) is false.

Definition

Epsil, as the implementation runs it.

count()

PositiveInfinity

unrank(_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 -1

valid(_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 False

Enumeration

Examples

1 more kept as data, checked against the oracles
About
Examples1
CrosswalkWikipediaMathWorldWikidataDLMFOEISWolfram LanguageSageMathmathlib4

See also: Count, At, Element, FubiniNumbers, PartitionNumbers