#Code style question

1 messages · Page 1 of 1 (latest)

fierce vault
#

do y'all ```ocaml
let rec foo a b =
if break_cond
then []
else c :: (foo d e)

or ```ocaml
let foo a b =
  let rec loop acc c =
    if break_cond
    then List.rev acc
    else loop (d :: acc) e
  in
  loop [] f
tranquil turtle
#

this is less of a code style question and more of a "do you want your function to be tail recursive" question

#

also, your first example is incorrect, you are missing a rec after let

fierce vault
#

oops yeah let me fix that

dense swallow
#

You can also look into tail recursion mod cons