Slashdot Mirror


How Does a Single Line of BASIC Make an Intricate Maze?

JameskPratt writes "This Slate article talks about a single line of code — 10 PRINT CHR$ (205.5 + RND (1)); : GOTO 10 — and how it manages to create a complicated maze without the use of a loop, variables and without very complicated syntax." Now that amazing snippet of code is the basis of a book, and the book is freely downloadable.

438 comments

  1. Obfuscation by Anonymous Coward · · Score: 0

    It's time to start the Obfuscated BASIC contest...

    http://www.ioccc.org/

  2. Without the use of a loop!? by Anonymous Coward · · Score: 5, Insightful

    What is
    10 something: GOTO 10
    if not an (endless) loop?

    1. Re:Without the use of a loop!? by Nutria · · Score: 4, Informative

      That's exactly what I thought... Maybe JameskPratt isn't a very good programmer.

      --
      "I don't know, therefore Aliens" Wafflebox1
    2. Re:Without the use of a loop!? by dcollins · · Score: 1

      [slick salesman voice] This is not your grandchild's looping mechanism! [/slick salesman voice]

      --
      We know where leadership by an anti-intellectual "strongman" who scapegoats minorities and likes boisterous rallies goes
    3. Re:Without the use of a loop!? by thestudio_bob · · Score: 2

      print REPLY; goto PARENT;

      --
      The real Sig captains the Northwestern. This one captains /.
    4. Re:Without the use of a loop!? by Anonymous Coward · · Score: 5, Informative

      No shit, and it is not a labyrinth either. It is just randomly printing forward slashes and backlashes.

    5. Re:Without the use of a loop!? by K.+S.+Kyosuke · · Score: 1

      What is 10 something: GOTO 10 if not an (endless) loop?

      Well, in certain dialects of Forth, you'd probably be able to write it using tail recursion. And it would be probably slightly shorter. :-)

      --
      Ezekiel 23:20
    6. Re:Without the use of a loop!? by gl4ss · · Score: 4, Insightful

      No shit, and it is not a labyrinth either. It is just randomly printing forward slashes and backlashes.

      "an intricate combination of paths or passages in which it is difficult to find one's way or to reach the exit."

      it is that. it's just not very amazing at all if you describe it as printing \ and / randomly.

      --
      world was created 5 seconds before this post as it is.
    7. Re:Without the use of a loop!? by Potor · · Score: 3, Insightful

      this is one of the stupidest /. stories ever -- it is not one line of code, and it is a loop, as you and many others point out.

    8. Re:Without the use of a loop!? by shitzu · · Score: 4, Insightful

      And most importantly - its not a particularly amazing piece of code. I am not a programmer, but know how to write basic stuff in a few languages - and i do not find a TWO LINE LOOP that fills the screen with a choice between two characters that make up something that LOOKS LIKE A MAZE, but is not necessarily navigable not a least bit amazing.

    9. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0
    10. Re:Without the use of a loop!? by Samantha+Wright · · Score: 1

      it's just not very amazing at all if you describe it as printing \ and / randomly.

      You are really going to break the author's heart if you keep that up.

      It's hard to look at this story and not feel that it's a base case in an inductive proof that refutes the existence of art.

      --
      Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
    11. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 3, Informative

      " it is not one line of code"

      Actualy, it absolutely is just one line of code. You are confusing the number of statements with the number of lines. In BASIC, as in many languages, you can have multiple statements and operation in a single line of code. Those statements do indeed however constitute an infinite loop, however.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    12. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      I think ./ might have just nuked the fridge.

    13. Re:Without the use of a loop!? by Endophage · · Score: 2

      Submitter was a moron. From the book: "For a one-line program that loops forever..." also "...it uses GOTO 10 to loop back..."

    14. Re: Without the use of a loop!? by Anonymous Coward · · Score: 4, Funny

      Pratt by name . . .

    15. Re:Without the use of a loop!? by Samantha+Wright · · Score: 0

      I'm sorry, the submitter can't hear you over how AMAZING this code snippet is. Buy a t-shirt!

      --
      Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
    16. Re:Without the use of a loop!? by erroneus · · Score: 4, Interesting

      I think there is a bit of a story in the fact that while in function, it is extremely simple though in result/appearance it creates what most perceive to be a complex maze of passages. The code puts out random positive space objects while the mind sees a single, complex negative space.

      It sort of reminds me of similar little tricks used to generate landscapes and other such things... mandelbrot comes to mind.

    17. Re:Without the use of a loop!? by tofubeer · · Score: 1

      To be a maze it would need an exit and and an entrance that are connected to one another.

    18. Re:Without the use of a loop!? by stokessd · · Score: 5, Funny

      The code puts out random positive space objects while the mind sees a single, complex negative space.

      Sadly, that's the way I'm seeing slashdot these days...

    19. Re:Without the use of a loop!? by Black+Parrot · · Score: 5, Funny

      Maybe he's trolling to see who will admit that they know BASIC.

      --
      Sheesh, evil *and* a jerk. -- Jade
    20. Re:Without the use of a loop!? by swillden · · Score: 5, Insightful

      It sort of reminds me of similar little tricks used to generate landscapes and other such things... mandelbrot comes to mind.

      Except that the Mandelbrot set, for example, really is much, much more interesting. It actually has a great deal of sophisticated structure, that's highly chaotic (in both typical and mathematical senses of the word) but not random at all. Not at all comparable to this example, whose output has no real structure at all, but just exploits the tendency of the human brain to find patterns whether or not they exist.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    21. Re:Without the use of a loop!? by Endophage · · Score: 1

      Calm down my dear. I think you need a brown paper bag to breathe into before you start hyperventilating.

    22. Re:Without the use of a loop!? by Anonymous Coward · · Score: 1

      Yeah, you can take 2 statements that would always appear on separate lines, and cram them onto the same "line" by using termination and removing the carriage return. But to most anyone, that's two lines.

      But the point of this book doesn't appear to be about how miraculous this snippet is. It's just the gimmick to anchor greater discussion. FTA:

      The book, which has also been released for free download under a Creative Commons license, unspools 10 PRINTâ(TM)s strange history and dense web of cultural connections, winding its way through the histories of mazes and labyrinths, grids in modern art, minimalist music and dance, randomness, repetition, textiles, screensavers, and Greek mythology. There are forays into early computer graphics, hacking, Cold War military strategy and Pac-Man. References abound, from the Commodore 64 userâ(TM)s manual to Roland Barthesâ(TM) S/Z. This is a book where Dungeons and Dragons and Abstract Expressionism get equal consideration.

    23. Re:Without the use of a loop!? by Tough+Love · · Score: 1

      Apparently, the target market for the book is anybody who believes that is not a loop.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    24. Re:Without the use of a loop!? by Sique · · Score: 2

      No. This would make it a solvable maze. So it's just a maze, or "a puzzle consisting of a complicated network of paths or passages".

      --
      .sig: Sique *sigh*
    25. Re:Without the use of a loop!? by MightyMartian · · Score: 4, Funny

      Much like a televangelist or politician then.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    26. Re:Without the use of a loop!? by Nutria · · Score: 2

      What programmer doesn't know/can't figure out rudimentary BASIC?

      --
      "I don't know, therefore Aliens" Wafflebox1
    27. Re:Without the use of a loop!? by Samantha+Wright · · Score: 5, Insightful

      It's called a display hack. They're at least as old as the oscilloscope, and have always been a mainstay of the demoscene. The book provides little actual relevant history about the context of this snippet in that regard, only noting that the snippet itself derives from the C64 User's Manual.

      Somewhat dismayingly, the bulk of the text ponders on criticism that presumes an intentional, carefully-planned artist:

      10 PRINT picks up on aspects of "Mouse in the Maze." Its output is a regular arrangement of "walls" in a grid—akin to the display of that earlier program and similar to the arrangement of the stereotypical laboratory maze. "Mouse in the Maze" does not present the compelling creation of an inspired Daedalus, but a behaviorist experiment. This maze is a challenge to intelligence—not, however, a romantic, riddling intelligence, but a classically conditioned, animal kind. It also brings in the idea of the scientist, who may be indifferent to the struggles of the creatures lost in the maze.

      This manner of thinking, now put on display nakedly in the context of something completely mathematical and involving no relevant human imagination, can plainly be seen to be philosophically inconsistent. The author has said that a very simple natural phenomenon is influenced by a complex work of art (specifically a TX-0 game from twenty or so years earlier), which indicates a profound metaphysical error.

      Certainly it is worthwhile to talk about chaotic functions (like the R pentamino in Conway's Game of Life, in addition to the display hacks already mentioned) but attempting to critique them as if they were part of the artistic canon is intellectually dishonest.

      --
      Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
    28. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      " But to most anyone, that's two lines."

      If you are saying most people don't know BASIC and don't understand the difference between a statement and a line then I won't disagree with you. However, there is no way to weasel around the facts as you are attempting to do. It is not, under any circumstances, acceptable to refer to a single line as two lines just because that single line is comprised of multiple statements.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    29. Re:Without the use of a loop!? by NFN_NLN · · Score: 3, Informative

      No shit, and it is not a labyrinth either. It is just randomly printing forward slashes and backlashes.

      I disagree, I think this finally proves the existence of god. ;)

    30. Re:Without the use of a loop!? by erroneus · · Score: 0, Redundant

      Hehe.... this guy needs to be modded funny.

    31. Re:Without the use of a loop!? by Hognoxious · · Score: 0, Flamebait

      Don't be too harsh on him. He uses the phrase "most anyone", which means he probably never wore shoes until he attended his sister's wedding, which also happened to be his own.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    32. Re:Without the use of a loop!? by erroneus · · Score: 1

      But but but... he wrote a program that generated these "complex mazes!" He's entitled to any copyrights associated with the output of this program! AMIRIGHT?

      Yeah, I get that math generated output is not particularly worthy of consideration beyond identifying what it actually is.

      But then again we see this all the time. People representing simple things as great things. Apple under Steve Jobs made a life long career of it.

    33. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      Because 'goto label' isn't used in any other programming language...

    34. Re:Without the use of a loop!? by Anonymous Coward · · Score: 1

      When BASIC was popular, some magazines had very nice one liners. I concur this one does not seem very interesting. And one would not use a variable for this kind of problem in most other languages too.

    35. Re:Without the use of a loop!? by war4peace · · Score: 1

      MS-DOS batch jobs.
      C.
      Visual Basic.

      --
      ...gis sdrawkcab (usually not responding to ACs; don't bother posting as AC)
    36. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      A random maze isn't self-similar and it hasn't much discernible structure. The Mandelbrot set is much more appealing. If you zoom into a grid of slashes and backslashes all you see is pixels.

    37. Re:Without the use of a loop!? by icebike · · Score: 1

      Swoosh...

      --
      Sig Battery depleted. Reverting to safe mode.
    38. Re:Without the use of a loop!? by egcagrac0 · · Score: 2

      I can't think of any processors that don't have a JUMP or equivalent. So, assembly/machine code.

      Intercal has COME FROM, which is basically the same thing.

    39. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0, Informative

      This guy needs to be modded insightful.

    40. Re:Without the use of a loop!? by egcagrac0 · · Score: 1

      This is not a proof, it's a demonstration.

    41. Re:Without the use of a loop!? by mrbester · · Score: 1

      Hrm. Maybe they were rubbish interpreters but no BASIC I ever used back in the late 70s / early 80s supported multiple statements.

      Using those interpreters would indeed require two lines.

      --
      "Wait. Something's happening. It's opening up! My God, it's full of apricots!"
    42. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      Yes, they did. You just either don't remember it or didn't know about it at the time.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    43. Re:Without the use of a loop!? by Anonymous Coward · · Score: 3, Informative

      The difference between a maze and a labyrinth is that the goal of a maze is to get from the entrance to the exit. The goal of a labyrinth on the other hand is to get to the center. If there is no entrance and there is no exit, it isn't a maze by strict definition, but a set of paths.

    44. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      10 PRINT CHR$(46.5+RND(1));:GOTO 10

    45. Re:Without the use of a loop!? by The+Moof · · Score: 4, Insightful

      If you want to go that route, every program written in C can be condensed down to 1 line. Or any language where whitespace isn't significant.

    46. Re:Without the use of a loop!? by Anonymous Coward · · Score: 1

      Strangely, printing \ and / randomly doesn't create the maze effect. The characters don't join up, and you continue to see characters instead of lines. Characters u2571 and u2572 yeild an effect much more in line with the original demo. I'd demonstrate, but slashdot hates unicode.

    47. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      You forgot to set the colors:
      5 POKE 53280,12:POKE 53281,5:POKE 646,1
      (no teal so I went with green)

    48. Re:Without the use of a loop!? by styrotech · · Score: 1

      That was the summary's fault.

      The actual article didn't say there was no loop at all:

      The line of code seems basic, even for BASIC. There aren't any variables. It uses a GOTO instead of a more elegant loop.

    49. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 2

      " every program written in C can be condensed down to 1 line"

      This would be true if it were not for the pre-processor. You cannot, for example #include multiple external files on the same line or have multiple #defines on the same line. As far as "going that route" goes, the only route I took was making factually correct statements to correct the factually erroneous ones repeated far too many times on this subject. This isn't open to interpretation, unless you happen to be a C interpreter* that is ;-)

      * Before some idiot tries to point out that C is a compiled language, you should be aware that there are in fact C interpreters. Nothing about the language makes it intrinsically compile only, just as BASIC can be compiled even though it is typically an interpreted language.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    50. Re:Without the use of a loop!? by egcagrac0 · · Score: 4, Informative
      #include
      main() { ten: printf("%c", (rand()%2)?47:92); goto ten; }

      The preprocessor include directive is on a separate line, but that's really not part of the program.

    51. Re:Without the use of a loop!? by arisvega · · Score: 1

      What is 10 something: GOTO 10 if not an (endless) loop?

      'something' may include a 'break'- or 'exit'-type of statement, encapsulated into an 'if' block. If the conditional pans out, the program will break and there will be no loop because the 'GOTO 10' will never be reached.

      --
      The three laws of thermodynamics:(1) You can't win. (2) You can't break even. (3) You can't even quit.
    52. Re:Without the use of a loop!? by narcc · · Score: 5, Interesting

      Indeed, it isn't exactly rocket science -- zillions of kids under 10 picked up the basics of BASIC from type-in programs in kids books and magazines back in the 80's.

      What bugs me most is that instead of doing the obvious (making a binary tree maze) it's some weird artifact of how the / and \ combine on-screen that makes something that vaguely resembles a maze -- full of loops (no big deal) large winding sections without any junctions (bad), and isolations (terrible!).

      Just for fun:

      IBM PC users! You can modify the C64 program in the summary to both run on your micro and produce a binary tree maze with this simple change: PRINT CHR$(220 + INT(RND(1)*2) );

      You won't be able to get the same effect with alternating forward- and back-slashes with something like PRINT CHR$(47 + INT(RND(1)*2)*45); as they don't connect at all -- neither on the same line nor between lines.

    53. Re:Without the use of a loop!? by Richy_T · · Score: 1

      I once used a "labyrinth" which had a tunnel underground to the outside (Leeds castle) does this then count as a maze? (Probably not). Are they topologically equivalent or is it more equivalent to a Klein bottle?

    54. Re:Without the use of a loop!? by Anonymous Coward · · Score: 5, Funny

      The code puts out random positive space objects while the mind sees a single, complex negative space.

      I don't even see the random positive space objects anymore. I just see blonde, brunette, redhead...

    55. Re:Without the use of a loop!? by war4peace · · Score: 1

      Yeah I know :) but better me than some newb, right? :P

      --
      ...gis sdrawkcab (usually not responding to ACs; don't bother posting as AC)
    56. Re:Without the use of a loop!? by Richy_T · · Score: 2

      I was thinking of posting something like the GP's post but after reading yours, I went to check and you're right. Spectrum Basic had multi-statement lines. ZX81 basic didn't though so there may be some validity though it can rightfully be regarded as very far from a standard basic with many missing features.

    57. Re:Without the use of a loop!? by Richy_T · · Score: 1

      Technically, the random number generator probably used a system variable too. For this example, that doesn't make a difference but I recall from my number theory class that pseudo-random numbers often generate organized patterns when plotted in 3d space so I thought this might be some interesting manifestation of a similar effect rather than just pointless babble.

    58. Re:Without the use of a loop!? by andrewa · · Score: 1

      Why am I not surprised that Nick Montfort is involved in this? He's the most pompous and pretentious author around. He's made a living out of glorifying retro technology in glowing terms - this latest effort is just typical of his approach that there is something deep and mystical about randomly generating characters on a c64 screen.

      --
      :(){ :|:& };:
    59. Re:Without the use of a loop!? by Richy_T · · Score: 1

      Actually, I can see how that could actually be ambiguous to someone with absolutely no knowledge of the field.

    60. Re:Without the use of a loop!? by Eunuchswear · · Score: 0

      fucking mod fucking parent up !

      --
      Watch this Heartland Institute video
    61. Re:Without the use of a loop!? by Richy_T · · Score: 1

      That there is a loop is defined by the structure of the code, not by what happens when it runs. if(0)while(1); also contains a loop.

    62. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      Then any c program can be considered one line of code and then "one line of code" would be meaningless. To have meaning it must mean one statement.

    63. Re:Without the use of a loop!? by KingMotley · · Score: 1

      Which basic was that? Because QBasic, GWBasic, the C-64 Basic, Apple basic, and Atari basic all supported it.

      I can't think of a single basic that did not support multiple statements per line.

    64. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 3, Informative

      Actually, you almost understood the implications. "One line of code" is in fact meaningless. It is one of the many reasons why using LOCs as a metric when assessing the quality and productivity of a codebase and its team is not a particularly useful approach.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    65. Re:Without the use of a loop!? by Dan+East · · Score: 3, Informative

      That's be cause you don't appreciate the context in which this code came to exist. Back in the early eighties, to be able to generate such visually impressive and complex looking imagery with so little code, was quite an amazing thing. I, for one, wish I would have known that bit of code back then as a ten year old. It certainly would have beaten my usual "10 PRINT "DAN WAS HERE!!! "; 20 GOTO 10" that I would type into the C64s, TI-99/4As, Atari 800s, and other computers on display at K-Mart and Sears.

      For the sake of completeness, here is a version that works with the syntax (and character set) of another home computer of the era, the TI-99/4A


      10 PRINT CHR$(INT(RND+.5)*45+47);
      20 GOTO 10

      The code is a little more complex because the forward and backward slash characters are not contiguous in the TI's character set (47 and 92). The result visually isn't as good because the TI's character glyphs are more spaced out than the C64's. However it does work - I tested it in the emulator (with standard TI BASIC, doesn't required Extended BASIC).

      --
      Better known as 318230.
    66. Re:Without the use of a loop!? by LordKronos · · Score: 1

      No shit, and it is not a labyrinth either. It is just randomly printing forward slashes and backlashes.

      "an intricate combination of paths or passages in which it is difficult to find one's way or to reach the exit."

      it is that. it's just not very amazing at all if you describe it as printing \ and / randomly.

      It's not difficult at all. In order to be difficult, I think there would have to be some decision making. The output from this program generate passageways that have absolutely no branching in them. You never have to make a single decision. They are all simply winding passageways that either
      1) connect from one edge to another (or back to the same edge),
      2) form a loop, or
      3) form a small diamond shaped room.

      There are no splits, and no dead ends.

    67. Re:Without the use of a loop!? by KingMotley · · Score: 1

      I take that back. I don't think the atari basic that ran on the 2600 with it's awesome 9 lines of code, and only 128 bytes total of usable memory could do multiple statements per line, but that was so long ago I'm not totally sure.

      Business Basic on AT&T Unix also supported multiple statements per line. There were many basics that came later that I used, but as far as I can recall, they all supported it as well.

    68. Re:Without the use of a loop!? by PCM2 · · Score: 1

      If we wanna quibble, the BASIC example given isn't really all that "random," either. The RND(x) function in 8-bit BASIC was (naturally) only pseudo-random, and not terribly chaotic, either. The way I recall it, on the Apple ][ at least, it really didn't take all that long at all to see the pattern start to repeat itself.

      --
      Breakfast served all day!
    69. Re:Without the use of a loop!? by Dan+East · · Score: 5, Interesting

      A simple addition makes the TI-99/4A version look visually just like the C64's. That is to simply define the forward and backward slash characters to look more the C64's and span the whole area of the character's bitmap.


      10 CALL CHAR(47, "C0E070381C0E0703")
      20 CALL CHAR(92, "03070E1C3870E0C0")
      30 PRINT CHR$(INT(RND+.5)*45+47);
      40 GOTO 30

      Finally, if we're going to go to the trouble of defining character images, then we might as well use contiguous character codes so we don't need the extra math. We could use the C64's exact values, however the TI's character set only has 128 characters. So we'll use values 100 less than the C64 version. Also, the TI rounds floating values to integers, whereas the C64 simply truncates them. So we don't need to add .5 to the random value.


      10 CALL CHAR(105, "C0E070381C0E0703")
      20 CALL CHAR(106, "03070E1C3870E0C0")
      30 PRINT CHR$(105+RND);
      40 GOTO 30

      --
      Better known as 318230.
    70. Re:Without the use of a loop!? by Dan+East · · Score: 5, Informative

      And finally, here's a screenshot in case anyone actually cares what the TI version looks like.

      http://dexsoft.com/slashdot/ti_screenshot.png

      --
      Better known as 318230.
    71. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      You might be legally retarded.

    72. Re:Without the use of a loop!? by nog_lorp · · Score: 1
      No, it isn't. Per the Dartmouth BASIC v2 Manual, page 4:

      We immediately observe several things about the above sample program.
      First, all lines in the program start with a line number. These serve to identify the lines in the program, each one of which is called a statement; ...

      Clearly, in BASIC terminology, line and statement are synonymous. Originally, the semicolon statement terminator did not even exist.
      Later adaptations of BASIC allow you to put multiple statements in a single physical line, but the numbers are line numbers and not statement numbers. In BASIC terminology this would be a multi-line program.

      Furthermore, if the above technical reasoning were not true, it would still be pedantic and borderline-incorrect to refer to this as a one liner, just would refer to a multi-statement C program or Perl program as such.

    73. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      [citation needed]

    74. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      No, it isn't.

      Yes, it is.

      Per the Dartmouth BASIC v2 Manual, page 4:

      The program isn't written in Dartmouth BASIC.

      Clearly, in BASIC terminology, line and statement are synonymous. Originally, the semicolon statement terminator did not even exist.

      That's like saying that "thread" and "process" are synonymous, because you're looking at an old system that doesn't support multiple threads per process.

      Later adaptations of BASIC allow you to put multiple statements in a single physical line, but the numbers are line numbers and not statement numbers.

      Yes, and there's one line number in the program in question, therefore it consists of one line.

      Furthermore, if the above technical reasoning were not true, it would still be pedantic and borderline-incorrect to refer to this as a one liner, just would refer to a multi-statement C program or Perl program as such.

      Not so much C, but people refer to Perl, shell, etc programs like that as one-liners ALL THE FUCKING TIME.

    75. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      "Clearly, in BASIC terminology, line and statement are synonymous."

      Try to be serious, and then think for a minute. Have you ever seen the error "Syntax error in statement 30". Now pay careful attention. Lines are numbered, and may have one or more statements. The fact that some implementations didn't afford a way to have multiple statements on a line, in no way makes the term line and statement synonymous. Just because, in certain pre-ANSI implementations, there was no way to have multiple statements per line, that doesn't mean that a line and a statement are the same. It might be that you don't know what the word synonymous means, or it might be that you don't realize that a one to one correlation doesn't mean Hey, there the same thing!. For example, in general, if I have 4 male dogs they each have one and only one penis, but nobody is idiotic enough to run around saying "Hey. Dog and Penis are synonymous!"

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    76. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      This guy needs to be modded profane.

    77. Re:Without the use of a loop!? by BasilBrush · · Score: 1

      Then the Dartmouth BASIC v2 Manual is wrong. Manuals often have mistakes in them.

      In BASIC, lines are lines, statements are statements. They are not synonymous.

      10 PRINT CHR$ (205.5 + RND (1)); : GOTO 10
      is most definitely a one line, two statement program.

      Originally, the semicolon statement terminator did not even exist.

      The semicolon statement terminator never existed. In BASIC, the semicolon is a statement separator, not a terminator.

    78. Re:Without the use of a loop!? by BasilBrush · · Score: 1

      Hrm. Maybe they were rubbish interpreters but no BASIC I ever used back in the late 70s / early 80s supported multiple statements.

      What BASIC interpreters did you use? Every BASIC I used back in that era allowed semicolon statement separators. Heck Microsoft BASIC allowed it and the vast majority of microcomputer BASICs back then were Microsoft BASIC. Including Commodore and Apple (after the very fist Integer BASIC).

    79. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      The difference between a maze and a labyrinth is that the goal of a maze is to get from the entrance to the exit. The goal of a labyrinth on the other hand is to get to the center. If there is no entrance and there is no exit, it isn't a maze by strict definition, but a set of paths.

      Close, but a labyrinth really isn't a puzzle like a maze.

      In colloquial English, labyrinth is generally synonymous with maze, but many contemporary scholars observe a distinction between the two: maze refers to a complex branching (multicursal) puzzle with choices of path and direction; while a single-path (unicursal) labyrinth has only a single, non-branching path, which leads to the center.

      The goal of a labyrinth is meditative.

    80. Re:Without the use of a loop!? by mrbester · · Score: 1

      Knight BASIC / Xtal BASIC (Sharp MZ80A/K) and Sinclair BASIC didn't. Seeing as I moved on to Pascal in 1981 my point remains valid: *no BASIC I ever used at the time* supported it.

      My memory is fine. Your reading comprehension needs improving.

      --
      "Wait. Something's happening. It's opening up! My God, it's full of apricots!"
    81. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 2

      I picked the one out that I actually thought might prove you right (Sinclair), and imagine my surprise when I was able to prove you wrong with the first link I clicked. Pay careful attention to the example program which includes multi-statement lines like: 170 LET in=1: IF r$="y" THEN GO TO 210 and 510 IF qf>nq-1 THEN PRINT "I'm sure your animal is very", "interesting, but I don't have","room for it just now.": GO TO 800

      I accept your apology.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    82. Re:Without the use of a loop!? by sg_oneill · · Score: 1

      No its not one of the stupidist stories, you've made one of the stupidist comments. The line of code is a rather famous one, that was well known in the 80s as something kids would memorize and drop into peoples computers as a way of impressing each other. I had memorized the amstrad version of it.

      The book is about the history of the line and people musing on the meaning of it all. These folks getting upset that its not a real maze or whatever are *seriously* missing the point. It was silly in the early 1980s, its no less silly now. But it was also something that was impressive then, and thus historically relevant now.

      --
      Excuse the Unicode crap in my posts. That's an apostrophe, and slashdot is busted.
    83. Re:Without the use of a loop!? by sg_oneill · · Score: 1

      Yes C could be more or less condensed to 1 line.ÂVery ugly line.

      But its not quite equivilent because the line number tags in earlier versions of basic are still relevant here. You cant just pack the whole program on one line in basic unless you forgo the goto and gosub commands, which somewhat pulls the language out of the turing completeness pool I'd imagine.

      --
      Excuse the Unicode crap in my posts. That's an apostrophe, and slashdot is busted.
    84. Re:Without the use of a loop!? by sg_oneill · · Score: 1

      Almost all home computer basics, with the exception of the Amstrad and sinclair units (The amstrad supported it) where based on microsoft basic being that it was cheap to licence and they'd port the damn thing for you. All of them, from memory, supported fitting multiple statements onto a single line.

      Here is why the categorically a line is NOT a statement. A statement is a unit of execution, and a line is a unit of flow control. That is the two major flow control commands could only point to line numbers not specific statements, and you could pile on as many statements into that line as was sensible. Of course flow went from line to line linearly so it was usually more sensible to do it that way.

      This is not unintentional as it was how contemporous systems worked, notably fortran which shares a lot in common with basic (if I remember right fortran let you omit line numbers for parts of the code further abstracting even further the line/statement difference) , and the later LOGO language which quite specifically relied on a very marked difference between lines and statements to organize flow control.

      --
      Excuse the Unicode crap in my posts. That's an apostrophe, and slashdot is busted.
    85. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      If you don't think it is part of the program, then remove it and see how well it works.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    86. Re:Without the use of a loop!? by Alien+Being · · Score: 1

      Ain't nobody, nowhere, gonna code this clusterfuck in one line.

    87. Re:Without the use of a loop!? by osu-neko · · Score: 1

      Hrm. Maybe they were rubbish interpreters but no BASIC I ever used back in the late 70s / early 80s supported multiple statements.

      What BASIC interpreters did you use? Every BASIC I used back in that era allowed semicolon statement separators. Heck Microsoft BASIC allowed it and the vast majority of microcomputer BASICs back then were Microsoft BASIC. Including Commodore and Apple (after the very fist Integer BASIC).

      Colons, actually. Semicolons were not used a statement separators, but as separators between items in a PRINT statement, e.g. PRINT CHR$(4);"OPEN FILE"

      --
      "Convictions are more dangerous enemies of truth than lies."
    88. Re:Without the use of a loop!? by osu-neko · · Score: 1

      The line you're misquoting is only correct in the context you ripped it from. In the example program it's referring to, each line happens to contain only one statement, so the statement is true. The implication you're trying to draw from that (that in BASIC terminology, rather than simply in this example, "line" and "statement" are synonymous) is quite false.

      --
      "Convictions are more dangerous enemies of truth than lies."
    89. Re:Without the use of a loop!? by museumpeace · · Score: 1

      I found I could dump screen capture to Paint, save as black/white then reopen and save as color...and patch a few breaks in the maze wall. and then flood colors into the maze to see where things run...left hand traverse will not always get you out of this "maze". still, like DNA, a lot of interest for one instruction.

      --
      SLASHDOT: news for people who can't concentrate on work or have no life at all and got tired of yelling back at the TV.
    90. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      Or single line in what the BASIC interpreters back then would allow you to type. I don't know about the C64 or other computers of the day, but on the Apple // I believe you could at most type about 255 characters before it forced you to start a new line. I don't recall if it just abandoned what you just typed, or just parsed what you typed up to that point. However when you listed the program line, the common "?" shortcut would be expanded to "PRINT", and the rest of the code would be expanded with spaces and such. This effectively pushed the line past the 255 character limit and making it impossible to cursor-trace (eg. when debugging.) It was a common challenge back then to try and write a full program that did something useful/interesting within one or two lines of typeable text.

      If you looked through TFB. it talks about various tricks that programmers used to squeeze as much code as possible into one line. While Applesoft only had the "?" shortcut for "PRINT", C64 BASIC allowed you abbreviate even more commands, effectively allowing you to squeeze even more code in the space of the input buffer. (or whatever the proper term.)

      Of course much of the above means nothing when the program in question can almost be typed in single line of a 40 column screen, spaces included.

      I find the program to be quite elegant. Most people if asked to write this program (in BASIC) would probably first come up with something like:
      10 A = INT (RND (1) * 2 )
      20 IF A = 0 THEN PRINT "\"; ELSE PRINT "/";
      30 GOTO 10

      (Applesoft didn't have an ELSE statement, so I'm guessing that's how it was formatted in other BASICs) The program in TFB takes advantage of two things. 1, floating point numbers fed into CHR$ are truncated to integers. 2, the two slash characters used are adjacent graphical characters in Commdore's extended set. The actual slashes that we're familiar with aren't adjacent in ASCII (characters 42 & 97 specifically.)

      You could condense the above program by eliminating the assignment, placing the random number generation directly into the comparison, or even further by using "RND(1) > .5" Sticking strictly with ASCII, one could do an alternate version with
      10 PRINT MID$("\/", RND (1) * 2, 1); : GOTO 10
      (Might have to add "+ 1" to the middle argument, it's been a while)

      10 PRINT CHR$ (205.5 + RND (1)); : GOTO 10 however takes advantage of item #2 and comes up with a beautiful solution. A stupidly simple program that produces a seemingly complex visual result.

    91. Re:Without the use of a loop!? by MickLinux · · Score: 1

      I'm pretty sure the timex sinclair allowed it, but how about the basic stamp computers? How about the casio 8000 pocket calculators? Not all of us were so priveledged to have expensive toys like the Apple ][+.

      That said,

      http://www.nibblemagazine.com/NibbleOneandTwoLiners(Complete).zip

      --
      Correct Horse Battery Staple: 72 bits of entropy. Enter "Correct H" into google. When it generates the phrase, that's
    92. Re:Without the use of a loop!? by neonsignal · · Score: 1

      for the maze effect, you need an old fashioned micro with a character size so small (eg 8 pixels square) that the slash characters were forced to go from one corner to the opposite just to make them legible...

    93. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      The amazing thing is that the a human looks at a random series of slashes and backslashes and therir brain says, "hey, that's a maze". Similar to looking at a bunch of squiggles on a page and saying "hey, that's the Tao Te Ching", or a bunch of pixels on a page and saying, "hey, that's my girlfriend, and who's that guy".

    94. Re:Without the use of a loop!? by meerling · · Score: 1

      It's more of a maze-like randomized pattern as there may or may not be a path through, though it is definitely labyrinthine.

    95. Re:Without the use of a loop!? by narcc · · Score: 5, Interesting

      A binary tree maze algorithm will generate a "perfect maze" (no loops, isolations, and only a single path between any two cells), though you need a long hallway along two sides (depending on which edges you use for walls).

      Mazes with square cells share edges, so by assuming some rules about the outside walls of a maze, you can represent each cell in a maze with only two bits. You need only store, for example, just the south and west walls of each cell.

      To make a binary tree maze, first assume an outer wall and a long hall (no south walls) in the first column, and along the bottom row (no west walls). For all remaining cells, randomly add a west or south wall. You don't need any information about adjacent cells -- just flip a coin and draw a wall for each remaining cell. This will produce a "perfect maze". It's pretty cool.

      The code I posed will generate a binary tree maze, though it won't show the two long halls. (In this case, the program uses west and south walls, so the halls will be the in the first column and the along the bottom row.)

      The lameness filter doesn't want me to show you an example. Still, it's pretty easy to make a nice binary tree maze generator yourself. Give it a try and you'll see how it works.

      For fun, you can make four binary tree mazes and arrange them so that you have two long halls (one East to West, the other North to South) intersecting at the center of the maze, just by choosing which pair of walls to randomly generate in each quadrant. It makes a much more interesting looking maze without adding much complexity (just figure out which quadrant the current cell is in) and retaining all of the properties of a perfect maze.

      I hope that helps.

    96. Re:Without the use of a loop!? by w0mprat · · Score: 1

      Maybe he's trolling to see who will admit that they know BASIC.

      Pretty much every programmer I know's first taste of programming was BASIC.

      --
      After logging in slashdot still does not take you back to the page you were on. It's been that way for 20 years.
    97. Re:Without the use of a loop!? by osu-neko · · Score: 1

      I know nothing of this author, but your review makes me suspect it might be a pretty good read. The kind of jerky ad hominem attacks seen here are usually drawn out of critics when they can't seem to criticize the material itself, so going after the author makes a good alternative, and "pretentious" is usually the way anti-intellectual critics describe anything worth reading...

      --
      "Convictions are more dangerous enemies of truth than lies."
    98. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      marveling so much about 10 PRINT...sounds like he's stoned.

      using so many big, abstract words strung together with snarkiness in an attempt to deride stoner-musings...sad.

    99. Re:Without the use of a loop!? by plopez · · Score: 1

      It's not a program. A program must have an achievable termination condition. It must at some point terminate.

      --
      putting the 'B' in LGBTQ+
    100. Re:Without the use of a loop!? by Samantha+Wright · · Score: 1

      I have no problem with stoner musings. The problem is that these are not being widely regarded as stoner musings.

      --
      Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
    101. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      #include "program.c" // But you wouldn't use includes if you're condensing everything to one line

    102. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      More to the point, how does it check that the maze is completable?? Impossible mazes are not fun!

    103. Re:Without the use of a loop!? by Dahamma · · Score: 1

      Except in the end preprocessed C code actually *includes* the include file, processes the #defines, etc. So, yes, you can in fact condense it down to 1 line with the same semantics. Try "-E" in gcc...

    104. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      The book provides little actual relevant history about the context of this snippet in that regard, only noting that the snippet itself derives from the C64 User's Manual.

      It's also on p.102 of "Personal Computing on the VIC-20" (the book that came with the VIC), which dates from 1981. I don't know if similar manuals were written for Commodore's earlier computers, but exactly the same code would probably have worked on the PET.

    105. Re:Without the use of a loop!? by Tablizer · · Score: 2

      and it is not a labyrinth either. It is just randomly printing forward slashes and backlashes.

      Just replace those slashes with parentheses, and you have a Lisp writer!

    106. Re:Without the use of a loop!? by LoTonah · · Score: 1

      I hope you're just forgetting that "Atari BASIC" was pretty synonymous with the 8-bit Atari 400/800/1200XL/600XL/800XL/65XE/130XE/XEGS line of computers. Since it was based on Microsoft BASIC (but NOT written by Microsoft), a lot of the same tricks could be applied. Including multiple statements per line.

      The Atari VCS BASIC cartridge is a aberration that should not be mentioned in the same breath ;) Besides, I think the flickering gave me seizures.

    107. Re:Without the use of a loop!? by hrimhari · · Score: 1

      (...) and you could pile on as many statements into that line as was sensible (...)

      Actually, I seem to remember my MSX-Basic 1.1 to be limited to 255 characters per line of code.

      --
      http://dilbert.com/2010-12-13
    108. Re:Without the use of a loop!? by nog_lorp · · Score: 1

      Why, then, would the creator of basic (along with just about everyone else to follow) refer to the numbers as line numbers?

    109. Re:Without the use of a loop!? by nog_lorp · · Score: 1

      Perl, shell, etc programs like that as one-liners ALL THE FUCKING TIME.

      With compound statements of various sorts, that is fair; in the case of perl scripts, they are called one line. When you simply /s/\n//, that is idiotic or done as a joke. Pray tell, what is the point of referring to a program as a one liner, when in a vast majority of languages, ALL programs are one liners after applying the above substitution? Is every minified Javascript application a one liner?

      On reconsideration... I suppose it is still meaningful so long as the line is reasonably short. You win.

    110. Re:Without the use of a loop!? by CityZen · · Score: 1

      10 Print [a truly random character]; : Goto 10

      Should suffice to print everything that ever was or will be, given enough time.

    111. Re:Without the use of a loop!? by CityZen · · Score: 1

      It has an achievable termination condition: When you get bored.

    112. Re:Without the use of a loop!? by daniel_mcl · · Score: 1

      Personally, I find it fascinating that if you just randomly put forward and back slashes on a screen then it forms a pattern like that. To me, it's much more interesting than an algorithm that generates mazes. I'd have expected that you just got a bunch of diamonds and things.

      --
      I used to read Caltizzle. I was a lot cooler than you.
    113. Re:Without the use of a loop!? by FrangoAssado · · Score: 2

      It might generate a warning on some compilers, but it's a perfectly valid C program. In fact, since this program uses rand without declaration, it might as well use printf.

      Nothing prevents one from doing this, though:

      int rand(void); int printf(const char * restrict f, ...); main() { ten: printf("%c", (rand()%2)?47:92); goto ten; }

      (Remove the "restrict" before "f" for C89)

      In general, though, ISO C doesn't require translators (the technical name the ISO uses for C compilers/interpreters) to accept lines greater than some limit (509 in ISO C89, 4095 in ISO C99), so technically it's debatable whether it's possible to write every C program as a one-liner: you *could*, but a compiler might correctly not accept it.

    114. Re:Without the use of a loop!? by jimbo · · Score: 1

      Thank you!

    115. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      Firstly, the actual maze produced isn't random but is a visualisation of the pseudo-random algorithm used in C64 basic. Who's to say that this doesn't contain structure just as complex as that of the mandelbrot set?

      Secondly, the mandelbrot set may not really contain the structures that we see at all. All those lovely spirals and so-on might just be floating-point artifacts. No-one knows for sure.

    116. Re:Without the use of a loop!? by Anonymous Coward · · Score: 1

      That's because you have missed the point.

      The point is not that this is amazing code, but that it is simple.

      The point is not that the output is a maze (although it is, by any definition), but that randomness through the prism of the code appears to contain patterns.

      The point is not even that, it is that this is a jumping-off point into an exploration of many connected ideas. The place of code in our lives, the nature of randomness, the notion of a maze itself (a proper maze? what does that mean? Why should a maze have only one solution? Most other things don't).

      That so many slashdotters seem so upset about the article is interesting in itself. Perhaps they feel above such trivial examples of code. Perhaps they think they understand the code. But if they do, it's only to the extent that the computer understands it. Which is to say, not at all.

      captcha: disagree

    117. Re:Without the use of a loop!? by mrbester · · Score: 2

      Note the second paragraph of that page, where it mentions that the version of Sinclair BASIC used on the Spectrum was an *update* of what was used in the ZX80 / ZX81 (which was also called Sinclair BASIC funnily enough). Also note that I mentioned *1981* and that the Spectrum 16K came out in *1982* . Get it now?

      --
      "Wait. Something's happening. It's opening up! My God, it's full of apricots!"
    118. Re:Without the use of a loop!? by rizole · · Score: 0

      Only try to realize the truth: there is no loop.

    119. Re:Without the use of a loop!? by drolli · · Score: 1

      And how is the state of the random number generator from a variable?

    120. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      That isn't a single line program. Learn what #include does.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    121. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      That's just plain wrong. I'm too tired to help people get a clue at this point. Have a great day.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    122. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      Wrong. It wont build, because printf is defined is stdio.h. It might compile, but it won't link, ergo it's not a valid program. Yes, you can pass some link parameters in a custom Makefile, but then you have two files required, which is certainly more than a single line.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    123. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      Yes. You're an idiot. Got it! Thanks for the clarification. Show me the proof that the versions you used didn't have it, or move along.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    124. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      You're doing a C++-style include. That shows a lot about how much C you know.

      printf() is considered "built-in" and implicit it in straight C.

      Moreover, there IS a limit on the length of a line, I believe it's something around 2k characters. I encountered it in C++ though, not sure if it's relevant in C.

    125. Re:Without the use of a loop!? by sproketboy · · Score: 1

      Very cool thanks! This was one of the nice features of the TI - that you could easily redefine character images.

    126. Re:Without the use of a loop!? by johnny+boy · · Score: 1
      Maybe if you forgot that this is a "C" program and tried to build using C++ which would produce mangled names. This works in VS 2008 Express with the modification from an empty console application to use the C compiler instead of C++.

      int rand(void); int printf(const char * f, ...); int main() { ten: printf("%c", (rand() % 2) ? 47 : 92); goto ten; }

      GCC also compiles the above code to an a.out without further modification if you place it in a file named "main.c" and run "gcc main.c". Or even:

      echo 'int rand(void); int printf(const char * f, ...); int main() { ten: printf("%c", (rand() % 2) ? 47 : 92); goto ten; }' | gcc -x c -

    127. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      Wtf? The c standard library is linked by default by every compiler I have used, the only reason for adding a compiler directive is to exclude it from the build.

    128. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      Which is all very well and good, except that non-standard extensions to the C language, like "knowing" about stdio.h functions without including them, are deviations from the standard. The discussion is about C, not how some tools allow you to deviate from the standard and still work.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    129. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      Right. With the seldom heard of #exclude directive. ROTLMAO

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    130. Re:Without the use of a loop!? by FrangoAssado · · Score: 2

      OK, now it's clear that you have absolutely no idea what you're talking about -- you might want to read the C standard, or at least test it on a compiler.

      If you're interested to learn, here's a general explanation:

      The function declarations usually present in header files just tell the compiler what are the parameters accepted by the function, and what is the function return value. In C (not C++), these declarations are not required. If a function with no declaration is called, the compiler/interpreter/whatever uses an "implicit declaration" -- most compilers will give a warning saying that's what they're doing. An implicit declaration assumes that the function returns an int and receives the arguments that were passed in the call, with some promotions: for example, char is converted to int, float is converted to double, and so on (I don't remember all of the promotions rules, and I can't be bothered looking them up).

      An #include directive has nothing to do with the linker, except in some non-standard extensions by compilers (e.g. Visual Studio has the #pragma comment(lib, "library.lib"), which tells the linker to link with "library.lib") which are found on some header files.

      Note that some header files have more than just function declarations -- some also define macros (e.g. NULL). If you use them, you *must* include the header or define the macros yourself (e.g., #define NULL (void*)0): macros don't have an "implicit declaration". Of course, you might just expand the macros yourself (e.g., use (void*)0 instead of NULL): in this case, you obviously don't need to include the header.

    131. Re:Without the use of a loop!? by BasilBrush · · Score: 1

      Yep, got my colons and semicolons mixed up. Too much coding in C derived languages for the last 3 decades.

    132. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      "An implicit declaration assumes that the function returns an int and receives the arguments that were passed in the call"

      And there you have it. The proof that you're the one that has no idea what he is talking about. Hint: What happens when your function returns something other than int and you don't declare it first? Also, we are talking about "almost any program", not a few specific ones (go back and read the beginning of this thread.) Good luck learning C!

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    133. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      Of course it is. Just because you instruct the compiler to fetch a piece of the sourcecode from some other place doesn't mean that the included sourcecode is not a part of the program.

    134. Re:Without the use of a loop!? by konoame · · Score: 1

      Doesn't look like a maze at all in xterm :/

    135. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      +1

      It's a simle, though interesting, example of human perception. Good for an art project maybe?

      It's not a very interesting programming example.

    136. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      No shit, and it is not a labyrinth either. It is just randomly printing forward slashes and backlashes.

      I disagree, I think this finally proves the existence of god. ;)

      Well it doesn't disprove it... so god must be true!

      When do I get that well paid Christian-politics Pundit job?

    137. Re:Without the use of a loop!? by FrangoAssado · · Score: 1

      What happens when your function returns something other than int and you don't declare it first?

      What happens is undefined behavior, according to the standard. But now you're changing your story.

      In response to my examples (both of which are completely valid and contain no undefined behavior), you wrote nonsense like "It might compile, but it won't link, ergo it's not a valid program". Now you're trying to sound as you were talking about general programs.

      The whole point is that #include does nothing magical that influences the linker. It's *exactly* the same as inserting a file verbatim at the #include point. Which means you don't *need* any #includes in C (in particular, they're not required by the linker). Ergo[1] it's possible to write any C program in one line, keeping in mind the limitation about the minimum line length the translator is required to accept, which I explained earlier.

      Good luck learning C!

      That's very funny, you gave me a good laugh!

      [1] I can try to sound smart, too :)

    138. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      " Now you're trying to sound as you were talking about general programs."

      No. The thread has always been about if you can write any program as a one liner. If you thought I was referring to your specific example, then I can see why you would have that perspective, however I didn't look at, nor care about, your specific example, since again the discussion is about being able to implement any program as a one liner, and why you can't do it due to the aforementioned restrictions. You are the one who tried to introduce a special case and try to pretend like it was the rule rather than the exception.

      "The whole point is that #include does nothing magical that influences the linker."

      That's your point, and it's bullshit. If I am trying to link to something that takes a pointer to a struct and I don't include the headers for it, the linker won't work. So, with it the linker succeeds and without it it doesn't. I suppose you would claim that the difference between the success and failure of the linker being dependent on if you include the header or not is "not influencing the linker."

      Anyway, I've wasted too much time on this whole subject, and I concede that you have a better grasp on the C language than most. Have a good day.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    139. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      Right. With the seldom heard of #exclude directive. ROTLMAO

      Wow go back to your javascript and create some more WEB 2.0 applications, it is quite clear that you have no idea what you are talking about or are just trolling.

      Hint: preprocessor directives (not compiler directive) do text processing, #include will be replaced by the contents of the following file. Non standard extensions might use it to automaticaly link libraries with it (Microsoft VS compiler), that is however not standard and most of all not C (VS is a c++ compiler and microsoft refuses to add a C mode to it - citing too low interest).

      Hint 2: The c standard does not deal with linking.

      Hint 3: Should have said flag, like gcc --nostdlib (which excludes the stdlib from build)

      Hint 4: Since you obviously did not try it before claiming that it "It wont build, because printf is defined is stdio.h" it is quite hard to take you seriously - in fact I just have time to waist.

      Hint 3:

    140. Re:Without the use of a loop!? by ultranova · · Score: 1

      compile, but it won't link, ergo it's not a valid program.

      Your earlier assertion that C programs can be run in an interpreter without compiling seems to contradict your current assertion that C programs must be compiled and linked before execution.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    141. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      No. I simply didn't add: "or in the case of running it in an interpreter it won't run." In the C programming community, we don't mention C interpreters unless we are indeed using them for some reason, since they are not the standard way C is used by any stretch of the imagination. No contradiction. Have a great day.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    142. Re:Without the use of a loop!? by FrangoAssado · · Score: 1

      One more time: #include does exactly what I said: it just includes a file verbatim (I can't believe you haven't taken the time to check this, after all this time in this discussion). This means that, after you resolved all #includes, you can then proceed to put the contents of that result in one line, ant the result will be a one-line program. If the original program compiled and linked, then the one-liner also will, by construction.

      Now, to the point of missing struct declarations:

      If I am trying to link to something that takes a pointer to a struct and I don't include the headers for it, the linker won't work. So, with it the linker succeeds and without it it doesn't.

      In your specific example, it will either fail during compilation or during execution, never at link time. That's because the information about return and argument types is gone by the time the linker runs (it might be present on debug sections of the object files, but the linker doesn't care about those). So, if the compiler is happy with the struct declarations, the linker will happily work -- even though the result might be undefined and crash during execution.

    143. Re:Without the use of a loop!? by previewlounge · · Score: 1

      awesome. this is one of the reasons I love programming and Slashdot comments. I have to admit, my admiration is from afar, observing the logic from a distance, although one day, hope to be up close and personal with the implementation of such soluble clarity.

    144. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      I know what it does you idiot. The point isn't what it does, but how it is used. It is used, typically, to include header files. Have a nice life. I've spent too much time dealing with idiots on my weekend.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    145. Re:Without the use of a loop!? by mrbester · · Score: 1

      It's not proof, but Richy_T's comment *right above the one where I listed three interpreters that didn't support it* independently and explicitly cites ZX81 BASIC.

      That the Spectrum did support multiple statements is immaterial as I didn't use it and said as much (1981 was before the Spectrum was released in 1982. I should know, I was there).

      I never made the claim that all versions didn't support it, only the ones I'd used way back when.

      I also posited a reason why it wasn't supported yet you continue with your "la la can't hear you" mentality about a different version that did, and somehow that makes me the idiot?

      --
      "Wait. Something's happening. It's opening up! My God, it's full of apricots!"
    146. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      "It's not proof"

      You could have stopped right there.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    147. Re:Without the use of a loop!? by FrangoAssado · · Score: 1

      I know what it does you idiot.

      Ah, so you've finally realized you're wrong, and now are resorting to ad-hominem attacks...

      That's fine, as long as we're clear that it is possible to write any C program as a one-liner, and #include is just a text-processing directive that doesn't influence the linker.

    148. Re:Without the use of a loop!? by mrbester · · Score: 1

      Yeah but it was necessary for me to reiterate my points as you didn't understand / chose to ignore them in favour of irrelevancies.

      --
      "Wait. Something's happening. It's opening up! My God, it's full of apricots!"
    149. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      "Ah, so you've finally realized you're wrong"

      I'm not wrong, and you definitely are an idiot. #include is a text processing directive, that almost always influences the linker because of how that text processing directive is used.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    150. Re:Without the use of a loop!? by FrangoAssado · · Score: 1

      you definitely are an idiot.

      That's great to know, thanks! I look forward to more varied insults.

      An #include influences the linker just in the most trivial sense that it changes the code seen by the compiler, and so it changes the compiled code seen by the linker. The point is that there's nothing magical about "stdio.h" that requires one to #include it; everything that can be done with #includes can be done without them. I keep repeating this point because I'm still not sure you understand it.

      You at least *did* realize that your previous point about code compiling but not linking is complete and utter nonsense, right?

    151. Re:Without the use of a loop!? by Hal_Porter · · Score: 1

      Not all of us were so priveledged to have expensive toys like the Apple ][+.

      Apple fans demonstrate their people skills again.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    152. Re:Without the use of a loop!? by Hal_Porter · · Score: 1

      I've spent too much time dealing with idiots on my weekend.

      No you haven't.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    153. Re:Without the use of a loop!? by Dahamma · · Score: 1

      Your words: "this would be true if not for the pre-processor".

      So run the pre-preprocessor to generate pre-processed C (.i from gcc) and it can be true. You said it yourself. And if doesn't seem like cheating to me, since CPP is/was also used in non-C applications like imake or even assembly.

      Anyway, it's a silly debate on a dumb article. But doesn't mean you need to resort to ad-hominem once anyone disagrees. Oh well. Have a great day as well :)

    154. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      Pray tell, what is the point of referring to a program as a one liner, when in a vast majority of languages, ALL programs are one liners after applying the above substitution?

      Because most programs don't have that substitution applied. It's like saying "what's the point of using the term 'C program', when any program can be written in C? [it is Turing-complete after all]"

    155. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      Yes. You are right. I should have said: "This is true so long as you don't use the pre-processor", since it is not a requirement that one use it.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    156. Re:Without the use of a loop!? by BonThomme · · Score: 1

      iRandom

    157. Re:Without the use of a loop!? by tzot · · Score: 1

      I came up with this quick&dirty (I got a strange kind of laziness) script.

      Typically, there happen to be enclosed spaces, so I am not sure what a “perfect maze” is (re no isolations). Of course, I might have screwed up.

      --
      I speak England very best
    158. Re:Without the use of a loop!? by tzot · · Score: 1

      Ah, you meant: cat /dev/random
      (or /dev/urandom, if you want to sacrifice randomness for speed).

      The bells will keep you awake while you wait for Shakespear's writings to pass before your eyes.

      --
      I speak England very best
    159. Re:Without the use of a loop!? by narcc · · Score: 4, Interesting

      Try something like this. (Keeping with the BASIC theme)

      10 CLS
      20 W = 10
      30 H = 10
      40 RANDOMIZE TIMER
      50 FOR I = 1 TO W: PRINT " __"; : NEXT I
      60 PRINT ""
      70 FOR I = 1 TO H
      80 PRINT "| ";
      90 FOR J = 1 TO W - 1
      100 IF INT(RND(1) * 2) = 0 THEN PRINT " __"; ELSE PRINT "| ";
      110 NEXT J
      120 PRINT "|"
      130 NEXT I
      140 PRINT "|";
      150 FOR I = 1 TO W - 1: PRINT "__ "; : NEXT I
      160 PRINT "__|"

      Lines 20 and 30 specify the width and height of the maze
      Lines 50 and 60 draw the north outer wall of the maze
      Lines 70 - 130 draw the maze by randomly drawing either a west or south wall.
      Line 80 draws the first cell in a row, which won't have a south wall, to make a long empty hall
      Line 120 draws the east-most outer wall at the end of each row
      Lines 140 - 160 draw the last row, just a long empty hall.

      You'll see that the maze has no loops or isolations. Every cell is reachable from every other cell by a single path.

      Hope that helps. Happy maze making!

    160. Re:Without the use of a loop!? by Smallpond · · Score: 1

      Heh. This will use up your whole roll of teletype paper

      10 PRINT "HELLO, WORLD"
      20 GOTO 10

    161. Re:Without the use of a loop!? by swillden · · Score: 2

      Firstly, the actual maze produced isn't random but is a visualisation of the pseudo-random algorithm used in C64 basic. Who's to say that this doesn't contain structure just as complex as that of the mandelbrot set?

      Doesn't matter. Try it with a different PRNG, or a TRNG, and you'll get the same maze-like effect, because the effect comes from the pattern-matching ability of the human mind, not from any real patterns in the slashes.

      Secondly, the mandelbrot set may not really contain the structures that we see at all. All those lovely spirals and so-on might just be floating-point artifacts. No-one knows for sure.

      Not true. The colors are representations of how many iterations it takes for the point to escape the unit circle (which shows that its absolute value will increase without bound). In portions of the edges of the set (the set itself is the points which remain bounded -- those are indeed hard to be certain of) the number of iterations is small, and it's easy to prove that the limits of the floating point representation are not being tested. Once you get "deeper", of course, floating point error becomes more significant. But the patterns don't change, which is itself interesting.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    162. Re:Without the use of a loop!? by narcc · · Score: 1

      The semicolon statement terminator never existed.

      True.

      In BASIC, the semicolon is a statement separator, not a terminator.

      False.

      Colons separate statements in, well, every dialect I can remember using. IIRC it's also part of ANSI Standard BASIC.

    163. Re:Without the use of a loop!? by tzot · · Score: 1

      randomly add a west or south wall

      Oh, now I get it: it's not an “or”, it's a “xor”! My attempt was picking randomly between 0-3 (no walls, east wall, south wall, east+south wall). Thanks.

      --
      I speak England very best
    164. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      but that randomness through the prism of the code appears to contain patterns.

      If you apply a systematic algorithm to any random data, patterns will emerge. This isn't even really about code at all, it's about math. The principle is used when auditing financial transactions quite often- people who can otherwise "cook the books" without detection will often cause data to become non-random through their manipulations.

    165. Re:Without the use of a loop!? by cjb110 · · Score: 1

      The goal of a labyrinth is meditative.

      Tell that to Theseus, or Jennifer!

      --
      ----- I refuse to have an argument with an unarmed person
    166. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0
    167. Re:Without the use of a loop!? by highphilosopher · · Score: 2

      AH NO! My entire box of tractor feed paper is GONE! You Bastard!!!

    168. Re:Without the use of a loop!? by highphilosopher · · Score: 1

      Sounds a bit more perverted than a JUMP statement though.

    169. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      You might want to go with some remedial reading comprehension material first. In what fucking way does this not critique the material?

    170. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      +1

    171. Re:Without the use of a loop!? by BasilBrush · · Score: 1

      As the GP poster referred to the semicolon, I accidentally continued that in my reply. Obviously I meant colon.

    172. Re:Without the use of a loop!? by Anonymous Coward · · Score: 0

      Except that "goto" is not actually a valid C keyword...

    173. Re:Without the use of a loop!? by TheSkepticalOptimist · · Score: 1

      It's also not a single line of code, its two lines of code just without a line break. By their definition ALL software can be written on one line.

      --
      I haven't thought of anything clever to put here, but then again most of you haven't either.
    174. Re:Without the use of a loop!? by shmlco · · Score: 1

      Well, if everyone is going to get all pedantic about it, then so will I.

      In BASIC, the COLON (:) was the statement separator, not the SEMICOLON (;).

      In the example code, "10 PRINT CHR$ (205.5 + RND (1)); : GOTO 10", the colon is the statement separator. The semicolon was used to suppress the automatic CRLF the PRINT statement would have generated after outputting the above expression.

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    175. Re:Without the use of a loop!? by shmlco · · Score: 1

      GOTO is a jump statement.

      FOR...NEXT, LOOP...UNTIL, and WHILE...WEND are are the traditional "and more elegant" BASIC looping statements.

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    176. Re:Without the use of a loop!? by shmlco · · Score: 1

      Technically, the BASIC interpreter used all sorts of system variables for the program counter, evaluation stack, and so on. That said, such things would be considered metadata, and the statement is correct in that no variables were declared in the implementation language.

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    177. Re:Without the use of a loop!? by markimusk · · Score: 1

      I worry that you felt the need to make sure this burgeoning code did NOT indeed need Extended Basic to execute!

    178. Re:Without the use of a loop!? by nog_lorp · · Score: 1

      You trollin'. It is not trivial to convert any program into C. It is trivial to remove all newlines.

    179. Re:Without the use of a loop!? by Richy_T · · Score: 1

      A loop is a flow control structure. Goto may be used to implement that or not.

    180. Re:Without the use of a loop!? by Richy_T · · Score: 1

      Hah, true enough, I guess.

    181. Re:Without the use of a loop!? by ultranova · · Score: 1

      No. I simply didn't add: "or in the case of running it in an interpreter it won't run."

      It might, it might not. Since printf is part of standard C library, it almost certainly would.

      In the C programming community, we don't mention C interpreters unless we are indeed using them for some reason, since they are not the standard way C is used by any stretch of the imagination.

      The de facto standard way is to use a single program that compiles and links the program, and includes standard libraries into the link state by default, resulting in printf being resolved just fine.

      No contradiction.

      Just an argument that's flat-out false.

      Have a great day.

      I did, thanks. You seem to be having a bad one.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    182. Re:Without the use of a loop!? by smithmc · · Score: 1

      TFA does not say that no loops are used. From TFA: "There aren’t any variables. It uses a GOTO instead of a more elegant loop."

      --
      Downmodding is the refuge of the weak. Don't downmod, make a better argument!
    183. Re:Without the use of a loop!? by smithmc · · Score: 1

      The code puts out random positive space objects while the mind sees a single, complex negative space.

      I don't even see the random positive space objects anymore. I just see blonde, brunette, redhead...

      Go outside. NOW.

      --
      Downmodding is the refuge of the weak. Don't downmod, make a better argument!
    184. Re:Without the use of a loop!? by CODiNE · · Score: 1

      I was thinking about that and wondering how a randomly generated maze could have such attributes such as no loops or isolations, I gave it a try...

      It looks random to me, and doesn't seem to show the properties you mentioned.  Well the thing is with the spaces on the sides of " | " you really CAN'T get an isolation since you can't close off a box. With the gaps you can go around basically any corner and get where you want.  If I close those spaces up a bit then yeah there's boxes and isolations and plenty of unreachable areas.

      I tried copying your exact "|  " and "___" from the pasted code but it comes out worse.  Maybe something got filtered.  But checking the maze generation algorithms on Wikipedia doesn't show any as simple as you mentioned.

      Let me know if I did it wrong or something.

      #include <stdio.h>

      int main(int argc,const char* argv[]){
      int h, w, i, j;
      h = w = atoi(argv[1]);
      srand(time(NULL));

      printf(" ");
      for(i=0 ;i<w; i++)
         printf("___");
      printf("\n");

      for(i=0; i<h; i++){
        printf("|");
        for(j=0; j<w; j++)
          rand()%2==1?printf("___"):printf(" | ");
        printf("|\n");
        }

      printf(" ");
      for(i=0; i<w; i++)
        printf("___");

      printf("|\n");
      return 0;
      }

      --
      Cwm, fjord-bank glyphs vext quiz
    185. Re:Without the use of a loop!? by narcc · · Score: 1

      Here you go:

      #include <stdio.h>

      int main(int argc,const char* argv[]){
      int h, w, i, j;
      h = w = atoi(argv[1]);
      srand(time(NULL));

      for(i=0 ;i<w; i++)
            printf(" __");
      printf("\n");

      for(i=0; i<h-1; i++){
          printf("| "); // two spaces
          for(j=0; j<w-1; j++)
              rand()%2==1?printf(" __"):printf("| "); // two spaces
          printf("|\n");
          }

      printf("|");
      for(i=0; i<w-1; i++)
          printf("__ ");

      printf("__|\n");
      return 0;
      }

      A space got filtered out on line 80 and 100 -- it should be in both cases "[pipe][space][space]"

      Well the thing is with the spaces on the sides of " | " you really CAN'T get an isolation since you can't close off a box. With the gaps you can go around basically any corner and get where you want.

      It's the best you can do with underscores, pipes, and spaces :) Try out the working program and you'll get a good sense of how it's supposed to be.

      If you want, I can make a javascript version so that it looks nicer. Just ask and I'll post some code for you.

      I was thinking about that and wondering how a randomly generated maze could have such attributes such as no loops or isolations, I gave it a try...

      A Binary Tree Maze is just the easiest kind to make. It doesn't make the best kind of maze, as you'll see, but it meets all the criteria for a perfect maze. There are lots of other interesting algorithms that will let you randomly generate a maze with those properties -- and MUCH better results. My favorite is Eller's Algorithm -- you should give it a look.

    186. Re:Without the use of a loop!? by narcc · · Score: 1

      Well the thing is with the spaces on the sides of " | " you really CAN'T get an isolation since you can't close off a box. With the gaps you can go around basically any corner and get where you want.

      Ignore my last reply to that quote. I completely misinterpreted it. Sorry about that!

      Anyhow, here's a JavaScript version of the program so you can see how the maze ought to look without dealing with troublesome spaces and the like.


      <script>

      var w = 16;
      var h = 16;

      var maze = document.createElement("table");
      maze.style.border = "solid 1px #000";
      maze.style.borderCollapse = "collapse";
      maze.style.width = (w*2)+"em";
      maze.style.height = (h*2)+"em";

      for (var i=0; i<h; i++)
      {
      maze.insertRow(i);
      maze.rows[i].insertCell(0);

      for (var j=1; j<w; j++)
      {
      maze.rows[i].insertCell(j);

      if (Math.round(Math.random())==1 && i<h-1)
      maze.rows[i].cells[j].style.borderLeft = "solid 1px #000";
      else
      maze.rows[i].cells[j].style.borderBottom = "solid 1px #000";
      }
      }
      document.body.appendChild(maze);
      </script>

      With a simple modification you can make the cells swap their south and west walls when you click them to see how the maze changes. It gives you a good sense of how the algorithm works:


      <script>

      var w = 16;
      var h = 16;

      var maze = document.createElement("table");
      maze.style.border = "solid 1px #000";
      maze.style.borderCollapse = "collapse";
      maze.style.width = (w*2)+"em";
      maze.style.height = (h*2)+"em";

      for (var i=0; i<h; i++)
      {
      maze.insertRow(i);
      maze.rows[i].insertCell(0);

      for (var j=1; j<w; j++)
      {
      maze.rows[i].insertCell(j);

      if (i<h-1)
      maze.rows[i].cells[j].onclick = function() {
      var t = this.style.borderLeft;

    187. Re:Without the use of a loop!? by CODiNE · · Score: 1

      Ahhh, that's much better.

      Hey funny the code for changing the borders only works right in Chrome.

      Safari will leave the bottom stuck, even if you change around the order of the assignments.

      Firefox bizarrely changes other cells in the area around the clicks.

      And THAT'S why I don't do web development.

      We need to get rid of this web thing, it's ruining the internet!

      --
      Cwm, fjord-bank glyphs vext quiz
    188. Re:Without the use of a loop!? by Zero__Kelvin · · Score: 1

      "The de facto standard way is to use a single program that compiles and links the program, and includes standard libraries into the link state by default, resulting in printf being resolved just fine."

      Wrong. The defacto standard is to include the stdio.h friggin' header file! I admit I didn't know that you can exclude it, but the fact remains that you should never do so, and I never have which is why I didn't know you could even do it. Not including the header is a piss poor, sloppy, and error prone approach that violates a fundamental law of programming, to wit: Always be explicit. What happens if I create and include a file called omgwtf.h with the following contents, for example? :

      int printf(char * string, ...)
      {
      return 0;
      }


      (And yes, I tried this to verify that it indeed causes the behavior of making all your printf calls suddenly output nothing, while linking just fine with no complaint.)

      How long will I spend finding the place where some idiot did something similar because some other idiot didn't understand fundamental programming principles and failed to include stdio.h? Answer: Way too fscking long, even if it just a few minutes

      "I did, thanks. You seem to be having a bad one."

      Not really. At this point in my life I'm used to dealing with incompetent programmers who think they are great at it. Good luck learning C!

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  3. Sad day for slashdot... by Anonymous Coward · · Score: 5, Insightful

    ...when the summary does not know what a loop is.

    1. Re:Sad day for slashdot... by Anonymous Coward · · Score: 0

      Fuck you I know what a loop is!

    2. Re:Sad day for slashdot... by Zero__Kelvin · · Score: 5, Funny

      Worse yet is the fact that the editors don't either.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    3. Re:Sad day for slashdot... by Trepidity · · Score: 4, Interesting

      Also, it can't string together a single grammatically correct sentence. Complete failure on both technical and English levels!

      The book is, however, quite interesting (just go straight to the open-access PDF and skip the mediocre Slate article).

    4. Re:Sad day for slashdot... by Anonymous Coward · · Score: 0

      Maybe the summary was talking about about "labyrinth loops", which is a different concept from computing loops.

    5. Re:Sad day for slashdot... by Anonymous Coward · · Score: 0

      And additionally while it may not use complicated syntax or variables, it does rely on the peculiarity of the C64 character set that characters resembling / and \ are right next to each other and the also rather peculiar C64 BASIC rounding behaviour which is different from any BASIC I've ever worked with (BASICA, GW-BASIC, Q(uick)Basic, Visual Basic and two embedded BASICs).

    6. Re:Sad day for slashdot... by Anonymous Coward · · Score: 0

      You shouldn't complain, however, about failure to use English, however, when you, however, add pointless junk to your sentences, however.

      Edit wikipedia much? However, when you are not making any actual contrast to a previous statement, is the written equivalent of saying "eh?" and it makes you look like a dumbass. Don't write your mental pauses into your prose.

    7. Re:Sad day for slashdot... by Trepidity · · Score: 1

      In this case, the "however" is functioning to distinguish the positive assessment of the book from the negative assessment of the blurb about it. Another way of phrasing the same thing would be to say "on the other hand", but that's slightly more wordy.

    8. Re:Sad day for slashdot... by Anonymous Coward · · Score: 0

      Whew! I feel better. I thought it was just me. So, um... what's a loop?

  4. No loop? by chthon · · Score: 5, Insightful

    No editors with programming experience perhaps.

    The basic definition of a loop is a GOTO to a previous address! All the rest is syntax and optimisation.

    1. Re:No loop? by Anonymous Coward · · Score: 1, Insightful

      and it's not even a single line.

      Everyone knows that : in BASIC starts a new line.

      This is two lines.

      Or are you going to suggest that simply s#\r\n## makes all programs a single line?

    2. Re:No loop? by AdamHaun · · Score: 1

      and it's not even a single line.

      Would it count anyway? Including a library function that implements a PRNG algorithm hardly sounds like "a single line of BASIC"...

      (Not criticizing the book, which I've never read -- it may be a great book for all I know.)

      --
      Visit the
    3. Re:No loop? by BoRegardless · · Score: 1

      Just missing BASIC experience...like I had in the 70s.

    4. Re:No loop? by Zero__Kelvin · · Score: 5, Informative

      "Everyone knows that : in BASIC starts a new line."

      Nobody knows that, because it is untrue. The : is a statement separator, not a line seperator. That 10 you see is the line number. Notice that there are no other line numbers. Make an error on either side of the colon and the interpreter will give you the exact same complaint: Syntax error in line 10. You can verify this by looking for the line " In BASIC it's used as a separator between the statements or instructions in a single line." on Wikipedia, or use your Google-Fu to verify it thousands of other ways.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    5. Re:No loop? by Zero__Kelvin · · Score: 1

      "Would it count anyway? Including a library function that implements a PRNG algorithm hardly sounds like "a single line of BASIC""

      Yes, it would, if only because RND is an official ANSII BASIC statement, not an external library. Common people, all this stuff is pretty basic .... ;-)

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    6. Re:No loop? by Samantha+Wright · · Score: 1

      : behaves differently from a true linebreak. An IF statement will skip over additional statements separated by colons if it fails:

      10 INPUT "PLEASE INPUT Y OR N: ", A$
      20 IF A$ "Y" AND A$ "N" THEN PRINT "INCORRECT": GOTO 10

      The "GOTO 10" will only be executed if the condition is met. This is what early BASIC programmers had instead of if statements that supported blocks.

      --
      Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
    7. Re:No loop? by MisterMidi · · Score: 1

      You're confusing lines and statements. The colon isn't a line separator, it's a statement separator. In (early) BASIC every line had its own number. In this oneliner there's just one.

  5. 10 ... : GOTO 10 is a loop by Mneme · · Score: 5, Informative

    it manages to create a complicated maze with out the use of a loop, variables and without very complicate syntax

    It's very cool the way this code draws a maze, but there's obviously a loop there.

    (And it's “without” not “with out”, and “complicated” not “complicate”.)

    1. Re: 10 ... : GOTO 10 is a loop by Lobachevsky · · Score: 4, Interesting

      it's not a maze, it's a pattern of random forward and backward slashes, "/" and "\". There's no guarantee that a path exists anywhere near the top to anywhere near the bottom. In fact, because it's random, you'd be blocked off at some point.

    2. Re: 10 ... : GOTO 10 is a loop by Frans+Faase · · Score: 1

      There are some interesting mathematical problems. Like given a certain width and an endless number of rows, if you start in at an arbitrary 'square', what is the distribution of the number of other squares that you can reach? (with or without wrapping?) What if it is endless in two directions?

    3. Re: 10 ... : GOTO 10 is a loop by Anonymous Coward · · Score: 0

      Percolation theory to the rescue.

    4. Re: 10 ... : GOTO 10 is a loop by Anonymous Coward · · Score: 0

      I think that the probability of landing in a specific shape (orientation matters) is area_of_shape / 2^(length_boundary/2 + 1), where the unlt is half the length of a slash. For example, the smallest shape is a 2x2 square, and the probability of landing in it is 4 / 2^(8/2 + 1) = 1/8.

      I wouldn't be surprised if the probability of landing in a shape of infinite area is non-zero. Is this stuff discussed somewhere in the 324-page book?

    5. Re: 10 ... : GOTO 10 is a loop by KiloByte · · Score: 1

      If the maze consists of whole blocks that are either full (chance p) or empty (chance 1-p), then if I can remember correctly, you can go forever with probability 1 after leaving an initial region iff p < 0.5, and will be trapped with probability 1 iff p > 0.5.

      This is different from this article that has either / or \, I'm way too rusty to prove it myself right now. Running a quick simulation is a way that doesn't require thinking, though.

      --
      The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
    6. Re: 10 ... : GOTO 10 is a loop by narcc · · Score: 2

      In fact, because it's random, you'd be blocked off at some point.

      Nonsense. See: Binary tree mazes.

      Also, I recommend that you look at other maze generation algorithms (especially Eller's Algorithm) as you can easily create a random yet solvable maze where there is exactly one path between any two cells -- no loops or isolations. In the case of Eller's Algorithm, you can create a random maze of any length that has this property without keeping the entire maze in memory -- just a single line!

    7. Re: 10 ... : GOTO 10 is a loop by Anonymous Coward · · Score: 0

      Are you saying that mazes must be more than random, and must have a path from one location to another?

    8. Re: 10 ... : GOTO 10 is a loop by Frans+Faase · · Score: 1

      I paged through the book and did not find any of it.

    9. Re: 10 ... : GOTO 10 is a loop by Anonymous Coward · · Score: 0

      It is not random. It will be exactly the same pattern every time you run it, and it is based on a pseudorandom number generator, so there could be an interesting underlying pattern.

    10. Re: 10 ... : GOTO 10 is a loop by Anonymous Coward · · Score: 0

      it's also not an effective maze because, even if there is a path from the top to the bottom, it wouldn't have any forks.

  6. It's 2012 by Anonymous Coward · · Score: 0

    There is a thing called recursion. It's the shit.

    1. Re:It's 2012 by Anonymous Coward · · Score: 0

      There is a thing called recursion. It's the shit.

      Its 2012 and infinite recursion still crashes. It just takes a little longer. At least an infinite loop does not crash.

      Plus recursion is nothing new and it has a high cost performance-wise. This has been understood by some for many decades.

      Its kiddies like you that explain why simple utilities need multiple GHz CPUs and multiple GBs of RAM. :-)

    2. Re:It's 2012 by allo · · Score: 1

      this "goto recursion" does not crash, because there is no stack to be able to jump back.

    3. Re:It's 2012 by Anonymous Coward · · Score: 0

      Its 2012 and infinite recursion still crashes. It just takes a little longer. At least an infinite loop does not crash.

      You seriously have to look up what tail recursion means.

    4. Re:It's 2012 by Tough+Love · · Score: 2

      It eventually fills up the galaxy with ascii chars and the world ends.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    5. Re:It's 2012 by KiloByte · · Score: 1

      Stuff that scrolls off the screen is pushed out of memory and falls into the bit bucket. Only when the bit bucket gets full the program will crash.

      --
      The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
    6. Re:It's 2012 by ultrasawblade · · Score: 1

      You misunderstood him. He was saying that recursion shares characteristics with a particular entity of excrement, rather than giving recursion.

      Iteration is the bee's knees.

    7. Re:It's 2012 by Anonymous Coward · · Score: 0

      Stuff that scrolls off the screen is pushed out of memory and falls into the bit bucket. Only when the bit bucket gets full the program will crash.

      If you're not using a hardcopy tty, you're doing it wrong?

  7. Without the use of a loop? by Anonymous Coward · · Score: 3, Informative

    That....is.....a loop.......

  8. Some minor deficiencies by zmooc · · Score: 5, Insightful

    create a complicated maze with out the use of a loop
    1. This is not necessarily a maze. It's noise. At best.
    2. It's "without", not "with out"
    3. There is a loop

    --
    0x or or snor perron?!
    1. Re:Some minor deficiencies by daremonai · · Score: 1, Informative

      The Slate article does make clear that this only works on something with the old Commodore 64 character set (PETSCII). And that it is a loop.It's not exactly a great article, but it does get these things right.

    2. Re:Some minor deficiencies by Cyberax · · Score: 1

      It would work with any script that has '/' and '\' symbols separated by 1 code point.

    3. Re:Some minor deficiencies by gl4ss · · Score: 1

      The Slate article does make clear that this only works on something with the old Commodore 64 character set (PETSCII). And that it is a loop.It's not exactly a great article, but it does get these things right.

      it would work on anything with the right type of font. if you want to try it on windows cmdline them from prefs select raster fonts and 8x8 pixel font.

      (yeah I tested.. with a javascript script of all things, ugh)

      --
      world was created 5 seconds before this post as it is.
    4. Re:Some minor deficiencies by reboot246 · · Score: 1

      And it's not even news. We were doing this 30+ years ago!

    5. Re:Some minor deficiencies by larry+bagina · · Score: 1

      or can index into a string of "/\".

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    6. Re:Some minor deficiencies by idji · · Score: 1

      a maze has 3 properties (1) an entrance, (2) an exit and, (3) at least one path between them. This pattern has none of the 3. the second "maze" has no paths from left to right, but 3 from top to bottom. (Just paste screenshot into your favorite graphics progam and floodfill the lines)

    7. Re:Some minor deficiencies by mysidia · · Score: 1
      This looks more like a maze

      for my $i (1..100000) { $x = int(rand(10)); if ($x == 1 ) { print '\\'; } elsif ($x > 2) { print ' '; } else { print '/'; } }

    8. Re:Some minor deficiencies by Richy_T · · Score: 1

      Or can generate a random number equal to the code difference (i.e. all of them)

    9. Re:Some minor deficiencies by Odin's+Raven · · Score: 1

      3. There is a loop

      Timothy: Do not try and code the loop. That's impossible. Instead...only try to realize the truth.
      Neo: What truth?
      Timothy: There is no loop.
      Neo: There is no loop?
      Timothy: Then you'll see, that it is not the code that loops, it is only yourself.
      ...
      ...
      ...
      Neo: WTF?!?

      --
      A marriage is always made up of two people who are prepared to swear that only the other one snores.
  9. Goto Makes a Loop by dcollins · · Score: 2

    Re: "it manages to create a complicated maze with out the use of a loop"

    --
    We know where leadership by an anti-intellectual "strongman" who scapegoats minorities and likes boisterous rallies goes
  10. No loop? by Anonymous Coward · · Score: 0

    10 [somethong]; GOTO 10
    is a loop!

  11. Not impressed by Anonymous Coward · · Score: 0

    Color me unimpressed. It's just randomly printing forward and backward slashes, which line up because of the font. It's nifty, but hardly amazing.

  12. Enterprise Java Version by Mr.+Sketch · · Score: 5, Funny

    package enterprise;

    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    import java.io.Writer;
    import java.util.Collections;
    import java.util.Map.Entry;
    import java.util.Random;
    import java.util.SortedMap;
    import java.util.TreeMap;

    public class Maze {
    private final WallFactory<Double> wallFactory;
    private final EntropyGenerator entropyGenerator;

    public Maze( WallFactory<Double> wallFactory, EntropyGenerator entropyGenerator ) {
    this.wallFactory = wallFactory;
    this.entropyGenerator = entropyGenerator;
    }

    public void visit( MazeVisitor visitor ) throws MazeException {
    while( true ) {
    MazeWall wall = wallFactory.createMazeWall( entropyGenerator.getNewEntropyValue() );
    wall.visit( visitor );
    }
    }

    public interface MazeWall {
    /**
    * @param visitor
    * @throws IOException
    */
    void visit( MazeVisitor visitor ) throws MazeException;
    }

    public static class LeftDiagonalWall implements MazeWall {
    @Override
    public void visit( MazeVisitor visitor ) throws MazeException {
    visitor.visit( this );
    }
    }

    public static class RightDiagonalWall implements MazeWall {
    @Override
    public void visit( MazeVisitor visitor ) throws MazeException {
    visitor.visit( this );
    }
    }

    public interface MazeVisitor {
    void visit( LeftDiagonalWall leftDiagonalWall ) throws MazeException;

    void visit( RightDiagonalWall rightDiagonalWall ) throws MazeException;
    }

    public interface WallFactory<T> {
    /**
    * @param value
    * @return the MazeWall
    * @throws MazeException
    */
    MazeWall createMazeWall( T value ) throws MazeException;
    }

    public static class StrategyWallFactory<T> implements WallFactory<T> {
    private WallRepartitionStrategy<T> wallRepartitionStrategy;

    public StrategyWallFactory( WallRepartitionStrategy<T> wallRepartitionStrategy ) {
    this.wallRepartitionStrategy = wallRepartitionStrategy;
    }

    @Override
    public MazeWall createMazeWall( T value ) throws MazeException {
    Class<? extends MazeWall> wallClassForValue = wallRepartitionStrategy.getWallClassForValue( value );
    try {
    return wallClassForValue.newInstance();
    } catch( InstantiationException | IllegalAccessException e ) {
    throw new MazeException( "Cannot create MazeWall instance", e );
    }
    }

    1. Re:Enterprise Java Version by CaptainLard · · Score: 1

      Thats nothing. Try parsing some serial bytes coming from a microcontroller.

    2. Re:Enterprise Java Version by roninmagus · · Score: 1

      I love this. Especially the constants for left_wall_representation and right_wall_representation. If this were dot net and the kind of stuff I have to work in often, it would have to pull the random values from a WCF service.

    3. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      This is one of the most painful / funny things I have ever read. Painful, because it hits too close home, funny because it is true.

      Enterprise Java -- never again, *sigh*.

    4. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      org.shittyexamples.maze.MazeFactory.printMaze();

    5. Re:Enterprise Java Version by AJWM · · Score: 1

      Come now, that's hardly Enterprise Java without a few JDBC connections. ;)

      --
      -- Alastair
    6. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      At least the Enterprise Java version doesn't rot your brain!

    7. Re:Enterprise Java Version by CockMonster · · Score: 2

      InstantiationException.IllegalAccessException cannot be resolved to a type Maze.java /Maze/src line 76 Java Problem Syntax error on token "|", . expected Maze.java /Maze/src line 76 Java Problem The method lineSeparator() is undefined for the type System Maze.java /Maze/src line 139 Java Problem

    8. Re:Enterprise Java Version by SpaceLifeForm · · Score: 0

      A good example of Java being fat and leading to unproductive use of coding time.

      --
      You are being MICROattacked, from various angles, in a SOFT manner.
    9. Re:Enterprise Java Version by GodfatherofSoul · · Score: 1

      Writing shitty code in a language isn't a reflection on that language.

      --
      I swear to God...I swear to God! That is NOT how you treat your human!
    10. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      bravo! you have made me literally bucksnort.
      "it's funny 'cause it's true!" - Homer Simpson

    11. Re:Enterprise Java Version by phantomfive · · Score: 2

      His point is the vast majority of enterprise Java is shitty code. If you write code that looks like that, please reconsider your coding methods.

      --
      "First they came for the slanderers and i said nothing."
    12. Re:Enterprise Java Version by Anonymous Coward · · Score: 2, Insightful

      You realize the above is a joke right? Just because you can make it complicated isn't a reflection of the language. You could implement the java equivalent of the original program very tersely if you wanted to.

    13. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      Dude, you have waaaay too much time on your hands! Recommend you get a job, or something.

    14. Re:Enterprise Java Version by Tumalu · · Score: 2

      And here's a more compact Java version:

      class Maze{public static void main(String[] args){while (true){for(int i=0;i<40;i++)System.out.print(Math.random()<.5?"/":"\\");System.out.println();}}}

      A bit verbose perhaps, but it's really not that much different than the version in the article. It's not the Java language that leads to the kind of verbosity that you see in enterprise code, but rather the conventions (and often the frameworks).

    15. Re:Enterprise Java Version by joss · · Score: 3, Interesting

      Actually, when the code is idiomatic, it is a reflection on that language/frameworks that go with it. Having spent a bad 5 years in enterprise java trenches I can vouch for the realism of that code. It gave me flashbacks. I'm still fucking shivering.

      --
      http://rareformnewmedia.com/
    16. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      I take you're point, but it's only valid given certain conditions and is really just the oft-repeated and vastly over-stated axiom that "Java is complicated".

      No, Java doesn't NECESSARILY lead to complicated code, stupid programmers do.

      Yes, I'll stipulate that the Java version of 10 print will be more complicated and have more statements... but really, if you can't do it in a handful of lines of code then that's not Java's fault, it's the fault of the programmer.

      (And if *THAT* was your point, that Java PROGRAMMERS overcomplicated things all the time, then yeah, forget it, I completely agree!)

    17. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      It's not Guice-injected.

    18. Re:Enterprise Java Version by narcc · · Score: 5, Informative

      Plagiarizer. You stole this from reddit -- from the same post linked from Nick Montfort's blog.

      Enterprise Java Version:
      http://www.reddit.com/r/programming/comments/142jix/10_print_chr_2055_rnd_1_goto_10_how_a_single_line/c79elxn

      You shouldn't take credit for the work of others. That +5 funny is a filthy dirty lie.

    19. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      God, as a sysadmin in an Enterprise Java Environment, let me tell you that having to wade through three hundred pages of logs to find a hundred line stack dump because the Java couldn't connect to the database because of a typo in the password (meanwhile the user gets unhelpful and ugly 404s) makes me yearn for a nice bit of PHP. YEARN!

      Don't bother telling me that it doesn't have to be that way either (assuming it doesn't). I've tried dropping hints but telling developers to their face that they write shitty code isn't good politics.

    20. Re:Enterprise Java Version by Richy_T · · Score: 3, Funny

      Perl version: Search CPAN, someone's bound to have written a maze module.

    21. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      It's funny because it's true.

    22. Re:Enterprise Java Version by Anonymous Coward · · Score: 2, Insightful

      Congrats for admitting you are a reddit user. Thats the first step towards recovery.

    23. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      there is life on this planet...

    24. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      Could you show us the two line version like the Python? I don't know Java well enough to write it myself.

    25. Re:Enterprise Java Version by Anonymous Coward · · Score: 1

      You know, it is technically possible that he's the same guy as the reddit user.

    26. Re:Enterprise Java Version by Anonymous Coward · · Score: 0

      Yes, a large amount of XML for the framework configuration and defining the connection pools. Not to mention the error handling.

    27. Re:Enterprise Java Version by PuZZleDucK · · Score: 1

      You could implement the java equivalent of the original program very tersely if you wanted to.

      I know I did :D

      import java.util.Random;
      public class Maze {
      public static void main(String[] args) {
      Random r = new Random(System.currentTimeMillis());
      for(int i = 0; i switch(r.nextInt(2)) {
      case 0 : System.out.print(String.valueOf(Character.toChars(9585))); break;
      case 1 : System.out.print(String.valueOf(Character.toChars(9586))); break;
      }/*switch*/ }/*for*/ }/*main*/ }/*class*/

      --
      Can a person program a new solution to a problem? Why should anyone be able to stop such a thing? -Richard Stallman
  13. Loops by Anonymous Coward · · Score: 0

    It may not be a while(1) { ... }, but that GOTO at the end makes things functionally equivalent...

    1. Re:Loops by Anonymous Coward · · Score: 0

      Please use for(;;) instead of while(1).

  14. Without looping? by sidragon.net · · Score: 2

    How does this not use a loop?

  15. Perl analogue by Okian+Warrior · · Score: 5, Interesting

    Don't have a Commodore Basic interpreter? this Perl 1-liner will do the same thing:

    print ["/","\\"]->[rand(2)] while 1;

    It has no start or end point, and for two arbitrary points you can't guarantee that a path exists.

    ...but it definitely *looks* like a maze, so that's what it must be. The authors said so, after all...

    1. Re:Perl analogue by Camel+Pilot · · Score: 1

      You beat me to it. Even sweeter.

    2. Re:Perl analogue by Anonymous Coward · · Score: 0

      From TFA:

      (Run it on another old-school computer, like an Apple II, and you won't get the same transfixing result, for details that have to do with the Commodore 64â(TM)s character set, called PETSCII.)

      Or, if you run it on a modern computer (utf) and use U+2571 and U+2572, for a "more authentic" (45 degree angles) reproduction.

    3. Re:Perl analogue by gblfxt · · Score: 1

      how does this guarantee its an ascii character though?

    4. Re:Perl analogue by Anonymous Coward · · Score: 0

      Why waste characters when you can use:

      print qw<\ />[rand 2]while 1

    5. Re:Perl analogue by sco08y · · Score: 1

      how does this guarantee its an ascii character though?

      ["/", "\\"]

      This creates an array of strings.

      rand(2)

      This picks a number 0 or 1.

      [...]->[...]

      That gets an element from the array, which since it's a string has to be ASCII. (Strictly there's some funky stuff with references going on there, too, which is unnecessary.)

    6. Re:Perl analogue by zmughal · · Score: 1
      The book actually has a Perl example. :-)

      {binmode STDOUT,"utf8";print chr(9585.5+rand);redo}

    7. Re:Perl analogue by Anonymous Coward · · Score: 0

      With fewer characters:

      print qw(/ \\)[rand 2]while 1

      But in most cases, you probably want a finite maze, so try:

      print qw(/ \\)[rand 2]for 1..4800

      Not only is this shorter than the original BASIC program, it has an extra feature -- it terminates.

    8. Re:Perl analogue by Anonymous Coward · · Score: 0

      *n*x analog:
      tr -dc '/\' </dev/urandom

      (tr is POSIX, urandom is not, but is common these days...)

    9. Re:Perl analogue by L.+J.+Beauregard · · Score: 1

      The regular forward and back slash don't join very well. If your output device supports UTF-8, try U+2571 and U+2572; this example is in Ruby 1.9:

      print (0x2571+rand(2)).chr(%q(UTF-8)) while true

      --
      Ooh, moderator points! Five more idjits go to Minus One Hell!
      Delendae sunt RIAA, MPAA et Windoze
    10. Re:Perl analogue by cloudmaster · · Score: 1

      Or, you could use fewer characters and make it faster by not creating an array reference every iteration. ;)

      print while $_=qw{\ /}[rand 2];

    11. Re:Perl analogue by Anonymous Coward · · Score: 0

      80x20 is not 4800, heretic. ;)

    12. Re:Perl analogue by Anonymous Coward · · Score: 0

      Technically, rand(2) picks a floating point number n where 0<=n<2, which will get truncated to 0 or 1 when it's used as an integer in the array index. ;)

  16. A book? by roninmagus · · Score: 1

    There's a book about this? It looks like it just randomly prints either a forward slash or a backslash. The fact it appears to be a maze is just an artifact of the monospaced type. Am I missing something here?

    1. Re:A book? by Anonymous Coward · · Score: 1

      You should really check out the book. These guys are all over the place, it's totally wacked out. I can hardly believe it was published by MIT Press.

  17. Really? by Multiplicity · · Score: 5, Insightful

    Frontpage slashdot story with a 10 GOTO 10 and saying it's not a loop?

    Dudes, just what the fuck. I ask you that.

    1. Re:Really? by Anonymous Coward · · Score: 2, Funny

      It's a step up from the plastic on Mars story a few days ago.

    2. Re:Really? by Anonymous Coward · · Score: 3, Insightful

      What the fuck? I'll tell you what the fuck... Slashdot as it stands today is a sad, pale reflection of the Good Slashdot of Old.

      The focus isn't "News for Nerds" anymore, it's "Bash Apple Good... and oh, here's some code too."

    3. Re:Really? by Horshu · · Score: 1

      Not only that, but randomly dumping out slashes and backslashes is "amazing" code.

    4. Re:Really? by uzkonosy_placental · · Score: 1

      reminds me of this sitcom, big bang theory: smart at beginning, soap opera at the end :)

  18. A slow day on /. ? by Monoman · · Score: 1

    1) It is an endless loop created by the GOTO command.
    2) Is it a maze or does it just look like one? There is no indication that it actually creates a maze each and every time. It is more likely a pseudo random pattern that LOOKS like a maze.

    --
    Keep the Classic Slashdot.
    1. Re:A slow day on /. ? by mysidia · · Score: 1

      Is it a maze or does it just look like one?

      It is a maze. It doesn't necessarily have exactly one solution (It probably has more than one). It doesn't necessarily have any solutions.

      The loop never seems to terminate, so it seems that the maze will keep getting larger until the program is manually aborted

    2. Re:A slow day on /. ? by Anonymous Coward · · Score: 0

      Is it a maze or does it just look like one?

      It is a maze. It doesn't necessarily have exactly one solution (It probably has more than one).
      It doesn't necessarily have any solutions.

      So, in other words, it's not a maze.

  19. Cue the morons screaming Goto is evil. by Anonymous Coward · · Score: 0

    Honestly, just don't.

    The entire basis of the OS you are using is filled with them. Yes, Linux too.
    Most of them are just contextual Gotos in the end, same thing. (in fact, there is literally some cases of actual Gotos since the other command-sensitive versions don't fit the roles)

    Goto isn't evil, the developers who (ab)use it are.

    Discuss.

  20. Bullshit code by Anonymous Coward · · Score: 0

    The code selects at random one of two characters, which when printed at random may look like maze walls, and then prints them. Rince and repeat.

    So basicallly it only prints garbage which was carefully selected. You get the same effect from any programming language which supports unicode, by randomly printing out unicode code points from the U+2500 - U+257f range.

  21. Cute, but... by rbprbp · · Score: 1

    ... what about a solvable maze?

    --
    They're there in their room. You're on your own.
  22. Without the use of a loop by Anonymous Coward · · Score: 0

    So apart from the loop from the goto then.

  23. Multi-Fail by SuperCharlie · · Score: 3, Interesting

    This article fails in English and fails in the content. Booya.

    1. Re:Multi-Fail by Chelloveck · · Score: 4, Interesting

      The article reads to me like a sophomore-level paper deconstructing some insignificant piece of drivel and claiming great insights into human nature.

      "What can this one line -- '10 PRINT,' to use the authors' shorthand -- teach us about software, and culture at large?"

      Damn! And that's just the review, I can't even imagine what the actual 294-page book must be like. Next up I expect a 500-page treatise on Vogon poetry.

      --
      Chelloveck
      I give up on debugging. From now on, SIGSEGV is a feature.
    2. Re:Multi-Fail by Anonymous Coward · · Score: 0

      "What can this one line -- '10 PRINT,' to use the authors' shorthand -- teach us about software, and culture at large?"

      A: Software is written by fucking morons who don't even know what constitutes a loop.
      B: Culture - if this constitutes culture - is shit.

    3. Re:Multi-Fail by Anonymous Coward · · Score: 0

      This article fails in English and fails in the content. Booya.

      Give them a break, it's obvious they've been on a very long acid trip.

    4. Re:Multi-Fail by Anonymous Coward · · Score: 0

      How about a few hundred pages going about trying to prove that 1 + 1 = 2?

    5. Re:Multi-Fail by Anonymous Coward · · Score: 0

      I imagine they will wet themselves when they discover LIFE.

    6. Re:Multi-Fail by Anonymous Coward · · Score: 0

      Damn! And that's just the review, I can't even imagine what the actual 294-page book must be like.

      No, but you'll have to, because there's no chance of you bothering to read it.

    7. Re:Multi-Fail by Anonymous Coward · · Score: 0

      I'll start chewing my arm off now.

  24. A C=64 emulator if you want to try it... by mapuche · · Score: 1

    http://codeazur.com.br/stuff/fc64_final/

  25. Python version by tepples · · Score: 5, Interesting
    The Python version is two non-comment lines:

    #!/usr/bin/env python
    # DataGlyphs simulator by Damian Yerrick
    from random import choice
    while True: print "".join(choice('/\\') for i in range(40))

    1. Re:Python version by Anonymous Coward · · Score: 1

      Full width:


      from random import choice
      while True: print choice('/\\'),

    2. Re:Python version by Anonymous Coward · · Score: 0

      This version is totally unoptimized. Try:

            for a in range(2): print "".join(choice('/\\') for i in range(40)) ... and now try:

            for a in range(15): print "".join(choice('/\\') for i in range(40))

      Second line will take forever to print anything on i5. I'm too tired to check WHY, but this looks interesting.

    3. Re:Python version by nadaou · · Score: 1

      I thought the 40 char width was a nice touch. Keepin it old school.

      --
      ~.~
      I'm a peripheral visionary.
    4. Re:Python version by Anonymous Coward · · Score: 1

      If you paste these lines into a Python interpreter, you will notice that the interpreter prompt is showing as "..." instead of ">>>" after the second line. This is because Python uses white space to delimit blocks, and in an interactive session, it is waiting for you to possibly type another statement for the for loop, or for you to terminate the block somehow. Just hit the Enter key to terminate the block.

      If you put these lines in a script and run it, there is no delay. The end-of-file terminates the last block and it just runs.

      So, sorry, no optimization problem, nothing that interesting. But thank you for being intersted in this. (I love Python and figuring this out was a pleasant diversion for a couple of minutes.)

    5. Re:Python version by Anonymous Coward · · Score: 0

      Why not do "while True: print choice('/\\') ," ?

    6. Re:Python version by sg_oneill · · Score: 1

      If you add

      from __future__ import print_function

      You can do something like

      while True: print (random.choice("\/"),end="")

      which eliminates the excess space in print blah ,

      In theory it should be possible to pack this all with the imports onto a single line. But for the life of me I cant get it to work and I'm not entirely sure why.

      --
      Excuse the Unicode crap in my posts. That's an apostrophe, and slashdot is busted.
    7. Re:Python version by Anonymous Coward · · Score: 0

      The Python version is two non-comment lines:

      #!/usr/bin/env python
      # DataGlyphs simulator by Damian Yerrick
      from random import choice
      while True: print "".join(choice('/\\') for i in range(40))

      Memory optimization: range --> xrange

      "for i in range(40)" creates a list of 40 elements and iterates through it.
      "for i in xrange(40)" yields the 40 elements without taking up space for the entire list in memory.

    8. Re:Python version by tepples · · Score: 1

      Why not do "while True: print choice('/\\') ," ?

      For one thing, Python defaults to a space character before anything output with print, and I didn't want to from sys import stdout or from __future__ import print_function. For another, I was emulating the C64's screen width.

    9. Re:Python version by Anonymous Coward · · Score: 0

      Thanks for figuring this out for me!

  26. Cellular automata by Anonymous Coward · · Score: 0

    The impressive part of this is that they managed to fluff just one recursive rule into an entire book.

    If Wolfram gets such bad reviews for stating the obvious of cellular automata after many thousands of experiments, why should we pay any attention to someone that has done just one?

  27. Reminded me of DataGlyphs by tepples · · Score: 4, Informative

    It's just randomly printing forward and backward slashes, which line up because of the font. It's nifty, but hardly amazing.

    And in fact, it appears Slashdot ran an article on this a decade ago when it was called DataGlyphs.

  28. Re:A maze by TaoPhoenix · · Score: 1

    But what exactly is a maze? If you knowingly pick a valid start and end point, doesn't it become one? Isn't a maze basically a bunch of twisty lines designed to obfuscate the path from start to finish?

    --
    My first Journal Entry ever, in 8 years! http://slashdot.org/journal/365947/aphelion-scifi-fantasy-horror-poetry-webzine
  29. /., in collaboration with the Erowid Vault by Press2ToContinue · · Score: 2

    /., in collaboration with the Erowid Vault. brings you "get high and watch this code run." Wow, it's so cool.

    --
    Sent from my ENIAC
  30. Okay, let me make sure I'm up to speed here... by Anonymous Coward · · Score: 0

    So, printing / and \ in a randomish sequence makes what looks to be a maze. Oh, and having code jump to itself is apparently not a loop. Did I miss anything?

    1. Re:Okay, let me make sure I'm up to speed here... by SomeGuyFromCA · · Score: 1

      The / and \ used on the C64 are much more 45* angles than the console / and \, making it look pretty.

      Oh, and since they're adjacent in PETSCII, you can print out either one randomly with a neat little line of code. That's it.

      Could do the same in C with
      putchar((random(2)-1) ? 47 : 92);
      if int random(int max) were defined to return a random integer from 0 to max.

      --
      if the answer isn't violence, neither is your silence / freedom of expression doesn't make it alright
  31. How did this make it on slasdot? by Anonymous Coward · · Score: 0

    Seriously, this is all a joke, isn't it? There is nobody back there monitoring this shit, is there?

  32. One line by Anonymous Coward · · Score: 0

    Almost all code can be put into a single line, don't see what' amazing about that.

  33. Yes Captain by Anonymous Coward · · Score: 2, Funny

    that's what our sensors are picking up.

  34. Re:A maze by Anonymous Coward · · Score: 0

    It would be a maze with that additional input. Without it, it's just a bunch of squiggly lines. (Hint: choosing those points is nontrivial)

  35. 80s Flashback by JoeCommodore · · Score: 2

    I remember doing that in 1980something on the PET (maybe not that line, but the logic was the same). IIRC it was a type-in along with a bunch of other cheap BASIC graphics routines in a Creative Computing - later I'm sure it showed up in RUN or Transactor for the VIC/64.

    It was cool for maybe a couple hours... along with thoughts of what games could I use it with (that's how we developed game ideas old-school style, starting with cool little snippets like this.)

    --
    "Enjoy what you're doing! If it becomes drudgery, you're doing it wrong!" - Jim Butterfield
  36. Tricks with Slash and Backslash by localman · · Score: 1

    Watching the video it occurs to me that the interesting part is that if you randomly print out slashes or backslashes endlessly, you create an endless "maze". It works particularly well on the c64 because the printable graphics set includes a slash and backslash that have no spacing around the character. But you can do the same thing in a terminal like this:

        perl -e 'while (1) { print rand() > .5 ? "/" : "\\" }';

    Although depending on your font it won't look as compelling as the c64 version.

    1. Re:Tricks with Slash and Backslash by discord5 · · Score: 3, Funny

      perl -e 'while (1) { print rand() > .5 ? "/" : "\\" }';

      Quick, claim it doesn't have a loop and write a book. :)

    2. Re:Tricks with Slash and Backslash by localman · · Score: 1

      v2 now loop free!

          perl -e 'a: print rand() > .5 ? "/" : "\\"; goto a'

    3. Re:Tricks with Slash and Backslash by Anonymous Coward · · Score: 0

      how about a loop, how about it.
      Ruby:
      loop {print ([47,92][rand 2]).chr}

      BASIC: 43 characters
      PERL: 37 characters, the earlier version
      PERL: 35 characters, the condensed version above
      RUBY: 35 characters

      even shorter, executible line? anyone?

    4. Re:Tricks with Slash and Backslash by Anonymous Coward · · Score: 0

      perl -e 'while (1) { print rand() > .5 ? "/" : "\\" }';

      Quick, claim it doesn't have a loop and write a book. :)

      WHILE is a loop dumbass!

  37. Bah why write the code... by ducomputergeek · · Score: 3, Informative
    --
    "The problem with socialism is eventually you run out of other people's money" - Thatcher.
  38. A meditation by LihTox · · Score: 3, Informative

    From page 4 of the book:

    This book is unusual in its focus on a single line of code, an extremely concise BASIC program that is simply called 10 PRINT throughout. Studies of individual, unique works abound in the humanities. Roland Barthes’s S/Z, Samuel Beckett’s Proust, Rudolf Arnheim’s Genesis of a Painting: Picasso’s Guernica, Stuart Hall et al.’s Doing Cultural Studies: The Story of the Sony Walkman, and Michel Foucault’s Ceci n’est pas une pipe all exemplify the sort of close readings that deepen our understanding of cultural production, cultural phenomena, and the Western cultural tradition. While such literary texts, paintings, and consumer electronics may seem significantly more complex than a one-line BASIC program, undertaking a close study of 10 PRINT as a cultural artifact can be as fruitful as close readings of other telling cultural artifacts have been.

    In short, this is not a programming book, but it appears to be a book of cultural anthropology about programming. Or perhaps a meditation which starts with one simple starting point and branching out in many different directions. Criticizing the program "10 PRINT" as trivial rather misses the point, I should think.

    1. Re:A meditation by ctnp · · Score: 1

      Maybe a metaphorical fugue?

    2. Re:A meditation by Anonymous Coward · · Score: 0

      It's on-point when they make it out to be a great piece of art from which we can divine something about human nature, when in reality it's some throwaway demonstration code that randomly prints a forward or backward slash.

    3. Re:A meditation by Anonymous Coward · · Score: 0

      Sounds like the book could have just as easily been based on an ink blot.

    4. Re:A meditation by Anonymous Coward · · Score: 0

      You must be new here.

      Since the post is about a Commodore program, you should have entitled your comment "Guru meditation"

  39. Bad Summary by fast+turtle · · Score: 0

    as the Goto 10 is a loop statement w/o end.

    --
    Mod me up/Mod me down: I wont frown as I've no crown
  40. Well... by fabioalcor · · Score: 1

    At least it would make a nice geeky retro screensaver.

  41. What is loop? by Anonymous Coward · · Score: 1

    Slashdot don't hurt me
    Slashdot don't hurt me
    no more.

  42. No, not Linux too ... by Zero__Kelvin · · Score: 1

    "The entire basis of the OS you are using is filled with them. Yes, Linux too."

    I guess you've never looked at the Linux source code. There certainly are a (very) few gotos, but it is certainly not "filled" with them. They are very rare indeed.

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    1. Re:No, not Linux too ... by Anonymous Coward · · Score: 0

      As of a couple of days ago, there were 102473 instances of "goto" in the kernel, 32717 of "while", 790812 of "if", and 181536 of "for".

      You can weasel all you want about what "filled" and "very rare" mean, but I'd say you're wrong.

    2. Re:No, not Linux too ... by Anonymous Coward · · Score: 0

      I think you haven't looked (I did a ten second check) and found 101395 instances of it in Linux 3.6.8

    3. Re:No, not Linux too ... by Zero__Kelvin · · Score: 1

      You looked and found 101395 instances of it? I think you mean you grepped for the word goto, forgetting that the word goto can appear in comments as well. I don't doubt that there are a large number of them (though a very, very small percentage), but I highly doubt your claim that in ten seconds you determined the correct number. Something like find . -name "*.c" -exec grep -H " goto " {} \; won't give you the correct answer for the aforementioned reason.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    4. Re:No, not Linux too ... by Anonymous Coward · · Score: 0

      No, they're not rare.

  43. Kinda lame by floodo1 · · Score: 1

    I think the slashdot editor read a little bit too much into this quote "It uses a GOTO instead of a more elegant loop." This doesn't mean it has no loop as stated here on slashdot.

    This article is the least interesting thing in a long time. Sure it's sorta cool that one line makes a cool looking screen on your commodore, but to extrapolate the grand claims that the article and the book make is nuts!

    --
    I KUT J00 M4NG!!!
  44. NO NEED FOR PETSCII by VeryLargeNumber · · Score: 1

    10 PRINT CHR$ (47+45*INT(RND (1)+0.5));: GOTO 10 : REM USES ASCII

  45. Quite yer bitchin, nerds by CockMonster · · Score: 1

    You get a free book.

  46. Not even that by Immerman · · Score: 5, Insightful

    It certainly has the intricate path part down, but most people would take issue with a "maze" that lacks a beginning, end, or any guarantee that you can get from point A to B even if you consider obvious closed loops out of bounds.

    --
    --- Most topics have many sides worth arguing, allow me to take one opposite you.
    1. Re:Not even that by osu-neko · · Score: 1

      I doubt it. Most people would look at the result of that program and declare it a maze instantly. They would only object to the features you note if you dropped them in the middle of it...

      --
      "Convictions are more dangerous enemies of truth than lies."
    2. Re:Not even that by Immerman · · Score: 1

      And most people would look at a sealed bottle of hydrochloric acid and call it water. It's their judgement once they've had a chance to notice salient details that matters.

      --
      --- Most topics have many sides worth arguing, allow me to take one opposite you.
  47. A simple Linux port by Sam+H · · Score: 2, Insightful

    strings /dev/urandom|tr -dc '/\'

    --
    God, root, what is difference ?
    1. Re:A simple Linux port by Sam+H · · Score: 5, Insightful

      Sorry, what was I thinking? This is obviously more elegant:

      tr -dc '/\' </dev/urandom

      --
      God, root, what is difference ?
    2. Re:A simple Linux port by cloudmaster · · Score: 1

      How crude. Clearly, you should be doing it with shell builtins directly instead of spending all that time opening a new filehandle and forking a child process. ;)

      while c=([0]=/ [1]=\\); do echo -n ${c[$((RANDOM%2))]}; done

      (actually, I really like the tr version)

  48. Not as impressive in ASCII by hawguy · · Score: 1

    It's not quite as impressive in ASCII (or Bash):


    #!/bin/bash

    char[0]='/'
    char[1]='\'

    while :
    do
            echo -n ${char[$(($RANDOM % 2))]}
    done

    I tried to include the output here, but Slashdot told me to "Please use fewer 'junk' characters"

    1. Re:Not as impressive in ASCII by gl4ss · · Score: 1

      choose a different font. choose some 8x8 set or so.

      also dear slashdot, whe the fuck is the no karma bonus option hidden somewhere behind a shitty menu now when posting? WHY??? IS SLASHDOT THE MAZE??

      --
      world was created 5 seconds before this post as it is.
  49. Ruby by RedHackTea · · Score: 1

    loop{print(rand(2)==0?'/':'\\')}

    --
    The G
  50. Diablo by dmomo · · Score: 3, Funny

    Wow. Who would have known that the code for Diablo is so simple.

  51. It's not a maze... by Anonymous Coward · · Score: 0

    Look closely, there are NO deadends.. Not a maze. Just pretty.

  52. Control-C ?! (Infamous last words of TFA on Slate) by D4C5CE · · Score: 1
    RUN/STOP - it's a C64, you insensitive clod. ;-)

    And since when's an infinite loop not a loop?

  53. ObBetteridge by Anonymous Coward · · Score: 0

    No.

    OK, well this is C64-specific because it relies on C64's PETSCII table.

    http://www.c64-wiki.com/index.php/PETSCII

    \ is at 109, / is at 110.
    According to the wiki, "Codes 192-223 as codes 96-127" so the program could've used 109.5 instead of 205.5.

    CHR$ 205 prints \
    CHR$ 206 prints /
    RND(1) returns [0 to 1), so adding the value to 205.5 and truncating the float either makes 205 or 206.
    PRINT with ; does not move to next print zone
    : separates statements
    GOTO 10 loops

  54. Fun bit of computing history there by AllanNienhuis · · Score: 2

    This type of thing has a pretty honourable history. Back in the day, there was actually a (small?) subculture of enthusiasts who experimented with one-line or two-line basic programs (I'm sure this was the case with other platforms/languages as well). Similar to the whole demogroup scene I guess - a way of experimenting and showing off. Each line number of a basic program was limited to I think 256 characters. It could have as many statements (separated by colons) as desired. Some folks would go so far as to 'poke' machine code instructions and then jmp/execute that machine code, but I think that was frowned upon a bit as that seemed a bit like cheating... :) There were contests and so on, and popular magazines like 'Nibble' would regularly publish these mini-programs which thousands of us would type into our computers. In doing so many of us became fascinated by what was possible, even if it promoted a rather unhealthy obfuscated code style... Naturally today with almost unlimited computing resources available to every programmer, this isn't amazing at all. But back then, this sort of thing _was_ pretty amazing - even if this isn't a particularly shining example of it. Some folks were able to generate real, playable games, or amazing visual animation effects in less than 500 bytes of source. It makes me want to drag out the old Apple II emulator and play around! Man, I wish I hadn't sold that old doorstop apple II... :)

    --
    Don't judge me based on my high slashdot user id!
  55. without very complicate syntax by Hognoxious · · Score: 1

    without very complicate syntax

    Can it work out the difference between a verb and an adjective?

    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  56. The real story here is a hacked Slashdot account! by Anonymous Coward · · Score: 0

    http://www.monkey.org/~timothy/

    Obviously the timothy /. admin account has been compromised by a spammer.

    How many geeks does it take to screw in a lightbulb? Hundreds. Geeks don't screw in lightbulbs, they debate the nature of the bulb until somebody else comes along and shines some light on the subject.

  57. who else but timothy by Anonymous Coward · · Score: 1

    to let such garbage through on slashdot

  58. in C by bitcoinnaire · · Score: 0

    int main() { l0: printf("%c", (rand()&1)?'/':'\\'); goto l0; }

    1. Re:in C by Anonymous Coward · · Score: 0

      Doesn't compile because of missing includes!

      Try this more elegant version:

      #include <stdio.h>
      #include <stdlib.h>
      int main()
      {
                      for(;;) putchar("/\\"[rand()&1]);
      }

      (works also in C++)

    2. Re:in C by bitcoinnaire · · Score: 0

      works for me. both on mac and linux.

    3. Re:in C by Anonymous Coward · · Score: 0

      Which compiler is that supposed to be? All I get is:

      $ cat x.C
      int main() { l0: printf("%c", (rand()&1)?'/':'\\'); goto l0; }
      $ gcc -Wall x.C
      x.C: In function ‘int main()’:
      x.C:1:37: error: ‘rand’ was not declared in this scope
      x.C:1:50: error: ‘printf’ was not declared in this scope

      Compiler version:
      $ gcc -v
      Using built-in specs.
      COLLECT_GCC=gcc
      COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
      Target: i686-linux-gnu
      Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
      Thread model: posix
      gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

    4. Re:in C by bitcoinnaire · · Score: 0

      $ cat 10print.c
      int main() { l0: printf("%c", (rand()&1)?'/':'\\'); goto l0; }
      $ gcc 10print.c -w -o 10print
      $ ./10print
      \///\\\\\//\/\^C

      $ gcc -v
      ...
      gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

  59. Cross-platform port by Anonymous Coward · · Score: 0

    In perl, it's still a one-liner.
    while (1) { print substr('/\\',int(.5+rand(1)),1); }

  60. QBasic version by Anonymous Coward · · Score: 0

    REM This isn't a one-liner, but nothing in such a powerful BASIC syntax is. REM SCREEN 1 REM Un-REM the next line to add color, though it isn't as good as the C64 REM COLOR 9, 1 CLS 10 PRINT CHR$(47 + INT(RND * 2) * 45); : GOTO 10

    1. Re:QBasic version by Hsien-Ko · · Score: 1

      Yeah, I wondered why when I tried that "one line" I winded up with a screen full of intersections.

  61. Apple II version by SickLittleMonkey · · Score: 1

    10 PRINT CHR$(INT(.5+RND(1))*45+47);:GOTO 10

    --
    main() {1;} // zen app
  62. Wrote this 27 years ago. by Anonymous Coward · · Score: 0

    I wrote this in 1985 on an Amstrad CPC. I then added a few extra lines to allow a single pixel to navigate the entire maze using INKEY$ and GET. Great game. Next, do "Hunt the Wumpus" in one line.

  63. i prefer c over basic by hanz88 · · Score: 3, Interesting

    int main(){for(;;)putchar("\\/"[rand()%2]);}

  64. Book not so bad by HuguesT · · Score: 2

    The book is worth reading, it retells many things from the beginning of personal computing, exploring subjects along the way. the 10 PRINT one-liner is the motivation but not the topic.

    Cheers.

    1. Re:Book not so bad by wlj · · Score: 1

      Pretty quick read with some nice old pictures.

      One thing I did not find: reference to the MAT statements in the old BASIC and how M$ dropped them. They were a very interesting feature at many levels.

  65. The Code is Meh but the Concept Is Laudable by Anonymous Coward · · Score: 1

    Many of the great programmers of my generation started out this way. It had occurred to a few rare teachers in public school systems in the late 70s to start teaching computer programming, and the tools available to them were things like S-100 CP/M machines, acoustic couplers to downtown PDP-11s, Apple IIs, TRS-80s, and Commodore 64s. BASIC in school was ubiquitous and worked fine for teaching the core concepts of how to design algorithms and data structures. Students who really lit up on this would tend to delve into assembly language as they sought to understand the machines, and many of them would turn into great programmers.

    That seems to have largely been lost. Many schools shifted to classes called simply "computers", where the focus shifted to teaching students how to use word processors and spreadsheets instead of how to create them. Typing was made a prerequisite. Today, I regularly encounter programmers 20 and 30 years younger then I who believe that programming mainly consists of bolting components together with as little original algorithm and database design as possible. I believe that this is because the school system curriculums have declined, and that as a result, much of the industry largely consists of hundreds of permutations, all basically the same shallow stuff, that are used to build web sites and applications that run on web sites and bolt them to databases. IIS and Apache on NT or Linux, CGIs written in any of a hundred languages, some interpreted, some not; it's essentially a homogenized slurry, and not much of it is particularly interesting or impressive. A return to a time where most programmers had the ability to consider whether it's better to write a optimized database access method to some custom files or use a canned database rather than simply choosing between several database packages would be a good thing.

  66. It's called by Anonymous Coward · · Score: 1

    Recursion, ya jabroni's.

    1. Re:It's called by Anonymous Coward · · Score: 0

      No, it isn't.

  67. anyone have the postscript version? by cellocgw · · Score: 1

    Back in the 80's I remember finding (via the nascent web) a postscript code snippet that would draw a legal maze. The code drew vertical or horizontal lines one box-size long, and had a rule or two that made sure enough edges were NOT drawn that a path existed from start to end.
    If anyone has that lying around, I wouldn't mind seeing it again.

    --
    https://app.box.com/WitthoftResume Code: https://github.com/cellocgw
    1. Re:anyone have the postscript version? by narcc · · Score: 2

      Here you go:

      http://peter.sorotokin.com/maze/Maze.html

      It's just below the java applet.

  68. Slashdot Article Generator by PPH · · Score: 1

    strings /dev/urandom | tr -dc '/.'

    --
    Have gnu, will travel.
  69. An explanation of the code by Anonymous Coward · · Score: 2, Informative

    If you need help with the code, here's a simple explanation:

    The RND(1) function will return a floating point value between 0 and 1 (technically, this is 0 to 0.999... but let's just call it 0 to 1). So the part of the code that says 205.5 + RND(1) simply returns a value somewhere between 205.5 and 206.5. Assuming the RND(1) function is a good random number generator, that means half of the numbers will be between 205.5 and 205.9999..., and half will be between 206.0 and 206.5.

    The CHR$() function pulls a single character from the Commodore 64's PETSCII table. The address is always an integeter, so if you ask for CHR$(205.999), that's the same as CHR$(205). Similarly, asking for CHR$(206.5) is the same as CHR$(206).

    In the PETSCII table, character 205 is a single backslash, and character 206 is a single forward slash. So what the code is doing is very simple: it simply prints either a forward slash or a backslash, and keeps doing it because it loops back to itself.

    This same code won't work on Linux or Windows/DOS because in the ASCII table, the forward slash is 057, and the backslash is 134. For ASCII systems, you'd need to (basically) flip a coin and print "\" if heads, and "/" if tails.

    And that's all it does. There's no magic. No guarantee it is even a solvable maze. It just looks pretty.

    -jh

    1. Re:An explanation of the code by UBfusion · · Score: 1

      Where has this world come to? Are we so ashamed to explain BASIC code that we have to post anonymously? What comes next, Newtonian mechanics?

  70. Endless 'i' characters? by Ossifer · · Score: 0

    So it prints an endless set of 'i', with either a circumflex or an "umlaut"?

  71. 10 STUFF : GOTO 10 is a loop by EmagGeek · · Score: 1

    Sorry, 10 STUFF : GOTO 10 is the use of a loop.

  72. Expected path length by lahvak · · Score: 1

    What would be the expected path length in such thing?

    --
    AccountKiller
  73. Record breaking by flimflammer · · Score: 1

    It seems as if every single user on Slashdot felt they had to chime in to alert the world that 10 GOTO 10 is in fact a loop, as if everybody else hadn't already made that point.

    1. Re:Record breaking by Psychotria · · Score: 3, Funny

      It seems as if every single user on Slashdot felt they had to chime in to alert the world that 10 GOTO 10 is in fact a loop, as if everybody else hadn't already made that point.

      The thing is, GOTO 10 is a loop. Therefore it's not without a loop. QED.

  74. Crappy Javascript version? by Anonymous Coward · · Score: 0

    Something simple enough for my typical crap-tastic non-programmer level of skill. Definitely not the best, but something. I'm sure somebody could make a one-line version for greasemonkey or whatever. Uses two nested loops, but they seem necessary to keep things reasonable.

    function makeCrappyMaze() {
            document.write ("<br/>");
            charArray = new Array();
            charArray = ["\u2500","\u2502","\u250C","\u2510","\u2514","\u2518","\u251C","\u2524","\u252C","\u2534","\u253C"]
            for (i=1; i<40; i++) {
                    for (j=1; j<60; j++) {
                    randNum = parseInt(Math.random() * charArray.length);
                    document.write (charArray[randNum]);
                    }
            document.write ("<br/>");
            }
    }

    It could probably be more compact without arrays, but I find the unicode escapes seem to work more consistently than ASCII codes with String.fromCharCode() for the extended set. (Depending on font, I'd get gibberish instead of desired box drawing characters.)

  75. Random data by Anonymous Coward · · Score: 0

    Some combination of random bits is a BMP of you and hitler spooning.

  76. Lisp by Jmc23 · · Score: 1
    One liner's in Lisp can be arbitrarily, almost infinitely complex.

    Here's a mishmash of idioms

    (dotimes (height 40) (terpri) (loop :for width :from 0 :to 20 :do (format t "~A" (aref #(#\\ #\/) (random 2)))))

    --
    Don't complain about syntax, grammar, or spelling. There is no.hell like input on android.
  77. Did that in 1982 by Bender+Unit+22 · · Score: 1

    on my Commodore 64, made mazes for the school newspaper.
    Since there were multiple paths through, I had to find one myself first and add an arrow to tell people where to start.

  78. Truchet Tiling by Anonymous Coward · · Score: 0

    http://mathworld.wolfram.com/TruchetTiling.html

  79. Reminded me of Music from very short programs by Anonymous Coward · · Score: 0

    Enjoyable music made with very short programs.

    http://www.youtube.com/watch?v=qlrs2Vorw2Y
    http://www.youtube.com/watch?v=tCRPUv8V22o

  80. PHP one line, "no loops" by Anonymous Coward · · Score: 0

    ?php l10: echo chr(47+rand(0,1)*45); goto l10;

  81. Atari Home Computer System by Daniel+Klugh · · Score: 1
    On the Atari HCS:
    10PR.CHR$(6+RND(0));:G.10
    which, when entered and then LISTed back out, becomes:
    PRINT CHR$(6+RND(0));:GOTO 10
    You might also want to POKE 82,0:POKE 712,148 to use the whole screen and make the border colour match the background.

    Atari BASIC rounds to the nearest whole number rather than just dropping the fraction; hence the use of "6" instead of "6.5".
    (it's actually theï Atari OS doing the rounding, not the BASIC lang. cart. itself)

    --
    Daniel Klugh
  82. Cheap Random Number Generator Artifacts by billstewart · · Score: 1

    One lesson my Time Series Analysis professor taught us in college was "If you stare at the numbers long enough you'll see all sorts of patterns in it!", pretty much regardless of whether they're there or not.

    This "maze" looks to me a lot like there's more structure than you'd get from a good i.i.d. random number stream. Is it just the mind finding patterns when they're not there, or are there patterns because the BASIC RNG isn't very good and is splattering artifacts all over the output? Most of the BASIC systems I've seen didn't begin to approach cryptographic quality, and were typically simple linear congruential multipliers.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  83. Open source? by Tablizer · · Score: 1

    Okay, so where can I download the BASIC code? :-)

  84. Not a single line... by Anonymous Coward · · Score: 0

    The colon (:) indicates a delimiter of a line, or statement. Thus this example is really two lines.

    Similarly, it is possible to write an entire program in BASIC on a "single" line. Which would be nearly impossible to read but it will work.

  85. Loop by Anonymous Coward · · Score: 0

    It wouldn't be a classic loop if you replaced the Goto with Run. It would produce a looping effect by chaining new program starts.

  86. C64 physics engine by Anonymous Coward · · Score: 0

    If the code in this article is 'an intricate maze without the use of a loop' than this is a C64 physics engine and also deserves a book:

          10 POKE 53281,1: PRINT""
          20 POKE 53280,7: POKE 53281,6
          30 X = 1 : Y = 1
          40 DX = 1 : DY = 1
          50 POKE 1024 + X + 40 * Y, 81
          60 FOR T = 1 TO 10 : NEXT
          70 POKE 1024 + X + 40 * Y, 32
          80 X = X + DX
          90 IF X = 39 THEN DX = -DX
        100 Y = Y + DY
        110 IF Y = 24 THEN DY = -DY
        120 GOTO 50

  87. Potential for porting by SpaghettiPattern · · Score: 1

    Gee! I wonder whether it can be ported to other inferior languages. We must produce more geniuses. Our civilisation is about to be annihilated!

    --

    I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
  88. Command line (bash) analogue, goto != loop, font by Khopesh · · Score: 1

    This should work in most advanced POSIX shells (though /bin/sh won't support $RANDOM if it's dash or some other leaner version)

    while :; do [ $((RANDOM%2)) = 0 ] && printf / || printf \\; done

    To all those people saying goto is a loop: it's only effectively a loop. Goto itself is not a loop, it's an assembler's jump and can do lots of things that loops cannot (loops and conditionals are implemented as jumps). For example, goto has no sense of nesting (or scope) and can be called in the most unexpected of places. This is why it's present but considered taboo in most languages.

    Also note that for maximum effect, you need a fixed-width font whose width equals its height and as much space between lines as is used between consecutive characters.

    Of course, if this kind of thing interests you, there's more impressive things you can do for pretty effects in short snippets of code.

    --
    Use my userscript to add story images to Slashdot. There's no going back.
  89. There were better.. but who remembers? by The+Optimizer · · Score: 1

    I must be getting very old. Back in the 8-bit heyday (1979-1983), Softside Magazine (for TRS-80, Apple ][ and Atari 800 users) used to have 2 submission contests that they ran in almost every issue: One line programs ( "one-liners" I think they called them) and 1K programs (program size without running = 1023 bytes or less).

    The TRS-80 was probably the best machine for one-liners as a single line could be 245 or so characters long (the Atari was limited to 120 characters, but you could abbreviate some keywords, I don't recall the Apple ][ Basic line limit).

    The one-liner I remember the most was a graphical version of the old "Lunar Lander" game for the TRS-80. Yes, graphical. A loop (X =0 to X= 127) created the lunar landscape, followed by a loop which updated the state machine of your ship (a single "dot" drawn with the SET and RESET commands) that factored in which keys you were holding down (PEEK of the keyboard matrix I think), and tested to see if you hit the ground with your velocity under some threshold. *THAT* single-line effort was certainly more interesting that the one presented here.

  90. Slashdotters struggle to understand... by Anonymous Coward · · Score: 0

    ..art theory article.

    Film at 11.

    *sigh*

  91. no-loop version by SimplexBang · · Score: 1

    The no-loop version would be an entire maze printed on a single line ...

    --
    Avoid your fears , or wonder at the past
  92. Tetris in one line of BBC Basic by Anonymous Coward · · Score: 0

    In my eyes, this is way more impressive - the link contains a detailed explanation of how it was achieved.

    Tetris in one line of BBC Basic

    And here's the final code:

    0d=d:IFdVDUd:a=POINT(32*POS,31-VPOS5):RETURNELSEMODE9:GCOL-9:CLG:O
    FF:d=9:REPEATVDU30:REPEATGOSUBFALSE:IFPOS=28VDUPOS,15,VPOS,24;11,26:IF0E
    LSEIFa=0PRINT:UNTIL0ELSEUNTILVPOS=25:v=ABSRNDMOD7:i=0:VDU4895;3:REPEATm=
    9-INKEY6MOD3:FORr=TRUETO1:t=rANDSGNt:IFt=rCOLOURv-15:VDUrEORm:i+=m=7AND9
    -6*r:IF0ELSEFORn=0TO11:d=n/3OR2EORd:GOSUBFALSE:IF1(n+i)MOD12AND975AND&
    C2590EC/8^vVDU2080*ABSr;:t+=a:IF0ELSENEXT,:VDU20:UNTILt*LOGm:UNTILVPOS=3

    1. Re:Tetris in one line of BBC Basic by petteyg359 · · Score: 1

      Cramming everything into one line does not magically reduce the number of statements used. I could write a combined jquery, extjs, yui, and prototype all on one line, too.

  93. What preprocessor include directive? by Anonymous Coward · · Score: 1

    int printf(char*,...);int rand(void);int main() { ten: printf("%c", (rand()%2)?47:92); goto ten; }

    Fixed that, single line and no unnecessary includes. A C #include just reads the contents of a different file, in this case only the declarations of printf and rand stored in stdio.h are of interest and can be used without the #include.

  94. It is a loop. by Anonymous Coward · · Score: 0

    The article says it doesn't use a loop, but "10 GOTO 10" is an infinite loop.

  95. This is a troll by REALMAN · · Score: 1

    It doesn't really generate a maze. A true maze has one entrance, many dead ends and one exit or solution. This is just random generated loops that resemble a maze.
    The "book" is meaningless drivel written in a style that seems to produce anger in the reader which I believe is the intent.

    --
    - A Frog in a pond utters an azure cry. -
  96. Book Title by Anonymous Coward · · Score: 0

    There is a metaphysical discussion wrapped in the fact that the title of the book has a syntax error...perhaps I'll write a book.

  97. great t-shirt by lems1 · · Score: 1

    something for geeks to wear on a t-shirt as the pattern has some geek creds ;)

    --
    This sig can be distributed under the LGPL license
  98. GOTO where? by hegstrom · · Score: 1

    7734 PRINT CHR$ (205.5 + RND (1)); : GOTO 7734 Saw a code snippet in a microsoft manual in the mid 80's that used 7734 as the target.

  99. Deterministic infinite mazes by grahamluckhurst · · Score: 1

    I have been playing around, in an amateurish way, with is for years. The slight difference is that I wanted a maze that was random but consistent. If you return to a location it same as before. All you need to do is to seed the random number generator with the maze coordinate. What I did not expect is how pretty they look. Examples http://www.infinitemaze.com/2.html.

  100. Re:Command line (bash) analogue, goto != loop, fon by Anonymous Coward · · Score: 0

    No one argues that "goto" is a looping command; they're arguing that the program contains a loop implemented with a goto.

    If we're going to split hairs like that, how about also noting that printf isn't a builtin with the POSIX shell (http://pubs.opengroup.org/onlinepubs/009695399/idx/sbi.html), so that's not truly a shell program. http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html for the full reference.

  101. 1kb roguelikes by Anonymous Coward · · Score: 1

    Should we tell these people about 1KB Roguelikes which implement an entire adventure game in a single line with 1024 characters? Probably not or they'd have an orgasm.

    1. Re:1kb roguelikes by Smallpond · · Score: 1

      Should we tell these people about 1KB Roguelikes which implement an entire adventure game in a single line with 1024 characters? Probably not or they'd have an orgasm.

      Conway's Life used to be popular for writing one-liners, too.

  102. Alogrithm output by Anonymous Coward · · Score: 0

    A maze created with this algorithm, false colored:

    http://img841.imageshack.us/img841/1472/fooout.png

    While there are many very small components, there are also some pretty large ones. I wonder how large they can get on average (so some sort of probability-based proof)?

  103. How is this even published on /. by uninformedLuddite · · Score: 1

    How is this even published here. It's a big steaming pile of crap. No wonder the types of people you want here have stopped coming. I keep saying that I won't be back but I invariably return. Once this website's articles provoked wonder and awe.

    --
    The new right fascists are bilingual. They speak English and Bullshit.
    1. Re:How is this even published on /. by jlv · · Score: 1

      Agreed! I wish mod points let me mod the article down!

  104. Re:Command line (bash) analogue, goto != loop, fon by Anonymous Coward · · Score: 0

    If we're going to split hairs like that, how about also noting that printf isn't a builtin with the POSIX shell, so that's not truly a shell program.

    Neither is $RANDOM, as noted above. That was a bash script (also noted above). Printf is a bash builtin.

  105. The summary is bogus by Anonymous Coward · · Score: 0

    Why hasn't timothy been fired yet?

  106. A touch of 6502 by Wisdom · · Score: 1

    Here is a 13 bytes version in 6502 machine code:

    7C 00 20 D2 FF A1 85 29 01 E9 92 D0 F5

    (Save this as a .prg file and run it in your favourite C64 emulator or on the real thing itself. Please note that the first two bytes are actually required by .prg file format to indicate load address. The actual code is 11 bytes).

    For more information:

    http://pouet.net/prod.php?which=60810

  107. Sorry you guys didn't like it. by JameskPratt · · Score: 1

    I am not a programmer. I do understand that goto makes the line repeat, so when I said that it had no loops all I meant was that it didn't use more conventional methods such as do until and for loops. For me this was interesting because it just one line a code and it can do something interesting as in like David Ahl books. As a nonprogrammer (I only tinker in code on occasion) I find little snippets of code that do something interesting, even if its noise or chaos to you, interesting none the less.

  108. Javascript version by Anonymous Coward · · Score: 0

    For fun I made a JS version. It uses images to draw the maze and similarly doesn't use variables or "a loop"

    setInterval(function() { document.write(' 0 ? 'kNsS0' : 'NfWrh') + '.png" />'); } , 10);

    if you stick a "javascript:" in front of it, it can be run from the address bar.

    1. Re:Javascript version by Anonymous Coward · · Score: 0

      ehh the filter ate part of it. You get the idea. Inserts img tags from imgur.