[Jprogramming] Need better understanding of "from"
'robert therriault' via Programming
programming at jsoftware.com
Tue Apr 13 14:20:59 UTC 2021
Hi Harvey,
>> What I'm trying to do is to grab 2 letters at a time in sequence
>> through the 6-character combined planetary abbreviations for 3
>> planets. Is there another way?
I think what you want is dyadic \ (Infix https://code.jsoftware.com/wiki/Vocabulary/bslash#dyadic)
planets=. 'mevema'
_2 [\ planets NB. negative left operand means take n at a time without overlapping
me
ve
ma
2 [\ planets NB. positive left operand means take n at a time with overlapping and potential shards at the end
me
ev
ve
em
ma
you could put any monadic verb that you want in place of the [ (Same), often used with < (Box)
_2 <\ planets NB. boxes two at a time without overlapping
┌──┬──┬──┐
│me│ve│ma│
└──┴──┴──┘
Cheers, bob
> On Apr 13, 2021, at 03:16, 'Mike Day' via Programming <programming at jsoftware.com> wrote:
>
> My variant:
>
> j =. 1
> 'mevema' {~ 0 1 + +: j
> ve
>
> I use {~ quite often, possibly thanks to nostalgia for [i] !
>
> Mike
>
> Sent from my iPad
>
>> On 13 Apr 2021, at 09:14, HH PackRat <hhpackrat at gmail.com> wrote:
>>
>> Hello, all!
>>
>> I'm stumped and need to know why the following "from" problem occurs
>> and how to do what I'd like to do:
>>
>> No problem when numeric values are used:
>> val=. 0 1 { 'mevema'
>> me
>> val=. 2 3 { 'mevema'
>> ve
>>
>> Problem when formulas are used instead of numeric values:
>> j=. 0 [or 1 or 2]
>> val=. (2*j) (1+2*j) { 'mevema'
>> |syntax error
>> | val=. (2*j)(1+(2*j)){'mevema'
>>
>> Why does "from" work with numeric values but not with formulaic
>> versions of those same values for use inside a "for_j" loop to handle
>> multiple cases?
>>
>> What I'm trying to do is to grab 2 letters at a time in sequence
>> through the 6-character combined planetary abbreviations for 3
>> planets. Is there another way? (Explicit code only, please, if you
>> give any examples.)
>>
>> I just don't understand why one version works and the other doesn't.
>> Any help appreciated!
>>
>> Harvey
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list