The problem here is that you told printf that you were giving it a
list of characters but did not do so.
printf
printf_jprintf_
printf_jprintf_
display@sprintf
a=:1+i.2 2
b=:6
'x%dx%sx%dx' sprintf b; (":a) ; b
x
6
x
1 2
3 4
x
6
x
$'x%dx%sx%dx' sprintf b; (":a) ; b
9 3
<"1 'x%dx%sx%dx' sprintf b; (":a) ; b
+---+---+---+---+---+---+---+---+---+
|x |6 |x |1 2|3 4|x |6 |x | |
+---+---+---+---+---+---+---+---+---+
In other words, J is treating each item in (":a) as a character, and
assembling a list of characters. But you did not supply a list of
characters.
I hope this makes sense,
--
Raul
On Mon, Aug 23, 2021 at 9:35 AM 'Rudolf Sykora' via Programming
<[email protected]> wrote:
>
> Dear list,
>
>
> I have been surprised by this:
>
> ---
> ]a=: _2 ]\ 1 2 3 4
> 1 2
> 3 4
> b=: 6
> 'x%d%d' printf b; b
> x66
> 'x%d%s%d' printf b; (":a) ; b
> x
> 6
>
> 1 2
> 3 4
>
> 6
>
> ---
>
> I do not understand who adds the newlines in the last case. I'd expect
> something like
> x61 2
> 3 46
> especially when
> 'x%d%s%d' printf b; ('abc',LF,'cd') ; b
> x6abc
> cd6
>
> I am aware that the shape of ('abc',LF,'cd') is just 6 while the
> shape of 'a' is 2 3, but is this supposed to result in the shown
> behaviour?
>
> Thanks for your hints.
>
>
> Ruda
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm