User-Defined Operators: Overview and Benefits
In this comprehensive guide, delve into the world of user-defined operators, exploring the reasons behind defining your own operators and understanding what operators are. Discover the advantages of custom operators and how they can enhance functionality, aesthetics, and efficiency in programming. Uncover the core concepts and practical examples to solidify your understanding and proficiency in this advanced topic.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
User-Defined Operators Ad m Brudzewsky
Overview User-Defined Operators 1
Overview Why? What? How? Examples User-Defined Operators 2
Why define your own operators? Apply multiple functions in similar ways Add a parameter to tweak behaviour Achieve nicer looking expressions Amend primitives to your needs Avoid repeating yourself User-Defined Operators 3
Why define your own operators? Apply multiple functions in similar ways Add a parameter to tweak behaviour Achieve nicer looking expressions Amend primitives to your needs Avoid repeating yourself in ways that isn't part of the core language User-Defined Operators 4
What is an operator? F/ F.G . . +.= -. User-Defined Operators 5
What is an operator? F/ / +/ / ,/ F.G . . +.= -. User-Defined Operators 6
What is an operator? operand F/ / +/ / ,/ F.G . . +.= -. User-Defined Operators 7
What is an operator? F/ / +/ / ,/ function operand F.G . . +.= -. User-Defined Operators 8
What is an operator? +/ ,\ function operand . @ + = - User-Defined Operators 9
What is an operator? 42 1200 array operand 3 1 + 'Hi' R'Hello' User-Defined Operators 10
What is an operator? derived functions 42 1200 3 1 + 'Hi' R'Hello' User-Defined Operators 11
What is an operator? derived functions Answer 42 Format 1200 Replace 'Hi' R'Hello' Increment 1 + Windows 3 User-Defined Operators 12
What is an operator? derived functions Answer 42 Format 1200 ambivalent dyadic Replace 'Hi' R'Hello' Increment 1 + Windows 3 ambivalent monadic monadic User-Defined Operators 13
What is an operator? derived functions Answer 42 Format 1200 ambivalent dyadic 'a' Answer 'b' 42 Answer 'b' 42 Replace 'Hi' R'Hello' Increment 1 + Windows 3 ambivalent monadic monadic User-Defined Operators 14
What is an operator? derived functions Answer 42 Format 1200 Format 123 SYNTAX ERROR: The function requires a left argument Format 123 ambivalent dyadic Replace 'Hi' R'Hello' Increment 1 + Windows 3 ambivalent monadic monadic User-Defined Operators 15
What is an operator? derived functions 4 Increment 2 SYNTAX ERROR: The function does not take a left argument 4 Increment 2 Answer 42 Format 1200 ambivalent dyadic Replace 'Hi' R'Hello' Increment 1 + Windows 3 ambivalent monadic monadic User-Defined Operators 16
What is an operator? FUNCTION deriving a monadic dyadic ambivalent OPERATOR monadic 1200 42 +\ dyadic 3 , 2 +. User-Defined Operators 17
How are they defined/identified? TRADFN DFN Presence of and in body Calling syntax in header res x Name y res x y Name { } dyadic function User-Defined Operators 18
How are they defined/identified? TRADOP DOP Presence of or in body Calling syntax in header res (F Name)y res F y Name { } monadic operator deriving a monadic function User-Defined Operators 19
How are they defined/identified? TRADOP DOP Presence of or in body Calling syntax in header res x(F Name)y res x F y Name { } monadic operator deriving a dyadic function User-Defined Operators 20
How are they defined/identified? TRADOP DOP Presence of or in body Calling syntax in header res x(F Name G)y res x F G y Name { } dyadic operator deriving a dyadic function User-Defined Operators 21
How are they defined/identified? TRADOP DOP Presence of or in body Calling syntax in header res (F Name G)y res F G y Name { } dyadic operator deriving a monadic function User-Defined Operators 22
Apply multiple functions in similar ways Add a parameter to tweak behaviour Achieve nicer looking expressions Amend primitives to your needs Avoid repeating yourself User-Defined Operators 23
Demo: utilities _S { ( )} Stack Vowel 'AEIOU' Vowel _S A 'AEIOU' _S A _T { r (62 ATX ' ') ' 'r r} Trace -_T/3 1 4 1 5 User-Defined Operators 24
Demo: combinators/compositions A_ { ( ) } Across 'HELLO' _A_~'APL' _H_ {( ) } Hook _H_ 'hello' 'racecar' 'APL' 'ABBA' 'max' _H_ _S'hello' 'racecar' 'APL' 'ABBA' 'max' _H_ _H_/'hello' 'racecar' 'APL' 'ABBA' 'max' User-Defined Operators 25
Demo: thought concepts param Fn _W_ Cond initArg _W_ { : } While 2 _W_{ <100}4 2 _T _W_{ <100}4 _E_ { 0:: } ErrorElse _0 {r ( r) r r} Depth 0 ( / )_0 4 5(2 3) User-Defined Operators 26
Next Webinar June 23: TBA User-Defined Operators 27
Next Webinar June 23: TBA Remember: BAA webinars every other week britishaplassociation.org/webinar-schedule-2022 June 16th, 30th; July 14th, 28th; etc. User-Defined Operators 28
Next Webinar June 23: TBA Remember: BAA webinars every other week britishaplassociation.org/webinar-schedule-2022 June 16th, 30th; July 14th, 28th; etc. More at: apl.wiki/activities User-Defined Operators 29