Skip to content

Commit

Permalink
Performance improvement to depths function
Browse files Browse the repository at this point in the history
Provided by anaseto on aplfarm-k.matrix.org
  • Loading branch information
semperos committed Sep 6, 2024
1 parent ebd02b7 commit 555b9af
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ari.goal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
istbl:{and["d"=@x;&/"s"=@'!x;&/{(@'x)¿"ANSI"}x;&/(*ls)=ls:#'x]} / is x a dictionary-as-table
reshape:{((*/x)#y){(-y)$x}/|1_x} / Implementation by anaseto, shared on Matrix
shape:{-1_#:'*:\x} / Implementation by John Earnest, shared on k-tree
depths:{[l;ind] ,/(..?[(@x)¿"ANSI";p.o[x;p.ind+1];p.ind])'l} / list depths
depths:{[ind;l]?[(@l)~"A";,/o[ind+1]'l; (@l)¿"NSI";(#l)#ind; ind-1]} / list depths
md.tbl:{[t;fmt] / helper
k:!t; v:(..?[(@x)¿"nN";p.fmt$x;$'x])'.t; w:(-1+""#k)|(|/-1+""#)'v
(k;v):(-w)!'´(k;v); "|"+("|\n|"/,/"|"/(k;"-"*w;+v))+"|"}
Expand All @@ -10,8 +10,7 @@ md.lst:{[l;fmt] / helper
ind:..x*" "; pfx:(ind'ds)+"- "
"\n"/v;"\n"/pfx+v}
sprintf.md:{[x;fmt]?[istbl x;md.tbl[x;fmt]; (@x)¿"ANSI";md.lst[x;fmt]; "n"=@x;fmt$x; $x]} / String print to Markdown
ltx.lq:{sub[rq/ "/;" ``"]sub[rx/(?m)^"/;"``"]x} / helper
ltx.rq:{sub[rq/" /;"'' "]sub[rx/(?m)"$/;"''"]x} / helper
ltx.lq:{sub[rq/ "/;" ``"]sub[rx/(?m)^"/;"``"]x}; ltx.rq:{sub[rq/" /;"'' "]sub[rx/(?m)"$/;"''"]x} / helpers
ltx.tbl:{[t;fmt] / helper
algn:!"r l"; algns:""/algn["S"=@'t]
k:!t; v:(..?[(@x)¿"nN";p.fmt$x;$'x])'.t; w:(-1+""#k)|(|/-1+""#)'v
Expand Down

0 comments on commit 555b9af

Please sign in to comment.