Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Align-columns/TUSCRIPT/align-columns.tu
Normal file
22
Task/Align-columns/TUSCRIPT/align-columns.tu
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
$$ MODE TUSCRIPT
|
||||
MODE DATA
|
||||
$$ SET exampletext=*
|
||||
Given$a$text$file$of$many$lines,$where$fields$within$a$line$
|
||||
are$delineated$by$a$single$'dollar'$character,$write$a$program
|
||||
that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$
|
||||
column$are$separated$by$at$least$one$space.
|
||||
Further,$allow$for$each$word$in$a$column$to$be$either$left$
|
||||
justified,$right$justified,$or$center$justified$within$its$column.
|
||||
$$ MODE TUSCRIPT
|
||||
SET nix=SPLIT (exampletext,":$:",c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12)
|
||||
LOOP l1=1,12
|
||||
SET colum=CONCAT ("c",l1)
|
||||
SET newcolum=CONCAT ("new",l1)
|
||||
SET @newcolum="", length=MAX LENGTH (@colum), space=length+2
|
||||
LOOP n,l2=@colum
|
||||
SET newcell=CENTER (l2,space)
|
||||
SET @newcolum=APPEND (@newcolum,"~",newcell)
|
||||
ENDLOOP
|
||||
SET @newcolum=SPLIT (@newcolum,":~:")
|
||||
ENDLOOP
|
||||
SET exampletext=JOIN(new1,"$",new2,new3,new4,new5,new6,new7,new8,new9,new10,new11,new12)
|
||||
Loading…
Add table
Add a link
Reference in a new issue