01. HC1 ‐ Haskell Chapter 1 Practical Tasks: Introduction - wimsio/universities GitHub Wiki

HC1T1 - Task 1: Function Composition

Define three functions:

  1. double: Multiplies a number by 2.
  2. increment: Increases a number by 1.
  3. doubleThenIncrement: Uses function composition to apply double first and then increment.

HC1T2 - Task 2: Pure Function Example

Write a function circleArea that calculates the area of a circle given the radius. Ensure that it’s pure and does not depend on any external state.

HC1T3 - Task 3: Checking if a Number is Greater than 18

Write a function greaterThan18 that checks whether a given number is greater than 18.

HC1T4 - Task 4: Composing a Function to Process Player Data

Write three functions:

  1. extractPlayers: Takes a list of tuples ((name, score)) and extracts the player names.
  2. sortByScore: Sorts the list of players by score in descending order.
  3. topThree: Returns the top three players.
  4. Compose these functions into getTopThreePlayers.

HC1T5 - Task 5: Laziness in Haskell

Create a function infiniteNumbers that generates an infinite list of numbers. Extract only the first n elements.

HC1T6 - Task 6: Using Type Signatures

Define a function addNumbers that takes two integers and returns their sum.

HC1T7 - Task 7: Converting Fahrenheit to Celsius

Write a function fToC that converts Fahrenheit to Celsius.

HC1T8 - Task 8: Higher-Order Functions

Create a function applyTwice that applies a function twice to an input value.

Finished. Congratulations! Get your progress token here