Advanced Language Features in Version 16.0 by Jay Foad and Dyalog 16.0

P
r
o
p
o
s
e
d
 
 
V
e
r
s
i
o
n
 
1
6
.
0
L
a
n
g
u
a
g
e
 
F
e
a
t
u
r
e
s
Jay Foad
D
y
a
l
o
g
 
1
6
.
0
 
(
S
p
r
i
n
g
 
2
0
1
7
)
Cut and Tessellate
Merge
Under and Obverse
Enclose-if-Simple, Link
Nub Sieve, Where
Version 16 Language Features
C
u
t
   
Cut 1 
' Cogito, ergo sum.'
┌────────
─────
─────┐
│ Cogito,│ ergo│ sum.│
└────────
─────
─────┘
   {
⊂⌽⍵
}Cut 1 
' Cogito, ergo sum.‘
┌────────
─────
─────┐
│,otigoC │ogre │.mus │
└────────
─────
─────┘
   
Cut ¯1 
' Cogito, ergo sum.‘
┌───────
────
────┐
│Cogito,│ergo│sum.│
└───────
────
────┘
Version 16 Language Features
C
u
t
   b←1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0
   b 
Cut 1 
' Cogito, ergo sum.‘
┌────────
─────
─────┐
│ Cogito,│ ergo│ sum.│
└────────
─────
─────┘
   
Cut ¯1 
' Cogito, ergo sum.‘
Cogito,
ergo
sum.
   
Cut 2 
'Cogito,/ergo/sum./‘
┌────────
─────
─────┐
│Cogito,/│ergo/│sum./│
└────────
─────
─────┘
   
Cut ¯2 
'Cogito,/ergo/sum./'
Version 16 Language Features
C
u
t
:
 
t
h
e
 
g
l
y
p
h
(Not 
)
Dagger 
 ?
Quad Circle 
 ?
Different glyphs for different cuts?
Version 16 Language Features
T
e
s
s
e
l
l
a
t
e
    
←glider←↑
⊃⎕
NGET'c:\dropbox\demos\glider.txt' 1
  X
   X
 XXX
      3 3 
 
 glider
┌───
───
───┐
│   │   │   │
│  X│ X │X  │
│   │  X│ X │
───
───
───
│  X│ X │X  │
│   │  X│ X │
│ XX│XXX│XX │
───
───
───
│   │  X│ X │
│ XX│XXX│XX │
│   │   │   │
└───
───
───┘
Version 16 Language Features
T
e
s
s
e
l
l
a
t
e
Hui:
life←{1
1
(-
⍴⍵
)↑5 6 7
∊⍨
(3 3 ,Cut ¯3
⊢⍵
)+.×9
1,
4
2}
Kromberg:
life←{
1 
 
.
 3 4 = 
 3 3 T {+/,
}
⊢⍵
}
Version 16 Language Features
M
e
r
g
e
A triadic operation:
THAT
 array but with 
THESE
 items at 
THOSE
 positions
  tmp←…    
 
name
 the array to form a variable
  tmp[x]←y 
 
mutate
 the variable
  …tmp     
 
dereference
 name to get new value
Version 16 Language Features
M
e
r
g
e
  P[X]+←Q   becomes   Q(+→X)P
  P[X] ←Q   becomes   Q(
→X)P
… except that instead of an index X
we use a Boolean selection mask B
  Q(+→B)P  
 select the major cells B
P
or a function f that generates one
  Q(+→f)P  
 use selection mask (f P)
Version 16 Language Features
M
e
r
g
e
      
 Stars at selected places in Hello
      '*' (
 → 0 1 0 0 1) 'Hello'
H*ll*
      f ← {0=3|
}
      100 (× → f) 
10
1 2 300 4 5 600 7 8 900 10
See the proposal paper from Dyalog '15 (Sicily)
Version 16 Language Features
U
n
d
e
r
 
(
a
k
a
 
D
u
a
l
)
f
g
 means:
Apply g to each argument 
before
 applying f
Then un-apply g to the result
      3 +
⍢⍟
 4  
 slide rule
12
      * (
3) + (
4)
12
Version 16 Language Features
U
n
d
e
r
mean ← +
 ÷ 
  
 arithmetic mean
