Question
Given the number types: N for all natural numbers Z for all integers Z+ for all positive integers Q for all rational numbers I for
Given the number types:
N for all natural numbers
Z for all integers
Z+ for all positive integers
Q for all rational numbers
I for all irrational numbers
R for all real numbers
W for all whole numbers
C for all complex numbers
.. and given the following numbers:
p
1
-5
binary number 0b01111111
octal number 0o754
hexadecimal number 0x39
then:
A. 80% Write a simple program that prints true or false given each of the 6 numbers for each of the 8 number types. Do this in SML, SQLite and Forth. (If you recognize just how tedious it is to create these 48 print statements, for each language, then please first see part B, below).
For example, your program will include the following output statements:
in SML:
print -5 is an element of N: true;
print 0b01111111 is an element of N: true;
in SQLite:
SELECT -5 is an element of N: true;
SELECT 0b01111111 is an element of N: true;
in 8th:
-5 is an element of N: true . cr
0b01111111 is an element of N: true . Cr
B. 20% Use a loop, at least in SML or 8th, to produce the print statements in part A. Loops are operations that repeat without you having to explicitly reenter duplicate code. The lines of code for processing collections can be greatly condensed by using loops.
Step 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