February 2019
Beginner to intermediate
180 pages
4h 4m
English
We can replace makeBy with makeByU if we uncurry its second argument. This will improve performance (a negligible amount in our example):
...makeByU(52, (. i) => switch (i / 13, i mod 13) { | (0, rank) => {suit: Hearts, rank: rank + 1} | (1, rank) => {suit: Diamonds, rank: rank + 1} | (2, rank) => {suit: Spades, rank: rank + 1} | (3, rank) => {suit: Clubs, rank: rank + 1} | _ => assert(false) })...
The dot syntax requires parentheses around i.
Read now
Unlock full access