Draw some expanding arrows












21














This challenge is about printing a series of growing ASCII-art arrows. I'll describe the pattern in words, but it might be easier to look at what the start of this series looks like:



>
<
->
<-
-->
<--
--->
<---
---->
<----
----->
<-----
------>
<------
...


An arrow with length n contains an arrowhead (< or >) and n-1 dashes (-). A right-facing arrow has the dashes first, then a >. A left-facing arrow starts with <, and is followed by the dashes. The series consists of a length n right-facing arrow followed by a length n left-facing arrow, with n from 1 to infinity.



To complete the challenge, write a program or function that takes one input, an integer i >= 1, and outputs the first i arrows. Arrows are individual, not in right-left pairs, so for i=3 you should output:



>
<
->


You can return a list of strings, or print them one after the other. If printing, the arrows must be delimited by some consistent delimiter, which doesn't have to be a newline as in the example.



This is code-golf, so fewest bytes wins.










share|improve this question


















  • 2




    Related.
    – AdmBorkBork
    Dec 12 '18 at 16:23










  • Can we have spaces before/after each line?
    – Olivier Grégoire
    Dec 12 '18 at 16:54










  • @OlivierGrégoire Yes, trailing whitespace is ok.
    – Pavel
    Dec 12 '18 at 16:55










  • And heading whitespace?
    – Olivier Grégoire
    Dec 12 '18 at 16:58










  • @OlivierGrégoire Yeah, that's fine.
    – Pavel
    Dec 12 '18 at 17:00


















21














This challenge is about printing a series of growing ASCII-art arrows. I'll describe the pattern in words, but it might be easier to look at what the start of this series looks like:



>
<
->
<-
-->
<--
--->
<---
---->
<----
----->
<-----
------>
<------
...


An arrow with length n contains an arrowhead (< or >) and n-1 dashes (-). A right-facing arrow has the dashes first, then a >. A left-facing arrow starts with <, and is followed by the dashes. The series consists of a length n right-facing arrow followed by a length n left-facing arrow, with n from 1 to infinity.



To complete the challenge, write a program or function that takes one input, an integer i >= 1, and outputs the first i arrows. Arrows are individual, not in right-left pairs, so for i=3 you should output:



>
<
->


You can return a list of strings, or print them one after the other. If printing, the arrows must be delimited by some consistent delimiter, which doesn't have to be a newline as in the example.



This is code-golf, so fewest bytes wins.










share|improve this question


















  • 2




    Related.
    – AdmBorkBork
    Dec 12 '18 at 16:23










  • Can we have spaces before/after each line?
    – Olivier Grégoire
    Dec 12 '18 at 16:54










  • @OlivierGrégoire Yes, trailing whitespace is ok.
    – Pavel
    Dec 12 '18 at 16:55










  • And heading whitespace?
    – Olivier Grégoire
    Dec 12 '18 at 16:58










  • @OlivierGrégoire Yeah, that's fine.
    – Pavel
    Dec 12 '18 at 17:00
















21












21








21


4





This challenge is about printing a series of growing ASCII-art arrows. I'll describe the pattern in words, but it might be easier to look at what the start of this series looks like:



>
<
->
<-
-->
<--
--->
<---
---->
<----
----->
<-----
------>
<------
...


An arrow with length n contains an arrowhead (< or >) and n-1 dashes (-). A right-facing arrow has the dashes first, then a >. A left-facing arrow starts with <, and is followed by the dashes. The series consists of a length n right-facing arrow followed by a length n left-facing arrow, with n from 1 to infinity.



To complete the challenge, write a program or function that takes one input, an integer i >= 1, and outputs the first i arrows. Arrows are individual, not in right-left pairs, so for i=3 you should output:



>
<
->


You can return a list of strings, or print them one after the other. If printing, the arrows must be delimited by some consistent delimiter, which doesn't have to be a newline as in the example.



This is code-golf, so fewest bytes wins.










share|improve this question













This challenge is about printing a series of growing ASCII-art arrows. I'll describe the pattern in words, but it might be easier to look at what the start of this series looks like:



>
<
->
<-
-->
<--
--->
<---
---->
<----
----->
<-----
------>
<------
...


An arrow with length n contains an arrowhead (< or >) and n-1 dashes (-). A right-facing arrow has the dashes first, then a >. A left-facing arrow starts with <, and is followed by the dashes. The series consists of a length n right-facing arrow followed by a length n left-facing arrow, with n from 1 to infinity.



To complete the challenge, write a program or function that takes one input, an integer i >= 1, and outputs the first i arrows. Arrows are individual, not in right-left pairs, so for i=3 you should output:



>
<
->


You can return a list of strings, or print them one after the other. If printing, the arrows must be delimited by some consistent delimiter, which doesn't have to be a newline as in the example.



This is code-golf, so fewest bytes wins.







code-golf ascii-art sequence






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 12 '18 at 15:56









Pavel

4,79813389




4,79813389








  • 2




    Related.
    – AdmBorkBork
    Dec 12 '18 at 16:23










  • Can we have spaces before/after each line?
    – Olivier Grégoire
    Dec 12 '18 at 16:54










  • @OlivierGrégoire Yes, trailing whitespace is ok.
    – Pavel
    Dec 12 '18 at 16:55










  • And heading whitespace?
    – Olivier Grégoire
    Dec 12 '18 at 16:58










  • @OlivierGrégoire Yeah, that's fine.
    – Pavel
    Dec 12 '18 at 17:00
















  • 2




    Related.
    – AdmBorkBork
    Dec 12 '18 at 16:23










  • Can we have spaces before/after each line?
    – Olivier Grégoire
    Dec 12 '18 at 16:54










  • @OlivierGrégoire Yes, trailing whitespace is ok.
    – Pavel
    Dec 12 '18 at 16:55










  • And heading whitespace?
    – Olivier Grégoire
    Dec 12 '18 at 16:58










  • @OlivierGrégoire Yeah, that's fine.
    – Pavel
    Dec 12 '18 at 17:00










2




2




Related.
– AdmBorkBork
Dec 12 '18 at 16:23




Related.
– AdmBorkBork
Dec 12 '18 at 16:23












Can we have spaces before/after each line?
– Olivier Grégoire
Dec 12 '18 at 16:54




Can we have spaces before/after each line?
– Olivier Grégoire
Dec 12 '18 at 16:54












@OlivierGrégoire Yes, trailing whitespace is ok.
– Pavel
Dec 12 '18 at 16:55




@OlivierGrégoire Yes, trailing whitespace is ok.
– Pavel
Dec 12 '18 at 16:55












And heading whitespace?
– Olivier Grégoire
Dec 12 '18 at 16:58




And heading whitespace?
– Olivier Grégoire
Dec 12 '18 at 16:58












@OlivierGrégoire Yeah, that's fine.
– Pavel
Dec 12 '18 at 17:00






@OlivierGrégoire Yeah, that's fine.
– Pavel
Dec 12 '18 at 17:00












38 Answers
38






active

oldest

votes













1 2
next












6















Canvas, 10 bytes



⇵-×<n¹[↔}]


Try it here!






share|improve this answer





















  • I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
    – Pavel
    Dec 12 '18 at 16:03










  • is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
    – dzaima
    Dec 12 '18 at 16:04



















8















R, 69 bytes





