Thanks Julian,

Unfortunately Fold doesn’t seem to have made it to the iOS platform yet. 

5 f0 i.4
not found: 
/private/var/mobile/Containers/Data/Application/84605E1E-B9BA-4FE7-8FFA-1C6C5C0A29E0/Documents/j/addons/dev/fold/foldr.ijs
|nonce error: f0
|   0 x&{{y[1 Z: y > x}}    F..+y
   load 'foldr'
not found: 
/private/var/mobile/Containers/Data/Application/84605E1E-B9BA-4FE7-8FFA-1C6C5C0A29E0/




As a matter of interest what did people use for this facility before F. was 
invented?

Richard Donovan




> On 28 Feb 2022, at 18:49, Julian Fondren <jfond...@minimaltype.com> wrote:
> 
> You can use Fold and the related Z: (Terminate Fold)
> 
>   0 {{ y[1 Z: y > 10 }} F.. + 1 5 6 16
> 12
>   0 {{ y[1 Z: y > 10 }} F:. + 1 5 6 16
> 1 6 12
> 
> analogous to +/ and +/\ with the argument shortened to where the sum exceeds 
> 10:
> 
>   +/1 5 6
> 12
>   +/\1 5 6
> 1 6 12
> 
> as a verb:
> 
>   f0 =: {{ 0 x&{{ y[1 Z: y > x }} F.. + y }}
>   10 f0 1 5 6 16
> 12
>   5 f0 1 5 6 16
> 6
>   100 f0 1 5 6 16
> 28
> 
> ------- Original Message -------
> 
>> On Monday, February 28th, 2022 at 12:40 PM, Richard Donovan 
>> <rsdono...@hotmail.com> wrote:
>> 
>> I hope someone can enlighten me…
>> 
>> If I have a list of numbers, how can I write a verb which will can perform a 
>> cumulative sum +/\ which will stop when a target sum is reached?
>> 
>> For example, is the list contains 1,5,6,16… I wish to find at what position 
>> the cumulative sum exceeds 10. I feel that when I am dealing with monster 
>> lists, it would be beneficial if the function could stop as soon as the 
>> target had been reached. (If the target was not reached by the end of the 
>> list, it would be good if the index of 1 greater than the last item could be 
>> returned, as occurs with other j verbs).
>> 
>> Thanks in advance,
>> 
>> Richard Donovan
>> 
>> ----------------------------------------------------------------------
>> 
>> 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

Reply via email to