I didn't want to talk about it, but verb k depends on strings being
non-empty lists of characters, and the example you give can be fixed by
using the list ,'a' in place of the scalar 'a' :
k =: ( ([: +/ E.) > )"1 0
'bc' k 'ab';'bc';'bcd';'ad';'a'
|rank error: k
| 'bc' k'ab';'bc';'bcd';'ad';'a'
'bc' k 'ab';'bc';'bcd';'ad';,'a'
0 1 1 0 0
$ &.> 'ab';'bc';'bcd';'ad';'a'
+-+-+-+-++
|2|2|3|2||
+-+-+-+-++
$ &.> 'ab';'bc';'bcd';'ad';,'a'
+-+-+-+-+-+
|2|2|3|2|1|
+-+-+-+-+-+
$ &.> ;:'ab bc bcd ad a'
+-+-+-+-+-+
|2|2|3|2|1|
+-+-+-+-+-+
So using ;: is a good idea for not fussing with 'a' vs ,'a' .
On 11/12/2011 5:06 AM, Marc Simpson wrote:
> On Sat, Nov 12, 2011 at 2:13 AM, Kip Murray<[email protected]> wrote:
> Good stuff—but note that the following case is problematic,
>
> 'bc' k 'ab';'bc';'bcd';'ad';'a'
> |rank error: k
> | 'bc' k'ab';'bc';'bcd';'ad';'a'
>
> In other words, padding with fill characters is a trade-off: on the
> one hand incorrect results are yielded for whitespace tests, on the
> other there are no length restrictions (length>= #x) placed on the
> boxed strings.
>
> When it's possible to use ;: as in Raul's example, the domain
> restriction and whitespace issues are resolved,
>
> 'bc' k ;:'ab bc bcd ad a'
> 0 1 1 0 0
> ' ' k ;:'ab bc bcd ad a'
> 0 0 0 0 0
>
> -M
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm