I do.
^: either applies to y if v returns true, or returns y.
what I want is to stop application once v u y is true, and return the last u y.
The application is searching for a unique (or non existing) value across
multiple locations, but once it is found, stop looking.
I tried something with {. to feed locations one at a time, and then $:@:}. as
the keep looking instruction, but I may not understand $: well enough.
----- Original Message -----
From: R.E. Boss <[email protected]>
To: [email protected]
Cc:
Sent: Saturday, November 16, 2013 4:54:30 PM
Subject: Re: [Jprogramming] repeatuntil and repeat while tacit definitions
possible?
Are you aware of http://www.jsoftware.com/help/dictionary/d202v.htm ?
R.E. Boss
(Add your info to http://www.jsoftware.com/jwiki/Community/Demographics )
> -----Original Message-----
> From: [email protected] [mailto:programming-
> [email protected]] On Behalf Of Pascal Jasmin
> Sent: zaterdag 16 november 2013 21:32
> To: [email protected]
> Subject: [Jprogramming] repeatuntil and repeat while tacit definitions
> possible?
>
> 2 conjunctions with monad only versions shown for simplicity
>
> repeatuntil =: 2 : 'for_i. y do. if. v"_ s =. u i do. s break. end. end.'
>
> repeatwhile =: 2 : 0
> out =. i.0
> for_i. y do. if. v"_ s =. u i do. out break. else. out =. out , s end.
end.
> )
>
> +: repeatuntil (6 < ]) 2 1 3 2 4 5 2
> 8
> +: repeatwhile (6 < ]) 2 1 3 2 4 5 2
> 4 2 6 4
>
> both short circuit based on finding an exit condition. I'd be surprised
that a
> tacit version is possible, but maybe through scan '/' and ^: ?
>
> I understand that the example is silly overkill, but the main application
is for
> repeatuntil is searching in many locations sorted by the likelihood of
finding it
> in a location.
> ----------------------------------------------------------------------
> 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