F:# comment imprimer la liste complète Console. WriteLine) imprime seulement les trois premiers éléments)

Mots clés : listf#list

meilleur 4 Réponses F:# comment imprimer la liste complète Console. WriteLine) imprime seulement les trois premiers éléments)

vote vote

93

> printfn "%A" [ 1 .. 5 ];;  // Full list using F# formatting  [1; 2; 3; 4; 5]  > printfn "%O" [ 1 .. 5 ];;  // Using ToString (same as WriteLine) [1; 2; 3; ... ] 
Console.WriteLine(sprintf "%A" list) 
vote vote

87

[1;2;3;4;5] |> Seq.iter (fun x -> printf "%d " x) 
[1;2;3;4;5] |> Seq.iter (printf "%d ") 
vote vote

70

[<StructuredFormatDisplayAttribute("PP {PrettyPrinter}")>] type Foo(a:string array) =   let pp = Array.mapi (fun i (s: string) -> sprintf "{idx: %d len: %d contents: '%s'}" i s.Length s) a   member x.PrettyPrinter = pp  > let foo = Foo [|"one";"two";"three"|];; val foo : Foo =   PP [|"{idx: 0 len: 3 contents: 'one'}"; "{idx: 1 len: 3 contents: 'two'}";        "{idx: 2 len: 5 contents: 'three'}"|]  > printfn "%A" foo;; PP [|"{idx: 0 len: 3 contents: 'one'}"; "{idx: 1 len: 3 contents: 'two'}";      "{idx: 2 len: 5 contents: 'three'}"|] val it : unit = () 
vote vote

61

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 

Questions similaires