Intro to Programming Languages

LecLabs 4.2 - functions and lists

[ ← Module List ]

Scheme functions and lists

7 challenges

Challenges

CHALLENGE 01

Lecture 4.2.1.1. Functions

— solves

Lecture video on Functions

CHALLENGE 02

Lab 4.2.1 - String Info

— solves

Objective

Create a scheme program that reads in single word and returns the string info on it

Click Here for Follow Along Video

Requirements

  • Prompt user to "Enter word: "
  • Read the user's input
  • Call string-info and store in a variable
  • Print the stored string information
CHALLENGE 03

Lecture 4.2.2. List Operations

— solves

Lecture video on List Operations

CHALLENGE 04

Lecture 4.2.2.1. Recursion

— solves

Lecture video on Recursion

CHALLENGE 05

Lecture 4.2.3. Higher Order Functions

— solves

Lecture video on Higher Order Functions

CHALLENGE 06

Lab 4.2.2 - String Mangler

— solves

Objective

Create a scheme program that reads in a word and a value. A sub string is created starting from start of string to the index marked by value. The sub string is moved to the end of the string.

Click Here for Follow Along Video

Requirements

  • Prompt user to "Enter a word: "
  • Read the user's input
  • Prompt user to "Enter a number: "
  • Read the user's input
  • Call mangle-word function
    • Use the word and number to return the mangled word
  • Print the stored string information
CHALLENGE 07

Lab 4.2.3 - Damage Calculator

— solves

Objective

Create a scheme script that calculates damage for a fantasy game.

Click Here for Follow Along Video

Requirements

  • Generate the parameters
    • modifier between 1 and +2
    • defense between 1 and 10
    • critical multiplier between 1.0 and 2.5
    • armor reduction factor between 0 and 2
  • Calculate damage
    • Calculate the attack value using roll-die
    • Calculate damage using the following formula
                    ┌                                                           ┐
                    |    ┌  attack-roll * level * Modifier * crit   ┐           |
      damage = max | 0, | -----------------------------------------| - defense |
                    |    └           armor-reduction-factor         ┘           |
                    └                                                           ┘
        
  • Do the damage calc
    • Receives the parameter list (modifier, defense, crtical, armor reduction factor)
    • Calls calculate damage
    • Calls show-data