20th December 2 hours exam needs dr.racket

avhzvat5yy
timer Asked: Dec 9th, 2020

Question Description

following is a sample


;; The first three lines of this file were inserted by DrRacket. They record metadata

;; about the language level of this file in a form that our tools can easily process.

#reader(lib "htdp-advanced-reader.ss" "lang")((modname 2016W1-F-solution) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #t #t none #f () #f)))

(require 2htdp/image)

(require spd/tags)

(@problem 1)

;; The following signature purpose, stub, and check-expects for the function

;; count-trues are provided for you to use with Problems 1A, 1B, 1C and 1D.

;;

;; Read Problems 1A, 1B, 1C and 1D before you start.

(@htdf count-trues)

(@signature (listof Boolean) -> Natural)

;; produce the number of trues in the list

(check-expect (count-trues empty) 0)

(check-expect (count-trues (list false true true true false false))

3)

(check-expect (count-trues (list true true false true true true true))

6)

;(define (count-trues x) 0) ;stub

;; Problem 1A:

;;

;; Write a non-tail recursive function definition for count-trues using the

;; (listof X) template.

;;

;; Include a template tag.

;; 5, 1 each for

;;

;; - template tag

;; - template is apparent

;; - base case result is correct (0)

;; - combination is correct (+)

;; - selection behaviour is correct (true and false cases)

(@template (listof Boolean))

#;

(define (count-trues lob)

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors