【发布时间】:2013-12-13 13:58:11
【问题描述】:
我想给 printf 函数一个元组:
let tuple = ("Hello", "world")
do printfn "%s %s" tuple
这当然行不通,编译器首先说,它需要string 而不是string*string。我是这样写的:
let tuple = ("Hello", "world")
do printfn "%s %s" <| fst tuple
然后编译器合理地注意到现在我有string -> unit 类型的函数值。说得通。我会写
let tuple = ("Hello", "world")
do printfn "%s %s" <| fst tuple <| snd tuple
它对我有用。但我想知道,是否有任何方法可以做得更好,比如
let tuple = ("Hello", "world")
do printfn "%s %s" <| magic tuple
我的问题是我无法得到 printf 需要哪种类型才能打印两个参数。
magic 函数是什么样的?
【问题讨论】: