4 ms·
k/q does this. They're called views[1] z::x+y x:42 y:42 z y:69 z [1]: https://code.kx.com/v2/ref/view/ https://code.kx.com/v2/ref/view
by geocar 8y ago
k/q does this. They're called views[1]
z::x+y
x:42
y:42
z
y:69
z
[1]: https://code.kx.com/v2/ref/view/ https://code.kx.com/v2/ref/view/
- repsilat 8y agoAnd JS :-). let x = ()=>42 let y = ()=>42 let z = ()=>x()+y() z() // 84 y = ()->69 z() // 111
- geocar 8y agoNot exactly the same thing, for one these aren't function calls, and for another the view is memoized: You can see the difference with some print statements: q)z::show(x;y;x+y);x+y q)x:42 q)y:42 q)z 42 42 84 84 q)x:69 q)z 69 42 111 111 q)z 111 Views are also aware of what's changed: q)a:1234 q)z 111 q)y:69 q)z 69 69 138 138
- wool_gather 8y agoWell, you can do that in any language with first-class functions. But there's obviously a syntactical difference between a function invocation and a variable read.