This document provides an overview of writing programs in the RPAL programming language. It first reviews RPAL's syntax. It then lists several example programs to write, including calculating factorials using different methods, checking for palindromes, adding numbers in a list, removing repeated numbers from a tuple, creating pairs of characters from strings, calculating the inner product of two vectors, and pretty-printing a tree. It notes some variations that could be made to these example programs. The document was prepared by Manuel E. Bermúdez, an associate professor at the University of Florida, for a programming language principles lecture.
This document provides an overview of writing programs in the RPAL programming language. It first reviews RPAL's syntax. It then lists several example programs to write, including calculating factorials using different methods, checking for palindromes, adding numbers in a list, removing repeated numbers from a tuple, creating pairs of characters from strings, calculating the inner product of two vectors, and pretty-printing a tree. It notes some variations that could be made to these example programs. The document was prepared by Manuel E. Bermúdez, an associate professor at the University of Florida, for a programming language principles lecture.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online from Scribd
This document provides an overview of writing programs in the RPAL programming language. It first reviews RPAL's syntax. It then lists several example programs to write, including calculating factorials using different methods, checking for palindromes, adding numbers in a list, removing repeated numbers from a tuple, creating pairs of characters from strings, calculating the inner product of two vectors, and pretty-printing a tree. It notes some variations that could be made to these example programs. The document was prepared by Manuel E. Bermúdez, an associate professor at the University of Florida, for a programming language principles lecture.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online from Scribd
1. Factorial: 1. Bottom-up (classic) 2. Top down. 3. Top-down, counting from 1 to n, 4. Bottom-up, counting from 1 to n. 2. Palindrome (classic) 3. Add up numbers in a list. Variation: find smallest one.
Let's Write a Few Programs (contd)
4. Remove repeated numbers from a tuple. 5. Create pairs of characters from two strings. P('abc','def')=('ad', 'be', 'cf') 6. Inner product of two vectors: IP( (1,2,3), (1,2,3)) = 14
Let's Write a Few Programs (contd)
7. Pretty-print a tree. Recursively build a string. NOTE: parentheses required ! Variation 1: structure the program using 'lets'. Variation 2: print the number of children for each node.