3 ms·
In MAGMA, a computer algebra programming language, there is a “exists” statement which takes a comprehension and evaluates to true if any item is true, somethin
by joppy 5y ago
In MAGMA, a computer algebra programming language, there is a “exists” statement which takes a comprehension and evaluates to true if any item is true, something like exists{x % 2 == 0 for x in numbers}. But it also has an extra parameter which can bind the value of the first item satisfying the condition, something like
If exists(y){x : x % 2 == 0 for x in numbers}:
Print y
There is also a “for all” statement which can return the first offender which does not satisfy the condition.
It’s an awkward but incredibly useful language choice - it would be interesting to see it explored more in mainstream languages.