Align columns: Difference between revisions
Content added Content deleted
(Lambdatalk's first add in "Align columns" by Alain Marty) |
m (→{{header|Lambdatalk}}: fixed a bug) |
||
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 |
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 |
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} |
||
⚫ | |||
-> are that column Further, justified, |
|||
⚫ | |||
⚫ | |||
that aligns each column of fields by ensuring that words in each |
|||
⚫ | |||
column are separated by at least one space. |
|||
⚫ | |||
are separated by at least one space. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
{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 |