;; The first three lines of this file were inserted by DrScheme. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-advanced-reader.ss" "lang")((modname ppt-base) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ())))
;; Kathi Fisler
;; Powerpoint exercise
;; Stage 0+helpers : the core code (for starting with in class)

;;;;;;;;;;;;;;; THE INTERFACE LANGUAGE ;;;;;;;;;;;;;;;;;;;;;;;

;; print-string : string -> void
;; prints string and a newline to the screen
(define (print-string str)
  (printf "~a~n" str))

;; print-newline : -> void
;; prints a newline on the screen
(define (print-newline) (printf "~n"))

;; print-unnumbered-strings : list[string] -> void
;; prints a list of strings to the screen, each prefixed with a -
(define (print-unnumbered-strings strlist)
  (for-each (lambda (str) (printf "- ~a~n" str)) strlist))

;; print-numbered-strings : list[string] number -> void
;; prints a list of strings to the screen, each prefixed with
;;   a number (in consecutive increasing order) starting with start
(define (print-numbered-strings strlist start)
  (cond [(empty? strlist) void]
        [(cons? strlist) 
         (begin
           (printf "~a. ~a~n" start (first strlist))
           (print-numbered-strings (rest strlist) (+ 1 start)))]))

;; await-click : -> void
;; mimics a mouse click by waiting for the user to type a character
(define (await-click) (read))

;;;;;;;;;;;; THE DATA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; a slide is a (make-slide string slide-body)
(define-struct slide (title body))

;; a slide-body is either
;;  - a string (paragraph), or
;;  - a (make-pointlist list[string] boolean)
(define-struct pointlist (points numbered?))

;; A cmd is 
;; - (make-displaycmd slide)
(define-struct displaycmd (slide))

;; A talk is a (make-talk list[cmd])
(define-struct talk (cmds))

;; A program in this language is just a talk

(define talk1
  (let ([intro-slide
         (make-slide 
          "Hand Evals in DrScheme"
          "Hand evaluation helps you learn how Scheme reduces programs to values")]
        [arith-eg-slide
         (make-slide 
          "Example 1"
          (make-pointlist (list "(+ (* 2 3) 6)" "(+ 6 6)" "12") false))]
        [func-eg-slide
         (make-slide 
          "Example 2"
          (make-pointlist (list "(define (foo x) (+ x 3))" "(* (foo 5) 4)" "(* (+ 5 3) 4)" "(* 8 4)"
                                "32") false))]
        [summary-slide
         (make-slide
          "Summary: How to Hand Eval"
          (make-pointlist (list "Find the innermost expression"
                                "Evaluate one step"
                                "Repeat until have a value")
                          true))])
    (make-talk
     (list (make-displaycmd intro-slide)
           (make-displaycmd arith-eg-slide)
           (make-displaycmd func-eg-slide)
           (make-displaycmd summary-slide)))))

