Writing RPAL Programs
Writing RPAL Programs. Programming Language Concepts Lecture 13. Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida. Writing RPAL Programs. First, review RPAL's syntax. Let's Write a Few Programs. Factorial: Bottom-up (classic) Top down.
Writing RPAL Programs
E N D
Presentation Transcript
Writing RPAL Programs Programming Language Concepts Lecture 13 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida
Writing RPAL Programs • First, review RPAL's syntax
Let's Write a Few Programs • Factorial: • Bottom-up (classic) • Top down. • Top-down, counting from 1 to n, • Bottom-up, counting from 1 to n. • Palindrome (classic) • Add up numbers in a list. • Variation: find smallest one.
Let's Write a Few Programs (cont’d) • Remove repeated numbers from a tuple. • Create pairs of characters from two strings. P('abc','def')=('ad', 'be', 'cf') • Inner product of two vectors: IP( (1,2,3), (1,2,3)) = 14
Let's Write a Few Programs (cont’d) • 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.
Writing RPAL Programs Programming Language Concepts Lecture 13 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida