/OCamlMadeEasy

Trying to add additional features to the language of OCaml such as array Indexing, etc

Primary LanguageOCamlMIT LicenseMIT

OCamlMadeEasy

OCaml GitHub Actions

Trying to add additional features to the language of OCaml such as array Indexing, etc

How to clone this repository?

Windows:

  1. Make sure you have git installed and running before continuing with the following steps
  2. Open your terminal or Command prompt
  3. Type in:
git clone https://github.com/adwii-iii/OCamlMadeEasy.git

MacOS:

  1. Since git is usually pre installed with Mac, you can skip step one
  2. Open terminal
  3. Type in:
git clone https://github.com/adwii-iii/OCamlMadeEasy.git

How to run the tests using Dune?

Windows and Mac OS

  1. Make sure you have OCaml and Dune installed
  2. Run the command:
dune build
  1. Followed by:
dune exec ./test.exe
  1. You should see that all the tests pass if the libraries are indeed in order
  2. To cleanup, run:
dune clean

What is included in the repository?

Algorithms

Here, I try to add algorithms that are implemented in conventional OOP programming languages

Here are some of the algorithms you can find in the algorithms folder:

  1. Insertion Sort
  2. Bubble Sort
  3. Merge Sort

ArrayModules

This folder contains the below files:

  1. ArrayIndexing.ml
  2. ArrayTuples.ml

Array Indexing

This file contains some basic array Indexing

Below are the functions in this file:

  1. GetPlace
    Remember that this function indexes spaces before the elements and not elements themselves

    This function takes two arguments, a list and an index where you want to access the list at and splits it into a tuple of two lists, ie a list before the given index and a list after the given index

    For example: getPlace [1;2;3;4] 2
    would give ([1;2], [3;4]) as the output

  2. Collapse
    This function takes an argument of the previously defined custom type o 'a place and then turns it back into the original list

    For example: getPlace [1;2;3;4] 2
    would give ([1;2], [3;4]) as the output, then passing it to collapse in such a manner: getPlace [1;2;3;4] 2 |> collapse
    would give back [1;2;3;4;]

  3. IsStart and IsEnd
    This function takes an argument of the previously defined custom type o 'a place and then checks if the index that the user has inputted is either the starting index or if it's the ending index

    For example: getPlace [1;2;3;4] 0 |> isStart
    would give True as the output

    getPlace [1;2;3;4] 0 |> isEnd
    would give False as the output

  4. Next and Lookup
    Next is a function that is used to show you the list when the index is at the given user index + 1, while lookup gives the element at index + 1

    For example: getPlace [1;2;3;4] 2 |> next
    would give ([1;2;3], [4]) as the output

    getPlace [1;2;3;4] 2 |> lookup
    would give 3 as the output

  5. Delete and Insert
    Delete is a function that deletes the element after the given index, and Insert insert's an element before the given index

    For example: getPlace [1;2;3;4] 2 |> delete
    would give ([1;2], [4]) as the output

    getPlace [1;2;3;4] 2 |> insert 7
    would give ([1;2;7], [4]) as the output