Answered step by step
Verified Expert Solution
Question
1 Approved Answer
**Language is SCHEME** 2. Masahiko Fujiwara showed that 1458 is one of four positive integers (with the trivial case 1) which, when its digits are
**Language is SCHEME**
2. Masahiko Fujiwara showed that 1458 is one of four positive integers (with the trivial case 1) which, when its digits are added together, produces a sum which, when multiplied by its reversal, yields the original number: 1+4+5+8 18 = 18 81-1458 (a) Define a function named (explode x) which converts any positive integer z to a list of single-digit integers (use division by 10 and the floor function). For instance, the expression (explode 12345) would return '(1 2 3 4 5). You may only use cons, car, cdr, functions you wrote in lab or are contained in the lecture slides. You may not use string or char functions (b) Define a Scheme function named (implode 1) which takes a list of digits in base 10 and converts them to an integer (the inverse operation of explode). You may only use cons, car, cdr, functions you wrote in lab or are contained in the lecture slides. You may not use string or char functions. (c) Write a function named (has-property x) which accepts an integer x and returns #t if x has this property and #f otherwise. Test your function with the integer 1458, Feel free to use the sum-list and reverse functions from lecture. (d) Use the find function from Lab 4 to identify two other integers with this property. Hint: 1 is the first integer with this property and 1458 is the third. You are looking for the second and fourth integers with this property. 2. Masahiko Fujiwara showed that 1458 is one of four positive integers (with the trivial case 1) which, when its digits are added together, produces a sum which, when multiplied by its reversal, yields the original number: 1+4+5+8 18 = 18 81-1458 (a) Define a function named (explode x) which converts any positive integer z to a list of single-digit integers (use division by 10 and the floor function). For instance, the expression (explode 12345) would return '(1 2 3 4 5). You may only use cons, car, cdr, functions you wrote in lab or are contained in the lecture slides. You may not use string or char functions (b) Define a Scheme function named (implode 1) which takes a list of digits in base 10 and converts them to an integer (the inverse operation of explode). You may only use cons, car, cdr, functions you wrote in lab or are contained in the lecture slides. You may not use string or char functions. (c) Write a function named (has-property x) which accepts an integer x and returns #t if x has this property and #f otherwise. Test your function with the integer 1458, Feel free to use the sum-list and reverse functions from lecture. (d) Use the find function from Lab 4 to identify two other integers with this property. Hint: 1 is the first integer with this property and 1458 is the third. You are looking for the second and fourth integers with this propertyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started