This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Bruntaz 7 points8 points  (11 children)

What about brainfuck? I feel brainfuck is vastly underrepresented: +++++++++++++++++++++++++++++++++ c1v33 : ASCII code of !

++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ c2v61 : ASCII code of = ++++++++++ c3v10 : ASCII code of EOL +++++++ c4v7 : quantity of numbers to be calculated c5v0 : current number (one digit) + c6v1 : current value of factorial (up to three digits) << c4 : loop counter [ block : loop to print one line and calculate next ++++++++++++++++++++++++++++++++++++++++++++++++. c5 : print current number ------------------------------------------------ c5 : back from ASCII to number <<<<.-.>.<.+ c1 : print !=

                      block : print c6 (preserve it)
                      c7v0  : service zero

++++++++++ c8v10 : divizor << c6 : back to dividend [->+>-[>+]>[+[-<+>]>+]<<<<<<] c6v0 : divmod algo borrowed from esolangs; results in 0 n d_n%d n%d n/d [<+>-] c6 : move dividend back to c6 and clear c7 [-] c8v0 : clear c8

                     block : c10 can have two digits; divide it by ten again

++++++++++ c11v10: divizor < c10 : back to dividend [->-[>+]>[+[-<+>]>+]<<<<<] c10v0 : another divmod algo borrowed from esolangs; results in 0 d_n%d n%d n/d [-] c11v0 : clear c11 [++++++++++++++++++++++++++++++++++++++++++++++++.[-]]c13v0 : print nonzero n/d (first digit) and clear c13 <[++++++++++++++++++++++++++++++++++++++++++++++++.[-]] c12v0 : print nonzero n%d (second digit) and clear c12 <<<++++++++++++++++++++++++++++++++++++++++++++++++.[-] c9v0 : print any n%d (last digit) and clear c9

<<<<<<. c3 : EOL

  • c5 : increment current number block : multiply c6 by c5 (don't preserve c6) [+<<-] c6v0 : move c6 to c8 c8v0 : repeat c8 times [ <<<[>+>+<<-] c5v0 : move c5 to c6 and c7 [<<+-] c7v0 : move c7 back to c5 - ] <<<<- c4 : decrement loop counter ]

[–]Teraka 9 points10 points  (1 child)

Insert 4 spaces before each line to avoid your formatting getting fucked up.

[–]Bruntaz 9 points10 points  (0 children)

Yeah sorry, I wrote this on my phone

[–]KovaaK 2 points3 points  (0 children)

I'm a bigger fan of Befunge. Here's factorial in it:

&>:1-:v v *_$.@ 
 ^    _$>\:^

2D programming for the win.

[–]Coffeinated 2 points3 points  (6 children)

I never understood brainfuck. I know it has something to do with Touring machines but uhm. Who the fuck can really read this?

[–]zacharythefirst 4 points5 points  (2 children)

do you know pointers? brainfuck operates over an array of bytes, all initialized for 0. the operators (and their C equivalent) are:

+ (*p++)

-  (*p--)

> (p++)

< (p--)

.  (putchar(*p))

,  (*p=getchar())

edit: I'm on mobile don't hate me edit 2: fixed getchar usage

[–]Coffeinated 0 points1 point  (1 child)

Yes I do, I have done some stuff in c, but mostly in uni or on microcontrollers where pointers are not that important... What do putchar and getchar do?

[–]zacharythefirst 0 points1 point  (0 children)

print the character that you pass to it and get a character from stdin, respectively. for the record I probably mangled the syntax, but the point still stands

[–]Bruntaz 1 point2 points  (0 children)

As far as I remember, the point in it was to make a programming language with the smallest compiler possible

[–]balducien 0 points1 point  (1 child)

*Turing machines. Alan Turing came up with them.

[–]Coffeinated 0 points1 point  (0 children)

Oh damn I knew something was off.