codinglawyer / lambdaup-exercises

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exercises

TIP

  • How to show data inside the console: Js.log()

EX 1

  1. Create let binding with simple value like string/int DOC
  2. Basic type - try to type let binding from the previous step DOC
  3. Create a record with several different type string/int/float/bool and try to log into the console DOC
  4. Create an array with string/int elements DOC
  5. Create a tuple and try to destruct it. Show destructed date inside a console DOC
  6. Create a list with some strings, e.g. names or something else DOC
  7. Create basic functions that will do multiplication and sum function DOC
  8. Refactor the previous function and use labeled arguments DOC
  9. Use currying of the prior step DOC

EX 2

  1. Create a variant that will contain Yes/No answer type. Try to assign it to the let binding DOC
  2. Create a constructor variant. Type should hold a few information about a conference like Name, Duration, and City. Each variant should contain type constructor e.g. the name should hold a string DOC
  3. Create a parameterized type. e.g. zone (x,y, radius) that can hold three values, two of them are of the same type, and the last one are different. Result type should be like: list(int, int, string) or list(float, float, bool)
  4. Create the optional type with option and assign to let binding. Use Some and None DOC
  5. Pattern Matching! DOC
    • Create a variant of knowledge level e.g. Low, Medium and High
    • Create a variant of three programming languages that you like
    • Create a function which accepts 2 arguments (knowledge and language) and try to match all cases - if it possible ;)
  6. Create a separate module called Utils for the sum function, try different approaches DOC
  7. Get list/array and try to display each element in the console API
  8. Refactor previous map/iter and use pipe operator and show output in the console API
  9. Try to write functions that solve the factorial algorithm (5! = 5*4*3*2*1 = 120), using recursive and Pattern Matching.

Scripts

Exercise 1

npm run ex1

Exercise 2

npm run ex2

Build

npm run build

Build + Watch

npm run start

About


Languages

Language:OCaml 100.0%