[Maxima] select all x in L
LindnerW at t-online.de
Wed May 23 16:32:00 CDT 2007
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.
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 defined the helper function
(%i1) select(a,L) := block([LL:], for x in L do if x=a then LL:cons(x,LL),LL)$
(%i3) H(a,L):= length(select(a,L));
which seems ok.
Q1: is there a predefined function 'select' (with another name?) in Maxima
I have overlooked?
Q2: I would like to have a 'more functional and general' version of select.
Does a member of the Maxima community has some hints?
More information about the Maxima