5 added 216 characters in body
source | link

Lists with repeated values

This is quite a common vector to work with:

{0,0}

It turns out this can be shortened by a byte:

0{,}

Even more bytes are saved if the vector is longer than two zeros. This can also be used to initialise zero matrices, e.g. the following gives a 2x2 matrix of zeros:

0{{,},{,}}

This can also be used for non-zero values if they're sufficiently large or sufficiently many or negative. Compare the following pairs:

{100,100}
0{,}+100
{-1,-1}
0{,}-1
{13,13,13,13}
0{,,,}+1+3

But remember that starting at 6 values, you're better off with 1~Table~6 in this case (potentially earlier, depending on precedence requirements).

The reason this works is that , introduces two arguments to the list, but omitted arguments (anywhere in Mathematica) are implicit Nulls. Furthermore, multiplication is Listable, and 0*x is 0 for almost any x (except for things like Infinity and Indeterminate), so here is what's happening:

  0{,}
= 0*{,}
= 0*{Null,Null}
= {0*Null,0*Null}
= {0,0}

For lists of 1s, you can use a similar trick by making use of exponentiation rules. There are two different ways to save bytes if you have at least three 1s in the list:

{1,1,1}
1^{,,}
{,,}^0

Lists with repeated values

This is quite a common vector to work with:

{0,0}

It turns out this can be shortened by a byte:

0{,}

Even more bytes are saved if the vector is longer than two zeros. This can also be used to initialise zero matrices, e.g. the following gives a 2x2 matrix of zeros:

0{{,},{,}}

This can also be used for non-zero values if they're sufficiently large or sufficiently many or negative. Compare the following pairs:

{100,100}
0{,}+100
{-1,-1}
0{,}-1
{1,1,1,1}
0{,,,}+1

But remember that starting at 6 values, you're better off with 1~Table~6 in this case (potentially earlier, depending on precedence requirements).

The reason this works is that , introduces two arguments to the list, but omitted arguments (anywhere in Mathematica) are implicit Nulls. Furthermore, multiplication is Listable, and 0*x is 0 for almost any x (except for things like Infinity and Indeterminate), so here is what's happening:

  0{,}
= 0*{,}
= 0*{Null,Null}
= {0*Null,0*Null}
= {0,0}

Lists with repeated values

This is quite a common vector to work with:

{0,0}

It turns out this can be shortened by a byte:

0{,}

Even more bytes are saved if the vector is longer than two zeros. This can also be used to initialise zero matrices, e.g. the following gives a 2x2 matrix of zeros:

0{{,},{,}}

This can also be used for non-zero values if they're sufficiently large or sufficiently many or negative. Compare the following pairs:

{100,100}
0{,}+100
{-1,-1}
0{,}-1
{3,3,3,3}
0{,,,}+3

But remember that starting at 6 values, you're better off with 1~Table~6 in this case (potentially earlier, depending on precedence requirements).

The reason this works is that , introduces two arguments to the list, but omitted arguments (anywhere in Mathematica) are implicit Nulls. Furthermore, multiplication is Listable, and 0*x is 0 for almost any x (except for things like Infinity and Indeterminate), so here is what's happening:

  0{,}
= 0*{,}
= 0*{Null,Null}
= {0*Null,0*Null}
= {0,0}

For lists of 1s, you can use a similar trick by making use of exponentiation rules. There are two different ways to save bytes if you have at least three 1s in the list:

{1,1,1}
1^{,,}
{,,}^0
4 added 57 characters in body
source | link

Lists with repeated values

This is quite a common vector to work with:

{0,0}

It turns out this can be shortened by a byte:

0{,}

Even more bytes are saved if the vector is longer than two zeros. This can also be used to initialise zero matrices, e.g. the following gives a 2x2 matrix of zeros:

0{{,},{,}}

This can also be used for non-zero values if they're sufficiently large or sufficiently many or negative. Compare the following pairs:

{100,100}
0{,}+100
{-1,-1}
0{,}-1
{1,1,1,1}
0{,,,}+1

But remember that starting at 76 values, you're better off with 1&~Array~71~Table~6 in this case (potentially earlier, depending on precedence requirements).

The reason this works is that , introduces two arguments to the list, but omitted arguments (anywhere in Mathematica) are implicit Nulls. Furthermore, multiplication is Listable, and 0*x is 0 for almost any x (except for things like Infinity and Indeterminate), so here is what's happening:

  0{,}
= 0*{,}
= 0*{Null,Null}
= {0*Null,0*Null}
= {0,0}

Lists with repeated values

This is quite a common vector to work with:

{0,0}

It turns out this can be shortened by a byte:

0{,}

Even more bytes are saved if the vector is longer than two zeros. This can also be used to initialise zero matrices, e.g. the following gives a 2x2 matrix of zeros:

