Navigation :
AP CS
Artificial Intelligence
Intermediate CS
-
3. Images
-
7. Numbers
-
8. Number Models
-
13. Booleans
-
15. Conditionals
-
20. Using Structures
-
Sem.I Review
-
21. Structures
-
22a. Recursion
-
22b. Lists
-- 22. List Intro
-- 22b. List Exercises 1
-- 22b. List Exercises 1.5
-- 22b. List Exercises 2
-- 22b. Bubble Wrap
-- Bubble Review
-- 22b. List Exercises 3
-- 22b. List Exercises 4
-- 22. Additional Resources
-- Parcels
-
Sem.II Review
-
Typed Racket
-
Resources
-
Pro Features
- Online Help
Robotics
WY Robotics
Exploring CS (Teachers)
Resources
22b. List Exercises 1.5
more-rand: number(x) list of numbers(nums) -> list of numbers
Give a new list with x and an additional random number from 0
through 9 put on the front of the more-rand list.
(check-random (more-rand 5 (list 1 2 3))
(list 5 (random 10) 1 2 3))
maybe-no-5: list of numbers -> list of numbers. If the first
number in the list is a 5, skip it, otherwise return the whole
list.
(check-expect (maybe-no-5 (list 1 5 51)) (list 1 5 51))
(check-expect (maybe-no-5 (list 5 9 14 23)) (list 9 14 23))
pemo: list of numbers -> number. Find the sum (plus) all of the
even numbers in the list and subtract (minus) all of the odd
numbers in the list.
(check-expect (pemo (list 10 30 5 20 10 11)) 54)
cram-small: list of strings(words) -> string. Take all of the
words that are less than 5 letters long and combine them all into
one big string.
(check-expect (cram-small (list "cat" "goose" "bear" "dolphin")) "catbear")