role Mixy

Collection of distinct objects with Real weights

role Mixy does Baggy { }

A role for collections of weighted values. See Mix and MixHash. Mixy objects differ from Baggy objects in that the weights of Mixy are Reals rather than Ints.


method total

method total(--> Real)

Returns the sum of all the weights

mix('a','b','c','a','a','d').total == 6; # True
{a => 5.6, b => 2.4} == 8; # True

method roll

method roll ($count = 1)

Similar to a Bag.roll, but with Real weights rather than integral ones.

See Also

Sets, Bags, and Mixes

Type graph

Below you should see a clickable image showing the type relations for Mixy that links to the documentation pages for the related types. If not, try the PNG version instead.

perl6-type-graph Mixy Mixy Baggy Baggy Mixy->Baggy Associative Associative QuantHash QuantHash QuantHash->Associative Baggy->QuantHash Mu Mu Any Any Any->Mu MixHash MixHash MixHash->Mixy MixHash->Any Mix Mix Mix->Mixy Mix->Any

Routines supplied by role Baggy

Mixy does role Baggy, which provides the following methods:

method grab

method grabpairs

method pick

method pickpairs

method roll

method classify-list

method categorize-list

method keys

method values

method kv

method elems

method total

method ACCEPTS