LecLabs 4.2 - functions and lists


Intro to Programming Languages.

[ ← Module List ]

Scheme functions and lists


Challenges

Lecture video on Functions

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

Lecture video on List Operations

Lecture video on Recursion

Lecture video on Higher Order Functions

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

Objective

Create a scheme script that calculates damanage 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
    • Calcualte 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

30-Day Scoreboard:

This scoreboard reflects solves for challenges in this module after the module launched in this dojo.

Rank Hacker Badges Score