Skip to main content
RIP MATHJAX 2015
Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

Julia, 76 73 bytes

n->("\$\$\\varphi=1+"*"\\cfrac1{1+"^n*"\\"*"d"^(n>0)*"dots"*"}"^n*"\$\$")

This creates a lambda function that takes a single integer as input and returns the MathJax as a string. To call it, give it a name, e.g. f=n->....

Unfortunately both backslashes and dollar signs have to be escaped in Julia strings because they both have special meaning. String concatenation is performed using * and string repetition with ^.

Examples:

julia> f(0)
"$$\varphi=1+\dots$$"

julia> f(4)
"$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$"

And proof that the output is valid MathJax:

$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

Suggestions are welcome as always!


Edit: Saved 3 bytes thanks to plannapus!

Julia, 76 73 bytes

n->("\$\$\\varphi=1+"*"\\cfrac1{1+"^n*"\\"*"d"^(n>0)*"dots"*"}"^n*"\$\$")

This creates a lambda function that takes a single integer as input and returns the MathJax as a string. To call it, give it a name, e.g. f=n->....

Unfortunately both backslashes and dollar signs have to be escaped in Julia strings because they both have special meaning. String concatenation is performed using * and string repetition with ^.

Examples:

julia> f(0)
"$$\varphi=1+\dots$$"

julia> f(4)
"$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$"

And proof that the output is valid MathJax:

$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

Suggestions are welcome as always!


Edit: Saved 3 bytes thanks to plannapus!

Julia, 76 73 bytes

n->("\$\$\\varphi=1+"*"\\cfrac1{1+"^n*"\\"*"d"^(n>0)*"dots"*"}"^n*"\$\$")

This creates a lambda function that takes a single integer as input and returns the MathJax as a string. To call it, give it a name, e.g. f=n->....

Unfortunately both backslashes and dollar signs have to be escaped in Julia strings because they both have special meaning. String concatenation is performed using * and string repetition with ^.

Examples:

julia> f(0)
"$$\varphi=1+\dots$$"

julia> f(4)
"$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$"

Suggestions are welcome as always!


Edit: Saved 3 bytes thanks to plannapus!

d^(n>0)
Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

Julia, 7676 73 bytes

n->("\$\$\\varphi=1+"*"\\cfrac1{1+"^n*"\\"*1+"^n*"\\"*"d"^(n>0?"d":"")*"dots"*"}"^n*"\$\$")

This creates a lambda function that takes a single integer as input and returns the MathJax as a string. To call it, give it a name, e.g. f=n->....

Unfortunately both backslashes and dollar signs have to be escaped in Julia strings because they both have special meaning. String concatenation is performed using * and string repetition with ^.

Examples:

julia> f(0)
"$$\varphi=1+\dots$$"

julia> f(4)
"$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$"

And proof that the output is valid MathJax:

$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

Suggestions are welcome as always!


Edit: Saved 3 bytes thanks to plannapus!

Julia, 76 bytes

n->("\$\$\\varphi=1+"*"\\cfrac1{1+"^n*"\\"*(n>0?"d":"")*"dots"*"}"^n*"\$\$")

This creates a lambda function that takes a single integer as input and returns the MathJax as a string. To call it, give it a name, e.g. f=n->....

Unfortunately both backslashes and dollar signs have to be escaped in Julia strings because they both have special meaning. String concatenation is performed using * and string repetition with ^.

Examples:

julia> f(0)
"$$\varphi=1+\dots$$"

julia> f(4)
"$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$"

And proof that the output is valid MathJax:

$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

Suggestions are welcome as always!

Julia, 76 73 bytes

n->("\$\$\\varphi=1+"*"\\cfrac1{1+"^n*"\\"*"d"^(n>0)*"dots"*"}"^n*"\$\$")

This creates a lambda function that takes a single integer as input and returns the MathJax as a string. To call it, give it a name, e.g. f=n->....

Unfortunately both backslashes and dollar signs have to be escaped in Julia strings because they both have special meaning. String concatenation is performed using * and string repetition with ^.

Examples:

julia> f(0)
"$$\varphi=1+\dots$$"

julia> f(4)
"$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$"

And proof that the output is valid MathJax:

$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

Suggestions are welcome as always!


Edit: Saved 3 bytes thanks to plannapus!

Ugh. Forgot the quotes around returned strings.
Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

Julia, 76 bytes

n->("\$\$\\varphi=1+"*"\\cfrac1{1+"^n*"\\"*(n>0?"d":"")*"dots"*"}"^n*"\$\$")

This creates a lambda function that takes a single integer as input and returns the MathJax as a string. To call it, give it a name, e.g. f=n->....

Unfortunately both backslashes and dollar signs have to be escaped in Julia strings because they both have special meaning. String concatenation is performed using * and string repetition with ^.

Examples:

julia> f(0)
"$$\varphi=1+\dots$$"

julia> f(4)
"$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$"

And proof that the output is valid MathJax:

$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

Suggestions are welcome as always!

Julia, 76 bytes

n->("\$\$\\varphi=1+"*"\\cfrac1{1+"^n*"\\"*(n>0?"d":"")*"dots"*"}"^n*"\$\$")

This creates a lambda function that takes a single integer as input and returns the MathJax as a string. To call it, give it a name, e.g. f=n->....

Unfortunately both backslashes and dollar signs have to be escaped in Julia strings because they both have special meaning. String concatenation is performed using * and string repetition with ^.

Examples:

julia> f(0)
$$\varphi=1+\dots$$

julia> f(4)
$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

And proof that the output is valid MathJax:

$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

Suggestions are welcome as always!

Julia, 76 bytes

n->("\$\$\\varphi=1+"*"\\cfrac1{1+"^n*"\\"*(n>0?"d":"")*"dots"*"}"^n*"\$\$")

This creates a lambda function that takes a single integer as input and returns the MathJax as a string. To call it, give it a name, e.g. f=n->....

Unfortunately both backslashes and dollar signs have to be escaped in Julia strings because they both have special meaning. String concatenation is performed using * and string repetition with ^.

Examples:

julia> f(0)
"$$\varphi=1+\dots$$"

julia> f(4)
"$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$"

And proof that the output is valid MathJax:

$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

Suggestions are welcome as always!

Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119
Loading