In addition to the issue Henry Rich pointed out, I think it's a good
idea to avoid unnecessary boxing.
Also, it might be simpler to specify the fill when computing prefix
rather than when computing last.
(I am also inclined to discard unnecessary intermediate results. But I
am not going to give an example of that, here, because I don't have
enough context to decide on "necessary".)
These are all judgement calls, of course.
But, as an example, consider:
last=: {:&> words
prefix=: _3 {.!.' '&> last
(These both have one level less boxing than your original expressions.)
FYI,
--
Raul
On Wed, Aug 26, 2020 at 2:26 PM Paul Jackson <[email protected]> wrote:
>
> I was working on code analysis a couple of months ago, and thought
> about code display and which elements needed blanks around them.
> Without that side trip I might not have noticed that I was getting
> numbers instead of characters. The problem was easy to get around,
> just test for and ignore the empty lines, so I got on with my work and
> left a note to report it later.
>
> I originally saw the issue on Android 901, and have just confirmed it
> on Windows 902 beta, both 64-bit if that matters.
>
> NB. Cut into lines where / is like LF]lines=: <;._2 'NB. add them//x+y/'
>
> NB. add them x+y
>
> NB. Words in each element of lines]words=: ;:&.> lines
>
> NB. add them
> x + y
>
> NB. Get the last word in each line]last=: {:&.> words
>
> NB. add them
> y
>
> NB. Get first three characters of each]prefix=: 3{.&.> ;last
>
> NB. 0 0 0 y
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm