AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Generation of Multiple Set Combinations

Ein Thema von danten · begonnen am 21. Nov 2017 · letzter Beitrag vom 21. Nov 2017
Antwort Antwort
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#1

Generation of Multiple Set Combinations

  Alt 21. Nov 2017, 11:05
Hello,
how to create a generator of all combinations of three array groups.
I need all the combinations, always from all three groups.
Thank you

Sample of the program in the image.
Miniaturansicht angehängter Grafiken
array.png  
Daniel
  Mit Zitat antworten Zitat
SProske

Registriert seit: 16. Feb 2015
Ort: Halle/S.
116 Beiträge
 
Delphi 10.2 Tokyo Enterprise
 
#2

AW: Generation of Multiple Set Combinations

  Alt 21. Nov 2017, 11:18
What exactly do you have problems with? Nested looping over all 3 arrays should be sufficient.
Delphi-Quellcode:
for I := Low(Array1) to High(Array1) do
  for J := Low(Array2) to High(Array2) do
    for K := Low(Array3) to High(Array3) do
      WriteLn(Format('%s-%s-%s', [Array1[I], Array2[J], Array3[K]]));
Sebastian
  Mit Zitat antworten Zitat
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#3

AW: Generation of Multiple Set Combinations

  Alt 21. Nov 2017, 11:48
Thank you,
the problem is to load the array array from edit.

Code:
Delphi-Quellcode:
procedure TFormGenerate.Generate;
var
  i1,i2,i3 : Integer;
  array1,array2,array3: array of string;
begin
  array1 := [editArray1.Text];
  array2 := [editArray2.Text];
  array3 := [editArray3.Text];

  for I1 := Low(Array1) to High(Array1) do
  for I2 := Low(Array2) to High(Array2) do
    for I3 := Low(Array3) to High(Array3) do
      Memo1.Lines.Add(Format('%s-%s-%s', [Array1[I1], Array2[I2], Array3[I3]]));
end;
Result = A,B,C,D-1,2,3,4,5,6-X1,X2

Delphi-Quellcode:
procedure TForm27.Generate;
var
  i1,i2,i3 : Integer;
  array1,array2,array3: array of string;
begin
  array1 := ['A','B'];
  array2 := ['1','2','3'];
  array3 := ['X1','X2'];

  for I1 := Low(Array1) to High(Array1) do
  for I2 := Low(Array2) to High(Array2) do
    for I3 := Low(Array3) to High(Array3) do
      Memo1.Lines.Add(Format('%s-%s-%s', [Array1[I1], Array2[I2], Array3[I3]]));
end;
Result =
A-1-X1
A-1-X2
A-2-X1
...
B-2-X2
B-3-X1
B-3-X2
Daniel
  Mit Zitat antworten Zitat
SProske

Registriert seit: 16. Feb 2015
Ort: Halle/S.
116 Beiträge
 
Delphi 10.2 Tokyo Enterprise
 
#4

AW: Generation of Multiple Set Combinations

  Alt 21. Nov 2017, 12:44
You need to split the string, like

Delphi-Quellcode:
var
  array1,array2,array3: TArray<string>;
begin
  array1:= string(editArray1.Text).Split([',']);
  ...
Sebastian
  Mit Zitat antworten Zitat
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#5

AW: Generation of Multiple Set Combinations

  Alt 21. Nov 2017, 12:59
You need to split the string, like

Delphi-Quellcode:
var
  array1,array2,array3: TArray<string>;
begin
  array1:= string(editArray1.Text).Split([',']);
  ...
Yes, that's exactly it.
Thank you very much.
Daniel
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:00 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz