Align columns: Difference between revisions

Content added Content deleted
(Lambdatalk's first add in "Align columns" by Alain Marty)
Line 3,970: Line 3,970:
=={{header|Lambdatalk}}==
=={{header|Lambdatalk}}==


The input data is a sequence of characters where words are supposed to be separated by $ and lines be ended by $\. A HTML table is used to format the output left, centered or right justified.
The input data is a sequence of characters where words are supposed to be separated by $ and lines be ended by \$. A HTML table is used to format the output left, centered or right justified.


<lang scheme>
<lang scheme>
{def txt
{def txt
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.}
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.}
-> txt
-> txt
{def columns // function's name
{def columns // function's name
Line 4,001: Line 4,001:


{columns left txt}
{columns left txt}
-> Given a text file of many lines, where fields within a line
-> are that column Further, justified,
are delineated by a single 'dollar' character, write a program
Given a text file of many lines, where fields within a line
that aligns each column of fields by ensuring that words in each
delineated by a single 'dollar' character, write a program
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
are separated by at least one space.
justified, right justified, or center justified within its column..
allow for each word in a column to be either left

right justified, or center justified within its column..



{columns center txt} and {columns right txt} outputs can be seen in this website: http://lambdaway.free.fr/lambdawalks/?view=align_columns
{columns center txt} and {columns right txt} outputs can be seen in this website: http://lambdaway.free.fr/lambdawalks/?view=align_columns