Align columns: Difference between revisions

m (→‎{{header|Wren}}: Change of library method name.)
Line 5,486:
justified, right justified, or center justified within its column.
</pre>
 
=={{header|Phixmonti}}==
<lang Phixmonti>include ..\Utilitys.pmt
 
0 40 repeat var gap
 
( "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." )
 
len var lines
 
def alignWords /# -1/0/1 for left/center/right #/
>ps
lines for
get len for >ps
tps get gap ps> get nip 1 +
tps -1 == if -1 * align else
tps 0 == if tostr align else
tps 1 == if align else
drop drop "Wrong!" exitfor
endif endif endif
print
endfor
drop
nl
endfor
ps> drop
enddef
lines for var i
i get "$" " " subst split
len for var j
j get len dup
gap j get rot
< if swap j set else swap drop endif var gap drop
endfor
i set
endfor
 
-1 alignWords nl
0 alignWords nl
1 alignWords nl
drop</lang>
 
=={{header|PHP}}==
672

edits