Question: create your own functional programing language, namely Func. You will not parse a source code or semantically check it since those will be covered in

create your own functional
programing language, namely Func. You will not parse a source code or semantically check
it since those will be covered in the Programming Languages of the Compiler course. You will
create the language objects within the Java main method and execute it in the main method. In
this project, you will define an abstract class which defines a basic statement where subclasses
of this class will be constant literals, variables (char, string, int, double, boolean), code
statements (unary or binary arithmetic operations, conditionals), functions (which can call
themselves), and built in functions such as print (prints to the console). Exclude arrays and loops
(for or while) in your Func design since a loop can be obtained using recursion.
In short, you will implement your own simple functional programing language in Java using Object
Oriented Programming (OOP). Expression Tree
remarks:
Functions in Func are first-class citizens, meaning they can be passed as arguments
to other functions, returned as values from functions, and assigned to variables.
In Func, data is immutable, meaning once created, it cannot be changed.
Func uses functions, where their return value is determined only by its input values.
This is because Func focuses on operations like arithmetic computations and
conditional expressions.
Func supports recursion, a fundamental concept in functional programming,
allowing functions to call themselves. Recursion is a common strategy in functional
languages for looping or iterating over data.
In Func, every construct is an expression that returns a value.
Func includes support for basic data types and operations, allowing it to focus on the
computation aspects typical of functional programming, where the complexity lies more
in the composition of functions than in sophisticated data manipulation.
For a Func code constructed as the objects in Java main method, your Func
implementation should be able to show it is an actual code (as string).
In the project presentation, you will explain your design, show example Func programs to
demonstrate the capabilities of your design and implementation.
Example Func codes (code as string):
func add(x, y)
{
x + y
}
func max(x, y)
{
if (x > y){
x
} else {
y
}
}
func factorial(n)
{
if (n ==0){
1
} else {
n * factorial(n -1)
}
}
print(add(5,3)) print(max(-5, add(1,3))) print(factorial(5))
Console
8
Console
4
Console
120

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!