Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
some q functions
//function return all subset of a list
sset: {[xs] (enlist ()) {x, (y,) each x }/ xs}
//or using the map each right /:
sset: {[xs] (enlist ()) {x, y ,/: x }/ xs}
//q)sset (1; 2; 3;`a)
()
,1
,2
2 1
,3
3 1
3 2
3 2 1
,`a
(`a;1)
(`a;2)
(`a;2;1)
(`a;3)
(`a;3;1)
(`a;3;2)
(`a;3;2;1)
//fibonacci
fib: {[n] last n {(-1#x),(sum x)}/ (0 1)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment