;=====
; Racket examples from CS 111 - Week 1 Lecture 2,
;    cleaned up after class!
; last modified: 2023-08-24

;=====
; these are all simple expressions of type number

13

e

1.3
.25
23.

-4
-10.34
+10.34

pi

;=====
; Racket also has a string data type
;    for "wordy" data

; syntax for a string simple expression:
;    anything typed within double quotes
;    will be considered a simple expression of type string

"I like pi"
"67"

;=====
; next data type: boolean
; has exactly two values,
;    #true #false

; simple expressions of type boolean

#true
#false

; Racket also allows you to express
;    booleans using these simple expressions,
;    also:

true
false

#t
#f

;=====
; another Racket data type: image

; yes, this IS a simple expression of type
;     image! (copied image from a browser,
;     copied into DrRacket definitions window)

dachshund image

;=====
; SO -- what if I want to perform some operation?
;    combine or use expressions in various ways?

; I need COMPOUND EXPRESSIONS for that

;=====
; BSL Racket's syntax for compound expressions:
;
; (operation expr expr expr ...)
;              ^ arguments

;=====
; you can write your own operations (functions) -
; Racket also has a number for operators and functions
;    built in --
; and BSL Racket has a number libraries/modules
;    of functions and operators available

;=====
; how about some operations on numbers

; here are some operators for number values
; + - * /

;=====
; NOTE: the type for a compound expression
;    is the type of the value returned by it
;    operation
; + - * / happen to return numbers, so
;    all of the following are compound expressions
;    of type number:

(+ 13 .34 1000 5)
13 (+ 5 2)

(* 13
   (+ 5 2))

(* 13 (+ 5 2))

(- 5 3)
(- 5 -3)

(/ 1 3)

;=====
; how about some operations on strings?

; string-append expects two or more string
;    expressions, and returns a single string
;    whose value is the values of all those string 
;    arguments concantenated (appended, smushed)
;    into one string

(string-append "How" "dy")

(string-append "Hi" " there")

; string-length expects a string argument,
;    and returns a number, the number of
;    characters in that string argument's value

; (so, this is a compound expression of type number,
;     since it results in a number)

(string-length (string-append "How" "dy"))

;=====
; how about some boolean operators?

(< 3 5)
(> 3 5)

(= 3 3.0)
(string=? "moo" "MOO")

(string? 3)
(string? "3")

; aside ...!

1/3   ; syntax for a rational number in Racket...!

;=====
; BSL Racket has an image module/library!
;
; you can use the functions from a Racket module
;    after you write a require expression whose
;    argument is the name of the module/library
;    you want to use something from

;=====
; 2htdp/image is a module/library written to be
;    used with our course text (2nd edition of
;    "How to Design Programs")

(require 2htdp/image)

;=====
; 2htdp/image defines a circle function
;    that expects a radius in pixels,
;    a string "solid" or "outline", and
;    a color, and returns an image of a circle
;    of that size, style, and color

; (ONE way to write a color is as a string containing
;     the name of that color, for a reasonably-large
;     set of color names)

(circle 50 "solid" "maroon")

;=====
; 2htdp/image also defines an overlay function,
;    that expects any number of image arguments
;    and returns an image that "stacks" the given
;    images

(overlay (circle 20 "solid" "pink")
         (circle 50 "solid" "maroon"))

;=====
; you can see more in the Racket Documentation
;    you can reach from DrRacket's Help menu --
;    try typing 2htdp/image in the top-left
;    textfield of the Racket Documentation,
;    and selecting "2htdp/image module"
;    in the results shown