METU CENG242 Hw3 Solution

The problem statement and input outputs are here
The task was to implement a QuadTree
The good thing about functional languages is that when you have a specification, writing the code is trivial and extremely fun
Also unlike programming in languages like C, performance is not a worry, rather than performance, style and practicality of the program matters
I [...]

A function that returns the show function for a given type of argument

The question was: “Can we write a function in Haskell, which takes a formal parameter of any type, and returns the ’show’ function for the type of the argument?” Cem Bozşahin
Answer is:

f x=b
where
[...]

METU CENG242 Hw3 Input Output

Problem Statement
Some of the input outputs in raw form
Inputs:

a=(new 10)
b=(negate (new 10))
c=insert ((2,3),(8,9)) (new 10)
d=delete ((5,5),(5,5)) (delete ((8,1),(9,8)) (negate (new 10)))
[...]

METU CENG242 Haskell HW2

Problem Statement
The Code
Hw2_Data
The task is to implement dynamic binding for function calls.
Returning error outputs is a little bit tricky.
Other than that, fullfilling requirements is not so hard with functional programming.
When a new function call (CallFunc) comes, the scopes list is updated with that functions own declerations.
When that function call ends, our own scope list is [...]

Functions in Haskell (Basic)

a :: Int
a = 5
add5 :: Int -> Int
mul5 :: Int -> Int
op5 Int -> Int -> Int
add5 x = x + a
mul5 x = x * a
add5 = add5 . mul5

This code briefly puts how variables and functions are defined in Haskell
Int -> Int -> Int : The first two “Int”‘s are inputs, [...]

METU CENG242 Haskell HW1

Homework PDF
Solution
Wish i could spend more time on it rather than earning money by playing poker delusion
The task is to write a Haskell program to convert an arithmetic tree to an infix expression
Here is my code:

data Tree = Empty | Leaf Char | Branch Char Tree Tree deriving Show
op = ['*','/','-','+']
val = [1,1,2,2]
retval (x:xs) (y:ys) [...]

Hello Haskell

main=putStrLn "Hello World!"

The hello world

fac 0 = 1
fac n = fac (n-1) * n
main = print(fac (100) )

And the factorial program