我有一个功能
(defn f-test [c-width] (format "%-(c-width)s" "boogey"))
当我尝试评估它时会发生这种情况
(f-test 10)
FormatFlagsConversionMismatchException Conversion = c, Flags = ( java.util.Formatter$FormatSpecifier.failMismatch (Formatter.java:4041)
但这就是我要做的事情
(format "%-10s" "boogey")
"boogey "
如何在格式调用中替换c-width?
答案 0 :(得分:2)
试试这个:
(defn f-test
[c-width]
(format (str "%-" c-width "s") "boogey"))