[SOLVED] Programming Paradigms Lab 8-Lazy evaluation in Haskell

30.00 $

Category: Tags: , , , , ,
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Lab8-n6pib7.zip (44.9 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

Programming Paradigms

Lab 8. Lazy evaluation in Haskell

Outline

  • ●  Side-scrolling game
  • ●  Rotating background
  • ●  Working with an infinite universe
  • ●  Generating random infinite universe

A starry background

Exercise 6.1.

Use the following code snippet and add some stars to background picture. https://code.world/haskell#P2vslEkap0OnUffMXjkd7tg

Exercise 6.2.

Improve on exercise 6.1 by introducing an explicit list of star positions and a function that generates a background with a given arrangement of stars.

Rotating backgrounds

Exercise 6.3.

Introduce two variations of background with different arrangements of stars. The backgrounds should rotate: start with background 1, then next should be background 2, then background 1, then again background 2, etc.

Exercise 6.4.

Add a list of star arrangements to the state of the game. Render those as consecutive backgrounds. Do not forget to update the list when a background flies too far into the past.

An infinite universe

Exercise 6.5.

Define an infinite list of star arrangements and use it in the game state. Make sure to use only a finite portion for rendering.

Exercise 6.6.

Define a function chunksOf :: Int -> [a] -> [[a]]
that splits a list into chunks (of given size) of consecutive elements.

An random universe

Exercise 6.7.

Use the functions randomRs and mkStdGen (from System.Random) to generate an infinite list of random star positions.

Exercise 6.8.

Generate an infinite universe without repeating backgrounds.

  • Lab8-n6pib7.zip