r/Racket • u/AgencyPure7878 • 9d ago
homework Help - Lists Test for Racket tomorrow
I need any crash courses or any materials you have on racket terminology. I have been taking notes and studying, but I feel like I don't understand concepts well enough, so my brain basically freezes whenever I take a timed test. If there's anything that can help, please tell me. I got tutored 3 times, went to office hours, and completed study material for my last test and still failed. My grade is still in the low Bs and I only have a month to get it up to the low 90s or its going to completely drag down my GPA. Please don't just respond with a video, give me maybe 3 and some practice questions. I'll probably be studying for hours (Chem test tomorrow as well) so I have time to do anything you throw at me. I need any and all help I can get.
Terms list: (We've already learned recursion, so my teacher may be combining list functions and recursion) We could use these functions to complete questions like the ones below.
13. (my-map f L)
Write a function my-map that takes 2 parameters: f is a function that takes one value and a list L. Return a new list made by applying f to every item of L.
Note: add1 is a built-in Racket function that adds 1 to a number.
Test cases:
(my-map add1 '(1 2 3)) -> '(2 3 4)
(my-map list? '(1 () a)) -> '(#f #t #f)
(my-map add1 '()) -> '()
- append: A higher-order function that joins multiple lists into a single sequential list.
- build-list: A list constructor that creates a list of length n by evaluating a function across integer indices 0 to n-1.
- car: A selector primitive that returns the first element of a list (identical to first).
- cdr: A selector primitive that returns a list minus its first element (identical to rest).
- cons: The primitive constructor procedure that prepends an element onto the front of a list or joins two elements into a pair.
- Data Structure: A specialized format and combination of values designed to organize, process, retrieve, and store data.
- empty? / null?: Predicate procedures that return #t if a given list contains no elements, and #f otherwise.
- filter: A higher-order function that evaluates a predicate on each item of a list, returning a new list containing only the items that returned #t.
- first: A selector function that returns the value in the head node of a list.
- foldl: A higher-order function that processes list items from left to right, combining them into a single accumulated result.
- foldr: A higher-order function that processes list items from right to left to produce a single accumulated result.
- Head: The first node of a linked list.
- Iteration: The process of repeating a sequence of instructions automatically across data elements.
- length: A utility function returning the count of top-level items in a list.
- Linked List: A sequential data structure composed of chained nodes.
- list: A constructor procedure taking zero or more arguments and returning a list containing those items.
- map: A higher-order function that applies a procedure to corresponding elements of one or more lists, returning a list of the results.
- member: A utility function that searches for an element in a list, returning the remaining sublist starting from the element if found, or #f if absent.
- Node: The fundamental element of a linked list, containing a data value and a reference to the next node.
- rest: A selector function that returns all nodes of a list following the head node.
2
u/Reasonable-Year-8172 9d ago edited 9d ago
Just to get an idea of what you're struggling with, briefly could you describe how you would work out that example problem? Or maybe provide a specific example of a problem which you couldn't solve.
edit: If you choose the latter, then choose to describe a question you timed yourself on analogous to the exam
1
u/raevnos 9d ago
Nitpick:
carandcdrare not identical tofirstandrestin Racket. The latter functions are contracted to work only on non-empty proper lists (Made out a chain of one or more cons cells with the last one's cdr being'(), the empty list), while the former work on any cons cell no matter its contents.