F#: how to print full list (Console.WriteLine() prints only first three elements)

前端 未结 4 1384
梦谈多话
梦谈多话 2021-01-31 15:20

Is it possible to print full list without using cycle? I tried:

Console.WriteLine([1;2;3;4;5])

and it prints only three first elements:

4条回答
  •  再見小時候
    2021-01-31 16:03

    A perhaps more functional way of doing it:

    let nums = [1;2;3;4;5;6]
    let concat acc x = acc + " " + (string x)
    let full_list = List.fold concat "" nums
    printfn "%s" full_list
    

提交回复
热议问题