Skip to main content
edited body
Source Link
user
  • 1.9k
  • 10
  • 21

This would calculate the factorial of 6, if the "self" was the function itself. Is there something that could allow this?

If[#[[1]] > 0, self[{#[[1]] - 1, #[[2]] #[[1]]}], Print[#[[2]]]] &[{6, 1}] 

There is also this function syntax:

Function[x, x If[x > 2, self[x - 1], 1]] 

which can be also be written using this shorthand syntax:

x \[Function] x If[x > 2, self[x - 1], 1] 

This would calculate the factorial of 6, if the "self" was the function itself. Is there something that could allow this?

If[#[[1]] > 0, self[{#[[1]] - 1, #[[2]] #[[1]]}], Print[#[[2]]]] &[{6, 1}] 

There is also this function syntax:

Function[x, x If[x > 2, self[x - 1], 1]] 

which can be also written using this shorthand syntax:

x \[Function] x If[x > 2, self[x - 1], 1] 

This would calculate the factorial of 6, if the "self" was the function itself. Is there something that could allow this?

If[#[[1]] > 0, self[{#[[1]] - 1, #[[2]] #[[1]]}], Print[#[[2]]]] &[{6, 1}] 

There is also this function syntax:

Function[x, x If[x > 2, self[x - 1], 1]] 

which can also be written using this shorthand syntax:

x \[Function] x If[x > 2, self[x - 1], 1] 
added 106 characters in body
Source Link
user
  • 1.9k
  • 10
  • 21

This would calculate the factorial of 6, if the "self" was the function itself. Is there something that could allow this?

If[#[[1]] > 0, self[{#[[1]] - 1, #[[2]] #[[1]]}], Print[#[[2]]]] &[{6, 1}] 

There is also this function syntax:

Function[x, x If[x > 2, self[x - 1], 1]] 

which can be also written using this shorthand syntax:

x \[Function] x If[x > 2, self[x - 1], 1] 

This would calculate the factorial of 6, if the "self" was the function itself. Is there something that could allow this?

If[#[[1]] > 0, self[{#[[1]] - 1, #[[2]] #[[1]]}], Print[#[[2]]]] &[{6, 1}] 

There is also this function syntax:

Function[x, x If[x > 2, self[x - 1], 1]] 

This would calculate the factorial of 6, if the "self" was the function itself. Is there something that could allow this?

If[#[[1]] > 0, self[{#[[1]] - 1, #[[2]] #[[1]]}], Print[#[[2]]]] &[{6, 1}] 

There is also this function syntax:

Function[x, x If[x > 2, self[x - 1], 1]] 

which can be also written using this shorthand syntax:

x \[Function] x If[x > 2, self[x - 1], 1] 
added 87 characters in body
Source Link
user
  • 1.9k
  • 10
  • 21

This would calculate the factorial of 6, if the "self" was the function itself. Is there something that could allow this?

If[#[[1]] > 0, self[{#[[1]] - 1, #[[2]] #[[1]]}], Print[#[[2]]]] &[{6, 1}] 

There is also this function syntax:

Function[x, x If[x > 2, self[x - 1], 1]] 

This would calculate the factorial of 6, if the "self" was the function itself. Is there something that could allow this?

If[#[[1]] > 0, self[{#[[1]] - 1, #[[2]] #[[1]]}], Print[#[[2]]]] &[{6, 1}] 

This would calculate the factorial of 6, if the "self" was the function itself. Is there something that could allow this?

If[#[[1]] > 0, self[{#[[1]] - 1, #[[2]] #[[1]]}], Print[#[[2]]]] &[{6, 1}] 

There is also this function syntax:

Function[x, x If[x > 2, self[x - 1], 1]] 
Tweeted twitter.com/StackMma/status/651167684114051076
Source Link
user
  • 1.9k
  • 10
  • 21
Loading