× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 2019-05-02 7:22 PM, Roger Harman wrote:
AFAIK, %lookup() does a linear search.

I assume you mean a binary search for the %lookupXX() functions *only*.

From the RPGLE Reference: "Since a binary search is used by the %LOOKUPxx built-in functions..."


%lookup does a binary search too, if the array is sequenced. "%lookupXX" includes the plain %lookup().

Test: This program displays 0 (when the array is not sorted) then 22 (when it is sorted).

dcl-ds ds;
arr char(1) dim(26) ascend;
end-ds;
dcl-s p int(10);
ds = 'zyxwvutsrqponmlkjihgfedcba';
dsply ( %lookup('v' : arr));
sorta arr;
dsply ( %lookup('v' : arr));
return;

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.