Logo

Greetings from The On-Line Encyclopedia of Integer Sequences!

Hints

Search: id:A132343
Displaying 1-1 of 1 results found. page 1
     Format: long | short | internal | text      Sort: relevance | references | number      Highlight: on | off
A132343 Output of Knuth's "man or boy" test for varying k. +0
1
0, -2, 0, 1, 0, 1, -1, -10, -30, -67, -138, -291, -642, -1446, -3250, -7244 (list; graph; listen)
OFFSET

1,2

COMMENT

The man or boy test was proposed by computer scientist D. E. Knuth as a means of evaluating implementations of the ALGOL 60 programming language. The aim of the test was to distinguish compilers that correctly implemented "recursion and non-local references" from those that did not.

LINKS

D. E. Knuth (Jul 1964). Man or boy?.

Charles H. Lindsey (Dec 1988). Block Structure and Environments.

PROGRAM

I have written the following simple routine, which may separate the "man-compilers" from the "boy-compilers" - D. E. Knuth.

Original ALGOL 60 program by Knuth, different values obtained by modifying the "10" in the last line.

begin

real procedure A (k, x1, x2, x3, x4, x5);

value k; integer k;

begin

real procedure B;

begin k:= k - 1;

B:= A := A (k, B, x1, x2, x3, x4);

end;

if k <= 0 then A:= x4 + x5 else B;

end;

outreal (A (10, 1, -1, -1, 1, 0));

end;

Smalltalk:

Integer>>manOrBoy

^self x1: [1] x2: [-1] x3: [-1] x4: [1] x5: [0]

Integer>>x1: x1 x2: x2 x3: x3 x4: x4 x5: x5

| b k |

k := self.

b := [ k := k - 1. k x1: b x2: x1 x3: x2 x4: x3 x5: x4 ].

^k <= 0 ifTrue: [ x4 value + x5 value ] ifFalse: b

Example: '10 manOrBoy' returns -67

CROSSREFS

Adjacent sequences: A132340 A132341 A132342 this_sequence A132344 A132345 A132346

Sequence in context: A108234 A091830 A029427 this_sequence A119346 A014586 A122924

KEYWORD

sign

AUTHOR

Paolo Bonzini (bonzini(AT)gnu.org), Nov 08 2007

page 1

Search completed in 0.002 seconds

Lookup | Welcome | Find friends | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
More pages | Superseeker | Maintained by N. J. A. Sloane (njas@research.att.com)

Last modified October 13 09:05 EDT 2008. Contains 145008 sequences.


AT&T Labs Research