This repository contains two homework assignments (hw1.hs
and hw2.hs
) related to functional and logic programming in Haskell. Each assignment includes a number of tasks implemented as Haskell functions.
- Clone this repository.
- Make sure you have a Haskell compiler installed (such as GHC, the Glasgow Haskell Compiler).
This Haskell script contains several functions showcasing basic functional programming concepts. These functions include:
shiftString
: Shifts the characters in a string.isShiftedForEquLessThanIterationTimes
andisShifted
: Checks if one string is a shifted version of another.stupidListOp
: Performs an operation on a list of integers.getNextLine
andpascalLine
: Generates a line of Pascal's Triangle.toList
,padWithZero
,toDigits
,doubleEveryOther
,sumDigits
,validate
: Implements various operations related to the validation of credit card numbers.
This Haskell script continues to explore functional programming concepts with a different set of functions. These include:
makeDistinctInt
andmakeDistinctString
: Removes duplicate items from a list.multiplyLists
: Multiplies items in a list.listSquares
androundSquare
: Deals with square numbers.twoSqaures
: Finds two squares that sum up to a given prime number.slowSort
: Sorts a list of integers.
To run the Haskell scripts, follow these steps:
- Open a terminal.
- Navigate to the directory containing the Haskell script you want to run.
- Compile the script using the GHC compiler with the command
ghc --make script_name.hs
(replacescript_name.hs
with the name of the script). - Run the compiled file using the command
./script_name
(replacescript_name
with the name of the script without the.hs
extension).
This is an academic project, and contributions are not currently sought. However, the scripts provided can serve as a foundation for anyone interested in learning functional and logic programming in Haskell.
This project is licensed under the terms of the MIT license. Please refer to the LICENSE file for more information.