(format t "line~p: ~:*-6ren">
gpt4 book ai didi

clojure - cl-format 重用之前的参数

转载 作者:行者123 更新时间:2023-12-02 13:39:43 25 4
gpt4 key购买 nike

有没有办法避免使用cl-format在下一行中重复1

(cl-format true "line~p: ~d\n"1 1)

最佳答案

CL-USER> (format t "line~p: ~:*~d~%" 1)
line: 1
NIL
CL-USER> (format t "line~p: ~:*~d~%" 2)
lines: 2
NIL

(还有 ~n@* 可以转到第 n 个参数。)

22.3.7.1 Tilde Asterisk: Go-To

The next arg is ignored. ~n* ignores the next n arguments.

~:* backs up in the list of arguments so that the argument last processed will be processed again. ~n:* backs up n arguments.

[…] ~n@* goes to the nth arg, where 0 means the first one; n defaults to 0, so ~@* goes back to the first arg. Directives after a ~n@* will take arguments in sequence beginning with the one gone to.

关于clojure - cl-format 重用之前的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37668392/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com