Close
Close window
Occurrences - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.
Maplesoft logo
Maplesoft logo

Online Help

All Products Maple MapleSim


[フレーム] [フレーム]

ListTools

Occurrences

number of occurrences in a list

Calling Sequence

Occurrences(x, L)

Occurrences(x, L, f, opts)

Parameters

x

-

anything

L

-

list

f

-

(optional) boolean valued procedure

opts

-

(optional) extra arguments to procedure f

Description

The Occurrences(x, L) command returns the number of entries in the list L which equal x using a boolean comparison.

If a function f is provided, equality is tested using f(x, L[i], opts) for each element Li in the list.

Examples

>

withListTools:

>

L3.263,2.3,6.255,3.261,3.262

L3.263,2.3,6.255,3.261,3.262

(1)
>

Occurrences3.263,L

1

(2)

The number of entries approximately equal to 3.263.

>

Occurrences3.263,L,verify,float10,digits=3

3

(3)

In the following example, the Occurrences command is used in conjunction with the ListTools:-FindRepetitions command to find the mode of a list with alpha-numeric values:

>

L21,2,3,4,3,4,b,b,a,c,c,c:

>

SortedListsortL2&comma;x&comma;yListTools:−Occurrencesy&comma;L2<ListTools:−Occurrencesx&comma;L2

SortedListc&comma;c&comma;c&comma;b&comma;b&comma;4&comma;3&comma;4&comma;3&comma;a&comma;2&comma;1

(4)
>

ListTools:-FindRepetitionsSortedList&comma;ListTools:-OccurrencesSortedList1&comma;L21

c

(5)


Download Help Document

AltStyle によって変換されたページ (->オリジナル) /