/ 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 Netkachov is a Senior Software Developer, currently working in Central London on new generation of energy trading solutions for brokers, traders and exchanges.

Read More

Why not to stay updated if the subject is interesting? Join Telegram channel Alex@Net or follow alex_at_net on Twitter. Or just, use the comments form below.