Last active
April 19, 2023 17:22
-
-
Save mikeacjones/a683e29fe825347148e7541bce697937 to your computer and use it in GitHub Desktop.
Function to return the power set - requires Bitwise.dwl (also in gist)
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
%dw 2.0 | |
import Bitwise | |
fun powerSet(set: Array) = do { | |
var iterable = (0 to pow(2,sizeOf(set))-1) as Array | |
--- | |
iterable map (item) -> set filter (Bitwise::AND(item,pow(2,$$)) != 0) | |
} |
This does work; dataweave is not usually compiled. Keep in mind that you also have to include the Bitwise.dwl file.
https://gist.github.com/mikeacjones/b3c3719d38f2f075b95bd4960e2252b0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this compile?