--- title: "Pot Pourri" type: "article" slug: "pot-pourri" url: "http://localhost/article/pot-pourri/" markdown_url: "http://localhost/article/pot-pourri.md" published_at: "2022-10-07T12:26:12+00:00" modified_at: "2026-07-27T09:49:08+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "This method of using recursive DEF FN to obtain sums was discussed in a TS Survival column in COMPUTER SHOPPER. It is fast and handy in some applications. 1 REM The method below of using recursive DEF FN to obtain sums was discussed in a TS Survival column in COMPUTER SHOPPER. I don't have the…" category: - name: "LISTing Newsletter" slug: "listing-newsletter" taxonomy: "category" url: "http://localhost/category/periodicals/listing-newsletter/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "Reference" slug: "reference" taxonomy: "post_tag" url: "http://localhost/tag/reference/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" publication_r: id: 38992 title: "LISTing Newsletter" type: "periodical" url: "http://localhost/periodical/listing-newsletter/" authors_r: - name: "Elliott Hammett" slug: "elliott-hammett" taxonomy: "indiv" url: "http://localhost/indiv/elliott-hammett/" issues_articles: - id: 40194 title: "LISTing Newsletter November 1985" type: "issue" url: "http://localhost/issue/listing-newsletter-november-1985/" pages: "21" pubdate: "November 1985" archive_link: false --- # Pot Pourri This method of using recursive DEF FN to obtain sums was discussed in a TS Survival column in COMPUTER SHOPPER. It is fast and handy in some applications. ``` 1 REM The method below of using recursive DEF FN to obtain sums was discussed in a TS Survival column in COMPUTER SHOPPER. I don't have the date,unfortunately, but it is fast and handy in some applications. 2 REM added by E.HAMMETT,CHAPEL HILL,N.C. 9 REM The function below calculates the sum of the first n elements of a linear array 10 DEF FN t(a$,n)=VAL (a$+"(n)"+("+FN t(a$,n-1)" AND n>1)) 11 REM The function below calculates the sum of squares of the first n elements of a linear array 12 DEF FN s(a$,n)=VAL (a$+"(n)*"+a$+"(n)"+("+FN s(a$,n-1)" AND n>1)) 20 DIM v(10): REM set up an array as an example 30 FOR i=1 TO 10: LET v(i)=2: NEXT i: REM put a value in each cell of the array for the example 40 LET sum=FN t("v",10): REM use the function, passing the array name as a string 50 PRINT : PRINT "Sum = ";sum 60 LET sumofsquares= FN s("v",10): REM use the function to obtain squares, passing the array name as a string 70 PRINT "Sum of squares = ";sumofsquares 75 PRINT '"LIST THE PROGRAM TO STUDY THE ";"USE OF USER DEFINED FUNCTIONS TO";"OBTAIN THESE TOTALS." 80 STOP 90 SAVE "recurfn" LINE 1 ```