This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Now please implemen t an RPAL function called "power” to achieve the same functionality. For example (power 3 2) returns the same v alue as (2**3), which is 8. Your function should use the fact that x2n = ( x 2 ) n to reduce the number of multiplications required. You are not allowed to use "**" operator in the function. (Note: Please submit a separate “ p3.rpal" with your function for Problem 3. Your "p3.rpal" should be able to pass the RPAL interpreter. It may help a lot if you try your function in a RPAL interpreter before you hand it in) 4. Problem 4 (25 Points) Implemen t a function "merge" which takes two lists of numbers in increasing order and merges them into one list of numbers in increasing order. For example, merge((1,3,4,7),(2,4,6,7,8)) = (1,2,3,4,4,6,7,7,8). Test your program in an interpreter (No need to submit a .rpal file) 2...
View Full Document
- Fall '08
- abstract syntax tree, RPAL, Language Principles Homework, RPAL string-to-tree-transduction grammar