table expand fast with rules, table expand fast with rules ignore case
This function combines the lookup strategy from table expand with rules() with the data integration features of table expand fast() where the additional rows are added at the end of the table to get the job done more quickly.
Indirect parameter passing is disabled
6 - 9 (For parameter description and return values: see table expand() )
table initialize( animals,
{ { Name, Size, Speed, Movement, Leg count, Surface, Special Skills },
{ Parrot, small, 50, flying, 2, feathers, immitates voices },
{ Dog, small, 30, walking, 4, hair, sense of smell },
{ Cat, small, 20, walking, 4, hair, night vision },
{ Fox, small, 25, walking, 4, hair, relatively smart },
{ Owl, small, 80, flying, 2, feathers, night vision },
{ Worm, tiny, 0.01, crawling, 0, mucous skin,unclear },
{ Whale, huge, 30, swimming, 0, skin, relatively smart } } );
headers[] = [animals:..,0]-{Name};
table initialize( target,
{ { Size, Speed, Movement, Leg count, Surface, Special Skills, Animal, Double Speed },
{ '*', ':mod([.],40)=0','*', '*', '*', '*', "It's an", 2 }, // Speed divisible by 40 -> Owl
{ small, '20..30', '*', '*', Hair, '*', "It's a ", 2 }, // Dog, Cat, Fox
{ small, '20..30', '*', '*', Hair, '*', "It's a ", 2 }, // "
{ small, '20..30', '*', '*', Hair, '*', "It's a ", 2 }, // "
{ '*', '<1', '*', '*', '*', '*', "", 2 } } );
count[] = table expand fast with rules ignore case ( target, headers[], {Animal, Movement, Double Speed},
animals, headers[], {Name, Movement, Speed}, { append with space, overwrite, mul }, true, Counter );
// Data integration process: Overwrite movement in target table, Add animal name to 'It's ...' and note double speed.
echo("List of animals with counted lookups:");
table list( animals );
echo("Target table after lookup (", count[], " items found):");
table list( target );
List of animals with counted lookups:
0 : Name | Size | Speed | Movement | Leg count | Surface | Special Skills | Counter
1 : Parrot | small | 50 | flying | 2 | feathers | immitates voices |
2 : Dog | small | 30 | walking | 4 | hair | sense of smell | 3
3 : Cat | small | 20 | walking | 4 | hair | night vision | 3
4 : Fox | small | 25 | walking | 4 | hair | relatively smart | 3
5 : Owl | small | 80 | flying | 2 | feathers | night vision | 1
6 : Worm | tiny | 0.01 | crawling | 0 | mucous skin | unclear | 1
7 : Whale | huge | 30 | swimming | 0 | skin | relatively smart |
Target table after lookup (11 items found):
0 : Size | Speed | Movement | Leg count | Surface | Special Skills | Animal | Double Speed
1 : * | :mod([.],40)=0 | flying | * | * | * | It's an Owl | 160
2 : small | 20..30 | walking | * | Hair | * | It's a Dog | 60
3 : small | 20..30 | walking | * | Hair | * | It's a Dog | 60
4 : small | 20..30 | walking | * | Hair | * | It's a Dog | 60
5 : * | <1 | crawling | * | * | * | Worm | 0.02
6 : small | 20..30 | walking | * | Hair | * | It's a Cat | 40
7 : small | 20..30 | walking | * | Hair | * | It's a Fox | 50
8 : small | 20..30 | walking | * | Hair | * | It's a Cat | 40
9 : small | 20..30 | walking | * | Hair | * | It's a Fox | 50
10 : small | 20..30 | walking | * | Hair | * | It's a Cat | 40
11 : small | 20..30 | walking | * | Hair | * | It's a Fox | 50
table expand fast with rules once
table expand fast smart
table expand fast
table expand with rules