Algosim documentation: first

first

Returns the first or the N first elements of an ordered container.

Syntax

The returned value is an lvalue.

Description

Examples

sort(frequencies(compute(RandomInt(1000000)^2, n, 1, 1000000) @ digits @ first))
(1, 192164)
(2, 146925)
(3, 123873)
(4, 109158)
(5, 98564)
(6, 90439)
(7, 84566)
(8, 79092)
(9, 75219)
Alice ≔ ExampleData("Alice in Wonderland") \ 50
ALICE’S ADVENTURES IN WONDERLAND

Lewis Carroll
…
sort(frequencies(words(Alice) @ characters @ first @ UpperCase))
(A, 3358)
(B, 984)
(C, 903)
(D, 829)
(E, 378)
(F, 742)
(G, 574)
(H, 1575)
(I, 1968)
(J, 120)
(K, 262)
(L, 747)
(M, 897)
(N, 574)
(O, 1430)
(P, 493)
(Q, 186)
(R, 491)
(S, 2530)
(T, 4428)
(U, 262)
(V, 238)
(W, 1864)
(X, 3)
(Y, 550)
(Z, 2)
first(ColorGradient(1, 10, "white", "black"), 3)
rgba(1.000, 1.000, 1.000, 1.000)
rgba(0.890, 0.890, 0.890, 1.000)
rgba(0.776, 0.776, 0.776, 1.000)

See also