Pascal Jasmin writes:
But I'd like to see the first before I ask for another, and the approach
of
finding them all and then returning the first is not practical.
Arie Groeneveld writes:
{.@(}.^:(6>:{.)^:_@: +:) 2 1 3 2 4 5 2
8
Presumably "is not practical" because the verb v in the actual application
is expensive to compute (+: in the toy example). However, +: is computed
for each of the items of the argument. If that were the case then the
following lazy variation could help,
dh=. +:@:(0&({::)) 0} ]
({.@:((dh @: }.^:(6>:{.)^:_)) @: dh) :: ('None found'"_) 2 1 3 2 4 5 2
8
({.@:((dh @: }.^:(6>:{.)^:_)) @: dh) :: ('None found'"_) 2 1 3 2
None found
Extra code might also be necessary to avoid a potential premature
convergence. Furthermore, for many years I have thought that a direct
tacit support for this kind of situations would be welcome; I will
elaborate more on this subject soon.
On Sun, Nov 17, 2013 at 4:24 AM, Aai <[email protected]> wrote:
> $:@}.`{.@.(6<{.) +: 2 1 3 2 4 5 2
> 8
>
> much slower
>
> {.@(}.^:(6>:{.)^:_@: +:) 2 1 3 2 4 5 2
> 8
>
> But I prefer Raul's solution.
>
>
>
>
> On 17-11-13 03:38, Pascal Jasmin wrote:
>
>> I spent some time describing the application. You can also think of the
>> application as search every web page on every ipv4 until the first
>> interesting thing is found. Maybe I care about a 2nd interesting thing,
>> maybe I don't. But I'd like to see the first before I ask for another, and
>> the approach of finding them all and then returning the first is not
>> practical.
>>
>> The explicit version I provided is not unworkable. I was hoping that
>> there is a version with {. and $:@:}.
>>
>>
>> ----- Original Message -----
>> From: Raul Miller <[email protected]>
>> To: Programming forum <[email protected]>
>> Cc:
>> Sent: Saturday, November 16, 2013 8:56:03 PM
>> Subject: Re: [Jprogramming] repeatuntil and repeat while tacit
>> definitions possible?
>>
>> ({~ 1 i.~ 6 < ]) +: 2 1 3 2 4 5 2
>> 8
>> ({.~ 1 i.~ 6 < ]) +: 2 1 3 2 4 5 2
>> 4 2 6 4
>>
>> Now you might argue that this is not the same thing. But it is the same
>> result.
>>
>> It's just faster to compute this way. And, ok, I understand that speed
>> is not necessarily desirable. But I think in this case you might want
>> to just use a different language.
>>
>>
> --
> Met vriendelijke groet,
> @@i = Arie Groeneveld
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm