Doing shorter comparisons in PowerShell One of the annoying bits about PowerShell, which helps amplify its disadvantage against other languages in code-golf, is that there are no symbolic comparison or logical operators.

A comparison that could be as short as this:

$x&lt;10&amp;&amp;$x&gt;5


Has to be:

$x-lt10-and$x-gt5


This bloats the code for even the simplest of comparisons by about 50% compared to many other regular scripting and programming languages, never mind any golfing languages. Even an Excel formula for a similar comparison comes up shorter by one character!

=AND(A1&lt;10,A1&gt;5)


Another one that really bugs me:

$x==$k&amp;&amp;$i&gt;9&amp;&amp;$i%10!=0


Has to be:

$x-eq$k-and$i-gt9-and$i%10-ne0


Interestingly, this one's exactly as long as the comparable formula for Excel, but that's mainly due to Excel's lack of a symbolic modulus operator.

=AND(A1=B1,C1&gt;9,MOD(C1,10)&lt;&gt;0)


Is there a way this can be shortened at all, or is this strictly a limitation of the language? Are there any particular scenarios to keep in mind where shortcuts can be used for joining multiple comparisons?
I found a semi-edge case where a multiple comparison can be shortened. This is useful when you need to test two or more variables for equality, and only return true if all tests are true.

Instead of this:

$a-eq$b-and$c-eq$d


You might be able to do this:

"$a$c"-eq"$b$d"


It's worked for me in a Pisano Period script, where I changed:

$a-eq1-and$b-eq0


To:

"$a$b"-eq10


Another example:

$a-eq'apple'-and$b-eq'orange'


Can be cut down to:

"$a$b"-eq'appleorange'