Last active
November 6, 2019 20:10
-
-
Save isaiah-perumalla/e5ee11fc4124e4a2b0d790c7502c1eef to your computer and use it in GitHub Desktop.
some q functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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