select all x in L



On Wed, May 23, 2007 at 09:32:00PM +0000, Wolfgang Lindner wrote:
> dear group,
> 
> currently we (me and my students) are studying a book on elementary probability theory
> (with use CAS DERIVE as assistent) and are porting some of the code to (wx)Maxima 5.12.
> Some of the basic concepts we will define ab ovo, before we will switch to Mario
> Riotorto's massive application package 'descriptive.mac' in order to draw histograms etc.

Nice plan. I'm glad to see people using maxima in education.

> One early problem is to define the 'frequency of a in list v_'.
> The Derive code is:
>                      H(a, v_) := DIM(SELECT(x = a, x, v_))

I think you want length(sublist(v_,lambda([x],is(equal(x,a)))))

see docs on sublist, it's a general way to pick out items in a list.

is(equal(...)) is a way of comparing based on mathematical equality,
rather than say exact matching of terms.

-- 
Daniel Lakeland
dlakelan at street-artists.org
http://www.street-artists.org/~dlakelan