[plt-scheme] Conditions in web-templates

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Feb 8 13:40:58 EST 2009

On Feb  7, Jay McCarthy wrote:
> Yes. Here is an example:
> 
> if.html:
> @(if (@monkeys . > . @monkey-limit)
>      @list{<p>There are too many monkeys!</p>}
>      @(if (@monkeys . < . @monkey-minimum)
>              @list{<p>There aren't enough monkeys!</p>}
>              @list{<p>There are just enough monkeys!</p>}))

This is, BTW, the same as:

  @(if (monkeys . > . monkey-limit)
       @list{<p>There are too many monkeys!</p>}
       (if (monkeys . < . monkey-minimum)
           @list{<p>There aren't enough monkeys!</p>}
           @list{<p>There are just enough monkeys!</p>}))

which is also the same as:

  @(cond [(monkeys . > . monkey-limit)
          @list{<p>There are too many monkeys!</p>}]
         [(monkeys . < . monkey-minimum)
          @list{<p>There aren't enough monkeys!</p>}]
         [else @list{<p>There are just enough monkeys!</p>}])

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.