Hex Artifact Content
Not logged in

Artifact 4af3c4ccb9eff42b8e5d305f3119010df30cfa68:


0000: 23 20 49 27 6d 20 6c 61 7a 79 2e 20 53 6f 20 49  # I'm lazy. So I
0010: 20 64 65 66 69 6e 65 20 6f 6e 6c 79 20 74 68 65   define only the
0020: 20 70 72 69 6d 69 74 69 76 65 73 20 6e 65 65 64   primitives need
0030: 65 64 20 66 6f 72 20 74 61 72 61 69 2e 0a 40 40  ed for tarai..@@
0040: 6c 61 7a 79 28 78 29 20 7b 20 66 75 6e 28 29 7b  lazy(x) { fun(){
0050: 78 7d 20 7d 3b 0a 40 6c 61 7a 79 20 2d 20 28 78  x} };.@lazy - (x
0060: 2c 79 29 20 7b 20 66 75 6e 28 29 7b 40 76 61 6c  ,y) { fun(){@val
0070: 75 65 28 40 6c 61 7a 79 28 78 29 28 29 20 2d 20  ue(@lazy(x)() - 
0080: 40 6c 61 7a 79 28 79 29 28 29 29 20 7d 20 7d 3b  @lazy(y)()) } };
0090: 0a 40 6c 61 7a 79 20 3c 3d 20 28 78 2c 79 29 20  .@lazy <= (x,y) 
00a0: 7b 20 66 75 6e 28 29 7b 40 76 61 6c 75 65 28 40  { fun(){@value(@
00b0: 6c 61 7a 79 28 78 29 28 29 20 3c 3d 20 40 6c 61  lazy(x)() <= @la
00c0: 7a 79 28 79 29 28 29 29 20 7d 20 7d 3b 0a 40 6c  zy(y)()) } };.@l
00d0: 61 7a 79 20 69 66 20 28 63 2c 74 2c 65 29 20 7b  azy if (c,t,e) {
00e0: 20 66 75 6e 28 29 7b 40 76 61 6c 75 65 28 69 66   fun(){@value(if
00f0: 20 40 6c 61 7a 79 28 63 29 28 29 20 74 68 65 6e   @lazy(c)() then
0100: 20 40 6c 61 7a 79 28 74 28 29 29 28 29 20 65 6c   @lazy(t())() el
0110: 73 65 20 40 6c 61 7a 79 28 65 28 29 29 28 29 29  se @lazy(e())())
0120: 20 7d 20 7d 3b 0a 0a 64 65 66 20 74 61 72 61 69   } };..def tarai
0130: 28 78 2c 79 2c 7a 29 0a 7b 0a 09 69 66 20 78 3c  (x,y,z).{..if x<
0140: 3d 79 20 74 68 65 6e 0a 09 09 79 0a 09 65 6c 73  =y then...y..els
0150: 65 0a 09 09 74 61 72 61 69 28 20 74 61 72 61 69  e...tarai( tarai
0160: 28 78 2d 31 2c 79 2c 7a 29 2c 20 74 61 72 61 69  (x-1,y,z), tarai
0170: 28 79 2d 31 2c 7a 2c 78 29 2c 20 74 61 72 61 69  (y-1,z,x), tarai
0180: 28 7a 2d 31 2c 78 2c 79 29 20 29 0a 7d 3b 0a 0a  (z-1,x,y) ).};..
0190: 23 20 70 72 69 6e 74 28 20 74 61 72 61 69 28 31  # print( tarai(1
01a0: 32 2c 20 36 2c 20 30 29 20 29 3b 0a 70 72 69 6e  2, 6, 0) );.prin
01b0: 74 28 20 40 6c 61 7a 79 28 20 74 61 72 61 69 28  t( @lazy( tarai(
01c0: 31 32 2c 20 36 2c 20 30 29 20 29 28 29 20 29 3b  12, 6, 0) )() );
01d0: 0a 0a 0a 23 23 23 23 20 4f 6d 61 6b 65 3a 20 6f  ...#### Omake: o
01e0: 6e 6c 79 20 5a 20 69 73 20 6d 61 64 65 20 6c 61  nly Z is made la
01f0: 7a 79 2e 0a 64 65 66 20 74 61 72 61 69 5a 28 78  zy..def taraiZ(x
0200: 2c 79 2c 7a 20 40 6c 61 7a 79 29 0a 7b 0a 09 69  ,y,z @lazy).{..i
0210: 66 20 78 3c 3d 79 20 74 68 65 6e 0a 09 09 79 0a  f x<=y then...y.
0220: 09 65 6c 73 65 0a 09 09 74 61 72 61 69 5a 28 20  .else...taraiZ( 
0230: 74 61 72 61 69 5a 28 78 2d 31 2c 79 2c 7a 29 2c  taraiZ(x-1,y,z),
0240: 20 74 61 72 61 69 5a 28 79 2d 31 2c 40 6c 61 7a   taraiZ(y-1,@laz
0250: 79 28 7a 29 28 29 2c 78 29 2c 20 74 61 72 61 69  y(z)(),x), tarai
0260: 5a 28 40 6c 61 7a 79 28 7a 29 28 29 2d 31 2c 78  Z(@lazy(z)()-1,x
0270: 2c 79 29 20 29 0a 7d 3b 0a 70 72 69 6e 74 28 20  ,y) ).};.print( 
0280: 74 61 72 61 69 5a 28 31 32 2c 36 2c 30 29 20 29  taraiZ(12,6,0) )
0290: 3b 0a                                            ;.