# Create a Parrot Program

Given an input, output that input followed by a newline endlessly.

Input will be a string consisting only of printable ASCII characters (0x20-0x7E) and newlines (0x0A).

If input is length 0, endlessly output newlines.

This is so fewest bytes in each language wins!

• Half of yes is 91 lines long. – manatwork Jun 5 '17 at 9:08
• So related it hurts. – Addison Crump Jun 5 '17 at 13:23
• @VoteToClose I knew I've answered this before.. – L3viathan Jun 6 '17 at 9:49
• Microsoft, 1 Steve Ballmerdevelopers, developers, developers, developers, ... – sergiol Jun 8 '17 at 0:43

# Bash, 8 bytes

yes "$1"  Try it online! • damn, 10 minutes late! but this does not print out newlines as newlines. – phil294 Jun 5 '17 at 9:29 • sorry, I didn't mean the yes-newlines but any newlines that could be contained IN the input are instead printed out as \n. kind of depends on how you read the question :D – phil294 Jun 5 '17 at 9:51 • @Blauhirn Oh I misunderstood this part :/. You need to call this as ./script$'Hello\n World' to include real newlines. On TIO you can just add a newline to the command line argument – ovs Jun 5 '17 at 10:05
• Are the quotations necessary? yes $1 works fine for me – DrnglVrgs Jun 5 '17 at 13:43 • @DrnglVrgs this does not work for me for an empty input – ovs Jun 5 '17 at 13:49 # 05AB1E, 2 bytes [,  Try it online! • Why aren't you doing [I,? – FrodCube Jun 5 '17 at 11:23 • @FrodCube: Because unfortunately that doesn't work with empty input :( – Emigna Jun 5 '17 at 11:49 • @FrodCube: Actually, the question states input of length 0 and not empty input so I can decrease this :) – Emigna Jun 5 '17 at 11:51 • @FrodCube: Yeah, it's a pretty new feature in 05AB1E actually. I'm sure Ohm will get it eventually as well. – Emigna Jun 5 '17 at 12:12 • [= also works and is a smiley face; the smile is the only benefit lol. – Magic Octopus Urn Jun 5 '17 at 14:45 # JavaScript (ES6), 24 bytes f=a=>f(a,console.log(a))  Try it online! # Ohm, 3 bytes ∞┼,  Try it online! It doesn't work with an empty input because Ohm is bad at input handling compared to other languages, but you can input "". Explanation ∞ Infinite loop next code (until ";" or end of line) ┼ Get first input , Println  • This looks cool... Could you explain it :D – Beta Decay Jun 5 '17 at 10:46 • @BetaDecay done! – FrodCube Jun 5 '17 at 11:16 • FYI, Ohm v2 (hopefully coming soon-ish) will have much better input handling than before! – Nick Clifford Jun 5 '17 at 14:23 • @NickClifford cool! I'm looking forward to that! I like your language – FrodCube Jun 5 '17 at 14:26 • Oooo... Is Ohm like 05AB1E with different commands?! Fervently starts reading GitHub pages – Magic Octopus Urn Jun 5 '17 at 14:54 # sed, 5 : # label (unnamed) p # print the pattern space b # branch back to the label  Unnamed labels is an undocumented "feature" in sed that works with version 4.2.2, but may not work in future versions. # Jelly, 2 bytes Ṅß  Try it online! Print with a newline, repeat the whole link (program). # brainfuck, 27 bytes +[>,]++++++++++[[<]>>[.>]<]  Try it online! • Could you save a byte with ,[>,]++++++++++[[<]>[.>]<]? – ETHproductions Jun 5 '17 at 10:40 # Python 2, 21 bytes def f(s):print s;f(s)  Assumes no recursion limit Try it online! # V, 2 bytes òÙ  You can't try this online for obvious reasons. ò 'Recursively Ù 'Duplicate the current line downwards  • TIO actually runs for 60 seconds then terminates and prints the STDOUT up until the termination point truncated to the first 128KiB. – Magic Octopus Urn Jun 5 '17 at 14:47 • In V because the output it inside of an nvim session, and isn't printed to STDOUT until it finishes, TIO kills the session and sees nothing on STDOUT. I didn't know about what you said, but unfortunately it doesn't fix V – nmjcman101 Jun 5 '17 at 14:51 • Ahhhh... That's unfortunate, I forgot the properties of V, I've only used it once unsuccessfully. – Magic Octopus Urn Jun 5 '17 at 14:53 # Ruby, 1817 12 + 2 = 14 bytes Run with the -n flag. loop{$><<$_}  Edit: Thanks for @sethrin for the -n flag! • Use the -n flag and skip the gets. – canhascodez Jun 5 '17 at 22:53 • @sethrin Nice one! I did not know about this flag! – Peter Lenkefi Jun 6 '17 at 8:18 # AutoHotkey, 20 Bytes OP did not specify how the output should happen, said only it has to happen endlessly with a newline after it. AHK was not tailored for cmd interaction. So the output happens repeatedly in a ToolTip at mouse position: loop tooltip,%1%nn  I like AHK's loop feature. loop repeats the next block forever, loop, 10 would repeat it 10 times. Sometimes I miss this feature in other languages like Python. The escape character in AutoHotkey is  (so there are no problems with backslashes in Windows paths). For some reason, a trailing newline is ignored so it is needed twice. (trayTip might not have this "bug" but I cannot test it because running with wine) ## old answer: loop msgbox,%1%  I just realized that OP probably wont like this solution, the output happens with user-interaction and includes no newlines. I'll look for another way. • Well, you've got my upvote for a creative solution – Skidsdev Jun 6 '17 at 15:03 # LibreLogo, 33 bytes Code: x=input " repeat [ label x bk 9 ]  Explanation: x = input " ; Input Stored in x as String repeat [ ; Endless Loop label x ; Print x in Current Position bk 9 ; Move Back 9 pt ]  Result: # Python 2, 25 bytes s=input() while 1:print s  Try it online! Input is expected to be a Python literal (quotes for a string, square bracket or parentheses with comma-separated items for a list/tuple, etc.) Python 3 would be +1 byte because print is a function, but also could do raw input without the 4-byte penalty for raw_input() in Python 2. # Brachylog, 3 bytes ẉ?↰  Try it online! Port of my Jelly answer. # PHP, 20 bytes for(;;)echo"$argn
";