0{{,},{,}}

This can also be used for non-zero values if they're sufficiently large or sufficiently many or negative. Compare the following pairs:

{100,100}
0{,}+100
{-1,-1}
0{,}-1
{1,1,1,1}
0{,,,}+1

But remember that starting at 7 values, you're better off with 1&~Array~7 in this case.

The reason this works is that , introduces two arguments to the list, but omitted arguments (anywhere in Mathematica) are implicit Nulls. Furthermore, multiplication is Listable, and 0*x is 0 for almost any x (except for things like Infinity and Indeterminate), so here is what's happening:

  0{,}
= 0*{,}
= 0*{Null,Null}
= {0*Null,0*Null}
= {0,0}

Lists with repeated values

This is quite a common vector to work with:

{0,0}

It turns out this can be shortened by a byte:

0{,}

Even more bytes are saved if the vector is longer than two zeros. This can also be used to initialise zero matrices, e.g. the following gives a 2x2 matrix of zeros:

0{{,},{,}}

This can also be used for non-zero values if they're sufficiently large or sufficiently many or negative. Compare the following pairs:

{100,100}
0{,}+100
{-1,-1}
0{,}-1
{1,1,1,1}
0{,,,}+1

But remember that starting at 6 values, you're better off with 1~Table~6 in this case (potentially earlier, depending on precedence requirements).

The reason this works is that , introduces two arguments to the list, but omitted arguments (anywhere in Mathematica) are implicit Nulls. Furthermore, multiplication is Listable, and 0*x is 0 for almost any x (except for things like Infinity and Indeterminate), so here is what's happening:

  0{,}
= 0*{,}
= 0*{Null,Null}
= {0*Null,0*Null}
= {0,0}
    Bounty Ended with 500 reputation awarded by AdmBorkBork
3 added 56 characters in body
source | link

Lists with repeated values

This is quite a common vector to work with:

{0,0}

It turns out this can be shortened by a byte:

0{,}

Even more bytes are saved if the vector is longer than two zeros. This can also be used to initialise zero matrices, e.g. the following gives a 2x2 matrix of zeros:

0{{,},{,}}

For sufficiently large or sufficiently many values, thisThis can also be used for other (constant)non-zero values if they're sufficiently large or sufficiently many or negative. Compare the following pairs:

{100,100}
0{,}+100
{-1,-1}
0{,}-1
{1,1,1,1}
0{,,,}+1

But remember that starting at 7 values, you're better off with 1&~Array~7 in this case.

The reason this works is that , introduces two arguments to the list, but omitted arguments (anywhere in Mathematica) are implicit Nulls. Furthermore, multiplication is Listable, and 0*x is 0 for almost any x (except for things like Infinity and Indeterminate), so here is what's happening:

  0{,}
= 0*{,}
= 0*{Null,Null}
= {0*Null,0*Null}
= {0,0}

Lists with repeated values

This is quite a common vector to work with:

{0,0}

It turns out this can be shortened by a byte:

0{,}

Even more bytes are saved if the vector is longer than two zeros. This can also be used to initialise zero matrices, e.g. the following gives a 2x2 matrix of zeros:

0{{,},{,}}

For sufficiently large or sufficiently many values, this can also be used for other (constant) values. Compare the following pairs:

{100,100}
0{,}+100

{1,1,1,1}
0{,,,}+1

But remember that starting at 7 values, you're better off with 1&~Array~7 in this case.

The reason this works is that , introduces two arguments to the list, but omitted arguments (anywhere in Mathematica) are implicit Nulls. Furthermore, multiplication is Listable, and 0*x is 0 for almost any x (except for things like Infinity and Indeterminate), so here is what's happening:

  0{,}
= 0*{,}
= 0*{Null,Null}
= {0*Null,0*Null}
= {0,0}

Lists with repeated values

This is quite a common vector to work with:

{0,0}

It turns out this can be shortened by a byte:

0{,}

Even more bytes are saved if the vector is longer than two zeros. This can also be used to initialise zero matrices, e.g. the following gives a 2x2 matrix of zeros:

0{{,},{,}}

This can also be used for non-zero values if they're sufficiently large or sufficiently many or negative. Compare the following pairs:

{100,100}
0{,}+100
{-1,-1}
0{,}-1
{1,1,1,1}
0{,,,}+1

But remember that starting at 7 values, you're better off with 1&~Array~7 in this case.

The reason this works is that , introduces two arguments to the list, but omitted arguments (anywhere in Mathematica) are implicit Nulls. Furthermore, multiplication is Listable, and 0*x is 0 for almost any x (except for things like Infinity and Indeterminate), so here is what's happening:

  0{,}
= 0*{,}
= 0*{Null,Null}
= {0*Null,0*Null}
= {0,0}
2 added 293 characters in body
source | link
1
source | link