Trying to add additional features to the language of OCaml such as array Indexing, etc
- Make sure you have git installed and running before continuing with the following steps
- Open your terminal or Command prompt
- Type in:
git clone https://github.com/adwii-iii/OCamlMadeEasy.git
- Since git is usually pre installed with Mac, you can skip step one
- Open terminal
- Type in:
git clone https://github.com/adwii-iii/OCamlMadeEasy.git
- Make sure you have OCaml and Dune installed
- Run the command:
dune build
- Followed by:
dune exec ./test.exe
- You should see that all the tests pass if the libraries are indeed in order
- To cleanup, run:
dune clean
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:
- Insertion Sort
- Bubble Sort
- Merge Sort
This folder contains the below files:
- ArrayIndexing.ml
- ArrayTuples.ml
This file contains some basic array Indexing
Below are the functions in this file:
- 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 - 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;]
- 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 giveTrue
as the output
getPlace [1;2;3;4] 0 |> isEnd
would giveFalse
as the output - 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 give3
as the output - 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