cycle.(++"\n")


Try it online!

Append a newline to the input and make list of infinite copies of it.

Alternative version, also 14 bytes:

unlines.repeat

• The alternative version is quite elegant :) – Conor O'Brien Jun 6 '17 at 20:05

# Braingolf, 14 12 bytes

#
V[R!&@v1+]


Try it online!

-2 bytes thanks to totallyhuman

## Explanation

#\nV[R!&@v1+]  Implicit input of string as charcodes
#\n            Push charcode of newline
V           Create stack2
[R...v1+]  While loop, runs endlessly
!&@      Print entire stack1 as chars without popping


# C, 24 bytes

f(char*s){puts(s),f(s);}


Basically a recursive function that outputs the string before calling herself again. Its my second post on codegolf so please be nice :p

# Cubix, 6 bytes

AN/qvo


Test it here

  A
N / q v
o

• N/A Push Newline(10) and input onto the stack
• v redirect into the loop
• o/q loop that outputs a character and pushes it to the bottom of the stack continuously

I was going to remove the EOI (-1) indicator from the stack, but it doesn't appear to affect the output any, so have left it saving bytes.

# Japt, 5 bytes

OpU;ß


Try it online!

Explanation

OpU;     output the input with a newline
ß    run the code again with the same input


# C#, 40 bytes

s=>{for(;;)System.Console.WriteLine(s);}


# MATL, 4 bytes

GDT


Try it Online

Explanation

     % Do...while loop
G   % Grab input
D   % Display it on a new line
T   % Literal TRUE to create an infinite loop


# C, 26 bytes

f(char*s){for(;;)puts(s);}


A function, f, that takes a C-style string as a parameter, s. The body of the function loops repeatedly, passing the string to the library function puts, which outputs the string to the standard output (stdout) along with a trailing new-line.

