I added a %l feature to printf utility addons/format/printf.ijs
-:
typechars=: 'duoxXfeEgGsScjJ'
+:
typechars=: 'duoxXfeEgGsScjJl'
lr=: 3 : '5!:5 <''y'''
formatl=: lr : (2&{ ux_vy ((<. #) {. lr@]))
%l is similar to %j, but uses lr instead of ": for formatting. The most common
use case is to get quoted literals, but the full features/unpredictabilit of lr
(5!:5) comes with it.
'%j * %j text' printf 1 2 3;'a'
1 2 3 * a text
'%l * %l text' printf 1 2 3;'a'
1 2 3 * 'a' text
'%l * %l %l' sprintf 1 2 3;'a';< 1 2 3;3 4;'a'
1 2 3 * 'a' 1 2 3;3 4;'a'
'%l * %l %J' sprintf 1 2 3;'a';< 1 2 3;3 4;'a'
1 2 3 * 'a'
┌─────┬───┬─┐
│1 2 3│3 4│a│
└─────┴───┴─┘
I don't know the procedure for submitting code more formally. I don't know
printf that well, so I'm unsure if %l already had an uncommon use. Other than
that, it probably shouldn't break anything.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm