Source =. 'a';'bcd';'e';'g'
    Target =. 'e';'a';'bcd';'f'
    getIndex =: i.~   NB. not e.
    shouldReturn =. 1 2 0 4  NB. 'not found' for i. is #x
    assert (Source getIndex Target)-:shouldReturn  NB. -: not =

Henry Rich

On 4/23/2012 7:13 AM, Joe Bohart wrote:
> Hi J'ers,
>
> I'm trying to write a verb that will
> match the items in Source with Target
> and return the index of items in Target
> such that they are in the same order as
> Source with nulls (or the J way of handling nulls)
> if no match is found.
>
> This is what i have (and it's wrong):
>
> Source =. 'a';'bcd';'e';'g'
> Target =. 'e';'a';'bcd';'f'
> getIndex =: e.
> shouldReturn =. 1 2 0 null
> assert (Source getIndex Target)=shouldReturn
>
> In the forums I've found solution candidates,but
> haven't been able to apply them and am a bit lost with:
> I.@:E. and ;:
>
> The concept of expressing null or missing data in J I haven't
> found much info on. Where can i find more information on nulls.
>
> Much Thanks -Joe
> ----------------------------------------------------------------------
> 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