F# concatenate int array option to string -
i have data contract (wcf) field defined as:
[<datacontract(namespace = _namespace.ws)>] type commitrequest = { // excluded brevity ... [<field: datamember(name="excludelist", isrequired=false) >] excludelist : int array option }
i want entries in excludelist, create comma separated string (to reduce number of network hops database update status). have tried following 2 approaches, neither of create desired string, both empty:
// logic determine if need execute block works correctly try // use f# concat let strlist = request.excludelist.value |> array.map string let idstring = string.concat ",", strlist // next try using .net join let idlist = string.join ((",", (request.excludelist.value.select (fun f -> f)).distinct).tostring ()) | ex -> ...
both compile , execute neither give me in string. appreciate pointing out doing wrong here.
let intoarray : int array option = [| 1; 23; 16 |] let strlist = intoarray.value |> array.map string let idstring = string.concat "," strlist // don't need comma between params // next try using .net join let idlist = system.string.join (",", strlist) // works
output:
> val intoarray : int array option = [|1; 23; 16|] val strlist : string [] = [|"1"; "23"; "16"|] val idstring : string = "1,23,16" val idlist : string = "1,23,16"
Comments
Post a Comment