忙里偷闲,重拾Common Lisp,直接上代码,该代码来源于互联网,看完之后,也许你也会跟着喜欢上Common Lisp了
C代码:
// upper_char_counter.c
int upper_char_counter(const char *str) {
int result = 0;int len = strlen(str);
int i = 0;
while (i < len) {
if (str[i] >= 'A' && str[i] <= 'Z') {
result++;
}
i++;
}
}
Common Lisp代码:
;; upper-char-counter.lisp
(defun upper-char-counter (str)
(count-if #'upper-case-p str))
本文分享了一段从C语言到Common Lisp的编程之旅,通过实际代码对比,展示了两种语言的独特魅力。从字符计数的小任务出发,深入浅出地介绍了Common Lisp的简洁与强大,激发读者对Lisp语言的兴趣。
557

被折叠的 条评论
为什么被折叠?



