More list functions for perl

General Overview

This library provides the functions uniq, section and difference for perl. This library is used by many of the uHTML libraries. It can be of use without uHTML as well.

To install the module project local, copy it into the uHTML subdirectory of the script-directory of the website. To install it globally, copy it into the uHTML subdirectory of a perl-library directory.

Terms of Use

It is allowed to use this library under the actual GNU General Public License. The name of this library and it's author is to be named in all derivations.

Requirements

This listfuncs library do not need any other library.

 

List of perl functions provided by the std library

uniq, section, difference, shuffle, sample

 

 

perl functions provided by the std library

uniq(@list)

Overview

The function uniq removes identical consecutive values from @list and returns the result, similar to uniq from GNU core utils.

Parameters

@list
List to process.

Example

foreach( uniq sort @list ) {…
up↑
section($list1,$list2,$list3…)

Overview

The function section computes the section of several lists.

Parameters

$list1,$list2,…
References of lists from which the section has to be computed.

Example

foreach( section( \@list1,\@list2 ) ) {…
up↑
difference($list1,$list2)

Overview

The function difference removes from @{$list1} all elements contained in @{$list2}.

Parameters

$list1
Reference of the original list from which elements will be removed.
$list2
References of list with elements that will be removed from @{$list1}.

Example

foreach( difference( \@list1,\@list2 ) ) {…
up↑
shuffle($list)

Overview

The function shuffle shuffles randomly @{$list}.

Parameters

$list
Reference of the list to be shuffled

Example

shuffle( \@list ) ;
up↑
sample($list,$count)

Overview

The function sample selects more or less evenly picked $count random elements from @{$list1}. The function returns a reference to a list with the samples.

Parameters

$list
Reference of the list from which elements will be picked.
$count
Count of elements to be picked from @{$list1}.

Example

foreach( @{sample( \@list,$count )} ) {…
up↑