We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hello World N Times
Hello World N Times
Sort by
recency
|
172 Discussions
|
Please Login in order to post a comment
You can solve it by looping n times and printing "Hello World" in each iteration. This basic print logic is often the first step in learning to code a useful concept for beginners using platforms like EnggTools Engineering Tools.
OCaml: let rec printHWn (n : int) : _ = match n with | 0 -> () | _ -> let _ = print_string "Hello World\n" in printHWn (n - 1)
let () = let n = read_int() in printHWn n
Nice work! You've captured functional well by using sequences instead of traditional loops. The
Seq.iter
is a clean and efficient approach. This mindset in software development emphasizes immutability and higher-order functions, which are core strengths of F# over imperative paradigms like TS and C#. Keep exploring!Scala
I'm learning F# coming from TS and C#
what about this 2 liner? IHMO the beauty of thinking functional is not thinking about for loops but in term of sequences