Changeset 0e896b7 in tol


Ignore:
Timestamp:
Mar 1, 2010, 4:30:46 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
e945583
Parents:
b2a343a
Message:

Adding default argument to Group function to use it when set is empty

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@2043 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/bgrammar/spfuninst.cpp

    rb2a343a r0e896b7  
    507507  else
    508508  {
    509     if(args.Card()==2)
     509    if(args.Card()>=2)
    510510    {
    511511            uTxt = args[1];
    512512            uSet = args[2];
    513             if(uTxt && uSet && Set(uSet).Card())
     513     
     514            if(uTxt && uSet)
    514515            {
    515               BText txt  = uTxt->Dump();
     516        BSet& set = Set(uSet);
     517              BText txt = uTxt->Dump();
    516518                                txt = txt.SubString(1,txt.Length()-2);
    517519              BStandardOperator* ope = (BStandardOperator*)gra->FindOperator(txt);
    518520              if(ope)
    519521              {
    520                       BSet&  set  = Set(uSet);
    521                       if(set.Card()>0)
     522                      if(set.Card()==0)
     523          {
     524            if(args.Card()==3)
     525            {
     526                    result = args[3];
     527            }
     528            else
     529            {
     530              Error(I2("Cannot evaluate Group over empty set without "
     531                       "a default value.",
     532                                               "No sepuede evaluar Group sobre un conjunto vacío "
     533                       "sin valor por defecto."));
     534            }
     535          }
     536          else 
    522537          {
    523538                        BBool ok = BTRUE;
    … …  
    19591974
    19601975  AddInstance("Group",
    1961   I2("(Text function, Set s)",
    1962      "(Text función, Set s)"),
     1976  I2("(Text function, Set s [, Anything defaultForEmpty])",
     1977     "(Text función, Set s [, Anything defaultForEmpty])"),
    19631978  I2("Evaluates a function taking as arguments the elements of a set.\n\n"
    19641979     "Example:\n"
Note: See TracChangeset for help on using the changeset viewer.