Artifact 411f3da9526e6a7db4719b6c69d20338240eae7ffdd6227951e603287ecdcaea:
- File joycogcl.joy — part of check-in [3bc956d5ca] at 2015-01-03 22:03:50 on branch origin/master — Bug/Typo fix - remove accidentally duplicated dup (user: base@atomicules.co.uk size: 1329)
0000: 28 2a 20 6a 6f 79 63 6f 67 63 6c 2e 6a 6f 79 20 (* joycogcl.joy 0010: 2a 29 0a 28 2a 20 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d *).(* ========== 0020: 3d 3d 20 2a 29 0a 0a 28 2a 20 41 20 63 6f 6d 6d == *)..(* A comm 0030: 61 6e 64 20 6c 69 6e 65 20 77 72 61 70 70 65 72 and line wrapper 0040: 20 66 6f 72 20 6a 6f 79 63 6f 67 2e 6a 6f 79 0a for joycog.joy. 0050: 20 20 20 0a 20 20 20 2d 20 59 6f 75 20 6d 61 79 . - You may 0060: 20 77 65 6c 6c 20 6e 65 65 64 20 74 6f 20 74 77 well need to tw 0070: 65 61 6b 20 74 68 65 20 70 61 74 68 20 62 65 6c eak the path bel 0080: 6f 77 20 74 6f 20 74 68 65 20 6a 6f 79 63 6f 67 ow to the joycog 0090: 2e 6a 6f 79 20 66 69 6c 65 0a 20 20 20 2d 20 45 .joy file. - E 00a0: 78 65 63 75 74 65 20 66 72 6f 6d 20 77 69 74 68 xecute from with 00b0: 69 6e 20 74 68 65 20 6a 6f 79 20 65 78 65 63 75 in the joy execu 00c0: 74 61 62 6c 65 20 64 69 72 65 63 74 6f 72 79 20 table directory 00d0: 28 73 6f 20 75 73 72 6c 69 62 2c 20 69 6e 69 6c (so usrlib, inil 00e0: 69 62 20 61 6e 64 20 61 67 67 6c 69 62 20 61 72 ib and agglib ar 00f0: 65 20 6c 6f 61 64 65 64 20 61 75 74 6f 6d 61 74 e loaded automat 0100: 69 63 61 6c 6c 79 29 0a 20 20 20 2d 20 43 61 6c ically). - Cal 0110: 6c 20 61 73 20 60 2e 2f 6a 6f 79 20 2f 70 61 74 l as `./joy /pat 0120: 68 2f 74 6f 2f 6a 6f 79 63 6f 67 63 6c 2e 6a 6f h/to/joycogcl.jo 0130: 79 20 33 34 20 35 30 20 31 32 20 31 33 20 31 35 y 34 50 12 13 15 0140: 20 31 37 20 31 39 20 32 31 20 32 33 20 32 36 60 17 19 21 23 26` 0150: 0a 20 20 20 20 20 49 2e 65 20 74 68 65 20 66 69 . I.e the fi 0160: 72 73 74 20 74 77 6f 20 61 72 67 75 6d 65 6e 74 rst two argument 0170: 73 20 61 72 65 20 74 68 65 20 66 72 6f 6e 74 20 s are the front 0180: 63 68 61 69 6e 72 69 6e 67 20 74 68 65 20 72 65 chainring the re 0190: 73 74 20 61 72 65 20 74 68 65 20 63 61 73 73 65 st are the casse 01a0: 74 74 65 0a 0a 2a 29 0a 0a 28 2a 20 47 65 74 20 tte..*)..(* Get 01b0: 48 4f 4d 45 20 64 69 72 65 63 74 6f 72 79 20 2a HOME directory * 01c0: 29 0a 0a 22 48 4f 4d 45 22 20 67 65 74 65 6e 76 ).."HOME" getenv 01d0: 20 0a 0a 28 2a 20 41 64 64 20 74 72 61 69 6c 69 ..(* Add traili 01e0: 6e 67 20 73 6c 61 73 68 20 2a 29 0a 0a 22 2f 22 ng slash *).."/" 01f0: 20 63 6f 6e 63 61 74 0a 0a 28 2a 20 50 61 74 68 concat..(* Path 0200: 20 72 65 6c 61 74 69 76 65 20 74 6f 20 48 4f 4d relative to HOM 0210: 45 20 74 6f 20 6a 6f 79 63 6f 67 20 66 69 6c 65 E to joycog file 0220: 20 2a 29 0a 0a 22 43 6f 64 65 2f 67 69 74 68 75 *).."Code/githu 0230: 62 2f 61 74 6f 6d 69 63 75 6c 65 73 2f 6a 6f 79 b/atomicules/joy 0240: 63 6f 67 2f 6a 6f 79 63 6f 67 2e 6a 6f 79 22 20 cog/joycog.joy" 0250: 0a 0a 28 2a 20 49 6e 63 6c 75 64 65 20 74 68 61 ..(* Include tha 0260: 74 20 66 69 6c 65 20 73 6f 20 63 61 6e 20 65 78 t file so can ex 0270: 65 63 75 74 65 20 6a 6f 79 63 6f 67 20 63 6f 6d ecute joycog com 0280: 6d 61 6e 64 20 2a 29 0a 0a 63 6f 6e 63 61 74 20 mand *)..concat 0290: 69 6e 63 6c 75 64 65 2e 0a 0a 28 2a 20 54 68 65 include...(* The 02a0: 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 first argument 02b0: 69 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 is the name of t 02c0: 68 65 20 66 69 6c 65 20 62 65 69 6e 67 20 65 78 he file being ex 02d0: 65 63 75 74 65 64 20 73 6f 20 64 72 6f 70 20 74 ecuted so drop t 02e0: 68 61 74 20 75 73 69 6e 67 20 60 72 65 73 74 60 hat using `rest` 02f0: 20 2a 29 0a 0a 61 72 67 76 20 72 65 73 74 20 0a *)..argv rest . 0300: 0a 28 2a 20 4d 61 6b 65 20 61 20 63 6f 70 79 20 .(* Make a copy 0310: 6f 66 20 69 74 20 2a 29 0a 0a 64 75 70 0a 0a 28 of it *)..dup..( 0320: 2a 20 57 6f 72 6b 69 6e 67 20 6f 6e 20 74 68 65 * Working on the 0330: 20 63 6f 70 79 2c 20 61 73 73 75 6d 65 20 6e 65 copy, assume ne 0340: 78 74 20 74 77 6f 20 61 72 67 75 6d 65 6e 74 73 xt two arguments 0350: 20 61 72 65 20 66 6f 72 20 74 68 65 20 66 72 6f are for the fro 0360: 6e 74 20 63 68 61 69 6e 72 69 6e 67 20 2a 29 0a nt chainring *). 0370: 0a 32 20 74 61 6b 65 20 0a 0a 28 2a 20 53 77 61 .2 take ..(* Swa 0380: 70 20 74 68 65 20 73 74 61 63 6b 20 74 6f 20 77 p the stack to w 0390: 6f 72 6b 20 6f 6e 20 72 65 73 74 20 6f 66 20 61 ork on rest of a 03a0: 72 67 73 20 61 67 61 69 6e 20 2a 29 0a 0a 73 77 rgs again *)..sw 03b0: 61 70 0a 0a 28 2a 20 54 68 65 20 72 65 73 74 20 ap..(* The rest 03c0: 61 72 65 20 66 6f 72 20 74 68 65 20 63 61 73 73 are for the cass 03d0: 65 74 74 65 20 2a 29 0a 0a 32 20 64 72 6f 70 0a ette *)..2 drop. 03e0: 0a 28 2a 20 42 75 74 20 65 76 65 72 79 74 68 69 .(* But everythi 03f0: 6e 67 20 77 69 6c 6c 20 62 65 20 73 74 72 69 6e ng will be strin 0400: 67 73 20 73 6f 20 6e 65 65 64 20 74 6f 20 63 6f gs so need to co 0410: 6e 76 65 72 74 20 74 6f 20 69 6e 74 65 67 65 72 nvert to integer 0420: 73 20 2a 29 0a 0a 5b 30 20 73 74 72 74 6f 6c 5d s *)..[0 strtol] 0430: 20 6d 61 70 0a 0a 28 2a 20 53 77 61 70 20 73 74 map..(* Swap st 0440: 61 63 6b 20 61 67 61 69 6e 20 74 6f 20 63 6f 6e ack again to con 0450: 76 65 72 74 20 6f 74 68 65 72 20 61 67 67 72 65 vert other aggre 0460: 67 61 74 65 20 74 6f 20 69 6e 74 65 67 65 72 73 gate to integers 0470: 20 2a 29 0a 0a 73 77 61 70 20 0a 0a 5b 30 20 73 *)..swap ..[0 s 0480: 74 72 74 6f 6c 5d 20 6d 61 70 0a 0a 28 2a 20 53 trtol] map..(* S 0490: 77 61 70 20 73 74 61 63 6b 20 62 61 63 6b 20 74 wap stack back t 04a0: 68 65 20 72 65 71 75 69 72 65 64 20 77 61 79 20 he required way 04b0: 2a 29 0a 0a 73 77 61 70 0a 0a 28 2a 20 43 61 6c *)..swap..(* Cal 04c0: 6c 20 74 68 65 20 61 63 74 75 61 6c 20 72 6f 75 l the actual rou 04d0: 74 69 6e 65 20 2a 29 0a 0a 6a 6f 79 63 6f 67 0a tine *)..joycog. 04e0: 0a 28 2a 20 41 6e 64 20 70 72 69 6e 74 20 74 68 .(* And print th 04f0: 65 20 72 65 73 75 6c 74 73 20 6f 75 74 20 2a 29 e results out *) 0500: 0a 0a 70 75 74 2e 0a 0a 28 2a 20 50 72 69 6e 74 ..put...(* Print 0510: 20 61 20 62 6c 61 6e 6b 20 6c 69 6e 65 20 2a 29 a blank line *) 0520: 0a 0a 22 5c 6e 22 20 70 75 74 63 68 61 72 73 2e .."\n" putchars. 0530: 0a .