CCV-GFSU / Events

Events related content by Club for Cyber Vigilance. A central point to access all the resources related but not limited to our tech talks and expert sessions.
0 stars 1 forks source link

Functional Programming using OCaml #7

Closed sanchitgupta654 closed 5 years ago

sanchitgupta654 commented 5 years ago

Title

A new Trend: Functional Programming using OCaml

Abstract

This idea of this session would be to provide everyone with an essence of Functional Programming
Functional programming is strict abouts its syntax, is easy to read and debug, uses concept of function with in a function and modularity, the code doesn't take much space and has gained huge pride and popularity in Security and banking related fields recently.

This topic covers vast veriety of topics ranging from lists, dinctionaries, Data structures to networking etc. However I wont be going that deep into the topic beacuse moving from OOPs mind to function programming concept is rather one of the biggest challenge.

My idea would be to explain everyone mainly through practicals about how to code using OCaml as this language had been a stack for Facebook, Youtube, Instagram, Google etc.

Topics I would cover:
Theory:

  1. What is Functional Programming
  2. Why Functional Programming
  3. Is Functional Prgramming easy?
  4. Scope

Practicals:

  1. Simple Functions
  2. Pattern Matching - If
  3. Diving into the world of Lists
  4. Recursion
  5. Glance at Data Structures.
  6. Exercise for the Audience.

Teaser of OCaml code:

Fnding last element in a list:

val findLast : 'a list -> 'a option = <fun>
let rec findLast ls = match ls with
| [] -> None
| [x] -> Some x
| x :: xs -> findLast xs;;

Quick Sort:

let rec findbigger ele ls = match ls with
    | [] -> []
    | [x] -> if (ele < x) then [x] else []
    | x :: xs -> if (ele < x) then x :: (findbigger ele xs) else (findbigger ele xs)

let rec findsmaller ele ls = match ls with
    | [] -> []
    | [x] -> if (ele >= x) then [x] else []
    | x :: xs -> if (ele >= x) then x :: (findsmaller ele xs) else (findsmaller ele xs)

let rec qsort = function
    | [] -> []
    | [x] -> [x]
    | x :: xs -> let smaller = findsmaller x xs in
             let bigger = findbigger x xs
             in (qsort smaller)@[x]@(qsort bigger)

Time

This should take somewhere near about 40 - 50 mins approx.

Special Requirements

If you have any special requirements or environment setup that you want the audience to have then please
state that here in bullet points.

Link to Slides/Content/References

Getting ready with: https://try.ocamlpro.com/ for practical in the class .. in case the internet doesn't work in the auditorium. The above link has to be opened just once after that one can switch of the internet as it won't be required after the URL has been loaded succesfully.

About Yourself

I'm Sanchit Gupta pursuing my M.Sc. in DFIS from GFSU. I have recently completed my B.Sc. in Aritificial Intelligence and Computer Science with majors in Robotics from The Univeristy of Birmingham United Kingdom.

gaurav-gogia commented 5 years ago

Looks good!