Unlock the Power of Tacit Programming in Dyalog 2024

glasgow 2024 n.w
1 / 79
Embed
Share

Discover the world of tacit programming in Dyalog through functional composition, benefits, and tools. Dive into compositional operators, trains, and exercises to enhance your programming skills. Explore the magic of function composition and the efficiency of tacit programming in this comprehensive guide.

  • Tacit Programming
  • Dyalog
  • Functional Composition
  • Tools
  • Benefits

Uploaded on | 0 Views


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


  1. Glasgow 2024 Tacit Programming in Dyalog Stefan Kruger Ad m Brudzewsky Rich Park

  2. Glasgow 2024 Tacit Programming in Dyalog Ad m Brudzewsky Rich Park Stefan Kruger

  3. Glasgow 2024 Tacit Programming in Dyalog Ad m Brudzewsky xpqz.github.io/cultivations/Trains Rich Park youtu.be/Enlh5qwwDuY Train Spotting Stefan Kruger xpqz.github.io/learnapl/tacit

  4. What is tacit programming? Explicit code mentions arguments: Expression ( /N)- /N 3 1 4 1 5 Tradfn R Range Y Dfn Tacit code implies arguments: Tacit {( / )-( / )} ( /- /) Tacit Programming in Dyalog 3

  5. You already know some f/ f .g f\ A g f f B Operators derive tacit functions Tacit Programming in Dyalog 4

  6. Function composition f g f g f fgh f g Function composition is plumbing that guides arguments to functions Tacit Programming in Dyalog 5

  7. Benefits Arguments in operands Memorable (like and + ) Adjacency (like - and / ) Brevity (like F C) DRY (Don t Repeat Yourself; like ) Just a general feeling of superiority and awesomeness Tacit Programming in Dyalog 6

  8. Overview Compositional operators (combinators) Trains (forks and atops) Tools Issues Plenty of exercises throughout Reading Tacit Programming in Dyalog 7

  9. Over The shape of an outer product .f is ( ) , ( ) We can write this as , pre-process both Tacit Programming in Dyalog 8

  10. Beside Location of th 1 in each element of is We can write this as pre-process right Tacit Programming in Dyalog 9

  11. Atop Any-presence of in is / We can write this as / post-process result Tacit Programming in Dyalog 10

  12. Commute A multiplication table of N is ( ) . ( ) We can write this as . selfie Tacit Programming in Dyalog 11

  13. Tasks: Tacify! 1. 'Hello' {( ) ( )} 'World' 1 2. 'ab' 'cd' 'ab' {+/ } 'ab' 'de' 2 3. 8 100 0 { } 2.5 4 50 0 4. 10 4 1 0 { } 2.5 2 2 1 0 5. { \ = } 2 7 1 8 3 1 0 1 0 1 Tacit Programming in Dyalog 13

  14. Train Introduction Also a type of composition Sequence of functions in isolation Most common mistake + 3 1 4 1 5 0.2 Parenthesised: (+ ) 3 1 4 1 5 Assigned (+ )3 1 4 1 5 2.8 Avg + Avg 3 1 4 1 5 Tacit Programming in Dyalog 14

  15. Discussion: Writing Trains (fY)+(hY) (f+h)Y Tacit Programming in Dyalog 15

  16. Discussion: Writing Trains (fY)+(hY) (f+h)Y (fY)+( Y) (f+ )Y Tacit Programming in Dyalog 16

  17. Discussion: Writing Trains (fY)+(hY) (f+h)Y (fY)+( Y) (f+ )Y (XfY)+(XhY) X(f+h)Y Tacit Programming in Dyalog 17

  18. Discussion: Writing Trains (fY)+(hY) (f+h)Y (fY)+( Y) (f+ )Y (XfY)+(XhY) X(f+h)Y (X )+(XhY) X( +h)Y Tacit Programming in Dyalog 18

  19. Discussion: Writing Trains (fY)+(hY) (f+h)Y (fY)+( Y) (f+ )Y (XfY)+(XhY) X(f+h)Y (X )+(XhY) X( +h)Y Tacit Programming in Dyalog 19

  20. Discussion: Writing Trains (fY)g(hY) (fgh)Y (fY)g( Y) (fg )Y g(hY) ( gh)Y (XfY)g(XhY) X(fgh)Y (X )g(XhY) X( gh)Y Tacit Programming in Dyalog 20

  21. Discussion: Writing Trains (fY)g(hY) (fgh)Y (fY)g( Y) (fg )Y g(hY) ( gh)Y (XfY)g(XhY) X(fgh)Y (X )g(XhY) X( gh)Y g(XhY) X( gh)Y Tacit Programming in Dyalog 21

  22. Discussion: Writing Trains (fY)g(hY) (fgh)Y (fY)g( Y) (fg )Y g(hY) ( gh)Y (XfY)g(XhY) X(fgh)Y (X )g(XhY) X( gh)Y g(XhY) X( gh)Y Tacit Programming in Dyalog 22

  23. Discussion: Writing Trains (fY)g(hY) (fgh)Y (fY)g( Y) (fg )Y f(gY) ( fg)Y (XfY)g(XhY) X(fgh)Y (X )g(XhY) X( gh)Y f(XgY) X( fg)Y Tacit Programming in Dyalog 23

  24. Train Details Some parts can be arrays: A g his{A} g h Two sub-types of trains: Fork: Atop: Longer trains: (d e f g h)is(d e (f g h)) (e f g h)is(e (f g h)) f g handA g h f g Tacit Programming in Dyalog 24

  25. Example: Writing a Train { / ( \ ) = } 1 3 5 6 7 1 { / ( \ ) = ( )} 1 3 5 6 7 1 { / ( \ = ) } 1 3 5 6 7 1 {( / \ = ) } 1 3 5 6 7 1 ( / \ = ) 1 3 5 6 7 1 Tacit Programming in Dyalog 26

  26. Tasks: Convert dfn to tacit 1. {1+ } 2 7 1 8 3 8 2 9 2. 3 1 4 {( )~( )} 1 6 1 3 4 6 3. { } 10 1 2 5 10 4. 2 {( ) } 2 7 1 8 3 7 Bonus: Find 3 ways to do this! 5. { *2} 2 7 1 8 3 4 49 1 64 9 Tacit Programming in Dyalog 27

  27. BREAK Tacit Programming in Dyalog 28

  28. Amazing tool: ]box on Tacit Programming in Dyalog 29

  29. |+/ ]box on | + / Tacit Programming in Dyalog 30

  30. |+/ ]box on t= -t=box | + / Tacit Programming in Dyalog 31

  31. |+/ ]box on t= -t=box -t=tree | + / . | . . . / . . + . Tacit Programming in Dyalog 32

  32. |+/ ]box on t= -t=box -t=tree -t=parens | + / . | . . . / . . + . |( ((+/) )) Tacit Programming in Dyalog 33

  33. Tasks: Convert dfn to tacit 1. {( ) ( )} 1 1 1 0 1 1 0 0 2. ',;' {(~ ) } 'ab,de;fgh' 3 ab de fgh nums 2 7 1 8 3 3. 4 {( + ) } nums 4. {(+ ) } nums 5. Bonus task: Combine 3 & 4 into an ambivalent function. 4.5 4.75 4.2 Tacit Programming in Dyalog 34

  34. Issues Arguments in operands Lots of monadic functions Dotting, Assignment, Recursion Selection Tacit Programming in Dyalog 35

  35. Issues: Arguments in operands 10 {x @{x< } } 1 2 13 14 5 16 7 18 1 2 18 16 5 14 7 13 10 { @( < ) } 1 2 13 14 5 16 7 18 1 2 18 16 5 14 7 13 2 {( ) } 3 3 9 9 8 7 6 5 4 3 2 1 Tacit Programming in Dyalog 36

  36. Issues: Lots of monadic functions { + } (+ ) ( ) (+ ( )) + ( ) (+ ) Tacit Programming in Dyalog 37

  37. Issues: Recursion, Assignment, Dotting Namespace dotting Assignment Recursion {9 NC' ': n, n . NL-2 9} Tacit Programming in Dyalog 38

  38. Issues: Selection {(3> ) } 3 1 4 1 5 4 5 (3 > ) 3 1 4 1 5 SYNTAX ERROR (3 > )3 1 4 1 5 SYNTAX ERROR (3 > )3 1 4 1 5 4 5 3 > 3 1 4 1 5 20.0 Conference Edition Tacit Programming in Dyalog 39

  39. Issues: Selection 'aeiou' { [ ]} 'hello world' eoohll wrld 'aeiou' { } 'hello world' LENGTH ERROR 'aeiou'{ }'hello world' eoohll wrld 'aeiou' ( )'hello world' eoohll wrld 'aeiou' ( ) 'hello world' 21.0? Tacit Programming in Dyalog 40

  40. Reading Tacit operator scope trains putting it all together Tacit Programming in Dyalog 41

  41. Reading Tacit: operator scope = 0 1 5 Tacit Programming in Dyalog 42

  42. Reading Tacit: operator scope = 0 1 5 Tacit Programming in Dyalog 43

  43. Reading Tacit: operator scope = 0 1 5 Tacit Programming in Dyalog 44

  44. Reading Tacit: operator scope = 0 1 5 Tacit Programming in Dyalog 45

  45. Reading Tacit: operator scope = 0 1 5 Tacit Programming in Dyalog 46

  46. Reading Tacit: operator scope = 0 1 5 Tacit Programming in Dyalog 47

  47. Reading Tacit: operator scope = 0 1 5 Tacit Programming in Dyalog 48

  48. Reading Tacit: operator scope = 0 1 5 Tacit Programming in Dyalog 49

  49. Reading Tacit: operator scope = 0 1 5 ((((= ) 0 1) ) )5 Tacit Programming in Dyalog 50

  50. Reading Tacit: operator scope = 0 1 5 ((((= ) 0 1) ) )5 Tacit Programming in Dyalog 51

More Related Content