comparison test/g13x.ijs @ 0:e0bbaa717f41 draft default tip

lol J
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Mon, 25 Nov 2013 11:56:30 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e0bbaa717f41
1 NB. 13!: ----------------------------------------------------------------
2
3 13!:0 [1
4
5 foo =: foo_loc1_
6 foo_loc1_ =: foo_loc2_ /
7 foo_loc2_ =: foo_loc3_ ~
8 foo_loc3_ =: +
9
10 commute =: ~
11
12 goo =: 4 : 0
13 p=.2*x
14 q=.p goo1 commute y
15 q*q
16 )
17
18 goo1 =: goo2
19 goo2 =: goo3
20 goo3 =: +
21
22 fac =: 3 : 0
23 if. 2>y do. 1
24 elseif. 2=y do. %'abc'
25 elseif. 1 do. y*fac y-1
26 end.
27 )
28
29 conj =: 2 : 0
30 if. 1=x do. y=.*:@y else. y=.%:@y end.
31 %glob
32 y/
33 )
34
35 h =: 3 : 'y h1 2'
36 h1 =: 4 : 'x+y'
37
38 f1 =: 3 : '+/'
39 f2 =: 3 : '('
40
41 13!:0 [1
42 'domain error' -: (3 : '%y' ) etx 'asdf'
43 'domain error' -: % (1 : 'u y') etx 'asdf'
44 13!:0 [0
45
46 f =: % 1 : 'u y'
47 'domain error' -: f etx 'asdf'
48
49 f=: 3 : 'try. 13!:8 y catch. 13!:11 $0 end.'
50
51 254 -: f 254
52 255 -: f 255
53 10 -: f 256
54
55 13!:8 :: 1: x=: ?256
56 x -: 13!:11 ''
57
58 'length error' -: 13!:11 etx 'junkfoo'
59 'length error' -: 13!:12 etx 'junkfoo'
60
61
62 NB. stops ---------------------------------------------------------------
63
64 '' -: 13!:2 ''
65 1 [ 13!:3 'sum *'
66 'sum *' -: 13!:2 ''
67 1 [ 13!:3 ''
68
69
70 NB. error text ----------------------------------------------------------
71
72 sum=: +/
73 f=: 3 : '2 3+g y'
74 g=: 3 : 'if. y do. y else. + end.'
75 h=: 2 3&+@sum
76
77 'value error: junkfoo' -: fex 'junkfoo'
78
79 'length error: fex' -: fex '2 3+4 5 6'
80 'domain error: fex' -: fex '+/1;2 3'
81 'domain error: sum' -: fex 'sum ''asdf'''
82 'syntax error: g' -: fex 'f 0'
83 'length error: f' -: fex 'f 2 3 4'
84 'domain error: sum' -: fex 'h ''asdf'''
85 'length error: h' -: fex 'h i.3 4'
86
87 'length error: fex' -: fex '2 3+4 5 6'
88
89 f=: 3 : 0
90 abc=. 'abc'
91 ". :: 0: 'abc,',y
92 13!:12 ''
93 )
94
95 ' ...' -: _4{. }: f 204 $'123 '
96 ' ...' -: _4{. }: f 204 $'1.3 '
97 ' ...' -: _4{. }: f 204 $'1j3 '
98 ' ...' -: _4{. }: f 221 $(16$'123'),'x '
99 ' ...' -: _4{. }: f 221 $' 1r',14$'1123'
100
101 18!:55 ;:'loc1 loc2 loc3'
102
103
104 NB. 13!:13 -------------------------------------------------------------
105
106 mean=: sum % #
107 sum =: [: +/ ".@('t=:13!:13 $0'&[) ] ]
108
109 13!:0 ]1
110 1: mean x=: ?4 5$100
111
112 ($t) -: 2 9
113 (0{"1 t) -: 'sum';'mean' NB. name
114 (1{"1 t) -: 0;0 NB. error number
115 (2{"1 t) -: 0;0 NB. line number
116 (3{"1 t) -: 3;3 NB. name class
117 ((<1 4){t) -: <'sum % #' NB. definition
118 (_8{.&.>5{"1 t) -: 2$<'g13x.ijs' NB. defining scripts
119 (6{"1 t) -: (<,<x),<,<x NB. boxed argument(s)
120 (7{"1 t) -: 2$<0 2$0 NB. locals
121 (8{"1 t) e. ' ';'*' NB. * if begins suspension
122
123 1: mean"1 x
124
125 ($t) -: 2 9
126 (0{"1 t) -: 'sum';'mean' NB. name
127 (1{"1 t) -: 0;0 NB. error number
128 (2{"1 t) -: 0;0 NB. line number
129 (3{"1 t) -: 3;3 NB. name class
130 ((<1 4){t) -: <'sum % #' NB. definition
131 (_8{.&.>5{"1 t) -: 2$<'g13x.ijs' NB. defining scripts
132 (6{"1 t) -: (<,<{:x),<,<{:x NB. boxed argument(s)
133 (7{"1 t) -: 2$<0 2$a: NB. locals
134 (8{"1 t) e. ' ';'*' NB. * if begins suspension
135
136 sum=: 3 : ('z=.+/y';'t=: 13!:13 $0';'z')
137
138 1: mean"1 x
139
140 ($t) -: 2 9
141 (0{"1 t) -: 'sum';'mean' NB. name
142 (1{"1 t) -: 0;0 NB. error number
143 (2{"1 t) -: 1;0 NB. line number
144 (3{"1 t) -: 3;3 NB. name class
145 ((<1 4){t) -: <'sum % #' NB. definition
146 (_8{.&.>5{"1 t) -: 2$<'g13x.ijs' NB. defining scripts
147 (6{"1 t) -: (<,<{:x),<,<{:x NB. boxed argument(s)
148 NB. (7{"1 t) -: (('y.';{:x),:(,'z');+/{:x);<0 2$a: NB. locals
149 (>(<0 7){t) e. ('y.';{:x), ((,'y');{:x),:(,'z');+/{:x NB. locals
150 (8{"1 t) e. ' ';'*' NB. * if begins suspension
151
152 13!:0 ]0
153
154
155 NB. 13!:18 -------------------------------------------------------------
156
157 mean=: sum % #
158 sum=: 3 : ('z=.+/y';'t=: 13!:18 $0';'z')
159
160 13!:0 ]1
161 1: mean i.12
162 NB. (2{.t) -: (2,{:$t){.];.1 '|sum[1]|mean[0] !'
163
164 13!:0 ]0
165
166
167 4!:55 ;:'commute conj f f1 f2 fac foo '
168 4!:55 ;:'g goo goo1 goo2 goo3 h h1 mean sum t x '
169
170