Скачать презентацию APL in Second Gear Does APL have Скачать презентацию APL in Second Gear Does APL have

ecf608573153bfd7ea613bb713798dfd.ppt

  • Количество слайдов: 72

APL in Second Gear APL in Second Gear

Does APL have a future? Does APL have a future?

What’s the point of APL? What’s the point of APL?

Did Ken Iverson invent APL? Did Ken Iverson invent APL?

Did Ken Iverson discover APL? Did Ken Iverson discover APL?

APL Exists in the Mind of the Beholder APL Exists in the Mind of the Beholder

APL is a Tool of Thought But of whose thoughts? APL is a Tool of Thought But of whose thoughts?

APL Big Bang Theory APL Big Bang Theory

(+/V)÷½ V (+/V)÷½ V

What’s the point of APL? What’s the point of APL?

A notation of direct abstraction is possible A notation of direct abstraction is possible

Skip the fluff Keep it simple Cut the crap 1 -to-1 (notion to notation) Skip the fluff Keep it simple Cut the crap 1 -to-1 (notion to notation) Don’t waste my time Trim the fat

The APL Food Chain The APL Food Chain

The Consumer The Consumer

The Business The Business

The Industry Software Expert The Industry Software Expert

The APLer The APLer

The Utility Wizard The Utility Wizard

The APL Interpreter Developer The APL Interpreter Developer

The Operating System Developer The Operating System Developer

The Consumer The Business The Industry Software Expert The APLer The Utility Wizard The The Consumer The Business The Industry Software Expert The APLer The Utility Wizard The APL Interpreter Developer The Operating System Developer

The Invisible Utility Wizard The Invisible Utility Wizard

I don’t buy it. We don’t have a Utility Wizard and we don’t need I don’t buy it. We don’t have a Utility Wizard and we don’t need one. We do just fine.

We already know how to compute an average. We don’t need another method. Our We already know how to compute an average. We don’t need another method. Our method works just fine.

(+/V)÷½ V (Prepare to fall in love again. ) (+/V)÷½ V (Prepare to fall in love again. )

A notation of direct abstraction is possible or Trim the fat A notation of direct abstraction is possible or Trim the fat

First gear: Primitives Second gear: Utilities built on primitives Third gear: Utilities built on First gear: Primitives Second gear: Utilities built on primitives Third gear: Utilities built on utilities And so on.

Given today’s date TODAY (yyyymmdd) and a birthdate DOB (yyyymmdd), what is the age Given today’s date TODAY (yyyymmdd) and a birthdate DOB (yyyymmdd), what is the age of the policyholder?

AGE TODAY AGELAST DOB AGE TODAY AGENEXT DOB AGE TODAY AGENEAREST DOB AGE TODAY AGELAST DOB AGE TODAY AGENEXT DOB AGE TODAY AGENEAREST DOB

Given today’s date TODAY (yyyymmdd) and the contract date POLDAT (yyyymmdd), how many days Given today’s date TODAY (yyyymmdd) and the contract date POLDAT (yyyymmdd), how many days has the policy been in effect?

NDAYS TODAY DATEMINUS POLDAT NDAYS TODAY DATEMINUS POLDAT

Given today’s date TODAY (yyyymmdd), what will be the date (yyyymmdd) in 90 days, Given today’s date TODAY (yyyymmdd), what will be the date (yyyymmdd) in 90 days, 180 days, 360 days?

DATES TODAY DATEPLUS 180 360 90 DATES TODAY DATEPLUS 180 360 90

Format these dates as a 10 -column matrix in mm/dd/yyyy notation. Format these dates as a 10 -column matrix in mm/dd/yyyy notation.

CMAT 'mm/dd/yyyy' FMTDATES CMAT 'mm/dd/yyyy' FMTDATES

Compute the average of a set of numbers V. Compute the average of a set of numbers V.

AVG (+/V)÷½ V AVG (+/V)÷½ V

CGRD SCALE CJUST UIOTAI CMIOTA UNLESS Columnize UNSCALE CSRT UPPERCASE DEB VEC 2 MAT CGRD SCALE CJUST UIOTAI CMIOTA UNLESS Columnize UNSCALE CSRT UPPERCASE DEB VEC 2 MAT DEBM WRAP DIV ZIP DLBM DLBV DTBM DTBV DTZM IF LIOTAI LIOTAN LJUST NMIOTA NUM WORDS RJUST VM

1. Communications 2. User Input 3. Calculations 4. File Handling 5. Reports/output 6. Miscellaneous 1. Communications 2. User Input 3. Calculations 4. File Handling 5. Reports/output 6. Miscellaneous

File Handling: Given a comma-delimited file that looks like the following, read its fields File Handling: Given a comma-delimited file that looks like the following, read its fields (except SS No. ) into a set of APL variables: Policy No. , Date of Birth, Sex, SSNo, Last. Name, Premiums 12614, 03/15/1940, M, 022 -14 -1567, Smith, 103500 12983, 05/30/1937, F, 038 -15 -1129, Jones, 58200

