SlideShare a Scribd company logo
1 of 9
Download to read offline
Idea for Interactive Programming Language
Lincoln Hannah - July 2018
Notebooks such as Jupyter give programming languages a level of interactivity approaching that of spreadsheets.
I present here an idea for a programming language specifically designed for an interactive environment similar to a notebook.
It aims to combining the power of a programming language with the usability of a spreadsheet.
Instead of free-form code, the user creates fields / columns, but these can be combined into tables and object classes.
By declaratively cycling through field elements, loops and other programing constructs can be created.
I give examples from classical computer science, machine learning and mathematical finance, specifically:
Nth Prime Number, 8 Queens, Poker Hand, Travelling Salesman, Linear Regression, VaR Attribution
Input
Output
Name Formula Comments
X 5:9:2 5 7 9 Array 5 to 9 by 2
Xby2 2*X 10 14 18 increment by 1 if increment omitted
Y 4: { Y^2 < 30 } 4 5 {} indicates a do while condition
like a do while loop
Z 1:1000 1 2 3 4 5 996 997 998 999 1000
MyCol Data ABC Hello 123
Function Fn( Arg1, Arg2 ) Arg1 + 2 * Arg2 In-line function definition
Function fibonacci( n=10 ) MultiLine
1:n 1 2 3 4 5 11 12 13 14 15
fib fib.prev + fib.prev(2) 1 1 2 3 5 89 144 233 377 610
Return fib.last 610
fibonacci( 4:7 ) 3 5 8 13
My_Dict Dictionary
key 4:6 4 5 6
value Data four five six
X 5 7 9 5 7 7 9 5 7 9 Fields in adjacent rows (X and Y)
Y 4 4 4 5 5 4 4 5 5 5 whithout a specified join, does a cross-join.
Xby2 10 14 18 10 14 14 18 10 14 18 produces every combination of X and Y so
My_Dict( Y ) four four four five five four four five five five Can be used like nested loops
MyCol ABC ABC ABC ABC ABC 123 123 123 123 123
XbyY X*Y 20 28 36 25 35 28 36 25 35 45
Fn( X, Y ) 13 15 17 15 17 15 17 15 17 19
Multiple blank lines indicates end of
multi-line function
Values - First 5 Values - Last 5
Data keyword allows vaulues to be
entered directly
Default argument values (n=10)
allow example function output to be
shown within function definition.
Useful for debugging.
Outer_Join( X, Y ) 4 5 7 9
X 5 7 9
Y 4 5
Concat( X, Y ) 5 7 9 4 5
X_filled Str(X) 5 7 9 Manual1 haha
Y 4 2
CountX count( X ) 3
MaxX max( X ) 9
X 5 7 9
SumY sum( Y ) 9 9 9
SumXbyY sum( XbyY ) 45 76 81
FirstMatch( X ) <= 6 <=8 CatchAll
X_bucket_1st up_to_6 up_to_8 Some_Other
X 5 7 9
Y_bucket_1st up_to_6 up_to_8 Some_Other
AllMatch( X ) <= 8 <=10
X_bucket_All up_to_8 up_to_10
X 5 7 5 7 9
X_bucket_All up_to_8 up_to_8 up_to_10up_to_10up_to_10
AllMatch( X ) <= 8 <= 8 >8
Above.AND.AllMatch( Y ) ==4 ==5 CatchAll
lable A B C
X 5 7 5 7 9 9
Y 4 4 4 4 4 5
lable A A B B C C
I New MyClass( Arg1=1 ) 1
I.Arg2 1
I.Const 1.2
I.Out1 8.2
Id Generated automatically. Arg2 not
speified so gets default value from
class definition.
W New MyClass( Arg1=X, Arg2=Y) 1 2 3 2 4 12 18 7 14 21
X 1 2 3 1 2 2 3 1 2 3
Y 1 1 1 2 2 6 6 7 7 7
W.Out1 6.2 8.2 10.2 9.2 11.2 23.2 25.2 24.2 26.2 28.2
W.Out2 0.2 1.4 2.6 -0.8 0.4 -3.6 -2.4 -5.8 -4.6 -3.4
M1 New Matrix( nRows=3, nCols=2 ) 1
M2 New Matrix( nRows=1, nCols=2 ) 1 Alternate notatation
M1.Row 1 2 1 2 1 2
M1.Col 1 1 2 2 3 3
M1.Value Data 10 11 12 13 14 15
M2.Col 1 1
M2.Row 1 2
M2.Value Data 3 3
M3 M1.Product( M2 )
M3.Row 1 2 3
M3.Col 1 1 1
M3.Value 63 75 87
Class MyClass
ID ID-Generator 1
Arg1 Decimal 1
Arg2 Decimal 1
Const Static Decimal 1.2
Out1 Const + 2 * Arg1 + 3 * Arg2 6.2
Out2 Const * Arg1 - Arg2 0.2
Data keyword allows values to be
entered in data area
Static Data indicates cannot be
overridden when instantiated. Data
without Static are default values
only. Fields will be input (white)
Every class has an id. (like the
primary Key of a table) ID shown if
no field selected, as per Z and W
above.
Arguments set to columns / vectors
so a column of Ojbects created with
generated IDs - 1 to 21.
NameSpace MathLibrary
Class Matrix
ID ID-Generator 1
nRows Data 2
nCols Data 2
Row 1 : nRows 1 2
Col 1 : nCols 1 2
Row 1 2 1 2
Col 1 1 2 2
Value Data 0 0 0 0
Row==Col 1 2
Trace Value 0 0
Add Method returns Matrix
M2 Argument Matrix 1
Return New Matrix( nRows= This.nRows, nCols= This.nCols) 1
Error_If nRows != M2.nRows Error( "number of Rows must match to add Matricies" )
Error_If nCols != M2.nCols Error( "number of Columns must match to add Matricies" )
Row == M2.Row == Return.Row
Col == M2.Col ==Return.Col
Return.Value Value + M2.Value
Transpose Method returns Matrix
Return New Matrix( nRows = This.nCols, nCols=This.nRows) 1
Return.Row == This.Col
Return.Col == This.Row
Return.Value This.Value
Product Method returns Matrix
Right Argument Matrix
Return New Matrix( nRows= This.nRows, nCols= Right.nCols)
Error_If nCols != Right.nRows Error( "number of Columns of left matrix must match number of Rows of Right matrix." )
This.Col == Right.Row
Return.Value sum( This.Value * Right.Value )
Fields created within method only
visible within method (Privative
Errors produced if user tries to add
matricies of unmatched dimensions
Left, Right, Add automatically joined
on Row and Column Due to matching
Default values set in class definition
can be overwritten.
Class Primes
Is_Prime Method returns Boolean
x Argument Integer 32
i 2 : { i > sqrt( x ) } 1 2 3 4 5
Mod_x x mod i == 0 TRUE TRUE FALSE TRUE FALSE
x 1 >1
Return TRUE OR( Mod_x )
Nth_Prime Method returns Integer
n Argument Integer 5
i 1: {Count_Primes == n} 1 2 3 4 5 6 7
Count_Primes Is_Prime( i ) + Count_Primes.prev(First=0) 1 2 3 3 4 4 5
Return Last( i ) 7
NameSpace Poker
Class Card
ID ID-Generator 1
Suit Possible_Values Data 4 Hearts Diamonds Clubs Spades
Number Possible_Values Data 13 Two Three Four Five Six Ten Jack Queen King Ace
Class Hand
ID ID-Generator 1
C New( 5 ) Card 1 2 3 4 5
C.Suit Data Hearts Diamonds Clubs Spades Spades
C.Number Data Five Five Five Five Six
Four_of_a_Kind count( distict( C.Suit ) ) >= 4 TRUE
Three_of_a_Kind count( distict( C.Suit ) ) >= 3 TRUE
Pair count( distict( C.Suit ) ) >= 2 TRUE
Full_House Count( Distict( C.Suit ) ) >= 2 TRUE
Non static Data - set defaults to test
formulas
NameSpace Chess
Class Position
D1 Possible_Values 1:8 1 2 3 4 5 6 7 8
D2 Possible_Values 1:8 1 2 3 4 5 6 7 8
Class Queen
Pos New Position 1
Pos.D1 Default 6
Pos.D2 Default 4
Cross1 New Position( D1= Pos.D1, D2=1:8 ) 1 2 3 4 5 6 7 8
Cross2 New Position( D2= Pos.D1, D1=1:8 ) 1 2 3 4 5 6 7 8
Diag1 New Position 1 2 3 4 5 6
Diag1.D1 1 + max( 0 ,D2-D1) : 8 - max(0 ,D2-D1) 1 2 3 4 5 6
Diag1.D2 Diag1.D1 + D2 - D1 3 4 5 6 7 8
Diag2 New Position 1 2 3 4 5 6 7
Diag2.D1 max( 1 , x+y - 8 ) : min( 8, x+y-1 ) 2 3 4 5 6 7 8
Diag2.D2 Reverse( Diag2.D1 ) 8 7 6 5 4 3 2
Take_Pos Concat( Cross1 , Cross2 , Diag1 , Diag2 ) 1 2 3 4 29 27 28 29
Take_Pos Concat Cross1 Cross2 Diag1 Diag2 Alternative notation
Take_Pos_Col Method
Col Argument Integer 7
Take_Pos.D1 == Col
Return Distinct( Take_Pos.D2 ) 3 4 5
Class 8_Queen
Queens New Queen 1 2 3 4 5 6 7 8
Queens.ID 1:8 1 2 3 4 5 6 7 8
Queens.D1 Queens.ID 1 2 3 4 5 6 7 8
X New 8_Queen
X.Queens[1].D2 All 1 2 3 4 5 6 7 8
i 2:8 2 3 4 5 6 7 8
X.Queens[i].D2 All ~ X.Queens[1: i-1].Take_Pos_Col(i)
X.ID 1 1 1 1 1 1 1 1 2 2
X.Queens.D1 1 2 3 4 5 6 7 8 1 2
X.Queens.D2 * * * * * * * * * *
X.ID 1 2 3 4 5 88 89 90 91 92
Pivot
1 2 1 1 4 5 5 5 6 5 4
2 4 7 7 1 1 1 7 3 3 6
3 6 4 5 5 8 8 1 1 1 8
4 8 6 8 8 5 6 4 8 7 2
5 3 8 2 2 2 3 2 4 2 7
6 7 2 4 7 7 7 8 2 8 1
7 1 5 6 3 3 2 6 7 6 3
8 5 3 3 6 6 4 3 5 4 5
X.Queens.D2
X.Queens.D1
NameSpace Travelling Salesman
Import_Data C:Test.CSV
Start_City Hull Hull Hull Leeds Leeds Bath
End_City Leeds Bath Slaugh Bath Slaugh Slaugh
Time 2.2 3.4 4.2 6.3 4.2 2.2
Start_City_* concat( Start_City, End_City ) 1 1 1 2 2 2 3 4 3 4
End_City_* concat( End_City, Start_City ) 2 3 4 3 4 1 1 1 2 2
Time_* concat( Time, Time ) 2.2 3.4 4.2 6.3 4.2 2.2 3.4 4.2 6.3 4.2
Cities distinct( Start_City_* ) 1 2 3 4
Perms New Permutations( Items = Cities )
Perms All Class Members
Perms.Permutation 1 1 1 1 2 23 24 24 24 24
Perms.Item 1 2 3 4 1 2 4 3 2 1
Perms.Permutation 1 1 1 1 2 23 24 24 24 24
Start_City_* == Perms.Item 1 2 3 4 1 2 4 3 2 1
End_City_* == If( Permutation.Next == Permutation, Item.Next, Item.Prev(3)2 3 4 1 3 4 3 2 1 4
Time 2.2 6.3 2.9 9.1 7.5 5.8 1.5 6.3 2.2 4.2
Perms.Permutation 1 2 3 4 5 20 21 22 23 24
Total_Time Sum( Time ) 38.1 18.2 27.1 37.8 1.5 16.7 3.0 22.0 27.0 8.0
Min_Total_Time Min( Total_Time ) 5
Min_Time_Perm Perms.Permutation 13
Min_Time_Perm 13 13 13 13
Perms.Item 2 1 3 4
NameSpace Linear Regression
Function variance( x ) ( sum( x^2 ) - sum( x )^2 )/ (count(x) -1 )
Function covar( x, y ) ( sum( x*y ) - sum(x)*sum(y) )/ (count(x) -1 )
Function slope( x, y ) covar( x, y ) / variance( x )
Function intercept( x, y ) mean( y ) - mean( x ) * slope( x, y )
Import_Data C:Daily_Temp_Training_Data.CSV
Daily_Temp 20 13 19 15 27 18 28 25 13 25
Next_Day_Temp 24 13 23 19 28 21 31 30 13 29
Temp_Slope slope( Daily_Temp, Next_Day_Temp ) 0.55
Temp_Intercept intercept( Daily_Temp, Next_Day_Temp ) 11
Import_Data C:Daily_Temp_Test_Data.CSV
Daily_Temp 16 29 15 10 10 10 23 29 20 23
Predicted_Next_Day_Temp Temp_Intercept + Temp_Slope * Daily_Temp 20 27 19 17 17 17 24 27 22 23
NameSpace VaR Attribution
Import_Data C:Historical_Simulation.CSV
Rate_Schock_ID 1 1 1 1 1 500 500 500 500 500
Trade_ID 1 2 3 4 5 221 222 223 224 225
PandL 26.53 1.89 16.98 49.23 23.90 17.50 45.38 46.61 37.93 45.27
Quantile Data 95%
Number_of_Shocks count( Rate_Schock_ID ) 500
VaR_Rank Quantile * Number_of_Schocks 475
Total_PandL sum( PandL ).descending 323.0 321.5 320.3 316.8 313.9 309.4 308.6 308.4 308.2 306.6
Ordered_IDs Rate_Shock_ID 335 405 209 102 409 168 116 138 379 339
Quantile_Schock_ID Ordered_IDs.rank( Q_Rank ) 245
Quantile_Schock_ID 245
Trade_ID 1 2 3 4 5 221 222 223 224 225
Trade_VAR_Attribution PandL 113 133 141 169 140 145 182 139 172 140

More Related Content

What's hot

June 05 P2
June 05 P2June 05 P2
June 05 P2
Samimvez
 
Thinking Functionally In Ruby
Thinking Functionally In RubyThinking Functionally In Ruby
Thinking Functionally In Ruby
Ross Lawley
 
Regression &amp; Classification
Regression &amp; ClassificationRegression &amp; Classification
Regression &amp; Classification
주영 송
 

What's hot (20)

Ch6
Ch6Ch6
Ch6
 
Admission for b.tech
Admission for b.techAdmission for b.tech
Admission for b.tech
 
10. Getting Spatial
10. Getting Spatial10. Getting Spatial
10. Getting Spatial
 
June 05 P2
June 05 P2June 05 P2
June 05 P2
 
DataFrame in Python Pandas
DataFrame in Python PandasDataFrame in Python Pandas
DataFrame in Python Pandas
 
Thinking Functionally In Ruby
Thinking Functionally In RubyThinking Functionally In Ruby
Thinking Functionally In Ruby
 
Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303
 
Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4
 
Principal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and VisualizationPrincipal Components Analysis, Calculation and Visualization
Principal Components Analysis, Calculation and Visualization
 
Regression &amp; Classification
Regression &amp; ClassificationRegression &amp; Classification
Regression &amp; Classification
 
Python lecture 05
Python lecture 05Python lecture 05
Python lecture 05
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
 
Pandas Series
Pandas SeriesPandas Series
Pandas Series
 
Survey Demo
Survey DemoSurvey Demo
Survey Demo
 
Monad
MonadMonad
Monad
 
Introduction to NumPy for Machine Learning Programmers
Introduction to NumPy for Machine Learning ProgrammersIntroduction to NumPy for Machine Learning Programmers
Introduction to NumPy for Machine Learning Programmers
 
9 2power Of Power
9 2power Of Power9 2power Of Power
9 2power Of Power
 
Algebra factoring
Algebra factoringAlgebra factoring
Algebra factoring
 
White-Box Testing on Methods
White-Box Testing on MethodsWhite-Box Testing on Methods
White-Box Testing on Methods
 
Python
PythonPython
Python
 

Similar to Idea for ineractive programming language

Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programming
Damian T. Gordon
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]
Palak Sanghani
 

Similar to Idea for ineractive programming language (20)

Learn Matlab
Learn MatlabLearn Matlab
Learn Matlab
 
Basic R Data Manipulation
Basic R Data ManipulationBasic R Data Manipulation
Basic R Data Manipulation
 
Matlab1
Matlab1Matlab1
Matlab1
 
Seminar PSU 10.10.2014 mme
Seminar PSU 10.10.2014 mmeSeminar PSU 10.10.2014 mme
Seminar PSU 10.10.2014 mme
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
The what over the how (another way on android development with kotlin)
The what over the how (another way on android development with kotlin)The what over the how (another way on android development with kotlin)
The what over the how (another way on android development with kotlin)
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programming
 
bobok
bobokbobok
bobok
 
Matlab-1.pptx
Matlab-1.pptxMatlab-1.pptx
Matlab-1.pptx
 
R Language Introduction
R Language IntroductionR Language Introduction
R Language Introduction
 
INTRODUCTION TO MATLAB session with notes
  INTRODUCTION TO MATLAB   session with  notes  INTRODUCTION TO MATLAB   session with  notes
INTRODUCTION TO MATLAB session with notes
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
Econometric Analysis 8th Edition Greene Solutions Manual
Econometric Analysis 8th Edition Greene Solutions ManualEconometric Analysis 8th Edition Greene Solutions Manual
Econometric Analysis 8th Edition Greene Solutions Manual
 
R code for data manipulation
R code for data manipulationR code for data manipulation
R code for data manipulation
 
R code for data manipulation
R code for data manipulationR code for data manipulation
R code for data manipulation
 
Python High Level Functions_Ch 11.ppt
Python High Level Functions_Ch 11.pptPython High Level Functions_Ch 11.ppt
Python High Level Functions_Ch 11.ppt
 
Solution of matlab chapter 3
Solution of matlab chapter 3Solution of matlab chapter 3
Solution of matlab chapter 3
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]
 
