CS116 Study Guide - Final Guide: Pacific Magazines, Newline, Init

92 views2 pages

Document Summary

;;string-num: (listof num) -> string (define (string-num lon) (foldr string-append ;;append them together (map number->string lon))) ;;convert all the numbers to strings (define-struct children (total girl boy)) ;;a children is a structure (make-children (t g b)), where. ;; t is an integer representing the total number of children in a family, ;; g is an integer representing the total number of girls, and. ;; b is an integer representing the total number of boys. (define f (make-children 3 2 1)) ;; consumes a children structure, c, and a gender and. ;; produces the string telling you what the previous. ;;effects: increases the total by 1 and increases either the. ;; boy or girl field by 1 depending on whether gender is. ;; "girl or "boy (define (update-family c gender) (local. [;;keep track of previous total (define previous-total (children-total c))] (begin. ;; increase the total by one (set-children-total! c (+ 1 (children-total c))) (cond.