’.’ And ’#’ With Help Of These Signs You Will Now Develop A Small Module With Functions To Create And Manipulate Pictures - IT Computer Science Assignment Help

Download Solution Order New Solution

Assignment Task

Introduction

The purpose of this laboration is to give you further training to develop a series of functions, with focus on recursive functions and higher order functions, and to put together a module of your own functions. You will also in this laboration get help with which functions that you shall create and in which order. This laboration treats a simple kind of so called ASCII-art, where you use signs in order to create pictures or patterns. In this simple kind of application you will only use two signs, ’.’ And ’#’. With help of these signs you will now develop a small module with functions to create and manipulate pictures, and also a program that uses this module to create something beautiful/funny/ interesting.

 

Assignments

Below describes functions and other code elements that you will create in the laboration. There are often more than one way to solve an assignment on. In some assignments you get to choose strategy yourself, and in some assignments you have to use a certain construction, or even define a function in several ways.

 

Assignment 1

To make the code simpel and clear we shall define a ”type alias” Picture for the picture. A picture will be a list of lists of signs, where we will write the inner lists as strings, for example when we create the picture entitled star:

Define a type alias for Picture.

 

Assignment 2

Above is a picture you can test your functions on. Upload this picture in a separate file (named Pictures.hs) as a module, so that you can import them to your program.

 

Assignment 3

In order to have fun with this picture we need a function that prints them out on the screen. We haven’t read about I/O yet, so this function is given:

printPicture :: Picture -> IO ()

printPicture = putStr . concat . map (++”\n”)

Give a description in words how concat and map works together.

 

Assignment 4

The first way we shall manipulate a picture is to turn it, both horizontally and vertically. Remember to try your functions by controlling that two turns with the same function returns the same picture.

Define the function flipH, with signature, that horizontally turns a picture. Consider carefully on which manipulation of the lists in the representation of the picture that needs to be done in order to accomplish this and keep it as compact as possible.

Define the function flipV, with signature, which is mirroring the picture vertically.

The function flipL you are to implement in 3 different ways:

  1. with list comprehension
  2. with recursion
  3. with at least one higher order function.

 

Assignment 5

It is now time to create a function which inverts a picture, aka, exchanges all ”.” For ”#” and vice versa.

Begin with creating a function invertChar, with signature, that inverts a sign.

Then create the function invertPicture in two different ways, by using list comprehensions, recursion and/or higher order functions.

Test your different implementations of functions carefully and see that they achieve the exact same thing.

 

Assignment 6

Another way to manipulate a picture is to combine them. Imagine that we place a picture on another picture where the ”.” Sign is transparent, which means that if there’s two ”.” On the same place in the pictures the resulting sign is ”.” There, and in all the other cases it’s a ”#” sign.

Firstly, form a function superimposeChar, that implements the rule above regarding the signs.

Then use this function to create the function superimpose with signature.

Superimpose :: Picture -> Picture -> Picture, which puts a picture on another picture.

Hint: by using zipWith you can get a very compact solution, but you can also solve the assignment with recursion (then it can be fit to use the help function ”superimposeLine”).

 

Assignment 7

In this assignment you are to create two functions that lets you create bigger pictures by placing two pictures next to each other, sideways (function (sideBySide)) respectively on the hight (function ”above”).

If the two pictures given as arguments to the function sideBySide have a different hight, the resulting picture have the same hight as the smaller picture, the excessive lines on the bigger picture shall be removed. The width will of course be the sum of the width of the two pictures.

In the same way the lines hight should be removed, if necessary, be chopped off when using the function ”above”. The hight on the new picture is always the sum of the height of the the pictures.

Create these functions in whichever way you want, but strive to be as simple as possible.

 

Assignment 8

In this assignment you shall create functions that stretches out the pictures, horizontally (function ”stretchH” and vertically (function ”stretchV”). These functions has the signatures:

StretchV :: Picture -> Int -> Picture

StretchH :: Picture -> Int -> Picture

Which also takes an integer as input. This number tells the factor which the pictures are to be stretched out with. Factor 2 in horizontally, means the picture will be twice as broad (each sign is doubled on the rows). Whilst the factor 2 vertically, means the picture will be twice as high (every row is doubled). Define these functions recursively.

Finally create the function scale, which scales a picture in sideway and on the hight, with a given factor. The signature is:

Scale :: Picture -> Int -> Picture. 3

 

This IT Computer Science Assignment has been solved by our IT Computer Science Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing Style. Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered.

You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turn tin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.