[1] U 0½ 3 0 [2] U U, 1 'C' 'Policy No. ' © [1] U 0½ 3 0 [2] U U, 1 'C' 'Policy No. ' © C=CMat [3] U U, 2 'M' 'Date of Birth' © M=mmddyyyy [4] U U, 3 'C' 'Sex' © C=CMat [5] U U, 5 'X' 'Last Name' © X=Char nest [6] U U, 6 'N' 'Premiums' © N=Numeric [7] F 'C: POLS. CSV' ª D F 1 READFILE U © 1 header record [8] : if Is. Chr D ª zw. Msg 'Unable to read ', F, ': ', D ª 0 ª : endif [9] (PN DOB SEX LAST PREM) ª SEX D , 1 [2]SEX

File Handling: Given a fixed-format file with the following layout, read its fields (except File Handling: Given a fixed-format file with the following layout, read its fields (except SS No. ) into a set of APL variables: Bytes Length Description ------ 1 -8 8 Policy number 9 -18 10 Date of birth 19 1 Sex (M or F) 20 -30 11 Social Security No. 31 -50 20 Last name 51 -65 15 Premiums ($)

[1] U 4 0½ 0 [2] U U, 0 8 'C' 'Policy No. ' [1] U 4 0½ 0 [2] U U, 0 8 'C' 'Policy No. ' © C=CMat [3] U U, 8 10 'M' 'Date of Birth' © M=mmddyyyy [4] U U, 18 1 'C' 'Sex' © C=CMat [5] U U, 30 20 'X' 'Last Name' © X=Char nest [6] U U, 50 15 'N' 'Premiums' © N=Numeric [7] F 'C: POLS. TXT' ª D F READFILE U [8] : if Is. Chr D ª zw. Msg 'Unable to read ', F, ': ', D ª 0 ª : endif [9] (PN DOB SEX LAST PREM) ª SEX D , 1 [2]SEX

File Handling: Save these APL variables in an APL file. File Handling: Save these APL variables in an APL file.

[10] f. TIE 'C: DBSPOLDAT' [11] f. PUT 'PN DOB SEX LAST LNAME PREM' [10] f. TIE 'C: DBSPOLDAT' [11] f. PUT 'PN DOB SEX LAST LNAME PREM' [12] f. UNTIE

Calculations: Sum premiums and the number of policies by year of birth. Calculations: Sum premiums and the number of policies by year of birth.

[5] YR YYYY DOB © yyyy from yyyymmdd [6] YRS NVUNQ YR © Distinct [5] YR YYYY DOB © yyyy from yyyymmdd [6] YRS NVUNQ YR © Distinct years, sorted [7] © Accum Prem and policy Count by year: [8] (PBY CBY) [1]YRS ACCUM YR (PREM, [1. 5]1)

Reports/output: Generate this report, and display it on the screen: Policy Summary Report As Reports/output: Generate this report, and display it on the screen: Policy Summary Report As of 09/22/2009 Number Total Year of Policies Premium $ -----------1940 17 12, 345 1945 302 3, 125, 889 1946 45 55, 013

[5] TODAY 'mm/dd/yyyy' FMTDATE 100 TS 3 [6] TTL Policy Summary Report ' As [5] TODAY 'mm/dd/yyyy' FMTDATE 100 TS 3 [6] TTL Policy Summary Report ' As of ', TODAY, ' ' [7] HDG Year ' Number of Policies Total Premium $' [8] BODY 'I 4' 'CI 10' 'CI 15' FMT¨ YRS CBY PBY [9] WID ¯ 1 ¯ 1 © Widths (¯ 1=del all blanks) [10] T WID TTL HDG BODY zw. Out 1 © 1=Screen [11] : if Is. Chr T ª zw. Msg T ª : endif

Reports/output: build the report as a Word file. Reports/output: build the report as a Word file.

[10] T WID TTL HDG BODY zw. Out 4 © 4=Expl result [11] : [10] T WID TTL HDG BODY zw. Out 4 © 4=Expl result [11] : if Is. Chr T ª zw. Msg T ª 0 ª : endif [12] R RTF T © Convert page to 1 . RTF format [13] : If ×½ R NOPEN F U 'C: REPORT. rtf' [14] zw. Msg 'Unable to build ', F, ': ', U [15] : End. If

Reports/output: build the report as an. xls file. Reports/output: build the report as an. xls file.

[9] 'Sheet 1' XL 'Add. Wkbk' © Build 1 st sheet [10] (8 15 [9] 'Sheet 1' XL 'Add. Wkbk' © Build 1 st sheet [10] (8 15 15) (1 1 1 3) XL 'Col. Wid' © Widths [11] TODAY FMTDATE 100 TS © Today 5 3 (mm/dd/yyyy) [12] © Center (¯ 4108) title in a merged range: [13] TTL 'Policy Summary Report' ('As of ', TODAY) [14] U 1 1, (½ TTL), 1 ª TTL U XL 'Write' [15] 1 U XL 'Bold' ª ¯ 4108 U XL 'HAlign' [16] U 4½ 2 1 1 1 3, 2 1 1 3 ª U XL 'Merge' [17] HDG '' 'Number' 'Total' [18] HDG, [0. 5]'Year' 'of Policies' 'Premium $' [19] U 4 1 2 3 ª HDG U XL 'Write' [20] 1 U XL 'Bold' ª ¯ 4108 U XL 'HAlign' [21] © Write body below col hdgs: [22] U 1, (½ 6 YRS), 3 ª ( [1]YRS CBY PBY) U XL 'Write' [23] U 2, (½ 6 YRS), 2 ª '$#, ##0. 00' U XL 'Format' [24] N 'C: REPORT. xls' [25] G ('Retry' 'Return') XL 'Save. As' N [26] : if ~G ª zw. Msg 'Unable to save file

Communications: Given two. xls files created by other functions, send them as attachments to Communications: Given two. xls files created by other functions, send them as attachments to Fred in Accounting.

[1] X 6½ Ð [2] (1 X) 'Fred, here are today''s files. ' © [1] X 6½ Ð [2] (1 X) 'Fred, here are today''s files. ' © Msg [3] (2 X) 'Daily Activity Files' © Subject [4] (3 X) 'Fred@Acme. com' © To [5] (4 X) 'Gary@Acme. com' © From [6] (5 X) 'smtp. acme. com' © SMTP host [7] (6 X) TIE 1, TIE 2 © Attached file ties [8] : If Is. Chr E SMTP X [9] zw. Msg 'Unable to send email: ', E [10] : End. If

User Input: Present a menu of choices, from which the user is to pick User Input: Present a menu of choices, from which the user is to pick one.

I 'Which color? ' COLORS 0 zmenu I 'Which color? ' COLORS 0 zmenu

User Input: Present a menu of choices, from which the user may pick any User Input: Present a menu of choices, from which the user may pick any number of them.

I 'Which colors? ' COLORS Ð zmenu I 'Which colors? ' COLORS Ð zmenu

User Input: Present a menu of choices, from which the user may pick any User Input: Present a menu of choices, from which the user may pick any number of them. Selected choices are in a list on the right; remaining choices are in a list on the left; Add/Remove buttons are located in between.

I 'Which colors? ' COLORS Ð ARMENU I 'Which colors? ' COLORS Ð ARMENU

User Input: Present a menu of choices, and allow the user to alter their User Input: Present a menu of choices, and allow the user to alter their order by highlighting choices and clicking the Up or Down buttons.

I 'Arrange' UDMENU COLORS I 'Arrange' UDMENU COLORS

User Input: Present the following input form: User Input: Present the following input form:

[1] FR 'Monthly' 'Quarterly' 'Semiannual' 'Yearly' [2] [3] POLNO '12345' ª NAME 'Jones, Thomas' [1] FR 'Monthly' 'Quarterly' 'Semiannual' 'Yearly' [2] [3] POLNO '12345' ª NAME 'Jones, Thomas' [4] DATE 20090131 ª FREQ 1 ª QUAL 0 ª EXEMPT 1 [5] RATE 5. 5 ª SEX 1 [6] [7] U 'CHR_PN' POLNO 'Policy Number' [8] U U, 'CHR_NM' NAME 'Name' ('size' 25) [9] U U, 'DATE_CD' DATE 'Contract Date' [10] U U, 'DDN_FR' FREQ 'Frequency' FR [11] V 1 'VGRP_1' U [12] [13] U 'CHK' (QUAL, EXEMPT) '' ('Qualified? ' 'Tax Exempt? ') [14] U U, 'NUM_TR' RATE 'Tax Rate (%)' [15] U U, 'OPT' SEX 'Sex' ('Male' 'Female') ('style' 'H') [16] V 2 'VGRP_2' U [17] [18] 0 IF 0 ASKINFO 'Policy Form' ('HGRP' T (V 1 V 2)) [19] (POLNO NAME DATE FREQ QT RATE SEX) T [20] (QUAL EXEMPT) QT

Where have we gone wrong? What’s holding us back? Where have we gone wrong? What’s holding us back?

The Consumer The Business The Industry Software Expert The APLer The Utility Wizard The The Consumer The Business The Industry Software Expert The APLer The Utility Wizard The APL Interpreter Developer The Operating System Developer

The solution: a different (gear-two) mindset. The solution: a different (gear-two) mindset.

The APL Interpreter Developer - Coordinates Wizard communication - Plays “librarian, ” not “author” The APL Interpreter Developer - Coordinates Wizard communication - Plays “librarian, ” not “author” - Documents/distributes both gears

The Utility Wizard -Works with APLer - Communicates with other Wizards - Develops utilities The Utility Wizard -Works with APLer - Communicates with other Wizards - Develops utilities

The APLer - Provides feedback to Wizard - Writes APL The APLer - Provides feedback to Wizard - Writes APL

APL in Second Gear, The Future of APL APL in Second Gear, The Future of APL