apl\11 1977 runs under Unix version 6 and 7 note that in most versions of apl that the shape of a vector of one element is null and this can not be used in mathematical expressions feb 1977 version ---------------- precompiled binary is used, we are not able to compile it as yet separate executable works (unlike oct 1976 version which core dumps on edit) labels are supported comments inside functions must occur after function definition (first line) no blank lines in functions stty erase ^H do not use avoid hitting backspace use M instead of X for multiply use P instead of % for divide L^HP a returns matrix inverse of a (ctrl-H is not echoed to screen) )clear clears workspace )width 80 set characters per line to 80 )vars list all variables )fns list all functions )edit test edit function test (this also puts function test in memory) note that for this version )edit invokes xed )erase file erase function file from workspace )drop file erase file E 'v { 1 2 3' execute string, e.g. v is set to 1 2 3 epilson will not work as execute on IBM APL2 1 V 0 1 or 0 returns 1 1 /^H= 2 1 not equal 2 returns 1 x { 2 'x = '; x displays x= 2 a { 2; b { 3; c { 4 multiple statements on one line are separated by semi-colons 'this is a ';a;' and b '; b displays this is a 2 and b 3 a { 'cat' variables can be strings of characters 'APPLE'[3] returns 3rd character of APPLE, .e.g P a { 'apple' b { 'string' c { a,' ',b assign c the value of a and b with a space inbetween e.g. c is 'apple string' a { (I10) M .5 same as a=1 to 10 step .5 !3.5 returns 11.6317284 (fractional factorials are permitted) 2 ! 4 choose 2 from 4, i.e. 6 (also known as binomial coefficient) B^HN 20 example of an ibeam, generally B ctrl-H N followed by a number in this case it returns the total number of 1/60 sec intervals since midnight B^HN 21 ??? B^HN 24 ??? B^HN 25 ??? B^HN 28 returns date B^HN 29 returns origin B^HN 30 returns width x { L enter numeric data (L is quad) 'test'; x { L prompts must appear on the same line as quad to work functions --------- average v find average of a vector boxit 'test' display a box around test factors v find all factors of vector fib n generate n terms fibonacci series (modified to work with apl-1977) gcd find the greatest common divisor, e.g. 70 gcd 10 ident generate the identity matrix inverse a find matrix inverse of a where a is a matrix matrix a display a matrix a X a of counting numbers multi a generate multiplication table of a X a (will core dump if array is too big) matrixab a b generates matrix of counting numbers a by b prime works but core dumps if values higher than 70 are used primen n display prime numbers up to n rising compute the rising factorial primei does not work, returns "compress index" fib1 does not work, returns "fetch botch" doesn't have ------------ Lrun Lcr )shell )list xed notes --------- pp print out entire file f display current filename x undelete last deletion oct 1976 version ---------------- must be compiled as a pure executable to work properly labels are not supported, line numbers must be used instead }clear clear workspace } represents right parentheses }drop file erase file }edit test edit function test (this also puts function test in memory) note that for this version }edit invokes ed }erase a erase variable or function a }fns list functions }lib list files in current directory }vars list variables }width 112 set width to 112 }off log out C for comment R for rho E for epsilon D for min (floor) S for max (ceiling) Y for take (up arrow) U for drop (down arrow) M for absolute value or modulus ; is [ ] is ] * is - < is ; > is : - is multiply : is plus " is minus sign = is divide P is power + is ( } is ) % is = [ is assign {3 goto line 3 (the first line after the function header is line 1) +1:1} - 5 this is equivalent to (1+1) X 5 :/ I10 sum the numbers 1 through 10 a [ 1 2 3 assign 1 2 3 to a a [ KappleK assign apple to a a [ I10 a J.- a generate multiplication table b [ a J.- a :/ ,b sum matrix b 3Y a take first 3 elements of vector a a,b concatenate a and b 1 ( 2 1 not equal 2 returns true or 1 -/I5 returns 5 factorial 0 )T 0 0 NOR 0 returns 1 "5 : 1 negative 5 plus 1 returns 4 M "5 return absolute value of negative 5 3Q10 return 3 random numbers from 1 to 10 K^H. 5 return 5 factorial or 120 2 K^H. 5 choose 2 from 5 or 10 (also known as binomial coefficient) this was put into function comb a [ 1 2 3 O^HM a rotate vector a a [ 2 2 R I4 L^H= a return matrix inverse of a E K x [ 1 K execute x=1 N^HB 29 return origin, B^HN 29 will also work (ibeam) functions --------- comb find the binomial coefficient, e.g. 2 comb 5 returns 10 fac x find the factorial of x gcd find the greatest common divisor, e.g. 70 gcd 10 loopit x print apple x times matrixab generates matrix of counting numbers sum sum a vector of numbers a [ loopit x a [ x C loopit x times {+x$0}/0 c[0 c[c:1 {+c%x:1}/0 L [ K apple K {5