Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

After reading this postthis post I recalled an old question I once met. We know that we can set default values for variables of a function:

f[u_: 1, v_: 2, w_: 3] := u^2 + v^3 + w^4 

We can use the default values like this:

f[] 

90

like this:

f[u] 

89 + u^2

and like this:

f[u, v] 

81 + u^2 + v^3

However, what if I want to call the default value of a variable not at end separately? Something like

f[, v, w] 

only gives

Null^2 + v^3 + w^4

while what I want to see is

1 + v^3 + w^4

Of course it's easy to circumvent, but I still wonder if there's a more straight forward solution.

After reading this post I recalled an old question I once met. We know that we can set default values for variables of a function:

f[u_: 1, v_: 2, w_: 3] := u^2 + v^3 + w^4 

We can use the default values like this:

f[] 

90

like this:

f[u] 

89 + u^2

and like this:

f[u, v] 

81 + u^2 + v^3

However, what if I want to call the default value of a variable not at end separately? Something like

f[, v, w] 

only gives

Null^2 + v^3 + w^4

while what I want to see is

1 + v^3 + w^4

Of course it's easy to circumvent, but I still wonder if there's a more straight forward solution.

After reading this post I recalled an old question I once met. We know that we can set default values for variables of a function:

f[u_: 1, v_: 2, w_: 3] := u^2 + v^3 + w^4 

We can use the default values like this:

f[] 

90

like this:

f[u] 

89 + u^2

and like this:

f[u, v] 

81 + u^2 + v^3

However, what if I want to call the default value of a variable not at end separately? Something like

f[, v, w] 

only gives

Null^2 + v^3 + w^4

while what I want to see is

1 + v^3 + w^4

Of course it's easy to circumvent, but I still wonder if there's a more straight forward solution.

Tweeted twitter.com/#!/StackMma/status/360726382290014209
edited body
Source Link
xzczd
  • 71.5k
  • 10
  • 183
  • 524

After reading this post I recalled an old question I once met. We know that we can set default values for variables of a function:

f[u_: 1, v_: 2, w_: 3] := u^2 + v^3 + w^4 

We can use the default values like this:

f[] 

90

like this:

f[u] 

89 + u^2

and like this:

f[u, v] 

81 + u^2 + v^3

However, what if I want to call the default value of a variable not at end separately? Something like

f[, v, w] 

only gives

Null^2 + v^3 + w^4

while what I want to see is

1 + v^3 + w^4

Of course it's easy to circumvent, but I still wanderwonder if there's a more straight forward solution.

After reading this post I recalled an old question I once met. We know that we can set default values for variables of a function:

f[u_: 1, v_: 2, w_: 3] := u^2 + v^3 + w^4 

We can use the default values like this:

f[] 

90

like this:

f[u] 

89 + u^2

and like this:

f[u, v] 

81 + u^2 + v^3

However, what if I want to call the default value of a variable not at end separately? Something like

f[, v, w] 

only gives

Null^2 + v^3 + w^4

while what I want to see is

1 + v^3 + w^4

Of course it's easy to circumvent, but I still wander if there's a more straight forward solution.

After reading this post I recalled an old question I once met. We know that we can set default values for variables of a function:

f[u_: 1, v_: 2, w_: 3] := u^2 + v^3 + w^4 

We can use the default values like this:

f[] 

90

like this:

f[u] 

89 + u^2

and like this:

f[u, v] 

81 + u^2 + v^3

However, what if I want to call the default value of a variable not at end separately? Something like

f[, v, w] 

only gives

Null^2 + v^3 + w^4

while what I want to see is

1 + v^3 + w^4

Of course it's easy to circumvent, but I still wonder if there's a more straight forward solution.

Source Link
xzczd
  • 71.5k
  • 10
  • 183
  • 524

Is it possible to separately call the default value of a variable which isn't at the end of the sequence?

After reading this post I recalled an old question I once met. We know that we can set default values for variables of a function:

f[u_: 1, v_: 2, w_: 3] := u^2 + v^3 + w^4 

We can use the default values like this:

f[] 

90

like this:

f[u] 

89 + u^2

and like this:

f[u, v] 

81 + u^2 + v^3

However, what if I want to call the default value of a variable not at end separately? Something like

f[, v, w] 

only gives

Null^2 + v^3 + w^4

while what I want to see is

1 + v^3 + w^4

Of course it's easy to circumvent, but I still wander if there's a more straight forward solution.