mean
⍢⍟
         
 geometric mean
mean
÷         
 harmonic mean
mean
(*
2)     
 quadratic mean
mean
(*
p)     
 power mean
Version 16 Language Features
U
n
d
e
r
sort←{(
⊂⍋⍵
)
⌷⍵
}  
 a better sort idiom
sort     mat    
 sort the rows
sort
1 
 mat    
 sort each row
Version 16 Language Features
U
n
d
e
r
sort←{(
⊂⍋⍵
)
⌷⍵
}  
 a better sort idiom
sort     mat    
 sort the rows
sort
1 
 mat    
 sort each row
sort   
 
 mat  
 sort the cols
sort
1 
 
 mat  
 sort each col
Version 16 Language Features
U
n
d
e
r
:
 
t
h
e
 
d
e
f
i
n
i
t
i
o
n
 f
g 
  ←→  g
¯1 
 (g 
) f (g 
)
  f
g 
  ←→  g
¯1 
       f (g 
)
Version 16 Language Features
O
b
v
e
r
s
e
FFT
 is the 
F
ast Fourier 
T
ransform
FFT
IFT
 declares that 
IFT
 is the inverse of 
FFT
Hence
      ×
(FFT
IFT)
does fast convolution
(or fast multiplication of huge numbers)
Version 16 Language Features
O
b
v
e
r
s
e
:
 
t
h
e
 
d
e
f
i
n
i
t
i
o
n
      f
g 
     ←→  f 
      f
g 
 ¯1  ←→  g
f
Version 16 Language Features
(
A
P
L
2
)
 
P
a
r
t
i
t
i
o
n
Dyalog has standardised on 
⎕ML
=
1
so dyadic 
 is Partitioned Enclose
      
←{
ML←3 
 
⍺⊂⍵
}
      0 1 1 2 2 0 
 'Dyalog'
┌──
──┐
│ya│lo│
└──
──┘
Version 16 Language Features
E
n
c
l
o
s
e
-
i
f
-
S
i
m
p
l
e
,
 
L
i
n
k
Enclose-if-simple:
 
'one' 'two'  ←→   'one' 'two'
 
'one'        ←→  
'one'
Link:
   
⍺⊆⍵
  ←→  (
⊆⍺
),(
⊆⍵
)
 X
Y
Z  ←~→   X Y Z
More useful in grounded array languages?
Version 16 Language Features
E
n
c
l
o
s
e
-
i
f
-
S
i
m
p
l
e
,
 
L
i
n
k
Version 16 Language Features
N
u
b
 
S
i
e
v
e
      ≠←{(
⍵⍳⍵
)=
⍳≢⍵
}
      ≠ 3 1 4 1 5 9
1 1 1 0 1 1
      {↑
(≠
)}'Mississippi'
M i s s i s s i p p i
1 1 1 0 0 0 0 0 1 0 0
Version 16 Language Features
W
h
e
r
e
      
←{
/
⍳⍴⍵
}
      
 1 0 1 1 0
1 3 4
Refinements:
      
←{
/
⍳⍴
1/
}   
 Scalar 
      
←{
/
⍳⍴
1/~~
} 
 Boolean 
Version 16 Language Features
Slide Note
Embed
Share

Explore the cutting-edge language features introduced in Version 16.0 by Jay Foad and Dyalog 16.0. From tessellation to merging operations, these enhancements offer a glimpse into the future of programming languages. Dive deep into the world of dynamic programming with innovative concepts such as triadic operations and glyph manipulations. Discover the power of tessellating gliders and merging stars at selected places. Unleash your creativity and enhance your coding skills with the latest in language evolution.

  • Advanced Features
  • Dynamic Programming
  • Code Enhancements
  • Language Evolution

