[Question]
      [
One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a ["cat program"](http://esolangs.org/wiki/Cat): read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility `cat` it is of course much less powerful than the real thing, which is normally used to print (and concatenate) several files read from disc.
### Task
You should write a **full program** which reads the contents of the standard input stream and writes them verbatim to the standard output stream. If and only if your language does not support standard input and/or output streams (as understood in most languages), you may instead take these terms to mean their closest equivalent in your language (e.g. JavaScript's `prompt` and `alert`). These are the *only* admissible forms of I/O, as any other interface would largely change the nature of the task and make answers much less comparable.
The output should contain exactly the input and *nothing else*. The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation. **This also applies to trailing newlines.** If the input does not contain a trailing newline, the output shouldn't include one either! (The only exception being if your language absolutely always prints a trailing newline after execution.)
Output to the standard error stream is ignored, so long as the standard output stream contains the expected output. In particular, this means your program can terminate with an error upon hitting the end of the stream (EOF), provided that doesn't pollute the standard output stream. *If you do this, I encourage you to add an error-free version to your answer as well (for reference).*
As this is intended as a challenge within each language and not between languages, there are a few language specific rules:
* If it is at all possible in your language to distinguish null bytes in the standard input stream from the EOF, your program must support null bytes like any other bytes (that is, they have to be written to the standard output stream as well).
* If it is at all possible in your language to support an *arbitrary* infinite input stream (i.e. if you can start printing bytes to the output before you hit EOF in the input), your program has to work correctly in this case. As an example `yes | tr -d \\n | ./my_cat` should print an infinite stream of `y`s. It is up to you how often you print and flush the standard output stream, but it must be guaranteed to happen after a finite amount of time, regardless of the stream (this means, in particular, that you cannot wait for a specific character like a linefeed before printing).
Please add a note to your answer about the exact behaviour regarding null-bytes, infinite streams, and extraneous output.
### Additional rules
* This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in *every* language. Therefore, no answer will be marked as accepted.
* Submissions in most languages will be scored in *bytes* in an appropriate preexisting encoding, usually (but not necessarily) UTF-8.
Some languages, like [Folders](http://esolangs.org/wiki/Folders), are a bit tricky to score. If in doubt, please ask on [Meta](http://meta.codegolf.stackexchange.com/).
* Feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.
Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.
Also note that languages *do* have to fulfil [our usual criteria for programming languages](http://meta.codegolf.stackexchange.com/questions/2028/what-are-programming-languages/2073#2073).
* If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck derivatives like Headsecks or Unary), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.
* Unless they have been overruled earlier, all standard [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") rules apply, including the <http://meta.codegolf.stackexchange.com/q/1061>.
As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf; these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the author actually had to put effort into golfing the code.
### Catalogue
The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
```
## Language Name, N bytes
```
where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance:
```
## Ruby, <s>104</s> <s>101</s> 96 bytes
```
If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header:
```
## Perl, 43 + 2 (-p flag) = 45 bytes
```
You can also make the language name a link which will then show up in the snippet:
```
## [><>](http://esolangs.org/wiki/Fish), 121 bytes
```
```
<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table><script>var QUESTION_ID = 62230; var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 8478; var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page; function answersUrl(index) { return "//api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; } function commentUrl(index, answers) { return "//api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; } function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { data.items.forEach(function(c) { if (c.owner.user_id === OVERRIDE_USER) answers_hash[c.post_id].comments.push(c); }); if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); } getAnswers(); var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/; var OVERRIDE_REG = /^Override\s*header:\s*/i; function getAuthorName(a) { return a.owner.display_name; } function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); var match = body.match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2], language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(42), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) return -1; return 0; }); for (var i = 0; i < langs.length; ++i) { var language = jQuery("#language-template").html(); var lang = langs[i]; language = language.replace("{{LANGUAGE}}", lang.lang) .replace("{{NAME}}", lang.user) .replace("{{SIZE}}", lang.size) .replace("{{LINK}}", lang.link); language = jQuery(language); jQuery("#languages").append(language); } }</script>
```

[Answer]
# sed, 0
```
```
The empty `sed` program does exactly what is required here:
```
$ printf "abc\ndef" | sed ''
abc
def$
```
[Answer]
# [Ziim](http://esolangs.org/wiki/Ziim), ~~222~~ ~~201~~ ~~196~~ ~~185~~ 182 bytes
```
    ↓ ↓
 ↓ ↓     ↓
 ↗ ↗↙↔↘↖ ↖
 ↓↓⤡⤢  ⤢↙
↘ ↖⤡ ↖
  ↙
  ↕↘ ↑ ↙
→↘↖↑ ↙ ↑
→↖   ↑
→↖↘ ↙
  ↑↓↑
   ⤡
```
This will probably not display correctly in your browser, so here is a diagram of the code:
[![enter image description here](https://i.stack.imgur.com/K0S8k.png)](https://i.stack.imgur.com/K0S8k.png)
I can't think of a simpler *structure* to solve the problem in Ziim, but I'm sure the actual code is still quite golfable.
Ziim cannot possibly handle infinite streams because it is only possible to print anything at the end of the program.
## Explanation
Since Ziim has a rather unique, declarative control flow model an imperative pseudocode algorithm won't cut it here. Instead, I'll explain the basics of Ziim and the present the tidied up structure of the above code (in a similar graphical manner) as ASCII art.
Control flow in Ziim happens all over the place: each arrow which isn't pointed at by another arrow initialises a "thread" which is processed independently of the others (not really in parallel, but there are no guarantees which order they are processed in, unless you sync them up via concatenation). Each such thread holds a list of binary digits, starting as `{0}`. Now each arrow in the code is some sort of command which has one or two inputs and one or two outputs. The exact command depends on how many arrows are pointing at it from which orientations.
Here is the list of the commands, where `m -> n` indicates that the command takes `m` inputs and produces `n` outputs.
* `1 -> 1`, **no-op**: simply redirects the thread.
* `1 -> 1`, **invert**: negates each bit in the thread (and also redirects it).
* `1 -> 1`, **read**: replaces the thread's value by the next *bit* from STDIN, or by the empty list if we've hit EOF.
* `2 -> 1`, **concatenate**: this is the only way to sync threads. When a thread hits one side of the arrow, it will be suspended until another thread hits the other side. At that point they will be concatenated into a single thread and continue execution.
* `2 -> 1`, **label**: this is the only way to join different execution paths. This is simply a no-op which has two possible inputs. So threads entering the "label" via either route will simply be redirected into the same direction.
* `1 -> 2`, **split**: takes a single thread, and sends two copies off in different directions.
* `1 -> 1`, **isZero?**: consumes the first bit of the thread, and sends the thread in one of two directions depending on whether the bit was 0 or 1.
* `1 -> 1`, **isEmpty?**: consumes the entire list (i.e. replaces it with an empty list), and sends the thread in one of two direction depending on whether the list was already empty or not.
So with that in mind, we can figure out a general strategy. Using *concatenate* we want to repeatedly append new bits to a string which represents the entire input. We can simply do this by looping the output of the *concatenate* back into one of its inputs (and we initialise this to an empty list, by clearing a `{0}` with *isEmpty?*). The question is how we can terminate this process.
In addition to appending the current bit we will also *prepend* a 0 or 1 indicating whether we've reached EOF. If we send our string through *isZero?*, it will get rid of that bit again, but let us distinguish the end of the stream, in which case we simply let the thread leave the edge of the grid (which causes Ziim to print the thread's contents to STDOUT and terminate the program).
Whether we've reached EOF or not can be determined by using *isEmpty?* on a copy of the input.
Here is the diagram I promised:
```
              +----------------------------+   {0} --> isEmpty --> label <--+
              |                            |                    n    |      |
              v                            |                         v      |
    {0} --> label --> read --> split --> split ------------------> concat   |
                                 |                                   |      |
                           n     v     y                             |      |
 inv --> label --> concat <-- isEmpty --> concat <-- label <-- {0}   |      |
  ^        ^          |                     |          ^             |      |
  |        |          v                     v          |             |      |
 {0}       +------- split ---> label <--- split -------+             |      |
                                 |                                   |      |
                                 +-------------> concat <------------+      |
                                                   |                        |
                                              y    v                        |
                         print and terminate <-- isZero --------------------+
```
Some notes about where to start reading:
* The `{0}` in the top left corner is the initial trigger which starts the input loop.
* The `{0}` towards the top right corner is immediately cleared to an empty list an represents the initial string which we'll gradually fill with the input.
* The other two `{0}`s are fed into a "producer" loop (one inverted, one not), to give us an unlimited supply of `0`s and `1`s which we need to prepend to the string.
[Answer]
# [Hexagony](https://github.com/mbuettner/hexagony), 6 bytes
This used to be 3 bytes (see below), but that version no long works since the latest update of the language. As I never intentionally introduced the error that version made use of, I decided not to count it.
---
An error-free solution (i.e. one which works with the fixed interpreter) turns out to be much trickier. I've had some trouble squeezing it into a 2x2 grid, but I found one solution now, although I need the full **7 bytes**:
```
<)@,;.(
```
After unfolding, we get:
[![enter image description here](https://i.stack.imgur.com/HsRLD.png)](https://i.stack.imgur.com/HsRLD.png)
Since the initial memory edge is 0, the `<` unconditionally deflects the instruction pointer into the North-East diagonal, where it wraps to the the grey path. The `.` is a no-op. Now `,` reads a byte, `)` increments it such that valid bytes (including null bytes) are positive and EOF is 0.
So on EOF, the IP wraps to red path, where `@` terminates the program. But if we still read a byte, then the IP wraps to the green path is instead where `(` decrements the edge to the original value, before `;` prints it to STDOUT. The IP now wraps unconditionally back to the grey path, repeating the process.
---
After writing [a brute force script](https://codegolf.stackexchange.com/a/62812/8478) for my Truth Machine answer, I set it to find an error-free **6-byte** solution for the cat program as well. Astonishingly, it did find one - yes, exactly one solution in all possible 6-byte Hexagony programs. After the 50 solutions from the truth machine, that was quite surprising. Here is the code:
```
~/;,@~
```
Unfolding:
[![enter image description here](https://i.stack.imgur.com/pjs2D.png)](https://i.stack.imgur.com/pjs2D.png)
The use of `~` (unary negation) instead of `()` is interesting, because a) it's a no-op on zero, b) it swaps the sides of the branch, c) in some codes a single `~` might be used twice to undo the operation with itself. So here is what's going on:
The first time (purple path) we pass through `~` it's a no-op. The `/` reflects the IP into the North-West diagonal. The grey path now reads a character and multiplies its character code by `-1`. This turns the EOF (`-1`) into a truthy (positive) value and all valid characters into falsy (non-positive) values. In the case of EOF, the IP takes the red path and the code terminates. In the case of a valid character, the IP takes the green path, where `~` undoes negation and `;` prints the character. Repeat.
---
Finally, here is the 3-byte version which used to work in the original version Hexagony interpreter.
```
,;&
```
Like the Labyrinth answer, this terminates with an error if the input stream is finite.
After unfolding the code, it corresponds to the following hex grid:
[![enter image description here](https://i.stack.imgur.com/xNuWk.png)](https://i.stack.imgur.com/xNuWk.png)
The `.` are no-ops. Execution starts on the purple path.
`,` reads a byte, `;` writes a byte. Then execution continues on the salmon(ish?) path. We need the `&` to reset the current memory edge to zero, such that the IP jumps back to the purple row when hitting the corner at the end of the second row. Once `,` hits EOF it will return `-1`, which causes an error when `;` is trying to print it.
---
Diagrams generated with [Timwi](https://codegolf.stackexchange.com/users/668/timwi)'s amazing [HexagonyColorer](https://github.com/Timwi/HexagonyColorer).
[Answer]
# [TeaScript](https://github.com/vihanb/TeaScript), 0 bytes
TeaScript is a concise golfing language compiled to JavaScript
```
```
In a recent update the input is implicitly added as the first property.
[Try it online](http://vihanserver.tk/p/TeaScript/?code=x&input=foobar%0Appcg%0Ahello%20world)
---
### Alternatively, 1 byte
```
x
```
`x` contains the input in TeaScript. Output is implicit
[Answer]
## [Brian & Chuck](https://github.com/mbuettner/brian-chuck), 44 bytes
```
#{<{,+?+}_+{-?>}<?
_}>?>+<<<{>?_}>>.<+<+{<{?
```
I originally created this language for [Create a programming language that only appears to be unusable](https://codegolf.stackexchange.com/a/63121/8478). It turns out to be a very nice exercise to golf simple problems in it though.
**The Basics:** Each of the two lines defines a Brainfuck-like program which operates on the other program's source code - the first program is called Brian and the second is called Chuck. Only Brian can read and only Chuck can write. Instead of Brainfuck's loops you have `?` which passes control to the other program (and the roles of instruction pointer and tape head change as well). An addition to Brainfuck is `{` and `}` which scan the tape for the first non-zero cell (or the left end). Also, `_` are replaced with null bytes.
While I don't think this is optimal yet, I'm quite happy with this solution. My first attempt was 84 bytes, and after several golfing sessions with Sp3000 (and taking some inspiration from his attempts), I managed to get it slowly down to 44, a few bytes at a time. Especially the brilliant `+}+` trick was his idea (see below).
### Explanation
Input is read into the first cell on Chuck's tape, then painstakingly copied to the end of Brian's tape, where it's printed. By copying it to the end, we can save bytes on setting the previous character to zero.
The `#` is just a placeholder, because switching control does not execute the cell we switched on. `{<{` ensures that the tape head is on Chuck's first cell. `,` reads a byte from STDIN or `-1` if we hit EOF. So we increment that with `+` to make it zero for EOF and non-zero otherwise.
Let's assume for now we're not at EOF yet. So the cell is positive and `?` will switch control to Chuck. `}>` moves the tape head (on Brian) to the `+` the `_` and `?` passes control back to Brian.
`{-` now decrements the first cell on Chuck. If it's not zero yet, we pass control to Chuck again with `?`. This time `}>` moves the tape head on Brian two cells of the right of the last non-zero cell. Initially that's here:
```
#{<{,+?+}_+{-?>}<?__
                   ^
```
But later on, we'll already have some characters there. For instance, if we've already read and printed `abc`, then it would look like this:
```
#{<{,+?+}_+{-?>}<?11a11b11c__
                            ^
```
Where the `1`s are actually 1-bytes (we'll see what that's about later).
This cell will always be zero, so this time `?` *won't* change control. `>` moves yet another cell to the right and `+` increments that cell. This is why the first character in the input ends up three cells to the right of the `?` (and each subsequent one three cells further right).
`<<<` moves back to the last character in that list (or the `?` if it's the first character), and `{>` goes back to the `+` on Brian's tape to repeat the loop, which slowly transfers the input cell onto the end of Brian's tape.
Once that input cell is empty the `?` after `{-` will not switch control any more. Then `>}<` moves the tape head on Chuck to the `_` and switches control such that Chuck's second half is executed instead.
`}>>` moves to the cell we've now written past the end of Brian's tape, which is the byte we've read from STDIN, so we print it back with `.`. In order for `}` to run past this new character on the tape we need to close the gap of two null bytes, so we increment them to `1` with `<+<+` (so that's why there are the 1-bytes between the actual characters on the final tape). Finally `{<{` moves back to the beginning of Brian's tape and `?` starts everything from the beginning.
You might wonder what happens if the character we read was a null-byte. In that case the newly written cell would itself be zero, but since it's at the end of Brian's tape and we don't care *where* that end is, we can simply ignore that. That means if the input was `ab\0de`, then Brian's tape would actually end up looking like:
```
#{<{,+?+}_+{-?>}<?11a11b1111d11e
```
Finally, once we hit EOF that first `?` on Brian's tape will be a no-op. At this point we terminate the program. The naive solution would be to move to the end of Chuck's tape and switch control, such that the program termiantes: `>}>}<?`. This is where Sp3000's really clever idea saves three bytes:
`+` turns Chuck's first cell into `1`. That means `}` has a starting point and finds the `_` in the middle of Chuck's tape. Instead of skipping past it, we simply close the gap by turning it into a `1` with `+` as well. Now let's see what the rest of Brian's code happens to do with this modified Chuck...
`{` goes back to Chuck's first cell as usual, and `-` turns it back into a null-byte. That means that `?` is a no-op. But now `>}<`, which usually moved the tape head to the middle of Chuck's tape, moves right past it to the end of Chuck's tape and `?` then passes control to Chuck, terminating the code. It's nice when things just work out... :)
[Answer]
# Haskell, 16 bytes
```
main=interact id
```
`interact` reads the input, passes it to the function given as its argument and prints the result it receives. `id` is the identity function, i.e. it returns its input unchanged. Thanks to Haskell's laziness `interact` can work with infinite input.
[Answer]
## sh + binutils, ~~3~~ 2 bytes
```
dd
```
Well, not quite as obvious. From @Random832
## Original:
```
cat
```
The painfully obvious... :D
[Answer]
# [Motorola MC14500B Machine Code](https://en.wikipedia.org/wiki/Motorola_MC14500B), 1.5 bytes
Written in hexadecimal:
```
18F
```
Written in binary:
```
0001 1000 1111
```
---
### Explanation
```
1   Read from I/O pin
8   Output to I/O pin
F   Loop back to start
```
The opcodes are 4 bits each.
[Answer]
# [Funciton](http://esolangs.org/wiki/Funciton), 16 bytes
```
╔═╗
╚╤╝
```
(Encoded as UTF-16 with a BOM)
## Explanation
The box returns the contents of STDIN. The loose end outputs it.
[Answer]
# [Mornington Crescent](https://esolangs.org/wiki/Mornington_Crescent), 41 bytes
```
Take Northern Line to Mornington Crescent
```
I have no idea whether Mornington Crescent can handle null bytes, and all input is read before the program starts, as that is the nature of the language.
[Answer]
# Brainfuck, 5 bytes
```
,[.,]
```
Equivalent to the pseudocode:
```
x = getchar()
while x != EOF:
    putchar(x)
    x = getchar()
```
This handles infinite streams, but treats null bytes as EOF. Whether or not BF *can* handle null bytes correctly varies from implementation to implementation, but this assumes the most common approach.
[Answer]
# [Labyrinth](https://github.com/mbuettner/labyrinth), 2 bytes
```
,.
```
If the stream is finite, this will terminate with an error, but all the output produce by the error goes to STDERR, so the standard output stream is correct.
As in Brainfuck `,` reads a byte (pushing it onto Labyrinth's main stack) and `.` writes a byte (popping it from Labyrinth's main stack).
The reason this loops is that both `,` and `.` are "dead ends" in the (very trivial) maze represented by the source code, such that the instruction pointer simply turns around on the spot and moves back to the other command.
When we hit EOF `,` pushes `-1` instead and `.` throws an error because `-1` is not a valid character code. This might actually change in the future, but I haven't decided on this yet.
---
For reference, we can solve this without an error in **6 bytes** as follows
```
,)@
.(
```
Here, the `)` increments the byte we read, which gives `0` at EOF and something positive otherwise. If the value is `0`, the IP moves straight on, hitting the `@` which terminates the program. If the value was positive, the IP will instead take a right-turn towards the `(` which decrements the top of the stack back to its original value. The IP is now in a corner and will simply keep making right turns, printing with `.`, reading a new byte with `.`, before it hits the fork at `)` once again.
[Answer]
# X86 assembly, 70 bytes
Disassembly with `objdump`:
```
00000000 <.data>:
   0:   66 83 ec 01             sub    sp,0x1
   4:   66 b8 03 00             mov    ax,0x3
   8:   00 00                   add    BYTE PTR [eax],al
   a:   66 31 db                xor    bx,bx
   d:   66 67 8d 4c 24          lea    cx,[si+0x24]
  12:   ff 66 ba                jmp    DWORD PTR [esi-0x46]
  15:   01 00                   add    DWORD PTR [eax],eax
  17:   00 00                   add    BYTE PTR [eax],al
  19:   cd 80                   int    0x80
  1b:   66 48                   dec    ax
  1d:   78 1c                   js     0x3b
  1f:   66 b8 04 00             mov    ax,0x4
  23:   00 00                   add    BYTE PTR [eax],al
  25:   66 bb 01 00             mov    bx,0x1
  29:   00 00                   add    BYTE PTR [eax],al
  2b:   66 67 8d 4c 24          lea    cx,[si+0x24]
  30:   ff 66 ba                jmp    DWORD PTR [esi-0x46]
  33:   01 00                   add    DWORD PTR [eax],eax
  35:   00 00                   add    BYTE PTR [eax],al
  37:   cd 80                   int    0x80
  39:   eb c9                   jmp    0x4
  3b:   66 b8 01 00             mov    ax,0x1
  3f:   00 00                   add    BYTE PTR [eax],al
  41:   66 31 db                xor    bx,bx
  44:   cd 80                   int    0x80
```
The source:
```
sub esp, 1
t:
mov eax,3
xor ebx,ebx
lea ecx,[esp-1]
mov edx,1
int 0x80
dec eax
js e
mov eax,4
mov ebx,1
lea ecx,[esp-1]
mov edx,1
int 0x80
jmp t
e:
mov eax,1
xor ebx,ebx
int 0x80
```
[Answer]
# [><>](http://esolangs.org/wiki/Fish), 7 bytes
```
i:0(?;o
```
Try it [here](http://fishlanguage.com/playground/u7ttRxRqTCymDDNe6).
Explanation:
```
i:0(?;o
i        Take a character from input, pushing -1 if the input is empty
 :0(     Check if the input is less than 0, pushing 1 if true, 0 if false
    ?;   Pop a value of the top of the stack, ending the program if the value is non-zero
      o  Otherwise, output then loop around to the left and repeat
```
If you want it to keep going until you give it more input, replace the `;` with `!`.
[Answer]
# [Universal Lambda](https://esolangs.org/wiki/Universal_Lambda), 1 byte
```
!
```
A Universal Lambda program is an encoding of a lambda term in binary, chopped into chunks of 8 bits, padding incomplete chunks with *any* bits, converted to a byte stream.
The bits are translated into a lambda term as follows:
* `00` introduces a lambda abstraction.
* `01` represents an application of two subsequent terms.
* `111..10`, with *n* repetitions of the bit `1`, refers to the variable of the *n*th parent lambda; i.e. it is a [De Bruijn index](https://en.wikipedia.org/wiki/De_Bruijn_index) in unary.
By this conversion, `0010` is the identity function `λa.a`, which means any single-byte program of the form `0010xxxx` is a `cat` program.
[Answer]
# C, 40 bytes
```
main(i){while(i=~getchar())putchar(~i);}
```
[Answer]
# [Cubix](https://github.com/ETHproductions/cubix), ~~6~~ 5 bytes
*Now handles null bytes!*
```
@_i?o
```
Cubix is a 2-dimensional, stack-based esolang. Cubix is different from other 2D langs in that the source code is wrapped around the outside of a cube.
[Test it online!](https://ethproductions.github.io/cubix) Note: there's a 50 ms delay between iterations.
## Explanation
The first thing the interpreter does is figure out the smallest cube that the code will fit onto. In this case, the edge-length is 1. Then the code is padded with no-ops `.` until all six sides are filled. Whitespace is removed before processing, so this code is identical to the above:
```
  @
_ i ? o
  .
```
Now the code is run. The IP (instruction pointer) starts out on the far left face, pointing east.
The first char the IP encounters is `_`, which is a mirror that turns the IP around if it's facing north or south; it's currently facing east, so this does nothing. Next is `i`, which inputs a byte from STDIN. `?` turns the IP left if the top item is negative, or right if it's positive. There are three possible paths here:
* If the inputted byte is -1 (EOF), the IP turns left and hits `@`, which terminates the program.
* If the inputted byte is 0 (null byte), the IP simply continues straight, outputting the byte with `o`.
* Otherwise, the IP turns right, travels across the bottom face and hits the mirror `_`. This turns it around, sending it back to the `?`, which turns it right again and outputs the byte.
I think this program is optimal. Before Cubix could handle null bytes (EOF was 0, not -1), this program worked for everything but null bytes:
```
.i!@o
```
---
I've written a [brute-forcer](https://jsfiddle.net/09z5sr3o/3/) to find all 5-byte cat programs. Though it takes ~5 minutes to finish, the latest version has found 5 programs:
```
@_i?o   (works as expected)
@i?o_   (works in exactly the same way as the above)
iW?@o   (works as expected)
?i^o@   (false positive; prints U+FFFF forever on empty input)
?iWo@   (works as expected)
```
[Answer]
## PowerShell, ~~88~~ ~~41~~ 30 Bytes
```
$input;write-host(read-host)-n
```
EDIT -- forgot that I can use the `$input` automatic variable for pipeline input ... EDIT2 -- don't need to test for existence of `$input`
Yeah, so ... STDIN in PowerShell is ... weird, shall we say. With the assumption that we need to accept input from *all* types of STDIN, this is one possible answer to this catalogue, and I'm sure there are others.1
Pipeline input in PowerShell doesn't work as you'd think, though. Since piping in PowerShell is a function of the language, and not a function of the environment/shell (and PowerShell isn't really *solely* a language anyway), there are some quirks to behavior.
For starters, and most relevant to this entry, the pipe isn't evaluated instantaneously (most of the time). Meaning, if we have `command1 | command2 | command3` in our shell, `command2` will not take input or start processing until `command1` completes ... *unless* you encapsulate your `command1` with a `ForEach-Object` ... which is *different* than `ForEach`. (even though `ForEach` is an alias for `ForEach-Object`, but that's a separate issue, since I'm talking `ForEach` as the statement, not alias)
This would mean that something like `yes | .\simple-cat-program.ps1` (even though `yes` doesn't really exist, but whatever) wouldn't work because `yes` would never complete. If we could do `ForEach-Object -InputObject(yes) | .\simple-cat-program.ps1` that should (in theory) work.
[Getting to Know ForEach and ForEach-Object](http://blogs.technet.com/b/heyscriptingguy/archive/2014/07/08/getting-to-know-foreach-and-foreach-object.aspx) on the Microsoft "Hey, Scripting Guy!" blog.
So, all those paragraphs are explaining why `if($input){$input}` exists. We take an input parameter that's specially created automatically if pipeline input is present, test if it exists, and if so, output it.
Then, we take input from the user `(read-host)` via what's essentially a separate STDIN stream, and `write-host` it back out, with the `-n` flag (short for `-NoNewLine`). Note that this does not support arbitrary length input, as `read-host` will only complete when a linefeed is entered (technically when the user presses "Enter", but functionally equivalent).
Phew.
1But there are other options:
For example, if we were concerned with *only* pipeline input, and we didn't require a full program, you could do something like  `| $_` which would just output whatever was input. (In general, that's somewhat redundant, since PowerShell has an implicit output of things "left behind" after calculations, but that's an aside.)
If we're concerned with only interactive user input, we could use just `write-host(read-host)-n`.
~~Additionally, this function has the ~~quirk~~ feature of accepting command-line input, for example `.\simple-cat-program.ps1 "test"` would populate (and then output) the `$a` variable.~~
[Answer]
# [MarioLANG](http://esolangs.org/wiki/MarioLANG#Examples), 11 bytes
```
,<
."
>!
=#
```
I'm not entirely sure this is optimal, but it's the shortest I found.
This supports infinite streams and will terminate with an error upon reaching EOF (at least the Ruby reference implementation does).
There's another version of this which turns Mario into a ninja who can double jump:
```
,<
.^
>^
==
```
In either case, Mario starts falling down the left column, where `,` reads a byte and `.` writes a byte (which throws an error at EOF because `,` doesn't return a valid character). `>` ensures that Mario walks to the right (`=` is just a ground for him to walk on). Then he moves up, either via a double jump with `^` or via an elevator (the `"` and `#` pair) before the `<` tells him to move back to the left column.
[Answer]
## [INTERCALL](https://github.com/theksp25/INTERCALL), 133 bytes
wat
```
INTERCALL IS A ANTIGOLFING LANGUAGE
SO THIS HEADER IS HERE TO PREVENT GOLFING IN INTERCALL
THE PROGRAM STARTS HERE:
READ
PRINT
GOTO I
```
[Answer]
# [rs](https://github.com/kirbyfan64/rs), 0 bytes
```
```
Seriously. rs just prints whatever it gets if the given script is completely empty.
[Answer]
# Vitsy, 2 bytes
```
zZ
```
`z` gets all of the input stack and pushes it to the active program stack. `Z` prints out all of the active stack to STDOUT.
Alternate method:
```
I\il\O
I\      Repeat the next character for input stack's length.
  i     Grab an item from the input.
   l\   Repeat the next character for the currently active program stack's length.
     O  Output the top item of the stack as a character.
```
[Answer]
# [V](http://github.com/DJMcMayhem/V), 0 bytes
[Try it online!](http://v.tryitonline.net/#code=&input=VGhlIGVtcHR5IHByb2dyYW0gcHJpbnRzIGl0cyBpbnB1dC4g)
V's idea of "memory" is just a gigantic 2D array of characters. Before any program is ran, all input it loaded into this array (known as "The Buffer"). Then, at the end of any program, all text in the buffer is printed.
In other words, the empty program *is* a cat program.
[Answer]
## [Half-Broken Car in Heavy Traffic](http://esolangs.org/wiki/Half-Broken_Car_in_Heavy_Traffic), 9 + 3 = 12 bytes
```
#<
o^<
 v
```
Half-Broken Car in Heavy Traffic (HBCHT) takes input as command line args, so run like
```
py -3 hbcht cat.hbc -s "candy corn"
```
Note that the +3 is for the `-s` flag, which outputs as chars. Also, HBCHT doesn't seem handle NULs, as all zeroes are dropped from the output (e.g. `97 0 98` is output as two chars `ab`).
### Explanation
In HBCHT, your car starts at the `o` and your goal is the exit `#`. `^>v<` direct the car's movement, while simultaneously modifying a BF-like tape (`^>v<` translate to `+>-<`). However, as the language name suggests, your car can only turn right – any attempts to turn left are ignored completely (including their memory effects). Note that this is only for turning – your car is perfectly capable of driving forward/reversing direction.
Other interesting parts about HBCHT are that your car's initial direction is randomised, and the grid is toroidal. Thus we just need the car to make it to the exit without modifying the tape for all four initial directions:
* Up and down are straightforward, heading directly to the exit.
* For left, we wrap and execute `<` and increment with `^`. We can't turn left at the next `<` so we wrap and decrement with `v`, negating out previous increment. Since we're heading downwards now we can turn right at the `<` and exit, having moved the pointer twice and modifying no cell values.
* For right, we do the same thing as left but skip the first `^` since we can't turn left.
---
**Edit**: It turns out that the HBCHT interpreter does let you execute just a single path via a command line flag, e.g.
```
py -3 hbcht -d left cat.hbc
```
However, not only is the flag too expensive for this particular question (at least 5 bytes for `" -d u"`), it seems that all paths still need to be able to make it to the exit for the code to execute.
[Answer]
# [Seed](https://github.com/TryItOnline/seed), ~~3883~~ ~~3864~~ 10 bytes
```
4 35578594
```
[Try it online!](https://tio.run/##K05NTfn/30TB2NTU3MLU0uT//8SkZAA "Seed – Try It Online")
This is one of the stupidest things I have ever done.
[Answer]
# GolfScript, 3 bytes
```
:n;
```
The empty program echoes standard input. The language cannot possibly handle infinite streams. However, it appends a newline, as @Dennis mentioned. It does so by wrapping the whole stack in an array and calling `puts`, which is defined as `print n print`, where `n` is a newline. However, we can redefine `n` to be STDIN, and then empty the stack, which is precisely what `:n;` does.
[Answer]
## [Snowman 1.0.2](https://github.com/KeyboardFire/snowman-lang/releases/tag/v1.0.2-beta), 15 chars
```
(:vGsP10wRsp;bD
```
Taken [directly from Snowman's `examples` directory](https://github.com/KeyboardFire/snowman-lang/blob/master/examples/cat.snowman). Reads a line, prints a line, reads a line, prints a line...
Note that due to an implementation detail, when STDIN is empty, `vg` will return the same thing as it would for an empty line. Therefore, this will repeatedly print newlines in an infinite loop once STDIN is closed. This may be fixed in a future version.
Explanation of the code:
```
(        // set two variables (a and f) to active—this is all we need
:...;bD  // a "do-loop" which continues looping as long as its "return value"
         // is truthy
  vGsP   // read a line, print the line
  10wRsp // print a newline—"print" is called in nonconsuming mode; therefore,
         // that same newline will actually end up being the "return value" from
         // the do-loop, causing it to loop infinitely
```
[Answer]
## [Minkolang](https://github.com/elendiastarman/Minkolang), 5 bytes
```
od?.O
```
[Try it here.](http://play.starmaninnovations.com/minkolang/?code=od%3F%2EO&input=Hello%20world!)
### Explanation
`o` reads in a character from input and pushes its ASCII code onto the stack (`0` if the input is empty). `d` then duplicates the top of stack (the character that was just read in). `?` is a conditional trampoline, which jumps the next instruction of the top of stack is not `0`. If the input was empty, then the `.` is not jumped and the program halts. Otherwise, `O` outputs the top of stack as a character. The toroidal nature of Minkolang means that this loops around to the beginning.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 0 bytes
```
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCIiLCIiLCIxIl0=)
Implicitly inputs then implicitly outputs. Stretching the rules a *teeny* bit. Specifically the following rule:
>
> The only exception being if your language absolutely always prints a trailing newline after execution.
>
>
>
In Vyxal, "printing after execution" (implicit, not explicit printing) always prints with a newline.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~50~~ 38 bytes
```
[“€¬((a=IO.‚Ø 9)!=:eof)€· IO.‡í€…„–“.E
```
[Try it online](https://tio.run/##yy9OTMpM/f8/@lHDnEdNaw6t0dBItPX013vUMOvwDAVLTUVbq9T8NE2Q1HYFsPjCw2uBvEcNyx41zHvUMBmoT8/1/3@P1JycfB2F8PyinBRFLiCoU3RQVlGNU9PS0IzX5kowNDI2MTUzt7A00LXlio6NsVbX0dPnqq6tsVKysbPn4goMdw0KiQz19A9wDHZxc/fw8vaJinAOc/Lz5XJ0cnZxBQp5AsV8/fwDAoOCQ0LDwiMio7i4CstTi0oqSzPzCxKLU9LSM7Kyc6oqksuS8nK5EpOSU1KBQplAsdy8/ILCouKS0rLyisoqAA "05AB1E – Try It Online") or [test an infinite stream](https://tio.run/##S0oszvifnFhiY@Pq72YXb12ZWlxTUqSgm6IQE5NXo59fUKKfX5yYlJkKpRTi/0c/apjzqGnNoTUaGom2nv56jxpmHZ6hYKmpaGuVmp@mCZLargAWX3h4LZD3qGHZo4Z5jxomA/Xpuf4H2vMfAA "Bash – Try It Online").
# Explanation
This is probably the first *real* 05AB1E cat posted here. While my previous answer (`?`) mostly worked...
>
> If it is at all possible in your language to support an arbitrary infinite input stream (i.e. if you can start printing bytes to the output before you hit EOF in the input), your program has to work correctly in this case.
>
>
>
And while there seems to be no way of doing this in 05AB1E, making `?` the shortest possible answer, there is one not very commonly used command that does the trick. `.E` pops a string and runs it as an Elixir program.
In this case, we use the following Elixir code:
```
a = IO.read(x)
if a != :eof do
    IO.write(a)
end
```
…where `x` is the number of bytes to read each time — the greater it is, the faster the program runs. It can be anything but `:all`, as that would be equivalent to my previous submission, invalidating it.
We can golf this down to:
```
if((a=IO.read x)!=:eof)do IO.write a end
```
By now, you might've realized that this program only ever outputs the first `x` bytes of input. But running the Elixir code isn't the only thing the program does. It runs it over and over in an infinite loop (`[`)!
The weird symbols you see in the 05AB1E program are dictionary compression – compressing English words or other common letter combinations into just two bytes each. By substituting in `9` for `x` in the Elixir program (making the program as fast as it can be while not raising the bytecount), we get the final program!
]


[Question]
      [
An 'Even string' is any string where the [parity](https://en.wikipedia.org/wiki/Parity_(mathematics)) of the ASCII values of the characters is always alternating. For example, the string `EvenSt-ring$!` is an even-string because the ASCII values of the characters are:
```
69 118 101 110 83 116 45 114 105 110 103 36 33
```
And the parities of these numbers are:
```
Odd Even Odd Even Odd Even Odd Even Odd Even Odd Even Odd
```
Which is alternating the whole way. However, a string like `Hello world!` is *not* an even string because the ASCII values are:
```
72 101 108 108 111 32 87 111 114 108 100 33
```
And the parities are:
```
Even Odd Even Even Odd Even Odd Odd Even Even Even Odd
```
Which is clearly not always alternating.
# The challenge
You must write either a full program or a function that accepts a string for input and outputs a [truthy](http://meta.codegolf.stackexchange.com/q/2190/31716) value if the string is even, and a falsy value otherwise. You can take your input and output in any reasonable format, and you can assume that the input will only have [printable ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) (the 32-127 range). You do *not* have to handle empty input.
# Examples
Here are some examples of even strings:
```
#define
EvenSt-ring$!
long
abcdABCD
3.141
~
0123456789
C ode - g ol!f
HatchingLobstersVexinglyPopulateJuvenileFoxglove
```
And all of these examples are not even strings:
```
Hello World
PPCG
3.1415
babbage
Code-golf
Standard loopholes apply
Shortest answer in bytes wins
Happy golfing!
```
You may also use [this ungolfed solution](http://julia.tryitonline.net/#code=c3RyID0gcmVhZGxpbmUoU1RESU4pCmV2ZW4gPSB0cnVlCnBhcml0eSA9IEludChzdHJbMV0pICUgMgpmb3IgYyBpbiBzdHJbMjplbmRdCiAgbmV3UGFyaXR5ID0gSW50KGMpICUgMgogIGlmIG5ld1Bhcml0eSA9PSBwYXJpdHkKICAgIGV2ZW4gPSBmYWxzZQogIGVuZAogIHBhcml0eSA9IG5ld1Bhcml0eQplbmQKcHJpbnQoZXZlbik&input=MDEyMzQ1Njc4OQ) to test any strings if you're curious about a certain test-case.

[Answer]
# [MATL](http://github.com/lmendo/MATL), ~~4~~ 3 bytes
Thanks to *Emigna* for saving a byte and thanks to *Luis Mendo* for fixing some bugs. Code:
```
doA
```
Explanation:
```
d     # Difference between the characters
 o    # Mod 2
  A   # Matlab style all
```
[Try it online!](http://matl.tryitonline.net/#code=ZG9B&input=J0hhdGNoaW5nTG9ic3RlcnNWZXhpbmdseVBvcHVsYXRlSnV2ZW5pbGVGb3hnbG92ZSc)
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), ~~5~~ 4 bytes
Saved 1 byte thanks to *Adnan*.
```
Ç¥ÉP
```
[Try it online!](http://05ab1e.tryitonline.net/#code=w4fCpcOJUA&input=QyBvZGUgLSBnIG9sIWY)
**Explanation**
```
Ç       # convert to ascii values
 ¥      # compute delta's
  É     # mod by 2
   P    # product
```
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), ~~7~~ ~~5~~ 4 bytes
```
OIḂẠ
```
Saved 2 bytes using the deltas idea from @[Steven H.](https://codegolf.stackexchange.com/a/96063/6710)
Saved 1 byte thanks to @[Lynn](https://codegolf.stackexchange.com/users/3852/lynn).
[Try it online!](http://jelly.tryitonline.net/#code=T0nhuILhuqA&input=&args=RXZlblN0LXJpbmckIQ) or [Verify all test cases.](http://jelly.tryitonline.net/#code=T0nhuILhuqAKw4figqw&input=&args=JyNkZWZpbmUnLCdFdmVuU3QtcmluZyQhJywnbG9uZycsJ2FiY2RBQkNEJywnMy4xNDEnLCd-JywnMDEyMzQ1Njc4OScsJ0Mgb2RlIC0gZyBvbCFmJywnSGVsbG8gV29ybGQnLCdQUENHJywnMy4xNDE1JywnYmFiYmFnZScsJ0NvZGUtZ29sZicsJ1N0YW5kYXJkIGxvb3Bob2xlcyBhcHBseScsJ1Nob3J0ZXN0IGFuc3dlciBpbiBieXRlcyB3aW5zJywnSGFwcHkgZ29sZmluZyEn)
## Explanation
```
OIḂẠ  Input: string S
O     Ordinal
 I    Increments
  Ḃ   Mod 2
   Ạ  All, 0 if it contains a falsey value, else 1
```
[Answer]
# Python 2, 54 Bytes
```
lambda s:all((ord(x)-ord(y))%2for x,y in zip(s,s[1:]))
```
[Answer]
# Mathematica, ~~50~~ 44 bytes
*The current version is basically all Martin Ender's virtuosity.*
```
Differences@ToCharacterCode@#~Mod~2~FreeQ~0&
```
Returns `True` or `False`. Nothing too clever: takes the mod-2 sum of each pair of consecutive ASCII codes, and checks that 0 is never obtained.
Old version:
```
Union@Mod[Most[a=ToCharacterCode@#]+Rest@a,2]=={1}&
```
[Answer]
# JavaScript (ES6), ~~60~~ ~~50~~ 46 bytes
```
s=>[...s].every(c=>p-(p=c.charCodeAt()%2),p=2)
```
I tried recursion, but at 51 bytes, it doesn't seem to be quite worth it:
```
f=([c,...s],p=2)=>c?p-(p=c.charCodeAt()%2)&f(s,p):1
```
### Test snippet
```
f=s=>[...s].every(c=>p-(p=c.charCodeAt()%2),p=2)
```
```
<input id=I value="Evenst-ring"><button onclick="console.log(f(I.value))">Run</button>
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), ~~138~~ ~~114~~ ~~112~~ 84 + 3 = 87 bytes
Thanks to [@Riley](https://codegolf.stackexchange.com/users/57100/riley) for help golfing.
This program treats empty input as a noneven string.
```
{({}(())){({}[()]<(()[{}])>)}{}(({})<>[[]{}]()){{}(<>)}{}({}<>)<>}<>(([])[()]){<>}{}
```
[Try it online!](http://brain-flak.tryitonline.net/#code=eyh7fSgoKSkpeyh7fVsoKV08KCgpW3t9XSk-KX17fSgoe30pPD5bW117fV0oKSl7e30oPD4pfXt9KHt9PD4pPD59PD4oKFtdKVsoKV0pezw-fXt9&input=RXZlblN0LXJpbmcgQyBvZGUgLSBnIG9sIWY&args=LWE)
## Explanation (outdated)
Shifts the input from the left stack to the right while modding by 2. Finds the difference between each adjacent character until all have been checked or one of the differences is equal to zero (which would only occur in a noneven string). If the loop terminated due to a noneven string then switch back to the left stack and pop the value remaining on it. Otherwise, stay on the right stack and pop the zero above the 1 remaining on the stack.
[Answer]
## R, 41 35 bytes
EDIT:
Saved a few bytes thanks to @JDL by using `diff` instead of `rle`.
```
all(diff(utf8ToInt(readline())%%2))
```
---
```
all(rle(utf8ToInt(readline())%%2)[[1]]<2)
```
**Explanation**
1. `readline()` read input.
2. `utf8ToInt()%%2` convert to ascii values and mod 2 (store as R-vector)
3. `all(rle()==1)` run length encoding of to find runs. All runs should be equal to one or smaller than 2 since no runs cant be negative or 0 (saves one byte instead of `==`).
[Answer]
# Pyth ([fork](https://github.com/Steven-Hewitt/pyth)), 9 bytes
```
.A%R2.+CM
```
No Try It Online link because the fork does not have its own version in the online interpreters.
Explanation:
```
       CM       Map characters to their ASCII codes.
     .+         Get deltas (differences between consecutive character codes)
  %R2           Take the modulo of each base 2
.A              all are truthy (all deltas are odd)
```
[Answer]
# [Brachylog](http://github.com/JCumin/Brachylog), 17 bytes
```
@c:{:2%}a@b:{l1}a
```
[Try it online!](http://brachylog.tryitonline.net/#code=QGM6ezoyJX1hQGI6e2wxfWE&input=IkV2ZW5TdC1yaW5nJCEi)
### Explanation
```
@c                   Input to a list of char codes
  :{:2%}a            Apply X mod 2 for each X in the list of char codes
         @b          Split the list into a list of lists where each sublist elements are the
                       same, e.g. turn [1,0,1,1,0,0] into [[1],[0],[1,1],[0,0]]
           :{l1}a    The length of each sublist must be 1
```
[Answer]
# Java 8, ~~77~~ ~~76~~ ~~72~~ 57 bytes
```
a->{int i=2,b=1;for(int c:a)b=i==(i=c%2)?0:b;return b>0;}
```
-4 bytes thanks to *@Geobits*.
**Explanation:**
[Try it online.](https://tio.run/##nZTfb9MwEMff@1dcC0iJWLK22/jRKEMjY1SITZWK4AHxcHacxMPzRbbTLZrKv16cbm8DJPxi6ez7fO9O95WvcYMJtUJflz93XKG1cIlS348ApHbCVMgFXA0hACNSAjXwiDdovv8AjDP/sB35wzp0ksMVaMhhh8npvcdB5vMDls@yikw0xHyBMctlnkcy5y/m8bvpgmVGuM5oYKfTbLvLBrG2Y8qLPWpuSJZw45uK1s5IXe8LP3R0eAhfTOeafrEP17114ialzqWtz3SRTnk0eVaKSmoxSR0Vvu8zY7CP4hhewuRgsp/gb@SHjdBrlwxFn48DeEW6DsCQ8fLsfXEegB6ls@NZAPcrgJnO5kfHJ69ev3kbABdApYAEaiA1rv5LQOkHiSU63vjVfCbmE4z9Ku58pPoVtZ1CJz51fn1SiQu6qxVtnhjgUd576AKVFf/00FIoRfCNjCoDhl2tio@hyzwJABkyhnWI4wu/laQmVQWwa4e6RFOCImob/1VYwLZVfYhUQ8YJ6wC1vRXGf0XAen8Bt1LbAL2lb6SHYS7vkPEfjbAdbXe/AQ)
```
a->{               // Method with character-array parameter and boolean return-type
  int i=2,         //  Integer `i`, starting at any integer not 0 or 1
      b=1;         //  Flag-integer `b`, starting at 1
  for(int c:a)     //  Loop over the input-array
    b=i==(i=c%2)?  //   If two adjacent characters were both odd or even:
       0           //    Set the flag-integer `b` to 0
      :            //   Else:
       b;          //    The flag-integer `b` remains the same
  return b>0;}     //  Return if the flag-integer `b` is still 1
```
[Answer]
# Brain-Flak 155 151 141 121
Includes +3 for -a
Saved 30 bytes thanks to [1000000000](https://codegolf.stackexchange.com/a/96107/57100)
```
{({}(())){({}[()]<(()[{}])>)}{}({}()<>)<>}<>{({}[({})]<(())>){((<{}{}>))}{}({}[()]<>)<>}<>{{}}([]<(())>){((<{}{}>))}{}
```
Output:
**truthy**: 1
**falsy**: 0 on top of the stack
[Try it online! (truthy)](http://brain-flak.tryitonline.net/#code=eyh7fSgoKSkpeyh7fVsoKV08KCgpW3t9XSk-KX17fSh7fSgpPD4pPD59PD57KHt9Wyh7fSldPCgoKSk-KXsoKDx7fXt9PikpfXt9KHt9WygpXTw-KTw-fTw-e3t9fShbXTwoKCkpPil7KCg8e317fT4pKX17fQ&input=QyBvZGUgLSBnIG9sIWY&args=LWE)
[Try it online! (falsy)](http://brain-flak.tryitonline.net/#code=eyh7fSgoKSkpeyh7fVsoKV08KCgpW3t9XSk-KX17fSh7fSgpPD4pPD59PD57KHt9Wyh7fSldPCgoKSk-KXsoKDx7fXt9PikpfXt9KHt9WygpXTw-KTw-fTw-e3t9fShbXTwoKCkpPil7KCg8e317fT4pKX17fQ&input=Q29kZS1nb2xm&args=LWE)
---
Better explanation coming later (if I can remember how it works after a few hours...)
```
#compute ((mod 2) + 1) and put on other stack
{({}(())){({}[()]<(()[{}])>)}{}({}()<>)<>}<>
#compare top two (remove top 1) push on other stack (-1 for different 0 for same)
{({}[({})]<(())>){((<{}{}>))}{}({}[()]<>)<>}<>
#remove all of the top -1s
{{}}
#take the logical not of the stack height
([]<(())>){((<{}{}>))}{}
```
[Answer]
# [Starry](https://esolangs.org/wiki/Starry), 85 bytes
```
 ,       +    *   ` , +               + * ' +  ' `       +    * +   + *   '     +  `.
```
[Try it online!](http://starry.tryitonline.net/#code=ICwgICAgICAgKyAgICAqICAgYCAsICsgICAgICAgICAgICAgICArICogJyArICAnIGAgICAgICAgKyAgICAqICsgICArICogICAnICAgICArICBgLg&input=RXZlblN0LXJpbmcgQyBvZGUgLSBnIG9sIWYK)
Note that since a Starry program has no way of telling when an input of arbitrary length ends, this program uses a trailing newline in the input to mark the end of the string. If you get a cryptic error message about and undefined method `ord` for `nil:NilClass` then the input is missing a trailing newline.
## Explanation
The basic strategy that the program employs is it reads the characters one by one from input and if they are not a newline (character 10) it mods they ASCII value of the character by 2 and finds the difference between it and the previously read character. If the difference is zero the program terminates and prints `0` (falsey). Otherwise the program loops back and does the process over again. If the program reads a newline it terminates and prints `10` (truthy).
### Annotated Program
```
 ,               Push the first character
       +         Push 2
    *            Replace the first character and 2 with the first character mod 2
   `             Label 3 <--------------------------------------------------------\
 ,               Push the next the character                                      |
 +               Push a duplicate of it                                           |
               + Push 10                                                          |
 *               Replace the 10 and the duplicate with their difference           |
 '               Pop and if not zero (the read char is not 10) goto label 1 >-\   |
 +               Push a duplicate of the character which must be newline (10) |   |
  '              Pop and goto label 2 >---------------------------------------+-\ |
 `               Label 1 <----------------------------------------------------/ | |
       +         Push 2                                                         | |
    *            Replace the character and 2 with the character mod 2           | |
 +               Duplicate it ^                                                 | |
   +             Roll the top three items on the stack. The top goes to         | |
                   the bottom. The top three items are now                      | |
                   (from top to bottom) the current character, the previous     | |
                   character, the current character (all modded by 2).          | |
 *               Replace the current character and previous character           | |
                   with their difference                                        | |
   '             Pop if nonzero goto label 3 >----------------------------------+-/
     +           Push zero                                                      |
  `              Label 2 <------------------------------------------------------/
.                Print out the number on top of the stack
                    0 if we came by not following the goto label 3
                   10 if we came by going to label 2
```
[Answer]
## Perl, 24 + 1 (`-p`) = 25 bytes
*-4 bytes thanks to [@Ton Hospel](https://codegolf.stackexchange.com/users/51507/ton-hospel) !*
```
s/./$&&v1/eg;$_=!/(.)\1/
```
Needs `-p` flag. Outputs 1 is the string is even, nothing otherwise. For instance :
```
perl -pe 's/./$&&v1/eg;$_=!/(.)\1/' <<< "#define
Hello World"
```
*Explanations* : replaces each character by its value mod 2 (so the string contains only 0s and 1s after that). Then search for two following 1 or 0 : if it finds some, then the string isn't even, otherwise it is.
[Answer]
# J, 15 bytes
```
0=1#.2=/\2|3&u:
```
## Usage
```
   f =: 0=1#.2=/\2|3&u:
   f 'C ode - g ol!f'
1
   f 'Code-golf'
0
```
## Explanation
```
0=1#.2=/\2|3&u:  Input: string S
           3&u:  Get ordinals of each char
         2|      Take each modulo 2
     2  \        For each pair of values
      =/           Test if they are equal, 1 if true else 0
  1#.            Treat the list of integers as base 1 digits and convert to decimal
                 This is equivalent to taking the sum
0=               Is it equal to 0, 1 if true else 0, and return
```
[Answer]
# Vim, 38 bytes
`qqs<C-R>=char2nr(@")%2<CR><Esc>l@qq@q:g/00\|11/d<CR>`
Assumes input string in buffer, and empty `"q`. Outputs binary nonsense if true, nothing if false.
* `s<C-R>=char2nr(@")%2<CR>`: Replaces a character with 1 if odd, 0 if even. The macro this is in just does this to every character in the line (no matter how long it is).
* `:g/00\|11/d<CR>`: Deletes the line if 2 consecutive "bits" have the same value. Faster than a back-reference.
Normally, in vimgolf, when you use an expression function inside a macro, you're supposed to do the macro itself on the expression register and use some trickery to tab-complete. That's more difficult this time. I may find a way to shorten that later.
[Answer]
## [Retina](http://github.com/mbuettner/retina), 39 bytes
Byte count assumes ISO 8859-1 encoding.
```
S_`
%{2`
$`
}T01`p`_p
..
Mm`.¶.|^¶$
^0
```
Outputs `1` for truthy and `0` for falsy.
[Try it online!](http://retina.tryitonline.net/#code=JShHYApTX2AKJXsyYAokYAp9VDAxYHBgX3AKLi4KCk1tYC7Cti58XsK2JApeMA&input=I2RlZmluZQpFdmVuU3QtcmluZyQhCmxvbmcKYWJjZEFCQ0QKMy4xNDEKfgowMTIzNDU2Nzg5CkMgb2RlIC0gZyBvbCFmCkhhdGNoaW5nTG9ic3RlcnNWZXhpbmdseVBvcHVsYXRlSnV2ZW5pbGVGb3hnbG92ZQpIZWxsbyBXb3JsZApQUENHCjMuMTQxNQpiYWJiYWdlCkNvZGUtZ29sZgpTdGFuZGFyZCBsb29waG9sZXMgYXBwbHkKU2hvcnRlc3QgYW5zd2VyIGluIGJ5dGVzIHdpbnMKSGFwcHkgZ29sZmluZyE) (The first line enables a linefeed-separated test suite.)
### Explanation
Inspired by a answer of mbomb007's [I recently developed a reasonably short `ord()` implementation](http://chat.stackexchange.com/transcript/message/32786271#32786271) in Retina. This is largely based on that, although I was able to make a few simplifications since I don't need a decimal result in since I only need to support printable ASCII (and I only care about the parity of the result, so ending up with an arbitrary offset is fine, too).
**Stage 1: Split**
```
S_`
```
This simply splits the input into its individual characters by splitting it around the empty match and dropping the empty results at the beginning and end with `_`.
**Stage 2: Replace**
```
%{2`
$`
```
The `%{` tells Retina a) that this stage and the next should be run in a loop until the string stops changing through a full iteration, and that these two stages should be applied to each line (i.e each character) of the input separately.
The stage itself is the standard technique for duplicating the first character of the input. We match the empty string (but only look at the first two matches) and insert the prefix of that match. The prefix of the first match (at the beginning of the string) is empty, so this doesn't do anything, and the prefix of the second match is the first character, which is therefore duplicated.
**Stage 3: Transliterate**
```
}T01`p`_o
```
`}` indicates the end of the loop. The stage itself is a transliteration. `01` indicates that it should only be applied to the first character of the string. `p` is shorthand for all printable ASCII characters and `_` means "delete". So if we expand this, the transliteration does the following transformation:
```
from:   !"#$%...
to:    _ !"#$...
```
So spaces are deleted and all other characters are decremented. That means, these two stages together will create a character range from space to the given character (because they'll repeatedly duplicate and decrement the first character until it becomes a space at which point the duplication and deletion cancel).
The length of this range can be used to determine the parity of the character.
**Stage 4: Replace**
```
..
```
We simply drop all pairs of characters. This clears even-length lines and reduces odd-length lines to a single character (the input character, in fact, but that doesn't really matter).
**Stage 5: Match**
```
Mm`.¶.|^¶$
```
It's easier to find inputs which *aren't* even, so we count the number of matches of either two successive empty lines or two successive non-empty lines. We should get `0` for even inputs and something non-zero otherwise.
**Stage 6: Match**
```
^0
```
All that's left is to invert the result, which we do by counting the number of matches of this regex, which checks that the input starts with a `0`. This is only possible if the result of the first stage was `0`.
[Answer]
# Clojure, 59 bytes
```
#(every?(fn[p](odd?(apply + p)))(partition 2 1(map int %)))
```
Generates all sequential pairs from string `n` and checks if every pair sum is odd. If a sequence of ints is considered a reasonable format then it's 50 bytes.
```
#(every?(fn[p](odd?(apply + p)))(partition 2 1 %))
```
See it online : <https://ideone.com/USeSnk>
[Answer]
## Julia, ~~55~~ 53 Bytes
```
f(s)=!ismatch(r"00|11",join(map(x->Int(x)%2,[s...])))
```
**Explained**
Map chars to 0|1 and check if the resulting string contains "00" or "11", which makes the string not alternating.
[Answer]
## Python, 52 bytes
```
f=lambda s:s==s[0]or(ord(s[0])-ord(s[1]))%2*f(s[1:])
```
A recursive function. Produces 1 (or True) for even strings, 0 for odd ones. Multiplies the parity of the difference of the first two characters by the recursive value on the remainder. A single-character string gives True, as checked by it equaling its first character. This assumes the input is non-empty; else, one more byte is needed for `s==s[:1]` or `len(s)<2`.
---
**Python 2, 52 bytes**
```
p=r=2
for c in input():x=ord(c)%2;r*=p-x;p=x
print r
```
Alternatively, an iterative solution. Iterates over the input characters, storing the current and previous character values mod 2. Multiplies the running product by the difference, which because 0 (Falsey) only when two consecutive parities are equal.
The "previous" value is initialized to 2 (or any value not 0 or 1) so that the first character never matches parity with the fictional previous character.
---
**Python, 42 bytes, outputs via exit code**
```
p=2
for c in input():x=ord(c)%2;p=x/(p!=x)
```
Outputs via exit code. Terminates with a ZeroDivisionError when two consecutive characters have the same parities, otherwise terminates cleanly.
[Answer]
## Haskell, ~~42~~ 40 bytes
```
all odd.(zipWith(-)=<<tail).map fromEnum
```
Usage example: `all odd.(zipWith(-)=<<tail).map fromEnum $ "long"` -> `True`.
How it works:
```
               map fromEnum         -- turn into a list of ascii values
    (zipWith(/=)=<<tail)            -- build a list of neighbor differences
all odd                             -- check if all differences are odd
```
Edit: @xnor saved two bytes. Thanks!
[Answer]
# Mathematica, ~~41~~ 40 Bytes
```
And@@OddQ@Differences@ToCharacterCode@#&
```
-1 character, thanks to Martin Ender
[Answer]
## C, 52 bytes
```
int f(char*s){return s[1]?(s[0]-s[1])%2?f(s+1):0:1;}
```
Compares the parity of first 2 characters, recursively moving through the string until it finds 2 characters with the same parity or the string with the length of 1 (`s[1] == 0`).
[Code with some of the test cases](https://ideone.com/eZpLvL)
[Answer]
# Ruby, ~~41~~ 30 (+1) bytes
```
p gsub(/./){$&.ord%2}!~/(.)\1/
```
Call this from the command line with the `-n` flag, like so:
```
ruby -ne 'p gsub(/./){$&.ord%2}!~/(.)\1/'
```
Replaces each character with the parity of its ASCII value and then compares to a regex. If even, the `=~` comparison will return the index of the first match (i.e. 0), which is a truthy value in Ruby; if not even, the comparison will return `nil`.
Thanks to Jordan for the improvements!
[Answer]
## Pyke, 8 bytes
```
m.o$2m%B
```
[Try it here!](http://pyke.catbus.co.uk/?code=m.o%242m%25B&input=Hello+World)
```
m.o      -    map(ord, input)
   $     -   delta(^)
    2m%  -  map(> % 2, ^)
       B - product(^)
```
[Answer]
# C#, 69 bytes
```
s=>{int i=1,e=0;for(;i<s.Length;)e+=(s[i-1]+s[i++]+1)%2;return e<1;};
```
Full program with test cases:
```
using System;
namespace EvenStrings
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<string,bool>f= s=>{int i=1,e=0;for(;i<s.Length;)e+=(s[i-1]+s[i++]+1)%2;return e<1;};

            Console.WriteLine(f("lno")); //false
            //true:
            Console.WriteLine(f("#define"));
            Console.WriteLine(f("EvenSt-ring$!"));
            Console.WriteLine(f("long"));
            Console.WriteLine(f("abcdABCD"));
            Console.WriteLine(f("3.141"));
            Console.WriteLine(f("~"));
            Console.WriteLine(f("0123456789"));
            Console.WriteLine(f("C ode - g ol!f"));
            Console.WriteLine(f("HatchingLobstersVexinglyPopulateJuvenileFoxglove"));

            //false:
            Console.WriteLine(f("Hello World"));
            Console.WriteLine(f("PPCG"));
            Console.WriteLine(f("3.1415"));
            Console.WriteLine(f("babbage"));
            Console.WriteLine(f("Code-golf"));
            Console.WriteLine(f("Standard loopholes apply"));
            Console.WriteLine(f("Shortest answer in bytes wins"));
            Console.WriteLine(f("Happy golfing!"));
        }
    }
}
```
[Answer]
# PHP, 69 Bytes
```
for(;$i<strlen($s=$argv[1])-1;)$d+=1-ord($s[$i++]^$s[$i])%2;echo$d<1;
```
solution with Regex 81 Bytes
```
for(;$i<strlen($s=$argv[1]);)$t.=ord($s[$i++])%2;echo 1-preg_match("#00|11#",$t);
```
[Answer]
## PowerShell v2+, 47 bytes
```
-join([char[]]$args[0]|%{$_%2})-notmatch'00|11'
```
(Can't *quite* catch PowerShell's usual competitors ...)
Takes input `$args[0]` as a string, casts it as a `char`-array, loops through it `|%{...}`, each iteration placing the modulo on the pipeline (with implicit `[char]` to `[int]` conversion). Those are encapsulated in parens and `-join`ed into a string, which is fed into the left-hand of the `-notmatch` operator, checking against `00` or `11` (i.e., returns `True` iff the `0`s and `1`s alternate). That Boolean result is left on the pipeline and output is implicit.
### Test Cases
```
PS C:\Tools\Scripts\golfing> '#define','EvenSt-ring$!','long','abcdABCD','3.141','~','0123456789','C ode - g ol!f','HatchingLobstersVexinglyPopulateJuvenileFoxglove'|%{"$_ --> "+(.\evenst-ring-c-ode-g-olf.ps1 $_)}
#define --> True
EvenSt-ring$! --> True
long --> True
abcdABCD --> True
3.141 --> True
~ --> True
0123456789 --> True
C ode - g ol!f --> True
HatchingLobstersVexinglyPopulateJuvenileFoxglove --> True
PS C:\Tools\Scripts\golfing> 'Hello World','PPCG','3.1415','babbage','Code-golf','Standard loopholes apply','Shortest answer in bytes wins','Happy golfing!'|%{"$_ --> "+(.\evenst-ring-c-ode-g-olf.ps1 $_)}
Hello World --> False
PPCG --> False
3.1415 --> False
babbage --> False
Code-golf --> False
Standard loopholes apply --> False
Shortest answer in bytes wins --> False
Happy golfing! --> False
```
[Answer]
# [><>](https://esolangs.org/wiki/Fish), ~~29~~ 27 bytes
```
i2%\0 n;n 1<
0:i/!?-}:%2^?(
```
Outputs 1 if the word is even, 0 if the word is odd.
You can [try it online](https://fishlanguage.com/playground).
Edit : saved two bytes thanks to Martin Ender
[Answer]
# [Perl 6](https://perl6.org), ~~47~~ 26 bytes
```
{?all .ords.rotor(2=>-1).map({(.[0]+^.[1])%2})}
```
```
{[~](.ords X%2)!~~/(.)$0/}
```
## Expanded:
```
# bare block lambda with implicit parameter $_
{
  [~](             # reduce using concatenation operator ( no space chars )
    .ords X[%] 2   # the ordinals cross modulus with 2 ( 1 or 0 )
  # ^-- implicit method call on $_
  )
  ![~~]            # negating meta operator combined with smartmatch operator
  / ( . ) $0 /     # is there a character followed by itself?
}
```
]


[Question]
      [
Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate).
## Input:
* A positive integer `n >= 1`.
## Output:
* `n` lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line.
## Test case (n=5):
```
    *
    **
    ***
    ****
    *****
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins.

[Answer]
# [tinylisp](https://github.com/dloscutoff/Esolangs/tree/master/tinylisp), 84 bytes
```
(load library
(d Q(q((A)(join(map string(map* repeat-val(repeat-val 42 A)(1to A)))nl
```
[Try it online!](https://tio.run/##RcuxCYAwEEbh3imu/E@wUFzAERzhxCAnZxJjEDJ91Mrqfc3L6ovpFWuFBVnJdEmSSoOVZpzAxNiDehwS6cpJ/faxpeSik9zdYvhJ40Dv0OfwhtlbxUw91wc "tinylisp – Try It Online")
# [tinylisp](https://github.com/dloscutoff/Esolangs/tree/master/tinylisp), 89 bytes
```
(d P(q((A N)(i(s N 1)(i(disp(string A))A(P(c 42 A)(s N 1)))(string A
(d Q(q((N)(P(q(42))N
```
[Try it online!](https://tio.run/##PcxBCoAgFIThfad4y5ll5gW8gOgZCuJBSKWbTv9SiHYD//A1Lc@h9TTDJgkXECQSiipR5jG2XlHbrWWXQAYkrOJd39@H/PPUkTyQTgzMOzIasiy0Fw "tinylisp – Try It Online")
the length of the library functions makes this surprisingly close to the library based one.
[Answer]
## Pyke, 6 bytes
```
Voh\**
```
[Try it here!](http://pyke.catbus.co.uk/?code=Voh%5C%2a%2a&input=5)
[Answer]
# [Brain-Flak](http://github.com/DJMcMayhem/Brain-Flak), 81 bytes
78 bytes but three for the `-A` flag, which enables ASCII output.
```
{(({}[()])<>()){({}[()]<(((((()()()){}())){}{}){})>)}{}((()()()()()){})<>}<>{}
```
[Try it online!](http://brain-flak.tryitonline.net/#code=eygoe31bKCldKTw-KCkpeyh7fVsoKV08KCgoKCgoKSgpKCkpe30oKSkpe317fSl7fSk-KX17fSgoKCkoKSgpKCkoKSl7fSk8Pn08Pnt9&input=NQ&args=LUE)
Brain-flak isn't the greatest language for ASCII-art, but it still managed to be somewhat short. Ish. Kinda.
Explanation:
```
While True:
{
(
Decrement counter
({}[()])
And move copy to other stack
<>())
Push N '*'s
{({}[()]<(((((()()()){}())){}{}){})>)}
Pop 0
{}
Push newline
((()()()()()){})
Move back to counter
<>
Endwhile
}
Move to other stack
<>
Pop an extra newline
{}
```
[Answer]
# Jolf, 7 bytes
This time, the builtin didn't let me win. Oh well.
```
―t0jj'*
```
[Try it here!](http://conorobrien-foxx.github.io/Jolf/#code=4oCVdDBqaicq&input=NQ)
## Explanation
```
―t0jj'*
―t0     pattern: left-corner-base triangle
   j     with <input> height
    j    and <input> width.
     '*  comprised of asterisks
```
[Answer]
## Racket 47 bytes
```
(for((i(+ 1 n)))(displayln(make-string i #\*)))
```
Ungolfed:
```
(define (f n)
  (for ((i (+ 1 n)))                         ; (i 5) in 'for' produces 0,1,2,3,4
    (displayln (make-string i #\*))))        ; #\* means character '*'
```
Testing:
```
(f 5)
```
Output:
```
*
**
***
****
*****
```
[Answer]
# Java 7,~~72~~ 70 bytes
*Thanks to @kevin for shave it off by 2 bytes.*
```
String f(int n,String s,String c){return n<1?c:f(--n,s+"*",c+s+"\n");}
```
### Output
```
*
**
***
****
*****
******
```
[Answer]
# Ruby, 27 (or 24) bytes
(Thanks to m-chrzan for pointing out the miscounting.)
Returns a string.
```
->n{(1..n).map{|i|?**i}*$/}
```
the `map` makes an array of strings of `*` of increasing length. The `*$/` takes the array and joins the elements to make a newline-separated string. If an array of strings is acceptable, these three bytes can be saved, scoring 24.
In test program
```
f=->n{(1..n).map{|i|?**i}*$/}
puts f[5]
```
[Answer]
# C++, 78 bytes
I don't know how there are 2 C++ answers that don't just do it with for loops. Very short and sweet this way:
```
void T(int n){for(int i=1;i<=n;i++){for(int j=0;j<i;j++)cout<<'*';cout<<'\n';}}
```
## Full program
```
#include <iostream>
using namespace std;
void T(int n)
{
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j < i; j++)
            cout << '*';
        cout << '\n';
    }
}
int main()
{
  T(5);
}
```
Edit: it is unclear to me whether to count the `#include<iostream>`, `using namespace std`, and/or `std::whatever` in calls. C/C++ answers all over this site seem to use both, and for the most part no one seems to care except for the occasional comment. If I need the `std::`, then +10. If I need the `#include<iostream>`, +18 ([although GCC allows me to do without the basic includes, so maybe not that one](https://codegolf.stackexchange.com/a/2204/56586))
[Answer]
# Java, 110 bytes
Not that short, but I really like having empty for loops.
```
String f(int n){String s="";for(int i=0;i<n;i++,s+=new String(new char[i]).replace("\0","*")+"\n"){}return s;}
```
[Answer]
# GameMaker Language, 68 bytes
```
a="*"for(i=2;i<=argument0;i++){a+="#"for(j=0;j<i;j++)a+="*"}return a
```
[Answer]
# Prolog, ~~60 58~~ 56 bytes
```
g(N):-N<=0,put(*),g(N-1);!.
f(N):-N<=0,f(N-1),g(N),nl;!.
```
I'm not that familiar with Prolog, but I just gave it a shot.
I'm sure it can be a lot shorter.
Put the code into a file, then load that file into swipl and run `f(25).` (or some other number).
*EDIT:* quotes can be left out in put statement
*EDIT 2:* changing `=:=` to `<=` saves 2 bytes. I tried inverting it, but that'd make it wait for a return for some reason.
[Answer]
# [Elixir](http://elixir-lang.org/), 81 bytes
```
&Enum.reduce(Enum.to_list(1..&1),"",fn(x,r)->r<>String.duplicate("*",x)<>"\n"end)
```
Anonymous function using the capture operator. `Enum.reduce` will iterate a list (the list is obtained by calling `Enum.to_list` on the range 1..n) and concatenate the return string `r` (which has been initialized with "") with a string made of `x` asterisks and a newline.
Full program with test case:
```
s=&Enum.reduce(Enum.to_list(1..&1),"",fn(x,r)->r<>String.duplicate("*",x)<>"\n"end)
IO.write s.(5)
```
**Try it online on [ElixirPlayground](http://elixirplayground.com/) !**
[Answer]
# Pyth, ~~10~~ 8 Bytes
thanks to Jakube for helping me shave off the extra 2 bytes!
```
VQ*Np"*"
```
[Try it](https://pyth.herokuapp.com/?code=VQ%2aNp%22%2a%22&input=5&debug=0)
[Answer]
**Brainfuck, 129 bytes**
I know there's already a shorter answer in brainfuck, however I wanted to create a program which could handle a multi-digit number input rather than either a single-digit input or a single ascii character input unlike the previous one posted.
```
,[>+++[->++++[-<<---->>]<]+>,]<-<<[<<]>>[<[->>++++++++++<<]>>>]+>>++++++++++>>++++++[-<+++++++>]<<<<<[>[->+>>.<<<]>>.<[-<+>]<+<-]
```
This is my first ever brainfuck program and it will work for any input between 0 and the maximum size of a single cell (traditionally 8 bits or 255) entered using the characters '0' to '9' (corresponding to ascii-values 048-057)
**Explanation**
The first part of this program, `,[>+++[->++++[-<<---->>]<]+>,]`, takes the input numbers as char values and removes 48 from each to make them equal to the numbers 0 to 9 rather than the char values of the numbers 0 to 9. It stores these in separate cells with a 1 in between each of them so that the start and end points can be found again.
The second part, `<-<<[<<]>>[<[->>++++++++++<<]>>>]`, consolidates the separate values into one cell. This is why the maximum size of a cell controls how high a number can be.
The third section, `+>>++++++++++>>++++++[-<+++++++>]<<<<<`, is used to set up the other cells needed: one with the number of asterisks per line, one with the code for a linefeed and one with the code for an asterisk. There is also a blank cell left for working with later.
The remainder of the code, `[>[->+>>.<<<]>>.<[-<+>]<+<-]`, is used to:
1. Output as many asterisks as necessary
2. Output a linefeed
3. Reset the value of the cell controlling the asterisks
4. Increment the control cell
5. Decrement the cell with the number until it equals 0
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), 11 bytes
```
'*×.pD¦`r`»
```
[Try it online!](http://05ab1e.tryitonline.net/#code=JyrDly5wRMKmYHJgwrs&input=NQ)
**Explanation:** (Prints hourglass)
```
                  Implicit input - 5
'*                Asterisk character - stack = '*'
  ×               Repeat input times - stack = '*****'
   .p             Get prefixes       - stack = ['*', '**', '***', '****', '*****']
     D            Duplicate last element
                  STACK = ['*', '**', '***', '****', '*****'] , ['*', '**', '***', '****', '*****']
      ¦           Remove first element from final list
                  STACK = ['*', '**', '***', '****', '*****'] , ['**', '***', '****', '*****']
       `r`        Reverse 1 list and flatten both
                  STACK = '*****','****','***','**','*','**','***','****','*****'
          »       Join by newlines and implicitly print
```
For input 5, prints:
```
*****
****
***
**
*
**
***
****
*****
```
[Answer]
# C++ 11, 65 bytes
Not including the `include` in the byte count.
```
#include<string>
using S=std::string;S g(int n){return n?g(n-1)+S(n,'*')+'\n':"";}
```
Usage:
```
std::cout << g(n) << std::endl;
```
[Answer]
# SQL, 153 Bytes
Golfed:
```
CREATE PROCEDURE P @n INT AS BEGIN DECLARE @a INT;SET @a=0;DECLARE @o VARCHAR(1000);SET @o='*'WHILE @a<@n BEGIN PRINT @o;SET @o=@o+'*'SET @a=@a+1;END;END
```
Ungolfed:
```
CREATE PROCEDURE P
@n INT
AS
BEGIN
DECLARE @a INT;
SET @a=0;
DECLARE @o VARCHAR(1000);
SET @o='*'
WHILE @a<@n
    BEGIN
    PRINT @o;
    SET @o=@o+'*'
    SET @a=@a+1;
END;
END
```
Testing:
```
EXEC P '6'
```
Output:
```
*
**
***
****
*****
******
```
[Answer]
# Crystal, 31 bytes
`n=5;(1..n).each{|x|puts "*"*x}`
Output:
```
*
**
***
****
*****
```
Really demonstrates the beauty of Crystal/Ruby. `n` is the integer input, `(1..n)` is an inclusive range from `1` to `n` (`[1, n]`). `.each` is a method on Range that runs the provided block for every integer in the range.
[Answer]
# [Dip](https://github.com/mcparadip/Dip), ~~6~~ 5 bytes
```
`**En
```
*-1 byte thanks to [Oliver](https://codegolf.stackexchange.com/users/12537/oliver)*
**Explanation:**
```
`**    Push "*" repeated input times
   E   Prefixes
    n  Join by newlines
```
[Answer]
# C, 88 bytes / 53 bytes
Using C89.
`g(a){a&&g(a-1);a<2||puts("");while(a--)putchar('*');}main(int a,char**v){g(atoi(v[1]));}`
With whitespace for clarity:
```
g(a) {
    a && g(a-1);
    a<2 || puts("");
    while (a--) putchar('*');
}
main(int a, char** v) {
    g(atoi(v[1]));
}
```
Without main, this function is 53 bytes:
`g(a){a&&g(a-1);a<2||puts("");while(a--)putchar('*');}`
[Answer]
# python3, ~~58~~ 57 bytes
```
print('\n'.join(['*'*(p+1)for p in range(int(input()))]))
```
Ungolfed:
```
rownums = int(input())
output = []
for i in range(rownums):
    currrow = "*" * (i+1) # 'i' * 5 == 'iiiii'
    output.append(currrow)
print('\n'.join(output))
```
[Answer]
# SmileBASIC, 30 bytes
```
INPUT N
FOR I=1TO N?"*"*I
NEXT
```
[Answer]
**Haskell 36 Bytes**
Here is a version using map.
```
f="*":map('*':)f;g=unlines.(`take`f)
```
Input `g 10`
Output `"*\n**\n***\n****\n*****\n******\n*******\n********\n*********\n**********\n"`
Alternatives of interest might be:
38 Bytes
```
g n=id=<<scanl(\x y->'*':x)"*\n"[2..n]
```
38 Bytes
```
f="*\n":map('*':)f;g n=id=<<(n`take`f)
```
36
```
g n=id=<<(take n$iterate('*':)"*\n")
```
[Answer]
# k, 18 bytes
```
{-1@(1+!x)#\:"*";}
```
Explanation:
```
-1@ // prints to console
1+!x //returns list from 1 to x (implicit input)
#\:  //for each item in the prefixed list, "take" this many
"*" //asterisk string
```
[Answer]
# [Perl 6](http://perl6.org/), 17 bytes
```
put(\*x++$)xx get
```
Full program that prints to stdout.
How it works:
```
    \*             # a Capture object that stringifies to the asterisk,
      x            # string-repeated by
       ++$         # a counter that starts at 1,
put(      )        # and printed followed by a newline.
           xx get  # Do all of that n times.
```
Invokes the `put` statement *n* times, each time printing the asterisk repeated by the counter variable `++$`.
---
# [Perl 6](http://perl6.org/), 21 bytes
```
{.put for \*Xx 1..$_}
```
A lambda that prints to stdout.
How it works:
```
{                   }  # A lambda.
          \*           # A Capture object that stringifies to the asterisk.
               1..$_   # Range from 1 to n.
            X          # Cartesian product of the two,
             x         # with the string repetition operator applied to each result.
 .put for              # Iterate over the strings, and print each followed by a newline.
```
[Answer]
# [Bash](https://www.gnu.org/software/bash/) + Unix utilities, 26 bytes
```
seq -f10^%f-1 $1|bc|tr 9 *
```
**Output to stderr should be ignored.**
[Try it online!](https://tio.run/nexus/bash#@1@cWqigm2ZoEKeql6ZrqKBiWJOUXFNSpGCpoPX//39TAA "Bash – TIO Nexus")
The code above works on TIO since the working directory there has no visible files. If this needs to run in a directory that contains a visible file, change `*` to `\*` at the cost of one byte (27 bytes):
```
seq -f10^%f-1 $1|bc|tr 9 \*
```
[Answer]
# Terrapin logo, 67 bytes
```
to a :a
make "b 1 repeat :a[repeat :b[type "*]make "b b+1 pr "]
end
```
[Answer]
# PHP, ~~43~~ ~~34~~ ~~31~~ 28 bytes
Note: uses IBM 850 encoding (old favorite reinvented recently)
```
for(;$argn--;)echo$o.=~ı,~§;
```
Run like this:
```
echo 5 | php -nR 'for(;$argn--;)echo$o.=~ı,~§;';echo
> *
> **
> ***
> ****
> *****
```
# Explanation
Iterates from `N` down to 0. Add an asterisk to `$o` for each iteration, then outputs `$o` and a newline.
# Tweaks
* Add an asterisk to `$o` for each iteration, and then output `$o`. Saves 9 bytes
* Combined adding an asterisk to `$o` with outputting, saves 3 bytes
* Saved 3 bytes by using `$argn`
[Answer]
## K, 16 Bytes
```
 {-1(1+!x)#'"*"};
  {-1(1+!x)#'"*"}10;
*
**
***
****
*****
******
*******
********
*********
**********
```
EDIT BELOW - adding explanation)
```
/Code     ---> explanation (pretend x is 3)
1+!x      ---> Numbers from 1 to 3
1 2 3#"*" ---> Take left many items of right ==> ("*";"**";"***")
-1x       ---> Print x to the console, if x is a list, each item is printed to a new line
example(notice the -1 printed at the bottom).
     -1("*";"**";"***")
     *
     **
     ***
     -1
To silence the output(-1), put a semicolon after the expression e.g.
-1("Hello");
Hello
```
[Answer]
# [Röda 0.12](https://github.com/fergusq/roda), ~~30~~ 29 bytes, non-competing
```
h i{seq 1,i|{|j|print"*"*j}_}
```
This is my first try in this scripting language created by [fergusq](https://codegolf.stackexchange.com/users/66323/fergusq) :D
This is a function. To run, use this:
```
h i{seq 1,i|{|j|print"*"*j}_}
main {
  h(5)
}
```
### Ungolfed
```
h i{                         /* Define a function h with parameter i */
   seq 1,i                   /* Generate a sequence of numbers from 1 to i */
          |{             }_  /*  and pipe it to a for-loop */
            |j|              /*  where j is the number in the sequence*/
               print"*"*j    /*  and print an asterisk duplicated j times*/
}
```
]