Todos los libros

Profesional

Apps Acerca de Coach Iniciar sesión Empezar a leer

Computer Science · Glosario

¿Qué es Map operation, filter, fold?

También llamado: map operation · filter · fold

Definition 9.3 University Computer Science — Year 2 · Capítulo 9 — Functional Programming

On a sequence [x1,…,xn][x_1, \dots, x_n], the map operation with a function ff gives [f(x1),…,f(xn)][f(x_1), \dots, f(x_n)]; the filter with a predicate pp keeps the xix_i with p(xi)p(x_i) true, in order; the fold from zz with a two-argument function gg gives g(…g(g(z,x1),x2)…,xn)g(\dots g(g(z, x_1), x_2) \dots, x_n) (a left fold; the right fold is g(x1,g(x2,…g(xn,z)))g(x_1, g(x_2, \dots g(x_n, z)))). Sums, counts, maxima, and the building of collections are folds.

Leer en el capítulo →