Why do most programming languages only have binary equality comparison operators?

前端 未结 24 970
一个人的身影
一个人的身影 2020-12-08 14:20

In natural languages, we would say \"some color is a primary color if the color is red, blue, or yellow.\"

In every programming language I\'ve seen, that translates

24条回答
  •  遥遥无期
    2020-12-08 14:49

    Just to add to language examples

    Scheme

    (define (isPrimaryColor color)
      (cond ((member color '(red blue yellow)) #t)
            (else #f)))
    
    (define (someNumberTest x)
      (cond ((or (and (>= x 1) (<= x 100)) (and (>= x 10000 (<= x 2000))) #t)
            (else #f)))
    

提交回复
热议问题