• + 0 comments

    OCaml solution

    let rec read_lines acc = try
        let line = input_line stdin in
        read_lines (acc @ [line])
      with End_of_file -> acc;;
    
    let arr = read_lines [];;
    
    let rec rev = function
        | [] -> []
        | h::t -> (rev t)@[h];;
    
    let () =
        List.iter print_endline (rev arr);;