Talk:Align columns: Difference between revisions

m
Line 54:
 
Given that:
# The <code>9!:2717</code> version confused even a veteran J user, and
# using these foreigns has side effects which would need to be reverted after the desired effect is acheived, further cluttering the solution, and
# using foreigns that control global formatting to acheive local formatting might be considered cute at best, and
# the task calls for "''allow[ing] each word in a column to be [aligned]''", which could imply the need to align words or columns independently, then
 
should we scrap our short (if cute) solution, and replace it with a longer, but more general solution? As a (possibly desirable) side-effect, a solution which eschewed the foreigns would be more comparable to others written in languages which lack a built-in formatting & alignment facility.
Line 88:
 
Example use:
colalign text NB. Default is left justificationalignment.
'C' colalign text NB. canCan bespecify changeda different alignment.
 
Or another candidate, such as:
colAlign =: 'L'&$: : (format@:align parse)
format =: [: > (,. ' '&,.)&.>/
align =: cols |."1&.>~ (<nowiki>''</nowiki>;1) <;.1 rotation
cols =: <@:>"1@:|:@:]
rotation =: (<.@*"1 2: %~ 'LCR'&i.)~ offset
Line 101:
 
Example of use:
colAlign text NB. Default is left justificationalignment.
'C' colAlign text NB. Can specify a different justificationalignment for all columns,
'RCLRCLRCLRCL' colAlign text NB. or for each column independently,
(6 12 (] {~ (?.@$ #)) 'LCR') colAlign text NB. or for each word independently.
 
Of course, we could include 2two solutions;: lead with the short one, finish with the general one. But that might be overkill.
 
--[[User:DanBron|DanBron]] 02:39, 3 December 2008 (UTC)
Anonymous user