Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #50871

Re: Rosetta Code: Zig-zag matrix

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.forth
Subject Re: Rosetta Code: Zig-zag matrix
Date 2016-09-11 22:05 -0700
Organization A noiseless patient Spider
Message-ID <87oa3thfmd.fsf@jester.gateway.pace.com> (permalink)
References <nr558f$3l8$1@dont-email.me>

Show all headers | View raw


"WJ" <w_a_x_man@yahoo.com> writes:
>   0   1   5   6  14  15  27  28  44  45  65  66
>   2   4   7  13  16  26  29  43  46  64  67  88
>   3   8  12  17  25  30  42  47  63  68  87  89
>   9  11  18  24  31  41  48  62  69  86  90 107
>  10  19  23  32  40  49  61  70  85  91 106 108
>  20  22  33  39  50  60  71  84  92 105 109 122
>  21  34  38  51  59  72  83  93 104 110 121 123
>  35  37  52  58  73  82  94 103 111 120 124 133
>  36  53  57  74  81  95 102 112 119 125 132 134
>  54  56  75  80  96 101 113 118 126 131 135 140
>  55  76  79  97 100 114 117 127 130 136 139 141
>  77  78  98  99 115 116 128 129 137 138 142 143

12 constant n
n n  *  1- constant km
: t ( x y -- n ) + dup 1+ * 2/ ;
: reflect ( x y -- x y ) negate swap negate n 1- tuck + -rot + ;
: av ( x y -- n ) 2dup t -rot 2dup + 1 and if nip else drop then + ;
: bv ( x y -- n ) reflect av km  swap - ;
: v ( x y -- n ) 2dup + n >= if bv else av then ; 
: go cr n 0 do n 0 do i j v . loop cr loop ;

go 
0 1 5 6 14 15 27 28 44 45 65 66 
2 4 7 13 16 26 29 43 46 64 67 88 
3 8 12 17 25 30 42 47 63 68 87 89 
9 11 18 24 31 41 48 62 69 86 90 107 
10 19 23 32 40 49 61 70 85 91 106 108 
20 22 33 39 50 60 71 84 92 105 109 122 
21 34 38 51 59 72 83 93 104 110 121 123 
35 37 52 58 73 82 94 103 111 120 124 133 
36 53 57 74 81 95 102 112 119 125 132 134 
54 56 75 80 96 101 113 118 126 131 135 140 
55 76 79 97 100 114 117 127 130 136 139 141 
77 78 98 99 115 116 128 129 137 138 142 143 
 ok

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Rosetta Code: Zig-zag matrix "WJ" <w_a_x_man@yahoo.com> - 2016-09-12 02:52 +0000
  Re: Rosetta Code: Zig-zag matrix Paul Rubin <no.email@nospam.invalid> - 2016-09-11 22:05 -0700
    Re: Rosetta Code: Zig-zag matrix albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 13:50 +0200
      Re: Rosetta Code: Zig-zag matrix Paul Rubin <no.email@nospam.invalid> - 2016-09-12 13:12 -0700
        Re: Rosetta Code: Zig-zag matrix albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 22:38 +0200
          Re: Rosetta Code: Zig-zag matrix Paul Rubin <no.email@nospam.invalid> - 2016-09-12 14:15 -0700

csiph-web