re: Top 10: JS Compilables VIEW POST

VIEW FULL DISCUSSION
 
let rec fibonacci = fun(n) => switch n {
  | _ when (n < 2) => 1
  | _ => (fibonacci (n - 1)) + (fibonacci (n - 2))
};

for (x in 1 to 10) {
  Js.log(fibonacci(x));
}

to

let rec fibonacci = n =>
  switch (n) {
  | 0 | 1 => 1
  | n => fibonacci(n - 1) + fibonacci(n - 2) 
  }

for (x in 1 to 10) {
  Js.log(fibonacci(x));
}


is a better example

code of conduct - report abuse