2 ms·
[1, 2, for (x of xs) { if (cond) {emit x} }] What are 1 and 2 doing? What is emit? Where does x go ? Is the above code just: filter cond xs
by mrkeen 4y ago
[1, 2, for (x of xs) {
if (cond) {emit x}
}]
What are 1 and 2 doing? What is emit? Where does x go ?
Is the above code just:
filter cond xs
?
- wruza 4y agoIt results into [1, 2, …(some xs satisfying cond)]. Emit does just that - emit another value into a context where for-expr was used. It emits some of x-es into that array literal. filter cond xs More like 1:2:filter cond xs.