bag

File bag.str
Author unknown
Since unknown

This module contains strategies for handling bags.

A bag is a set of elements where each element has an occurence number. Addingan element to a bag which already exists, will increase the occurence numberfor that element by one.

In the current implementation, bags are represented as lists of (element,occurrence) tuples. Adding a new element is done using bag-insert.




Statistics


General
Lines of code 50
Stratego
Module number 1 (100% documented)
Constructor number 0
Overlay number 0
Strategy number 0
Rule number 4 (100% documented)
DynamicRule number 0



Rule summary


bag-insert Inserts a new element into a bag bag.str
bag-insert(Strategy equ) Inserts a new element into a bag bag.str
bag-union Takes the union of two bags bag.str
bag-union(Strategy equ) Takes the union of two bags bag.str



Rule details


ATerm bag-insert
File bag.str
Author unknown
Since unknown
 

Inserts a new element into a bag. The element must be on the forma (element, occurrence) tuple, where occurrence is an integer. Thebag may be empty.

Example: <bag-insert> (('a', 1), []) => [('a',1)]


type (elem, occur) * List(a) -> List(a)

 
ATerm bag-insert(Strategy equ)
File bag.str
Author unknown
Since unknown
 
Parameters
Strategy equ Used to test equality on elements.

Inserts a new element into a bag. The element must be on the forma (element, occurrence) tuple, where occurrence is an integer. Thebag may be empty. The strategy parameter is used to check elementsfor equality.


type (elem, occurrence) * List(a) -> List(a)

 
ATerm bag-union
File bag.str
Author unknown
Since unknown
 

Takes the union of two bags.

Example: <bag-union> ([('a',2), ('b',1)], [('a',1)]) => [('b',1),('a',3)]


type List(a) * List(a) -> List(a)

 
ATerm bag-union(Strategy equ)
File bag.str
Author unknown
Since unknown
 
Parameters
Strategy equ Used to test equality on elements.

Takes the union of two bags. The strategy parameter is usedto check elements for equality.


type List(a) * List(a) -> List(a)