Uploaded on Sep 21, 2024 | 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. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Proposed Version 16.0 Language Features Jay Foad #DYNA16

  2. Dyalog 16.0 (Spring 2017) Cut and Tessellate Merge Under and Obverse Enclose-if-Simple, Link Nub Sieve, Where Version 16 Language Features #DYNA16

  3. Cut Cut 1 ' Cogito, ergo sum.' Cogito, ergo sum. { }Cut 1 ' Cogito, ergo sum. ,otigoC ogre .mus Cut 1 ' Cogito, ergo sum. Cogito, ergo sum. Version 16 Language Features #DYNA16

  4. Cut b 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 b Cut 1 ' Cogito, ergo sum. Cogito, ergo sum. Cut 1 ' Cogito, ergo sum. Cogito, ergo sum. Cut 2 'Cogito,/ergo/sum./ Cogito,/ ergo/ sum./ Cut 2 'Cogito,/ergo/sum./' Version 16 Language Features #DYNA16

  5. Cut: the glyph (Not ) Dagger ? Quad Circle ? Different glyphs for different cuts? Version 16 Language Features #DYNA16

  6. Tessellate glider NGET'c:\dropbox\demos\glider.txt' 1 X X XXX 3 3 glider X X X X X X X X X X XX XXX XX X X XX XXX XX Version 16 Language Features #DYNA16

  7. Tessellate Hui: life {1 1 (- ) 5 6 7 (3 3 ,Cut 3 )+. 9 1, 4 2} Kromberg: life { 1 . 3 4 = 3 3 T {+/, } } Version 16 Language Features #DYNA16

  8. Merge A triadic operation: THAT array but with THESE items at THOSE positions tmp name the array to form a variable tmp[x] y mutate the variable tmp dereference name to get new value Version 16 Language Features #DYNA16

  9. Merge P[X]+ Q becomes Q(+ X)P P[X] Q becomes Q( X)P except that instead of an index X we use a Boolean selection mask B Q(+ B)P select the major cells B P or a function f that generates one Q(+ f)P use selection mask (f P) Version 16 Language Features #DYNA16

  10. Merge Stars at selected places in Hello '*' ( 0 1 0 0 1) 'Hello' H*ll* f {0=3| } 100 ( f) 10 1 2 300 4 5 600 7 8 900 10 See the proposal paper from Dyalog '15 (Sicily) Version 16 Language Features #DYNA16

  11. Under (aka Dual) f g means: Apply g to each argument before applying f Then un-apply g to the result 3 + 4 slide rule 12 * ( 3) + ( 4) 12 Version 16 Language Features #DYNA16

  12. Under mean + arithmetic mean mean geometric mean mean harmonic mean mean (* 2) quadratic mean mean (* p) power mean Version 16 Language Features #DYNA16

  13. Under sort {( ) } a better sort idiom sort mat sort the rows sort 1 mat sort each row Version 16 Language Features #DYNA16

  14. Under sort {( ) } a better sort idiom sort mat sort the rows sort 1 mat sort each row sort mat sort the cols sort 1 mat sort each col Version 16 Language Features #DYNA16

  15. Under: the definition f g g 1 (g ) f (g ) f g g 1 f (g ) Version 16 Language Features #DYNA16

  16. Obverse FFT is the Fast Fourier Transform FFT IFT declares that IFT is the inverse of FFT Hence (FFT IFT) does fast convolution (or fast multiplication of huge numbers) Version 16 Language Features #DYNA16

  17. Obverse: the definition f g f f g 1 g f Version 16 Language Features #DYNA16

  18. (APL2) Partition Dyalog has standardised on ML=1 so dyadic is Partitioned Enclose { ML 3 } 0 1 1 2 2 0 'Dyalog' ya lo Version 16 Language Features #DYNA16

  19. Enclose-if-Simple, Link Enclose-if-simple: 'one' 'two' 'one' 'two' 'one' 'one' Link: ( ),( ) X Y Z ~ X Y Z More useful in grounded array languages? Version 16 Language Features #DYNA16

  20. Enclose-if-Simple, Link Version 16 Language Features #DYNA16

  21. Nub Sieve {( )= } 3 1 4 1 5 9 1 1 1 0 1 1 { ( )}'Mississippi' M i s s i s s i p p i 1 1 1 0 0 0 0 0 1 0 0 Version 16 Language Features #DYNA16

  22. Where { / } 1 0 1 1 0 1 3 4 Refinements: { / 1/ } Scalar { / 1/~~ } Boolean Version 16 Language Features #DYNA16

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#