Raku Land



Build Status


Lingua::Conjunction - Convert lists into linguistic conjunctions and fill them into a template


    use Lingua::Conjunction;

    say conjunction <chair>; # chair
    say conjunction <chair spoon>; # chair and spoon
    say conjunction <chair spoon window>; # chair, spoon, and window

    # "Tom, a man; Tiffany, a woman; and GumbyBRAIN, a bot"
    say conjunction 'Tom, a man', 'Tiffany, a woman', 'GumbyBRAIN, a bot';

    # These are reports for May, June, and August
    say conjunction <May June August>, :str('These [is|are] report[|s] for |list|');

    # "Jacques, un garcon; Jeanne, une fille et Spot, un chien"
    say conjunction 'Jacques, un garcon', 'Jeanne, une fille', 'Spot, un chien',

Table of Contents


Provides a way to make it easy to prepare a string containing a list of items, where that string is meant to be read by a human.



say conjunction <chair spoon>;
say conjunction <May June August>, :str('Report[|s] for |list|'),
    :lang<fr>, :!last, :sep<·>, :alt<°>, :con<aaand>, :dis<ooor>, :type<or>;

Returns a string with the given list of items joined based on the configuration specified by the named arguments, which are as follows:


Specifies an alternative separator to use when at least one of the items contains sep separator. Defaults to ; (a semicolon).


Short for conjunction. The term to use when joining the last item to the previous one, when type argument is set to value and. By default is set based on value of lang argument.


Short for disjunction. The term to use when joining the last item to the previous one, when type argument is set to value or. By default is set based on value of lang argument.


Takes a string representing the code of the language to use. This will pre-set con, dis, and last arguments. Defaults to en. Currently supported languages and the defaults they pre-set are as follows (language is the first two-letter key on the left; that's what you'd specify as lang argument):

    af => { last => True,  con => 'en',  dis => 'of'    },
    da => { last => True,  con => 'og',  dis => 'eller' },
    de => { last => True,  con => 'und', dis => 'oder'  },
    en => { last => True,  con => 'and', dis => 'or'    },
    es => { last => True,  con => 'y',   dis => 'o'     },
    fi => { last => True,  con => 'ja',  dis => 'tai'   },
    fr => { last => False, con => 'et',  dis => 'ou'    },
    it => { last => True,  con => 'e',   dis => 'o'     },
    la => { last => True,  con => 'et',  dis => 'vel'   },
    nl => { last => True,  con => 'en',  dis => 'of'    },
    no => { last => False, con => 'og',  dis => 'eller' },
    pt => { last => True,  con => 'e',   dis => 'ou'    },
    sw => { last => True,  con => 'na',  dis => 'au'    },


Specifies whether to use sep when joining the penultimate and last elements of the list, when the number of elements is more than 2. In English, this is what's known as Oxford Comma. By default is set based on value of lang argument.


The primary item separator to use. Defaults to , (a comma).


say conjunction <May June August>, :str('Report[|s] for |list|');
say conjunction <Squishy Slushi Sushi>,
    :str('Octop[us|i] [is|are] named |list|');

Specifies a template to use when generating the string. You can use special sequence [|] (e.g. octop[us|i]) where string to the left of the | will be used when the list contains just one item and the string to the right will be used otherwise. The other special sequence is |list| that can will be replaced with the "conjuncted" items of the list. Defaults to |list|


Takes either value and or value or. Specifies whether words specified by con or by dis arguments should be used when joining the last two elements of the list.


Fork this module on GitHub: https://github.com/raku-community-modules/Lingua-Conjunction


To report bugs or request features, please use https://github.com/raku-community-modules/Lingua-Conjunction/issues


This module was inspired by Perl's Lingua::Conjunction and and my own List::ToHumanString. Some of the internal data was shamelessly stolen borrowed from Lingua::Conjunction's guts.

The rest is by Zoffix Znet (http://zoffix.com/)


You can use and distribute this module under the terms of the The Artistic License 2.0. See the LICENSE file included in this distribution for complete details.