Pretty simple stuff. The only hack here is taking advantage of default-int for the return value and then not actually returning a value. That doesn't matter in this case, though, since the function never returns (it just keeps printing forever)!

Try it online!

• f(char*s){puts(s);f(s);} saves a few – nmjcman101 Jun 5 '17 at 14:40

# Groovy, 20 bytes

x={println it;x(it)}

• Does this run forever since it is recursive? – Twometer Jul 2 '17 at 19:29

# Java 8, 34 bytes

s->{for(;;System.out.println(s));}


Surprised there wasn't a Java answer yet.

Try it here. (Wait 60 second for it to time-out.)

• you don't need to wait for it to timeout, it'll reach the max output buffer of 128kb much faster than that :P – Skidsdev Jun 6 '17 at 8:51
• @Mayube Perhaps, but it's still running Real time: 60.008 s according to the Debug-section before it outputs the result (and gives two warnings 60-sec limit exceeded and 128kb exceeded). – Kevin Cruijssen Jun 6 '17 at 9:25
• TIO also caches the results, so once it's been run and hit the timelimit, the output is cached and will simply be served to others who run it without actually re-compiling and running the code – Skidsdev Jun 6 '17 at 9:27
• @Mayube True. I didn't knew this also applied to others. Thought it was a local cache. In that case you can ignore the "(Wait 60 second for it to time-out.)" in my answer. :) But if you check on the "disable output cache" setting you'll see it takes ~ 60 seconds. – Kevin Cruijssen Jun 6 '17 at 9:30

# Pyth, 2 bytes

#


Unfortunately I can't remove Q :(

You need to run from command-line like this, so that this is competing:

python3 pyth.py -c "#
"


The interpreter has been fixed too.

# ><>, 16 bytes

i:0(?v
:o71.>~a{


Try it online!

As mentioned in the comments below my first attempt may have misunderstood the question so the newer 16 byte solution has been made, I have left the original below so people may see.

# ><>, 13 bytes

<ov!?+1:i
oa<


Try it online!

• I think there's been a bracketing problem: this code returns "that input followed by (a newline endlessly)", while most of the other answers give "(that input followed by a newline) endlessly"… – Not a tree Jun 6 '17 at 9:52
• @Notatree, Thanks for mentioning this, I have updated my answer to respect your comment :) – Teal pelican Jun 6 '17 at 10:28
• Nice, my best try was 17 bytes! – Not a tree Jun 6 '17 at 10:35
• @Notatree, I changed the check in the first line from 1+?!v to 0)?v which saved a byte, what was your solution, would be nice to see more ><> answers :) - I also believe with some nifty mirrors you may be able to remove the jump instructions too but haven't figured it out yet. – Teal pelican Jun 6 '17 at 10:39
• @Notatree, you were really close to the 16 bytes as well, change your second line to a\~ then move your last line around 1 to o>{: and you would have made it. the jump is just to cut out on extra mirrors across lines but yours works just as well :) – Teal pelican Jun 6 '17 at 11:12

# CJam, 6 bytes

q{_n}h


Try it online!

• @LuisMendo Ooh didn't read that part... – Erik the Outgolfer Jun 6 '17 at 11:07

# Perl 5, 27 bytes

while(1){print"$ARGV[0]\n"}  Try it online! • input will always be given, it just might be an empty string, so you should be able to do while(1){print"$ARGV[0]\n"} – Skidsdev Jun 6 '17 at 15:30
• @Mayube - thx, updated answer. – tale852150 Jun 6 '17 at 15:35
• Also welcome to ppcg! I fixed the formatting on your answer for you, in the future I totally recommend using Try it online (linked in the edited answer) as it not only makes testing way easier, but can give you a fully formatted ppcg answer to post – Skidsdev Jun 6 '17 at 15:38
• @Mayube - thx, glad to be here... – tale852150 Jun 6 '17 at 15:39

## SAS, 32 bytes

%macro t(s);%put&s;%t(&s);%mend;
`