;========
; Fall 2026 - CS 111
; Week 7 Lab Exercise - save as lab7.rkt
;
; date: 2026-10-09
;========

;-----
; this file will use definitions and functions from these modules:

(require 2htdp/image)
(require 2htdp/universe)
(require 2htdp/batch-io)

;========
; NOTE:
; *   To receive credit for this lab exercise, you must:
;     *   be present during your lab section,
;         either in BSS 313 or in the lab Zoom session,
;         based on your lab section
;     *   participate appropriately in a pair,
;         either in BSS 313 or in a Zoom breakout room

;========
; USING pair-programming:
; 1. COPY and PASTE the contents of this
;    file into a DrRacket Definitions window, and save as:
;
;        lab7.rkt
;
; 2. ADD comments and expressions TO THIS as specified below
;    (one student saying what to type, the other student typing it
;    into DrRacket)
;
;        ********
;    *   DO NOT DELETE THE COMMENTS! They speed up grading!
;        ********
;
;    *   remember: it is a class style standard to put a
;        BLANK LINE between each comment-block and an expression
;        following it
;
; 3. SAVE the contents of your definitions window frequently
;    as you are working, to the driver's Google Drive,
;    using a file name of lab7.rkt.
;
; 4. RUN the resulting file frequently as you are working,
;    fixing any errors that arise.
;
; 5. When you are done, use Gmail to MAIL a copy of the
;    resulting filled-in lab7.rkt file
;
;    *** AS WELL AS YOUR Problem 1's .txt files ***,
;
;    to BOTH of you.
;
; 6. And, EACH of you should SUBMIT these files,
;
;    *** lab7.rkt AND your Problem 1's .txt files ***,
;
;    to Canvas BEFORE you leave lab.
;
; 7. REMEMBER to also answer the
;    "Week 7 Lab Exercise - Pair-Programming Peer Review Survey"
;    in Canvas, posted along with this lab exercise, by
;    11:59 pm TONIGHT (Friday, October 9)
;========

;=====
; Leave a blank line, and then put COMMENT(s) containing BOTH
;     of your names (include first AND last names)





;========
; PROBLEM 1 - write another file-i/o-related function
;========
; Recall that the Racket built-in function length expects
; a list and returns its length (number of elements within it).
; And, consider that you know how to read a file's contents
; into a list of strings where each string is one "word" from a file.
; 
; Using the design recipe, design a function get-num-words that
; expects the name of an existing file, and returns the number of "words"
; in that file.
; *   Create two files with names ending in .txt to use in
;     the tests of get-num-words, and submit these along with
;     your lab7.rkt file.
;     (you can create these .txt files using write-file if you would
;     like, or you can create them using a text editor, your choice)





;========
; PROBLEM 2 - write another function that "walks through"
;             a list
;========
; CHOOSE ***ONE*** of the options A, B, or C below, and use the
;     DESIGN RECIPE to design that function
;========

;==== TEMPLATE for a function that needs
;     to "walk through" all of the elements of a
;     variable-length list
;
; (define (a-list-funct ... a-list ...)
;     (cond
;         [(empty? a-list) ...]
;         [else (...
;                  ... (first a-list) ...
;                  (a-list-funct ... (rest a-list) ...) ...)]
;     )
; )

;----- Problem 2 option A -----
; Using the design recipe, write a function num-list-smush that
; expects a list of numbers, and returns a single string
; containing string versions of those numbers each followed by
; \n (the newline character).
;
; For example, (num-list-smush (list 1 2 3)) should return
; "1\n2\n3\n".

;----- Problem 2 option B -----
; Using the design recipe, write a function grab-positive-nums
; that expects any list, and returns a list containing just
; the positive numbers from that list.
;
; For example,
; (grab-positive-nums (list #true 4 "moo" -3 7 (circle 20 "solid" "red")))
; should return (cons 4 (cons 7 empty)).

;----- Problem 2 option C -----
; Using the design recipe, write a function convert-to-nums
; that expects a list of strings, and returns a list of those
; strings converted to numbers, OMITTING any that string->number
; cannot convert to a number.
;
; For example,
; (convert-to-nums (list "23" "moo" "450" "oink" "1"))
; should return (cons 23 (cons 450 (cons 1 empty)))).





;=====
; Remember: once you have Run these and are satisfied
;     with them,
; *   Use Gmail to EMAIL copies of this file lab7.rkt
;     *** AND ALSO YOUR Problem 1's .txt files ***
;     to BOTH of you
;
; *   BOTH of you should submit this file
;     *** AND ALSO YOUR Problem 1's .txt files ***
;     to Canvas BEFORE you leave lab.
;
; *   ALSO answer the
;     "Week 7 Lab Exercise - Pair-Programming Peer Review Survey"
;     in Canvas, posted along with this lab exercise, by
;     11:59 pm TONIGHT (Friday, October 9)
;=====