1. On this page:
      if
      cond
      else
      =>
      and
      or

      3.12 Conditionals: if, cond, and, and or

      +Conditionals in The Racket Guide introduces conditionals.

      syntax

      (if test-expr then-expr else-expr)

      Evaluates test-expr. If it produces any value other than#f, then then-expr is evaluated, and its results arethe result for the if form. Otherwise, else-expr isevaluated, and its results are the result for the ifform. The then-expr and else-expr are in tailposition with respect to the if form.

      Examples:
      > (if (positive? -5) (error "doesn't get here") 2)

      2

      > (if (positive? 5) 1 (error "doesn't get here"))

      1

      > (if 'we-have-no-bananas "yes" "no")

      "yes"

      syntax

      (cond cond-clause ...)

       
      cond-clause = [test-expr then-body ...+]
        | [else then-body ...+]
        | [test-expr => proc-expr]
        | [test-expr]

      A cond-clause that starts with else must be the lastcond-clause.

      If no cond-clauses are present, the result is #<void>.

      If only a [else then-body ...+] is present, then thethen-bodys are evaluated. The results from all but the lastthen-body are ignored. The results of the lastthen-body, which is in tail position with respect to thecond form, are the results for the whole condform.

      Otherwise, the first test-expr is evaluated. If it produces#f, then the result is the same as a cond form withthe remaining cond-clauses, in tail position with respect tothe original cond form. Otherwise, evaluation depends on theform of the cond-clause:

      [test-expr then-body ...+]

      The then-bodys areevaluated in order, and the results from all but the lastthen-body are ignored. The results of the lastthen-body, which is in tail position with respect to thecond form, provides the result for the whole condform.

      [test-expr => proc-expr]

      The proc-expr isevaluated, and it must produce a procedure that accepts one argument,otherwise the exn:fail:contract exception is raised. The procedure is appliedto the result of test-expr in tail position with respect tothe cond expression.

      [test-expr]

      The result of the test-expr isreturned as the result of the cond form. Thetest-expr is not in tail position.

      Examples:
      > (cond)
      > (cond
          [else 5])

      5

      > (cond
         [(positive? -5) (error "doesn't get here")]
         [(zero? -5) (error "doesn't get here, either")]
         [(positive? 5) 'here])

      'here

      > (cond
         [(member 2 '(1 2 3)) => (lambda (l) (map - l))])

      '(-2 -3)

      > (cond
         [(member 2 '(1 2 3))])

      '(2 3)

      syntax

      else

      Recognized specially within forms like cond. Anelse form as an expression is a syntax error.

      syntax

      =>

      Recognized specially within forms like cond. A=> form as an expression is a syntax error.

      syntax

      (and expr ...)

      If no exprs are provided, then result is #t.

      If a single expr is provided, then it is in tail position, sothe results of the and expression are the results of theexpr.

      Otherwise, the first expr is evaluated. If it produces#f, the result of the and expression is#f. Otherwise, the result is the same as an andexpression with the remaining exprs in tail position withrespect to the original and form.

      Examples:
      > (and)

      #t

      > (and 1)

      1

      > (and (values 1 2))

      1

      2

      > (and #f (error "doesn't get here"))

      #f

      > (and #t 5)

      5

      syntax

      (or expr ...)

      If no exprs are provided, then result is #f.

      If a single expr is provided, then it is in tail position, sothe results of the or expression are the results of theexpr.

      Otherwise, the first expr is evaluated. If it produces avalue other than #f, that result is the result of theor expression. Otherwise, the result is the same as anor expression with the remaining exprs in tailposition with respect to the original or form.

      Examples:
      > (or)

      #f

      > (or 1)

      1

      > (or (values 1 2))

      1

      2

      > (or 5 (error "doesn't get here"))

      5

      > (or #f 5)

      5

       

          1. http://www.ilxs21.cn | http://m.ilxs21.cn | http://wap.ilxs21.cn | http://3g.ilxs21.cn | http://4g.ilxs21.cn | http://5g.ilxs21.cn | http://mobile.ilxs21.cn | http://vip.ilxs21.cn | http://ios.ilxs21.cn | http://anzhuo.ilxs21.cn | http://d3.ilxs21.cn | http://4fae94.ilxs21.cn | http://0b03.ilxs21.cn | http://www.ilxs21.cn/7.html | http://www.ilxs21.cn/a5f5fe.html | http://www.ilxs21.cn/db31.html | 中年风韵妇女