[Question]
  [
## Information
Create a diagonal line given its length (let’s call the variable, say, \$n\$ where \$n > 0\$)
* The diagonal line starts from the top left and goes to the bottom right.
* You **must** use the ASCII character `\` for the line.
* The input number can be given from STDIN or if your program doesn’t support that, use a hardcoded value in your code or pass it as an argument while running the program.
* For padding, **only use** the **space character** `0x20`
* *Trailing spaces* and/or *newlines* are **allowed**.
* The **length** of the line is the **non whitespace** characters
Here is an example program (59 bytes):
```
n = int(input())
for i in range(n):
  print(' ' * i + '\\')
```
[Try it online!](https://tio.run/##K6gsycjPM7YoKPr/P0/BViEzr0QjM6@gtERDU5MrLb9IIRMopFCUmJeeqpGnacWloFBQBFKjrqCuoAWU1FZQj4lR1/z/3wQA "Python 3.8 (pre-release) – Try It Online")
Example:
```
Input: 4
Output
\
 \
  \
   \
```
### Rules
* Use *standard* I/O when possible.
* Standard *loopholes* are forbidden.
* This is code golf, so the shortest answer in bytes wins.
* Please explain the code that you wrote.
  
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), 1 [byte](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
Better tool for the job ;)
```
＼
```
[Try it here!](https://dzaima.github.io/Canvas/?u=JXVGRjND,i=NA__,v=8)
Given an integer, this draws a diagonal of that string. If you pass a string instead, this prints the string along the diagonal. There is matching anti-diagonal builtin `／` as well.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 2 bytes
```
↖Ｎ
```
[Try it online!](https://tio.run/##S85ILErOT8z5//9R27T3e9b9/28CAA "Charcoal – Try It Online")
right tool for the job
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 9 bytes ([SBCS](https://github.com/abrudz/SBCS))
Anonymous tacit prefix function. Returns a list of string, as per [meta consensus](https://codegolf.meta.stackexchange.com/a/17095/43319).
```
'\'↑⍨¨-∘⍳
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///Xz1G/VHbxEe9Kw6t0H3UMeNR7@b/aY/aJjzq7XvU1fyod82j3i2H1huDlPRNDQ5yBpIhHp7B/4G0V7C/n0KaggkA "APL (Dyalog Unicode) – Try It Online")
`∘⍳` indices one through \$n\$, then:
 `-` negate those
`¨` for each:
 `↑⍨` take (when negative: from the rear) that many characters (padding with spaces) from:
  `'\'` the backslash character
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 bytes
```
=þị⁾\ Y
```
[Try it online!](https://tio.run/##y0rNyan8/9/28L6Hu7sfNe6LUYj8//@/CQA "Jelly – Try It Online")
```
Ḷ⁶ẋp”\Y
```
[Try it online!](https://tio.run/##y0rNyan8///hjm2PGrc93NVd8Khhbkzk////TQA "Jelly – Try It Online")
## How they work
```
=þị⁾\ Y - Main link. Takes N on the left
=þ      - Yield the identity matrix of size N
  ị⁾\   - Index into "\ ", replacing 1 with "\" and 0 with " "
      Y - Join by newlines
```
  
```
Ḷ⁶ẋp”\Y - Main link. Takes N on the left
Ḷ       - Range [0, ..., N-1]
 ⁶ẋ     - Repeat that many spaces for each
   p”\  - Append "\" to each
      Y - Join by newlines
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-R`](https://codegolf.meta.stackexchange.com/a/14339/), 5 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
õ!ù'\
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LVI&code=9SH5J1w&input=OA)
```
õ!ù'\     :Implicit input of integer
õ         :Range [1,input]
 !ù'\     :For each, left pad "\" to that length with spaces
          :Implicit output joined with newlines
```
# [Japt](https://github.com/ETHproductions/japt) [`-mR`](https://codegolf.meta.stackexchange.com/a/14339/), 5 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
'\iUç
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LW1S&code=J1xpVec&input=OA)
```
'\iUç     :Implicit map of each U in the range [0,input)
'\i       :Prepend to "\"
   Uç     :  Space repeated U times
          :Implicit output joined with newlines
```
[Answer]
# [51AC8](https://github.com/PyGamer0/51AC8), 10 bytes
```
R[\ ×\\+t]
```
[Try it Online!](https://pygamer0.pythonanywhere.com/?flags=&header=&code=R%5B%5C%20%C3%97%5C%5C%2Bt%5D&footer=&stdin=4)
*-2 bytes* due to an update.
*-7 bytes* due to an update introducing for\_each loops and range.
*-1 byte* online interpreter and implicit input.
## Explanation
```
       # Implicit Input (STDIN) and push to stack
R      # Range from 0 to input (exclusive)
[      # Start for each
  \    # Push ' ' to the stack
  ×    # Multiply the top 2 elements on the stack
  \\   # Push '\'
  +    # Add top 2 elements
  t    # Pop and print top of stack
]      # End of while loop
```
[Answer]
# [Python 2](https://docs.python.org/2/), 37 bytes
```
x='\\'
exec'print x;x=" "+x;'*input()
```
[Try it online!](https://tio.run/##K6gsycjPM/r/v8JWPSZGnSu1IjVZvaAoM69EocK6wlZJQUm7wlpdKzOvoLREQ/P/fxMA "Python 2 – Try It Online")
[Answer]
# [C (clang)](http://clang.llvm.org/), 37 bytes
```
f(n){printf("%*c\n",n--,92,n&&f(n));}
```
[Try it online!](https://tio.run/##S9ZNzknMS///P00jT7O6oCgzryRNQ0lVKzkmT0knT1dXx9JIJ09NDSSraV37PzcxM09DU6GaS0EhTcNQ0xpMG0FpYyhtAqRr/wMA "C (clang) – Try It Online")
---
# [C (gcc)](https://gcc.gnu.org/), 39 bytes
A recursive version suggested by [@att](https://codegolf.stackexchange.com/users/81203/att).
```
f(n){--n&&f(n);printf("%*c\n",n+1,92);}
```
[Try it online!](https://tio.run/##S9ZNT07@/z9NI0@zWlc3T00NxLIuKMrMK0nTUFLVSo7JU9LJ0zbUsTTStK79n5uYmaehqVDNpaCQpmGoaQ2mjaC0MZQ2AdK1/wE "C (gcc) – Try It Online")
---
# [C (gcc)](https://gcc.gnu.org/), 44 bytes
```
i;f(n){for(i=0;i++<n;)printf("%*c\n",i,92);}
```
[Try it online!](https://tio.run/##S9ZNT07@/z/TOk0jT7M6Lb9II9PWwDpTW9smz1qzoCgzryRNQ0lVKzkmT0knU8fSSNO69n9uYmaehqZCNZeCQpqGoaY1mDaC0sZQ2gRI1/4HAA "C (gcc) – Try It Online")
[Answer]
# Dyalog APL, ~~16~~ 14 bytes
Solution - Takes in number of lines as input from user, and returns a
string of diagonal line.
`' \'[1+∘.=⍨⍳⎕]`
### Explanation
```
⎕            ⍝ ⎕ takes input from the user (number of lines)
             ⍝ In the below explanation, I have assumed ⎕ = 9 as input
⍳⎕            ⍝ 1 to 9 : [1,2,3,4,5,6,7,8,9]
∘.=          ⍝ Outer Product with Equality
⍨            ⍝ Apply a function with same argument on both sides
∘.=⍨⍳⎕       ⍝ ∘.=⍨ function applied to array ⍳⎕ = [1,2..9]
             ⍝ This is same as (⍳9) ∘.= (⍳9), which produces Identity Matrix of size 9
1+∘.=⍨⍳⎕     ⍝ Add 1 to each element of previous matrix (since APL uses 1-based index)
' \'[1+∘.=⍨⍳⎕] ⍝ From the string ' \', select characters specified by indices in 1+∘.=⍨⍳⎕
```
[Answer]
# brainfuck, 113 bytes
```
,>>+++++++[<+++++++++++++>-]<+>++++++++++>>++++[<++++++++>-]<<<<[>>>>[->+>+<<]>[-<+>]>[<<<.>>>-]<<<<<.>.>>+<<<<-]
```
[Try it online.](https://tio.run/##SypKzMxLK03O/v9fx85OGwKibbSRgZ1urI22HRLfDlURSB4Iou2AIFrXDqjUxiYWyAJqAlJAGT2gBEQNkAnkaINYurH//ysCAA)
First time poster. This was a fun exercise! Please provide criticism, I pretty much went in cold when writing this.
```
, how long the line should be via char code
>
initialize cell 1 with "\"
>+++++++[<+++++++++++++>-]<+
> 
initialize cell 2 with "\n"
++++++++++
>
initialize cell 3 with " "; go back to beginning
>++++[<+++++>-]<
<<<
start loop at cell 0
[
    >>>> go to cell 4
    [
        ->+>+<< copy the pad value to cells 5 and 6
    ]
    
    > now we move cell 5 to cell 4
    [
        -<+> cell 4 keeps track how much padding we'll need for our next iteration
    ]
    >
    cell 6 keeps track of how many spaces we need to print currently
    [
        <<<  go to space char
        .    print it
        >>>- decrease counter
    ]
    <<<<< move to line char
    .>.   print line and newline
    >>+   move to cell 4 and increase our padding by 1
    <<<<- back to cell 0; subtract line counter
]
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 bytes
```
Ṭ€ị⁾\ Y
```
[Try it online!](https://tio.run/##y0rNyan8///hzjWPmtY83N39qHFfjELk////TQA "Jelly – Try It Online")
~~Working on golfing. This is longer than I remember it being possible.~~ The JHT exercise allows other characters so I can't get this to 5 bytes because of that :/
```
Ṭ€ị⁾\ Y    Main Link
 €         For each (implicit range)
Ṭ          Generate a boolean list with 1s at the indices
  ị        Index that into
   ⁾\      "\ "
      Y    and join on newlines
```
[Answer]
# [J](http://jsoftware.com/), 10 bytes
```
' \'{~=@i.
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/1RVi1KvrbB0y9f5rcqUmZ@QraFinaSoYIbFNkNhm/wE "J – Try It Online")
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~90~~ ~~77~~ 60 bytes
```
i;main(n){for(scanf("%i",&n);i<n;printf("%*s\\\n",i++,""));}
```
[Try it online!](https://tio.run/##FchLCoAgFAXQrcSLQsuaNVJaiROx34O6RtooWrvRGR7f@d1hzSXD7/c0FyamiUO/jZn14RgC8lnCJaJ3WARVTKqG1Gygz4uR/muitRakuG0VkZT6zXn4AA "C (clang) – Try It Online")
My first work without `int` in it while still using it. I'm doing better now, aren't I?
Thanks to att for golfing 13 bytes. Thanks to ceilingcat for golfing 17 bytes.
[Answer]
# [convey](http://xn--wxa.land/convey/), 46 bytes
```
[0>>,+1
   v"^
{,"=@#]}
 >^}"~v#'\\'
' '!""~/}
```
[Try it online!](https://xn--wxa.land/convey/run.html#eyJjIjoiWzA+PiwrMVxuICAgdlwiXlxueyxcIj1AI119XG4gPl59XCJ+diMnXFxcXCdcbicgJyFcIlwifi99IiwidiI6MSwiaSI6IjIwIn0=)
Visualization (i use '\_' instead of space because the gif doesnt show the space char if i use it, but in the official page the output works whit spaces):
[![enter image description here](https://i.stack.imgur.com/S12iw.gif)](https://i.stack.imgur.com/S12iw.gif)
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `M`, 7 bytes
```
(nI\\+,
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJNIiwiIiwiKG5JXFxcXCssIiwiIiwiNSJd)
Explanation:
```
(  # range from 0 to implict input
  n  # loop variable
   I  # push that many spaces
    \\  # backslash literal
      +  # concatenate the spaces with the backslash
       ,  # print
```
[Answer]
# JavaScript (ES6), 33 bytes
```
f=(n,s=`\\
`)=>--n?s+f(n,' '+s):s
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/f8/zVYjT6fYNiEmhitB09ZOVzfPvlg7DSimrqCuXaxpVfw/OT@vOD8nVS8nP10jTcNQU5MLVcQIQ8QYQ8REU/M/AA "JavaScript (Node.js) – Try It Online")
[Answer]
# MATLAB/Octave, ~~32~~ 31 bytes
*-1 byte thanks to [Luis Mendo](https://codegolf.stackexchange.com/users/36398/luis-mendo)*
```
disp([60*eye(input(''))+32,''])
```
[Try it online!](https://tio.run/##y08uSSxL/Z@SWVygoe6ZV1BaYmWorgnhR5sZaKVWpmpkgoQ11NU1NbWNjXTU1WM1UdSbqGtygfnJGYlFGtj0aEIVQDWYk6rB0IwIHf8NuUy4zLkMzQA "Octave – Try It Online")  
Reads the length from standard input, writes to standard output.  
---
Alternatively, using function input/output, **~~22~~ 21 bytes**:
```
@(x)[60*eye(x)+32,'']
```
[Try it online!](https://tio.run/##y08uSSxL/f/fQaNCM9rMQCu1MhXI0jY20lFXj/2fZpuYV2zNlZJZXKCh7plXUFpiZaiuCeGnaRhqaqJIGSOkjNGkTBBSJmhS5ggpczQpQyMky4zQJI0MEJJGBpqa/wE "Octave – Try It Online")  
Anonymous function, outputs character array.
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 3 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
■♦9
```
[Run and debug it](https://staxlang.xyz/#p=fe0439&i=5)
## Explanation
```
m'\)
m    map 1..n and print with newlines
 '\) pad \ on the left with spaces to given length
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 4 bytes
```
'\3Λ
```
[Try it online!](https://tio.run/##yy9OTMpM/f9fPcb43Oz//00A "05AB1E – Try It Online")
Using the input as length, draw `\` in direction `3` (down-right) with the canvas builtin `Λ`. See [Kevin's tip](https://codegolf.stackexchange.com/a/175520/64121) for details on how the canvas works
---
6 bytes without the canvas builtin:
```
'\ILj»
```
[Try it online!](https://tio.run/##yy9OTMpM/f9fPcbTJ@vQ7v//TQA "05AB1E – Try It Online")
For each number in the range `IL == [1..input]`, pad the string `"\"` with leading spaces to this length (`j`). `»` joins the results by newlines.
Another 6 bytes solution suggested by [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen):
```
L<'\ú»
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fx0Y95vCuQ7v//zcBAA "05AB1E – Try It Online")
For each number in the range `L< == [0..input-1]`, pad the string `"\"` with that many leading spaces.
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 46 bytes
```
for i in range(int(input())):print(' '*i+'\\')
```
[Try it online!](https://tio.run/##K6gsycjPM7YoKPr/Py2/SCFTITNPoSgxLz1VIzOvBIgLSks0NDU1rQqKQHx1BXWtTG31mBh1zf//TQA "Python 3.8 (pre-release) – Try It Online")
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal) `jṀ`, 4 bytes
```
ƛ\\꘍
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=j%E1%B9%80&code=%C6%9B%5C%5C%EA%98%8D&inputs=4&header=&footer=)
Flags go brrr
```
ƛ\\꘍   Full Program
ƛ      For each (implicity loops from 0 to n - 1)
 \\    push '\'
   ꘍   prepend x spaces to '\'
```
`Ṁ` is equivalent to `mM`, which makes implicit range start at `0` instead of `1` and end at `n - 1` instead of `n`.
`j` joins the top of the stack on newlines at the end.
[Answer]
# [Red](http://www.red-lang.org), 30 bytes
```
repeat i n[print pad/left"\"i]
```
[Try it online!](https://tio.run/##K0pN@R@UmqIQHauQZ6VgaPC/KLUgNbFEIVMhL7qgKDOvRKEgMUU/JzWtRClGKTP2/38A "Red – Try It Online")
[Answer]
# Java, 56 bytes
```
n->{for(var s="\\";n-->0;s=" "+s)System.out.println(s);}
```
[Try it online!](https://tio.run/##LU6xDoIwFJzhKxomGkPj4FZlcXJwYhSHWgopwivpeyUxhG@vjfGWy90ldzeqVVVj945LeE1WMz0pRHZXFtiWs4S/j6Qo0epsx@aUlg15C8PjyZQfkG95NqYmEchOog@gyToQVwcYZuPPNyAzGF/3lwhVvfXOl6vyDC9F2xYSqqo@yiRYcUDefJDMLFwgsaQJmqBELvco86wXSmuzUHni8nduz/f4BQ)
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 10 bytes
```
ri{S*'\N}%
```
[Try it online!](https://tio.run/##S85KzP3/vyizOlhLPcavVvX/f1MA "CJam – Try It Online")
### Explanation
```
r             e# Read input
 i            e# Evaluate as an integer, n
  {     }%    e# Do the following for each k in [0 1 ... n-1]
              e# Push k (implicit)
   S          e# Push space
    *         e# Repeat. Gives a string with k spaces
     '\       e# Push character "\"
       N      e# Push newline
              e# Output the stack (implicit)
```
[Answer]
# [R](https://www.r-project.org/), 35 bytes
```
cat(sep="\\
",strrep(" ",0:scan()))
```
[Try it online!](https://tio.run/##K/r/PzmxRKM4tcBWKSaGS0mnuKSoKLVAQ0lBScfAqjg5MU9DU1Pzv/l/AA "R – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~42~~, 39 bytes
* -3 bytes thanks to @Dominic van Essen
```
write(strrep("\\",diag(x<-scan())),1,x)
```
[Try it online!](https://tio.run/##K/r/v7wosyRVo7ikqCi1QEMpJkZJJyUzMV2jwka3ODkxT0NTU1PHUKdC87/5fwA "R – Try It Online")
**Explanation:**
* take x from standard input,
* create a diagonal matrix of size x
* repeat the character `'\'` one time for each 1 of the matrix and 0-times for each 0 (= empty string)
* print the matrix separating each character with a space
[Answer]
# [PHP](https://www.php.net/), 58 57 bytes
```
for($i=0;$i<$argv[1];$i++)echo str_repeat(' ',$i)."\\\n";
```
[Try it here!](https://tio.run/##K8go@G9jXwAk0/KLNFQybQ2sVTJtVBKL0suiDWOBbG1tzdTkjHyF4pKi@KLUgtTEEg11BXUdlUxNPaWYmJg8Jev///@bAAA)
This is my first golf, so feel free to mention anything I can do to improve this!
[Answer]
# [Factor](https://factorcode.org/), 40 bytes
```
[ iota [ [ bl ] times "\\"print ] each ]
```
[Try it online!](https://tio.run/##S0tMLskv@h8a7OnnbqVQnFpYmpqXnFqskJmvkJtYkqGQnVqUl5qjYM3FZfI/GihakqgQDYRJOQqxCiWZuUCVSjExSgVFmXklQJHUxOQMhdj/yYk5Of8B "Factor – Try It Online")
[Answer]
# [Perl 5](https://www.perl.org/), 34 bytes
```
s//\\/;$==<>;s// / while(say,$=--)
```
[Try it online!](https://tio.run/##K0gtyjH9X1qcqlBmqmdoYP2/WF8/JkbfWsXW1sbOGshR0Fcoz8jMSdUoTqzUUbHV1dX8/98UAA "Perl 5 – Try It Online")
This should be run from the command line like `perl -E 's//\\/;$==<>;s// / while(say,$=--)'` to activate the `say` feature without adding any bytes.
Ungolfed:
```
$_='\\'; #Set the default variable $_ to a single backslash
$==<>; #Take input into $=. This variable converts the input to an integer
while($=--){ #Decrement $= and loop
    say; #Prints $_ and a newline
    $_=" $_"; #Adds a space to the start of $_
}
```
Uses `s// /` as shorthand for `$_=" $_"` (i.e. to prepend a space to `$_`). Putting `say` into the while loop lets us drop the brackets from the loop body.
[Answer]
# [Ruby](https://www.ruby-lang.org/en/), 41 bytes
```
puts Array.new(gets.to_i){|i|(' '*i+'\\')}
```
[Try it online!](https://tio.run/##KypNqvz/v6C0pFjBsagosVIvL7VcIz21pFivJD8@U7O6JrNGQ11BXStTWz0mRl2z9v9/QyMA)
]