unj*_*nj2 6 lisp scheme functional-programming
我对我的代码的Scheme样式感到困惑.
我应该格式化表格如下:
一个.
if()
()
()
Run Code Online (Sandbox Code Playgroud)
或b.
if () ()
()
Run Code Online (Sandbox Code Playgroud)
或c.
if () () ()
Run Code Online (Sandbox Code Playgroud)
我应该将cond条款格式化为
.
cond ()
()
Run Code Online (Sandbox Code Playgroud)
或b.
cond
()
()
Run Code Online (Sandbox Code Playgroud)
我什么时候使用单身; 评论和双重;;?
要填写Doug针对您的具体问题的答案:
(if test
then
else)
(cond
(test1 exp1)
(test2 exp2)
(else exp3))
Run Code Online (Sandbox Code Playgroud)
或者,对于具有长系列表达式的conds:
(cond
(test1
exp1
exp2)
(else
exp3
exp4))
Run Code Online (Sandbox Code Playgroud)
评论惯例有点宽松.当我编写细致的代码时,我会这样做:
;;; new section ;;;
;;; section comments
(define (f g . x)
"docstring goes here"
;; in-function comments
(g x)) ; trailing line comment
Run Code Online (Sandbox Code Playgroud)
但;vs ;;使用的确切界限各不相同.特别是,有些人(包括我)不太喜欢尾随行注释,而是;用于函数内注释和;;;部分注释.
| 归档时间: |
|
| 查看次数: |
1079 次 |
| 最近记录: |