;; A ListOfG: ;; --empty ;; --(cons g ListOfG) ;;examples of lists; ;;list-of-Numbers: empty (cons 1 empty) (cons 1 (cons 5 (cons 10 (cons 4 empty)))) ;;list-of-Symbols: empty (cons 'a empty) (cons 'a (cons 'b (cons 'c empty))) ;;list-of-Strings: empty (cons "one" empty) (cons "one" (cons "two" (cons "three" empty))) ;;list-of-posns (or structures) empty (cons (make-posn 1 2) empty) (cons (make-posn 1 2) (cons (make-posn 3 4) (cons (make-posn 5 6) empty))) ;; TODO: Try running these examples and see the results it produces ;; If you haven't seen it yet, there is an easier way to make lists ;; We can use the keyword, list, to make lists identical to the lists above ;; TODO: Try uncommenting the next few lines and running them, compare the results ;(list 1 5 10 4) ;(list 1) ;(list 'a 'b 'c) ;(list 'a) ;(list "one" "two" "three") ;(list "one") ;(list (make-posn 1 2) (make-posn 3 4) (make-posn 5 6)) ;; Now just to make sure try comparing some of these lists using equal? ;(equal? (list 1 2 3) (cons 1 (cons 2 (cons 3 empty)))) ;; TODO: Try some more to tests ;; Now go the Language and choose Begining Student with List Abbreviations ;; TODO: Now try running the program again. ;; Notice cons and empty no longer appear in the results ;; Just because the list appears different doesn't mean it is, we can still check lists using cons? and empty? ;(list) ;(list (make-posn 1 2)) ;(list (make-posn 1 2) (make-posn 3 4) (make-posn 5 6)) ;; Now take the three lists above and run them through this function: ;; Sum-of-posns which takes a list of posns and creates list of numbers. ;; Each number in the list is the sum of the x and y coordinate for each posn ;TODO: Go through the steps of building this function, ie, the contract, the template, examples, etc.. ;;Contract ;;TEMPLATE ;;Examples ;; You can use this language or continue to use Begining Student ;; You can also use (cons a-list empty) or the (list list-elements) representation with either language ;; Remember, that all list does is hide the cons and empty from you, they are still there its just not shown to you