for(i in 1:scan()-1)cat('<'[i%%2],rep('-',i/2),'>'[!i%%2],'
',sep='')


Try it online!




  • -5 bytes thanks to @Giuseppe

  • -3 bytes thanks to @Robert S.






share|improve this answer























  • strrep coerces its second argument to integer so you can use / in place of %/%
    – Giuseppe
    Dec 12 '18 at 16:40










  • you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
    – Giuseppe
    Dec 12 '18 at 16:44










  • I'm an idiot... thanks ! :D
    – digEmAll
    Dec 12 '18 at 17:17










  • @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
    – digEmAll
    Dec 12 '18 at 17:21



















8














Haskell, 41 40 bytes



(`take`g">")
g p=p:('<':init p):g('-':p)


Try it online!



Plain old recursion: start with string p = ">", collect p, a < in front of all but the last char of p and a recursive call with one - put in front of p. Take the first n items of this list.



Edit: -1 byte thanks to @xnor.






share|improve this answer



















  • 1




    A weird change to save a byte.
    – xnor
    Dec 13 '18 at 5:44



















7















Java (JDK), 81 bytes





n->{for(int i=0;i<n;)System.out.printf(i%2<1?"<%s%n":"%s>%n","-".repeat(i++/2));}


Try it online!



Explanations



n->{                  // int-accepting consumer
for(int i=0;i<n;) // for each i from 0 to n-1 included
System.out.printf( // output on stdout with a pattern
i%2<1 // if i is even:
?"<%s%n" // use the left-arrow pattern
:"%s>%n", // else: use the right-arrow pattern
"-".repeat(i++/2) // fill the "%s" in the pattern with i/2 dashes, and increment i
); //
} //





share|improve this answer























  • Consider removing static reference to System.out
    – candied_orange
    Dec 15 '18 at 18:11












  • @candied_orange That's not self-contained.
    – Olivier Grégoire
    Dec 15 '18 at 18:32










  • How about done like this?
    – candied_orange
    Dec 15 '18 at 18:52












  • @candied_orange It's the same: the imports are required in the count.
    – Olivier Grégoire
    Dec 15 '18 at 19:38










  • Why doesn't import java.util.function.*; count?
    – candied_orange
    Dec 15 '18 at 19:44



















6















Commodore BASIC V2 (C64), 94 bytes



0inputn:fOi=1ton:oniaN1gO1:?"<";
1on-(i<3)gO2:fOj=1.5toi/2:?"-";:nE
2on-nOiaN1gO3:?">";
3?:nE


Not entirely sure about the byte count, this is based on the text representation for typing the valid program. It's a bit shorter on disk (91 bytes) because BASIC V2 uses a "tokenized" representation of programs.



Online Demo



Slightly "ungolfed":



0 inputn:fori=1ton:oniand1goto1:print"<";    :rem read n from user, loop to n, if odd skip "<"
1 on-(i<3)goto2:forj=1.5toi/2:print"-";:next :rem skip for i<3, print (i-1)/2 times "-"
2 on-notiand1goto3:print">"; :rem if even skip ">"
3 print:next :rem newline and next loop iteration





share|improve this answer





























    6















    Python 2, 54 bytes



    thanks to the and Jo King for fixing a bug.





    k=0
    exec"print k%2*'<'+k/2*'-'+~k%2*'>';k+=1;"*input()


    Try it online!






    share|improve this answer



















    • 3




      Your arrows have too many dashes; only every other one should lengthen by a dash.
      – xnor
      Dec 13 '18 at 2:35






    • 1




      54 bytes
      – tsh
      Dec 13 '18 at 5:23










    • 54 bytes with the arrows pointing the right way
      – Jo King
      Dec 13 '18 at 9:52



















    5














    Pyth, 17 bytes



    m_W%d2+*-/d2@"><


    Output is a list of strings. Try it online here.



    m_W%d2+*-/d2@"><"dQ   Implicit: Q=eval(input())
    Trailing "dQ inferred
    m Q Map [0-Q), as d, using:
    /d2 Floored division of d by 2
    *- Repeat "-" the above number of times
    + Append to the above...
    @"><"d Modular index d into "><" - yields ">" for even d, "<" for odd
    - examples: d=4 gives "-->", d=7 gives "---<"
    _W Reverse the above if...
    %d2 ... (d % 2) != 0
    Implicit print result of the map





    share|improve this answer





























      5














      Python 3, 53 bytes



      My first codegolf answer.



      lambda x:[i%2*"<"+i//2*"-"+~i%2*">"for i in range(x)]


      -10 bytes thanks to Jo King






      share|improve this answer



















      • 1




        Welcome to PPCG! You can remove the brackets by putting the string after the number, use ~i instead of i+1 and use // to integer divide, assuming you're using Python 3. 53 bytes
        – Jo King
        Dec 13 '18 at 9:45








      • 1




        I've linked the updated solution in my previous comment. If you like, you can use the auto-formatter in the TIO link to help create your answer
        – Jo King
        Dec 13 '18 at 9:54



















      5















      Self-modifying Brainfuck, 55 bytes



      Take input as character code.

      Only support input up to 255.

      Use null character to separate lines.



      Coincidentally, all arrow-drawing characters are used as BF commands. Unfortunately, it doesn't save any bytes (currently).



      >>,[<<[-<.>>+<]<<.>>.+>>-[<<<<<.>>>>[-<+<.>>].>-<]>]<>-


      Try it online!



      Explanation



       Code  |              Memory         | Output | Comment
      -------+-----------------------------+--------+--------------------------
      | '<' '>' '-' [0] 0 0 0 | |
      >>, | '<' '>' '-' 0 0 [x] 0 | |
      [ | | |
      | '<' '>' '-' l 0 [x] 0 | | l = arrow length
      <<[-< | | | copy l to next cell
      .>>+<] | | | and print '-'
      | '<' '>' '-' [0] l x 0 | ----- | there are l '-'s
      <<. | '<' [>] '-' 0 l x 0 | > |
      >>.+ | '<' '>' '-' [1] l x 0 | <null> |
      >>- | '<' '>' '-' 1 l [y] 0 | | y=x-1
      [ | | | execute if y>0
      <<<<<. | [<] '>' '-' 1 l y 0 | < |
      >>>> | '<' '>' '-' 1 [l] y 0 | |
      [-<+<. | | |
      >>] | '<' '>' '-' L [0] y 0 | ----- | L=l+1
      . | '<' '>' '-' L [0] y 0 | <null> |
      >-<]>] | | | decrement y
      <>- | | | do nothing, used as data





      share|improve this answer































        5















        Haskell, 51 44 bytes



        -7 bytes thanks to xnor (using iterate over list-comprehension)!





        (`take`do b<-iterate('-':)"";[b++">",'<':b])


        Try it online!



        Explanation / Ungolfed



        Using do-notation saves us a concat, and using infix-notation allows a pointfree function with take, undoing these would give:



        f n = take n $ concat [ [b++">", '<':b] | b <- iterate ('-':) "" ]





        share|improve this answer































          5














          Japt -m, 16 15 13 bytes



          g"><" iUUz ç-


          Test it online



          Explanation:



          -m              // Map the program through [0...Input); U becomes the item
          g"><" iUUz ç-
          "><" // Literal "><"
          g // Get the char at index U (with wrapping)
          i // Insert:
          U // At index U (with wrapping)
          ç- // "-" repeated:
          Uz // U/2 times





          share|improve this answer































            4















            PowerShell, 62 56 50 bytes





            param($n)(0..$n|%{($j='-'*$_)+'>';"<$j"})[0..--$n]


            Try it online!



            Loops from 0 up to input $n, each iteration creating two arrow strings. Those are then indexed with 0..--$n to pull out the correct number of elements.



            Saved 6 bytes thanks to KGlasier.






            share|improve this answer























            • Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
              – KGlasier
              Dec 12 '18 at 17:00










            • Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
              – KGlasier
              Dec 12 '18 at 17:03








            • 1




              @KGlasier Awesome - thanks for the obvious golfs! :)
              – AdmBorkBork
              Dec 12 '18 at 17:16



















            4















            Jelly, 15 bytes



            ị⁾><;’H”-ẋƲṚ⁸¡)


            Try it online!






            share|improve this answer





















            • -1 byte using tie: TIO.
              – HyperNeutrino
              Dec 14 '18 at 14:29



















            4















            MathGolf, 17 15 bytes



            Saved 2 bytes thanks to Jo King and Kevin Cruijssen



            {ï½'-*'>ï¥╛Å⌡n


            Try it online!



            Explanation



            The 15-byte approach is different compared to my original solution, I can't take any credit for the implementation.



            {                 start block or arbitrary length
            ï index of current loop, or length of last loop
            ½ pop a : push(a//2 if int else a/2)
            '- push single character "-"
            * pop a, b : push(a*b)
            '> push single character ">"
            ï index of current loop, or length of last loop
            ¥ modulo 2
            ╛ if without else
            Å start block of length 2
            ⌡ decrement twice
            swap top elements
            n newline char, or map array with newlines





            share|improve this answer























            • How does the if/else work in MathGolf? I know how the if-without-else and else-without-if statements work, but how to create an if{ ... } else{ ... } in MathGolf with ¿? (Maybe I should post this in the chat instead of here.. But I might perhaps have a save of 1 byte if I can fix the if-else.)
              – Kevin Cruijssen
              Dec 13 '18 at 10:20








            • 1




              @KevinCruijssen I think it works with the next two commands/blocks. e.g. ¿12 will push 1 if true, else 2, ¿Å3*Å1+ will add one if true else triple the next element
              – Jo King
              Dec 13 '18 at 10:30












            • @KevinCruijssen The if/else pops two operators or blocks from the code. Jo King is correct in his example, but you could also do ¿{"foo"}{"bar"} or ¿1{2}.
              – maxb
              Dec 13 '18 at 10:34










            • @JoKing I'll add a TODO to fix the docs for the slicing operators.
              – maxb
              Dec 13 '18 at 10:35






            • 1




              15 bytes using @KevinCruijssen's solution
              – Jo King
              Dec 13 '18 at 10:46





















            4















            Japt -m, 14 bytes



            "<>"¬hUUz ç-)q


            Try it online!



            Updated with a completely new method.



            Explanation:



                              #Implicitly map over the range [0..input) as U
            "<>" #The string "<>"
            ¬ #Split into the array ["<",">"]
            hU ) #Replace the element at index U with wrapping:
            - # The character '-'
            ç # Repeated a number of times equal to
            Uz # U integer divided by 2
            q #Join the array to a string





            share|improve this answer



















            • 1




              ç auto-casts its first parameter into a string, so you can drop the '.
              – Oliver
              Dec 13 '18 at 0:21






            • 1




              You don't need the u method thanks to index wrapping so this can be 14 bytes.
              – Shaggy
              Dec 13 '18 at 8:13



















            3














            JavaScript (ES6), 58 bytes



            Returns a space-separated string.





            n=>(g=p=>n--?k++&1?`<${p} `+g(p+'-'):p+'> '+g(p):'')(k='')


            Try it online!






            share|improve this answer





























              3















              SNOBOL4 (CSNOBOL4), 123 122 118 bytes



              	N =INPUT - 1
              P H =X / 2
              Y =DUPL('-',H)
              OUTPUT =EQ(H,X - H) Y '>' :S(I)
              OUTPUT ='<' Y
              I X =LT(X,N) X + 1 :S(P)
              END


              Try it online!






              share|improve this answer































                3















                V, 22 bytes



                i>
                <Àñäkjjé-já-ñÀGjdG


                Try it online!






                share|improve this answer

















                • 5




                  This looks like some weird scandinavian language
                  – Pavel
                  Dec 12 '18 at 18:02



















                3















                Charcoal, 16 bytes



                NθFθ«⊘ι↓>‖T»Fθ‖T


                Try it online! Link is to verbose version of code. I had three 17-byte solutions before I eventually stumbled over this one. Explanation:



                Nθ


                Input n.



                Fθ«


                Repeat n times, 0-indexed.



                ⊘ι


                Draw a line of -s of length half the index (truncated).



                ↓>


                Draw the arrowhead and move to the next line.



                ‖T»


                Reflect everything, flipping the arrowheads.



                Fθ‖T


                The above loop has n reflections, but we need an even number of reflections, so perform another n reflections.






                share|improve this answer





























                  3















                  Clean, 76 73 bytes



                  import StdEnv,StdLib
                  $n=take n[s\i<-inits['--'..],s<-[i++['>'],['<':i]]]


                  Try it online!



                  Uses the neat fact that ['-','-'..] is the same as ['--'..] to save a bit.






                  share|improve this answer





























                    3














                    JavaScript, 49 bytes





                    f=n=>--n?f(n,l='')+(n%2?`
                    <`+l:`
                    ${l+='-'}>`):'>'


                    Try it online!






                    share|improve this answer























                    • Wow, pretty cool
                      – Levitator Imbalance
                      Dec 14 '18 at 10:41










                    • ...but it throws on 10000, meanwhile my ES6 solution is still works :D Anyway, your solution is very cool)
                      – Levitator Imbalance
                      Dec 14 '18 at 10:53





















                    2















                    6502 machine code (C64), 49 bytes



                    00 C0 20 9B B7 A2 00 8A 4A A8 90 05 A9 3C 20 D2 FF A9 2D C0 00 F0 06 20 D2 FF 
                    88 D0 FA 8A 4A B0 05 A9 3E 20 D2 FF A9 0D 20 D2 FF E8 E4 65 D0 D7 60


                    Still quite a bit shorter than BASIC ;) This one has a number range only up to 255 because the natural integer size of the machine has only 8 bits.



                    Online demo



                    Usage: SYS49152,[n] (e.g. SYS49152,3 for the example from the challenge)



                    Commented disassembly:



                             00 C0       .WORD $C000        ; load address
                    .C:c000 20 9B B7 JSR $B79B ; get unsigned byte from commandline
                    .C:c003 A2 00 LDX #$00 ; main loop counter
                    .C:c005 .loop:
                    .C:c005 8A TXA ; loop counter to accumulator
                    .C:c006 4A LSR A ; divide by 2, shift lowest bit to C
                    .C:c007 A8 TAY ; result to Y
                    .C:c008 90 05 BCC .toright ; C clear -> counter even, skip '<'
                    .C:c00a A9 3C LDA #$3C ; load character '<'
                    .C:c00c 20 D2 FF JSR $FFD2 ; output character
                    .C:c00f .toright:
                    .C:c00f A9 2D LDA #$2D ; load character '-'
                    .C:c011 C0 00 CPY #$00 ; counter/2 == 0 ? then no dashes
                    .C:c013 F0 06 BEQ .skipdashes
                    .C:c015 .printdashes:
                    .C:c015 20 D2 FF JSR $FFD2 ; output character
                    .C:c018 88 DEY ; decrement Y
                    .C:c019 D0 FA BNE .printdashes ; not 0 yet -> repeat
                    .C:c01b .skipdashes:
                    .C:c01b 8A TXA ; loop counter to accumulator
                    .C:c01c 4A LSR A ; shift lowest bit to C
                    .C:c01d B0 05 BCS .toleft ; C set -> counter odd, skip '>'
                    .C:c01f A9 3E LDA #$3E ; load character '>'
                    .C:c021 20 D2 FF JSR $FFD2 ; output character
                    .C:c024 .toleft:
                    .C:c024 A9 0D LDA #$0D ; load newline character
                    .C:c026 20 D2 FF JSR $FFD2 ; output character
                    .C:c029 E8 INX ; next loop iteration
                    .C:c02a E4 65 CPX $65 ; compare to command line argument
                    .C:c02c D0 D7 BNE .loop ; not reached yet -> repeat main loop
                    .C:c02e 60 RTS ; exit





                    share|improve this answer





























                      2















                      Perl 6, 39 bytes





                      {map {'<'x$_%2~'-'x$_/2~'>'x$_%%2},^$_}


                      Try it online!



                      Anonymous code block that returns a list of lines.






                      share|improve this answer





























                        2















                        K (ngn/k), 31 29 bytes



                        {"<->"x#2,x{(1=*x)_1,2-|x}}


                        Try it online!



                        first we generate lists with 0 instead of "<", 1 instead of "-", and 2 instead of ">":



                        { } function with argument x



                        x{...} apply the inner function x times, starting with an initial value of 0 and preserving intermediate results



                        |x reverse



                        2- replace 0 with 2 and vice versa, keep the 1s as they are



                        1, prepend a 1



                        (1=*x)_ is the first of x equal to 1? if yes, drop one element, otherwise drop 0 elements (do nothing)



                        2, prepend a 2 for the initial ">" arrow



                        x# we have a little too many lists, so take only the first x of them



                        "<->" use the lists' elements (0/1/2) as indices in this string






                        share|improve this answer























                        • I would like to ask for an explanation (I haven't started learning K yet, I don't know which version to start with...)
                          – Galen Ivanov
                          Dec 13 '18 at 12:14






                        • 1




                          @GalenIvanov i tried to write an explanation, i hope it makes sense. thanks for your interest in my favourite language :) there are multiple implementations with different advantages and disadvantages (kx's original, kona, oK and i'm working on my own). would you like to join the apl chat room so i can give you more details?
                          – ngn
                          Dec 13 '18 at 12:44












                        • Thank you, I'm already there
                          – Galen Ivanov
                          Dec 13 '18 at 12:49



















                        2















                        05AB1E, 23 20 bytes



                        FNÉD„><è'-N;∍«s_iR},


                        Try it online!



                        First time using 05AB1E or any other golfing language for that matter. Any ideas welcome.



                        -3 from Kevin Cruijssen






                        share|improve this answer



















                        • 1




                          Welcome to the world of 05AB1E, and nice first answer. +1 from me. :) "><" can be „>< to save a byte. There are builtins for 1, 2, and 3 char strings, being ', , and respectively. Here is a 18 bytes alternative I came up with, but perhaps it could be golfed a bit more. If you haven't seen it yet, we have a tips for golfing in 05AB1E page, and also feel free to ask anything in the chat.
                          – Kevin Cruijssen
                          Dec 13 '18 at 8:54








                        • 1




                          @KevinCruijssen Thanks so much for your ideas. I don't feel right just using your code, as it feels fairly different from mine, but I did use the idea of modulo 2 as checking for if a number is odd. I also use the two char string idea. I would not mind at all if you posted the 18 byte version on your own.
                          – nedla2004
                          Dec 13 '18 at 23:09










                        • I've posted my answer in that case. :)
                          – Kevin Cruijssen
                          Dec 14 '18 at 8:31



















                        2














                        ES6, 96 82 79 70 bytes



                        Try it online! (Thanks to @Oliver)



                        n=>[...Array(n)].map((_,i)=>(i%2?"<":"")+"-".repeat(i/2)+(i%2?"":">"))





                        share|improve this answer



















                        • 1




                          Welcome to PPCG! By default, taking input as a variable is disallowed; you have to either make it a function (just stick a i=> in front of your code!) or from a command-line argument or STDIN or something.
                          – HyperNeutrino
                          Dec 14 '18 at 14:40










                        • @HyperNeutrino okay, edited answer. However, the most voted answer contains only the body of the function, but ok. Anyway I'm outsider)
                          – Levitator Imbalance
                          Dec 14 '18 at 15:09












                        • Can you link it? I don't think any of them are invalid, at least not the top few.
                          – HyperNeutrino
                          Dec 14 '18 at 15:16






                        • 1




                          A few more bytes: Try it online
                          – Oliver
                          Dec 14 '18 at 16:15






                        • 1




                          A few more bytes if you re-arrange that last ternary operator and remove the center parenthesis: Try it online
                          – Oliver
                          Dec 14 '18 at 16:59



















                        2















                        Red, 109 108 bytes



                        -1 byte thanks to NK1406



                        func[n][repeat i n[print reduce[pick[pad/with pad/left/with]k: i% 2 + 1
                        pick copy"<>"k i / 2 + k - 1 #"-"]]]


                        Try it online!






                        share|improve this answer



















                        • 1




                          -1 for removing a space
                          – NK1406
                          Dec 15 '18 at 18:28










                        • @NK1406 Thank you! I didn't know this is valid.
                          – Galen Ivanov
                          Dec 15 '18 at 19:01



















                        2















                        C (gcc), 127 95 + 26 = 121 bytes





                        i,j;f(x){for(i=0;i<x;putchar(10),i+=2){for(j=0;E;printf(">n%c",x-i-1?60:9);for(j=0;x-i-1&&E;}}


                        Try it online!



                        Compile with -DE=j<i/2;++j)putchar(45)



                        -6 bytes from Logern



                        Yay mismatched parentheses!



                        Ungolfed:





                        void f(int x) {
                        for (int i = 0; i < x; i += 2) {
                        for (int j = 0; j < i/2; ++j) {
                        printf("-");
                        }
                        printf(">n");
                        if (x - i - 1) { // Test for last loop: only print <-- if x is even
                        printf("<");
                        for (int j = 0; j < i/2; ++j) {
                        printf("-");
                        }
                        }
                        else {
                        printf("t"); // This is the 9 in the x-i-1?60:9
                        }
                        printf("n");
                        }
                        }



                        Try it online!






                        share|improve this answer



















                        • 1




                          121 bytes with a -D compiler flag instead of #define - Try it online!
                          – Logern
                          Dec 14 '18 at 17:31










                        • Another -3 bytes by taking out the i=0 like this
                          – NK1406
                          Dec 15 '18 at 18:19










                        • @NK1406 Functions have to be reusable, that edit would break this rule. Try it online!
                          – pizzapants184
                          Dec 16 '18 at 5:32










                        • @pizzapants184 Sorry, didn't see that!
                          – NK1406
                          Dec 16 '18 at 14:19










                        • Suggest x+~i instead of x-i-1 and i+=puts(" ") instead of putchar(10),i+=2
                          – ceilingcat
                          Dec 28 '18 at 5:55





















                        1














                        Powershell, 51 bytes





                        param($n)0..$n|%{'-'*$_+'>';'<'+'-'*$_}|?{$n---gt0}





                        share|improve this answer





























                          1















                          Perl 5, 44 bytes





                          map{$_/=2;say'<'x/./,'-'x$_,'>'x!$&}0..<>-1


                          Try it online!






                          share|improve this answer

























                            1 2
                            next



                            Your Answer





                            StackExchange.ifUsing("editor", function () {
                            return StackExchange.using("mathjaxEditing", function () {
                            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                            });
                            });
                            }, "mathjax-editing");

                            StackExchange.ifUsing("editor", function () {
                            StackExchange.using("externalEditor", function () {
                            StackExchange.using("snippets", function () {
                            StackExchange.snippets.init();
                            });
                            });
                            }, "code-snippets");

                            StackExchange.ready(function() {
                            var channelOptions = {
                            tags: "".split(" "),
                            id: "200"
                            };
                            initTagRenderer("".split(" "), "".split(" "), channelOptions);

                            StackExchange.using("externalEditor", function() {
                            // Have to fire editor after snippets, if snippets enabled
                            if (StackExchange.settings.snippets.snippetsEnabled) {
                            StackExchange.using("snippets", function() {
                            createEditor();
                            });
                            }
                            else {
                            createEditor();
                            }
                            });

                            function createEditor() {
                            StackExchange.prepareEditor({
                            heartbeatType: 'answer',
                            autoActivateHeartbeat: false,
                            convertImagesToLinks: false,
                            noModals: true,
                            showLowRepImageUploadWarning: true,
                            reputationToPostImages: null,
                            bindNavPrevention: true,
                            postfix: "",
                            imageUploader: {
                            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                            allowUrls: true
                            },
                            onDemand: true,
                            discardSelector: ".discard-answer"
                            ,immediatelyShowMarkdownHelp:true
                            });


                            }
                            });














                            draft saved

                            draft discarded


















                            StackExchange.ready(
                            function () {
                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177454%2fdraw-some-expanding-arrows%23new-answer', 'question_page');
                            }
                            );

                            Post as a guest















                            Required, but never shown

























                            38 Answers
                            38






                            active

                            oldest

                            votes








                            38 Answers
                            38






                            active

                            oldest

                            votes









                            active

                            oldest

                            votes






                            active

                            oldest

                            votes








                            1 2
                            next










                            6















                            Canvas, 10 bytes



                            ⇵-×<n¹[↔}]


                            Try it here!






                            share|improve this answer





















                            • I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                              – Pavel
                              Dec 12 '18 at 16:03










                            • is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                              – dzaima
                              Dec 12 '18 at 16:04
















                            6















                            Canvas, 10 bytes



                            ⇵-×<n¹[↔}]


                            Try it here!






                            share|improve this answer





















                            • I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                              – Pavel
                              Dec 12 '18 at 16:03










                            • is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                              – dzaima
                              Dec 12 '18 at 16:04














                            6












                            6








                            6







                            Canvas, 10 bytes



                            ⇵-×<n¹[↔}]


                            Try it here!






                            share|improve this answer













                            Canvas, 10 bytes



                            ⇵-×<n¹[↔}]


                            Try it here!







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 12 '18 at 16:01









                            dzaima

                            14.4k21754




                            14.4k21754












                            • I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                              – Pavel
                              Dec 12 '18 at 16:03










                            • is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                              – dzaima
                              Dec 12 '18 at 16:04


















                            • I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                              – Pavel
                              Dec 12 '18 at 16:03










                            • is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                              – dzaima
                              Dec 12 '18 at 16:04
















                            I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                            – Pavel
                            Dec 12 '18 at 16:03




                            I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                            – Pavel
                            Dec 12 '18 at 16:03












                            is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                            – dzaima
                            Dec 12 '18 at 16:04




                            is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                            – dzaima
                            Dec 12 '18 at 16:04











                            8















                            R, 69 bytes





                            for(i in 1:scan()-1)cat('<'[i%%2],rep('-',i/2),'>'[!i%%2],'
                            ',sep='')


                            Try it online!




                            • -5 bytes thanks to @Giuseppe

                            • -3 bytes thanks to @Robert S.






                            share|improve this answer























                            • strrep coerces its second argument to integer so you can use / in place of %/%
                              – Giuseppe
                              Dec 12 '18 at 16:40










                            • you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                              – Giuseppe
                              Dec 12 '18 at 16:44










                            • I'm an idiot... thanks ! :D
                              – digEmAll
                              Dec 12 '18 at 17:17










                            • @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                              – digEmAll
                              Dec 12 '18 at 17:21
















                            8















                            R, 69 bytes





                            for(i in 1:scan()-1)cat('<'[i%%2],rep('-',i/2),'>'[!i%%2],'
                            ',sep='')


                            Try it online!




                            • -5 bytes thanks to @Giuseppe

                            • -3 bytes thanks to @Robert S.






                            share|improve this answer























                            • strrep coerces its second argument to integer so you can use / in place of %/%
                              – Giuseppe
                              Dec 12 '18 at 16:40










                            • you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                              – Giuseppe
                              Dec 12 '18 at 16:44










                            • I'm an idiot... thanks ! :D
                              – digEmAll
                              Dec 12 '18 at 17:17










                            • @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                              – digEmAll
                              Dec 12 '18 at 17:21














                            8












                            8








                            8







                            R, 69 bytes





                            for(i in 1:scan()-1)cat('<'[i%%2],rep('-',i/2),'>'[!i%%2],'
                            ',sep='')


                            Try it online!




                            • -5 bytes thanks to @Giuseppe

                            • -3 bytes thanks to @Robert S.






                            share|improve this answer















                            R, 69 bytes





                            for(i in 1:scan()-1)cat('<'[i%%2],rep('-',i/2),'>'[!i%%2],'
                            ',sep='')


                            Try it online!




                            • -5 bytes thanks to @Giuseppe

                            • -3 bytes thanks to @Robert S.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Dec 12 '18 at 17:18

























                            answered Dec 12 '18 at 16:36









                            digEmAll

                            2,45148




                            2,45148












                            • strrep coerces its second argument to integer so you can use / in place of %/%
                              – Giuseppe
                              Dec 12 '18 at 16:40










                            • you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                              – Giuseppe
                              Dec 12 '18 at 16:44










                            • I'm an idiot... thanks ! :D
                              – digEmAll
                              Dec 12 '18 at 17:17










                            • @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                              – digEmAll
                              Dec 12 '18 at 17:21


















                            • strrep coerces its second argument to integer so you can use / in place of %/%
                              – Giuseppe
                              Dec 12 '18 at 16:40










                            • you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                              – Giuseppe
                              Dec 12 '18 at 16:44










                            • I'm an idiot... thanks ! :D
                              – digEmAll
                              Dec 12 '18 at 17:17










                            • @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                              – digEmAll
                              Dec 12 '18 at 17:21
















                            strrep coerces its second argument to integer so you can use / in place of %/%
                            – Giuseppe
                            Dec 12 '18 at 16:40




                            strrep coerces its second argument to integer so you can use / in place of %/%
                            – Giuseppe
                            Dec 12 '18 at 16:40












                            you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                            – Giuseppe
                            Dec 12 '18 at 16:44




                            you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                            – Giuseppe
                            Dec 12 '18 at 16:44












                            I'm an idiot... thanks ! :D
                            – digEmAll
                            Dec 12 '18 at 17:17




                            I'm an idiot... thanks ! :D
                            – digEmAll
                            Dec 12 '18 at 17:17












                            @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                            – digEmAll
                            Dec 12 '18 at 17:21




                            @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                            – digEmAll
                            Dec 12 '18 at 17:21











                            8














                            Haskell, 41 40 bytes



                            (`take`g">")
                            g p=p:('<':init p):g('-':p)


                            Try it online!



                            Plain old recursion: start with string p = ">", collect p, a < in front of all but the last char of p and a recursive call with one - put in front of p. Take the first n items of this list.



                            Edit: -1 byte thanks to @xnor.






                            share|improve this answer



















                            • 1




                              A weird change to save a byte.
                              – xnor
                              Dec 13 '18 at 5:44
















                            8














                            Haskell, 41 40 bytes



                            (`take`g">")
                            g p=p:('<':init p):g('-':p)


                            Try it online!



                            Plain old recursion: start with string p = ">", collect p, a < in front of all but the last char of p and a recursive call with one - put in front of p. Take the first n items of this list.



                            Edit: -1 byte thanks to @xnor.






                            share|improve this answer



















                            • 1




                              A weird change to save a byte.
                              – xnor
                              Dec 13 '18 at 5:44














                            8












                            8








                            8






                            Haskell, 41 40 bytes



                            (`take`g">")
                            g p=p:('<':init p):g('-':p)


                            Try it online!



                            Plain old recursion: start with string p = ">", collect p, a < in front of all but the last char of p and a recursive call with one - put in front of p. Take the first n items of this list.



                            Edit: -1 byte thanks to @xnor.






                            share|improve this answer














                            Haskell, 41 40 bytes



                            (`take`g">")
                            g p=p:('<':init p):g('-':p)


                            Try it online!



                            Plain old recursion: start with string p = ">", collect p, a < in front of all but the last char of p and a recursive call with one - put in front of p. Take the first n items of this list.



                            Edit: -1 byte thanks to @xnor.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Dec 13 '18 at 18:05

























                            answered Dec 12 '18 at 17:33









                            nimi

                            31.4k32085




                            31.4k32085








                            • 1




                              A weird change to save a byte.
                              – xnor
                              Dec 13 '18 at 5:44














                            • 1




                              A weird change to save a byte.
                              – xnor
                              Dec 13 '18 at 5:44








                            1




                            1




                            A weird change to save a byte.
                            – xnor
                            Dec 13 '18 at 5:44




                            A weird change to save a byte.
                            – xnor
                            Dec 13 '18 at 5:44











                            7















                            Java (JDK), 81 bytes





                            n->{for(int i=0;i<n;)System.out.printf(i%2<1?"<%s%n":"%s>%n","-".repeat(i++/2));}


                            Try it online!



                            Explanations



                            n->{                  // int-accepting consumer
                            for(int i=0;i<n;) // for each i from 0 to n-1 included
                            System.out.printf( // output on stdout with a pattern
                            i%2<1 // if i is even:
                            ?"<%s%n" // use the left-arrow pattern
                            :"%s>%n", // else: use the right-arrow pattern
                            "-".repeat(i++/2) // fill the "%s" in the pattern with i/2 dashes, and increment i
                            ); //
                            } //





                            share|improve this answer























                            • Consider removing static reference to System.out
                              – candied_orange
                              Dec 15 '18 at 18:11












                            • @candied_orange That's not self-contained.
                              – Olivier Grégoire
                              Dec 15 '18 at 18:32










                            • How about done like this?
                              – candied_orange
                              Dec 15 '18 at 18:52












                            • @candied_orange It's the same: the imports are required in the count.
                              – Olivier Grégoire
                              Dec 15 '18 at 19:38










                            • Why doesn't import java.util.function.*; count?
                              – candied_orange
                              Dec 15 '18 at 19:44
















                            7















                            Java (JDK), 81 bytes





                            n->{for(int i=0;i<n;)System.out.printf(i%2<1?"<%s%n":"%s>%n","-".repeat(i++/2));}


                            Try it online!



                            Explanations



                            n->{                  // int-accepting consumer
                            for(int i=0;i<n;) // for each i from 0 to n-1 included
                            System.out.printf( // output on stdout with a pattern
                            i%2<1 // if i is even:
                            ?"<%s%n" // use the left-arrow pattern
                            :"%s>%n", // else: use the right-arrow pattern
                            "-".repeat(i++/2) // fill the "%s" in the pattern with i/2 dashes, and increment i
                            ); //
                            } //





                            share|improve this answer























                            • Consider removing static reference to System.out
                              – candied_orange
                              Dec 15 '18 at 18:11












                            • @candied_orange That's not self-contained.
                              – Olivier Grégoire
                              Dec 15 '18 at 18:32










                            • How about done like this?
                              – candied_orange
                              Dec 15 '18 at 18:52












                            • @candied_orange It's the same: the imports are required in the count.
                              – Olivier Grégoire
                              Dec 15 '18 at 19:38










                            • Why doesn't import java.util.function.*; count?
                              – candied_orange
                              Dec 15 '18 at 19:44














                            7












                            7








                            7







                            Java (JDK), 81 bytes





                            n->{for(int i=0;i<n;)System.out.printf(i%2<1?"<%s%n":"%s>%n","-".repeat(i++/2));}


                            Try it online!



                            Explanations



                            n->{                  // int-accepting consumer
                            for(int i=0;i<n;) // for each i from 0 to n-1 included
                            System.out.printf( // output on stdout with a pattern
                            i%2<1 // if i is even:
                            ?"<%s%n" // use the left-arrow pattern
                            :"%s>%n", // else: use the right-arrow pattern
                            "-".repeat(i++/2) // fill the "%s" in the pattern with i/2 dashes, and increment i
                            ); //
                            } //





                            share|improve this answer















                            Java (JDK), 81 bytes





                            n->{for(int i=0;i<n;)System.out.printf(i%2<1?"<%s%n":"%s>%n","-".repeat(i++/2));}


                            Try it online!



                            Explanations



                            n->{                  // int-accepting consumer
                            for(int i=0;i<n;) // for each i from 0 to n-1 included
                            System.out.printf( // output on stdout with a pattern
                            i%2<1 // if i is even:
                            ?"<%s%n" // use the left-arrow pattern
                            :"%s>%n", // else: use the right-arrow pattern
                            "-".repeat(i++/2) // fill the "%s" in the pattern with i/2 dashes, and increment i
                            ); //
                            } //






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Dec 13 '18 at 11:01

























                            answered Dec 12 '18 at 16:41









                            Olivier Grégoire

                            8,77711843




                            8,77711843












                            • Consider removing static reference to System.out
                              – candied_orange
                              Dec 15 '18 at 18:11












                            • @candied_orange That's not self-contained.
                              – Olivier Grégoire
                              Dec 15 '18 at 18:32










                            • How about done like this?
                              – candied_orange
                              Dec 15 '18 at 18:52












                            • @candied_orange It's the same: the imports are required in the count.
                              – Olivier Grégoire
                              Dec 15 '18 at 19:38










                            • Why doesn't import java.util.function.*; count?
                              – candied_orange
                              Dec 15 '18 at 19:44


















                            • Consider removing static reference to System.out
                              – candied_orange
                              Dec 15 '18 at 18:11












                            • @candied_orange That's not self-contained.
                              – Olivier Grégoire
                              Dec 15 '18 at 18:32










                            • How about done like this?
                              – candied_orange
                              Dec 15 '18 at 18:52












                            • @candied_orange It's the same: the imports are required in the count.
                              – Olivier Grégoire
                              Dec 15 '18 at 19:38










                            • Why doesn't import java.util.function.*; count?
                              – candied_orange
                              Dec 15 '18 at 19:44
















                            Consider removing static reference to System.out
                            – candied_orange
                            Dec 15 '18 at 18:11






                            Consider removing static reference to System.out
                            – candied_orange
                            Dec 15 '18 at 18:11














                            @candied_orange That's not self-contained.
                            – Olivier Grégoire
                            Dec 15 '18 at 18:32




                            @candied_orange That's not self-contained.
                            – Olivier Grégoire
                            Dec 15 '18 at 18:32












                            How about done like this?
                            – candied_orange
                            Dec 15 '18 at 18:52






                            How about done like this?
                            – candied_orange
                            Dec 15 '18 at 18:52














                            @candied_orange It's the same: the imports are required in the count.
                            – Olivier Grégoire
                            Dec 15 '18 at 19:38




                            @candied_orange It's the same: the imports are required in the count.
                            – Olivier Grégoire
                            Dec 15 '18 at 19:38












                            Why doesn't import java.util.function.*; count?
                            – candied_orange
                            Dec 15 '18 at 19:44




                            Why doesn't import java.util.function.*; count?
                            – candied_orange
                            Dec 15 '18 at 19:44











                            6















                            Commodore BASIC V2 (C64), 94 bytes



                            0inputn:fOi=1ton:oniaN1gO1:?"<";
                            1on-(i<3)gO2:fOj=1.5toi/2:?"-";:nE
                            2on-nOiaN1gO3:?">";
                            3?:nE


                            Not entirely sure about the byte count, this is based on the text representation for typing the valid program. It's a bit shorter on disk (91 bytes) because BASIC V2 uses a "tokenized" representation of programs.



                            Online Demo



                            Slightly "ungolfed":



                            0 inputn:fori=1ton:oniand1goto1:print"<";    :rem read n from user, loop to n, if odd skip "<"
                            1 on-(i<3)goto2:forj=1.5toi/2:print"-";:next :rem skip for i<3, print (i-1)/2 times "-"
                            2 on-notiand1goto3:print">"; :rem if even skip ">"
                            3 print:next :rem newline and next loop iteration





                            share|improve this answer


























                              6















                              Commodore BASIC V2 (C64), 94 bytes



                              0inputn:fOi=1ton:oniaN1gO1:?"<";
                              1on-(i<3)gO2:fOj=1.5toi/2:?"-";:nE
                              2on-nOiaN1gO3:?">";
                              3?:nE


                              Not entirely sure about the byte count, this is based on the text representation for typing the valid program. It's a bit shorter on disk (91 bytes) because BASIC V2 uses a "tokenized" representation of programs.



                              Online Demo



                              Slightly "ungolfed":



                              0 inputn:fori=1ton:oniand1goto1:print"<";    :rem read n from user, loop to n, if odd skip "<"
                              1 on-(i<3)goto2:forj=1.5toi/2:print"-";:next :rem skip for i<3, print (i-1)/2 times "-"
                              2 on-notiand1goto3:print">"; :rem if even skip ">"
                              3 print:next :rem newline and next loop iteration





                              share|improve this answer
























                                6












                                6








                                6







                                Commodore BASIC V2 (C64), 94 bytes



                                0inputn:fOi=1ton:oniaN1gO1:?"<";
                                1on-(i<3)gO2:fOj=1.5toi/2:?"-";:nE
                                2on-nOiaN1gO3:?">";
                                3?:nE


                                Not entirely sure about the byte count, this is based on the text representation for typing the valid program. It's a bit shorter on disk (91 bytes) because BASIC V2 uses a "tokenized" representation of programs.



                                Online Demo



                                Slightly "ungolfed":



                                0 inputn:fori=1ton:oniand1goto1:print"<";    :rem read n from user, loop to n, if odd skip "<"
                                1 on-(i<3)goto2:forj=1.5toi/2:print"-";:next :rem skip for i<3, print (i-1)/2 times "-"
                                2 on-notiand1goto3:print">"; :rem if even skip ">"
                                3 print:next :rem newline and next loop iteration





                                share|improve this answer













                                Commodore BASIC V2 (C64), 94 bytes



                                0inputn:fOi=1ton:oniaN1gO1:?"<";
                                1on-(i<3)gO2:fOj=1.5toi/2:?"-";:nE
                                2on-nOiaN1gO3:?">";
                                3?:nE


                                Not entirely sure about the byte count, this is based on the text representation for typing the valid program. It's a bit shorter on disk (91 bytes) because BASIC V2 uses a "tokenized" representation of programs.



                                Online Demo



                                Slightly "ungolfed":



                                0 inputn:fori=1ton:oniand1goto1:print"<";    :rem read n from user, loop to n, if odd skip "<"
                                1 on-(i<3)goto2:forj=1.5toi/2:print"-";:next :rem skip for i<3, print (i-1)/2 times "-"
                                2 on-notiand1goto3:print">"; :rem if even skip ">"
                                3 print:next :rem newline and next loop iteration






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Dec 12 '18 at 16:53









                                Felix Palmen

                                3,341525




                                3,341525























                                    6















                                    Python 2, 54 bytes



                                    thanks to the and Jo King for fixing a bug.





                                    k=0
                                    exec"print k%2*'<'+k/2*'-'+~k%2*'>';k+=1;"*input()


                                    Try it online!






                                    share|improve this answer



















                                    • 3




                                      Your arrows have too many dashes; only every other one should lengthen by a dash.
                                      – xnor
                                      Dec 13 '18 at 2:35






                                    • 1




                                      54 bytes
                                      – tsh
                                      Dec 13 '18 at 5:23










                                    • 54 bytes with the arrows pointing the right way
                                      – Jo King
                                      Dec 13 '18 at 9:52
















                                    6















                                    Python 2, 54 bytes



                                    thanks to the and Jo King for fixing a bug.





                                    k=0
                                    exec"print k%2*'<'+k/2*'-'+~k%2*'>';k+=1;"*input()


                                    Try it online!






                                    share|improve this answer



















                                    • 3




                                      Your arrows have too many dashes; only every other one should lengthen by a dash.
                                      – xnor
                                      Dec 13 '18 at 2:35






                                    • 1




                                      54 bytes
                                      – tsh
                                      Dec 13 '18 at 5:23










                                    • 54 bytes with the arrows pointing the right way
                                      – Jo King
                                      Dec 13 '18 at 9:52














                                    6












                                    6








                                    6







                                    Python 2, 54 bytes



                                    thanks to the and Jo King for fixing a bug.





                                    k=0
                                    exec"print k%2*'<'+k/2*'-'+~k%2*'>';k+=1;"*input()


                                    Try it online!






                                    share|improve this answer















                                    Python 2, 54 bytes



                                    thanks to the and Jo King for fixing a bug.





                                    k=0
                                    exec"print k%2*'<'+k/2*'-'+~k%2*'>';k+=1;"*input()


                                    Try it online!







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Dec 13 '18 at 17:25

























                                    answered Dec 12 '18 at 16:14









                                    ovs

                                    18.7k21059




                                    18.7k21059








                                    • 3




                                      Your arrows have too many dashes; only every other one should lengthen by a dash.
                                      – xnor
                                      Dec 13 '18 at 2:35






                                    • 1




                                      54 bytes
                                      – tsh
                                      Dec 13 '18 at 5:23










                                    • 54 bytes with the arrows pointing the right way
                                      – Jo King
                                      Dec 13 '18 at 9:52














                                    • 3




                                      Your arrows have too many dashes; only every other one should lengthen by a dash.
                                      – xnor
                                      Dec 13 '18 at 2:35






                                    • 1




                                      54 bytes
                                      – tsh
                                      Dec 13 '18 at 5:23










                                    • 54 bytes with the arrows pointing the right way
                                      – Jo King
                                      Dec 13 '18 at 9:52








                                    3




                                    3




                                    Your arrows have too many dashes; only every other one should lengthen by a dash.
                                    – xnor
                                    Dec 13 '18 at 2:35




                                    Your arrows have too many dashes; only every other one should lengthen by a dash.
                                    – xnor
                                    Dec 13 '18 at 2:35




                                    1




                                    1




                                    54 bytes
                                    – tsh
                                    Dec 13 '18 at 5:23




                                    54 bytes
                                    – tsh
                                    Dec 13 '18 at 5:23












                                    54 bytes with the arrows pointing the right way
                                    – Jo King
                                    Dec 13 '18 at 9:52




                                    54 bytes with the arrows pointing the right way
                                    – Jo King
                                    Dec 13 '18 at 9:52











                                    5














                                    Pyth, 17 bytes



                                    m_W%d2+*-/d2@"><


                                    Output is a list of strings. Try it online here.



                                    m_W%d2+*-/d2@"><"dQ   Implicit: Q=eval(input())
                                    Trailing "dQ inferred
                                    m Q Map [0-Q), as d, using:
                                    /d2 Floored division of d by 2
                                    *- Repeat "-" the above number of times
                                    + Append to the above...
                                    @"><"d Modular index d into "><" - yields ">" for even d, "<" for odd
                                    - examples: d=4 gives "-->", d=7 gives "---<"
                                    _W Reverse the above if...
                                    %d2 ... (d % 2) != 0
                                    Implicit print result of the map





                                    share|improve this answer


























                                      5














                                      Pyth, 17 bytes



                                      m_W%d2+*-/d2@"><


                                      Output is a list of strings. Try it online here.



                                      m_W%d2+*-/d2@"><"dQ   Implicit: Q=eval(input())
                                      Trailing "dQ inferred
                                      m Q Map [0-Q), as d, using:
                                      /d2 Floored division of d by 2
                                      *- Repeat "-" the above number of times
                                      + Append to the above...
                                      @"><"d Modular index d into "><" - yields ">" for even d, "<" for odd
                                      - examples: d=4 gives "-->", d=7 gives "---<"
                                      _W Reverse the above if...
                                      %d2 ... (d % 2) != 0
                                      Implicit print result of the map





                                      share|improve this answer
























                                        5












                                        5








                                        5






                                        Pyth, 17 bytes



                                        m_W%d2+*-/d2@"><


                                        Output is a list of strings. Try it online here.



                                        m_W%d2+*-/d2@"><"dQ   Implicit: Q=eval(input())
                                        Trailing "dQ inferred
                                        m Q Map [0-Q), as d, using:
                                        /d2 Floored division of d by 2
                                        *- Repeat "-" the above number of times
                                        + Append to the above...
                                        @"><"d Modular index d into "><" - yields ">" for even d, "<" for odd
                                        - examples: d=4 gives "-->", d=7 gives "---<"
                                        _W Reverse the above if...
                                        %d2 ... (d % 2) != 0
                                        Implicit print result of the map





                                        share|improve this answer












                                        Pyth, 17 bytes



                                        m_W%d2+*-/d2@"><


                                        Output is a list of strings. Try it online here.



                                        m_W%d2+*-/d2@"><"dQ   Implicit: Q=eval(input())
                                        Trailing "dQ inferred
                                        m Q Map [0-Q), as d, using:
                                        /d2 Floored division of d by 2
                                        *- Repeat "-" the above number of times
                                        + Append to the above...
                                        @"><"d Modular index d into "><" - yields ">" for even d, "<" for odd
                                        - examples: d=4 gives "-->", d=7 gives "---<"
                                        _W Reverse the above if...
                                        %d2 ... (d % 2) != 0
                                        Implicit print result of the map






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Dec 12 '18 at 16:16









                                        Sok

                                        3,537722




                                        3,537722























                                            5














                                            Python 3, 53 bytes



                                            My first codegolf answer.



                                            lambda x:[i%2*"<"+i//2*"-"+~i%2*">"for i in range(x)]


                                            -10 bytes thanks to Jo King






                                            share|improve this answer



















                                            • 1




                                              Welcome to PPCG! You can remove the brackets by putting the string after the number, use ~i instead of i+1 and use // to integer divide, assuming you're using Python 3. 53 bytes
                                              – Jo King
                                              Dec 13 '18 at 9:45








                                            • 1




                                              I've linked the updated solution in my previous comment. If you like, you can use the auto-formatter in the TIO link to help create your answer
                                              – Jo King
                                              Dec 13 '18 at 9:54
















                                            5














                                            Python 3, 53 bytes



                                            My first codegolf answer.



                                            lambda x:[i%2*"<"+i//2*"-"+~i%2*">"for i in range(x)]


                                            -10 bytes thanks to Jo King






                                            share|improve this answer



















                                            • 1




                                              Welcome to PPCG! You can remove the brackets by putting the string after the number, use ~i instead of i+1 and use // to integer divide, assuming you're using Python 3. 53 bytes
                                              – Jo King
                                              Dec 13 '18 at 9:45








                                            • 1




                                              I've linked the updated solution in my previous comment. If you like, you can use the auto-formatter in the TIO link to help create your answer
                                              – Jo King
                                              Dec 13 '18 at 9:54














                                            5












                                            5








                                            5






                                            Python 3, 53 bytes



                                            My first codegolf answer.



                                            lambda x:[i%2*"<"+i//2*"-"+~i%2*">"for i in range(x)]


                                            -10 bytes thanks to Jo King






                                            share|improve this answer














                                            Python 3, 53 bytes



                                            My first codegolf answer.



                                            lambda x:[i%2*"<"+i//2*"-"+~i%2*">"for i in range(x)]


                                            -10 bytes thanks to Jo King







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Dec 13 '18 at 9:54

























                                            answered Dec 13 '18 at 9:28









                                            van der Zon Stef

                                            1513




                                            1513








                                            • 1




                                              Welcome to PPCG! You can remove the brackets by putting the string after the number, use ~i instead of i+1 and use // to integer divide, assuming you're using Python 3. 53 bytes
                                              – Jo King
                                              Dec 13 '18 at 9:45








                                            • 1




                                              I've linked the updated solution in my previous comment. If you like, you can use the auto-formatter in the TIO link to help create your answer
                                              – Jo King
                                              Dec 13 '18 at 9:54














                                            • 1




                                              Welcome to PPCG! You can remove the brackets by putting the string after the number, use ~i instead of i+1 and use // to integer divide, assuming you're using Python 3. 53 bytes
                                              – Jo King
                                              Dec 13 '18 at 9:45








                                            • 1




                                              I've linked the updated solution in my previous comment. If you like, you can use the auto-formatter in the TIO link to help create your answer
                                              – Jo King
                                              Dec 13 '18 at 9:54








                                            1




                                            1




                                            Welcome to PPCG! You can remove the brackets by putting the string after the number, use ~i instead of i+1 and use // to integer divide, assuming you're using Python 3. 53 bytes
                                            – Jo King
                                            Dec 13 '18 at 9:45






                                            Welcome to PPCG! You can remove the brackets by putting the string after the number, use ~i instead of i+1 and use // to integer divide, assuming you're using Python 3. 53 bytes
                                            – Jo King
                                            Dec 13 '18 at 9:45






                                            1




                                            1




                                            I've linked the updated solution in my previous comment. If you like, you can use the auto-formatter in the TIO link to help create your answer
                                            – Jo King
                                            Dec 13 '18 at 9:54




                                            I've linked the updated solution in my previous comment. If you like, you can use the auto-formatter in the TIO link to help create your answer
                                            – Jo King
                                            Dec 13 '18 at 9:54











                                            5















                                            Self-modifying Brainfuck, 55 bytes



                                            Take input as character code.

                                            Only support input up to 255.

                                            Use null character to separate lines.



                                            Coincidentally, all arrow-drawing characters are used as BF commands. Unfortunately, it doesn't save any bytes (currently).



                                            >>,[<<[-<.>>+<]<<.>>.+>>-[<<<<<.>>>>[-<+<.>>].>-<]>]<>-


                                            Try it online!



                                            Explanation



                                             Code  |              Memory         | Output | Comment
                                            -------+-----------------------------+--------+--------------------------
                                            | '<' '>' '-' [0] 0 0 0 | |
                                            >>, | '<' '>' '-' 0 0 [x] 0 | |
                                            [ | | |
                                            | '<' '>' '-' l 0 [x] 0 | | l = arrow length
                                            <<[-< | | | copy l to next cell
                                            .>>+<] | | | and print '-'
                                            | '<' '>' '-' [0] l x 0 | ----- | there are l '-'s
                                            <<. | '<' [>] '-' 0 l x 0 | > |
                                            >>.+ | '<' '>' '-' [1] l x 0 | <null> |
                                            >>- | '<' '>' '-' 1 l [y] 0 | | y=x-1
                                            [ | | | execute if y>0
                                            <<<<<. | [<] '>' '-' 1 l y 0 | < |
                                            >>>> | '<' '>' '-' 1 [l] y 0 | |
                                            [-<+<. | | |
                                            >>] | '<' '>' '-' L [0] y 0 | ----- | L=l+1
                                            . | '<' '>' '-' L [0] y 0 | <null> |
                                            >-<]>] | | | decrement y
                                            <>- | | | do nothing, used as data





                                            share|improve this answer




























                                              5















                                              Self-modifying Brainfuck, 55 bytes



                                              Take input as character code.

                                              Only support input up to 255.

                                              Use null character to separate lines.



                                              Coincidentally, all arrow-drawing characters are used as BF commands. Unfortunately, it doesn't save any bytes (currently).



                                              >>,[<<[-<.>>+<]<<.>>.+>>-[<<<<<.>>>>[-<+<.>>].>-<]>]<>-


                                              Try it online!



                                              Explanation



                                               Code  |              Memory         | Output | Comment
                                              -------+-----------------------------+--------+--------------------------
                                              | '<' '>' '-' [0] 0 0 0 | |
                                              >>, | '<' '>' '-' 0 0 [x] 0 | |
                                              [ | | |
                                              | '<' '>' '-' l 0 [x] 0 | | l = arrow length
                                              <<[-< | | | copy l to next cell
                                              .>>+<] | | | and print '-'
                                              | '<' '>' '-' [0] l x 0 | ----- | there are l '-'s
                                              <<. | '<' [>] '-' 0 l x 0 | > |
                                              >>.+ | '<' '>' '-' [1] l x 0 | <null> |
                                              >>- | '<' '>' '-' 1 l [y] 0 | | y=x-1
                                              [ | | | execute if y>0
                                              <<<<<. | [<] '>' '-' 1 l y 0 | < |
                                              >>>> | '<' '>' '-' 1 [l] y 0 | |
                                              [-<+<. | | |
                                              >>] | '<' '>' '-' L [0] y 0 | ----- | L=l+1
                                              . | '<' '>' '-' L [0] y 0 | <null> |
                                              >-<]>] | | | decrement y
                                              <>- | | | do nothing, used as data





                                              share|improve this answer


























                                                5












                                                5








                                                5







                                                Self-modifying Brainfuck, 55 bytes



                                                Take input as character code.

                                                Only support input up to 255.

                                                Use null character to separate lines.



                                                Coincidentally, all arrow-drawing characters are used as BF commands. Unfortunately, it doesn't save any bytes (currently).



                                                >>,[<<[-<.>>+<]<<.>>.+>>-[<<<<<.>>>>[-<+<.>>].>-<]>]<>-


                                                Try it online!



                                                Explanation



                                                 Code  |              Memory         | Output | Comment
                                                -------+-----------------------------+--------+--------------------------
                                                | '<' '>' '-' [0] 0 0 0 | |
                                                >>, | '<' '>' '-' 0 0 [x] 0 | |
                                                [ | | |
                                                | '<' '>' '-' l 0 [x] 0 | | l = arrow length
                                                <<[-< | | | copy l to next cell
                                                .>>+<] | | | and print '-'
                                                | '<' '>' '-' [0] l x 0 | ----- | there are l '-'s
                                                <<. | '<' [>] '-' 0 l x 0 | > |
                                                >>.+ | '<' '>' '-' [1] l x 0 | <null> |
                                                >>- | '<' '>' '-' 1 l [y] 0 | | y=x-1
                                                [ | | | execute if y>0
                                                <<<<<. | [<] '>' '-' 1 l y 0 | < |
                                                >>>> | '<' '>' '-' 1 [l] y 0 | |
                                                [-<+<. | | |
                                                >>] | '<' '>' '-' L [0] y 0 | ----- | L=l+1
                                                . | '<' '>' '-' L [0] y 0 | <null> |
                                                >-<]>] | | | decrement y
                                                <>- | | | do nothing, used as data





                                                share|improve this answer















                                                Self-modifying Brainfuck, 55 bytes



                                                Take input as character code.

                                                Only support input up to 255.

                                                Use null character to separate lines.



                                                Coincidentally, all arrow-drawing characters are used as BF commands. Unfortunately, it doesn't save any bytes (currently).



                                                >>,[<<[-<.>>+<]<<.>>.+>>-[<<<<<.>>>>[-<+<.>>].>-<]>]<>-


                                                Try it online!



                                                Explanation



                                                 Code  |              Memory         | Output | Comment
                                                -------+-----------------------------+--------+--------------------------
                                                | '<' '>' '-' [0] 0 0 0 | |
                                                >>, | '<' '>' '-' 0 0 [x] 0 | |
                                                [ | | |
                                                | '<' '>' '-' l 0 [x] 0 | | l = arrow length
                                                <<[-< | | | copy l to next cell
                                                .>>+<] | | | and print '-'
                                                | '<' '>' '-' [0] l x 0 | ----- | there are l '-'s
                                                <<. | '<' [>] '-' 0 l x 0 | > |
                                                >>.+ | '<' '>' '-' [1] l x 0 | <null> |
                                                >>- | '<' '>' '-' 1 l [y] 0 | | y=x-1
                                                [ | | | execute if y>0
                                                <<<<<. | [<] '>' '-' 1 l y 0 | < |
                                                >>>> | '<' '>' '-' 1 [l] y 0 | |
                                                [-<+<. | | |
                                                >>] | '<' '>' '-' L [0] y 0 | ----- | L=l+1
                                                . | '<' '>' '-' L [0] y 0 | <null> |
                                                >-<]>] | | | decrement y
                                                <>- | | | do nothing, used as data






                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Dec 13 '18 at 11:12

























                                                answered Dec 13 '18 at 10:48









                                                user202729

                                                13.9k12551




                                                13.9k12551























                                                    5















                                                    Haskell, 51 44 bytes



                                                    -7 bytes thanks to xnor (using iterate over list-comprehension)!





                                                    (`take`do b<-iterate('-':)"";[b++">",'<':b])


                                                    Try it online!



                                                    Explanation / Ungolfed



                                                    Using do-notation saves us a concat, and using infix-notation allows a pointfree function with take, undoing these would give:



                                                    f n = take n $ concat [ [b++">", '<':b] | b <- iterate ('-':) "" ]





                                                    share|improve this answer




























                                                      5















                                                      Haskell, 51 44 bytes



                                                      -7 bytes thanks to xnor (using iterate over list-comprehension)!





                                                      (`take`do b<-iterate('-':)"";[b++">",'<':b])


                                                      Try it online!



                                                      Explanation / Ungolfed



                                                      Using do-notation saves us a concat, and using infix-notation allows a pointfree function with take, undoing these would give:



                                                      f n = take n $ concat [ [b++">", '<':b] | b <- iterate ('-':) "" ]





                                                      share|improve this answer


























                                                        5












                                                        5








                                                        5







                                                        Haskell, 51 44 bytes



                                                        -7 bytes thanks to xnor (using iterate over list-comprehension)!





                                                        (`take`do b<-iterate('-':)"";[b++">",'<':b])


                                                        Try it online!



                                                        Explanation / Ungolfed



                                                        Using do-notation saves us a concat, and using infix-notation allows a pointfree function with take, undoing these would give:



                                                        f n = take n $ concat [ [b++">", '<':b] | b <- iterate ('-':) "" ]





                                                        share|improve this answer















                                                        Haskell, 51 44 bytes



                                                        -7 bytes thanks to xnor (using iterate over list-comprehension)!





                                                        (`take`do b<-iterate('-':)"";[b++">",'<':b])


                                                        Try it online!



                                                        Explanation / Ungolfed



                                                        Using do-notation saves us a concat, and using infix-notation allows a pointfree function with take, undoing these would give:



                                                        f n = take n $ concat [ [b++">", '<':b] | b <- iterate ('-':) "" ]






                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited Dec 13 '18 at 14:04

























                                                        answered Dec 12 '18 at 17:22









                                                        BMO

                                                        11.3k22185




                                                        11.3k22185























                                                            5














                                                            Japt -m, 16 15 13 bytes



                                                            g"><" iUUz ç-


                                                            Test it online



                                                            Explanation:



                                                            -m              // Map the program through [0...Input); U becomes the item
                                                            g"><" iUUz ç-
                                                            "><" // Literal "><"
                                                            g // Get the char at index U (with wrapping)
                                                            i // Insert:
                                                            U // At index U (with wrapping)
                                                            ç- // "-" repeated:
                                                            Uz // U/2 times





                                                            share|improve this answer




























                                                              5














                                                              Japt -m, 16 15 13 bytes



                                                              g"><" iUUz ç-


                                                              Test it online



                                                              Explanation:



                                                              -m              // Map the program through [0...Input); U becomes the item
                                                              g"><" iUUz ç-
                                                              "><" // Literal "><"
                                                              g // Get the char at index U (with wrapping)
                                                              i // Insert:
                                                              U // At index U (with wrapping)
                                                              ç- // "-" repeated:
                                                              Uz // U/2 times





                                                              share|improve this answer


























                                                                5












                                                                5








                                                                5






                                                                Japt -m, 16 15 13 bytes



                                                                g"><" iUUz ç-


                                                                Test it online



                                                                Explanation:



                                                                -m              // Map the program through [0...Input); U becomes the item
                                                                g"><" iUUz ç-
                                                                "><" // Literal "><"
                                                                g // Get the char at index U (with wrapping)
                                                                i // Insert:
                                                                U // At index U (with wrapping)
                                                                ç- // "-" repeated:
                                                                Uz // U/2 times





                                                                share|improve this answer














                                                                Japt -m, 16 15 13 bytes



                                                                g"><" iUUz ç-


                                                                Test it online



                                                                Explanation:



                                                                -m              // Map the program through [0...Input); U becomes the item
                                                                g"><" iUUz ç-
                                                                "><" // Literal "><"
                                                                g // Get the char at index U (with wrapping)
                                                                i // Insert:
                                                                U // At index U (with wrapping)
                                                                ç- // "-" repeated:
                                                                Uz // U/2 times






                                                                share|improve this answer














                                                                share|improve this answer



                                                                share|improve this answer








                                                                edited Dec 14 '18 at 15:24

























                                                                answered Dec 12 '18 at 19:49









                                                                Oliver

                                                                4,7401831




                                                                4,7401831























                                                                    4















                                                                    PowerShell, 62 56 50 bytes





                                                                    param($n)(0..$n|%{($j='-'*$_)+'>';"<$j"})[0..--$n]


                                                                    Try it online!



                                                                    Loops from 0 up to input $n, each iteration creating two arrow strings. Those are then indexed with 0..--$n to pull out the correct number of elements.



                                                                    Saved 6 bytes thanks to KGlasier.






                                                                    share|improve this answer























                                                                    • Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                                      – KGlasier
                                                                      Dec 12 '18 at 17:00










                                                                    • Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                                      – KGlasier
                                                                      Dec 12 '18 at 17:03








                                                                    • 1




                                                                      @KGlasier Awesome - thanks for the obvious golfs! :)
                                                                      – AdmBorkBork
                                                                      Dec 12 '18 at 17:16
















                                                                    4















                                                                    PowerShell, 62 56 50 bytes





                                                                    param($n)(0..$n|%{($j='-'*$_)+'>';"<$j"})[0..--$n]


                                                                    Try it online!



                                                                    Loops from 0 up to input $n, each iteration creating two arrow strings. Those are then indexed with 0..--$n to pull out the correct number of elements.



                                                                    Saved 6 bytes thanks to KGlasier.






                                                                    share|improve this answer























                                                                    • Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                                      – KGlasier
                                                                      Dec 12 '18 at 17:00










                                                                    • Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                                      – KGlasier
                                                                      Dec 12 '18 at 17:03








                                                                    • 1




                                                                      @KGlasier Awesome - thanks for the obvious golfs! :)
                                                                      – AdmBorkBork
                                                                      Dec 12 '18 at 17:16














                                                                    4












                                                                    4








                                                                    4







                                                                    PowerShell, 62 56 50 bytes





                                                                    param($n)(0..$n|%{($j='-'*$_)+'>';"<$j"})[0..--$n]


                                                                    Try it online!



                                                                    Loops from 0 up to input $n, each iteration creating two arrow strings. Those are then indexed with 0..--$n to pull out the correct number of elements.



                                                                    Saved 6 bytes thanks to KGlasier.






                                                                    share|improve this answer















                                                                    PowerShell, 62 56 50 bytes





                                                                    param($n)(0..$n|%{($j='-'*$_)+'>';"<$j"})[0..--$n]


                                                                    Try it online!



                                                                    Loops from 0 up to input $n, each iteration creating two arrow strings. Those are then indexed with 0..--$n to pull out the correct number of elements.



                                                                    Saved 6 bytes thanks to KGlasier.







                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited Dec 12 '18 at 17:16

























                                                                    answered Dec 12 '18 at 16:34









                                                                    AdmBorkBork

                                                                    26.3k364228




                                                                    26.3k364228












                                                                    • Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                                      – KGlasier
                                                                      Dec 12 '18 at 17:00










                                                                    • Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                                      – KGlasier
                                                                      Dec 12 '18 at 17:03








                                                                    • 1




                                                                      @KGlasier Awesome - thanks for the obvious golfs! :)
                                                                      – AdmBorkBork
                                                                      Dec 12 '18 at 17:16


















                                                                    • Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                                      – KGlasier
                                                                      Dec 12 '18 at 17:00










                                                                    • Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                                      – KGlasier
                                                                      Dec 12 '18 at 17:03








                                                                    • 1




                                                                      @KGlasier Awesome - thanks for the obvious golfs! :)
                                                                      – AdmBorkBork
                                                                      Dec 12 '18 at 17:16
















                                                                    Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                                    – KGlasier
                                                                    Dec 12 '18 at 17:00




                                                                    Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                                    – KGlasier
                                                                    Dec 12 '18 at 17:00












                                                                    Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                                    – KGlasier
                                                                    Dec 12 '18 at 17:03






                                                                    Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                                    – KGlasier
                                                                    Dec 12 '18 at 17:03






                                                                    1




                                                                    1




                                                                    @KGlasier Awesome - thanks for the obvious golfs! :)
                                                                    – AdmBorkBork
                                                                    Dec 12 '18 at 17:16




                                                                    @KGlasier Awesome - thanks for the obvious golfs! :)
                                                                    – AdmBorkBork
                                                                    Dec 12 '18 at 17:16











                                                                    4















                                                                    Jelly, 15 bytes



                                                                    ị⁾><;’H”-ẋƲṚ⁸¡)


                                                                    Try it online!






                                                                    share|improve this answer





















                                                                    • -1 byte using tie: TIO.
                                                                      – HyperNeutrino
                                                                      Dec 14 '18 at 14:29
















                                                                    4















                                                                    Jelly, 15 bytes



                                                                    ị⁾><;’H”-ẋƲṚ⁸¡)


                                                                    Try it online!






                                                                    share|improve this answer





















                                                                    • -1 byte using tie: TIO.
                                                                      – HyperNeutrino
                                                                      Dec 14 '18 at 14:29














                                                                    4












                                                                    4








                                                                    4







                                                                    Jelly, 15 bytes



                                                                    ị⁾><;’H”-ẋƲṚ⁸¡)


                                                                    Try it online!






                                                                    share|improve this answer













                                                                    Jelly, 15 bytes



                                                                    ị⁾><;’H”-ẋƲṚ⁸¡)


                                                                    Try it online!







                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered Dec 12 '18 at 17:17









                                                                    Erik the Outgolfer

                                                                    31.4k429103




                                                                    31.4k429103












                                                                    • -1 byte using tie: TIO.
                                                                      – HyperNeutrino
                                                                      Dec 14 '18 at 14:29


















                                                                    • -1 byte using tie: TIO.
                                                                      – HyperNeutrino
                                                                      Dec 14 '18 at 14:29
















                                                                    -1 byte using tie: TIO.
                                                                    – HyperNeutrino
                                                                    Dec 14 '18 at 14:29




                                                                    -1 byte using tie: TIO.
                                                                    – HyperNeutrino
                                                                    Dec 14 '18 at 14:29











                                                                    4















                                                                    MathGolf, 17 15 bytes



                                                                    Saved 2 bytes thanks to Jo King and Kevin Cruijssen



                                                                    {ï½'-*'>ï¥╛Å⌡n


                                                                    Try it online!



                                                                    Explanation



                                                                    The 15-byte approach is different compared to my original solution, I can't take any credit for the implementation.



                                                                    {                 start block or arbitrary length
                                                                    ï index of current loop, or length of last loop
                                                                    ½ pop a : push(a//2 if int else a/2)
                                                                    '- push single character "-"
                                                                    * pop a, b : push(a*b)
                                                                    '> push single character ">"
                                                                    ï index of current loop, or length of last loop
                                                                    ¥ modulo 2
                                                                    ╛ if without else
                                                                    Å start block of length 2
                                                                    ⌡ decrement twice
                                                                    swap top elements
                                                                    n newline char, or map array with newlines





                                                                    share|improve this answer























                                                                    • How does the if/else work in MathGolf? I know how the if-without-else and else-without-if statements work, but how to create an if{ ... } else{ ... } in MathGolf with ¿? (Maybe I should post this in the chat instead of here.. But I might perhaps have a save of 1 byte if I can fix the if-else.)
                                                                      – Kevin Cruijssen
                                                                      Dec 13 '18 at 10:20








                                                                    • 1




                                                                      @KevinCruijssen I think it works with the next two commands/blocks. e.g. ¿12 will push 1 if true, else 2, ¿Å3*Å1+ will add one if true else triple the next element
                                                                      – Jo King
                                                                      Dec 13 '18 at 10:30












                                                                    • @KevinCruijssen The if/else pops two operators or blocks from the code. Jo King is correct in his example, but you could also do ¿{"foo"}{"bar"} or ¿1{2}.
                                                                      – maxb
                                                                      Dec 13 '18 at 10:34










                                                                    • @JoKing I'll add a TODO to fix the docs for the slicing operators.
                                                                      – maxb
                                                                      Dec 13 '18 at 10:35






                                                                    • 1




                                                                      15 bytes using @KevinCruijssen's solution
                                                                      – Jo King
                                                                      Dec 13 '18 at 10:46


















                                                                    4















                                                                    MathGolf, 17 15 bytes



                                                                    Saved 2 bytes thanks to Jo King and Kevin Cruijssen



                                                                    {ï½'-*'>ï¥╛Å⌡n


                                                                    Try it online!



                                                                    Explanation



                                                                    The 15-byte approach is different compared to my original solution, I can't take any credit for the implementation.



                                                                    {                 start block or arbitrary length
                                                                    ï index of current loop, or length of last loop
                                                                    ½ pop a : push(a//2 if int else a/2)
                                                                    '- push single character "-"
                                                                    * pop a, b : push(a*b)
                                                                    '> push single character ">"
                                                                    ï index of current loop, or length of last loop
                                                                    ¥ modulo 2
                                                                    ╛ if without else
                                                                    Å start block of length 2
                                                                    ⌡ decrement twice
                                                                    swap top elements
                                                                    n newline char, or map array with newlines





                                                                    share|improve this answer























                                                                    • How does the if/else work in MathGolf? I know how the if-without-else and else-without-if statements work, but how to create an if{ ... } else{ ... } in MathGolf with ¿? (Maybe I should post this in the chat instead of here.. But I might perhaps have a save of 1 byte if I can fix the if-else.)
                                                                      – Kevin Cruijssen
                                                                      Dec 13 '18 at 10:20








                                                                    • 1




                                                                      @KevinCruijssen I think it works with the next two commands/blocks. e.g. ¿12 will push 1 if true, else 2, ¿Å3*Å1+ will add one if true else triple the next element
                                                                      – Jo King
                                                                      Dec 13 '18 at 10:30












                                                                    • @KevinCruijssen The if/else pops two operators or blocks from the code. Jo King is correct in his example, but you could also do ¿{"foo"}{"bar"} or ¿1{2}.
                                                                      – maxb
                                                                      Dec 13 '18 at 10:34










                                                                    • @JoKing I'll add a TODO to fix the docs for the slicing operators.
                                                                      – maxb
                                                                      Dec 13 '18 at 10:35






                                                                    • 1




                                                                      15 bytes using @KevinCruijssen's solution
                                                                      – Jo King
                                                                      Dec 13 '18 at 10:46
















                                                                    4












                                                                    4








                                                                    4







                                                                    MathGolf, 17 15 bytes



                                                                    Saved 2 bytes thanks to Jo King and Kevin Cruijssen



                                                                    {ï½'-*'>ï¥╛Å⌡n


                                                                    Try it online!



                                                                    Explanation



                                                                    The 15-byte approach is different compared to my original solution, I can't take any credit for the implementation.



                                                                    {                 start block or arbitrary length
                                                                    ï index of current loop, or length of last loop
                                                                    ½ pop a : push(a//2 if int else a/2)
                                                                    '- push single character "-"
                                                                    * pop a, b : push(a*b)
                                                                    '> push single character ">"
                                                                    ï index of current loop, or length of last loop
                                                                    ¥ modulo 2
                                                                    ╛ if without else
                                                                    Å start block of length 2
                                                                    ⌡ decrement twice
                                                                    swap top elements
                                                                    n newline char, or map array with newlines





                                                                    share|improve this answer















                                                                    MathGolf, 17 15 bytes



                                                                    Saved 2 bytes thanks to Jo King and Kevin Cruijssen



                                                                    {ï½'-*'>ï¥╛Å⌡n


                                                                    Try it online!



                                                                    Explanation



                                                                    The 15-byte approach is different compared to my original solution, I can't take any credit for the implementation.



                                                                    {                 start block or arbitrary length
                                                                    ï index of current loop, or length of last loop
                                                                    ½ pop a : push(a//2 if int else a/2)
                                                                    '- push single character "-"
                                                                    * pop a, b : push(a*b)
                                                                    '> push single character ">"
                                                                    ï index of current loop, or length of last loop
                                                                    ¥ modulo 2
                                                                    ╛ if without else
                                                                    Å start block of length 2
                                                                    ⌡ decrement twice
                                                                    swap top elements
                                                                    n newline char, or map array with newlines






                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited Dec 13 '18 at 11:47

























                                                                    answered Dec 13 '18 at 10:08









                                                                    maxb

                                                                    2,92611131




                                                                    2,92611131












                                                                    • How does the if/else work in MathGolf? I know how the if-without-else and else-without-if statements work, but how to create an if{ ... } else{ ... } in MathGolf with ¿? (Maybe I should post this in the chat instead of here.. But I might perhaps have a save of 1 byte if I can fix the if-else.)
                                                                      – Kevin Cruijssen
                                                                      Dec 13 '18 at 10:20








                                                                    • 1




                                                                      @KevinCruijssen I think it works with the next two commands/blocks. e.g. ¿12 will push 1 if true, else 2, ¿Å3*Å1+ will add one if true else triple the next element
                                                                      – Jo King
                                                                      Dec 13 '18 at 10:30












                                                                    • @KevinCruijssen The if/else pops two operators or blocks from the code. Jo King is correct in his example, but you could also do ¿{"foo"}{"bar"} or ¿1{2}.
                                                                      – maxb
                                                                      Dec 13 '18 at 10:34










                                                                    • @JoKing I'll add a TODO to fix the docs for the slicing operators.
                                                                      – maxb
                                                                      Dec 13 '18 at 10:35






                                                                    • 1




                                                                      15 bytes using @KevinCruijssen's solution
                                                                      – Jo King
                                                                      Dec 13 '18 at 10:46




















                                                                    • How does the if/else work in MathGolf? I know how the if-without-else and else-without-if statements work, but how to create an if{ ... } else{ ... } in MathGolf with ¿? (Maybe I should post this in the chat instead of here.. But I might perhaps have a save of 1 byte if I can fix the if-else.)
                                                                      – Kevin Cruijssen
                                                                      Dec 13 '18 at 10:20








                                                                    • 1




                                                                      @KevinCruijssen I think it works with the next two commands/blocks. e.g. ¿12 will push 1 if true, else 2, ¿Å3*Å1+ will add one if true else triple the next element
                                                                      – Jo King
                                                                      Dec 13 '18 at 10:30












                                                                    • @KevinCruijssen The if/else pops two operators or blocks from the code. Jo King is correct in his example, but you could also do ¿{"foo"}{"bar"} or ¿1{2}.
                                                                      – maxb
                                                                      Dec 13 '18 at 10:34










                                                                    • @JoKing I'll add a TODO to fix the docs for the slicing operators.
                                                                      – maxb
                                                                      Dec 13 '18 at 10:35






                                                                    • 1




                                                                      15 bytes using @KevinCruijssen's solution
                                                                      – Jo King
                                                                      Dec 13 '18 at 10:46


















                                                                    How does the if/else work in MathGolf? I know how the if-without-else and else-without-if statements work, but how to create an if{ ... } else{ ... } in MathGolf with ¿? (Maybe I should post this in the chat instead of here.. But I might perhaps have a save of 1 byte if I can fix the if-else.)
                                                                    – Kevin Cruijssen
                                                                    Dec 13 '18 at 10:20






                                                                    How does the if/else work in MathGolf? I know how the if-without-else and else-without-if statements work, but how to create an if{ ... } else{ ... } in MathGolf with ¿? (Maybe I should post this in the chat instead of here.. But I might perhaps have a save of 1 byte if I can fix the if-else.)
                                                                    – Kevin Cruijssen
                                                                    Dec 13 '18 at 10:20






                                                                    1




                                                                    1




                                                                    @KevinCruijssen I think it works with the next two commands/blocks. e.g. ¿12 will push 1 if true, else 2, ¿Å3*Å1+ will add one if true else triple the next element
                                                                    – Jo King
                                                                    Dec 13 '18 at 10:30






                                                                    @KevinCruijssen I think it works with the next two commands/blocks. e.g. ¿12 will push 1 if true, else 2, ¿Å3*Å1+ will add one if true else triple the next element
                                                                    – Jo King
                                                                    Dec 13 '18 at 10:30














                                                                    @KevinCruijssen The if/else pops two operators or blocks from the code. Jo King is correct in his example, but you could also do ¿{"foo"}{"bar"} or ¿1{2}.
                                                                    – maxb
                                                                    Dec 13 '18 at 10:34




                                                                    @KevinCruijssen The if/else pops two operators or blocks from the code. Jo King is correct in his example, but you could also do ¿{"foo"}{"bar"} or ¿1{2}.
                                                                    – maxb
                                                                    Dec 13 '18 at 10:34












                                                                    @JoKing I'll add a TODO to fix the docs for the slicing operators.
                                                                    – maxb
                                                                    Dec 13 '18 at 10:35




                                                                    @JoKing I'll add a TODO to fix the docs for the slicing operators.
                                                                    – maxb
                                                                    Dec 13 '18 at 10:35




                                                                    1




                                                                    1




                                                                    15 bytes using @KevinCruijssen's solution
                                                                    – Jo King
                                                                    Dec 13 '18 at 10:46






                                                                    15 bytes using @KevinCruijssen's solution
                                                                    – Jo King
                                                                    Dec 13 '18 at 10:46













                                                                    4















                                                                    Japt -m, 14 bytes



                                                                    "<>"¬hUUz ç-)q


                                                                    Try it online!



                                                                    Updated with a completely new method.



                                                                    Explanation:



                                                                                      #Implicitly map over the range [0..input) as U
                                                                    "<>" #The string "<>"
                                                                    ¬ #Split into the array ["<",">"]
                                                                    hU ) #Replace the element at index U with wrapping:
                                                                    - # The character '-'
                                                                    ç # Repeated a number of times equal to
                                                                    Uz # U integer divided by 2
                                                                    q #Join the array to a string





                                                                    share|improve this answer



















                                                                    • 1




                                                                      ç auto-casts its first parameter into a string, so you can drop the '.
                                                                      – Oliver
                                                                      Dec 13 '18 at 0:21






                                                                    • 1




                                                                      You don't need the u method thanks to index wrapping so this can be 14 bytes.
                                                                      – Shaggy
                                                                      Dec 13 '18 at 8:13
















                                                                    4















                                                                    Japt -m, 14 bytes



                                                                    "<>"¬hUUz ç-)q


                                                                    Try it online!



                                                                    Updated with a completely new method.



                                                                    Explanation:



                                                                                      #Implicitly map over the range [0..input) as U
                                                                    "<>" #The string "<>"
                                                                    ¬ #Split into the array ["<",">"]
                                                                    hU ) #Replace the element at index U with wrapping:
                                                                    - # The character '-'
                                                                    ç # Repeated a number of times equal to
                                                                    Uz # U integer divided by 2
                                                                    q #Join the array to a string





                                                                    share|improve this answer



















                                                                    • 1




                                                                      ç auto-casts its first parameter into a string, so you can drop the '.
                                                                      – Oliver
                                                                      Dec 13 '18 at 0:21






                                                                    • 1




                                                                      You don't need the u method thanks to index wrapping so this can be 14 bytes.
                                                                      – Shaggy
                                                                      Dec 13 '18 at 8:13














                                                                    4












                                                                    4








                                                                    4







                                                                    Japt -m, 14 bytes



                                                                    "<>"¬hUUz ç-)q


                                                                    Try it online!



                                                                    Updated with a completely new method.



                                                                    Explanation:



                                                                                      #Implicitly map over the range [0..input) as U
                                                                    "<>" #The string "<>"
                                                                    ¬ #Split into the array ["<",">"]
                                                                    hU ) #Replace the element at index U with wrapping:
                                                                    - # The character '-'
                                                                    ç # Repeated a number of times equal to
                                                                    Uz # U integer divided by 2
                                                                    q #Join the array to a string





                                                                    share|improve this answer















                                                                    Japt -m, 14 bytes



                                                                    "<>"¬hUUz ç-)q


                                                                    Try it online!



                                                                    Updated with a completely new method.



                                                                    Explanation:



                                                                                      #Implicitly map over the range [0..input) as U
                                                                    "<>" #The string "<>"
                                                                    ¬ #Split into the array ["<",">"]
                                                                    hU ) #Replace the element at index U with wrapping:
                                                                    - # The character '-'
                                                                    ç # Repeated a number of times equal to
                                                                    Uz # U integer divided by 2
                                                                    q #Join the array to a string






                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited Dec 13 '18 at 14:07

























                                                                    answered Dec 12 '18 at 18:09









                                                                    Kamil Drakari

                                                                    2,971416




                                                                    2,971416








                                                                    • 1




                                                                      ç auto-casts its first parameter into a string, so you can drop the '.
                                                                      – Oliver
                                                                      Dec 13 '18 at 0:21






                                                                    • 1




                                                                      You don't need the u method thanks to index wrapping so this can be 14 bytes.
                                                                      – Shaggy
                                                                      Dec 13 '18 at 8:13














                                                                    • 1




                                                                      ç auto-casts its first parameter into a string, so you can drop the '.
                                                                      – Oliver
                                                                      Dec 13 '18 at 0:21






                                                                    • 1




                                                                      You don't need the u method thanks to index wrapping so this can be 14 bytes.
                                                                      – Shaggy
                                                                      Dec 13 '18 at 8:13








                                                                    1




                                                                    1




                                                                    ç auto-casts its first parameter into a string, so you can drop the '.
                                                                    – Oliver
                                                                    Dec 13 '18 at 0:21




                                                                    ç auto-casts its first parameter into a string, so you can drop the '.
                                                                    – Oliver
                                                                    Dec 13 '18 at 0:21




                                                                    1




                                                                    1




                                                                    You don't need the u method thanks to index wrapping so this can be 14 bytes.
                                                                    – Shaggy
                                                                    Dec 13 '18 at 8:13




                                                                    You don't need the u method thanks to index wrapping so this can be 14 bytes.
                                                                    – Shaggy
                                                                    Dec 13 '18 at 8:13











                                                                    3














                                                                    JavaScript (ES6), 58 bytes



                                                                    Returns a space-separated string.





                                                                    n=>(g=p=>n--?k++&1?`<${p} `+g(p+'-'):p+'> '+g(p):'')(k='')


                                                                    Try it online!






                                                                    share|improve this answer


























                                                                      3














                                                                      JavaScript (ES6), 58 bytes



                                                                      Returns a space-separated string.





                                                                      n=>(g=p=>n--?k++&1?`<${p} `+g(p+'-'):p+'> '+g(p):'')(k='')


                                                                      Try it online!






                                                                      share|improve this answer
























                                                                        3












                                                                        3








                                                                        3






                                                                        JavaScript (ES6), 58 bytes



                                                                        Returns a space-separated string.





                                                                        n=>(g=p=>n--?k++&1?`<${p} `+g(p+'-'):p+'> '+g(p):'')(k='')


                                                                        Try it online!






                                                                        share|improve this answer












                                                                        JavaScript (ES6), 58 bytes



                                                                        Returns a space-separated string.





                                                                        n=>(g=p=>n--?k++&1?`<${p} `+g(p+'-'):p+'> '+g(p):'')(k='')


                                                                        Try it online!







                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered Dec 12 '18 at 16:30









                                                                        Arnauld

                                                                        72.4k689305




                                                                        72.4k689305























                                                                            3















                                                                            SNOBOL4 (CSNOBOL4), 123 122 118 bytes



                                                                            	N =INPUT - 1
                                                                            P H =X / 2
                                                                            Y =DUPL('-',H)
                                                                            OUTPUT =EQ(H,X - H) Y '>' :S(I)
                                                                            OUTPUT ='<' Y
                                                                            I X =LT(X,N) X + 1 :S(P)
                                                                            END


                                                                            Try it online!






                                                                            share|improve this answer




























                                                                              3















                                                                              SNOBOL4 (CSNOBOL4), 123 122 118 bytes



                                                                              	N =INPUT - 1
                                                                              P H =X / 2
                                                                              Y =DUPL('-',H)
                                                                              OUTPUT =EQ(H,X - H) Y '>' :S(I)
                                                                              OUTPUT ='<' Y
                                                                              I X =LT(X,N) X + 1 :S(P)
                                                                              END


                                                                              Try it online!






                                                                              share|improve this answer


























                                                                                3












                                                                                3








                                                                                3







                                                                                SNOBOL4 (CSNOBOL4), 123 122 118 bytes



                                                                                	N =INPUT - 1
                                                                                P H =X / 2
                                                                                Y =DUPL('-',H)
                                                                                OUTPUT =EQ(H,X - H) Y '>' :S(I)
                                                                                OUTPUT ='<' Y
                                                                                I X =LT(X,N) X + 1 :S(P)
                                                                                END


                                                                                Try it online!






                                                                                share|improve this answer















                                                                                SNOBOL4 (CSNOBOL4), 123 122 118 bytes



                                                                                	N =INPUT - 1
                                                                                P H =X / 2
                                                                                Y =DUPL('-',H)
                                                                                OUTPUT =EQ(H,X - H) Y '>' :S(I)
                                                                                OUTPUT ='<' Y
                                                                                I X =LT(X,N) X + 1 :S(P)
                                                                                END


                                                                                Try it online!







                                                                                share|improve this answer














                                                                                share|improve this answer



                                                                                share|improve this answer








                                                                                edited Dec 12 '18 at 17:23

























                                                                                answered Dec 12 '18 at 16:39









                                                                                Giuseppe

                                                                                16.6k31052




                                                                                16.6k31052























                                                                                    3















                                                                                    V, 22 bytes



                                                                                    i>
                                                                                    <Àñäkjjé-já-ñÀGjdG


                                                                                    Try it online!






                                                                                    share|improve this answer

















                                                                                    • 5




                                                                                      This looks like some weird scandinavian language
                                                                                      – Pavel
                                                                                      Dec 12 '18 at 18:02
















                                                                                    3















                                                                                    V, 22 bytes



                                                                                    i>
                                                                                    <Àñäkjjé-já-ñÀGjdG


                                                                                    Try it online!






                                                                                    share|improve this answer

















                                                                                    • 5




                                                                                      This looks like some weird scandinavian language
                                                                                      – Pavel
                                                                                      Dec 12 '18 at 18:02














                                                                                    3












                                                                                    3








                                                                                    3







                                                                                    V, 22 bytes



                                                                                    i>
                                                                                    <Àñäkjjé-já-ñÀGjdG


                                                                                    Try it online!






                                                                                    share|improve this answer













                                                                                    V, 22 bytes



                                                                                    i>
                                                                                    <Àñäkjjé-já-ñÀGjdG


                                                                                    Try it online!







                                                                                    share|improve this answer












                                                                                    share|improve this answer



                                                                                    share|improve this answer










                                                                                    answered Dec 12 '18 at 17:50









                                                                                    DJMcMayhem

                                                                                    40.9k11145309




                                                                                    40.9k11145309








                                                                                    • 5




                                                                                      This looks like some weird scandinavian language
                                                                                      – Pavel
                                                                                      Dec 12 '18 at 18:02














                                                                                    • 5




                                                                                      This looks like some weird scandinavian language
                                                                                      – Pavel
                                                                                      Dec 12 '18 at 18:02








                                                                                    5




                                                                                    5




                                                                                    This looks like some weird scandinavian language
                                                                                    – Pavel
                                                                                    Dec 12 '18 at 18:02




                                                                                    This looks like some weird scandinavian language
                                                                                    – Pavel
                                                                                    Dec 12 '18 at 18:02











                                                                                    3















                                                                                    Charcoal, 16 bytes



                                                                                    NθFθ«⊘ι↓>‖T»Fθ‖T


                                                                                    Try it online! Link is to verbose version of code. I had three 17-byte solutions before I eventually stumbled over this one. Explanation:



                                                                                    Nθ


                                                                                    Input n.



                                                                                    Fθ«


                                                                                    Repeat n times, 0-indexed.



                                                                                    ⊘ι


                                                                                    Draw a line of -s of length half the index (truncated).



                                                                                    ↓>


                                                                                    Draw the arrowhead and move to the next line.



                                                                                    ‖T»


                                                                                    Reflect everything, flipping the arrowheads.



                                                                                    Fθ‖T


                                                                                    The above loop has n reflections, but we need an even number of reflections, so perform another n reflections.






                                                                                    share|improve this answer


























                                                                                      3















                                                                                      Charcoal, 16 bytes



                                                                                      NθFθ«⊘ι↓>‖T»Fθ‖T


                                                                                      Try it online! Link is to verbose version of code. I had three 17-byte solutions before I eventually stumbled over this one. Explanation:



                                                                                      Nθ


                                                                                      Input n.



                                                                                      Fθ«


                                                                                      Repeat n times, 0-indexed.



                                                                                      ⊘ι


                                                                                      Draw a line of -s of length half the index (truncated).



                                                                                      ↓>


                                                                                      Draw the arrowhead and move to the next line.



                                                                                      ‖T»


                                                                                      Reflect everything, flipping the arrowheads.



                                                                                      Fθ‖T


                                                                                      The above loop has n reflections, but we need an even number of reflections, so perform another n reflections.






                                                                                      share|improve this answer
























                                                                                        3












                                                                                        3








                                                                                        3







                                                                                        Charcoal, 16 bytes



                                                                                        NθFθ«⊘ι↓>‖T»Fθ‖T


                                                                                        Try it online! Link is to verbose version of code. I had three 17-byte solutions before I eventually stumbled over this one. Explanation:



                                                                                        Nθ


                                                                                        Input n.



                                                                                        Fθ«


                                                                                        Repeat n times, 0-indexed.



                                                                                        ⊘ι


                                                                                        Draw a line of -s of length half the index (truncated).



                                                                                        ↓>


                                                                                        Draw the arrowhead and move to the next line.



                                                                                        ‖T»


                                                                                        Reflect everything, flipping the arrowheads.



                                                                                        Fθ‖T


                                                                                        The above loop has n reflections, but we need an even number of reflections, so perform another n reflections.






                                                                                        share|improve this answer













                                                                                        Charcoal, 16 bytes



                                                                                        NθFθ«⊘ι↓>‖T»Fθ‖T


                                                                                        Try it online! Link is to verbose version of code. I had three 17-byte solutions before I eventually stumbled over this one. Explanation:



                                                                                        Nθ


                                                                                        Input n.



                                                                                        Fθ«


                                                                                        Repeat n times, 0-indexed.



                                                                                        ⊘ι


                                                                                        Draw a line of -s of length half the index (truncated).



                                                                                        ↓>


                                                                                        Draw the arrowhead and move to the next line.



                                                                                        ‖T»


                                                                                        Reflect everything, flipping the arrowheads.



                                                                                        Fθ‖T


                                                                                        The above loop has n reflections, but we need an even number of reflections, so perform another n reflections.







                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered Dec 12 '18 at 20:59









                                                                                        Neil

                                                                                        79.4k744177




                                                                                        79.4k744177























                                                                                            3















                                                                                            Clean, 76 73 bytes



                                                                                            import StdEnv,StdLib
                                                                                            $n=take n[s\i<-inits['--'..],s<-[i++['>'],['<':i]]]


                                                                                            Try it online!



                                                                                            Uses the neat fact that ['-','-'..] is the same as ['--'..] to save a bit.






                                                                                            share|improve this answer


























                                                                                              3















                                                                                              Clean, 76 73 bytes



                                                                                              import StdEnv,StdLib
                                                                                              $n=take n[s\i<-inits['--'..],s<-[i++['>'],['<':i]]]


                                                                                              Try it online!



                                                                                              Uses the neat fact that ['-','-'..] is the same as ['--'..] to save a bit.






                                                                                              share|improve this answer
























                                                                                                3












                                                                                                3








                                                                                                3







                                                                                                Clean, 76 73 bytes



                                                                                                import StdEnv,StdLib
                                                                                                $n=take n[s\i<-inits['--'..],s<-[i++['>'],['<':i]]]


                                                                                                Try it online!



                                                                                                Uses the neat fact that ['-','-'..] is the same as ['--'..] to save a bit.






                                                                                                share|improve this answer













                                                                                                Clean, 76 73 bytes



                                                                                                import StdEnv,StdLib
                                                                                                $n=take n[s\i<-inits['--'..],s<-[i++['>'],['<':i]]]


                                                                                                Try it online!



                                                                                                Uses the neat fact that ['-','-'..] is the same as ['--'..] to save a bit.







                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered Dec 12 '18 at 21:35









                                                                                                Οurous

                                                                                                6,44311033




                                                                                                6,44311033























                                                                                                    3














                                                                                                    JavaScript, 49 bytes





                                                                                                    f=n=>--n?f(n,l='')+(n%2?`
                                                                                                    <`+l:`
                                                                                                    ${l+='-'}>`):'>'


                                                                                                    Try it online!






                                                                                                    share|improve this answer























                                                                                                    • Wow, pretty cool
                                                                                                      – Levitator Imbalance
                                                                                                      Dec 14 '18 at 10:41










                                                                                                    • ...but it throws on 10000, meanwhile my ES6 solution is still works :D Anyway, your solution is very cool)
                                                                                                      – Levitator Imbalance
                                                                                                      Dec 14 '18 at 10:53


















                                                                                                    3














                                                                                                    JavaScript, 49 bytes





                                                                                                    f=n=>--n?f(n,l='')+(n%2?`
                                                                                                    <`+l:`
                                                                                                    ${l+='-'}>`):'>'


                                                                                                    Try it online!






                                                                                                    share|improve this answer























                                                                                                    • Wow, pretty cool
                                                                                                      – Levitator Imbalance
                                                                                                      Dec 14 '18 at 10:41










                                                                                                    • ...but it throws on 10000, meanwhile my ES6 solution is still works :D Anyway, your solution is very cool)
                                                                                                      – Levitator Imbalance
                                                                                                      Dec 14 '18 at 10:53
















                                                                                                    3












                                                                                                    3








                                                                                                    3






                                                                                                    JavaScript, 49 bytes





                                                                                                    f=n=>--n?f(n,l='')+(n%2?`
                                                                                                    <`+l:`
                                                                                                    ${l+='-'}>`):'>'


                                                                                                    Try it online!






                                                                                                    share|improve this answer














                                                                                                    JavaScript, 49 bytes





                                                                                                    f=n=>--n?f(n,l='')+(n%2?`
                                                                                                    <`+l:`
                                                                                                    ${l+='-'}>`):'>'


                                                                                                    Try it online!







                                                                                                    share|improve this answer














                                                                                                    share|improve this answer



                                                                                                    share|improve this answer








                                                                                                    edited Dec 13 '18 at 5:49

























                                                                                                    answered Dec 13 '18 at 3:17









                                                                                                    tsh

                                                                                                    8,43511546




                                                                                                    8,43511546












                                                                                                    • Wow, pretty cool
                                                                                                      – Levitator Imbalance
                                                                                                      Dec 14 '18 at 10:41










                                                                                                    • ...but it throws on 10000, meanwhile my ES6 solution is still works :D Anyway, your solution is very cool)
                                                                                                      – Levitator Imbalance
                                                                                                      Dec 14 '18 at 10:53




















                                                                                                    • Wow, pretty cool
                                                                                                      – Levitator Imbalance
                                                                                                      Dec 14 '18 at 10:41










                                                                                                    • ...but it throws on 10000, meanwhile my ES6 solution is still works :D Anyway, your solution is very cool)
                                                                                                      – Levitator Imbalance
                                                                                                      Dec 14 '18 at 10:53


















                                                                                                    Wow, pretty cool
                                                                                                    – Levitator Imbalance
                                                                                                    Dec 14 '18 at 10:41




                                                                                                    Wow, pretty cool
                                                                                                    – Levitator Imbalance
                                                                                                    Dec 14 '18 at 10:41












                                                                                                    ...but it throws on 10000, meanwhile my ES6 solution is still works :D Anyway, your solution is very cool)
                                                                                                    – Levitator Imbalance
                                                                                                    Dec 14 '18 at 10:53






                                                                                                    ...but it throws on 10000, meanwhile my ES6 solution is still works :D Anyway, your solution is very cool)
                                                                                                    – Levitator Imbalance
                                                                                                    Dec 14 '18 at 10:53













                                                                                                    2















                                                                                                    6502 machine code (C64), 49 bytes



                                                                                                    00 C0 20 9B B7 A2 00 8A 4A A8 90 05 A9 3C 20 D2 FF A9 2D C0 00 F0 06 20 D2 FF 
                                                                                                    88 D0 FA 8A 4A B0 05 A9 3E 20 D2 FF A9 0D 20 D2 FF E8 E4 65 D0 D7 60


                                                                                                    Still quite a bit shorter than BASIC ;) This one has a number range only up to 255 because the natural integer size of the machine has only 8 bits.



                                                                                                    Online demo



                                                                                                    Usage: SYS49152,[n] (e.g. SYS49152,3 for the example from the challenge)



                                                                                                    Commented disassembly:



                                                                                                             00 C0       .WORD $C000        ; load address
                                                                                                    .C:c000 20 9B B7 JSR $B79B ; get unsigned byte from commandline
                                                                                                    .C:c003 A2 00 LDX #$00 ; main loop counter
                                                                                                    .C:c005 .loop:
                                                                                                    .C:c005 8A TXA ; loop counter to accumulator
                                                                                                    .C:c006 4A LSR A ; divide by 2, shift lowest bit to C
                                                                                                    .C:c007 A8 TAY ; result to Y
                                                                                                    .C:c008 90 05 BCC .toright ; C clear -> counter even, skip '<'
                                                                                                    .C:c00a A9 3C LDA #$3C ; load character '<'
                                                                                                    .C:c00c 20 D2 FF JSR $FFD2 ; output character
                                                                                                    .C:c00f .toright:
                                                                                                    .C:c00f A9 2D LDA #$2D ; load character '-'
                                                                                                    .C:c011 C0 00 CPY #$00 ; counter/2 == 0 ? then no dashes
                                                                                                    .C:c013 F0 06 BEQ .skipdashes
                                                                                                    .C:c015 .printdashes:
                                                                                                    .C:c015 20 D2 FF JSR $FFD2 ; output character
                                                                                                    .C:c018 88 DEY ; decrement Y
                                                                                                    .C:c019 D0 FA BNE .printdashes ; not 0 yet -> repeat
                                                                                                    .C:c01b .skipdashes:
                                                                                                    .C:c01b 8A TXA ; loop counter to accumulator
                                                                                                    .C:c01c 4A LSR A ; shift lowest bit to C
                                                                                                    .C:c01d B0 05 BCS .toleft ; C set -> counter odd, skip '>'
                                                                                                    .C:c01f A9 3E LDA #$3E ; load character '>'
                                                                                                    .C:c021 20 D2 FF JSR $FFD2 ; output character
                                                                                                    .C:c024 .toleft:
                                                                                                    .C:c024 A9 0D LDA #$0D ; load newline character
                                                                                                    .C:c026 20 D2 FF JSR $FFD2 ; output character
                                                                                                    .C:c029 E8 INX ; next loop iteration
                                                                                                    .C:c02a E4 65 CPX $65 ; compare to command line argument
                                                                                                    .C:c02c D0 D7 BNE .loop ; not reached yet -> repeat main loop
                                                                                                    .C:c02e 60 RTS ; exit





                                                                                                    share|improve this answer


























                                                                                                      2















                                                                                                      6502 machine code (C64), 49 bytes



                                                                                                      00 C0 20 9B B7 A2 00 8A 4A A8 90 05 A9 3C 20 D2 FF A9 2D C0 00 F0 06 20 D2 FF 
                                                                                                      88 D0 FA 8A 4A B0 05 A9 3E 20 D2 FF A9 0D 20 D2 FF E8 E4 65 D0 D7 60


                                                                                                      Still quite a bit shorter than BASIC ;) This one has a number range only up to 255 because the natural integer size of the machine has only 8 bits.



                                                                                                      Online demo



                                                                                                      Usage: SYS49152,[n] (e.g. SYS49152,3 for the example from the challenge)



                                                                                                      Commented disassembly:



                                                                                                               00 C0       .WORD $C000        ; load address
                                                                                                      .C:c000 20 9B B7 JSR $B79B ; get unsigned byte from commandline
                                                                                                      .C:c003 A2 00 LDX #$00 ; main loop counter
                                                                                                      .C:c005 .loop:
                                                                                                      .C:c005 8A TXA ; loop counter to accumulator
                                                                                                      .C:c006 4A LSR A ; divide by 2, shift lowest bit to C
                                                                                                      .C:c007 A8 TAY ; result to Y
                                                                                                      .C:c008 90 05 BCC .toright ; C clear -> counter even, skip '<'
                                                                                                      .C:c00a A9 3C LDA #$3C ; load character '<'
                                                                                                      .C:c00c 20 D2 FF JSR $FFD2 ; output character
                                                                                                      .C:c00f .toright:
                                                                                                      .C:c00f A9 2D LDA #$2D ; load character '-'
                                                                                                      .C:c011 C0 00 CPY #$00 ; counter/2 == 0 ? then no dashes
                                                                                                      .C:c013 F0 06 BEQ .skipdashes
                                                                                                      .C:c015 .printdashes:
                                                                                                      .C:c015 20 D2 FF JSR $FFD2 ; output character
                                                                                                      .C:c018 88 DEY ; decrement Y
                                                                                                      .C:c019 D0 FA BNE .printdashes ; not 0 yet -> repeat
                                                                                                      .C:c01b .skipdashes:
                                                                                                      .C:c01b 8A TXA ; loop counter to accumulator
                                                                                                      .C:c01c 4A LSR A ; shift lowest bit to C
                                                                                                      .C:c01d B0 05 BCS .toleft ; C set -> counter odd, skip '>'
                                                                                                      .C:c01f A9 3E LDA #$3E ; load character '>'
                                                                                                      .C:c021 20 D2 FF JSR $FFD2 ; output character
                                                                                                      .C:c024 .toleft:
                                                                                                      .C:c024 A9 0D LDA #$0D ; load newline character
                                                                                                      .C:c026 20 D2 FF JSR $FFD2 ; output character
                                                                                                      .C:c029 E8 INX ; next loop iteration
                                                                                                      .C:c02a E4 65 CPX $65 ; compare to command line argument
                                                                                                      .C:c02c D0 D7 BNE .loop ; not reached yet -> repeat main loop
                                                                                                      .C:c02e 60 RTS ; exit





                                                                                                      share|improve this answer
























                                                                                                        2












                                                                                                        2








                                                                                                        2







                                                                                                        6502 machine code (C64), 49 bytes



                                                                                                        00 C0 20 9B B7 A2 00 8A 4A A8 90 05 A9 3C 20 D2 FF A9 2D C0 00 F0 06 20 D2 FF 
                                                                                                        88 D0 FA 8A 4A B0 05 A9 3E 20 D2 FF A9 0D 20 D2 FF E8 E4 65 D0 D7 60


                                                                                                        Still quite a bit shorter than BASIC ;) This one has a number range only up to 255 because the natural integer size of the machine has only 8 bits.



                                                                                                        Online demo



                                                                                                        Usage: SYS49152,[n] (e.g. SYS49152,3 for the example from the challenge)



                                                                                                        Commented disassembly:



                                                                                                                 00 C0       .WORD $C000        ; load address
                                                                                                        .C:c000 20 9B B7 JSR $B79B ; get unsigned byte from commandline
                                                                                                        .C:c003 A2 00 LDX #$00 ; main loop counter
                                                                                                        .C:c005 .loop:
                                                                                                        .C:c005 8A TXA ; loop counter to accumulator
                                                                                                        .C:c006 4A LSR A ; divide by 2, shift lowest bit to C
                                                                                                        .C:c007 A8 TAY ; result to Y
                                                                                                        .C:c008 90 05 BCC .toright ; C clear -> counter even, skip '<'
                                                                                                        .C:c00a A9 3C LDA #$3C ; load character '<'
                                                                                                        .C:c00c 20 D2 FF JSR $FFD2 ; output character
                                                                                                        .C:c00f .toright:
                                                                                                        .C:c00f A9 2D LDA #$2D ; load character '-'
                                                                                                        .C:c011 C0 00 CPY #$00 ; counter/2 == 0 ? then no dashes
                                                                                                        .C:c013 F0 06 BEQ .skipdashes
                                                                                                        .C:c015 .printdashes:
                                                                                                        .C:c015 20 D2 FF JSR $FFD2 ; output character
                                                                                                        .C:c018 88 DEY ; decrement Y
                                                                                                        .C:c019 D0 FA BNE .printdashes ; not 0 yet -> repeat
                                                                                                        .C:c01b .skipdashes:
                                                                                                        .C:c01b 8A TXA ; loop counter to accumulator
                                                                                                        .C:c01c 4A LSR A ; shift lowest bit to C
                                                                                                        .C:c01d B0 05 BCS .toleft ; C set -> counter odd, skip '>'
                                                                                                        .C:c01f A9 3E LDA #$3E ; load character '>'
                                                                                                        .C:c021 20 D2 FF JSR $FFD2 ; output character
                                                                                                        .C:c024 .toleft:
                                                                                                        .C:c024 A9 0D LDA #$0D ; load newline character
                                                                                                        .C:c026 20 D2 FF JSR $FFD2 ; output character
                                                                                                        .C:c029 E8 INX ; next loop iteration
                                                                                                        .C:c02a E4 65 CPX $65 ; compare to command line argument
                                                                                                        .C:c02c D0 D7 BNE .loop ; not reached yet -> repeat main loop
                                                                                                        .C:c02e 60 RTS ; exit





                                                                                                        share|improve this answer













                                                                                                        6502 machine code (C64), 49 bytes



                                                                                                        00 C0 20 9B B7 A2 00 8A 4A A8 90 05 A9 3C 20 D2 FF A9 2D C0 00 F0 06 20 D2 FF 
                                                                                                        88 D0 FA 8A 4A B0 05 A9 3E 20 D2 FF A9 0D 20 D2 FF E8 E4 65 D0 D7 60


                                                                                                        Still quite a bit shorter than BASIC ;) This one has a number range only up to 255 because the natural integer size of the machine has only 8 bits.



                                                                                                        Online demo



                                                                                                        Usage: SYS49152,[n] (e.g. SYS49152,3 for the example from the challenge)



                                                                                                        Commented disassembly:



                                                                                                                 00 C0       .WORD $C000        ; load address
                                                                                                        .C:c000 20 9B B7 JSR $B79B ; get unsigned byte from commandline
                                                                                                        .C:c003 A2 00 LDX #$00 ; main loop counter
                                                                                                        .C:c005 .loop:
                                                                                                        .C:c005 8A TXA ; loop counter to accumulator
                                                                                                        .C:c006 4A LSR A ; divide by 2, shift lowest bit to C
                                                                                                        .C:c007 A8 TAY ; result to Y
                                                                                                        .C:c008 90 05 BCC .toright ; C clear -> counter even, skip '<'
                                                                                                        .C:c00a A9 3C LDA #$3C ; load character '<'
                                                                                                        .C:c00c 20 D2 FF JSR $FFD2 ; output character
                                                                                                        .C:c00f .toright:
                                                                                                        .C:c00f A9 2D LDA #$2D ; load character '-'
                                                                                                        .C:c011 C0 00 CPY #$00 ; counter/2 == 0 ? then no dashes
                                                                                                        .C:c013 F0 06 BEQ .skipdashes
                                                                                                        .C:c015 .printdashes:
                                                                                                        .C:c015 20 D2 FF JSR $FFD2 ; output character
                                                                                                        .C:c018 88 DEY ; decrement Y
                                                                                                        .C:c019 D0 FA BNE .printdashes ; not 0 yet -> repeat
                                                                                                        .C:c01b .skipdashes:
                                                                                                        .C:c01b 8A TXA ; loop counter to accumulator
                                                                                                        .C:c01c 4A LSR A ; shift lowest bit to C
                                                                                                        .C:c01d B0 05 BCS .toleft ; C set -> counter odd, skip '>'
                                                                                                        .C:c01f A9 3E LDA #$3E ; load character '>'
                                                                                                        .C:c021 20 D2 FF JSR $FFD2 ; output character
                                                                                                        .C:c024 .toleft:
                                                                                                        .C:c024 A9 0D LDA #$0D ; load newline character
                                                                                                        .C:c026 20 D2 FF JSR $FFD2 ; output character
                                                                                                        .C:c029 E8 INX ; next loop iteration
                                                                                                        .C:c02a E4 65 CPX $65 ; compare to command line argument
                                                                                                        .C:c02c D0 D7 BNE .loop ; not reached yet -> repeat main loop
                                                                                                        .C:c02e 60 RTS ; exit






                                                                                                        share|improve this answer












                                                                                                        share|improve this answer



                                                                                                        share|improve this answer










                                                                                                        answered Dec 12 '18 at 21:59









                                                                                                        Felix Palmen

                                                                                                        3,341525




                                                                                                        3,341525























                                                                                                            2















                                                                                                            Perl 6, 39 bytes





                                                                                                            {map {'<'x$_%2~'-'x$_/2~'>'x$_%%2},^$_}


                                                                                                            Try it online!



                                                                                                            Anonymous code block that returns a list of lines.






                                                                                                            share|improve this answer


























                                                                                                              2















                                                                                                              Perl 6, 39 bytes





                                                                                                              {map {'<'x$_%2~'-'x$_/2~'>'x$_%%2},^$_}


                                                                                                              Try it online!



                                                                                                              Anonymous code block that returns a list of lines.






                                                                                                              share|improve this answer
























                                                                                                                2












                                                                                                                2








                                                                                                                2







                                                                                                                Perl 6, 39 bytes





                                                                                                                {map {'<'x$_%2~'-'x$_/2~'>'x$_%%2},^$_}


                                                                                                                Try it online!



                                                                                                                Anonymous code block that returns a list of lines.






                                                                                                                share|improve this answer













                                                                                                                Perl 6, 39 bytes





                                                                                                                {map {'<'x$_%2~'-'x$_/2~'>'x$_%%2},^$_}


                                                                                                                Try it online!



                                                                                                                Anonymous code block that returns a list of lines.







                                                                                                                share|improve this answer












                                                                                                                share|improve this answer



                                                                                                                share|improve this answer










                                                                                                                answered Dec 13 '18 at 0:02









                                                                                                                Jo King

                                                                                                                20.7k247109




                                                                                                                20.7k247109























                                                                                                                    2















                                                                                                                    K (ngn/k), 31 29 bytes



                                                                                                                    {"<->"x#2,x{(1=*x)_1,2-|x}}


                                                                                                                    Try it online!



                                                                                                                    first we generate lists with 0 instead of "<", 1 instead of "-", and 2 instead of ">":



                                                                                                                    { } function with argument x



                                                                                                                    x{...} apply the inner function x times, starting with an initial value of 0 and preserving intermediate results



                                                                                                                    |x reverse



                                                                                                                    2- replace 0 with 2 and vice versa, keep the 1s as they are



                                                                                                                    1, prepend a 1



                                                                                                                    (1=*x)_ is the first of x equal to 1? if yes, drop one element, otherwise drop 0 elements (do nothing)



                                                                                                                    2, prepend a 2 for the initial ">" arrow



                                                                                                                    x# we have a little too many lists, so take only the first x of them



                                                                                                                    "<->" use the lists' elements (0/1/2) as indices in this string






                                                                                                                    share|improve this answer























                                                                                                                    • I would like to ask for an explanation (I haven't started learning K yet, I don't know which version to start with...)
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 13 '18 at 12:14






                                                                                                                    • 1




                                                                                                                      @GalenIvanov i tried to write an explanation, i hope it makes sense. thanks for your interest in my favourite language :) there are multiple implementations with different advantages and disadvantages (kx's original, kona, oK and i'm working on my own). would you like to join the apl chat room so i can give you more details?
                                                                                                                      – ngn
                                                                                                                      Dec 13 '18 at 12:44












                                                                                                                    • Thank you, I'm already there
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 13 '18 at 12:49
















                                                                                                                    2















                                                                                                                    K (ngn/k), 31 29 bytes



                                                                                                                    {"<->"x#2,x{(1=*x)_1,2-|x}}


                                                                                                                    Try it online!



                                                                                                                    first we generate lists with 0 instead of "<", 1 instead of "-", and 2 instead of ">":



                                                                                                                    { } function with argument x



                                                                                                                    x{...} apply the inner function x times, starting with an initial value of 0 and preserving intermediate results



                                                                                                                    |x reverse



                                                                                                                    2- replace 0 with 2 and vice versa, keep the 1s as they are



                                                                                                                    1, prepend a 1



                                                                                                                    (1=*x)_ is the first of x equal to 1? if yes, drop one element, otherwise drop 0 elements (do nothing)



                                                                                                                    2, prepend a 2 for the initial ">" arrow



                                                                                                                    x# we have a little too many lists, so take only the first x of them



                                                                                                                    "<->" use the lists' elements (0/1/2) as indices in this string






                                                                                                                    share|improve this answer























                                                                                                                    • I would like to ask for an explanation (I haven't started learning K yet, I don't know which version to start with...)
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 13 '18 at 12:14






                                                                                                                    • 1




                                                                                                                      @GalenIvanov i tried to write an explanation, i hope it makes sense. thanks for your interest in my favourite language :) there are multiple implementations with different advantages and disadvantages (kx's original, kona, oK and i'm working on my own). would you like to join the apl chat room so i can give you more details?
                                                                                                                      – ngn
                                                                                                                      Dec 13 '18 at 12:44












                                                                                                                    • Thank you, I'm already there
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 13 '18 at 12:49














                                                                                                                    2












                                                                                                                    2








                                                                                                                    2







                                                                                                                    K (ngn/k), 31 29 bytes



                                                                                                                    {"<->"x#2,x{(1=*x)_1,2-|x}}


                                                                                                                    Try it online!



                                                                                                                    first we generate lists with 0 instead of "<", 1 instead of "-", and 2 instead of ">":



                                                                                                                    { } function with argument x



                                                                                                                    x{...} apply the inner function x times, starting with an initial value of 0 and preserving intermediate results



                                                                                                                    |x reverse



                                                                                                                    2- replace 0 with 2 and vice versa, keep the 1s as they are



                                                                                                                    1, prepend a 1



                                                                                                                    (1=*x)_ is the first of x equal to 1? if yes, drop one element, otherwise drop 0 elements (do nothing)



                                                                                                                    2, prepend a 2 for the initial ">" arrow



                                                                                                                    x# we have a little too many lists, so take only the first x of them



                                                                                                                    "<->" use the lists' elements (0/1/2) as indices in this string






                                                                                                                    share|improve this answer















                                                                                                                    K (ngn/k), 31 29 bytes



                                                                                                                    {"<->"x#2,x{(1=*x)_1,2-|x}}


                                                                                                                    Try it online!



                                                                                                                    first we generate lists with 0 instead of "<", 1 instead of "-", and 2 instead of ">":



                                                                                                                    { } function with argument x



                                                                                                                    x{...} apply the inner function x times, starting with an initial value of 0 and preserving intermediate results



                                                                                                                    |x reverse



                                                                                                                    2- replace 0 with 2 and vice versa, keep the 1s as they are



                                                                                                                    1, prepend a 1



                                                                                                                    (1=*x)_ is the first of x equal to 1? if yes, drop one element, otherwise drop 0 elements (do nothing)



                                                                                                                    2, prepend a 2 for the initial ">" arrow



                                                                                                                    x# we have a little too many lists, so take only the first x of them



                                                                                                                    "<->" use the lists' elements (0/1/2) as indices in this string







                                                                                                                    share|improve this answer














                                                                                                                    share|improve this answer



                                                                                                                    share|improve this answer








                                                                                                                    edited Dec 13 '18 at 12:29

























                                                                                                                    answered Dec 13 '18 at 11:45









                                                                                                                    ngn

                                                                                                                    6,94112559




                                                                                                                    6,94112559












                                                                                                                    • I would like to ask for an explanation (I haven't started learning K yet, I don't know which version to start with...)
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 13 '18 at 12:14






                                                                                                                    • 1




                                                                                                                      @GalenIvanov i tried to write an explanation, i hope it makes sense. thanks for your interest in my favourite language :) there are multiple implementations with different advantages and disadvantages (kx's original, kona, oK and i'm working on my own). would you like to join the apl chat room so i can give you more details?
                                                                                                                      – ngn
                                                                                                                      Dec 13 '18 at 12:44












                                                                                                                    • Thank you, I'm already there
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 13 '18 at 12:49


















                                                                                                                    • I would like to ask for an explanation (I haven't started learning K yet, I don't know which version to start with...)
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 13 '18 at 12:14






                                                                                                                    • 1




                                                                                                                      @GalenIvanov i tried to write an explanation, i hope it makes sense. thanks for your interest in my favourite language :) there are multiple implementations with different advantages and disadvantages (kx's original, kona, oK and i'm working on my own). would you like to join the apl chat room so i can give you more details?
                                                                                                                      – ngn
                                                                                                                      Dec 13 '18 at 12:44












                                                                                                                    • Thank you, I'm already there
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 13 '18 at 12:49
















                                                                                                                    I would like to ask for an explanation (I haven't started learning K yet, I don't know which version to start with...)
                                                                                                                    – Galen Ivanov
                                                                                                                    Dec 13 '18 at 12:14




                                                                                                                    I would like to ask for an explanation (I haven't started learning K yet, I don't know which version to start with...)
                                                                                                                    – Galen Ivanov
                                                                                                                    Dec 13 '18 at 12:14




                                                                                                                    1




                                                                                                                    1




                                                                                                                    @GalenIvanov i tried to write an explanation, i hope it makes sense. thanks for your interest in my favourite language :) there are multiple implementations with different advantages and disadvantages (kx's original, kona, oK and i'm working on my own). would you like to join the apl chat room so i can give you more details?
                                                                                                                    – ngn
                                                                                                                    Dec 13 '18 at 12:44






                                                                                                                    @GalenIvanov i tried to write an explanation, i hope it makes sense. thanks for your interest in my favourite language :) there are multiple implementations with different advantages and disadvantages (kx's original, kona, oK and i'm working on my own). would you like to join the apl chat room so i can give you more details?
                                                                                                                    – ngn
                                                                                                                    Dec 13 '18 at 12:44














                                                                                                                    Thank you, I'm already there
                                                                                                                    – Galen Ivanov
                                                                                                                    Dec 13 '18 at 12:49




                                                                                                                    Thank you, I'm already there
                                                                                                                    – Galen Ivanov
                                                                                                                    Dec 13 '18 at 12:49











                                                                                                                    2















                                                                                                                    05AB1E, 23 20 bytes



                                                                                                                    FNÉD„><è'-N;∍«s_iR},


                                                                                                                    Try it online!



                                                                                                                    First time using 05AB1E or any other golfing language for that matter. Any ideas welcome.



                                                                                                                    -3 from Kevin Cruijssen






                                                                                                                    share|improve this answer



















                                                                                                                    • 1




                                                                                                                      Welcome to the world of 05AB1E, and nice first answer. +1 from me. :) "><" can be „>< to save a byte. There are builtins for 1, 2, and 3 char strings, being ', , and respectively. Here is a 18 bytes alternative I came up with, but perhaps it could be golfed a bit more. If you haven't seen it yet, we have a tips for golfing in 05AB1E page, and also feel free to ask anything in the chat.
                                                                                                                      – Kevin Cruijssen
                                                                                                                      Dec 13 '18 at 8:54








                                                                                                                    • 1




                                                                                                                      @KevinCruijssen Thanks so much for your ideas. I don't feel right just using your code, as it feels fairly different from mine, but I did use the idea of modulo 2 as checking for if a number is odd. I also use the two char string idea. I would not mind at all if you posted the 18 byte version on your own.
                                                                                                                      – nedla2004
                                                                                                                      Dec 13 '18 at 23:09










                                                                                                                    • I've posted my answer in that case. :)
                                                                                                                      – Kevin Cruijssen
                                                                                                                      Dec 14 '18 at 8:31
















                                                                                                                    2















                                                                                                                    05AB1E, 23 20 bytes



                                                                                                                    FNÉD„><è'-N;∍«s_iR},


                                                                                                                    Try it online!



                                                                                                                    First time using 05AB1E or any other golfing language for that matter. Any ideas welcome.



                                                                                                                    -3 from Kevin Cruijssen






                                                                                                                    share|improve this answer



















                                                                                                                    • 1




                                                                                                                      Welcome to the world of 05AB1E, and nice first answer. +1 from me. :) "><" can be „>< to save a byte. There are builtins for 1, 2, and 3 char strings, being ', , and respectively. Here is a 18 bytes alternative I came up with, but perhaps it could be golfed a bit more. If you haven't seen it yet, we have a tips for golfing in 05AB1E page, and also feel free to ask anything in the chat.
                                                                                                                      – Kevin Cruijssen
                                                                                                                      Dec 13 '18 at 8:54








                                                                                                                    • 1




                                                                                                                      @KevinCruijssen Thanks so much for your ideas. I don't feel right just using your code, as it feels fairly different from mine, but I did use the idea of modulo 2 as checking for if a number is odd. I also use the two char string idea. I would not mind at all if you posted the 18 byte version on your own.
                                                                                                                      – nedla2004
                                                                                                                      Dec 13 '18 at 23:09










                                                                                                                    • I've posted my answer in that case. :)
                                                                                                                      – Kevin Cruijssen
                                                                                                                      Dec 14 '18 at 8:31














                                                                                                                    2












                                                                                                                    2








                                                                                                                    2







                                                                                                                    05AB1E, 23 20 bytes



                                                                                                                    FNÉD„><è'-N;∍«s_iR},


                                                                                                                    Try it online!



                                                                                                                    First time using 05AB1E or any other golfing language for that matter. Any ideas welcome.



                                                                                                                    -3 from Kevin Cruijssen






                                                                                                                    share|improve this answer















                                                                                                                    05AB1E, 23 20 bytes



                                                                                                                    FNÉD„><è'-N;∍«s_iR},


                                                                                                                    Try it online!



                                                                                                                    First time using 05AB1E or any other golfing language for that matter. Any ideas welcome.



                                                                                                                    -3 from Kevin Cruijssen







                                                                                                                    share|improve this answer














                                                                                                                    share|improve this answer



                                                                                                                    share|improve this answer








                                                                                                                    edited Dec 13 '18 at 23:05

























                                                                                                                    answered Dec 12 '18 at 19:55









                                                                                                                    nedla2004

                                                                                                                    4011410




                                                                                                                    4011410








                                                                                                                    • 1




                                                                                                                      Welcome to the world of 05AB1E, and nice first answer. +1 from me. :) "><" can be „>< to save a byte. There are builtins for 1, 2, and 3 char strings, being ', , and respectively. Here is a 18 bytes alternative I came up with, but perhaps it could be golfed a bit more. If you haven't seen it yet, we have a tips for golfing in 05AB1E page, and also feel free to ask anything in the chat.
                                                                                                                      – Kevin Cruijssen
                                                                                                                      Dec 13 '18 at 8:54








                                                                                                                    • 1




                                                                                                                      @KevinCruijssen Thanks so much for your ideas. I don't feel right just using your code, as it feels fairly different from mine, but I did use the idea of modulo 2 as checking for if a number is odd. I also use the two char string idea. I would not mind at all if you posted the 18 byte version on your own.
                                                                                                                      – nedla2004
                                                                                                                      Dec 13 '18 at 23:09










                                                                                                                    • I've posted my answer in that case. :)
                                                                                                                      – Kevin Cruijssen
                                                                                                                      Dec 14 '18 at 8:31














                                                                                                                    • 1




                                                                                                                      Welcome to the world of 05AB1E, and nice first answer. +1 from me. :) "><" can be „>< to save a byte. There are builtins for 1, 2, and 3 char strings, being ', , and respectively. Here is a 18 bytes alternative I came up with, but perhaps it could be golfed a bit more. If you haven't seen it yet, we have a tips for golfing in 05AB1E page, and also feel free to ask anything in the chat.
                                                                                                                      – Kevin Cruijssen
                                                                                                                      Dec 13 '18 at 8:54








                                                                                                                    • 1




                                                                                                                      @KevinCruijssen Thanks so much for your ideas. I don't feel right just using your code, as it feels fairly different from mine, but I did use the idea of modulo 2 as checking for if a number is odd. I also use the two char string idea. I would not mind at all if you posted the 18 byte version on your own.
                                                                                                                      – nedla2004
                                                                                                                      Dec 13 '18 at 23:09










                                                                                                                    • I've posted my answer in that case. :)
                                                                                                                      – Kevin Cruijssen
                                                                                                                      Dec 14 '18 at 8:31








                                                                                                                    1




                                                                                                                    1




                                                                                                                    Welcome to the world of 05AB1E, and nice first answer. +1 from me. :) "><" can be „>< to save a byte. There are builtins for 1, 2, and 3 char strings, being ', , and respectively. Here is a 18 bytes alternative I came up with, but perhaps it could be golfed a bit more. If you haven't seen it yet, we have a tips for golfing in 05AB1E page, and also feel free to ask anything in the chat.
                                                                                                                    – Kevin Cruijssen
                                                                                                                    Dec 13 '18 at 8:54






                                                                                                                    Welcome to the world of 05AB1E, and nice first answer. +1 from me. :) "><" can be „>< to save a byte. There are builtins for 1, 2, and 3 char strings, being ', , and respectively. Here is a 18 bytes alternative I came up with, but perhaps it could be golfed a bit more. If you haven't seen it yet, we have a tips for golfing in 05AB1E page, and also feel free to ask anything in the chat.
                                                                                                                    – Kevin Cruijssen
                                                                                                                    Dec 13 '18 at 8:54






                                                                                                                    1




                                                                                                                    1




                                                                                                                    @KevinCruijssen Thanks so much for your ideas. I don't feel right just using your code, as it feels fairly different from mine, but I did use the idea of modulo 2 as checking for if a number is odd. I also use the two char string idea. I would not mind at all if you posted the 18 byte version on your own.
                                                                                                                    – nedla2004
                                                                                                                    Dec 13 '18 at 23:09




                                                                                                                    @KevinCruijssen Thanks so much for your ideas. I don't feel right just using your code, as it feels fairly different from mine, but I did use the idea of modulo 2 as checking for if a number is odd. I also use the two char string idea. I would not mind at all if you posted the 18 byte version on your own.
                                                                                                                    – nedla2004
                                                                                                                    Dec 13 '18 at 23:09












                                                                                                                    I've posted my answer in that case. :)
                                                                                                                    – Kevin Cruijssen
                                                                                                                    Dec 14 '18 at 8:31




                                                                                                                    I've posted my answer in that case. :)
                                                                                                                    – Kevin Cruijssen
                                                                                                                    Dec 14 '18 at 8:31











                                                                                                                    2














                                                                                                                    ES6, 96 82 79 70 bytes



                                                                                                                    Try it online! (Thanks to @Oliver)



                                                                                                                    n=>[...Array(n)].map((_,i)=>(i%2?"<":"")+"-".repeat(i/2)+(i%2?"":">"))





                                                                                                                    share|improve this answer



















                                                                                                                    • 1




                                                                                                                      Welcome to PPCG! By default, taking input as a variable is disallowed; you have to either make it a function (just stick a i=> in front of your code!) or from a command-line argument or STDIN or something.
                                                                                                                      – HyperNeutrino
                                                                                                                      Dec 14 '18 at 14:40










                                                                                                                    • @HyperNeutrino okay, edited answer. However, the most voted answer contains only the body of the function, but ok. Anyway I'm outsider)
                                                                                                                      – Levitator Imbalance
                                                                                                                      Dec 14 '18 at 15:09












                                                                                                                    • Can you link it? I don't think any of them are invalid, at least not the top few.
                                                                                                                      – HyperNeutrino
                                                                                                                      Dec 14 '18 at 15:16






                                                                                                                    • 1




                                                                                                                      A few more bytes: Try it online
                                                                                                                      – Oliver
                                                                                                                      Dec 14 '18 at 16:15






                                                                                                                    • 1




                                                                                                                      A few more bytes if you re-arrange that last ternary operator and remove the center parenthesis: Try it online
                                                                                                                      – Oliver
                                                                                                                      Dec 14 '18 at 16:59
















                                                                                                                    2














                                                                                                                    ES6, 96 82 79 70 bytes



                                                                                                                    Try it online! (Thanks to @Oliver)



                                                                                                                    n=>[...Array(n)].map((_,i)=>(i%2?"<":"")+"-".repeat(i/2)+(i%2?"":">"))





                                                                                                                    share|improve this answer



















                                                                                                                    • 1




                                                                                                                      Welcome to PPCG! By default, taking input as a variable is disallowed; you have to either make it a function (just stick a i=> in front of your code!) or from a command-line argument or STDIN or something.
                                                                                                                      – HyperNeutrino
                                                                                                                      Dec 14 '18 at 14:40










                                                                                                                    • @HyperNeutrino okay, edited answer. However, the most voted answer contains only the body of the function, but ok. Anyway I'm outsider)
                                                                                                                      – Levitator Imbalance
                                                                                                                      Dec 14 '18 at 15:09












                                                                                                                    • Can you link it? I don't think any of them are invalid, at least not the top few.
                                                                                                                      – HyperNeutrino
                                                                                                                      Dec 14 '18 at 15:16






                                                                                                                    • 1




                                                                                                                      A few more bytes: Try it online
                                                                                                                      – Oliver
                                                                                                                      Dec 14 '18 at 16:15






                                                                                                                    • 1




                                                                                                                      A few more bytes if you re-arrange that last ternary operator and remove the center parenthesis: Try it online
                                                                                                                      – Oliver
                                                                                                                      Dec 14 '18 at 16:59














                                                                                                                    2












                                                                                                                    2








                                                                                                                    2






                                                                                                                    ES6, 96 82 79 70 bytes



                                                                                                                    Try it online! (Thanks to @Oliver)



                                                                                                                    n=>[...Array(n)].map((_,i)=>(i%2?"<":"")+"-".repeat(i/2)+(i%2?"":">"))





                                                                                                                    share|improve this answer














                                                                                                                    ES6, 96 82 79 70 bytes



                                                                                                                    Try it online! (Thanks to @Oliver)



                                                                                                                    n=>[...Array(n)].map((_,i)=>(i%2?"<":"")+"-".repeat(i/2)+(i%2?"":">"))






                                                                                                                    share|improve this answer














                                                                                                                    share|improve this answer



                                                                                                                    share|improve this answer








                                                                                                                    edited Dec 14 '18 at 17:02

























                                                                                                                    answered Dec 14 '18 at 10:35









                                                                                                                    Levitator Imbalance

                                                                                                                    1213




                                                                                                                    1213








                                                                                                                    • 1




                                                                                                                      Welcome to PPCG! By default, taking input as a variable is disallowed; you have to either make it a function (just stick a i=> in front of your code!) or from a command-line argument or STDIN or something.
                                                                                                                      – HyperNeutrino
                                                                                                                      Dec 14 '18 at 14:40










                                                                                                                    • @HyperNeutrino okay, edited answer. However, the most voted answer contains only the body of the function, but ok. Anyway I'm outsider)
                                                                                                                      – Levitator Imbalance
                                                                                                                      Dec 14 '18 at 15:09












                                                                                                                    • Can you link it? I don't think any of them are invalid, at least not the top few.
                                                                                                                      – HyperNeutrino
                                                                                                                      Dec 14 '18 at 15:16






                                                                                                                    • 1




                                                                                                                      A few more bytes: Try it online
                                                                                                                      – Oliver
                                                                                                                      Dec 14 '18 at 16:15






                                                                                                                    • 1




                                                                                                                      A few more bytes if you re-arrange that last ternary operator and remove the center parenthesis: Try it online
                                                                                                                      – Oliver
                                                                                                                      Dec 14 '18 at 16:59














                                                                                                                    • 1




                                                                                                                      Welcome to PPCG! By default, taking input as a variable is disallowed; you have to either make it a function (just stick a i=> in front of your code!) or from a command-line argument or STDIN or something.
                                                                                                                      – HyperNeutrino
                                                                                                                      Dec 14 '18 at 14:40










                                                                                                                    • @HyperNeutrino okay, edited answer. However, the most voted answer contains only the body of the function, but ok. Anyway I'm outsider)
                                                                                                                      – Levitator Imbalance
                                                                                                                      Dec 14 '18 at 15:09












                                                                                                                    • Can you link it? I don't think any of them are invalid, at least not the top few.
                                                                                                                      – HyperNeutrino
                                                                                                                      Dec 14 '18 at 15:16






                                                                                                                    • 1




                                                                                                                      A few more bytes: Try it online
                                                                                                                      – Oliver
                                                                                                                      Dec 14 '18 at 16:15






                                                                                                                    • 1




                                                                                                                      A few more bytes if you re-arrange that last ternary operator and remove the center parenthesis: Try it online
                                                                                                                      – Oliver
                                                                                                                      Dec 14 '18 at 16:59








                                                                                                                    1




                                                                                                                    1




                                                                                                                    Welcome to PPCG! By default, taking input as a variable is disallowed; you have to either make it a function (just stick a i=> in front of your code!) or from a command-line argument or STDIN or something.
                                                                                                                    – HyperNeutrino
                                                                                                                    Dec 14 '18 at 14:40




                                                                                                                    Welcome to PPCG! By default, taking input as a variable is disallowed; you have to either make it a function (just stick a i=> in front of your code!) or from a command-line argument or STDIN or something.
                                                                                                                    – HyperNeutrino
                                                                                                                    Dec 14 '18 at 14:40












                                                                                                                    @HyperNeutrino okay, edited answer. However, the most voted answer contains only the body of the function, but ok. Anyway I'm outsider)
                                                                                                                    – Levitator Imbalance
                                                                                                                    Dec 14 '18 at 15:09






                                                                                                                    @HyperNeutrino okay, edited answer. However, the most voted answer contains only the body of the function, but ok. Anyway I'm outsider)
                                                                                                                    – Levitator Imbalance
                                                                                                                    Dec 14 '18 at 15:09














                                                                                                                    Can you link it? I don't think any of them are invalid, at least not the top few.
                                                                                                                    – HyperNeutrino
                                                                                                                    Dec 14 '18 at 15:16




                                                                                                                    Can you link it? I don't think any of them are invalid, at least not the top few.
                                                                                                                    – HyperNeutrino
                                                                                                                    Dec 14 '18 at 15:16




                                                                                                                    1




                                                                                                                    1




                                                                                                                    A few more bytes: Try it online
                                                                                                                    – Oliver
                                                                                                                    Dec 14 '18 at 16:15




                                                                                                                    A few more bytes: Try it online
                                                                                                                    – Oliver
                                                                                                                    Dec 14 '18 at 16:15




                                                                                                                    1




                                                                                                                    1




                                                                                                                    A few more bytes if you re-arrange that last ternary operator and remove the center parenthesis: Try it online
                                                                                                                    – Oliver
                                                                                                                    Dec 14 '18 at 16:59




                                                                                                                    A few more bytes if you re-arrange that last ternary operator and remove the center parenthesis: Try it online
                                                                                                                    – Oliver
                                                                                                                    Dec 14 '18 at 16:59











                                                                                                                    2















                                                                                                                    Red, 109 108 bytes



                                                                                                                    -1 byte thanks to NK1406



                                                                                                                    func[n][repeat i n[print reduce[pick[pad/with pad/left/with]k: i% 2 + 1
                                                                                                                    pick copy"<>"k i / 2 + k - 1 #"-"]]]


                                                                                                                    Try it online!






                                                                                                                    share|improve this answer



















                                                                                                                    • 1




                                                                                                                      -1 for removing a space
                                                                                                                      – NK1406
                                                                                                                      Dec 15 '18 at 18:28










                                                                                                                    • @NK1406 Thank you! I didn't know this is valid.
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 15 '18 at 19:01
















                                                                                                                    2















                                                                                                                    Red, 109 108 bytes



                                                                                                                    -1 byte thanks to NK1406



                                                                                                                    func[n][repeat i n[print reduce[pick[pad/with pad/left/with]k: i% 2 + 1
                                                                                                                    pick copy"<>"k i / 2 + k - 1 #"-"]]]


                                                                                                                    Try it online!






                                                                                                                    share|improve this answer



















                                                                                                                    • 1




                                                                                                                      -1 for removing a space
                                                                                                                      – NK1406
                                                                                                                      Dec 15 '18 at 18:28










                                                                                                                    • @NK1406 Thank you! I didn't know this is valid.
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 15 '18 at 19:01














                                                                                                                    2












                                                                                                                    2








                                                                                                                    2







                                                                                                                    Red, 109 108 bytes



                                                                                                                    -1 byte thanks to NK1406



                                                                                                                    func[n][repeat i n[print reduce[pick[pad/with pad/left/with]k: i% 2 + 1
                                                                                                                    pick copy"<>"k i / 2 + k - 1 #"-"]]]


                                                                                                                    Try it online!






                                                                                                                    share|improve this answer















                                                                                                                    Red, 109 108 bytes



                                                                                                                    -1 byte thanks to NK1406



                                                                                                                    func[n][repeat i n[print reduce[pick[pad/with pad/left/with]k: i% 2 + 1
                                                                                                                    pick copy"<>"k i / 2 + k - 1 #"-"]]]


                                                                                                                    Try it online!







                                                                                                                    share|improve this answer














                                                                                                                    share|improve this answer



                                                                                                                    share|improve this answer








                                                                                                                    edited Dec 15 '18 at 19:00

























                                                                                                                    answered Dec 13 '18 at 9:18









                                                                                                                    Galen Ivanov

                                                                                                                    6,33711032




                                                                                                                    6,33711032








                                                                                                                    • 1




                                                                                                                      -1 for removing a space
                                                                                                                      – NK1406
                                                                                                                      Dec 15 '18 at 18:28










                                                                                                                    • @NK1406 Thank you! I didn't know this is valid.
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 15 '18 at 19:01














                                                                                                                    • 1




                                                                                                                      -1 for removing a space
                                                                                                                      – NK1406
                                                                                                                      Dec 15 '18 at 18:28










                                                                                                                    • @NK1406 Thank you! I didn't know this is valid.
                                                                                                                      – Galen Ivanov
                                                                                                                      Dec 15 '18 at 19:01








                                                                                                                    1




                                                                                                                    1




                                                                                                                    -1 for removing a space
                                                                                                                    – NK1406
                                                                                                                    Dec 15 '18 at 18:28




                                                                                                                    -1 for removing a space
                                                                                                                    – NK1406
                                                                                                                    Dec 15 '18 at 18:28












                                                                                                                    @NK1406 Thank you! I didn't know this is valid.
                                                                                                                    – Galen Ivanov
                                                                                                                    Dec 15 '18 at 19:01




                                                                                                                    @NK1406 Thank you! I didn't know this is valid.
                                                                                                                    – Galen Ivanov
                                                                                                                    Dec 15 '18 at 19:01











                                                                                                                    2















                                                                                                                    C (gcc), 127 95 + 26 = 121 bytes





                                                                                                                    i,j;f(x){for(i=0;i<x;putchar(10),i+=2){for(j=0;E;printf(">n%c",x-i-1?60:9);for(j=0;x-i-1&&E;}}


                                                                                                                    Try it online!



                                                                                                                    Compile with -DE=j<i/2;++j)putchar(45)



                                                                                                                    -6 bytes from Logern



                                                                                                                    Yay mismatched parentheses!



                                                                                                                    Ungolfed:





                                                                                                                    void f(int x) {
                                                                                                                    for (int i = 0; i < x; i += 2) {
                                                                                                                    for (int j = 0; j < i/2; ++j) {
                                                                                                                    printf("-");
                                                                                                                    }
                                                                                                                    printf(">n");
                                                                                                                    if (x - i - 1) { // Test for last loop: only print <-- if x is even
                                                                                                                    printf("<");
                                                                                                                    for (int j = 0; j < i/2; ++j) {
                                                                                                                    printf("-");
                                                                                                                    }
                                                                                                                    }
                                                                                                                    else {
                                                                                                                    printf("t"); // This is the 9 in the x-i-1?60:9
                                                                                                                    }
                                                                                                                    printf("n");
                                                                                                                    }
                                                                                                                    }



                                                                                                                    Try it online!






                                                                                                                    share|improve this answer



















                                                                                                                    • 1




                                                                                                                      121 bytes with a -D compiler flag instead of #define - Try it online!
                                                                                                                      – Logern
                                                                                                                      Dec 14 '18 at 17:31










                                                                                                                    • Another -3 bytes by taking out the i=0 like this
                                                                                                                      – NK1406
                                                                                                                      Dec 15 '18 at 18:19










                                                                                                                    • @NK1406 Functions have to be reusable, that edit would break this rule. Try it online!
                                                                                                                      – pizzapants184
                                                                                                                      Dec 16 '18 at 5:32










                                                                                                                    • @pizzapants184 Sorry, didn't see that!
                                                                                                                      – NK1406
                                                                                                                      Dec 16 '18 at 14:19










                                                                                                                    • Suggest x+~i instead of x-i-1 and i+=puts(" ") instead of putchar(10),i+=2
                                                                                                                      – ceilingcat
                                                                                                                      Dec 28 '18 at 5:55


















                                                                                                                    2















                                                                                                                    C (gcc), 127 95 + 26 = 121 bytes





                                                                                                                    i,j;f(x){for(i=0;i<x;putchar(10),i+=2){for(j=0;E;printf(">n%c",x-i-1?60:9);for(j=0;x-i-1&&E;}}


                                                                                                                    Try it online!



                                                                                                                    Compile with -DE=j<i/2;++j)putchar(45)



                                                                                                                    -6 bytes from Logern



                                                                                                                    Yay mismatched parentheses!



                                                                                                                    Ungolfed:





                                                                                                                    void f(int x) {
                                                                                                                    for (int i = 0; i < x; i += 2) {
                                                                                                                    for (int j = 0; j < i/2; ++j) {
                                                                                                                    printf("-");
                                                                                                                    }
                                                                                                                    printf(">n");
                                                                                                                    if (x - i - 1) { // Test for last loop: only print <-- if x is even
                                                                                                                    printf("<");
                                                                                                                    for (int j = 0; j < i/2; ++j) {
                                                                                                                    printf("-");
                                                                                                                    }
                                                                                                                    }
                                                                                                                    else {
                                                                                                                    printf("t"); // This is the 9 in the x-i-1?60:9
                                                                                                                    }
                                                                                                                    printf("n");
                                                                                                                    }
                                                                                                                    }



                                                                                                                    Try it online!






                                                                                                                    share|improve this answer



















                                                                                                                    • 1




                                                                                                                      121 bytes with a -D compiler flag instead of #define - Try it online!
                                                                                                                      – Logern
                                                                                                                      Dec 14 '18 at 17:31










                                                                                                                    • Another -3 bytes by taking out the i=0 like this
                                                                                                                      – NK1406
                                                                                                                      Dec 15 '18 at 18:19










                                                                                                                    • @NK1406 Functions have to be reusable, that edit would break this rule. Try it online!
                                                                                                                      – pizzapants184
                                                                                                                      Dec 16 '18 at 5:32










                                                                                                                    • @pizzapants184 Sorry, didn't see that!
                                                                                                                      – NK1406
                                                                                                                      Dec 16 '18 at 14:19










                                                                                                                    • Suggest x+~i instead of x-i-1 and i+=puts(" ") instead of putchar(10),i+=2
                                                                                                                      – ceilingcat
                                                                                                                      Dec 28 '18 at 5:55
















                                                                                                                    2












                                                                                                                    2








                                                                                                                    2







                                                                                                                    C (gcc), 127 95 + 26 = 121 bytes





                                                                                                                    i,j;f(x){for(i=0;i<x;putchar(10),i+=2){for(j=0;E;printf(">n%c",x-i-1?60:9);for(j=0;x-i-1&&E;}}


                                                                                                                    Try it online!



                                                                                                                    Compile with -DE=j<i/2;++j)putchar(45)



                                                                                                                    -6 bytes from Logern



                                                                                                                    Yay mismatched parentheses!



                                                                                                                    Ungolfed:





                                                                                                                    void f(int x) {
                                                                                                                    for (int i = 0; i < x; i += 2) {
                                                                                                                    for (int j = 0; j < i/2; ++j) {
                                                                                                                    printf("-");
                                                                                                                    }
                                                                                                                    printf(">n");
                                                                                                                    if (x - i - 1) { // Test for last loop: only print <-- if x is even
                                                                                                                    printf("<");
                                                                                                                    for (int j = 0; j < i/2; ++j) {
                                                                                                                    printf("-");
                                                                                                                    }
                                                                                                                    }
                                                                                                                    else {
                                                                                                                    printf("t"); // This is the 9 in the x-i-1?60:9
                                                                                                                    }
                                                                                                                    printf("n");
                                                                                                                    }
                                                                                                                    }



                                                                                                                    Try it online!






                                                                                                                    share|improve this answer















                                                                                                                    C (gcc), 127 95 + 26 = 121 bytes





                                                                                                                    i,j;f(x){for(i=0;i<x;putchar(10),i+=2){for(j=0;E;printf(">n%c",x-i-1?60:9);for(j=0;x-i-1&&E;}}


                                                                                                                    Try it online!



                                                                                                                    Compile with -DE=j<i/2;++j)putchar(45)



                                                                                                                    -6 bytes from Logern



                                                                                                                    Yay mismatched parentheses!



                                                                                                                    Ungolfed:





                                                                                                                    void f(int x) {
                                                                                                                    for (int i = 0; i < x; i += 2) {
                                                                                                                    for (int j = 0; j < i/2; ++j) {
                                                                                                                    printf("-");
                                                                                                                    }
                                                                                                                    printf(">n");
                                                                                                                    if (x - i - 1) { // Test for last loop: only print <-- if x is even
                                                                                                                    printf("<");
                                                                                                                    for (int j = 0; j < i/2; ++j) {
                                                                                                                    printf("-");
                                                                                                                    }
                                                                                                                    }
                                                                                                                    else {
                                                                                                                    printf("t"); // This is the 9 in the x-i-1?60:9
                                                                                                                    }
                                                                                                                    printf("n");
                                                                                                                    }
                                                                                                                    }



                                                                                                                    Try it online!







                                                                                                                    share|improve this answer














                                                                                                                    share|improve this answer



                                                                                                                    share|improve this answer








                                                                                                                    edited Dec 16 '18 at 5:31

























                                                                                                                    answered Dec 14 '18 at 6:23









                                                                                                                    pizzapants184

                                                                                                                    2,644716




                                                                                                                    2,644716








                                                                                                                    • 1




                                                                                                                      121 bytes with a -D compiler flag instead of #define - Try it online!
                                                                                                                      – Logern
                                                                                                                      Dec 14 '18 at 17:31










                                                                                                                    • Another -3 bytes by taking out the i=0 like this
                                                                                                                      – NK1406
                                                                                                                      Dec 15 '18 at 18:19










                                                                                                                    • @NK1406 Functions have to be reusable, that edit would break this rule. Try it online!
                                                                                                                      – pizzapants184
                                                                                                                      Dec 16 '18 at 5:32










                                                                                                                    • @pizzapants184 Sorry, didn't see that!
                                                                                                                      – NK1406
                                                                                                                      Dec 16 '18 at 14:19










                                                                                                                    • Suggest x+~i instead of x-i-1 and i+=puts(" ") instead of putchar(10),i+=2
                                                                                                                      – ceilingcat
                                                                                                                      Dec 28 '18 at 5:55
















                                                                                                                    • 1




                                                                                                                      121 bytes with a -D compiler flag instead of #define - Try it online!
                                                                                                                      – Logern
                                                                                                                      Dec 14 '18 at 17:31










                                                                                                                    • Another -3 bytes by taking out the i=0 like this
                                                                                                                      – NK1406
                                                                                                                      Dec 15 '18 at 18:19










                                                                                                                    • @NK1406 Functions have to be reusable, that edit would break this rule. Try it online!
                                                                                                                      – pizzapants184
                                                                                                                      Dec 16 '18 at 5:32










                                                                                                                    • @pizzapants184 Sorry, didn't see that!
                                                                                                                      – NK1406
                                                                                                                      Dec 16 '18 at 14:19










                                                                                                                    • Suggest x+~i instead of x-i-1 and i+=puts(" ") instead of putchar(10),i+=2
                                                                                                                      – ceilingcat
                                                                                                                      Dec 28 '18 at 5:55










                                                                                                                    1




                                                                                                                    1




                                                                                                                    121 bytes with a -D compiler flag instead of #define - Try it online!
                                                                                                                    – Logern
                                                                                                                    Dec 14 '18 at 17:31




                                                                                                                    121 bytes with a -D compiler flag instead of #define - Try it online!
                                                                                                                    – Logern
                                                                                                                    Dec 14 '18 at 17:31












                                                                                                                    Another -3 bytes by taking out the i=0 like this
                                                                                                                    – NK1406
                                                                                                                    Dec 15 '18 at 18:19




                                                                                                                    Another -3 bytes by taking out the i=0 like this
                                                                                                                    – NK1406
                                                                                                                    Dec 15 '18 at 18:19












                                                                                                                    @NK1406 Functions have to be reusable, that edit would break this rule. Try it online!
                                                                                                                    – pizzapants184
                                                                                                                    Dec 16 '18 at 5:32




                                                                                                                    @NK1406 Functions have to be reusable, that edit would break this rule. Try it online!
                                                                                                                    – pizzapants184
                                                                                                                    Dec 16 '18 at 5:32












                                                                                                                    @pizzapants184 Sorry, didn't see that!
                                                                                                                    – NK1406
                                                                                                                    Dec 16 '18 at 14:19




                                                                                                                    @pizzapants184 Sorry, didn't see that!
                                                                                                                    – NK1406
                                                                                                                    Dec 16 '18 at 14:19












                                                                                                                    Suggest x+~i instead of x-i-1 and i+=puts(" ") instead of putchar(10),i+=2
                                                                                                                    – ceilingcat
                                                                                                                    Dec 28 '18 at 5:55






                                                                                                                    Suggest x+~i instead of x-i-1 and i+=puts(" ") instead of putchar(10),i+=2
                                                                                                                    – ceilingcat
                                                                                                                    Dec 28 '18 at 5:55













                                                                                                                    1














                                                                                                                    Powershell, 51 bytes





                                                                                                                    param($n)0..$n|%{'-'*$_+'>';'<'+'-'*$_}|?{$n---gt0}





                                                                                                                    share|improve this answer


























                                                                                                                      1














                                                                                                                      Powershell, 51 bytes





                                                                                                                      param($n)0..$n|%{'-'*$_+'>';'<'+'-'*$_}|?{$n---gt0}





                                                                                                                      share|improve this answer
























                                                                                                                        1












                                                                                                                        1








                                                                                                                        1






                                                                                                                        Powershell, 51 bytes





                                                                                                                        param($n)0..$n|%{'-'*$_+'>';'<'+'-'*$_}|?{$n---gt0}





                                                                                                                        share|improve this answer












                                                                                                                        Powershell, 51 bytes





                                                                                                                        param($n)0..$n|%{'-'*$_+'>';'<'+'-'*$_}|?{$n---gt0}






                                                                                                                        share|improve this answer












                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer










                                                                                                                        answered Dec 12 '18 at 17:47









                                                                                                                        mazzy

                                                                                                                        2,1251315




                                                                                                                        2,1251315























                                                                                                                            1















                                                                                                                            Perl 5, 44 bytes





                                                                                                                            map{$_/=2;say'<'x/./,'-'x$_,'>'x!$&}0..<>-1


                                                                                                                            Try it online!






                                                                                                                            share|improve this answer


























                                                                                                                              1















                                                                                                                              Perl 5, 44 bytes





                                                                                                                              map{$_/=2;say'<'x/./,'-'x$_,'>'x!$&}0..<>-1


                                                                                                                              Try it online!






                                                                                                                              share|improve this answer
























                                                                                                                                1












                                                                                                                                1








                                                                                                                                1







                                                                                                                                Perl 5, 44 bytes





                                                                                                                                map{$_/=2;say'<'x/./,'-'x$_,'>'x!$&}0..<>-1


                                                                                                                                Try it online!






                                                                                                                                share|improve this answer













                                                                                                                                Perl 5, 44 bytes





                                                                                                                                map{$_/=2;say'<'x/./,'-'x$_,'>'x!$&}0..<>-1


                                                                                                                                Try it online!







                                                                                                                                share|improve this answer












                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer










                                                                                                                                answered Dec 12 '18 at 22:25









                                                                                                                                Xcali

                                                                                                                                5,168520




                                                                                                                                5,168520






















                                                                                                                                    1 2
                                                                                                                                    next

















                                                                                                                                    draft saved

                                                                                                                                    draft discarded




















































                                                                                                                                    If this is an answer to a challenge…




                                                                                                                                    • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                                    • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                                      Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                                    • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                                                                                                    More generally…




                                                                                                                                    • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                                    • …Avoid asking for help, clarification or responding to other answers (use comments instead).






                                                                                                                                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                                                                                                    Please pay close attention to the following guidance:


                                                                                                                                    • Please be sure to answer the question. Provide details and share your research!

                                                                                                                                    But avoid



                                                                                                                                    • Asking for help, clarification, or responding to other answers.

                                                                                                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                                                                                                    To learn more, see our tips on writing great answers.




                                                                                                                                    draft saved


                                                                                                                                    draft discarded














                                                                                                                                    StackExchange.ready(
                                                                                                                                    function () {
                                                                                                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177454%2fdraw-some-expanding-arrows%23new-answer', 'question_page');
                                                                                                                                    }
                                                                                                                                    );

                                                                                                                                    Post as a guest















                                                                                                                                    Required, but never shown





















































                                                                                                                                    Required, but never shown














                                                                                                                                    Required, but never shown












                                                                                                                                    Required, but never shown







                                                                                                                                    Required, but never shown

































                                                                                                                                    Required, but never shown














                                                                                                                                    Required, but never shown












                                                                                                                                    Required, but never shown







                                                                                                                                    Required, but never shown







                                                                                                                                    Popular posts from this blog

                                                                                                                                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                                                                                                                                    Alcedinidae

                                                                                                                                    Origin of the phrase “under your belt”?