Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/Align-columns/Lambdatalk/align-columns.lambdatalk
Normal file
38
Task/Align-columns/Lambdatalk/align-columns.lambdatalk
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{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.}
|
||||
-> txt
|
||||
{def columns // function's name
|
||||
|
||||
{def columns.r // loop function
|
||||
{lambda {:just :a :b}
|
||||
{if {A.empty? :a} // end of loop
|
||||
then :b // return the string
|
||||
else {columns.r :just // justification
|
||||
{A.rest :a}. // loop on next char
|
||||
{if {W.equal? {A.first :a} \} // if end of line
|
||||
then < tr> :b // open a table row
|
||||
else {if {W.equal? {A.first :a} $} // if space between words
|
||||
then < td style="text-align::just;">:b // open a table data with justif
|
||||
else {A.first :a}:b }} } }}} // else add character
|
||||
|
||||
{lambda {:just :txt} // main function
|
||||
{table // open an HTML table
|
||||
{columns.r // call the loop function
|
||||
:just // justification
|
||||
{A.reverse {A.split ${:txt}}} // split and reverse
|
||||
. // end point
|
||||
}}}}
|
||||
-> columns
|
||||
|
||||
|
||||
{columns left 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..
|
||||
|
||||
|
||||
|
||||
{columns center txt} and {columns right txt} outputs can be seen in this website: http://lambdaway.free.fr/lambdawalks/?view=align_columns
|
||||
Loading…
Add table
Add a link
Reference in a new issue