This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

counts number in a list

4 posts · 5577 views

Hi every one

I need a function count numbers in a list for example
(count-numbers '(3 4 5 a b c d 6 ) ) -> 4

Re: counts number in a list

You can use the loop macro (search for a count clause) with a numberp predicate.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

Re: counts number in a list

let, dolist, incf, and numberp would also work.

A recursive helper function could be used to eliminate the let, dolist, and incf; some classes prefer recursive solutions.

Re: counts number in a list

Tnxxxxxxxxxxxxxxxxxxxxxxxx