4 ms·
Python "with", C++ RAII (and ADA, D, Rust, and Vala). This is hardly a new concept.
by dragontamer 11y ago
Python "with", C++ RAII (and ADA, D, Rust, and Vala).
This is hardly a new concept.
- kazinator 11y agoNone of these will apply a square to N items, and then the inverse (square root) to the sum of those squares. This is really more like map-reduce, with an additional inverse step deduced from the inverse of the function that is used for the map step. With map-reduce, we can map all the inputs individually through a square function, and then reduce with +. Okay, that brings us to sum of squares. "Under" adds one more step: to "undo" the squaring with a square root, and without being explicitly given the square root function. If we have a zoo of functions that are all associated with inverses, we can roll this into a single operation. Say a functional combinator under(T, P) which takes a processing function P (which takes one or more arguments) and a transforming function T (one argument), and produces a new function F which is of the same arity as P, such that F(a, b, c, ...) calculates T_inverse(P(T(a), T(b), T(c), ...)). The we have under(square, sum)(1, 2, 3) to take the norm of 1, 2 and 3.
- dragontamer 11y agoThx for the correction. Point understood.