Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以写一个这样的函数
(define (bool-num x) (if x 1 0)) (define (cnt-true lst) (foldl + 0 (map bool-num lst)))
但我发现并不优雅,因为球拍有一个count功能 and false?,但没有true?
count
false?
true?
所以我可以计算错误元素的数量:
(count false? lst)
有什么我想念的吗?
您正在寻找程序identity:
identity
(count identity '(#t #f #t #t #f)) => 3 (count identity '(1 2 #t #f #f 9)) => 4
这是我将用来创建投票的片段。有没有一种简单的方法可以让这些问题在每次访问时随机出现?我想把它放在某种 PHP 或 javascript 数组中。有人可以指点我一个很好的教程来学习如何做到这一点吗?
<div id="pollWrap"> <form action="inc/functions.php?action=vote" method="post" name="poll