Lecture overview -- Keyboard shortcut: 'u'  Previous page: Conditional expressions -- Keyboard shortcut: 'p'  Next page: Example with <kbd>cond</kbd>: <kbd>leap-year?</kbd> -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 3 - Page 11 : 42
Functional Programming in Scheme
Name binding, Recursion, Iteration, and Continuations
Examples with if

Expression

Value

(body
  (if (string=? 
        (weekday (current-time))
        "Wednesday")
      (p (em "Remember Thursday meeting!"))
      '( ))

  (h1 "Schedule")

  (p "..."))

Remember the Thursday meeting tomorrow!

Schedule

...

(body
  (p (if (string=? 
           (weekday (current-time))
           "Wednesday")
         (em "Remember Thursday meeting!")
         '( )))

  (h1 "Schedule")

  (p "..."))

Remember the Thursday meeting tomorrow!

Schedule

...

Examples using an if conditional expression on a Wednesday. In both examples we extract the weekday (a string) from the current time. If it is a Wednesday we emit a paragraph which serves as a reminder of a meeting the following day. If not executed on a Wednesday, we do not want any special text. We achieve this by returning the empty list, which is spliced into the the body context (in the first example) and into the paragraph context (in the second example). The splicing is a result of the handling of lists by the HTML mirror functions in LAML. The two examples differ slightly. In the first example the if is placed on the outer level, feeding information to body. In the second row, the if is placed at an inner level, feeding information to the p function. The two examples also give slightly different results. Can you characterize the results?