Autor |
Beitrag |
nepleurepas
      
Beiträge: 164
Win XP
|
Verfasst: So 21.09.08 12:53
Hallo,
gibt es eine möglichkeit, eine bedingung zu invertieren ohne 'else' zu verwenden?
Bsp:
Delphi-Quelltext 1: 2:
| if (a=250) and (b=250) then ..... else .... |
wie kann ich nun [2] als folge von 'then' erhalten, wenn (a=250) and (b=250) immernoch in der bedingung stehen sollen? Ich muss also das (a=250) and (b=250) irgendwie invertieren. Mathematisch 1-((a=250) and (b=250)).
Und jetzt sagt mir bitte nicht if (a<>250) or (b<>250), das is mir schon klar. Ich wills halt mit der Delphi syntax invertieren...
Hoffe ihr versteht mich
Danke
|
|
BenBE
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: So 21.09.08 12:57
De Morgan'sche Gesetze
Delphi-Quelltext 1:
| not (a=250) and (b=250) ==> (not (a=250)) or (not (b = 250)) ==> (a <> 250) or (b <> 250) |
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Zuletzt bearbeitet von BenBE am So 21.09.08 13:11, insgesamt 1-mal bearbeitet
|
|
nepleurepas 
      
Beiträge: 164
Win XP
|
Verfasst: So 21.09.08 13:07
(a=250) and (b=250) ==> (not (a=250)) or (not (b = 250)) ==> (a <> 250) or (b <> 250)[/quote]
ja gut, dass war jetz mathematisch verneint. Meine frage war ja, ob es n operator gibt. "Else" sagt ja im prinzip nichts anderes als 'alle Fälle, die nicht unter 'if' fallen.
Meine frage jetzt, kann ich auch direkt sowas wie 'else' in die bedingung schreiben?
|
|
BenBE
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: So 21.09.08 13:10
Delphi-Quelltext 1:
| if not (Bedingung) Then |
Macht auch nix andres, als ich jetzt grad Mathematisch gezeigt hab. Sollte man aber immer schauen, ob es nicht sinnvoller ist, die Bedingung mal eben mathematisch negiert.
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
nepleurepas 
      
Beiträge: 164
Win XP
|
Verfasst: So 21.09.08 13:11
|
|
|