Skip to content

Commit 3f05477

Browse files
committed
update jlibrary
1 parent 7e17672 commit 3f05477

File tree

2 files changed

+62
-21
lines changed

2 files changed

+62
-21
lines changed

jlibrary/addons/dev/eformat/eformat.ijs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ EVEMPTYT
7070
EVEMPTYDD
7171
)
7272

73-
NB.x is (1 if all of main name always needed),(max # characters allowed),(parenthesize w if compound); y is AR
73+
NB.x is (1 if all of main name always needed),(max # characters allowed),(par); y is AR
74+
NB. par is:0=no parens needed; 1=parens needed for train but not AC exec; parens needed for train and AC
7475
NB. result is string to display, or ... if string too long
7576
eflinAR_j_ =: {{
7677
NB. parse the AR, recursively
7778
if. y -: 0 0 do. '...' return. end. NB. If no room for formatting, stop looking
79+
posy =. 4!:0 <'y' NB. part of speech of y
7880
'frc max par' =. x
7981
aro =. >y
8082
if. 2 = 3!:0 aro do. NB. primitive or named entity
@@ -95,31 +97,31 @@ else.
9597
NB. these cases are not so important because they don't give verb-execution errors
9698
stgs=.0$a: NB. list of strings
9799
for_i. aro1 do.
98-
stg =. (0 ,~ 0., 0. >. max%(#aro1)-i_index) eflinAR i NB. collect strings for each AR
100+
stg =. ((i_index<<:#aro1) ,~ 0., 0. >. max%(#aro1)-i_index) eflinAR i NB. collect strings for each AR; paren trains except the right
99101
max =. max - #stg [ stgs =. stgs , <stg NB. don't allow total size to be exceeded
100102
end.
101103
NB. We have strings for each component. If nothing has a display, return '...' unless this is top-level
102104
if. (frc=0) *. *./ stgs = <'...' do. '...' return. end.
103-
(')' ,~ '('&,)^:par ;:^:_1 stgs return.
105+
(')' ,~ '('&,)^:(par~:0) ;:^:_1 stgs return.
104106
case. do. NB. default: executed A/C
105107
stgs =. <stg=. (0 >. (<:frc) , max , 1) eflinAR {. aro NB. get (stg) for AC
106-
stgs =. stgs ,~ <stg =. (0 >. 0 , 0 ,~ max =. max -#stg) eflinAR {. aro1
107-
if. 1 < #aro1 do. stgs =. stgs , <stg =. (0 >. 0 , 1 ,~ max =. max -#stg) eflinAR {: aro1 end.
108+
stgs =. stgs ,~ <stg =. (0 >. 0 , (posy{0 1 1 0) ,~ max =. max -#stg) eflinAR {. aro1
109+
if. 1 < #aro1 do. stgs =. stgs , <stg =. (0 >. 0 , (posy{0 0 2 0) ,~ max =. max -#stg) eflinAR {: aro1 end.
108110
if. (frc=0) *. *./ stgs = <'...' do. '...' return. end.
109111
NB. string not too long; leave spaces where needed (before letter, digit or inflection)
110112
NB. leading space needed before inflection always, or num/letter preceded by num/letter
111113
fpad =. i.&1@:(e.&>&('.:';'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'))"0 {.@> stgs
112114
NB. trailing space after num/letter
113115
bpad =. i.&1@:(e.&>&('.:';'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'))"0 {:@> stgs
114116
npad =. 0 (0}) 2 > fpad+|.!._1 bpad
115-
(')' ,~ '('&,)^:par ; npad ((' ' #~ [) , ])&.> stgs return.
117+
(')' ,~ '('&,)^:(par=2) ; npad ((' ' #~ [) , ])&.> stgs return.
116118
end.
117119
end.
118120
}}
119121

120122

121123
NB. y is AR of self
122-
NB. x is the IRS n from "n, if any (63 63 if no IRS)
124+
NB. x is the IRS n from "n, if any (63 63 if no IRS))
123125
NB. Result is string form, limited to 30 characters
124126
eflinearself_j_ =: {{
125127
'' eflinearself y

jlibrary/system/main/stdlib.ijs

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
18!:4 <'z'
22
3 : 0 ''
33

4-
JLIB=: '9.04.05'
4+
JLIB=: '9.04.06'
55

66
notdef=. 0: ~: 4!:0 @ <
77
hostpathsep=: ('/\'{~6=9!:12'')&(I. @ (e.&'/\')@] })
@@ -225,8 +225,8 @@ def=: :
225225
define=: : 0
226226
H=. '0123456789ABCDEF'
227227
h=. '0123456789abcdef'
228-
dfh=: 16 #. 16 | (H,h) i. ]
229-
hfd=: h {~ 16 #.^:_1 ]
228+
dfh=: (16 #. 16 | (H,h) i. ]) :.hfd
229+
hfd=: (h {~ 16 #.^:_1 ]) :.dfh
230230
4!:55 'H';'h'
231231
do=: ".
232232
drop=: }.
@@ -1423,6 +1423,11 @@ d=. ~: /\ a #^:_1 c ~: }: 0, c
14231423
}. (a >: d) # txt
14241424
)
14251425
dquote=: ('"'&,@(,&'"'))@ (#~ >:@(=&'"'))
1426+
dquotex=: 3 : 0
1427+
s=. y#~ >: m=. (=&'"') y
1428+
p=. (i.#y)#~>: m
1429+
('"'&,@(,&'"')) '\' (p i.(I.m))}s
1430+
)
14261431
dtbs=: 3 : 0
14271432
CRLF dtbs y
14281433
:
@@ -2892,8 +2897,9 @@ efindexaudit_j_ =: {{
28922897
($x),rs
28932898
}}
28942899

2895-
NB. y is a result from efindexaudit; x is $y
2900+
NB. y is a result from efindexaudit; x is $y; m is (printed string for x;printed string for y)
28962901
effrommsg_j_ =: {{
2902+
'xstg ystg'=. m
28972903
'rc aeo path'=. y
28982904
'axis excl off'=. aeo
28992905
axismsg=. ''
@@ -2903,15 +2909,15 @@ effrommsg_j_ =: {{
29032909
NB. generate a message like 'atom at position xx in exclusion list at position xx in ...
29042910
NB. match successive elements of path with successive elements of parts, and remove the elements referring to empty paths
29052911
parts=. ((1=#path) {:: ('index list';'index'));(excl {:: 'selector';'exclusion list');'atom'
2906-
pathmsg=. path (] , ((' at position ';''){::~0=#@[) , ":@[)&.> (parts {.~ #path)
2912+
pathmsg=. path (] , (1<#x) # ' at position ' ,^:(*@#@]) ":@[)&.> (parts {.~ #path)
29072913
pathmsg=. pathmsg #~ (0 1 0{.~#path) +. (0~:#)&>path NB.always print 'selector'/'exclusion list'; others are optional
2908-
if. #pathmsg do. pathmsg=. >([ , ' in ' , ])&.>/ |.pathmsg else. pathmsg=. 'x' end.
2914+
if. #pathmsg do. pathmsg=. >([ , ' in ' , ])&.>/ |.pathmsg else. pathmsg=. xstg end.
29092915
emsg=. ''
29102916
select. rc
29112917
case. _4 do. emsg=. pathmsg , ' contains too many exclusion lists (must have rank 0)'
29122918
case. _3 do. emsg=. pathmsg , ' is overly boxed'
29132919
case. _2 do. emsg=. pathmsg , ' must have rank 1'
2914-
case. _1 do. emsg=. pathmsg , ' is overlong; has length ' , (":off) , ' but y''s rank is only ' , ":#x
2920+
case. _1 do. emsg=. pathmsg , ' is overlong; has length ' , (":off) , ' but rank of ' , ystg , ' is only ' , ":#x
29152921
case. 1 do. emsg=. pathmsg , ' is not a number'
29162922
case. 2 do. emsg=. pathmsg , ' is ' , (":off) , '; not an integer'
29172923
case. 3 do. emsg=. pathmsg , ' is ' , (":off) , '; too long for ' , axismsg , 'y, whose length is only ' , ":axislen
@@ -3097,7 +3103,7 @@ case. 3 do.
30973103
fcase. ;:'o.' do.
30983104
if. e=EVDOMAIN do. if. #emsg=. 'x has '&,^:(*@#) a efindexmsg a 9!:23 (0;_12 12) do. hdr,emsg return. end. end.
30993105
case. ;:'=<<.<:>>.>:++.+:**.*:-%%:^^.~:|!"j.H.??.' do. NB. atomic dyads and u"v
3100-
NB. Primitive atomic verb. Check for agreement
3106+
NB. Primitive atomic verb.
31013107
if. e=EVDOMAIN do.
31023108
if. #emsg=. a efcknumericargs w do. hdr,emsg return. end.
31033109
if. prim e. ;:'??.' do.
@@ -3195,16 +3201,52 @@ case. 3 do.
31953201
end.
31963202
case. ;:'/./..' do.
31973203
if. e=EVLENGTH do. emsg =. 'shapes ' , (":$a) , ' and ' , (":$w) , ' have different numbers of items' end.
3198-
NB. { x domain and index
31993204
case. ;:'{' do.
3200-
if. e e. EVINDEX,EVLENGTH,EVDOMAIN do. if. L. rc=. a efindexaudit $w do. emsg=. ($w) effrommsg rc end. end.
3205+
if. e e. EVINDEX,EVLENGTH,EVDOMAIN do. if. L. rc=. a efindexaudit $w do. emsg=. ($w) ('x';'y') effrommsg rc end. end.
32013206
fcase. ;:'{.{:' do.
32023207
if. e=EVINHOMO do. hdr , 'y argument and fill are incompatible: ' , efandlist w efhomo@:(,&(*@(#@,) * 3!:0)) fill return. end.
32033208
case. ;:'}.}:' do.
32043209
if. e=EVLENGTH do. emsg=.'x has ' , ('atoms atom' efdispnsp #a) , ' but y has only ' , ('axes axis' efdispnsp #@$w)
32053210
elseif. e=EVDOMAIN do. emsg=. 'x has '&,^:(*@#) a efindexmsg a 9!:23 (2;0$0)
32063211
end.
3207-
NB. } xy homo ind domain (incl fill) and index x/ind agreement
3212+
case. ;:'}' do.
3213+
if. ism do. NB. If we didn't capture ind, we can do nothing
3214+
if. e=EVINHOMO do. if. 1 < #types =. a. -.~ a efhomo@:(,&(*@(#@,) * 3!:0)) w do. hdr,'arguments are incompatible: ' , efandlist types return. end. end.
3215+
NB. get the shape of the selected region (or index error)
3216+
selshape =. ''
3217+
if. 32 ~: 3!:0 ind do. NB. unboxed selectors
3218+
select. #$ind
3219+
case. 0;1 do.
3220+
selshape =. <ind efindexaudit $w
3221+
case. 2 do. NB. todo: scatter modify
3222+
if. e=EVDOMAIN do. if. #emsg=. efcknumericargs ind do. hdr,'m is ',emsg return. end. end.
3223+
if. e=EVLENGTH do. if. ({:$ind) > #@$w do. hdr,'the 1-cells of m have length ' , (":{:$ind) , ', but the rank of y is only ' , ":#@$w return. end. end.
3224+
if. e e. EVDOMAIN,EVINDEX do. if. #emsg=. 'm has '&,^:(*@#) ind efindexmsg ind 9!:23 (0;'') do. hdr,emsg return. end. end. NB. nonintegral index
3225+
if. e=EVINDEX do.
3226+
erow =. 1 i.~ ind +./@((< -) +. >:)"1 $w NB. row containing error
3227+
if. erow < #ind do.
3228+
ecol =. 1 i.~ (erow { ind) ((< -) +. >:) $w NB. column containing error
3229+
hdr,'position (' , (":erow,ecol) , ') of m has the value ' , (":(<erow,ecol) { ind) , ', but the length of axis ' , (":ecol) , ' of y is only ' , (":ecol{$w) return.
3230+
end.
3231+
end.
3232+
NB. selectors must be valid here
3233+
selshape =. <(#ind) , (#@$ind) }. $w NB. each row of ind selects a cell of w
3234+
case. do. if. e e. EVRANK,EVLENGTH do. hdr,'rank of selector must be < 3' return. end.
3235+
end.
3236+
else. NB. boxed selectors
3237+
selshape =. <@(efindexaudit&($w))"0 ind NB. one result per box
3238+
end.
3239+
if. e e. EVINDEX,EVLENGTH,EVDOMAIN do. NB. index-type error - see if any index box had an error
3240+
if. 1 (< L.) selshape do. NB. there is an index-type error
3241+
errbox =. 1 i.~ 0 ~: L.@> ,selshape
3242+
hdr,((1 < #@, selshape) # 'in box ' , (":errbox) , ' of m, ') , ($w) ('m';'y') effrommsg errbox {:: ,selshape return.
3243+
end.
3244+
end.
3245+
cellshapes =. ,selshape NB. all the selections
3246+
if. -. *./ (-:"_1 _ {.) cellshapes do. if. e=EVDOMAIN do. hdr,'the boxes of m must specify regions of the same shape' return. end. end.
3247+
cellshapes =. (# , }.@>@{.) cellshapes NB. shape of the selected region
3248+
if. -. ($a) ([ -: -@#@[ {.!._1 ]) cellshapes do. if. e=EVRANK do. hdr,'the shape of x (' , (":$a) ,') must be a suffix of the shape of the selection (' , (":cellshapes) , ')' return. end. end.
3249+
end.
32083250
NB. ". domain
32093251
case. ;:'b.' do.
32103252
if. e=EVDOMAIN do.
@@ -3303,7 +3345,6 @@ NB. most decoding omitted
33033345
case. do. hdr,'unknown x value' return.
33043346
end.
33053347
case. ;:'Z:' do.
3306-
NB. copy from monad p.
33073348
if. e=EVSYNTAX do. hdr,'fold is not running' return. end.
33083349
case. ;:'@.' do.
33093350
if. ism do. NB. the errors in @. must include the selectors
@@ -3369,8 +3410,6 @@ NB. } x domain
33693410
if. #emsg=. a efcknumericargs w do. hdr,emsg return. end.
33703411
if. #emsg=. a efindexmsg a 9!:23 (0;0) do. hdr,'y must be a nonnegative integer' return. end.
33713412
end.
3372-
NB. A. domain
3373-
NB. C. domain
33743413
case. ;:'A.C.' do.
33753414
if. e=EVINDEXDUP do. hdr , ('a permutation in ' #~ 1<*/}:$a) , 'y contains a duplicate value' return. end.
33763415
if. e e. EVDOMAIN,EVINDEX do.

0 commit comments

Comments
 (0)