Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/drafts/rosettacode/power-set.wiki # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / drafts / rosettacode / power-set.wiki` 85 lines ยท 1395 bytes Raw Blame History 1 =={{header|Omegese}}== 2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}} 3 Omega has no imports, so the small output helpers (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 text sp " " 8 text minus "-" 9 text tlb "{" 10 text trb "}" 11 text tcomma ", " 12 text tcount "subsets: " 13 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 14 fn emit a view uchar * to void 15 o = ulong 0 16 while lt o len a bound 4096 17 k = write 1 a o sub len a o 18 if le k 0 19 exit 1 20 end 21 o = add o ulong k 22 end 23 end 24 note emitu writes n in decimal; 20 digits hold every ulong 25 fn emitu n ulong to void 26 d = new uchar 20 0 27 i = ulong 20 28 v = n 29 while true bound 20 30 i = sub i 1 31 put d i uchar add rem v 10 48 32 v = div v 10 33 if eq v 0 34 break 35 end 36 end 37 emit part d i sub 20 i 38 end 39 note subset m of {1, 2, 3, 4} holds element i+1 when bit i of m is set; the 16 subsets are listed in 40 note the order of m, which is binary counting 41 fn subset m ulong to void 42 emit tlb 43 first = true 44 for i ulong 4 45 if ne and shr m i 1 0 46 if not first 47 emit tcomma 48 end 49 emitu add i 1 50 first = false 51 end 52 end 53 emit trb 54 emit nl 55 end 56 fn main to int 57 for m ulong 16 58 subset m 59 end 60 emit tcount 61 emitu 16 62 emit nl 63 ret 0 64 end 65 66 {{out}} 67

68 {}

69 {1}

70 {2}

71 {1, 2}

72 {3}

73 {1, 3}

74 {2, 3}

75 {1, 2, 3}

76 {4}

77 {1, 4}

78 {2, 4}

79 {1, 2, 4}

80 {3, 4}

81 {1, 3, 4}

82 {2, 3, 4}

83 {1, 2, 3, 4}

84 subsets: 16

85