On 10/11/07, metaperl.j <[EMAIL PROTECTED]> wrote:
> Does J have a mode in which data is represented in a way that can be parsed
> back in to recreate the data?
>
> For example, the atom 56 and the vector 1 $ 67 have the same printed
> representation in the default J console.
>
> Is there some mode that would distinguish the printed representations of
> these two? Perhaps even something extremely verbose and SGML-ish would be
> nice
J supports several such mechanisms.
For example:
name=:(5!:1 <'name')5!:0
results in no change for name for any defined name -- noun, verb, adverb
or conjunction. (However, if name is a local name, this will fail because
you can't use =: on local names).
The advantage of 5!:0 is that you can use it in the middle of an arbitrary
expression.
You get the same basic effect from
0!:100'name=:',5!:5<'name'
and
0!:100'name=:',5!:6<'name'
This is probably what you are asking for, as 5!:5 produces a fairly readable
list of characters (5!:5 and 5!:6 are slightly different for complex
tacit verbs:
5!:6 introduces some extra parenthesis which show some of the tacit
structure.)
That said, if you are only concerned with nouns, note that
3!:2 (3!:1) name
and
3!:2 (3!:3) name
both produce the same noun value as was contained in name. The
advantage here is that name can be replaced by an arbitrary expression:
3!:2(3!:1)i.2 2
0 1
2 3
Note also that you can use either bigendian or littleendian representation
and you can use 32 bit or 64 bit representation (as long as the data fits).
In other words, the following all produce the same result:
(3!:2) 0(3!:1)i.2 2
(3!:2) 1(3!:1)i.2 2
(3!:2) 2(3!:1)i.2 2
(3!:2) 3(3!:1)i.2 2
(3!:2) 0(3!:3)i.2 2
(3!:2) 1(3!:3)i.2 2
(3!:2) 2(3!:3)i.2 2
(3!:2) 3(3!:3)i.2 2
I sometimes find 3!:3 useful when I am trying to understand the low
level details of floating point operations.
And, of course, nothing prevents you from designing and implementing
your own system, should you have requirements not met by any of
these approaches.
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm