Funktionsvariante von 'oneof' Funktion in Racket
Ich habe folgende Funktion geschrieben, um herauszufinden, ob eine und nur eine von 5 Variablen wahr ist:
(define (oneof v w x y z)
(or (and v (not w) (not x) (not y) (not z))
(and w (not v) (not x) (not y) (not z))
(and x (not v) (not w) (not y) (not z))
(and y (not v) (not w) (not x) (not z))
(and z (not v) (not w) (not x) (not y)) ))
(xor akzeptiert nur 2 Argumente)
Es ist jedoch sehr zwingend und nicht funktionsfähig. Außerdem möchte ich eine Funktion (eine von N) schreiben, die für 5 Variablen eher generisch als spezifisch ist. Wie geht das? Vielen Dank
Edit: Wie in den Kommentaren erwähnt, ist der Code 'repetitiv' und nicht 'zwingend', obwohl die Notwendigkeit einer Verbesserung weiterhin besteht.