A quick introduction to R
A quick introduction to RA quick introduction to R
A quick introduction to R
 

Recently uploaded

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 

Recently uploaded (20)

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 

Idea for ineractive programming language

  • 1. Idea for Interactive Programming Language Lincoln Hannah - July 2018 Notebooks such as Jupyter give programming languages a level of interactivity approaching that of spreadsheets. I present here an idea for a programming language specifically designed for an interactive environment similar to a notebook. It aims to combining the power of a programming language with the usability of a spreadsheet. Instead of free-form code, the user creates fields / columns, but these can be combined into tables and object classes. By declaratively cycling through field elements, loops and other programing constructs can be created. I give examples from classical computer science, machine learning and mathematical finance, specifically: Nth Prime Number, 8 Queens, Poker Hand, Travelling Salesman, Linear Regression, VaR Attribution Input Output Name Formula Comments X 5:9:2 5 7 9 Array 5 to 9 by 2 Xby2 2*X 10 14 18 increment by 1 if increment omitted Y 4: { Y^2 < 30 } 4 5 {} indicates a do while condition like a do while loop Z 1:1000 1 2 3 4 5 996 997 998 999 1000 MyCol Data ABC Hello 123 Function Fn( Arg1, Arg2 ) Arg1 + 2 * Arg2 In-line function definition Function fibonacci( n=10 ) MultiLine 1:n 1 2 3 4 5 11 12 13 14 15 fib fib.prev + fib.prev(2) 1 1 2 3 5 89 144 233 377 610 Return fib.last 610 fibonacci( 4:7 ) 3 5 8 13 My_Dict Dictionary key 4:6 4 5 6 value Data four five six X 5 7 9 5 7 7 9 5 7 9 Fields in adjacent rows (X and Y) Y 4 4 4 5 5 4 4 5 5 5 whithout a specified join, does a cross-join. Xby2 10 14 18 10 14 14 18 10 14 18 produces every combination of X and Y so My_Dict( Y ) four four four five five four four five five five Can be used like nested loops MyCol ABC ABC ABC ABC ABC 123 123 123 123 123 XbyY X*Y 20 28 36 25 35 28 36 25 35 45 Fn( X, Y ) 13 15 17 15 17 15 17 15 17 19 Multiple blank lines indicates end of multi-line function Values - First 5 Values - Last 5 Data keyword allows vaulues to be entered directly Default argument values (n=10) allow example function output to be shown within function definition. Useful for debugging.
  • 2. Outer_Join( X, Y ) 4 5 7 9 X 5 7 9 Y 4 5 Concat( X, Y ) 5 7 9 4 5 X_filled Str(X) 5 7 9 Manual1 haha Y 4 2 CountX count( X ) 3 MaxX max( X ) 9 X 5 7 9 SumY sum( Y ) 9 9 9 SumXbyY sum( XbyY ) 45 76 81 FirstMatch( X ) <= 6 <=8 CatchAll X_bucket_1st up_to_6 up_to_8 Some_Other X 5 7 9 Y_bucket_1st up_to_6 up_to_8 Some_Other AllMatch( X ) <= 8 <=10 X_bucket_All up_to_8 up_to_10 X 5 7 5 7 9 X_bucket_All up_to_8 up_to_8 up_to_10up_to_10up_to_10 AllMatch( X ) <= 8 <= 8 >8 Above.AND.AllMatch( Y ) ==4 ==5 CatchAll lable A B C X 5 7 5 7 9 9 Y 4 4 4 4 4 5 lable A A B B C C I New MyClass( Arg1=1 ) 1 I.Arg2 1 I.Const 1.2 I.Out1 8.2 Id Generated automatically. Arg2 not speified so gets default value from class definition.
  • 3. W New MyClass( Arg1=X, Arg2=Y) 1 2 3 2 4 12 18 7 14 21 X 1 2 3 1 2 2 3 1 2 3 Y 1 1 1 2 2 6 6 7 7 7 W.Out1 6.2 8.2 10.2 9.2 11.2 23.2 25.2 24.2 26.2 28.2 W.Out2 0.2 1.4 2.6 -0.8 0.4 -3.6 -2.4 -5.8 -4.6 -3.4 M1 New Matrix( nRows=3, nCols=2 ) 1 M2 New Matrix( nRows=1, nCols=2 ) 1 Alternate notatation M1.Row 1 2 1 2 1 2 M1.Col 1 1 2 2 3 3 M1.Value Data 10 11 12 13 14 15 M2.Col 1 1 M2.Row 1 2 M2.Value Data 3 3 M3 M1.Product( M2 ) M3.Row 1 2 3 M3.Col 1 1 1 M3.Value 63 75 87 Class MyClass ID ID-Generator 1 Arg1 Decimal 1 Arg2 Decimal 1 Const Static Decimal 1.2 Out1 Const + 2 * Arg1 + 3 * Arg2 6.2 Out2 Const * Arg1 - Arg2 0.2 Data keyword allows values to be entered in data area Static Data indicates cannot be overridden when instantiated. Data without Static are default values only. Fields will be input (white) Every class has an id. (like the primary Key of a table) ID shown if no field selected, as per Z and W above. Arguments set to columns / vectors so a column of Ojbects created with generated IDs - 1 to 21.
  • 4. NameSpace MathLibrary Class Matrix ID ID-Generator 1 nRows Data 2 nCols Data 2 Row 1 : nRows 1 2 Col 1 : nCols 1 2 Row 1 2 1 2 Col 1 1 2 2 Value Data 0 0 0 0 Row==Col 1 2 Trace Value 0 0 Add Method returns Matrix M2 Argument Matrix 1 Return New Matrix( nRows= This.nRows, nCols= This.nCols) 1 Error_If nRows != M2.nRows Error( "number of Rows must match to add Matricies" ) Error_If nCols != M2.nCols Error( "number of Columns must match to add Matricies" ) Row == M2.Row == Return.Row Col == M2.Col ==Return.Col Return.Value Value + M2.Value Transpose Method returns Matrix Return New Matrix( nRows = This.nCols, nCols=This.nRows) 1 Return.Row == This.Col Return.Col == This.Row Return.Value This.Value Product Method returns Matrix Right Argument Matrix Return New Matrix( nRows= This.nRows, nCols= Right.nCols) Error_If nCols != Right.nRows Error( "number of Columns of left matrix must match number of Rows of Right matrix." ) This.Col == Right.Row Return.Value sum( This.Value * Right.Value ) Fields created within method only visible within method (Privative Errors produced if user tries to add matricies of unmatched dimensions Left, Right, Add automatically joined on Row and Column Due to matching Default values set in class definition can be overwritten.
  • 5. Class Primes Is_Prime Method returns Boolean x Argument Integer 32 i 2 : { i > sqrt( x ) } 1 2 3 4 5 Mod_x x mod i == 0 TRUE TRUE FALSE TRUE FALSE x 1 >1 Return TRUE OR( Mod_x ) Nth_Prime Method returns Integer n Argument Integer 5 i 1: {Count_Primes == n} 1 2 3 4 5 6 7 Count_Primes Is_Prime( i ) + Count_Primes.prev(First=0) 1 2 3 3 4 4 5 Return Last( i ) 7 NameSpace Poker Class Card ID ID-Generator 1 Suit Possible_Values Data 4 Hearts Diamonds Clubs Spades Number Possible_Values Data 13 Two Three Four Five Six Ten Jack Queen King Ace Class Hand ID ID-Generator 1 C New( 5 ) Card 1 2 3 4 5 C.Suit Data Hearts Diamonds Clubs Spades Spades C.Number Data Five Five Five Five Six Four_of_a_Kind count( distict( C.Suit ) ) >= 4 TRUE Three_of_a_Kind count( distict( C.Suit ) ) >= 3 TRUE Pair count( distict( C.Suit ) ) >= 2 TRUE Full_House Count( Distict( C.Suit ) ) >= 2 TRUE Non static Data - set defaults to test formulas
  • 6. NameSpace Chess Class Position D1 Possible_Values 1:8 1 2 3 4 5 6 7 8 D2 Possible_Values 1:8 1 2 3 4 5 6 7 8 Class Queen Pos New Position 1 Pos.D1 Default 6 Pos.D2 Default 4 Cross1 New Position( D1= Pos.D1, D2=1:8 ) 1 2 3 4 5 6 7 8 Cross2 New Position( D2= Pos.D1, D1=1:8 ) 1 2 3 4 5 6 7 8 Diag1 New Position 1 2 3 4 5 6 Diag1.D1 1 + max( 0 ,D2-D1) : 8 - max(0 ,D2-D1) 1 2 3 4 5 6 Diag1.D2 Diag1.D1 + D2 - D1 3 4 5 6 7 8 Diag2 New Position 1 2 3 4 5 6 7 Diag2.D1 max( 1 , x+y - 8 ) : min( 8, x+y-1 ) 2 3 4 5 6 7 8 Diag2.D2 Reverse( Diag2.D1 ) 8 7 6 5 4 3 2 Take_Pos Concat( Cross1 , Cross2 , Diag1 , Diag2 ) 1 2 3 4 29 27 28 29 Take_Pos Concat Cross1 Cross2 Diag1 Diag2 Alternative notation Take_Pos_Col Method Col Argument Integer 7 Take_Pos.D1 == Col Return Distinct( Take_Pos.D2 ) 3 4 5
  • 7. Class 8_Queen Queens New Queen 1 2 3 4 5 6 7 8 Queens.ID 1:8 1 2 3 4 5 6 7 8 Queens.D1 Queens.ID 1 2 3 4 5 6 7 8 X New 8_Queen X.Queens[1].D2 All 1 2 3 4 5 6 7 8 i 2:8 2 3 4 5 6 7 8 X.Queens[i].D2 All ~ X.Queens[1: i-1].Take_Pos_Col(i) X.ID 1 1 1 1 1 1 1 1 2 2 X.Queens.D1 1 2 3 4 5 6 7 8 1 2 X.Queens.D2 * * * * * * * * * * X.ID 1 2 3 4 5 88 89 90 91 92 Pivot 1 2 1 1 4 5 5 5 6 5 4 2 4 7 7 1 1 1 7 3 3 6 3 6 4 5 5 8 8 1 1 1 8 4 8 6 8 8 5 6 4 8 7 2 5 3 8 2 2 2 3 2 4 2 7 6 7 2 4 7 7 7 8 2 8 1 7 1 5 6 3 3 2 6 7 6 3 8 5 3 3 6 6 4 3 5 4 5 X.Queens.D2 X.Queens.D1
  • 8. NameSpace Travelling Salesman Import_Data C:Test.CSV Start_City Hull Hull Hull Leeds Leeds Bath End_City Leeds Bath Slaugh Bath Slaugh Slaugh Time 2.2 3.4 4.2 6.3 4.2 2.2 Start_City_* concat( Start_City, End_City ) 1 1 1 2 2 2 3 4 3 4 End_City_* concat( End_City, Start_City ) 2 3 4 3 4 1 1 1 2 2 Time_* concat( Time, Time ) 2.2 3.4 4.2 6.3 4.2 2.2 3.4 4.2 6.3 4.2 Cities distinct( Start_City_* ) 1 2 3 4 Perms New Permutations( Items = Cities ) Perms All Class Members Perms.Permutation 1 1 1 1 2 23 24 24 24 24 Perms.Item 1 2 3 4 1 2 4 3 2 1 Perms.Permutation 1 1 1 1 2 23 24 24 24 24 Start_City_* == Perms.Item 1 2 3 4 1 2 4 3 2 1 End_City_* == If( Permutation.Next == Permutation, Item.Next, Item.Prev(3)2 3 4 1 3 4 3 2 1 4 Time 2.2 6.3 2.9 9.1 7.5 5.8 1.5 6.3 2.2 4.2 Perms.Permutation 1 2 3 4 5 20 21 22 23 24 Total_Time Sum( Time ) 38.1 18.2 27.1 37.8 1.5 16.7 3.0 22.0 27.0 8.0 Min_Total_Time Min( Total_Time ) 5 Min_Time_Perm Perms.Permutation 13 Min_Time_Perm 13 13 13 13 Perms.Item 2 1 3 4
  • 9. NameSpace Linear Regression Function variance( x ) ( sum( x^2 ) - sum( x )^2 )/ (count(x) -1 ) Function covar( x, y ) ( sum( x*y ) - sum(x)*sum(y) )/ (count(x) -1 ) Function slope( x, y ) covar( x, y ) / variance( x ) Function intercept( x, y ) mean( y ) - mean( x ) * slope( x, y ) Import_Data C:Daily_Temp_Training_Data.CSV Daily_Temp 20 13 19 15 27 18 28 25 13 25 Next_Day_Temp 24 13 23 19 28 21 31 30 13 29 Temp_Slope slope( Daily_Temp, Next_Day_Temp ) 0.55 Temp_Intercept intercept( Daily_Temp, Next_Day_Temp ) 11 Import_Data C:Daily_Temp_Test_Data.CSV Daily_Temp 16 29 15 10 10 10 23 29 20 23 Predicted_Next_Day_Temp Temp_Intercept + Temp_Slope * Daily_Temp 20 27 19 17 17 17 24 27 22 23 NameSpace VaR Attribution Import_Data C:Historical_Simulation.CSV Rate_Schock_ID 1 1 1 1 1 500 500 500 500 500 Trade_ID 1 2 3 4 5 221 222 223 224 225 PandL 26.53 1.89 16.98 49.23 23.90 17.50 45.38 46.61 37.93 45.27 Quantile Data 95% Number_of_Shocks count( Rate_Schock_ID ) 500 VaR_Rank Quantile * Number_of_Schocks 475 Total_PandL sum( PandL ).descending 323.0 321.5 320.3 316.8 313.9 309.4 308.6 308.4 308.2 306.6 Ordered_IDs Rate_Shock_ID 335 405 209 102 409 168 116 138 379 339 Quantile_Schock_ID Ordered_IDs.rank( Q_Rank ) 245 Quantile_Schock_ID 245 Trade_ID 1 2 3 4 5 221 222 223 224 225 Trade_VAR_Attribution PandL 113 133 141 169 140 145 182 139 172 140