Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 1.02 KB

readme.md

File metadata and controls

42 lines (34 loc) · 1.02 KB

Demo code for Lift-Up Conditional Introduction learning hour

Those code examples in different language are companion code for the Lift-Up Conditional introduction learning hour.

How to use this example

During the concept part 2, you can use this code to demonstrate the Lift-Up conditional technique to move the if(b) condition at the beginning of the function.

Example in OCaml

Initial code

let liftUpConditional a b =
  if a then 
    if b then 
        "ATrueBTrue"
    else
        "ATrueBFalse"
  else
    if b then 
        "AFalseBTrue"
    else
        "AFalseBFalse"

should be safely transformed like this with the Lift-Up conditional technique.

let liftUpConditional a b =
  if b then 
    if a then 
        "ATrueBTrue"
    else
        "AFalseBTrue"
  else
    if a then 
        "ATrueBFalse"
    else
        "AFalseBFalse"