Comma quibbling: Difference between revisions
Content deleted Content added
Line 1,246:
val it : string = "{ABC, DEF, G and H}"</lang>
===or Another===
====The Function====
<lang fsharp>
let quibble quibbler quibblee = Seq.zip quibblee quibbler //Sorry, just too good a line to miss, back in my Latin classes
</lang>
let fN=List.mapi(fun n _->match n with 0->"" |1-> " and " |_->", ") n |> List.rev▼
====The Task====
printf "{"; List.iter2(printf"%s%s") n fN; printfn "}"▼
<lang fsharp>
printf "{"; fN ["ABC"; "DEF"; "G"; "H"] |> Seq.iter(fun(n,g)->printf "%s%s" n g); printfn"}"
printf "{"; fN ["ABC"; "DEF"; "G"] |> Seq.iter(fun(n,g)->printf "%s%s" n g); printfn"}"
printf "{"; fN ["ABC"; "DEF"] |> Seq.iter(fun(n,g)->printf "%s%s" n g); printfn"}"
printf "{"; fN ["ABC"] |> Seq.iter(fun(n,g)->printf "%s%s" n g); printfn"}"
</lang>
{{out}}
|