;;;; The assignment is to fill in the definitions below, adding your code where
ID: 3544037 • Letter: #
Question
;;;; The assignment is to fill in the definitions below, adding your code where ever you see
;;;; the comment
;; fill in here
;;;; to make each function do what its comments say it should do
;;;; You may also add your own functions, as long as each function has a comment like the ones below.
;;;; You may not make any other changes to this code.
;;;; code for a program to create closures that generate ascii patterns
;;; patterns: a pattern is represented by a list of 4 elements: pattern, numrows, numcols and fn
;;; where:
;;; pattern is just the symbol pattern
;;; fn is a function (ie a closure) of two parameters: row, column that returns the character
;;; at the given row and column of the pattern. If row is out of bounds ie row<0 or
;;; row>=numrows, or similarly for col, fn returns the character #. (a period character)
;;; numrows is the number of rows in the pattern
;;; numcols is the number of columns in the pattern
;;; the following are functions to create and access a pattern
;;; note that make-pattern adds bounds checking to fn
(define (make-pattern numrows numcols fn)
(list 'pattern numrows numcols (add-check fn numrows numcols)))
(define (pattern-numrows pattern)(cadr pattern))
(define (pattern-numcols pattern)(caddr pattern))
(define (pattern-fn pattern) (cadddr pattern))
;; repeat-rows returns a pattern made up of nrepeats copies of
;;; pattern, appended vertically (above and below each other)
(define (repeat-rows nrepeats pattern)
;; fill in here
)
;;; append cols returns the pattern made by appending pattern2 to the right of pattern1
;;; the number of rows in the resulting pattern is the smaller of the number of rows in pattern1 and patten2
(define (append-cols pattern1 pattern2)
;; fill in here
)
;;; append-rows returns the pattern made by appending pattern2 to the below pattern1
;;; the number of columns in the resulting pattern is the smaller of the number of columns in pattern1 and patten2
(define (append-rows pattern1 pattern2)
;;fill in here
)
;;; flip-cols returns a pattern that is the left-right mirror image of pattern
(define (flip-cols pattern)
;;fill in here
)
;;; flip-rows returns a pattern that is the up-down mirror image of pattern
(define (flip-rows pattern)
;; fill in here
)
Explanation / Answer
what is the proramming language?
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.