Search

Filter

  • Advanced Filters:

  • to
  • Specific Data Sources:

    All Edit

    Select All  |  Select None

Reset filters

Original definition Z~L~R Z~LtR Z~v/Lo.:,R Z~DIO++/A\Ro.~L Modern definition Z~v/Lo.~,R Z~DIO++/AX~Ro.~L .... i il --by Roy A. Sykes, Jr. Los Angeles, California With this issue of APL Quote Quad, we begin a series of tutorials on various aspects of APL. Each issue will explore an algorithm or primitive, with the intention of giving readers both a practical introduction and some advanced techniques. We will assume the reader is familiar with IBM's APL2, which has become the de facto standard for second generation implementations of APL. Some of these articles were published previously in the now-defunct APL MarketNews as "APL Algorithmia." AUTHOR'S NOTE: Both definitions are equivalent for simple arrays, obviating the need to change existing APL programs. The extended definition of membership is such that expressions using match each ( L - " R ) or outer product match ( L o . =R) when either argument is a scalar can be replaced by membership with a scalar right argument, often speeding execution: (c'WlT') ~'" 'WHIT' OiO0 'WIT' 'OUTWIT' 'TWIT' 'WHI2' 'WIT' 'OUTWIT' 'TWIT' ~'" c'WIT' 'WHIT' 'WIT' 'OUTWIT' 'TWIT' ¢ c'WIT' Got a match? ODERN APL SYSTEMS have, since the mid-198o's , offered a primitive dyadic function called "match" (Z~-L-zR). Match does what novice APL users often wish the equal primitive did: it compares all aspects of its two arguments and returns a scalar 1 if they are identical, 0 otherwise. Although usually associated with nested arrays, match proves useful even with simple arrays. In fact, the A P L * P L U S PC System, which does not provide nested arrays, nonetheless has implemented match. The APL definition of match for simple arrays is M On older APL systems, expressions such as ' ' = l * 0 pA and ' ' = @ \ 0 p A were used to determine whether A was numeric (0) or character (1). Match simplifies this to ' ' ---0pA. A P L * P L U S PC/II/III systems enable 0 - 0 p A to determine if A = is numeric (@ is zilde, the empty vector numeric constant). These idioms are inadequate in systems which allow heterogeneous (simple mixed character and numeric) and nested arrays. Instead, an algorithm must test every item of the array. Match helps: ( tOpcA)~(pA)p' ' computes whether A is all-character by matching its type ( ~'0 p cA) against an identically-shaped array of blanks. You may substitute 0 for ' ' to test for all-numeric. Much code for data testing and validation is shortened and clarified by using match. We end this column with an illustrative list: Original method (most return a one-item vector) ¢ Is S a numeric scalar? ( 0=ppS )A0--1 I"0pS or (ppS)=l~0pS Is V a Modern method (all return a scalar) [1] [2] [3] [~] [5] [6] ¢ [7] V Z-L MATCH R;A;B A Z~L---R for simple arrays. -((pA~pL)¢pB~pR)pZ-O A Save shapes; quit and return 0 ~(ACB)/O A if ranks or any item of shapes differ. -(0cA)mE01 ~ Compare unless the arguments are empty. L~i~0pL ~ Arguments are empty, so use their R~i*0pR ~ prototype (zero or blank) instead. L 0 1 : Z * ~ 0 e L = R ~ Compare the values, returning a scalar. V ( pS )-=0pS ¢ two-item vector? (2EpV)Al=ppV (pV)---, 2 0 0-zt 0pcV 5 7~pM INP---'YES' ¢ Is V a There are four steps: check rank, shape, type (numeric or character, implicit in line [ 7 ] ), and finally the values. Notice that empty arrays of different type do not match. (However, Sharp APL does not consider the prototype of empty arrays, so that 1--- ' ' -= t 0.) For nested arrays, the function is applied recursively to corresponding items of the two arguments, essentially by using ~ATCH'" rather than = on line [ 7 ]. Match has replaced equal in the definition of index of (L t R) and membership (LER), and is also used in the newer find (L_cR) and without (L~R) functions, enabling these primitives to work on nested arrays: SEPTEMBER two-item numeric vector? ( 2epV)A( 11' 0pV)=lCppV 5-by-7 matrix? 2 5 7A.=(pp/~),2tp~ ¢ Is ~ a ¢ ¢ Did the user respond YES? ( 3:pINP)A 'YES' A.:3tINP Is numeric vector N all three-digit integers? A/(N:LN)A(N>100)AN_<999 N_=L100 [NL999 Roy A. Sykes, Jr. is the President of Sykes Systems, Inc., an APL consultingfirm. He can be reached at . roysykes@netcom.com . . . . 1995 - - VOLUME 26, NUMBER 1

Page 1 of 1

Page 1 of 1

Toggle back to continuous viewing mode

/lp/association-for-computing-machinery/whiz-bang-v94QhjH0jw
Welcome to DeepDyve! Rent Premier Research Articles and Save Up to 90%

Learn more

Free Article

Bookmark

Whiz bang!

Sykes Jr., Roy A.
ACM SIGAPL APL Quote Quad , Volume 26 (1)
Association for Computing MachinerySep 1, 1995

More Info

More Like This Article

View All dataSource[]=actageo&dataSource[]=aspet&dataSource[]=aaos&dataSource[]=aacc&dataSource[]=aacr&dataSource[]=aea&dataSource[]=aip&dataSource[]=ajnr&dataSource[]=ams&dataSource[]=aps_physical&dataSource[]=appi_book&dataSource[]=appi_journal&dataSource[]=apha&dataSource[]=asip&dataSource[]=asm&dataSource[]=asn&dataSource[]=aspb&dataSource[]=avs&dataSource[]=annual_reviews&dataSource[]=arxiv&dataSource[]=acm&dataSource[]=berghahn&dataSource[]=cabi&dataSource[]=clinical_trials&dataSource[]=dailymed&dataSource[]=degruyter&dataSource[]=du_press&dataSource[]=esa&dataSource[]=eu_press&dataSource[]=elsevier&dataSource[]=emerald&dataSource[]=ejtr&dataSource[]=emea&dataSource[]=epo&dataSource[]=faseb&dataSource[]=gsa&dataSource[]=health_affairs&dataSource[]=hindawi&dataSource[]=imanager&dataSource[]=imedpub&dataSource[]=informa_healthcare&dataSource[]=informs&dataSource[]=iop&dataSource[]=iucr&dataSource[]=iospress&dataSource[]=jbjs&dataSource[]=leftcoast&dataSource[]=lu_press&dataSource[]=mesharpe&dataSource[]=mary_ann_liebert&dataSource[]=medline&dataSource[]=mit_press&dataSource[]=nature&dataSource[]=oxford&dataSource[]=pier_professional&dataSource[]=pnas&dataSource[]=portlandpress&dataSource[]=psyc_articles&dataSource[]=psyc_books&dataSource[]=psyc_critiques&dataSource[]=plos_journal&dataSource[]=pubmed_central&dataSource[]=rsna&dataSource[]=rockefeller&dataSource[]=rcn&dataSource[]=ria&dataSource[]=rsc&dataSource[]=sage&dataSource[]=spie&dataSource[]=springer_journal&dataSource[]=springer&dataSource[]=taylor_francis&dataSource[]=aps&dataSource[]=the_scientist&dataSource[]=uc_press&dataSource[]=uspto_abstract&dataSource[]=wiley&dataSource[]=pct

Browse: Subject Areas | Journals | Publishers

Sign Up for a DeepDyve Account

Bookmark an Article

To bookmark an article, please log in first, or sign up for a DeepDyve account if you don't already have one.

OK

Subscribe to Journal Email Alerts

To subscribe to email alerts, please log in first, or sign up for a DeepDyve account if you don't already have one.

OK

Thank you for renting with DeepDyve

Your PayPal account has been charged $2.99. You now have access to the full text of this article. A rental receipt has also been sent to your email address.

Your credit card has been charged $2.99. You now have access to the full text of this article. A rental receipt has also been sent to your email address.

OK

New! You can now keep track of new articles from ACM SIGAPL APL Quote Quad on your personalized homepage! Learn more

PDF Download — Not Available

Thanks for your interest in purchasing the PDF. Your request has been noted and we will work with our publisher partner to discuss enabling this feature.

In the meantime, you can get the PDF by visiting the publisher site.

Thank you for purchasing with DeepDyve

Your PayPal account has been charged $.

Your credit card has been charged $.

You can now download this article. A purchase receipt has also been sent to your email address.

Download This Article or I'm done with my download

Print Page — Not Available

Thanks for your interest in printing individual pages. Your request has been noted and we will work with our publisher partner to discuss enabling this feature.

In the meantime, you can get the PDF by visiting the publisher site.

Thank you for printing with DeepDyve

Your PayPal account has been charged $0.

Your credit card has been charged $0.

You can now print this article. A purchase receipt has also been sent to your email address.

Print the Selected Pages or I'm done with my printing

Please refresh to generate a new download link

Your article download link has expired. Please refresh this page to obtain a new download link and try again.

Follow a Journal

To get new article updates from a journal on your personalized homepage, please log in first, or sign up for a DeepDyve account if you don't already have one.

OK