Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
34
Task/Align-columns/SETL/align-columns.setl
Normal file
34
Task/Align-columns/SETL/align-columns.setl
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
program align;
|
||||
magic := false; $ turn off regexp matching in GNU SETL
|
||||
read_file;
|
||||
|
||||
ncols := max/[#line : line in lines];
|
||||
sizes := [1+max/[#(line(col) ? "") : line in lines] : col in [1..ncols]];
|
||||
|
||||
loop for line in lines do
|
||||
print(+/[align(line(col), sizes(col)) : col in [1..#line]]);
|
||||
end loop;
|
||||
|
||||
read_file::
|
||||
f := open(command_line(1), "r");
|
||||
lines := [];
|
||||
loop doing geta(f, line); while line /= om do
|
||||
lines with:= split(line, "$");
|
||||
end loop;
|
||||
close(f);
|
||||
|
||||
proc align(s, n);
|
||||
case command_line(2) of
|
||||
("r"): return lpad(s, n);
|
||||
("l"): return rpad(s, n);
|
||||
("c"): return center(s, n);
|
||||
end case;
|
||||
end proc;
|
||||
|
||||
proc center(s, n);
|
||||
padding := n - #s;
|
||||
l := " " * ceil(padding/2);
|
||||
r := " " * floor(padding/2);
|
||||
return l + s + r;
|
||||
end proc;
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue