Print the ASCII table

28

2

The task is to display n characters of the ASCII table.

You may write a function (or a program that takes the argument as a parameter, STDIN is allowed as well) that takes a parameter n, which will be the index of the last character to print.

The task is quite simple, so as an example here's a possible implementation in Python 2.7:

(lambda n:map(chr, range(n)))(256)

As I said it's a simple task. So this is code-golf and the shortest codes wins!

EDIT

As some of you pointed out this code doesn't print the result. It's just an example since I might struggle explaining the problem in english ;-).

EDIT2

Feel free to post the answer in any programming language, even if it's not the shortest code. Maybe there are some interesting implementations out there!

EDIT3

Fixed the example so it prints the result.

oopbase

Posted 2014-10-28T12:46:15.867

Reputation: 542

You didn't say we had to output them in ascending order, so is outputting the characters backwards allowed? How far can I bend the rules? – Stuntddude – 2015-06-12T00:54:16.440

True ASCII is 7 bit, not 8 bit – Shaun Bebbers – 2017-03-16T08:31:58.967

What is the desired range? 0—n-1, 0—n, 1—n? – sergiol – 2018-05-10T00:02:45.140

>

  • Does it have to be a function? 2. According to your reference code, n would be the first character that is not printed.
  • < – Dennis – 2014-10-28T12:49:36.443

    2Actually the reference code prints nothing. It just returns a list of the characters and lets the REPL do whatever it wants with the result. – manatwork – 2014-10-28T12:50:39.797

    @Dennis I updated my question, you are allowed to use the parameter as an program argument. And you are correct, n is the first char that is not printed. – oopbase – 2014-10-28T12:52:00.813

    @manatwork You are correct. But when it's executed in the console you see the resulting array. So basically it's just an example since I might struggle explaining something in english ;-) – oopbase – 2014-10-28T12:52:58.483

    So, it has to be a command-line argument? STDIN is not allowed? – Dennis – 2014-10-28T12:53:28.980

    @Dennis Updated the question again, STDIN is allowed as well – oopbase – 2014-10-28T12:54:15.383

    1Can somebody please explain the downvote? I am sorry if my english isn't that good. If there's something unclear within the question please tell me. – oopbase – 2014-10-28T12:57:48.557

    1for x in range(input()):print chr(x) Would actually print the characters, if you want to edit your example. – FryAmTheEggman – 2014-10-28T12:59:36.353

    2nota [i for i in range(n)] is quite similar to range(n) – njzk2 – 2014-10-28T19:22:16.420

    In BF the code is very simple: ,[->.+<], with a tiny problem: it can't parse real numbers!!!1!11!!oneone!!1!!!11 – None – 2014-10-29T06:03:18.070

    @ciu Did you see my answer or did you just think of that yourself? In case it's the latter, I actually solved this in brainfuck :D

    – undergroundmonorail – 2014-10-31T14:50:42.457

    Answers

    19

    CJam, 4 bytes

    ric,
    

    Full program that reads from STDIN (input field in the online interpreter).

    This simply executes range(chr(int(input()))), taking advantage of the fact that , gives a return an array of characters if its argument is a character.

    I call dibs on c, (2 bytes), just in case that assuming the input is already on the stack turns out to be allowed.

    Dennis

    Posted 2014-10-28T12:46:15.867

    Reputation: 196 637

    Do you have to specify some input? The online runner just outputs the code itself. – manatwork – 2014-10-28T12:52:34.837

    12@manatwork: Just a sec. You have to hurry when you post these... ;) – Dennis – 2014-10-28T12:53:47.993

    I am a little confused by this. The character at 0 ( aka 0c )prevents anything else from being printed after it. ric,( seems to work fine. This means the code doesn't work. – kaine – 2014-10-28T18:03:45.570

    @kaine: I've tested this with Chrome, Firefox and the Java interpreter. It works just fine for me. – Dennis – 2014-10-28T18:14:55.017

    Interesting I am using the linked interpreter but internet explorer (I know pity me but that is all i can use here). There is no output for any integer input. If it works on yours though, i'd still count it as working. "In C library and Unix conventions, the null character is used to terminate text strings; such null-terminated strings can be known in abbreviation as ASCIZ or ASCIIZ, where here Z stands for "zero"." This quote is probably why. – kaine – 2014-10-28T18:17:29.760

    1

    @kaine: Internet Explorer is written in C++, which does not use null-terminated strings. According to this, null characters are parse errors in HTML 5; the browser must replace it with a � or abort processing the document.

    – Dennis – 2014-10-28T18:55:34.950

    4Keep in mind that you have to enter a sufficiently large n, because the first few dozen of ASCII characters are non-printable characters. Fun fact: this program also outputs the Unicode table, for example n=9999 – Sanchises – 2014-10-29T15:28:10.487

    26

    brainfuck - 169 146 142 bytes

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

    Limitations:

    • EOF must be 0
    • Requires 8-bit wrapping cells
    • Because of ^, mods input by 256

    Not the shortest answer here, but hey, brainfuck! This would be a really, really good brainfuck challenge, except for the fact that it requires human readable input without guaranteeing the number of digits. I could have required input to have leading zeroes to make it 3 characters long, but what fun is that? :D One major problem with taking input this way is that brainfuck's only branching or looping structure checks if the current cell is zero or not. When the input can contain zeroes, it can cause your code to take branches it shouldn't be taking. To solve this problem, I store each digit of input plus 1, then subtract the excess at the last possible second. That way, I always know where my zeroes are.

    I did say that this would have been a great brainfuck challenge without having to parse input. Why is that? Well, let's pretend that we don't take a numeric input. We'll say the challenge is "Given a byte of input, output all ASCII characters below that byte". Here's what my answer would be:


    brainfuck - 8 bytes

    ,[->.+<]
    

    It's quite a difference! The real program uses 135 instructions to collect the input (over 95% of the program!), just because it's a human typing it. Store the number as a byte and give that to me, and it only takes one.

    (Fun fact: If you understood the hypothetical program, then congratulations! You understand brainfuck in its entirety. The whole language has only eight commands, and that program happens to use each one exactly once.)

    Explanation

    -[+>+[+<]>+]>+               abuse 8 bit wrapping to put 47 in cell 4
    
    >>,[>,]                      starting in cell 6; get each character of input
    
    <[<]<[->>[->]<[<]<]          subtract the value of cell 4 from each input character
                                 '0' has an ascii value of 47 so subtracting 47 from each
                                 digit gives you that digit's value plus 1
    
    >>>[                         if the number is in more than one cell
                                 (when the program first starts this means "if the input has
                                 more than one digit")
    
    [<[-<+<+<+>>>]               copy first input cell to 3 new cells
    
    +++++++++[<[-<+>]<<          do some fancy addition magic to multiply that value by 10
    [-<+>>>+<<]<[->+<]>>>>-]]
    
    <,<<,>                       clean up a bit (abusing comma to set cells to 0)
    
    [->>>+<<<]>>>                add the value to the next cell of input
    
    ----------                   because we multiplied (the digit plus 1) by 10; the answer
                                 is 10 too high; so subtract 10
    
    >]                           if the input is still in multiple cells; do the song and
                                 dance again (multiply by 10; add to next cell; subtract 10)
    
    <-                           we never got a chance to fix the final digit; so it's still 1
                                 too high
    
                   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                   ;;         we have now finished processing input         ;;
                   ;;     the tape is empty except for the current cell     ;;
                   ;;  the current cell contains the number that was input  ;;
                   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    [                            while the cell containing input != 0
    
    -                            subtract 1 from it
    
    >.+                          go a cell to the right; output that cell; then add 1
    
    <]                           repeat
    

    undergroundmonorail

    Posted 2014-10-28T12:46:15.867

    Reputation: 5 897

    <s>.+[.+] shorter</s> this prints always 256 chars – username.ak – 2016-02-06T14:09:40.327

    Because it's not specified which order the characters had to be in, you could golf the printing part from [->.+<] down to [.-], saving 3 bytes. – Esolanging Fruit – 2016-12-15T01:03:20.240

    1

    Also, your second answer is valid.

    – Esolanging Fruit – 2017-02-13T00:18:19.933

    Nice! Definitely +1 for the effort :-) – oopbase – 2014-10-28T15:24:37.913

    1You could save some bytes on the outputting part: >[-]<[->.+<] Set cell next to current cell to 0, then count down the current cell while increasing the cell next to it and simultaneously printing the value. – Shujal – 2014-10-28T15:59:52.737

    @shu That's an excellent point! I didn't think of that at all. In addition to being shorter, it fixes the problem I had with choking on large inputs and it's probably faster! Thanks :) – undergroundmonorail – 2014-10-29T12:59:31.447

    Yeah, it's much, much faster now. I also didn't need the >[-]< part because I was already next to an empty cell. :) – undergroundmonorail – 2014-10-29T13:09:24.917

    12

    Pyth, 4 bytes

    VQCN
    

    Basically a translation of the Python 3 program:

    for N in range(eval(input())):print(chr(N))
    

    FryAmTheEggman

    Posted 2014-10-28T12:46:15.867

    Reputation: 16 206

    11

    Befunge 93 - 23 21

    &> :#v_,>:#,_@
     ^-1:<
    

    Befunge 93 - 15 13 (by Ingo Bürk)

    This one prints the list in reverse, but OP only said we need to print the first n characters, not that it has to be in order.

    &>::>v
    @^-1,_
    

    Might not be golfable any further without moving on to Befunge98 (for the ";" operator, see @Kasran's answer)

    Try it here:

    function BefungeBoard(source, constraints) {
        constraints = constraints || {
            width: 80,
            height: 25
        };
    
        this.constraints = constraints;
        this.grid = source.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/).map(function (line) {
            return (line + String.repeat(' ', constraints.width - line.length)).split('');
        });
        for (var i = this.grid.length; i < constraints.height; i++) {
            this.grid[i] = String.repeat(' ', constraints.width).split('');
        }
    
        this.pointer = {
            x: 0,
            y: 0
        };
    
        this.direction = Direction.RIGHT;
    }
    
    BefungeBoard.prototype.nextPosition = function () {
        var vector = this.direction.toVector(),
            nextPosition = {
                x: this.pointer.x + vector[0],
                y: this.pointer.y + vector[1]
            };
    
        nextPosition.x = nextPosition.x < 0 ? this.constraints.width - 1 : nextPosition.x;
        nextPosition.y = nextPosition.y < 0 ? this.constraints.height - 1 : nextPosition.y;
    
        nextPosition.x = nextPosition.x >= this.constraints.width ? 0 : nextPosition.x;
        nextPosition.y = nextPosition.y >= this.constraints.height ? 0 : nextPosition.y;
    
        return nextPosition;
    };
    
    BefungeBoard.prototype.advance = function () {
        this.pointer = this.nextPosition();
        if (this.onAdvance) {
            this.onAdvance.call(null, this.pointer);
        }
    };
    
    BefungeBoard.prototype.currentToken = function () {
        return this.grid[this.pointer.y][this.pointer.x];
    };
    
    BefungeBoard.prototype.nextToken = function () {
        var nextPosition = this.nextPosition();
        return this.grid[nextPosition.y][nextPosition.x];
    };
    
    var Direction = (function () {
        var vectors = [
            [1, 0],
            [-1, 0],
            [0, -1],
            [0, 1]
        ];
    
        function Direction(value) {
            this.value = value;
        }
    
        Direction.prototype.toVector = function () {
            return vectors[this.value];
        };
    
        return {
            UP: new Direction(2),
            DOWN: new Direction(3),
            RIGHT: new Direction(0),
            LEFT: new Direction(1)
        };
    })();
    
    function BefungeStack() {
        this.stack = [];
    }
    
    BefungeStack.prototype.pushAscii = function (item) {
        this.pushNumber(item.charCodeAt());
    };
    
    BefungeStack.prototype.pushNumber = function (item) {
        if (isNaN(+item)) {
            throw new Error(typeof item + " | " + item + " is not a number");
        }
    
        this.stack.push(+item);
    };
    
    BefungeStack.prototype.popAscii = function () {
        return String.fromCharCode(this.popNumber());
    };
    
    BefungeStack.prototype.popNumber = function () {
        return this.stack.length === 0 ? 0 : this.stack.pop();
    };
    
    function Befunge(source, constraints) {
        this.board = new BefungeBoard(source, constraints);
        this.stack = new BefungeStack();
        this.stringMode = false;
        this.terminated = false;
    
        this.digits = "0123456789".split('');
    }
    
    Befunge.prototype.run = function () {
        for (var i = 1; i <= (this.stepsPerTick || 10); i++) {
            this.step();
            if (this.terminated) {
                return;
            }
        }
    
        requestAnimationFrame(this.run.bind(this));
    };
    
    Befunge.prototype.step = function () {
        this.processCurrentToken();
        this.board.advance();
    };
    
    Befunge.prototype.processCurrentToken = function () {
        var token = this.board.currentToken();
        if (this.stringMode && token !== '"') {
            return this.stack.pushAscii(token);
        }
    
        if (this.digits.indexOf(token) !== -1) {
            return this.stack.pushNumber(token);
        }
    
        switch (token) {
            case ' ':
                while ((token = this.board.nextToken()) == ' ') {
                    this.board.advance();
                }
                return;
            case '+':
                return this.stack.pushNumber(this.stack.popNumber() + this.stack.popNumber());
            case '-':
                return this.stack.pushNumber(-this.stack.popNumber() + this.stack.popNumber());
            case '*':
                return this.stack.pushNumber(this.stack.popNumber() * this.stack.popNumber());
            case '/':
                var denominator = this.stack.popNumber(),
                    numerator = this.stack.popNumber(),
                    result;
                if (denominator === 0) {
                    result = +prompt("Illegal division by zero. Please enter the result to use:");
                } else {
                    result = Math.floor(numerator / denominator);
                }
    
                return this.stack.pushNumber(result);
            case '%':
                var modulus = this.stack.popNumber(),
                    numerator = this.stack.popNumber(),
                    result;
                if (modulus === 0) {
                    result = +prompt("Illegal division by zero. Please enter the result to use:");
                } else {
                    result = Math.floor(numerator / modulus);
                }
    
                return this.stack.pushNumber(result);
            case '!':
                return this.stack.pushNumber(this.stack.popNumber() === 0 ? 1 : 0);
            case '`':
                return this.stack.pushNumber(this.stack.popNumber() < this.stack.popNumber() ? 1 : 0);
            case '>':
                this.board.direction = Direction.RIGHT;
                return;
            case '<':
                this.board.direction = Direction.LEFT;
                return;
            case '^':
                this.board.direction = Direction.UP;
                return;
            case 'v':
                this.board.direction = Direction.DOWN;
                return;
            case '?':
                this.board.direction = [Direction.RIGHT, Direction.UP, Direction.LEFT, Direction.DOWN][Math.floor(4 * Math.random())];
                return;
            case '_':
                this.board.direction = this.stack.popNumber() === 0 ? Direction.RIGHT : Direction.LEFT;
                return;
            case '|':
                this.board.direction = this.stack.popNumber() === 0 ? Direction.DOWN : Direction.UP;
                return;
            case '"':
                this.stringMode = !this.stringMode;
                return;
            case ':':
                var top = this.stack.popNumber();
                this.stack.pushNumber(top);
                return this.stack.pushNumber(top);
            case '\\':
                var first = this.stack.popNumber(),
                    second = this.stack.popNumber();
                this.stack.pushNumber(first);
                return this.stack.pushNumber(second);
            case '$':
                return this.stack.popNumber();
            case '#':
                return this.board.advance();
            case 'p':
                return this.board.grid[this.stack.popNumber()][this.stack.popNumber()] = this.stack.popAscii();
            case 'g':
                return this.stack.pushAscii(this.board.grid[this.stack.popNumber()][this.stack.popNumber()]);
            case '&':
                return this.stack.pushNumber(+prompt("Please enter a number:"));
            case '~':
                return this.stack.pushAscii(prompt("Please enter a character:")[0]);
            case '.':
                return this.print(this.stack.popNumber());
            case ',':
                return this.print(this.stack.popAscii());
            case '@':
                this.terminated = true;
                return;
        }
    };
    
    Befunge.prototype.withStdout = function (printer) {
        this.print = printer;
        return this;
    };
    
    Befunge.prototype.withOnAdvance = function (onAdvance) {
        this.board.onAdvance = onAdvance;
        return this;
    };
    
    String.repeat = function (str, count) {
        var repeated = "";
        for (var i = 1; i <= count; i++) {
            repeated += str;
        }
    
        return repeated;
    };
    
    window['requestAnimationFrame'] = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) {
        window.setTimeout(callback, 1000 / 60);
    };
    
    (function () {
        var currentInstance = null;
    
        function resetInstance() {
            currentInstance = null;
        }
    
        function getOrCreateInstance() {
            if (currentInstance !== null && currentInstance.terminated) {
                resetInstance();
            }
    
            if (currentInstance === null) {
                var boardSize = Editor.getBoardSize();
                currentInstance = new Befunge(Editor.getSource(), {
                    width: boardSize.width,
                    height: boardSize.height
                });
                currentInstance.stepsPerTick = Editor.getStepsPerTick();
    
                currentInstance.withStdout(Editor.append);
                currentInstance.withOnAdvance(function (position) {
                    Editor.highlight(currentInstance.board.grid, position.x, position.y);
                });
            }
    
            return currentInstance;
        }
    
        var Editor = (function (onExecute, onStep, onReset) {
            var source = document.getElementById('source'),
                sourceDisplay = document.getElementById('source-display'),
                sourceDisplayWrapper = document.getElementById('source-display-wrapper'),
                stdout = document.getElementById('stdout');
            var execute = document.getElementById('execute'),
                step = document.getElementById('step'),
                reset = document.getElementById('reset');
            var boardWidth = document.getElementById('board-width'),
                boardHeight = document.getElementById('board-height'),
                stepsPerTick = document.getElementById('steps-per-tick');
    
            function showEditor() {
                source.style.display = "block";
                sourceDisplayWrapper.style.display = "none";
                source.focus();
            }
    
            function hideEditor() {
                source.style.display = "none";
                sourceDisplayWrapper.style.display = "block";
    
                var computedHeight = getComputedStyle(source).height;
                sourceDisplayWrapper.style.minHeight = computedHeight;
                sourceDisplayWrapper.style.maxHeight = computedHeight;
    
                sourceDisplay.textContent = source.value;
            }
    
            function resetOutput() {
                stdout.value = null;
            }
    
            function escapeEntities(input) {
                return input.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
            }
    
            sourceDisplayWrapper.onclick = function () {
                resetOutput();
                showEditor();
                onReset && onReset.call(null);
            };
            execute.onclick = function () {
                resetOutput();
                hideEditor();
                onExecute && onExecute.call(null);
            };
            step.onclick = function () {
                hideEditor();
                onStep && onStep.call(null);
            };
            reset.onclick = function () {
                resetOutput();
                showEditor();
                onReset && onReset.call(null);
            };
    
            return {
                getSource: function () {
                    return source.value;
                },
    
                append: function (content) {
                    stdout.value = stdout.value + content;
                },
    
                highlight: function (grid, x, y) {
                    var highlighted = [];
                    for (var row = 0; row < grid.length; row++) {
                        highlighted[row] = [];
                        for (var column = 0; column < grid[row].length; column++) {
                            highlighted[row][column] = escapeEntities(grid[row][column]);
                        }
                    }
    
                    highlighted[y][x] = '<span class="activeToken">' + highlighted[y][x] + '</span>';
                    sourceDisplay.innerHTML = highlighted.map(function (lineTokens) {
                        return lineTokens.join('');
                    }).join('\n');
                },
    
                getBoardSize: function () {
                    return {
                        width: +boardWidth.innerHTML,
                        height: +boardHeight.innerHTML
                    };
                },
    
                getStepsPerTick: function () {
                    return +stepsPerTick.innerHTML;
                }
            };
        })(function () {
            getOrCreateInstance().run();
        }, function () {
            getOrCreateInstance().step();
        }, resetInstance);
    })();
    .container {
        width: 100%;
    }
    .so-box {
        font-family:'Helvetica Neue', Arial, sans-serif;
        font-weight: bold;
        color: #fff;
        text-align: center;
        padding: .3em .7em;
        font-size: 1em;
        line-height: 1.1;
        border: 1px solid #c47b07;
        -webkit-box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3), 0 2px 0 rgba(255, 255, 255, 0.15) inset;
        text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
        background: #f88912;
        box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3), 0 2px 0 rgba(255, 255, 255, 0.15) inset;
    }
    .control {
        display: inline-block;
        border-radius: 6px;
        float: left;
        margin-right: 25px;
        cursor: pointer;
    }
    .option {
        padding: 10px 20px;
        margin-right: 25px;
        float: left;
    }
    input, textarea {
        box-sizing: border-box;
    }
    textarea {
        display: block;
        white-space: pre;
        overflow: auto;
        height: 75px;
        width: 100%;
        max-width: 100%;
        min-height: 25px;
    }
    span[contenteditable] {
        padding: 2px 6px;
        background: #cc7801;
        color: #fff;
    }
    #controls-container, #options-container {
        height: auto;
        padding: 6px 0;
    }
    #stdout {
        height: 50px;
    }
    #reset {
        float: right;
    }
    #source-display-wrapper {
        display: none;
        width: 100%;
        height: 100%;
        overflow: auto;
        border: 1px solid black;
        box-sizing: border-box;
    }
    #source-display {
        font-family: monospace;
        white-space: pre;
        padding: 2px;
    }
    .activeToken {
        background: #f88912;
    }
    .clearfix:after {
        content:".";
        display: block;
        height: 0;
        clear: both;
        visibility: hidden;
    }
    .clearfix {
        display: inline-block;
    }
    * html .clearfix {
        height: 1%;
    }
    .clearfix {
        display: block;
    }
    <div class="container">
        <textarea id="source" placeholder="Enter your Befunge-93 program here" wrap="off">&> :#v_,>:#,_@
     ^-1:<</textarea>
        <div id="source-display-wrapper">
            <div id="source-display"></div>
        </div>
    </div>
    <div id="controls-container" class="container clearfix">
        <input type="button" id="execute" class="control so-box" value="► Execute" />
        <input type="button" id="step" class="control so-box" value="Step" />
        <input type="button" id="reset" class="control so-box" value="Reset" />
    </div>
    <div id="stdout-container" class="container">
        <textarea id="stdout" placeholder="Output" wrap="off" readonly></textarea>
    </div>
    <div id="options-container" class="container">
        <div class="option so-box">Steps per Tick: <span id="steps-per-tick" contenteditable>500</span>
    
        </div>
        <div class="option so-box">Board Size: <span id="board-width" contenteditable>80</span> x <span id="board-height" contenteditable>25</span>
    
        </div>
    </div>

    karhell

    Posted 2014-10-28T12:46:15.867

    Reputation: 411

    @JamesHolderness Well spotted. I've edited the answer accordingly. – karhell – 2017-01-09T09:51:43.203

    I hope you don't mind that I used an inline interpreter from here :)

    – Ingo Bürk – 2014-10-29T19:36:38.783

    The question doesn't state that we must print it in any order, so this is five byte shorter: &> #- #1:# :#,_@ (it just prints it in reverse) – Ingo Bürk – 2014-10-29T19:55:43.353

    I shaved off another bytes for a total of 15. Because of newlines I will edit it into your post. – Ingo Bürk – 2014-10-29T19:57:28.187

    Well played on the extra golfing :) As for the inline interpreter, I wasn't aware there was one. It's great, thanks :) – karhell – 2014-10-30T08:47:54.890

    The interpreter is new from the linked challenge. I just thought I'd actually use it when I saw your answer. :) – Ingo Bürk – 2014-10-30T08:58:17.330

    8

    Java, 151 128 77 62 56 bytes

    First try at code-golfing.

    void f(int n){for(char i=0;++i<=n;System.out.print(i));}
    

    Usage:

    import java.util.Scanner;
    class A {
    
        public static void main(String[] a) {
            int num = new Scanner(System.in).nextInt();
            new A().f(num);
        }
    
        void f(int n) {
            for (char i = 0; ++i <= n; System.out.print(i));
        }
    }
    

    Thanks to @Shujal, @flawr, @Ingo Bürk and @Loovjo for the serious byte reduction.

    Rodolfo Dias

    Posted 2014-10-28T12:46:15.867

    Reputation: 3 940

    156 bytes: void f(int n){for(char i=0;++i<=n;System.out.print(i));} – Loovjo – 2015-06-23T14:23:10.890

    1@Loovjo 55 bytes actually if you remove the = and post-increment instead of pre-increment: void f(int n){for(char i=0;i++<n;)System.out.print(i);} – Jack Ammo – 2015-06-30T00:43:05.117

    1

    @JackAmmo You're right that you can change the <= to < by also changing ++i to i++. However, you then also have to change the char i=0; to char i=1;. So this: void f(int n){for(char i=1;i++<n;)System.out.print(i);} (and indeed 55 bytes) Try it here.

    – Kevin Cruijssen – 2017-03-15T12:15:20.640

    1You can save some chars by declaring the int while opening the scanner: int i,n=new Scanner(... and changing the loop to for(;++i<n;). Also, you don't need to invoke Character.toString. You can just feed System.out a char value and it will happily output it. – Shujal – 2014-10-28T16:03:52.467

    @Shujal I have much to learn yet. Thanks! – Rodolfo Dias – 2014-10-28T19:21:39.953

    1The challenge allows the use of your a as input. And I think you can shorten the for loop by abusing the increment place as loop body: for(;++i<n;System.out.print((char)i)); (but you might have to change the initialization or end value by +- 1) – flawr – 2014-10-29T19:11:57.657

    1You are allowed to write a function, so no need for an entire class and everything. – Ingo Bürk – 2014-10-29T19:33:24.320

    @IngoBürk I'm dumb enough to write the whole thing and not read that I can and cannot do. Oh well... – Rodolfo Dias – 2014-10-29T20:16:08.223

    @RodolfoDias You can drop the public keyword and honestly, the static as well. It's still a function/method. You can also replace ++i<n+1 with ++i<=n. – Ingo Bürk – 2014-10-29T20:40:38.673

    @IngoBürk Hmm, if I don't put the i+1, the function prints the n-1 first ASCII charachters. At least, it's what it's happening here :/ – Rodolfo Dias – 2014-10-29T20:52:41.187

    1@RodolfoDias Are you sure? Obviously, ++i<n+1 should be equivalent to ++i<=n. Note the = in there, however! It just saves one byte. It works for me. – Ingo Bürk – 2014-10-29T21:01:47.370

    @IngoBürk Damn it, next time I have to double our triple-read comments before posting. Of course it's the same think... hides – Rodolfo Dias – 2014-10-30T06:49:10.870

    1So we come down to void f(int n){int i=0;for(;++i<=n;System.out.print((char)i));} which is 62 bytes. At least I don't see more to golf now. :) – Ingo Bürk – 2014-10-30T06:53:31.833

    6

    APL,5

    ⎕UCS⍳
    

    Example usage:

    ⎕UCS⍳256
    

    Shujal

    Posted 2014-10-28T12:46:15.867

    Reputation: 687

    1You don't have to support code points over 127. Just ↑⎕AV would work fine. So 4 chars – Adám – 2016-02-07T21:43:50.117

    1You don't have to make a dfn. Just ⎕UCS⍳ would work fine. So 5 chars – Moris Zucca – 2014-10-28T13:34:27.117

    6

    JavaScript, ES6 - 52 58 56 53 44 42 bytes

    n=>String.fromCharCode(...Array(n).keys())
    

    Paste this into the Firefox console. Run as f(NUM).

    Had to make it longer because the first didn't properly accept input.

    Down 3, thanks edc65! Down to 44 thanks to Swivel!

    Scimonster

    Posted 2014-10-28T12:46:15.867

    Reputation: 2 905

    244 Characters! f=n=>String.fromCharCode(...Array(n).keys()) – Swivel – 2016-07-21T20:57:12.467

    @Scimonster No +1 for 9 byte weight loss assistance? :P – Swivel – 2016-07-22T20:20:51.270

    You don't need the f=, unnamed functions are allowed. – FlipTack – 2016-12-31T20:02:59.610

    1This doesn't really handle neither parameter nor input. – manatwork – 2014-10-28T14:14:25.940

    Just change the 70 to a different number; that's the input. – Scimonster – 2014-10-28T14:17:13.043

    Okay, i updated it to take input, at the cost of 6 bytes. – Scimonster – 2014-10-28T14:25:50.227

    Much better. But the parenthesis around fat arrow function's single argument is not necessary: f=n=>…. – manatwork – 2014-10-28T14:31:52.510

    Thanks for that. This is the first time i've really done ES6. – Scimonster – 2014-10-28T14:43:26.847

    3-2: f=n=>[...Array(n)].map((v,i)=>String.fromCharCode(i)) – edc65 – 2014-10-28T18:13:12.067

    @edc65 -3 by my count, thanks! – Scimonster – 2014-10-28T18:41:07.890

    Remind me what [...Array(n)] does? – WallyWest – 2014-10-31T00:49:26.500

    @WallyWest It creates an empty array of length n, then populates it with 0s via the spread operator, so that map will work. – Scimonster – 2014-10-31T07:21:13.057

    6

    Haskell, 17 23 bytes

    flip take['\0'..]
    

    Not sure if it is possible to do any better without imports.

    Edit

    My first solution didn't actually print the result, so allow 6 more chars for that:

    print.flip take['\0'..]
    

    Also, not shorter (25 chars with printing, 19 without), but an interesting alternate approach (it requires 'Data.List', though):

    print.((inits['\0'..])!!)
    

    archaephyrryx

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 035

    (`take`['\0'..]) saves a byte. – Laikoni – 2017-08-16T07:13:33.557

    This doesn't actually print the result. – nyuszika7h – 2014-10-29T15:22:15.120

    @nyuszika7h now it does – John Dvorak – 2014-10-29T16:00:20.370

    4

    Bash+BSD common utilities, 9 bytes

    jot -c $1
    

    GNU dc, 20 bytes

    ?sc_1[1+dPdlc>m]dsmx
    

    Digital Trauma

    Posted 2014-10-28T12:46:15.867

    Reputation: 64 644

    4

    Perl, 17 bytes

    say chr for 0..$_
    

    Demnogonis

    Posted 2014-10-28T12:46:15.867

    Reputation: 141

    You can avoid the +1 for -n by using <> in place of $_. – Xcali – 2017-08-16T03:35:49.730

    1Too many parenthesis. print chr for 0..$ARGV[0] – manatwork – 2014-10-29T15:29:43.593

    You're right! It has been a while since I used perl – Demnogonis – 2014-10-29T15:46:20.903

    1You can use shift instead of $ARGV[0] to save 2 bytes. – nyuszika7h – 2014-10-29T16:32:14.953

    If you are allowed to print the characters on different lines, you can use say. Also, the character count is shorter if you do it as a one-liner with -n. echo "90" | perl -nE'say chr for 0..$_' would count as 18 characters. 17 for say chr for 0..$_ plus 1 for the n. – hmatt1 – 2014-10-29T17:26:43.590

    You're right. But say won't work with every version of perl. – Demnogonis – 2014-10-30T08:32:55.123

    @Demnogonis say was introduced in 5.14 and you're allowed to use it on here to save 2 bytes if you want to. – hmatt1 – 2014-10-30T16:45:47.203

    You should remove the old versions instead of using strikethrough. That's what the revision history is for. – nyuszika7h – 2014-10-30T19:11:06.127

    @nyuszika7h Old habits die hard. I was forced to work with active perl 5.6 until last year. – Demnogonis – 2014-10-30T21:34:52.663

    4

    C, 31 30 28 27

    k;f(n){putch(k++)<n&&f(n);}
    

    Since putch is nonstandard, here's the fully compliant version:

    k;f(n){putchar(k++)<n&&f(n);}
    

    Must be called from main:

    main(){f(255);}
    

    EDIT: Improved by taking advantage of putchar return value
    EDIT 2: Reduced by another character through recursion

    takra

    Posted 2014-10-28T12:46:15.867

    Reputation: 793

    1putch is a non-standard function. Also, may I ask why this answer was downvoted? – Stuntddude – 2015-06-12T00:37:44.400

    @Stuntddude I'll add an alternatve version that uses putchar, and no idea why this is downvoted. After all, it is one of the shorter ones. – takra – 2015-06-12T00:39:45.937

    3

    Brainfuck, 44 bytes

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

    Expects a decimal string without a trailing newline.

    Try it online.

    Reading integers in the range [0, max_cell_size] in brainfuck is not difficult. I encourage you to invent a clean method on your own. I consider this a beginner level exercise. (The reverse operation of printing a cell's numeric value is more involved, and could be considered an intermediate level task.)

    Here's a 58-byte version that can handle 256 on 8-bit implementations:

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

    Mitch Schwartz

    Posted 2014-10-28T12:46:15.867

    Reputation: 4 899

    Why haven't I thought of this??? This is ingenious!!! – FinW – 2017-02-25T19:03:00.130

    Can I borrow this to use on future answers? – FinW – 2017-02-25T19:11:39.747

    1

    @FinW I'm guessing you don't know about this meta post.

    – Mitch Schwartz – 2017-02-26T02:37:04.073

    3

    CJam, 3

    ,:c
    

    I assumed the argument to be the top stack element.

    Example usage:

    256,:c
    
    ri,:c
    

    Shujal

    Posted 2014-10-28T12:46:15.867

    Reputation: 687

    3

    Ruby, 30 characters

    puts (0..$*[0].to_i).map &:chr
    

    Doorknob

    Posted 2014-10-28T12:46:15.867

    Reputation: 68 138

    3

    J - 5 bytes

    {.&a.
    

    {. is Head, a. is Alphabet ( a list of all chars) and & Bonds them, generating a monadic verb called like:

    {.&a. 100 NB. first 100 characters
    

    Note: It seems this does not work interactively: Jconsole and jQt seems to set up a translation, outputting box characters instead of some control characters. In a script or from the commandline, it does work though:

      ijconsole <<< '127 {. a.' | hd
    

    jpjacobs

    Posted 2014-10-28T12:46:15.867

    Reputation: 3 440

    Notice that the alphabet is not exactly ASCII. – FUZxxl – 2015-06-30T13:10:26.807

    Up to {.&a. 127, it is no? – jpjacobs – 2015-07-01T06:44:36.613

    No because J has box drawing characters instead of some of the control characters. – FUZxxl – 2015-07-01T06:46:14.230

    Actually, writing this to a file and inspecting it with a hex viewer tells me that J outputs the correct values (0x00 0x01, ...) . it's only the J interpreter/ IDE interpretting those values as boxdrawing characters instead of control characters. It does exactly the same as all other languages using char or equivalents do. – jpjacobs – 2015-07-01T07:07:07.637

    That's weird because I tested it on my UNIX box and it did indeed output Unicode characters for some of the code-points. – FUZxxl – 2015-07-01T07:16:44.203

    Let us continue this discussion in chat.

    – jpjacobs – 2015-07-01T08:25:52.220

    Oh please not... – FUZxxl – 2015-07-01T08:28:17.807

    3

    awk - 27

    {while(i<$0)printf"%c",i++}
    

    To give the parameter on stdin run it like:

    awk '{while(i<$0)printf"%c",i++}' <<<96
    

    Just for fun: The "think positive version" starting with a definitive yes:

    yes|head -96|awk '{printf"%c",NR-1}'
    

    NR-1 is needed to print (char)0 for NR==1.    :-(

    And why don't we have a no command? That's kinda mean!

    user19214

    Posted 2014-10-28T12:46:15.867

    Reputation:

    1alias no='yes no' – nyuszika7h – 2014-10-29T15:25:13.050

    ...but then I'd have to count the chars of that alias definition too... :-( – None – 2014-10-29T15:49:21.490

    3

    gs2, 2 bytes

    V.
    

    This should be competing, I think! It would’ve worked even in the early days of gs2. Try it here.

    Lynn

    Posted 2014-10-28T12:46:15.867

    Reputation: 55 648

    1

    Successfully tested with this version, which predates the challenge by a month.

    – Dennis – 2016-02-05T18:02:46.063

    2

    Keg, 4 bytes (SBCS)

    ¿ï(,
    

    TIO

    Push input, output ASCII table.

    user85052

    Posted 2014-10-28T12:46:15.867

    Reputation:

    2

    Golfscript - 5

    Thanks to @Dennis

    ~,''+
    

    Beta Decay

    Posted 2014-10-28T12:46:15.867

    Reputation: 21 478

    1~,""+ is shorter and correctly processes input from STDIN. – Dennis – 2014-10-28T14:04:10.980

    @Dennis That doesn't produce any output for me... – Beta Decay – 2014-10-28T14:15:46.863

    1Are you using the online interpeter? To correctly simulate input from STDIN, you have to use, e.g., ;"65", since the input from STDIN will always be a string. – Dennis – 2014-10-28T14:17:25.603

    1@Dennis Oh thanks that works now! – Beta Decay – 2014-10-28T14:25:56.600

    2

    Lua - 43 41 Bytes

    for i=1,arg[1]do print(string.char(i))end
    

    William Barbosa

    Posted 2014-10-28T12:46:15.867

    Reputation: 3 269

    You can shorten this by a byte a=""for i=1,arg[1]do print(a.char(i))end – Digital Veer – 2015-10-31T15:21:54.503

    You can shorten this by 2 bytes for i=1,arg[1]do print(("").char(i))end – manatwork – 2016-07-22T09:25:26.503

    2

    Befunge 98, 22

    &:00pv>0gk,@
    0::-1<^j`
    

    Kind of sad that this is so long.

    &:00p        ; gets numerical input, stores a copy at cell (0,0)               ;
         v       ; IP goes down                                                    ;
    
         <       ; IP goes left, so I execute 1-::0`j^                             ;
     ::-1        ; (1-::) subtract one from our number and duplicate it twice      ;
    0       `    ; (0`) compare the number with 0, push 1 if greater else 0        ;
         <^j     ; if the result was 0, go up, otherwise continue going left       ;
    
          >0gk,  ; get the value at cell (0,0), print that many numbers from stack ;
               @ ; terminate program                                               ;
    

    Justin

    Posted 2014-10-28T12:46:15.867

    Reputation: 19 757

    2

    T-SQL: 68 63

    As a print loop

    DECLARE @i INT=64,@ INT=0A:PRINT CHAR(@)SET @+=1IF @<=@i GOTO A
    

    T-SQL: 95 86

    As a query

    DECLARE @ INT=64SELECT TOP(@+1)CHAR(ROW_NUMBER()OVER(ORDER BY 0/0)-1)FROM sys.messages
    

    Edit: Made changes and fixes pointed out by Muqo. Thanks. Fixes and golfing suggested by @t-clausen.dk

    MickyT

    Posted 2014-10-28T12:46:15.867

    Reputation: 11 735

    Second answer is invalid. You can rewrite it this way and golf 9 characters: DECLARE @ INT=64SELECT TOP(@+1)CHAR(ROW_NUMBER()OVER(ORDER BY 0/0)-1)FROM sys.messages – t-clausen.dk – 2016-07-11T14:26:36.357

    @t-clausen.dk not sure how I let that one through. Thanks for that. – MickyT – 2016-07-11T18:37:05.083

    For the loop, you can save 5 or so characters converting the WHILE to a GOTO with label. For the query, maybe specify msdb.sys.objects to guarantee enough objects. Also, it doesn't output CHAR(0). However, as consolation you can ORDER BY @. – Muqo – 2014-10-29T02:41:23.220

    2

    Ruby, 23

    f=->n{puts *?\0..n.chr}
    

    Explanation

    • Input is taken as the argument to a lambda. It expects an Integer.
    • The "destructuring operator" (*) invokes #to_ary on the Range to print every character on its own line.

    britishtea

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 189

    2

    Python 3.4 - 36 bytes / 43 bytes

    print(*map(chr,range(int(input()))))
    print(*map(chr,range(int(input()))),sep='')
    

    255 input()

    How this works is:

    1. Get upper limit of range
    2. Generate a range of the table.
    3. Map the range to chr function ( takes int, returns ascii ).
    4. Consume the map via splat argument expansion ( number -> character -> print! )

    The second one just removes the space separating each character in exchange for 7 bytes.

    Full Metal

    Posted 2014-10-28T12:46:15.867

    Reputation: 21

    You could very much make this into a lambda, as the question states this, and in Python 2, map returns a list, so you could just do f=lambda i:map(chr,range(i)) – Justin – 2014-10-29T06:14:20.053

    That's true, and my initial solution was similar but I didn't want to use a lambda so that I could immediately print output. I wish map kept the trend of returning a list instead of an iterator, even if it is more pythonic that way. – Full Metal – 2014-10-29T06:27:09.057

    2

    Pascal 87

    program _;var c:char;n:byte;begin n:=0;readln(n);for c:=chr(0)to chr(n)do write(c);end.
    

    Pascal 73

    program _;var c,n:byte;begin readln(n);for c:=0to n do write(chr(c));end.
    

    Builds and runs fine from http://www.onlinecompiler.net/pascal

    Mark K Cowan

    Posted 2014-10-28T12:46:15.867

    Reputation: 227

    Quite possibly, I've only used Delphi. But someone edited that out of the title. – Mark K Cowan – 2018-06-04T15:26:39.490

    1

    FreePascal (and if I remember correctly, Turbo Pascal too) only needs 60 of those characters: var c,n:byte;begin read(n);for c:=0to n do write(chr(c))end. http://pastebin.com/aFLVTuvh

    – manatwork – 2014-10-29T16:00:52.933

    2

    x86 ASM (Linux) (many many bytes unless you compile it)

    Written as a function, assumes parameter is passed in AX (I forget the number for the read syscall) Also doesn't preserve [SP] or BX.

    test ax,ax
    jz @Done
    mov [sp],ax
    @Loop:
    mov ax,4
    mov bx,1
    mov cx,sp
    mov dx,1
    int 0x80
    sub [sp],1  ; Can I do this?  Or do I need to load/sub/store separately?
    jnz @Loop
    @Done:
    ret
    

    Mark K Cowan

    Posted 2014-10-28T12:46:15.867

    Reputation: 227

    2(I should have put a F00F exploit in there, it's not like anyone will run it anyway) – Mark K Cowan – 2014-10-29T13:09:11.093

    7I was going to run this. I'm not going to run this now. – Aearnus – 2014-10-30T02:43:11.610

    2

    Perl - 29

    sub f{print map{chr}0..shift}
    

    nyuszika7h

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 624

    2

    Julia: 20 characters (REPL)

    This is close to the question's example: just generates the characters and let the REPL to do whatever it wants with them.

    f(n)=map(char,[0:n])
    

    Julia: 33 characters

    Prints each character in a separate line.

    print(map(char,[0:int(ARGS[1])]))
    

    manatwork

    Posted 2014-10-28T12:46:15.867

    Reputation: 17 865

    2

    M (MUMPS) - 21

    R n F i=1:1:n W $C(i)

    In expanded form: READ n FOR i=1:1:n WRITE $CHAR(i)

    temporicide

    Posted 2014-10-28T12:46:15.867

    Reputation: 61

    2

    BrainFuck - 140 112 Bytes

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

    Try It Here!

    Saved 28 bytes by changing [<<<->>>->+<]>[<<<->>>->+<]>[<<<->>>-] to [<<<->->->-].

    What it does

    ,>,>,>                                                              Takes three inputs
                                                                        in three separate cells
    
    -[>+<-----]>---[<+>-]<[<<<->->->-]<                                 Takes 48 off of each to
                                                                        convert them to decimal
    
    [>+<-]<[>>++++++++++<<-]<[>>>>++++++++++[<++++++++++>-]<<<<-]>>>    Combines them into a
                                                                        three digit number by
                                                                        multiplying the first
                                                                        by 100, the second by
                                                                        10 and then adding all
                                                                        three
    
    [>.+<-]                                                             Repeatedly prints the
                                                                        value of the adjacent
                                                                        cell and then adds one
                                                                        to it until it reaches
                                                                        the input value.
    

    FinW

    Posted 2014-10-28T12:46:15.867

    Reputation: 477

    1

    PHP, 35 34 bytes

    <?=join(range(a^a,chr($argv[1])));
    

    yup. PHP can create a range of characters.

    Takes argument from command line. Save to file, execute.

    Titus

    Posted 2014-10-28T12:46:15.867

    Reputation: 13 814

    1

    ><>, 14 bytes

    0:o1+:r:@=?;$!
    

    Try it here!

    Explanation

    0              push 0 to the stack                [n, 0]
     :             duplicate the top value            [n, 0, 0]
      o            output it                          [n, 0]
       1+          add one                            [n, 1]
         :         duplicate top value                [n, 1, 1]
          r        reverse the stack                  [1, 1, n]
           :       duplicate the top value again      [1, 1, n, n]
            @      move the top value back twice      [1, n, 1, n]
             =?;   pop top two values, if equal, end  [1, n]
                $  swap top two stack values          [n, 1]
                 ! skip next instruction (0)
    

    or

    0:o1+$1-:?!;$!
    

    Try it here!

    Explanation

    0              push 0 to the stack                [n, 0]
     :             duplicate the top value            [n, 0, 0]
      o            output it                          [n, 0]
       1+          add one                            [n, 1]
         $         swap top two values                [1, n]
          1-       subtract one                       [1, n-1]
            :      duplicate top value                [1, n-1, n-1]
             ?!;   if n is 0, end                     [1, n-1]
                $  swap top two stack values          [n-1, 1]
                 ! skip next instruction (0)
    

    For both simply place n on the stack and the result will be outputted.

    redstarcoder

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 771

    1

    SmileBASIC, 31 bytes

    INPUT N
    FOR I=.TO N?CHR$(I)NEXT
    

    . is read as 0.0, and I could have just used 0 in this case, but . looks cooler.

    12Me21

    Posted 2014-10-28T12:46:15.867

    Reputation: 6 110

    1

    J, 8 bytes

    f=:{.&a.
    

    Explanation:

    f=:{.&a.
    f=:      define a function f
          a. the ascii sequence
         &   attach it to the next operator
       {.    take the first n items of
             you'll notice I don't say how many,
             that's because in J you can leave blanks and the interpreter fills them in
    

    Bijan

    Posted 2014-10-28T12:46:15.867

    Reputation: 781

    I trust that you did something, but I don't see what changed. – Bijan – 2017-03-15T13:31:08.047

    Riley's edit formatted the header by prefixing # so it would be styled as a header (larger font, bold). – DLosc – 2017-03-15T22:08:13.077

    1

    √ å ı ¥ ® Ï Ø ¿ , 3 bytes

    Note: Non-competing as language post-dates challenge

    IrW
    

    Explanation

    I   › Take input from command line, evaluate and push to stack
     r  › Push the range from 0 to top value + 1
      W › Output the whole stack as Unicode characters
    

    Alternate Solution

    As pointed out by @FlipTack in his Java answer, it is not clear if the OP wants us to print up to and including the input or excluding the input.

    If the second is true, the solution below is the correct answer.

    IrPW
    

    Explanation

    I    › Take input from command line, evaluate and push to stack
     r   › Push the range from 0 to top value + 1
      P  › Pop the top value from the stack
       W › Output the whole stack as Unicode characters
    

    caird coinheringaahing

    Posted 2014-10-28T12:46:15.867

    Reputation: 13 702

    1

    evil, 10 bytes

    I've been playing around with evil lately, and this is my first PPCG submission (albeit 2.5 years late). I find it a fun esolang to use partially because it seems nobody uses it!

    ramlwalusb
    

    Explanation

    r   // Store input character to Accumulator as byte
    a   // Since we are writing then adding, add 1 to Accumulator
    m   // Drop a loop marker
    l   // Swap Wheel and Accumulator
    w   // Output Accumulator
    a   // Increment Accumulator
    l   // Swap Wheel and Accumulator
    u   // Decrement Accumulator
    sb  // Go back to m if A != 0
    

    evil is also an easy language to write an interpreter for. I think there's a javascript one floating around somewhere, but I ended up just writing my own.

    EDIT: Try it online!

    charliefox2

    Posted 2014-10-28T12:46:15.867

    Reputation: 131

    Cool answer! Welcome to the site! – James – 2017-03-15T18:47:53.347

    1

    Ruby - 35 33 bytes

    Please note that I can't Ruby at all:

    $*[0].to_i.times{|i|puts i.chr()}
    

    William Barbosa

    Posted 2014-10-28T12:46:15.867

    Reputation: 3 269

    1As far as I know there is an alias for "puts" that is simply "p". So -3 bytes if that's correct? – oopbase – 2014-10-28T13:28:21.997

    2@Forlan07, not really an alias. p is equivalent to puts whatever.inspect. – manatwork – 2014-10-28T13:36:58.227

    @manatwork OK, nice to know :-) – oopbase – 2014-10-28T13:39:48.707

    This prints every character on a separate line. Shouldn't it be print? – nyuszika7h – 2014-10-29T13:48:06.730

    Fixed and 3 bytes shorter: puts (0..$*[0]).map(&:chr)*'' – nyuszika7h – 2014-10-29T13:51:18.377

    Sorry, that should be $*[0].to_i, which makes it 2 bytes longer rather than 3 shorter. – nyuszika7h – 2014-10-29T15:28:24.203

    1

    PowerShell - 20

    %{0..$_|%{[char]$_}}
    
    Usage:
    56 | %{0..$_|%{[char]$_}}
    

    SomeShinyObject

    Posted 2014-10-28T12:46:15.867

    Reputation: 953

    A bit debatable to call a piece of syntax that isn't even valid a program or function ;-) (you cannot use ForEach-Object standalone like that). The function part of that is the script block, but it won't ever work as a function, because the context ($_) is provided by ForEach-Object. You can shorten it a bit by casting the range to an array, by the way. – Joey – 2014-10-30T07:32:22.900

    1

    Java, 125 bytes

    class M{public static void main(String[]a){p(256);}static void p(int l){int i=-1;for(;i++<l;){System.out.println((char)i);}}}
    

    Simply puts in the number of characters to print from the ascii table @ p(n) where n is the number of characters.

    Aaron C

    Posted 2014-10-28T12:46:15.867

    Reputation: 131

    1

    Befunge-98, 26 20

    0&;1-::0`j;;,$>:#,_@
    

    It's longer than the other Befunge-98 answer, but it's not self-modifying and only uses one line. (Also, the pointer only moves to the right until it gets to the print loop.)

    This is shorter now. Also, it's still not self-modifying. Hooray, jumping trickery!

    Kasran

    Posted 2014-10-28T12:46:15.867

    Reputation: 681

    1

    Rebol - 35 34

    for n 0 do input 1[prin to-char n]
    

    draegtun

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 592

    1

    If I'm allowed to have another answer in a different language, here goes...

    Pascal: 91 bytes

    PROGRAM A;VAR i,n:Integer;BEGIN
    n:=0;readln(n);FOR i:=0 TO n DO
    Write(chr(i));readln;END.
    

    (just for kicks, really, I haven't messed in Pascal in ages)

    Rodolfo Dias

    Posted 2014-10-28T12:46:15.867

    Reputation: 3 940

    @Dennis is well aware of this. Just check all the questions he's answered – caird coinheringaahing – 2017-03-15T22:00:10.423

    7Posting multiple answers is perfectly fine. – Dennis – 2014-10-28T20:55:55.073

    1

    Python 3 — 51 bytes

    lambda n:sys.stdout.buffer.write(bytes(range(n+1)))
    

    This is a variation of a line I keep in my shell history for when I need to refer to the ASCII table.

    It first calls range(), passing n + 1 as the sole argument. When used like this, range() returns an iterable of integers between 0 (inclusive) and the argument (exclusive—hence the need for the +1). The iterable is then passed to bytes(), which returns a bytestring, interpreting each integer as one byte. The bytestring is then written directly to the buffer for stdout (passing it to sys.stdout.write() or print() would result in an exception; those accept strings, not bytestrings).

    Note that n must not be greater than 255. If it is, bytes() will raise an exception, because values greater than 255 do not fit in a single byte.

    Also note that this doesn't bind the function to a name. I'm assuming that's acceptable, given that it does still create the function.

    Blacklight Shining

    Posted 2014-10-28T12:46:15.867

    Reputation: 170

    >

  • There's no need for all of that: lambda n:print(str(bytes(range(n+1)))) is just 38 characters. 2. If you go with your current method, you need to include import sys.
  • < – Beta Decay – 2014-10-29T15:18:17.490

    Actually, just lambda n:print(bytes(range(n+1))) works perfectly well. – Beta Decay – 2014-10-29T15:20:13.803

    1

    PHP - 47 bytes

    <?=join(array_map('chr',range(0,$argv[1])));
    

    Usage:

    php ascii.php n
    

    zamnuts

    Posted 2014-10-28T12:46:15.867

    Reputation: 263

    join does the same as implode and is 3 bytes shorter. – Titus – 2016-12-14T13:20:36.047

    @Titus good catch, updated! – zamnuts – 2016-12-15T07:21:56.360

    1

    LiveScript - 47

    f=->alert String.fromCharCode.apply(,[0 to it])
    

    nyuszika7h

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 624

    1

    PHP - 36

    If PHP Notice are set to off then this:

    <? for(;$i<$argv[1];)echo chr($i++);
    

    PHP - 42

    Otherwise:

    <? for($i=0;$i<$argv[1];$i++)echo chr($i);
    

    Dexa

    Posted 2014-10-28T12:46:15.867

    Reputation: 236

    -1: omit the whitespace after <?. I have read somewhere in meta that warnings are ok; cannot find it at the moment though. – Titus – 2016-07-13T02:18:42.557

    @Titus -1 for this? I'll just smile and walk away :) – Dexa – 2016-07-13T09:36:29.540

    @Dexa -1 bytes. But actually it´s -3 with the unnecessary PHP tags. – Titus – 2016-12-14T12:03:56.297

    @Titus Oh I meant you downvoted because of this. No problem. – Dexa – 2016-12-14T14:45:07.717

    I think you can remove the PHP tag. JS answers typically don't include script tags, either. – Ingo Bürk – 2014-10-30T07:19:38.413

    OK, ty. First post so not sure how it goes :) – Dexa – 2014-10-30T09:49:55.537

    @IngoBürk That may be because Node.js doesn't need any script tags. You need <?php (or <? if short tags are enabled) for any PHP script, though. – nyuszika7h – 2014-10-30T19:12:20.430

    @nyuszika7h Node doesn't support ES6 and yet ES6 answers don't include tags. – Ingo Bürk – 2014-10-30T19:17:30.273

    I don't see your point. It does have partial support via --harmony, but that doesn't have to be counted unless perhaps the answer relies on Node-specific APIs. Script tags are just a way to include JavaScript in a HTML file, on the other hand even standalone PHP scripts need an opening tag or they won't work. – nyuszika7h – 2014-10-30T19:19:54.447

    @nyuszika7h You're right. Although it can at least be the short tag <? without a closing tag. Sorry for the wrong suggestion, Dexa.

    – Ingo Bürk – 2014-10-30T19:30:26.963

    @IngoBürk not a problem at all. Few chars more or less wont make any difference, other languages do this much better anyway :) – Dexa – 2014-10-31T09:04:16.183

    1

    F# - 66 characters

    [<EntryPoint>]
    let m a=
     for x in char 0..a.[0].[0]do printfn"%c"x
     0
    

    Koopakiller

    Posted 2014-10-28T12:46:15.867

    Reputation: 129

    1

    PowerShell, 20

    [char[]](0.."$args")
    

    Joey

    Posted 2014-10-28T12:46:15.867

    Reputation: 12 260

    1

    C# - 65 63 52

    c=>{for(var i='\0';i<=c;)System.Console.Write(i++);}
    

    Inspired by Java solution

    Usage:

    public class Program
    {
        public static void Main()
        {
            new System.Action<char>(c => {for(var i='\0';i<=c;)System.Console.Write(i++);})((char)255);
        }
    }
    

    Thanks to Martin for the help.

    pmudra

    Posted 2014-10-28T12:46:15.867

    Reputation: 121

    You can probably save two bytes by a) using var instead of char and b) by doing ...Write(i++) and leaving the third section of the for statement empty. – Martin Ender – 2015-06-10T13:43:49.030

    I just saw a python solution using lambdas. So would this be a valid solution: c=>{for(var i='\0';i<=c;)System.Console.Write(i++);}? – pmudra – 2015-06-11T08:46:34.493

    I'm not very familiar with C#'s lambdas, but I think so. – Martin Ender – 2015-06-11T12:45:16.057

    1

    MATLAB: 13 bytes

    @(n)char(0:n)
    

    This is an anonymous function that prints the string.

    MATLAB: 17 bytes

    This one takes STDIN.

    char(0:input(''))
    

    I think these are pretty short for a non-golf language. :)

    Memming

    Posted 2014-10-28T12:46:15.867

    Reputation: 163

    1The standard tips for casting to chars when golfing in MATLAB / Octave: @(n)[0:n,'']. =) Saves you a byte! – Stewie Griffin – 2016-01-12T14:18:33.677

    1

    x86 DOS (11 bytes)

    Takes parameter in CL

    -u100
    07AD:0100 mov ah,02
    07AD:0102 cwd
    07AD:0103 int 21
    07AD:0105 inc dx
    07AD:0106 cmp dl,cl
    07AD:0108 jb 103
    07AD:010A ret
    07AD:010B 
    

    ninjalj

    Posted 2014-10-28T12:46:15.867

    Reputation: 3 018

    1

    Pip, 3 bytes (not competing)

    The language is newer than the question, but happens to do very well with it:

    C,a
    

    a is the first command-line argument. The unary range operator , constructs a range of all numbers 0 <= n < a. Finally, C converts them to characters. The resulting list is autoprinted, by default without any delimiter. Works into Unicode range too!

    DLosc

    Posted 2014-10-28T12:46:15.867

    Reputation: 21 213

    1

    Perl 6, 25 22 bytes

    put (^@*ARGS[0])».chr
    

    Hotkeys

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 015

    1

    F#, 43 bytes

    fun n->Seq.iter(printf"%c")['\x00'..char n]
    

    That is...

    fun n->                                     // A function that takes n
                               ['\x00'..char n] // Generates a list of chars from NUL to n
           Seq.iter(          )                 // For each one,
                    printf"%c"                  // Print it!
    

    I tried using \0 for NUL, but it doesn't work in F#. I couldn't get it under 4 characters, in any case. =P

    Roujo

    Posted 2014-10-28T12:46:15.867

    Reputation: 353

    1

    ES6, 42 bytes

    Sorry for the necro.

    n=>String.fromCharCode(...Array(n).keys())
    

    If you need it as a program, 54 bytes:

    alert(String.fromCharCode(...Array(+prompt()).keys()))
    

    However for some reason I can't get the above to work as a Stack Snippet.

    Neil

    Posted 2014-10-28T12:46:15.867

    Reputation: 95 035

    1

    Lua, 37 Bytes

    a=...for i=1,a do print(a.char(i))end
    

    Katenkyo

    Posted 2014-10-28T12:46:15.867

    Reputation: 2 857

    0

    Java 76 74 70

    Thanks to Mego for saving 4 bytes.

    public void f(int x){for(int u=0;u<x;u++)System.out.println((char)u);}
    

    Previous versions:

    class f{public void f(int x){for(int u=0;u<x;u++)System.out.println((char)u);}}
    class f{public f(int x){for(int u=0;u<x;u++)System.out.println((char)u);}}
    

    The second version needs to be called by new f(n);

    Feel free to give me ideas for making it even smaller.

    cookie

    Posted 2014-10-28T12:46:15.867

    Reputation: 271

    You can do a standalone function: public void f(int x){...}. For even less bytes, if you're working with Java 8, you can use a lambda: x->java.util.stream.IntStream.range(0,x).mapToObj(n->(char)n); – Mego – 2016-12-14T14:44:00.990

    In fact, you don't even need the public - a default-scoped function is fine. – Mego – 2016-12-19T05:32:14.943

    0

    Pushy, 2 bytes

    Non-competing as the language postdates the challenge.

    Input is given on the command line, $ pushy asciitable.pshy 90. Note that this will not work for numbers larger than 127.

    X"
    

    Explanation:

        \ Implicit: Input number on stack
    X   \ Get range [0, n)
     "  \ Interpret as charcodes and print
    

    FlipTack

    Posted 2014-10-28T12:46:15.867

    Reputation: 13 242

    0

    QBIC, 14 bytes, NC

    :[a|?chr$(b-1)
    

    Takes a number form the command line and loops from 1 to that number, feeding each iteration into CHR$.

    Non-competing, QBIC was thought of a year after this challenge was posted.

    steenbergh

    Posted 2014-10-28T12:46:15.867

    Reputation: 7 772

    0

    Perl 6, 9 bytes

    (^*).chrs
    

    The header and code alone are too short, so have this extra sentence.

    bb94

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 831

    0

    Java 8, 45 bytes

    A lambda expression which takes an integer and prints the table to STDOUT. Golfing suggestions welcome!

    x->{for(char i=0;i<x;System.out.print(i++));}
    

    It's not clear whether OP wants x to be the last character printed, or the first character not printed. If it's the second, just change i<x to i<=x :)

    FlipTack

    Posted 2014-10-28T12:46:15.867

    Reputation: 13 242

    0

    Tcl, 47 bytes

    set i 0
    time {puts [format %c $i];incr i} $argv
    

    Try it online!

    sergiol

    Posted 2014-10-28T12:46:15.867

    Reputation: 3 055

    1Making the user set n is not valid – ASCII-only – 2018-05-09T22:10:23.677

    @ASCII-only: I am in the process of reviewing my older answers. Thanks for pointing out – sergiol – 2018-05-09T23:54:55.700

    0

    Python, 30 bytes

    An unnamed lambda function which returns the result as a string.

    lambda n:('%c'*n)%(*range(n),)
    

    Try it online!

    This uses the printf-style string formatting: when '%c' is formatted with an integer, it converts the integer to a character and displays that. So, we multiply the string by n, and format it with all values in range(n).

    29 bytes

    If we want to be cheeky and return a list of characters instead of a string, we can get 1 byte shorter:

    lambda n:[*map(chr,range(n))]
    

    Try it online!

    FlipTack

    Posted 2014-10-28T12:46:15.867

    Reputation: 13 242

    0

    QC 18 bytes

    '00901)01016010003

    '00 Read from stdin and store in memory at address 00
    901 Print memory from address 01 until 0 is reached
    )0101 Increment memory at 01 by 1
    6010003 Jump to 03 if value at 01 and 00 are not equal
    

    Edited because of invalid amount of bytes

    cookie

    Posted 2014-10-28T12:46:15.867

    Reputation: 271

    0

    REXX, 28 bytes

    say xrange('0'x,d2c(arg(1)))
    

    idrougge

    Posted 2014-10-28T12:46:15.867

    Reputation: 641

    0

    Sinclair ZX81 171 bytes for the listing (method 1):

     1 LET N$=""
     2 GOTO 2+(INKEY$<>"")
     3 LET A$=INKEY$
     4 IF A$=CHR$ 118 THEN GOTO 9
     5 IF CODE A$<28 OR CODE A$>37 THEN GOTO 2
     6 PRINT A$;
     7 LET N$=N$+A$
     8 GOTO 2
     9 LET N=VAL N$
    10 IF N>255 THEN LET N=255
    11 PRINT AT 0,0;
    12 FOR I=0 TO N
    13 PRINT CHR$ N;
    14 NEXT I
    

    This is using the INKEY$ command to build a string of numbers, which is checked by comparing each input to the character range from 0 to 9 inclusing in line 5. Each character is stored in the N$ variable and outputted to the screen. CHR$ 118 is the ZX81 equivalent of a new line "\r\n" in PHP for instance.

    There is a check to see if you have entered a valid range once you have pressed NEW LINE (0 to 255 inclusive) - as you can only enter numbers, the range is not going to be below zero.

    Then there is a simple FOR...NEXT loop from line 12 to output the non-ASCII compatible character set. So I lose points because the ZX81 does not handle ASCII without some conversion tables.

    Also, the ZX81 character set is incomplete to upper-case and inversed upper-case only; the remaining characters are either graphical symbols or they are ZX81 BASIC keywords, such as PI, INKEY$, PRINT etc... There is a much simpler method that I will post later, but is more prone to human error.

    Method 2, 34 bytes for the listing, no error checks and sanitizing inputs:

     1 INPUT N
     2 FOR I=0 TO N
     3 PRINT CHR$ I;
     4 NEXT I
    

    Of course I'm sure that someone has already pointed out that true ASCII is 7 bit and the first 8 bit compatible ASCII set was PETSCII.

    Shaun Bebbers

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 814

    0

    Commodore 64/128

    This solution uses PETSCII which is an 8-bit wide ASCII-compatible character set.

    Solution 1 - 42 BASIC bytes used (35 bytes for the listing)

    0 printchr$(14);:fori=0to255:poke1024+i,i:next
    

    Solution 2 - 10 bytes assembled, ~72 bytes source code

    * = 49152
    lda #$00
    tax
    .loop
        sta $0400,x
        dex
        txa
    bne loop
    rts
    

    The assembly is doing what the BASIC listing is doing (without switching the character set to business mode first), but is obviously many times quicker. As the 6502 (6510/85xx) processor has an 8-bit accumulator and [8-bit] registers, we start at zero and count down, so 0 - 1 is 0xff. Each character is stored in the screen RAM located at 0x0400 (1024) and sta $0400,x says store the content of X to location $0400 + x. The bne loop will branch back based on the zero flag, once that is set (i.e., x=0x00) it will drop out of the loop and return to BASIC with rts.

    Once assembled, run with sys 49152 - this solution should work on the C64 and 128. It will work on other Commodore machines as long as you move the routine to a free area of RAM and relocate the starting point of the screen RAM from 1024.

    Shaun Bebbers

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 814

    0

    R, 24 bytes

    cat(intToUtf8(1:scan()))
    

    Try it online!

    JayCe

    Posted 2014-10-28T12:46:15.867

    Reputation: 2 655

    0

    Excel VBA, 26 bytes

    An anonymous VBE immediate window function that takes input from cell [A1]

    For i=1To[A1]:?Chr(i):Next
    

    Taylor Scott

    Posted 2014-10-28T12:46:15.867

    Reputation: 6 709

    0

    Yabasic, 34 bytes

    Input""n
    For i=1To n
    ?Chr$(i)
    Next
    

    Try it online!

    Taylor Scott

    Posted 2014-10-28T12:46:15.867

    Reputation: 6 709

    0

    Kotlin, 42 bytes

    {n:Int->for(c in 0..n-1)print(c.toChar())}
    

    Try it online!

    snail_

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 982

    0

    Check, 2 bytes

    ,o
    

    Try it online!

    Check has:

    • Implicit input
    • A range builtin
    • A builtin to output a list of codepoints as characters

    Esolanging Fruit

    Posted 2014-10-28T12:46:15.867

    Reputation: 13 542

    0

    Momema, 25 bytes

    0*-8j0j+1-=*0-9*00+-1*0j1
    

    Outputs the characters in reverse order. Try it online!

    Explanation

    0   *-8     #            [0] = read num
    j   0       #  label j0: goto j0
    j   +1-=*0  #  label j1: goto j(1 - !![0])
    -9  *0      #            print char [0]
    0   +-1*0   #            [0] = 1 + [0]
    j   1       #  label j2: goto j0
    

    Esolanging Fruit

    Posted 2014-10-28T12:46:15.867

    Reputation: 13 542

    0

    Haskell - 16 22 characters

    (`take`['\0'..])
    

    Edit

    Now printing the result

    print.(`take`['\0'..])
    

    Victor Duarte da Silva

    Posted 2014-10-28T12:46:15.867

    Reputation: 9

    nice trick to get rid of a character – John Dvorak – 2014-10-29T09:32:26.977

    This doesn't actually print the result. – nyuszika7h – 2014-10-29T15:20:47.810

    @JanDvorak he pretty much removed the space, as (``) does the same thing as flip here, in just as many characters... – archaephyrryx – 2014-10-29T15:57:40.007

    0

    Lua

    for i=0,255 do
        print(string.char(i))
    end
    

    Mitchell

    Posted 2014-10-28T12:46:15.867

    Reputation: 11

    4This is code golf, so please include the byte count of your submission in the answer. Also, you don't need the line breaks. You can put all of this in one line like for i=0,255 do print(string.char(i)) end. – Martin Ender – 2014-12-31T19:19:22.380

    This is not valid solution as it not handles input/parameter as required. – manatwork – 2016-07-22T09:27:48.670

    0

    C, 31 bytes

    i;f(n){for(;i<n;)putchar(i++);}
    

    Use:

    i;f(n){for(;i<n;)putchar(i++);}
    
    int main(void)
    {
        f(34);   //Call the function
        return 0;
    }
    

    Spikatrix

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 663

    1The challenge says to output all ASCII characters, not just the printable ones, and also to print "n ACII characters", not "ASCII characters up to n", so you could save 4 characters by letter i default to 0 and changing the loop condition to <.

    And you could save 1 (or 2, depending how eager you are to invoke undefined behavior) character by moving the call to putchar() into the loop condition. – Stuntddude – 2015-06-12T00:26:26.280

    Thanks. Does the program look ok now? – Spikatrix – 2015-06-12T04:42:07.810

    @Stuntddude In whch way moving the putchar inside the loop condition would trigger UB? – edc65 – 2015-06-12T10:16:14.877

    0

    PL/SQL 59

    select chr(rownum)from dual connect by rownum<=&i
    

    Didn't see a requirement that said output had to be a concatenated string, so this should work?

    freekvd

    Posted 2014-10-28T12:46:15.867

    Reputation: 909

    0

    JavaScript, 65 bytes

    First code golf, but here's my simple JavaScript implementation:

    function f(n){for(i=1;i<n;)console.log(String.fromCharCode(i++))}
    

    Not great but decent. ;)

    Usage:

    f(x) // x could be any number, but generally numbers
         // greater than 0 are better. ;)
    

    The output is rather long so I'm not going to copy it but if you run it I think you'll get the idea. :P

    Uncompressed:

    function f(n) {
        for (i = 1; i < n;)
            console.log(String.fromCharCode(i++)); // by using i++ we increase
                                                   // i right as we get it
    }
    

    Florrie

    Posted 2014-10-28T12:46:15.867

    Reputation: 831

    Welcome to PPCG! I don't think you need those braces, and you do the i++ when call the function like ...fromCharCode(i++) and then leave the third section of the for statement empty. – Martin Ender – 2015-06-10T13:42:15.747

    However, I just noticed that your answer isn't quite valid. You should write a function which takes 256 as a parameter. – Martin Ender – 2015-06-10T13:44:16.637

    Also, I think you should start the loop at 0 rather than 1. – Peter Taylor – 2015-06-10T14:00:28.243

    Ah, I'll update to fit what you guys have pointed out. :) – Florrie – 2015-06-10T15:09:02.597

    0

    C#, 112 | 83 bytes

    Full program, 112 bytes:

    class P{static void Main(string[]a){for(int i=0;i<int.Parse(a[0]);i++){System.Console.Write("{0}\n",(char)i);}}}
    

    A function, 83 bytes:

    static void f(int n){for(int i=0;i<n;i++){System.Console.Write("{0}\n",(char)i);}}}
    

    fsacer

    Posted 2014-10-28T12:46:15.867

    Reputation: 131

    0

    Microscript, 9 bytes

    i1{d1s}ah

    Or alternatively:

    i1cs1]fah

    SuperJedi224

    Posted 2014-10-28T12:46:15.867

    Reputation: 11 342

    0

    Excel VBA - 143

    For i = 1 To 127
    Cells(i, 1) = i
    Cells(i, 2) = Evaluate("DEC2HEX(" & i & ")")
    Cells(i, 3) = Evaluate("DEC2OCT(" & i & ")")
    Cells(i, 4) = Chr(i)
    Next
    

    Wightboy

    Posted 2014-10-28T12:46:15.867

    Reputation: 339

    0

    K: 8 bytes

    {10h$!x}
    

    Q: 11 bytes

    {10h$til x}
    

    scottstein37

    Posted 2014-10-28T12:46:15.867

    Reputation: 181

    0

    Gema, 43 characters

    *=@set{i;0}@repeat{*;@int-char{$i}@incr{i}}
    

    Sample run:

    bash-4.3$ gema '*=@set{i;0}@repeat{*;@int-char{$i}@incr{i}}' <<< 96 | xxd 
    0000000: 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f  ................
    0000010: 1011 1213 1415 1617 1819 1a1b 1c1d 1e1f  ................
    0000020: 2021 2223 2425 2627 2829 2a2b 2c2d 2e2f   !"#$%&'()*+,-./
    0000030: 3031 3233 3435 3637 3839 3a3b 3c3d 3e3f  0123456789:;<=>?
    0000040: 4041 4243 4445 4647 4849 4a4b 4c4d 4e4f  @ABCDEFGHIJKLMNO
    0000050: 5051 5253 5455 5657 5859 5a5b 5c5d 5e5f  PQRSTUVWXYZ[\]^_
    

    manatwork

    Posted 2014-10-28T12:46:15.867

    Reputation: 17 865

    0

    Hassium, 45 Bytes

    func a(n)for(x=0;x<n;print((x++).toChar())){}
    

    Run and see expanded here

    Jacob Misirian

    Posted 2014-10-28T12:46:15.867

    Reputation: 737

    0

    Pylons, 9

    0{d1+,i}c
    

    How it works:

    0     # Push 0 to the top of the stack.
    {     # Start a for loop.
     d    # Duplicate the top of the stack.
      1   # Push 1 to the stack.
       +  # Add the top two elements of the stack.
     ,    # Switch to for loop iterators.
      i   # Get input
       }  # End for loop
    c     # Print stack as joined array of chars and exit.
    

    Morgan Thrapp

    Posted 2014-10-28T12:46:15.867

    Reputation: 3 574

    0

    Oracle SQL 11.2, 48 bytes

    SELECT CHR(LEVEL)FROM DUAL CONNECT BY LEVEL<=:1;
    

    Jeto

    Posted 2014-10-28T12:46:15.867

    Reputation: 1 601

    0

    Japt, 7 bytes (non-competing)

    This answer is non-competing because Japt is newer than this challenge.

    Uo md q
    

    Test it online!

    How it works

          // Implicit: U = input integer
    Uo    // Create the range [0..U).
    md    // Map each item X in this range to X.d().
          // If X is a number, this turns into the character with that char code.
    q     // Join the array with the empty string.
          // Implicit: output last expression
    

    ETHproductions

    Posted 2014-10-28T12:46:15.867

    Reputation: 47 880

    0

    DUP, 21 bytes

    [1+a:0[$1+$a;<][^,]#]
    

    Try it here!

    Anonymous lambda. Usage:

    256[1+a:0[$1+$a;<][^,]#]!
    

    Explanation

    [                     {start lambda}
     1+a:                 {inputnum is end of range (saved to a)}
         0                {0 is start of range}
          [       ][  ]#  {while loop}
           $1+$a;<        {dup, increment, check if top of stack < a}
                    ^,    {if so, output char}
                        ] {end lambda}
    

    Mama Fun Roll

    Posted 2014-10-28T12:46:15.867

    Reputation: 7 234

    0

    Jelly, 2 bytes

    ḶỌ
    

    Try it online!

    According to current reference implementation as of time of posting.


    Jelly, 3 bytes

    ‘ḶỌ
    

    Try it online!

    Inclusive. Reference implementation is exclusive.

    Erik the Outgolfer

    Posted 2014-10-28T12:46:15.867

    Reputation: 38 134

    @ASCII-only Well, I may update the links here, but it's not just the certificates.

    – Erik the Outgolfer – 2018-05-09T22:09:27.280