I have quite a complex problem that I have simplified for the purpose of this question.
Let's just say the problem is as follow:
I want a list of the first 3 numbers (1,2,3) added to all of these numbers: 0,10,20
So I want the following desired output:
all = [1; 2; 3; 11; 12; 13; 21; 22; 23]
This is the code I have written:
let r = [0;10;20];;
let r2 = [1..3];;
let rshift value = r2 |> List.map (fun (x)-> x + value)
let all = r |> List.map (fun x-> rshift x)
The actual output is:
val allshift : int list list = [[1; 2; 3]; [11; 12; 13]; [21; 22; 23]]
As you can see, this is a list of a list of ints
, instead of just one long list of int
. How can I get the desired output from above?
Thanks for your help!
There are many ways. Here are some of them:
Print:
Link: https://dotnetfiddle.net/oUpZna