# Fun One Liners

**URL:** <https://discourse.julialang.org/t/fun-one-liners/28352>\
**Category:** General Usage\
**Created:** [September 3, 2019, 11:13pm UTC](https://discourse.julialang.org/t/fun-one-liners/28352 "2019-09-03T23:13:18Z")\
**Posts on this page:** 3\
**Page:** 8

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [October 16, 2022, 1:20pm UTC](https://discourse.julialang.org/t/fun-one-liners/28352/143 "2022-10-16T13:20:04Z")

</div>

do while is replaced with while true and a conditional break at the end of the loop.

---

<div class="post-metadata">

**Author:** ![fins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fins/32/43444_2.png) [@fins](https://discourse.julialang.org/u/fins)\
**Post date:** [October 16, 2022, 1:29pm UTC](https://discourse.julialang.org/t/fun-one-liners/28352/144 "2022-10-16T13:29:06Z")

</div>

~~works in general, except for an empty Superset (S=0) in my alg., without an extra-check.  
But not a biggie - an extra-line _somewhere_ can be afforded, I guess.~~

Right! Thx! 👍

```julia
i=0; while true; processSubset(i); i = (i-S) & S; if i==0 break; end; end

```

---

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [October 16, 2022, 2:16pm UTC](https://discourse.julialang.org/t/fun-one-liners/28352/145 "2022-10-16T14:16:20Z")

</div>

Another ( _I haven’t read all the posts, so it may be that someone else posted the same result_ ) way to get all subsets of a set

```julia
ps(l,i=[[]])=isempty(l) ? (return i) : ps(l[2:end], append!(i,vcat.(i,l[1])))

# or

ps(l,i=[[]])=isempty(l) ? (return i) : ps(l[2:end], [i;[append!([l[1]], e) for e in i]])

# I tried to broadcast the append! function, but it doesn't work / I couldn't

```

[Previous page](https://discourse.julialang.org/t/fun-one-liners/28352.md?page=7)
