www.wikidata.de-de.nina.az
Operatorassoziativitat bezeichnet vor allem in der Informatik aber auch Mathematik und Logik die Festlegung wie komplexere Ausdrucke mit nicht infix Operatoren die fur Operationen stehen die nicht unbedingt assoziativ sind zu lesen sind Zum Beispiel sind in der Mathematik die Addition und Multiplikation die ublicherweise mit displaystyle bzw displaystyle cdot notiert werden assoziative Operationen es gilt also a b c a b c displaystyle a b c a b c bzw a b c a b c displaystyle a cdot b cdot c a cdot b cdot c ebenso wie in der Logik die Konjunktion displaystyle land und Disjunktion displaystyle lor Hier ist es gleichgultig ob a b c displaystyle a b c als a b c displaystyle a b c oder als a b c displaystyle a b c interpretiert wird Bei nicht assoziativen Operationen wie etwa der Subtraktion infix notiert durch gilt a b c a b c displaystyle a b c a b c nicht allgemein und daher muss festgelegt werden ob Ausdrucke wie a b c displaystyle a b c uberhaupt erlaubt sind und falls sie erlaubt sind welche Klammerung implizit vorliegen soll Wird festgelegt dass linksassoziativ ist ist a b c displaystyle a b c wie a b c displaystyle a b c zu interpretieren Soll dagegen rechtsassoziativ sein ware a b c displaystyle a b c wie a b c displaystyle a b c zu interpretieren Inhaltsverzeichnis 1 Linksassoziative Operatoren 2 Rechtsassoziative Operatoren 3 Weder noch 4 Siehe auch 5 EinzelnachweiseLinksassoziative Operatoren BearbeitenBei linksassoziativen Operatoren wird implizite Linksklammerung vereinbart 1 2 3 4 5 ein binarer Operator displaystyle nbsp gilt somit als linksassoziativ wenn die Ausdrucke a b c displaystyle a b c nbsp a b c displaystyle a b c nbsp a b c d displaystyle a b c d nbsp a b c d displaystyle bigl a b c bigr d nbsp etc wie gezeigt zu lesen sind Beispiele fur linksassoziative Operatoren sind Subtraktion a b c displaystyle a b c nbsp a b c displaystyle a b c nbsp Division a b c displaystyle a b c nbsp a b c displaystyle a b c nbsp a b c displaystyle a div b div c nbsp a b c displaystyle a div b div c nbsp a b c displaystyle a b c nbsp a b c displaystyle a b c nbsp Jedoch Bei waagerechten Bruchstrichen bindet der kurzere Bruchstrich starker a b c displaystyle frac a frac b c nbsp a b c a c b displaystyle frac a bigl frac b c bigr frac a cdot c b nbsp a b c displaystyle frac frac a b c nbsp a b c a b c displaystyle frac bigl frac a b bigr c frac a b cdot c nbsp Funktionsanwendung durch Juxtaposition in vielen Programmiersprachen u a Haskell f x y z f x y z dd Rechtsassoziative Operatoren BearbeitenUmgekehrt liegt bei rechtsassoziativen Operatoren displaystyle nbsp implizite Rechtsklammerung vor so dass gilt x y z displaystyle x y z nbsp displaystyle nbsp x y z displaystyle x y z nbsp w x y z displaystyle w x y z nbsp displaystyle nbsp w x y z displaystyle w x y z nbsp etc Beispiele fur rechtsassoziative Operatoren sind 6 Die Potenzierung x y z x y z displaystyle x y z x y z nbsp denn x y z displaystyle x y z nbsp ware einfach x y z displaystyle x yz nbsp Achtung Taschenrechner werten Eingaben der Form x y z gleichwohl in der Regel linksassoziativ also so aus als ob sie in der Form x y z eingegeben worden waren bei Ausdrucken dieser Form muss daher die Rechtsassoziativitat der Potenzierung stets mittels eigener Klammersetzung erzwungen werden x y z Die Subjunktion in der Logik wird von den meisten Autoren rechtssassoziativ verwendet das heisst dass P Q R displaystyle P rightarrow Q rightarrow R nbsp als P Q R displaystyle P rightarrow Q rightarrow R nbsp zu lesen ist Der Zuweisungsoperator einiger Programmiersprachen wie C x y z ist gleichbedeutend mit x y z das heisst der Variablen y wird zunachst der Wert von z zugewiesen und erst danach das Ergebnis dieser Zuweisung also der zugewiesene Wert z der Variablen x zugewiesen Funktionsanwendung durch infix in Haskell f g h x f g h x dd Weder noch BearbeitenEs kann auch sein dass Ausdrucke wie a b c displaystyle a bullet b bullet c nbsp einfach verboten werden selbst dann wenn die Operation fur die der Operator displaystyle bullet nbsp steht assoziativ ist So ist zum Beispiel in Haskell der Vergleichsoperator wie auch lt gt usw in diesem Sinne nicht assoziativ obwohl die Vergleichsoperation zwischen Booleschen Werten etwa als Funktion 2 2 2 displaystyle 2 times 2 to 2 nbsp assoziativ ist Siehe auch BearbeitenOperatorrangfolgeEinzelnachweise Bearbeiten Order of operations PDF 265 kB Rochester Institute of Technology The Order of Operations Education Place The Order of Operations Khan Academy Video ab 05 40 Using Order of Operations and Exploring Properties PDF Absatz 9 Virginia Department of Education Vorrangregeln und Assoziativitat Technische Universitat Chemnitz Rules for Exponents and the Reasons for Them PDF 344 kB Western Michigan University Abgerufen von https de wikipedia org w index php title Operatorassoziativitat amp oldid 227035581