Jump to content

Talk:Align columns: Difference between revisions

(→‎J solution: intentional data.)
Line 1:
== J solution ==
 
I haven't read the J solution in depth yet, but it appears more complex than may be necessary. For example, with <tt>'LEFT CENTER RIGHT'=:i.23</tt> we can solve the task thus:
 
(#~ 0 1 $~ #) (9!:17 CENTER #~ 2 [ 9!:7 ' '$~11) (]":) 4 :'<;._2&.(,&x)y'S:0 /'$';LF;text
Given a text file of many lines, where fields within a line
are delineated by a single 'dollar' character, write a
that aligns each column of fields by ensuring that words in each
column are separated by at least one
Further, allow for each word in a column to be either left
justified, right justified, or center justified within its
 
(#~ 0 1 $~ #) (9!:17 CENTER #~ 2 [ 9!:7 ' '$~11) (]":) 4 :'<;._2&.(@:,~&x)y'S:0> /'$';LF;text
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.
Replacing <tt>CENTER</tt> with <tt>LEFT</tt> or <tt>RIGHT</tt> to taste.
 
Line 20:
 
:: I have added a note to clarify that this aspect of the data is intentional. --[[User:Paddy3118|Paddy3118]] 03:52, 2 December 2008 (UTC)
 
::: Fixed. --[[User:DanBron|DanBron]] 12:38, 2 December 2008 (UTC)
 
== Output Question ==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.