I said not to try to shift the first element! That requires a
design decision. If you want to ignore leading shift requests, it's
easy enough:
shift =. 1 : '{~ (;@(<@(1&|.);.1) i.@#)@:(= *./\)@:u'
'lc uc' =. +&(i.26)&.(a.&i.)"0 'aA'
p =. e.&uc
p shift 'abcDEfghI'
abDEcfgIh
p shift 'AbC'
ACb
p shift 'XYZ'
XYZ
Henry Rich
On 8/9/2011 4:24 PM, R.E. Boss wrote:
>
> uc (]{~ [:+/(,:-.)@e.~((1<@|."1[)#^:_1&> (<@#i.@#))])'abcDEfghI'
> abDEcfgIh
>
> uc (]{~ [:+/(,:-.)@e.~((1<@|."1[)#^:_1&> (<@#i.@#))])'AbC'
> bAC
>
> uc (]{~ [:+/(,:-.)@e.~((1<@|."1[)#^:_1&> (<@#i.@#))])'XYZ'
> XYZ
>
> Failed Bantchev's second test also.
>
>
> R.E. Boss
>
>
>> -----Oorspronkelijk bericht-----
>> Van: [email protected] [mailto:programming-
>> [email protected]] Namens Boyko Bantchev
>> Verzonden: dinsdag 9 augustus 2011 21:39
>> Aan: Programming forum
>> Onderwerp: Re: [Jprogramming] Materials for NYCJUG meeting today -
>> Tuesday 8/9 at Empire State Building
>>
>> On 9 August 2011 21:11, Marshall Lochbaum<[email protected]>
>> wrote:
>>> Here's the selection option, which is equally ugly:
>>> ................
>>
>> ... and buggy :)
>>
>> shift 'AbC'
>> bCb
>>
>> shift 'XYZ'
>> |index error: shift
>>
>>
>> On 9 August 2011 22:15, Henry Rich<[email protected]> wrote:
>>> 'lc uc' =. +&(i.26)&.(a.&i.)"0 'aA'
>>> p =. e.&uc
>>> shift =. {~ (;@(<@(1&|.);.1) i.@#)@:-.@:p
>>
>> shift 'AbC'
>> Cb
>>
>> $ shift 'XYZ'
>> 0
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm