Formatting in J

This is a discussion on Formatting in J within the APL forums in Programming Languages category; The formatting facilities in J appear to be very limited; there is no equivalent to APL2 picture format, and 8!:n seems to be a small subset of #FMT. In particular, 8!:n seems to be designed to format only numbers, with no provision for interspersing numbers with text. There seem to be no equivalents to the A, G<...>, and <...> (insert text) specifiers for #FMT, nor is there a Z qualifier for zero padding. I can display the time of day in a readable form by entering something like }.,'r<:00>3.0' (8!:2) <. _3{. 6!:0 '' but this wouldn't work for, say, ...

Go Back   Application Development Forum > Programming Languages > APL

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 12-16-2007, 05:01 PM
brian.b.mcguinness@lmco.com
Guest
 
Default Formatting in J

The formatting facilities in J appear to be very limited; there is no
equivalent to APL2 picture format,
and 8!:n seems to be a small subset of #FMT. In particular, 8!:n
seems to be designed to format only
numbers, with no provision for interspersing numbers with text. There
seem to be no equivalents to the
A, G<...>, and <...> (insert text) specifiers for #FMT, nor is there a
Z qualifier for zero padding.

I can display the time of day in a readable form by entering something
like
}.,'r<:00>3.0' (8!:2) <. _3{. 6!:0 ''
but this wouldn't work for, say, an angle in degrees, minutes, and
seconds since angles can be negative
and the negative sign would be inserted after the zero background
padding rather than before it.

I would like to see 8!:n beefed up to include more of the capabilities
of #FMT in order to simplify the
task of porting APL code to J.

--- Brian
Reply With Quote
  #2  
Old 12-17-2007, 11:56 AM
Gosi
Guest
 
Default Re: Formatting in J

On Dec 16, 10:01 pm, brian.b.mcguinn...@lmco.com wrote:
> The formatting facilities in J appear to be very limited; there is no
> equivalent to APL2 picture format,
> and 8!:n seems to be a small subset of #FMT. In particular, 8!:n
> seems to be designed to format only
> numbers, with no provision for interspersing numbers with text. There
> seem to be no equivalents to the
> A, G<...>, and <...> (insert text) specifiers for #FMT, nor is there a
> Z qualifier for zero padding.
>
> I can display the time of day in a readable form by entering something
> like}.,'r<:00>3.0' (8!:2) <. _3{. 6!:0 ''
>
> but this wouldn't work for, say, an angle in degrees, minutes, and
> seconds since angles can be negative
> and the negative sign would be inserted after the zero background
> padding rather than before it.
>
> I would like to see 8!:n beefed up to include more of the capabilities
> of #FMT in order to simplify the
> task of porting APL code to J.
>
> --- Brian


There are several utilities that do format.

As examples there are utilities in dates, format, printf that may be
of interest for you.
Examples of printf can be seen using the printf lab.

Verb datefmt may also be of interest to you.

It is helpful to use find in files and look for format in system

The dyadic ": in the dictionary may give you what you want
Reply With Quote
  #3  
Old 12-17-2007, 08:56 PM
cdburke@gmail.com
Guest
 
Default Re: Formatting in J

On Dec 17, 6:01 am, brian.b.mcguinn...@lmco.com wrote:
> The formatting facilities in J appear to be very limited; there is no
> equivalent to APL2 picture format,
> and 8!:n seems to be a small subset of #FMT. In particular, 8!:n
> seems to be designed to format only
> numbers, with no provision for interspersing numbers with text. There
> seem to be no equivalents to the
> A, G<...>, and <...> (insert text) specifiers for #FMT, nor is there a
> Z qualifier for zero padding.
>
> I can display the time of day in a readable form by entering something
> like}.,'r<:00>3.0' (8!:2) <. _3{. 6!:0 ''
>
> but this wouldn't work for, say, an angle in degrees, minutes, and
> seconds since angles can be negative
> and the negative sign would be inserted after the zero background
> padding rather than before it.
>
> I would like to see 8!:n beefed up to include more of the capabilities
> of #FMT in order to simplify the
> task of porting APL code to J.
>
> --- Brian


The 8!: family was modelled pretty closely on []fmt (see definition in
http://www.jsoftware.com/help/dictionary/dx008.htm ). It is a subset
in some respects, a superset in others.

I suggest that you post some examples of your requirements to the J
programming forum.

Chris
Reply With Quote
  #4  
Old 12-18-2007, 08:58 PM
brian.b.mcguinness@lmco.com
Guest
 
Default Re: Formatting in J

Thanks for the suggestions. I will look into these options.
It just surprises me that, given the frequency with which
people need to intermingle text and numbers in the output
from computer programs, and the support given for this in
many languages, that it is not supported by 8!:n in J.

--- Brian
Reply With Quote
  #5  
Old 12-18-2007, 10:13 PM
cdburke@gmail.com
Guest
 
Default Re: Formatting in J

On Dec 19, 9:58 am, brian.b.mcguinn...@lmco.com wrote:
> Thanks for the suggestions. I will look into these options.
> It just surprises me that, given the frequency with which
> people need to intermingle text and numbers in the output
> from computer programs, and the support given for this in
> many languages, that it is not supported by 8!:n in J.


Certainly you can mix text and numbers:

(8!:2) 123;' Main St. ';12345
123 Main St. 12345

It is hard to answer vague complaints - much better that you give
specific examples of what you want in the J programming forum.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 11:12 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.