/ F#

HR F#: Array Of N Elements

The problem Array Of N Elements requires to write the function that returns N items. The string serialisation of the data structure should be very specific and similar to [ 1, 2, 3 ].

In the previous solutions I've generated the items using sequences. If sequences was allowed, the solution would be trivial: let f n = seq { 1..n }. But the sequences are printed as seq [1; 2; 3] so it is need to be converted to list either with Seq.toList or List.ofSeq.

The solution is:

let f n = seq { 1..n } |> List.ofSeq
Alex Netkachov

Alex Netkachov

Alex likes functional programming and algorithms. Apart from programming, his favourites are walking with his family in the parks and national trails and reading about universe and history.

Read More