ClearAll[fun]
Options[fun] = {key -> "k", val -> ""};
fun[OptionsPattern[]] := {OptionValue[key]-> OptionValue[val]}
fun[key -> "k", val -> "v"]
(* {"k" -> "v"} *)
fun[val -> #] & /@ {1, 2, 3}
(* {{"k" -> 1}, {"k" -> 2}, {"k" -> 3}} *)
MapThread[fun[key -> #1, val -> #2] &, {{"x", "y", "z"}, {1, 2, 3}}]
(* {{"x" -> 1}, {"y" -> 2}, {"z" -> 3}} *)
How is it possible to make fun Listable and get the same results
It seems I am missing something basic here, and I cannot find a relevant answer.
fun[key -> {"x", "y", "z"}, val -> {1, 2, 3}]
to return the same thing as your last output and whether this could be achieved with the attributeListable
onfun
? $\endgroup$