# haskell
reduce f ac [] = ac
reduce f ac (x:xs) = reduce f (f ac x) xs

main = do
  putStrLn "Hello, World!"
  let prod = reduce (*) 1 [1..5]
  print $ prod

# ocaml                      
let rec reduce f ac lst =
  match lst with
  | [] -> ac
  | x::xs -> reduce f (f ac x) xs

let () =
  print_endline "Hello, World!";
  let prod = reduce ( * ) 1 (List.init 5 (fun x -> x + 1)) in
  print_int prod

# F#
let rec reduce f ac lst =
  match lst with
  | [] -> ac
  | x::xs -> reduce f (f ac x) xs

[<EntryPoint>]
let main argv =
  printfn "Hello, World!"
  let prod = reduce (*) 1 (List.init 5 (fun x -> x + 1))
  printfn "%d" prod
  0 // return an integer exit code

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: