Skip to main content
Commonmark migration
Source Link

R, 20 bytes

function(a,b)a/(1/b)

in R, a/Inf is 0. Moreover, in the R, we can actually see define * to be this operation instead of .Primitive("*") which is the standard multiplication operator. The TIO link shows the old and new values and demonstrates that we can use our new * operator as the infix multiplication operator.

Try it online!

###3 Bytes:

3 Bytes:

%*%

the matrix multiplication operator. Implicitly converts numbers into matrices, so it returns a 1x1 matrix as a result, but that's stored as a length-1 vector in R, just like a single number is.

OR

%o%

Which is an alias for outer(x,y,'*') which also computes the correct value for numbers.

R, 20 bytes

function(a,b)a/(1/b)

in R, a/Inf is 0. Moreover, in the R, we can actually see define * to be this operation instead of .Primitive("*") which is the standard multiplication operator. The TIO link shows the old and new values and demonstrates that we can use our new * operator as the infix multiplication operator.

Try it online!

###3 Bytes:

%*%

the matrix multiplication operator. Implicitly converts numbers into matrices, so it returns a 1x1 matrix as a result, but that's stored as a length-1 vector in R, just like a single number is.

OR

%o%

Which is an alias for outer(x,y,'*') which also computes the correct value for numbers.

R, 20 bytes

function(a,b)a/(1/b)

in R, a/Inf is 0. Moreover, in the R, we can actually see define * to be this operation instead of .Primitive("*") which is the standard multiplication operator. The TIO link shows the old and new values and demonstrates that we can use our new * operator as the infix multiplication operator.

Try it online!

3 Bytes:

%*%

the matrix multiplication operator. Implicitly converts numbers into matrices, so it returns a 1x1 matrix as a result, but that's stored as a length-1 vector in R, just like a single number is.

OR

%o%

Which is an alias for outer(x,y,'*') which also computes the correct value for numbers.

added 110 characters in body
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 20 bytes

function(a,b)a/(1/b)

in R, a/Inf is 0. Moreover, in the R, we can actually see define * to be this operation instead of .Primitive("*") which is the standard multiplication operator. The TIO link shows the old and new values and demonstrates that we can use our new * operator as the infix multiplication operator.

Try it online!

###3 Bytes:

%*%

the matrix multiplication operator. Implicitly converts numbers into matrices, so it returns a 1x1 matrix as a result, but that's stored as a length-1 vector in R, just like a single number is.

OR

%o%

Which is an alias for outer(x,y,'*') which also computes the correct value for numbers.

R, 20 bytes

function(a,b)a/(1/b)

in R, a/Inf is 0. Moreover, in the R, we can actually see define * to be this operation instead of .Primitive("*") which is the standard multiplication operator. The TIO link shows the old and new values and demonstrates that we can use our new * operator as the infix multiplication operator.

Try it online!

###3 Bytes:

%*%

the matrix multiplication operator. Implicitly converts numbers into matrices, so it returns a 1x1 matrix as a result, but that's stored as a length-1 vector in R, just like a single number is.

R, 20 bytes

function(a,b)a/(1/b)

in R, a/Inf is 0. Moreover, in the R, we can actually see define * to be this operation instead of .Primitive("*") which is the standard multiplication operator. The TIO link shows the old and new values and demonstrates that we can use our new * operator as the infix multiplication operator.

Try it online!

###3 Bytes:

%*%

the matrix multiplication operator. Implicitly converts numbers into matrices, so it returns a 1x1 matrix as a result, but that's stored as a length-1 vector in R, just like a single number is.

OR

%o%

Which is an alias for outer(x,y,'*') which also computes the correct value for numbers.

Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 20 bytes

function(a,b)a/(1/b)

in R, a/Inf is 0. Moreover, in the R, we can actually see define * to be this operation instead of .Primitive("*") which is the standard multiplication operator. The TIO link shows the old and new values and demonstrates that we can use our new * operator as the infix multiplication operator.

Try it online!

###3 Bytes:

%*%

the matrix multiplication operator. Implicitly converts numbers into matrices, so it returns a 1x1 matrix as a result, but that's stored as a length-1 vector in R, just like a single number is.