![]() |
|
|
#12 | |
|
Bamboozled!
"πΊππ·π·π"
May 2003
Down not across
2A0116 Posts |
Quote:
Code:
#include <stdio.h>
void hello (char *s)
{
int i = 42;
char c;
while (1)
{
switch (i)
{
case 7:
putchar ('\n');
i = 93;
break;
case 0:
putchar (c);
i = 5;
break;
case 42:
c = *s;
i = 19;
break;
default:
s++;
i = 42;
break;
case 93:
return;
case 19:
i = (c == 0) * 7;
}
}
}
main ()
{
hello ("Hello world");
}
Paul |
|
|
|
|
|
|
#13 | |
|
"Mark"
Apr 2003
Between here and the
11·577 Posts |
Quote:
|
|
|
|
|
|
|
#14 | |
|
May 2008
Worcester, United Kingdom
22·7·19 Posts |
Quote:
The real issue here is not to avoid 'break' or 'goto' clauses but rather to avoid their inappropriate use. The use of break clauses to achieve early exits from loops is often appropriate - so much so that some high level languages have a specific construct to achieve this. Brian Gladman PS to Paul - I was about to disagree with you until I actually read your piece of code :-) Last fiddled with by Brian Gladman on 2009-04-06 at 15:18 |
|
|
|
|
|
|
#15 |
|
Bamboozled!
"πΊππ·π·π"
May 2003
Down not across
2A0116 Posts |
|
|
|
|
|
|
#16 |
|
Jan 2004
103 Posts |
And here I was thinking Paul's "Hello World" was a beautifully elegant, transparent, tight, high performance implementation, exhibiting supreme mastery of the language. Damn!
|
|
|
|
|
|
#17 | |
|
Bamboozled!
"πΊππ·π·π"
May 2003
Down not across
10,753 Posts |
Quote:
In particular, it's a clear and simple example of the concept of Turing eqivalence -- in particular, of how to implement GOTO in a Turing-complete language which lacks an explicit representation of that concept. I even demonstrated how to implement a computed GOTO though that was, I confess, showing off. Paul |
|
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ivy Bridge Thread | Dubslow | Hardware | 70 | 2012-05-25 00:56 |
| Bad Poetry Thread | Passionflower2 | Lounge | 26 | 2012-01-25 04:35 |
| PRP discussion thread | philmoore | Five or Bust - The Dual Sierpinski Problem | 83 | 2010-09-25 10:20 |
| If a p-1 thread is unStickied, does it mean it's done? | jasong | Marin's Mersenne-aries | 2 | 2006-10-08 02:07 |
| Deutscher Thread (german thread) | TauCeti | NFSNET Discussion | 0 | 2003-12-11 22:12 |